2009-05-14 21:31:47 +03:00
|
|
|
load = 0x80000000
|
2009-05-11 01:28:12 +03:00
|
|
|
|
2009-05-19 00:18:23 +03:00
|
|
|
CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -nostdinc -DNUM_THREADS=0
|
2009-05-11 01:28:12 +03:00
|
|
|
CPPFLAGS = -O5 -Wa,-mips32
|
|
|
|
CROSS = mipsel-linux-gnu-
|
|
|
|
CC = $(CROSS)gcc
|
|
|
|
LD = $(CROSS)ld
|
|
|
|
OBJCOPY = $(CROSS)objcopy
|
|
|
|
OBJDUMP = $(CROSS)objdump
|
|
|
|
|
2009-05-20 23:07:56 +03:00
|
|
|
kernel_sources = interrupts.cc panic.cc data.cc test.cc alloc.cc memory.cc arch.cc invoke.cc schedule.cc
|
2009-05-14 21:31:47 +03:00
|
|
|
boot_sources = init.cc
|
|
|
|
BUILT_SOURCES = $(kernel_sources) $(boot_sources)
|
2009-05-11 01:28:12 +03:00
|
|
|
|
|
|
|
PYPP = /usr/bin/pypp
|
|
|
|
%.cc: %.ccp kernel.hh
|
|
|
|
$(PYPP) --name $< < $< > $@
|
|
|
|
%.hh: %.hhp
|
|
|
|
$(PYPP) --name $< < $< > $@
|
|
|
|
|
|
|
|
# Transform ':' into ';' so vim doesn't think there are errors.
|
2009-05-14 21:31:47 +03:00
|
|
|
uimage: all.raw Makefile
|
|
|
|
mkimage -A MIPS -O Linux -C none -a $(load) -e 0x$(shell /bin/sh -c '$(OBJDUMP) -t all | grep __start$$ | cut -b-8') -n "Shevek's kernel" -d $< $@ | sed -e 's/:/;/g'
|
2009-05-11 01:28:12 +03:00
|
|
|
|
2009-05-20 23:07:56 +03:00
|
|
|
arch.%: mips.%
|
2009-05-19 00:18:23 +03:00
|
|
|
ln -s $< $@ || true
|
2009-05-18 10:30:27 +03:00
|
|
|
|
|
|
|
%.o:%.cc Makefile kernel.hh arch.hh
|
2009-05-11 01:28:12 +03:00
|
|
|
$(CC) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
%.o:%.S Makefile
|
|
|
|
$(CC) $(CPPFLAGS) -DKERNEL_STACK_SIZE=0x2000 -c $< -o $@
|
|
|
|
|
2009-05-14 21:31:47 +03:00
|
|
|
# entry.o must be the first file. boot.o must be the first of the init objects (which can be dumped after loading).
|
|
|
|
all: entry.o $(subst .cc,.o,$(kernel_sources)) boot.o $(subst .cc,.o,$(boot_sources))
|
2009-05-11 01:28:12 +03:00
|
|
|
$(LD) --omagic -Ttext $(load) $^ -o $@
|
|
|
|
|
|
|
|
junk = mdebug.abi32 reginfo comment pdr
|
|
|
|
%.raw: %
|
|
|
|
$(OBJCOPY) -S $(addprefix --remove-section=.,$(junk)) -Obinary $< $@
|
|
|
|
|
|
|
|
%.gz: %
|
|
|
|
gzip < $< > $@
|
|
|
|
|
|
|
|
clean:
|
2009-05-18 10:30:27 +03:00
|
|
|
rm -f all uimage *.o all.raw.gz arch.hh
|
2009-05-11 01:28:12 +03:00
|
|
|
|
|
|
|
.PHONY: clean
|