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
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
ifndef OPTLEVEL
|
|
|
|
OPTLEVEL:=-O2
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CPU),x86)
|
2011-09-08 05:10:41 -04:00
|
|
|
BUILDID=x86
|
|
|
|
X86FAMILY=1
|
2012-09-10 17:36:15 -04:00
|
|
|
CPUFLAGS=
|
|
|
|
CPULDFLAGS=
|
|
|
|
CPUOBJS:=$(CPU)/boot.o $(CPU)/base.o $(CPU)/x86.o
|
2011-08-05 08:25:00 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CPU),x64)
|
2011-09-08 05:10:41 -04:00
|
|
|
BUILDID=x64
|
|
|
|
X86FAMILY=1
|
2012-09-10 17:36:15 -04:00
|
|
|
CPUFLAGS=-ffreestanding -mno-red-zone
|
2012-09-28 17:37:32 -04:00
|
|
|
CPULDFLAGS=
|
2012-09-10 17:36:15 -04:00
|
|
|
CPUOBJS:=$(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 \
|
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
|
2011-08-05 08:25:00 -04:00
|
|
|
CPUFLAGS:=$(CPUFLAGS) -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow
|
|
|
|
endif
|
|
|
|
|
2012-01-07 15:09:01 -05:00
|
|
|
DIRS=. x64 x86 x86-family fs kb kb/layout
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
DEFINES:=-DSORTIX_KERNEL -U_GNU_SOURCE
|
2011-11-28 09:25:00 -05:00
|
|
|
ifeq ($(PANIC_SHORT),1)
|
|
|
|
DEFINES:=$(DEFINES) -DPANIC_SHORT
|
2012-03-02 08:08:25 -05:00
|
|
|
endif
|
2012-01-08 08:20:39 -05:00
|
|
|
ifeq ($(DISKWRITE),1)
|
|
|
|
DEFINES:=$(DEFINES) -DENABLE_DISKWRITE=1
|
|
|
|
else
|
|
|
|
DEFINES:=$(DEFINES) -DENABLE_DISKWRITE=0
|
2012-03-02 08:08:25 -05:00
|
|
|
endif
|
|
|
|
ifeq ($(CALLTRACE),1)
|
|
|
|
DEFINES:=$(DEFINES) -DENABLE_CALLTRACE=1
|
|
|
|
else
|
|
|
|
DEFINES:=$(DEFINES) -DENABLE_CALLTRACE=0
|
|
|
|
endif
|
2012-03-07 12:04:59 -05:00
|
|
|
ifdef VERSION
|
|
|
|
DEFINES:=$(DEFINES) -DVERSIONSTR=\"$(VERSION)\"
|
|
|
|
endif
|
2012-02-13 07:16:43 -05:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
INCLUDES=-I. -Iinclude
|
2012-02-13 07:16:43 -05:00
|
|
|
CPPFLAGS=$(INCLUDES) $(DEFINES)
|
2012-08-01 10:17:32 -04:00
|
|
|
ifeq ($(DEBUG_KERNEL),1)
|
|
|
|
FLAGSDEBUG=-g3
|
|
|
|
else
|
2012-09-10 17:36:15 -04:00
|
|
|
FLAGSDEBUG=$(OPTLEVEL)
|
2012-08-01 10:17:32 -04:00
|
|
|
endif
|
2012-09-10 17:36:15 -04:00
|
|
|
FLAGS=$(CPUFLAGS) -Wall -Wall -Wextra -nostdlib -nostartfiles \
|
2012-08-01 10:17:32 -04:00
|
|
|
-nodefaultlibs -fno-stack-protector $(FLAGSDEBUG)
|
2012-02-13 07:16:43 -05:00
|
|
|
CFLAGS=$(FLAGS)
|
|
|
|
CXXFLAGS=$(FLAGS) -std=gnu++0x -fno-exceptions -fno-rtti
|
2012-09-10 17:36:15 -04:00
|
|
|
ASFLAGS=
|
2012-02-13 07:16:43 -05:00
|
|
|
|
|
|
|
STATICLIBS=\
|
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
|
|
|
|
2012-03-21 19:52:29 -04:00
|
|
|
HEADERDIRS:=$(shell find include -type d)
|
|
|
|
HEADERS:=$(shell find include -type f)
|
2012-03-04 10:04:12 -05:00
|
|
|
|
2011-09-06 13:51:47 -04:00
|
|
|
OBJS=$(CPUOBJS) \
|
2012-12-05 13:29:20 -05:00
|
|
|
ata.o \
|
|
|
|
bga.o \
|
2012-03-02 08:08:25 -05:00
|
|
|
calltrace.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
com.o \
|
2012-03-02 08:08:25 -05:00
|
|
|
$(CPU)/calltrace.o \
|
2012-08-02 08:48:10 -04:00
|
|
|
$(CPU)/interlock.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
$(CPU)/kthread.o \
|
|
|
|
crc32.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
descriptors.o \
|
|
|
|
device.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
directory.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
elf.o \
|
2011-11-17 17:31:41 -05:00
|
|
|
filesystem.o \
|
2011-11-21 15:49:13 -05:00
|
|
|
fs/devfs.o \
|
2011-11-20 10:25:32 -05:00
|
|
|
fs/initfs.o \
|
2011-11-18 11:49:31 -05:00
|
|
|
fs/ramfs.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
fs/util.o \
|
2012-05-27 08:32:27 -04:00
|
|
|
fs/videofs.o \
|
2012-12-05 13:29:20 -05:00
|
|
|
initrd.o \
|
|
|
|
interlock.o \
|
|
|
|
interrupt.o \
|
|
|
|
io.o \
|
|
|
|
kb/layout/us.o \
|
|
|
|
kb/ps2.o \
|
|
|
|
kernelinfo.o \
|
|
|
|
kernel.o \
|
|
|
|
keyboard.o \
|
|
|
|
kthread.o \
|
|
|
|
lfbtextbuffer.o \
|
|
|
|
linebuffer.o \
|
|
|
|
log.o \
|
|
|
|
logterminal.o \
|
|
|
|
memorymanagement.o \
|
|
|
|
mount.o \
|
|
|
|
panic.o \
|
|
|
|
pci.o \
|
|
|
|
pipe.o \
|
|
|
|
process.o \
|
|
|
|
refcount.o \
|
|
|
|
scheduler.o \
|
|
|
|
serialterminal.o \
|
|
|
|
signal.o \
|
|
|
|
sound.o \
|
|
|
|
string.o \
|
|
|
|
syscall.o \
|
|
|
|
terminal.o \
|
|
|
|
textbuffer.o \
|
|
|
|
textterminal.o \
|
|
|
|
thread.o \
|
|
|
|
time.o \
|
|
|
|
uart.o \
|
|
|
|
utf8.o \
|
|
|
|
vga.o \
|
|
|
|
vgatextbuffer.o \
|
|
|
|
video.o \
|
|
|
|
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
|
|
|
|
|
|
|
all: sortix.bin
|
|
|
|
|
2012-09-10 15:45:38 -04:00
|
|
|
.PHONY: all headers clean install install-include-dirs install-headers
|
|
|
|
|
|
|
|
headers:
|
|
|
|
|
2011-08-05 08:25:00 -04:00
|
|
|
# x64 compilation
|
|
|
|
x64/boot.o: x64/boot.s
|
2012-09-10 17:36:15 -04:00
|
|
|
$(HOSTAS) -64 $< -o $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
sortix-x64.tmp: $(ALLOBJS) x64/boot.o
|
2012-09-28 17:37:32 -04:00
|
|
|
$(HOSTCXX) -nodefaultlibs -nostartfiles -Wl,-N -Wl,-melf_x86_64_sortix -Wl,-Ttext -Wl,100000 -Wl,-z -Wl,max-page-size=0x1000 -o sortix-x64-internal.out x64/boot.o $(OBJS) $(STATICLIBS) end.o
|
2012-09-10 17:36:15 -04:00
|
|
|
$(HOSTOBJCOPY) sortix-x64-internal.out -O elf32-i386 sortix-x64.tmp
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
# x86 compilation
|
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
sortix-x86.tmp: $(ALLOBJS)
|
2012-09-28 17:37:32 -04:00
|
|
|
$(HOSTCXX) -nodefaultlibs -nostartfiles -Wl,-melf_i386_sortix -Wl,-Ttext -Wl,100000 -o $@ $(OBJS) $(STATICLIBS) end.o
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
# general rules
|
|
|
|
|
2011-09-08 05:10:41 -04:00
|
|
|
sortix.bin: sortix-$(BUILDID).tmp
|
2011-08-05 08:25:00 -04:00
|
|
|
cp -vu $< $@
|
|
|
|
|
|
|
|
%.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:
|
2012-02-11 13:06:00 -05:00
|
|
|
for D in $(DIRS); do rm -f $$D/*.o $$D/*.bin $$D/*.out $$D/*.tmp; done
|
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
|
2012-09-10 17:36:15 -04:00
|
|
|
mkdir -p $(INSTALLINCLUDEDIR)
|
|
|
|
DIRS=$$(echo $(HEADERDIRS) | \
|
|
|
|
tr ' ' '\n' | \
|
|
|
|
sed 's/include\/*//'); \
|
|
|
|
for D in $$DIRS; do \
|
|
|
|
mkdir -p $(INSTALLINCLUDEDIR)/$$D || exit $?; \
|
2012-03-21 19:52:29 -04:00
|
|
|
done
|
2012-09-10 15:45:38 -04:00
|
|
|
|
|
|
|
install-headers: install-include-dirs headers
|
2012-09-10 17:36:15 -04:00
|
|
|
for SRC in $(HEADERS); do \
|
|
|
|
DEST=`echo $$SRC | sed 's/include\///'`; \
|
|
|
|
cp -P $$SRC $(INSTALLINCLUDEDIR)/$$DEST || exit $?; \
|
2012-03-04 10:04:12 -05:00
|
|
|
done
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-09-10 17:36:15 -04:00
|
|
|
install-kernel: install-kernel-binary
|
|
|
|
|
|
|
|
install-kernel-binary:
|
|
|
|
mkdir -p $(INSTALLBOOTDIR)/$(HOST)
|
|
|
|
cp -P sortix.bin $(INSTALLBOOTDIR)/$(HOST)
|
|
|
|
|