sortix-mirror/kernel/Makefile

246 lines
4.9 KiB
Makefile
Raw Normal View History

SOFTWARE_MEANT_FOR_SORTIX=1
2014-06-28 14:10:20 +00:00
include ../build-aux/platform.mak
include ../build-aux/compiler.mak
include ../build-aux/version.mak
include ../build-aux/dirs.mak
# Default values in case the user doesn't override these variables.
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CPPFLAGS?=
CXXFLAGS?=$(OPTLEVEL)
# Base compiler options and definitions.
CPPFLAGS:=$(CPPFLAGS) -I. -Iinclude -D__is_sortix_kernel
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -ffreestanding -fbuiltin -std=gnu++11 \
-fno-exceptions -fno-rtti -fcheck-new
ifeq ($(PANIC_SHORT),1)
CPPFLAGS:=$(CPPFLAGS) -DPANIC_SHORT
2011-08-05 12:25:00 +00:00
endif
ifdef VERSION
CPPFLAGS:=$(CPPFLAGS) -DVERSIONSTR=\"$(VERSION)\"
endif
# Architecture-dependent options and definitions.
BOOTOBJS:=
2011-08-05 12:25:00 +00:00
ifeq ($(CPU),x86)
X86FAMILY:=1
CPUDIR:=$(CPU)
CPUOBJS:=$(CPUDIR)/boot.o
2011-08-05 12:25:00 +00:00
endif
ifeq ($(CPU),x64)
X86FAMILY:=1
CPUDIR:=$(CPU)
CXXFLAGS:=$(CXXFLAGS) -mno-red-zone -mno-mmx -mno-sse -mno-sse2
CPUOBJS:=$(CPUDIR)/boot.o
endif
ifndef CPUDIR
CPUDIR=.
2011-08-05 12:25:00 +00:00
endif
ifdef X86FAMILY
CPUOBJS:=$(CPUOBJS) \
$(CPUDIR)/memorymanagement.o \
x86-family/memorymanagement.o \
$(CPUDIR)/interrupt.o \
x86-family/interrupt.o \
2015-01-16 00:19:05 +00:00
x86-family/ioport.o \
x86-family/pic.o \
x86-family/gdt.o \
x86-family/idt.o \
$(CPUDIR)/syscall.o \
2013-05-15 20:04:18 +00:00
x86-family/cmos.o \
2013-10-13 21:56:58 +00:00
x86-family/time.o \
x86-family/pat.o \
x86-family/float.o \
2015-04-30 22:07:06 +00:00
x86-family/ps2.o \
2016-09-06 21:53:20 +00:00
x86-family/vbox.o \
x86-family/x86-family.o
2011-08-05 12:25:00 +00:00
endif
# Object files that constitute the kernel.
2011-08-05 12:25:00 +00:00
CRTI_OBJ=$(CPUDIR)/crti.o
CRTBEGIN_OBJ=$(shell $(CXX) $(CXXFLAGS) -print-file-name=crtbegin.o)
CRTEND_OBJ=$(shell $(CXX) $(CXXFLAGS) -print-file-name=crtend.o)
CRTN_OBJ=$(CPUDIR)/crtn.o
LIBS=\
-nostdlib \
2014-02-13 19:26:38 +00:00
-lk \
2012-09-28 21:37:32 +00:00
-lgcc \
2012-02-13 12:16:43 +00:00
OBJS=\
$(CPUOBJS) \
addralloc.o \
2013-05-11 23:24:42 +00:00
alarm.o \
2013-10-13 21:56:58 +00:00
clock.o \
2012-12-05 18:29:20 +00:00
com.o \
copy.o \
descriptor.o \
2013-05-27 21:55:49 +00:00
disk/ahci/ahci.o \
disk/ahci/hba.o \
disk/ahci/port.o \
2014-09-27 22:48:09 +00:00
disk/ata/ata.o \
disk/ata/hba.o \
disk/ata/port.o \
disk/node.o \
dnsconfig.o \
dtable.o \
2011-09-06 17:51:47 +00:00
elf.o \
2013-03-12 13:24:31 +00:00
fcache.o \
2013-11-02 21:46:55 +00:00
fs/full.o \
fsfunc.o \
fs/kram.o \
2013-10-29 00:03:57 +00:00
fs/null.o \
2015-05-10 21:09:59 +00:00
fs/random.o \
2013-01-30 19:33:13 +00:00
fs/user.o \
2012-12-05 18:29:20 +00:00
fs/util.o \
2013-11-02 21:37:17 +00:00
fs/zero.o \
2014-03-25 19:28:51 +00:00
gpu/bga/bga.o \
2014-10-05 13:02:50 +00:00
hostname.o \
2013-01-13 01:37:14 +00:00
identity.o \
2012-12-05 18:29:20 +00:00
initrd.o \
inode.o \
2012-12-05 18:29:20 +00:00
interlock.o \
interrupt.o \
ioctx.o \
2012-12-05 18:29:20 +00:00
io.o \
2014-04-22 12:02:04 +00:00
kb/kblayout.o \
2012-12-05 18:29:20 +00:00
kb/ps2.o \
kernelinfo.o \
kernel.o \
kthread.o \
lfbtextbuffer.o \
2016-02-28 11:11:02 +00:00
libk.o \
2012-12-05 18:29:20 +00:00
linebuffer.o \
log.o \
logterminal.o \
memorymanagement.o \
2015-04-30 23:21:35 +00:00
mouse/ps2.o \
mtable.o \
2013-04-23 21:53:16 +00:00
net/fs.o \
net/socket.o \
2013-03-18 13:22:17 +00:00
op-new.o \
2012-12-05 18:29:20 +00:00
panic.o \
2013-06-01 11:24:27 +00:00
partition.o \
pci-mmio.o \
2012-12-05 18:29:20 +00:00
pci.o \
pipe.o \
2012-12-29 22:09:09 +00:00
poll.o \
2012-12-05 18:29:20 +00:00
process.o \
2015-07-30 23:20:39 +00:00
psctl.o \
ptable.o \
pty.o \
2014-07-14 21:24:43 +00:00
random.o \
2012-12-05 18:29:20 +00:00
refcount.o \
registers.o \
2013-08-30 15:35:30 +00:00
resource.o \
2012-12-05 18:29:20 +00:00
scheduler.o \
2013-08-20 00:23:53 +00:00
segment.o \
2012-12-05 18:29:20 +00:00
signal.o \
sockopt.o \
2012-12-05 18:29:20 +00:00
string.o \
syscall.o \
textbuffer.o \
textterminal.o \
thread.o \
time.o \
2013-10-13 21:56:58 +00:00
timer.o \
tty.o \
2012-12-05 18:29:20 +00:00
uart.o \
2013-10-13 21:56:58 +00:00
user-timer.o \
2012-12-05 18:29:20 +00:00
vga.o \
vgatextbuffer.o \
video.o \
vnode.o \
2012-12-05 18:29:20 +00:00
worker.o \
2011-09-06 17:51:47 +00:00
2012-09-10 21:36:15 +00:00
ALLOBJS=\
$(CRTI_OBJ) \
2012-09-10 21:36:15 +00:00
$(OBJS) \
$(CRTN_OBJ) \
2012-09-10 21:36:15 +00:00
end.o
2011-08-05 12:25:00 +00:00
# TODO: The .init section is linked at 128 MiB on i686 and at 4 MiB on x86_64
# which increases the memory requirement (and isn't mapped) and the _init
# function isn't invoked yet in the kernel anyway.
#LINK_OBJECTS=\
#$(CRTI_OBJ) $(CRTBEGIN_OBJ) $(OBJS) $(LIBS) $(CRTN_OBJ) $(CRTEND_OBJ) end.o
LINK_OBJECTS=$(OBJS) $(LIBS) end.o
# Rules and recipes for building the kernel.
2011-08-05 12:25:00 +00:00
all: kernel
kernel: sortix.bin
.PHONY: all kernel headers clean install install-include-dirs install-headers \
install-kernel install-kernel-binary
headers:
2011-08-05 12:25:00 +00:00
# x64 compilation
ifeq ($(CPU),x64)
2011-08-05 12:25:00 +00:00
sortix-x86_64.bin: $(ALLOBJS)
$(CXX) $(CXXFLAGS) -Wl,-Ttext -Wl,100000 -Wl,-z -Wl,max-page-size=0x1000 $(LINK_OBJECTS) -o $@
2011-08-05 12:25:00 +00:00
sortix.bin: sortix-x86_64.bin
$(OBJCOPY) $< -O elf32-i386-sortix $@
endif
2011-08-05 12:25:00 +00:00
# x86 compilation
ifeq ($(CPU),x86)
2011-08-05 12:25:00 +00:00
sortix.bin: $(ALLOBJS)
$(CXX) $(CXXFLAGS) -Wl,-Ttext -Wl,100000 $(LINK_OBJECTS) -o $@
2011-08-05 12:25:00 +00:00
endif
2011-08-05 12:25:00 +00:00
2014-04-22 12:02:04 +00:00
%: %.kblayout
kblayout-compiler --format=sortix-kblayout-1 --compression=none $< -o $@
# TODO: After releasing Sortix 1.1, change --identifier to -i.
2014-04-22 12:02:04 +00:00
kb/default-kblayout.h: kb/default-kblayout
carray -cgHs -t uint8_t -G SORTIX_KB_DEFAULT_KBLAYOUT_H --identifier=default_kblayout $< -o $@
2014-04-22 12:02:04 +00:00
vgafont.h: vgafont.f16
carray -gHs -t uint8_t -G VGAFONT_H --identifier=vgafont $< -o $@
*.cpp */*.cpp */*/*.cpp: | kb/default-kblayout.h vgafont.h
2014-04-22 12:02:04 +00:00
2011-08-05 12:25:00 +00:00
%.o: %.cpp
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
2011-08-05 12:25:00 +00:00
%.o: %.S
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
2011-08-05 12:25:00 +00:00
clean:
rm -f $(ALLOBJS) sortix.bin
2014-06-28 14:10:20 +00:00
rm -f *.bin *.out *.tmp
rm -f *.o */*.o */*/*.o
2014-04-22 12:02:04 +00:00
rm -f kb/default-kblayout kb/default-kblayout.h
rm -f vgafont.h
2011-08-05 12:25:00 +00:00
# Installation into sysroot
2012-09-10 21:36:15 +00:00
install: install-headers install-kernel
install-include-dirs: headers
mkdir -p $(DESTDIR)$(INCLUDEDIR)
install-headers: install-include-dirs headers
cp -RTv include $(DESTDIR)$(INCLUDEDIR)
2011-08-05 12:25:00 +00:00
2012-09-10 21:36:15 +00:00
install-kernel: install-kernel-binary
install-kernel-binary: sortix.bin
mkdir -p $(DESTDIR)$(BOOTDIR)
cp sortix.bin $(DESTDIR)$(BOOTDIR)/sortix.bin