2011-11-28 09:25:00 -05:00
|
|
|
ifndef O
|
|
|
|
O:=-O3
|
|
|
|
endif
|
|
|
|
|
2011-08-05 08:25:00 -04:00
|
|
|
ifndef CPU
|
|
|
|
CPU=x86
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CPU),x86)
|
2011-09-08 05:10:41 -04:00
|
|
|
BUILDID=x86
|
|
|
|
X86FAMILY=1
|
2011-08-05 08:25:00 -04:00
|
|
|
CPUDEFINES=-DPLATFORM_X86
|
|
|
|
CPUFLAGS=-m32
|
|
|
|
CPULDFLAGS=-melf_i386
|
|
|
|
CPUASFLAGS=-32
|
|
|
|
CPUNASMFLAGS=-felf32
|
|
|
|
CPUOBJS=$(CPU)/boot.o $(CPU)/base.o $(CPU)/x86.o
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CPU),x64)
|
2011-09-08 05:10:41 -04:00
|
|
|
BUILDID=x64
|
|
|
|
X86FAMILY=1
|
2011-08-05 08:25:00 -04:00
|
|
|
CPUDEFINES=-DPLATFORM_X64
|
|
|
|
CPUFLAGS=-m64 -ffreestanding -mcmodel=large -mno-red-zone
|
|
|
|
CPULDFLAGS=-melf64-little -z max-page-size=0x1000
|
|
|
|
CPUASFLAGS=-64
|
|
|
|
CPUNASMFLAGS=-felf64
|
|
|
|
CPUOBJS=$(CPU)/base.o $(CPU)/x64.o
|
|
|
|
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 \
|
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-02-11 12:50:12 -05:00
|
|
|
DEFINES:=-DSORTIX_KERNEL -U_GNU_SOURCE $(CPUDEFINES)
|
2011-09-08 05:10:41 -04:00
|
|
|
ifeq ($(JSSORTIX),1)
|
|
|
|
DEFINES:=$(DEFINES) -DPLATFORM_SERIAL -DJSSORTIX
|
|
|
|
BUILDID:=$(BUILDID)-js
|
|
|
|
endif
|
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-03-21 19:52:29 -04:00
|
|
|
INCLUDES=-I. -Iinclude -I../libmaxsi/preproc
|
2012-02-13 07:16:43 -05:00
|
|
|
CPPFLAGS=$(INCLUDES) $(DEFINES)
|
|
|
|
FLAGSRELEASE=-s $(O)
|
|
|
|
FLAGSDEBUG=
|
|
|
|
FLAGS=$(CPUFLAGS) -Wall -Wall -Wextra -nostdlib -fno-builtin -nostartfiles \
|
|
|
|
-nodefaultlibs -fno-stack-protector $(FLAGSRELEASE)
|
|
|
|
CFLAGS=$(FLAGS)
|
|
|
|
CXXFLAGS=$(FLAGS) -std=gnu++0x -fno-exceptions -fno-rtti
|
|
|
|
ASFLAGS=$(CPUASFLAGS)
|
|
|
|
NASMFLAGS=$(CPUNASMFLAGS)
|
|
|
|
|
|
|
|
STATICLIBS=\
|
|
|
|
../libmaxsi/libmaxsi-sortix.a \
|
|
|
|
|
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) \
|
|
|
|
kernel.o \
|
2011-09-07 12:45:07 -04:00
|
|
|
interrupt.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
time.o \
|
|
|
|
log.o \
|
2012-01-18 16:06:10 -05:00
|
|
|
utf8.o \
|
2012-03-21 12:19:26 -04:00
|
|
|
memorymanagement.o \
|
2012-03-02 08:08:25 -05:00
|
|
|
calltrace.o \
|
|
|
|
$(CPU)/calltrace.o \
|
2012-05-04 07:13:44 -04:00
|
|
|
kthread.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
panic.o \
|
|
|
|
keyboard.o \
|
2012-01-07 15:09:01 -05:00
|
|
|
kb/ps2.o \
|
|
|
|
kb/layout/us.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
scheduler.o \
|
|
|
|
syscall.o \
|
|
|
|
sound.o \
|
|
|
|
pci.o \
|
2012-03-17 10:18:03 -04:00
|
|
|
com.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
uart.o \
|
2012-01-22 10:48:57 -05:00
|
|
|
terminal.o \
|
2012-02-09 17:54:24 -05:00
|
|
|
linebuffer.o \
|
2012-02-09 17:55:03 -05:00
|
|
|
logterminal.o \
|
2012-07-22 18:01:12 -04:00
|
|
|
textterminal.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
serialterminal.o \
|
2012-07-22 18:01:12 -04:00
|
|
|
textbuffer.o \
|
|
|
|
vgatextbuffer.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
descriptors.o \
|
|
|
|
device.o \
|
2012-02-21 14:12:52 -05:00
|
|
|
refcount.o \
|
2012-05-01 20:43:55 -04:00
|
|
|
video.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
vga.o \
|
2012-03-07 12:04:59 -05:00
|
|
|
kernelinfo.o \
|
2011-09-06 13:51:47 -04:00
|
|
|
elf.o \
|
|
|
|
process.o \
|
|
|
|
initrd.o \
|
2011-11-07 08:36:35 -05:00
|
|
|
thread.o \
|
2012-01-18 11:10:44 -05:00
|
|
|
event.o \
|
2011-11-16 02:37:29 -05:00
|
|
|
io.o \
|
|
|
|
pipe.o \
|
2011-11-17 17:31:41 -05:00
|
|
|
filesystem.o \
|
2011-11-20 18:02:53 -05:00
|
|
|
directory.o \
|
2011-11-17 17:31:41 -05:00
|
|
|
mount.o \
|
2011-09-15 16:38:40 -04:00
|
|
|
signal.o \
|
2012-05-27 08:31:09 -04:00
|
|
|
fs/util.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-01-08 08:20:39 -05:00
|
|
|
ata.o \
|
2012-02-13 07:16:43 -05:00
|
|
|
$(STATICLIBS) \
|
|
|
|
end.o # Must be last, determines kernel size.
|
2011-09-06 13:51:47 -04:00
|
|
|
|
2011-08-05 08:25:00 -04:00
|
|
|
JSOBJS:=$(subst .o,-js.o,$(OBJS))
|
|
|
|
|
|
|
|
all: sortix.bin
|
|
|
|
|
|
|
|
# jssortix compilation
|
|
|
|
|
|
|
|
jssortix: jssortix.bin
|
|
|
|
|
2011-09-08 05:10:41 -04:00
|
|
|
sortix-x86-js.tmp: $(OBJS)
|
|
|
|
ld -melf_i386 -Ttext 100000 -o sortix-x86-js-internal.out $(OBJS)
|
|
|
|
objcopy -O binary sortix-x86-js-internal.out $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
# x64 compilation
|
|
|
|
x64/boot.o: x64/boot.s
|
2011-12-01 17:05:08 -05:00
|
|
|
as -64 $< -o $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
sortix-x64.tmp: $(OBJS) x64/boot.o
|
2011-12-01 17:05:08 -05:00
|
|
|
ld -N -melf_x86_64 -Ttext 100000 -o sortix-x64-internal.out x64/boot.o $(OBJS)
|
|
|
|
objcopy sortix-x64-internal.out -O elf32-i386 sortix-x64.tmp
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
# x86 compilation
|
|
|
|
|
|
|
|
sortix-x86.tmp: $(OBJS)
|
|
|
|
ld -melf_i386 -Ttext 100000 -o $@ $(OBJS)
|
|
|
|
|
|
|
|
# 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-02-13 07:16:43 -05:00
|
|
|
g++ -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS)
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
%.o: %.s
|
2012-02-13 07:16:43 -05:00
|
|
|
as $(ASFLAGS) $< -o $@
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
%.o: %.asm
|
2012-02-13 07:16:43 -05:00
|
|
|
nasm $(NASMFLAGS) $< -o $@
|
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
|
|
|
|
install:
|
2012-03-21 19:52:29 -04:00
|
|
|
for DIR in $(HEADERDIRS); do \
|
|
|
|
mkdir -p $(SYSROOT)/usr/$$DIR; \
|
|
|
|
done
|
|
|
|
for FILE in $(HEADERS); do \
|
|
|
|
cp $$FILE $(SYSROOT)/usr/$$FILE; \
|
2012-03-04 10:04:12 -05:00
|
|
|
done
|
2011-08-05 08:25:00 -04:00
|
|
|
|