2013-03-19 18:28:32 -04:00
|
|
|
SOFTWARE_MEANT_FOR_SORTIX=1
|
2012-09-10 17:36:15 -04:00
|
|
|
include ../compiler.mak
|
|
|
|
include ../version.mak
|
|
|
|
include ../dirs.mak
|
2011-11-28 09:25:00 -05:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
# Default values in case the user doesn't override these variables.
|
|
|
|
OPTLEVEL?=-g -O2
|
|
|
|
CALLTRACE?=0
|
|
|
|
DISKWRITE?=0
|
|
|
|
ASLFAGS?=
|
|
|
|
CPPFLAGS?=
|
|
|
|
CXXFLAGS?=$(OPTLEVEL)
|
|
|
|
|
|
|
|
# Base compiler options and definitions.
|
|
|
|
|
|
|
|
CPPFLAGS:=$(CPPFLAGS) -I. -Iinclude -DSORTIX_KERNEL
|
|
|
|
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -ffreestanding -fbuiltin -std=gnu++11 \
|
|
|
|
-fno-exceptions -fno-rtti
|
|
|
|
|
|
|
|
ifeq ($(PANIC_SHORT),1)
|
|
|
|
CPPFLAGS:=$(CPPFLAGS) -DPANIC_SHORT
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
2013-03-19 18:28:32 -04:00
|
|
|
CPPFLAGS:=$(CPPFLAGS) -DENABLE_DISKWRITE=$(DISKWRITE)
|
|
|
|
CPPFLAGS:=$(CPPFLAGS) -DENABLE_CALLTRACE=$(CALLTRACE)
|
|
|
|
ifdef VERSION
|
|
|
|
CPPFLAGS:=$(CPPFLAGS) -DVERSIONSTR=\"$(VERSION)\"
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Architecture-dependent options and definitions.
|
|
|
|
|
|
|
|
BOOTOBJS:=
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
ifeq ($(CPU),x86)
|
2013-03-19 18:28:32 -04:00
|
|
|
X86FAMILY:=1
|
2012-09-10 17:36:15 -04:00
|
|
|
CPUOBJS:=$(CPU)/boot.o $(CPU)/base.o $(CPU)/x86.o
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CPU),x64)
|
2013-03-19 18:28:32 -04:00
|
|
|
X86FAMILY:=1
|
|
|
|
CXXFLAGS:=$(CXXFLAGS) -mno-red-zone
|
|
|
|
CPUOBJS:=$(CPU)/boot.o $(CPU)/base.o $(CPU)/x64.o
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef X86FAMILY
|
|
|
|
CPUOBJS:=$(CPUOBJS) \
|
2011-10-02 09:58:08 -04:00
|
|
|
$(CPU)/memorymanagement.o \
|
|
|
|
x86-family/memorymanagement.o \
|
2011-08-05 08:25:00 -04:00
|
|
|
$(CPU)/interrupt.o \
|
2011-08-12 11:17:02 -04:00
|
|
|
$(CPU)/gdt.o \
|
2012-02-29 18:15:28 -05:00
|
|
|
x86-family/gdt.o \
|
|
|
|
$(CPU)/idt.o \
|
|
|
|
x86-family/idt.o \
|
2011-10-26 18:05:20 -04:00
|
|
|
$(CPU)/syscall.o \
|
2011-09-21 14:52:29 -04:00
|
|
|
$(CPU)/thread.o \
|
|
|
|
$(CPU)/scheduler.o \
|
2011-11-28 19:21:59 -05:00
|
|
|
$(CPU)/process.o \
|
2013-10-13 17:56:58 -04:00
|
|
|
x86-family/time.o \
|
2012-06-30 18:50:27 -04:00
|
|
|
x86-family/msr.o \
|
2012-08-04 18:06:17 -04:00
|
|
|
x86-family/float.o \
|
2011-08-12 11:17:02 -04:00
|
|
|
x86-family/x86-family.o
|
2013-03-19 18:28:32 -04:00
|
|
|
# TODO: Are these -m flags even needed in the first place?
|
|
|
|
CXXFLAGS:=$(CXXFLAGS) -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
# Object files that constitute the kernel.
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
LIBS=\
|
|
|
|
-nostdlib \
|
2012-09-23 08:04:53 -04:00
|
|
|
-lc-sortix \
|
2012-09-28 17:37:32 -04:00
|
|
|
-lgcc \
|
2012-02-13 07:16:43 -05:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
OBJS=\
|
|
|
|
$(CPUOBJS) \
|
2013-02-09 12:32:45 -05:00
|
|
|
addralloc.o \
|
2013-05-11 19:24:42 -04:00
|
|
|
alarm.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
ata.o \
|
|
|
|
bga.o \
|
2012-03-02 08:08:25 -05:00
|
|
|
calltrace.o \
|
2013-10-13 17:56:58 -04:00
|
|
|
clock.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
com.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
copy.o \
|
2012-03-02 08:08:25 -05:00
|
|
|
$(CPU)/calltrace.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
$(CPU)/kthread.o \
|
|
|
|
crc32.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
descriptor.o \
|
2012-12-15 20:10:19 -05:00
|
|
|
dispmsg.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
dtable.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
elf.o \
|
2013-03-12 09:24:31 -04:00
|
|
|
fcache.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
fsfunc.o \
|
|
|
|
fs/kram.o \
|
2013-01-30 14:33:13 -05:00
|
|
|
fs/user.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
fs/util.o \
|
2013-01-12 20:37:14 -05:00
|
|
|
identity.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
initrd.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
inode.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
interlock.o \
|
|
|
|
interrupt.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
ioctx.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
io.o \
|
|
|
|
kb/layout/us.o \
|
|
|
|
kb/ps2.o \
|
|
|
|
kernelinfo.o \
|
|
|
|
kernel.o \
|
|
|
|
kthread.o \
|
|
|
|
lfbtextbuffer.o \
|
|
|
|
linebuffer.o \
|
|
|
|
log.o \
|
|
|
|
logterminal.o \
|
|
|
|
memorymanagement.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
mtable.o \
|
2013-04-23 17:53:16 -04:00
|
|
|
net/fs.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
panic.o \
|
|
|
|
pci.o \
|
|
|
|
pipe.o \
|
2012-12-29 17:09:09 -05:00
|
|
|
poll.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
process.o \
|
|
|
|
refcount.o \
|
|
|
|
scheduler.o \
|
|
|
|
serialterminal.o \
|
|
|
|
signal.o \
|
|
|
|
sound.o \
|
|
|
|
string.o \
|
|
|
|
syscall.o \
|
|
|
|
textbuffer.o \
|
|
|
|
textterminal.o \
|
|
|
|
thread.o \
|
|
|
|
time.o \
|
2013-10-13 17:56:58 -04:00
|
|
|
timer.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
uart.o \
|
2013-10-13 17:56:58 -04:00
|
|
|
user-timer.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
utf8.o \
|
|
|
|
vga.o \
|
|
|
|
vgatextbuffer.o \
|
|
|
|
video.o \
|
2012-08-07 18:19:44 -04:00
|
|
|
vnode.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
worker.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
ALLOBJS=\
|
|
|
|
$(OBJS) \
|
|
|
|
end.o
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
# Rules and recipes for building the kernel.
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
all: kernel
|
|
|
|
|
|
|
|
kernel: sortix.bin
|
|
|
|
|
|
|
|
.PHONY: all kernel headers clean install install-include-dirs install-headers \
|
|
|
|
install-kernel install-kernel-binary
|
2012-09-10 15:45:38 -04:00
|
|
|
|
|
|
|
headers:
|
|
|
|
|
2011-08-05 08:25:00 -04:00
|
|
|
# x64 compilation
|
2013-03-19 18:28:32 -04:00
|
|
|
ifeq ($(CPU),x64)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
sortix-x86_64.bin: $(ALLOBJS)
|
|
|
|
$(HOSTCXX) $(CXXFLAGS) -Wl,-Ttext -Wl,100000 -Wl,-z -Wl,max-page-size=0x1000 $(OBJS) $(LIBS) end.o -o $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
sortix.bin: sortix-x86_64.bin
|
|
|
|
$(HOSTOBJCOPY) $< -O elf32-i386-sortix $@
|
|
|
|
|
|
|
|
endif
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
# x86 compilation
|
|
|
|
ifeq ($(CPU),x86)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
sortix.bin: $(ALLOBJS)
|
|
|
|
$(HOSTCXX) $(CXXFLAGS) -Wl,-Ttext -Wl,100000 $(OBJS) $(LIBS) end.o -o $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
endif
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
%.o: %.cpp
|
2012-09-10 17:36:15 -04:00
|
|
|
$(HOSTCXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
%.o: %.s
|
2012-09-10 17:36:15 -04:00
|
|
|
$(HOSTAS) $< -o $@ $(ASFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
clean:
|
2013-03-19 18:28:32 -04:00
|
|
|
rm -f $(ALLOBJS) sortix.bin
|
|
|
|
rm -f $(wildcard *.bin) $(wildcard *.out) $(wildcard *.tmp)
|
|
|
|
rm -f $(wildcard *.o) $(wildcard */*.o) $(wildcard */*/*.o)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2011-09-15 16:38:40 -04:00
|
|
|
# Installation into sysroot
|
2012-09-10 17:36:15 -04:00
|
|
|
install: install-headers install-kernel
|
2012-09-10 15:45:38 -04:00
|
|
|
|
|
|
|
install-include-dirs: headers
|
2013-03-19 18:28:32 -04:00
|
|
|
mkdir -p $(DESTDIR)$(INCLUDEDIR)
|
2012-09-10 15:45:38 -04:00
|
|
|
|
|
|
|
install-headers: install-include-dirs headers
|
2013-03-19 18:28:32 -04:00
|
|
|
cp -RTv include $(DESTDIR)$(INCLUDEDIR)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
install-kernel: install-kernel-binary
|
|
|
|
|
2013-03-19 18:28:32 -04:00
|
|
|
install-kernel-binary: sortix.bin
|
|
|
|
mkdir -p $(DESTDIR)$(BOOTDIR)/$(HOST)
|
|
|
|
cp sortix.bin $(DESTDIR)$(BOOTDIR)/$(HOST)
|
2012-09-10 17:36:15 -04:00
|
|
|
|