1 # Legacy Bios build system
3 # Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
5 # This file may be distributed under the terms of the GNU GPLv3 license.
11 SRC16=floppy.c disk.c system.c clock.c serial.c kbd.c output.c boot.c
14 # Default compiler flags (note -march=armv4 is needed for 16 bit insns)
15 CFLAGS = -Wall -Os -MD -m32 -march=i386 -mregparm=2 -ffreestanding
16 CFLAGS16 = -Wall -Os -MD -m32 -DMODE16 -march=i386 -mregparm=2 -ffreestanding -fno-jump-tables
18 all: $(OUT) $(OUT)rom.bin
20 # Run with "make V=1" to see the actual compile commands
32 ################ Build rules
33 $(OUT)%.proc.16.s: $(OUT)%.16.s
34 @echo " Moving data sections to text in $<"
35 $(Q)sed 's/\t.section\t.rodata.*// ; s/\t.data//' < $< > $@
38 @echo " Generating assembler for $<"
39 $(Q)$(CC) $(CFLAGS16) -fwhole-program -S -combine -c $< -o $@
42 @echo " Precompiling $<"
43 $(Q)$(CPP) -P $< -o $@
45 $(OUT)%.bin: $(OUT)%.o
46 @echo " Extracting binary $@"
47 $(Q)objcopy -O binary $< $@
49 $(OUT)%.offset.auto.h: $(OUT)%.o
50 @echo " Generating symbol offset header $@"
51 $(Q)nm $< | ./tools/defsyms.py > $@
54 @echo " Generating whole program assembler $@"
55 $(Q)$(CC) $(CFLAGS16) -fwhole-program -S -combine -c $(addprefix src/, $(SRC16)) -o $@
57 $(OUT)romlayout16.o: romlayout.S $(OUT)blob.proc.16.s $(OUT)font.proc.16.s $(OUT)cbt.proc.16.s
58 @echo " Generating 16bit layout of $@"
59 $(Q)$(CC) $(CFLAGS16) -c $< -o $@
61 $(OUT)rom16.o: $(OUT)romlayout16.o
63 $(Q)ld -melf_i386 -Ttext 0 $< -o $@
65 $(OUT)rom16.bin: $(OUT)rom16.o
66 @echo " Extracting binary $@"
67 $(Q)objcopy -O binary $< $@
69 $(OUT)romlayout32.o: $(OUT)rom16.offset.auto.h
70 @echo " Compiling whole program $@"
71 $(Q)$(CC) $(CFLAGS) -fwhole-program -combine -c $(addprefix src/, $(SRC32)) -o $@
73 $(OUT)rom32.o: $(OUT)romlayout32.o $(OUT)rombios32.lds
75 $(Q)ld -T $(OUT)rombios32.lds $< -o $@
77 $(OUT)rom.bin: $(OUT)rom16.bin $(OUT)rom32.bin $(OUT)rom16.offset.auto.h $(OUT)rom32.offset.auto.h
79 $(Q)./tools/buildrom.py