blob: e747126b55b7b5f2b3671cee734f8c8edc3e355d [file] [log] [blame]
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05001# Legacy Bios build system
2#
3# Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
4#
5# This file may be distributed under the terms of the GNU GPLv3 license.
6
7# Output directory
8OUT=out/
9
10# Source files
Kevin O'Connor4b60c002008-02-25 22:29:55 -050011SRC16=floppy.c disk.c system.c clock.c serial.c kbd.c mouse.c output.c boot.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050012SRC32=post.c output.c
13
Kevin O'Connorbdce35f2008-02-26 21:33:14 -050014# Default compiler flags
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050015CFLAGS = -Wall -g -Os -MD -m32 -march=i386 -mregparm=2 -ffreestanding
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050016CFLAGS16 = -Wall -Os -MD -m32 -DMODE16 -march=i386 -mregparm=2 -ffreestanding -fno-jump-tables
17
18all: $(OUT) $(OUT)rom.bin
19
20# Run with "make V=1" to see the actual compile commands
21ifdef V
22Q=
23else
24Q=@
25endif
26
27.PHONY : all FORCE
28
29vpath %.c src
30vpath %.S src
31
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//' < $< > $@
36
37$(OUT)%.16.s: %.c
38 @echo " Generating assembler for $<"
Kevin O'Connorbdce35f2008-02-26 21:33:14 -050039 $(Q)$(CC) $(CFLAGS16) -fwhole-program -S -combine -c $< src/null.c -o $@
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050040
41$(OUT)%.lds: %.lds.S
42 @echo " Precompiling $<"
43 $(Q)$(CPP) -P $< -o $@
44
45$(OUT)%.bin: $(OUT)%.o
46 @echo " Extracting binary $@"
47 $(Q)objcopy -O binary $< $@
48
49$(OUT)%.offset.auto.h: $(OUT)%.o
50 @echo " Generating symbol offset header $@"
51 $(Q)nm $< | ./tools/defsyms.py > $@
52
53$(OUT)blob.16.s:
54 @echo " Generating whole program assembler $@"
55 $(Q)$(CC) $(CFLAGS16) -fwhole-program -S -combine -c $(addprefix src/, $(SRC16)) -o $@
56
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 $@
60
61$(OUT)rom16.o: $(OUT)romlayout16.o
62 @echo " Linking $@"
Kevin O'Connorbdce35f2008-02-26 21:33:14 -050063 $(Q)ld -melf_i386 -e post16 -Ttext 0 $< -o $@
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050064
65$(OUT)rom16.bin: $(OUT)rom16.o
66 @echo " Extracting binary $@"
67 $(Q)objcopy -O binary $< $@
68
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 $@
72
73$(OUT)rom32.o: $(OUT)romlayout32.o $(OUT)rombios32.lds
74 @echo " Linking $@"
75 $(Q)ld -T $(OUT)rombios32.lds $< -o $@
76
77$(OUT)rom.bin: $(OUT)rom16.bin $(OUT)rom32.bin $(OUT)rom16.offset.auto.h $(OUT)rom32.offset.auto.h
78 @echo " Building $@"
79 $(Q)./tools/buildrom.py
80
81####### Generic rules
82clean:
83 rm -rf $(OUT)
84
85$(OUT):
86 mkdir $@
87
88-include $(OUT)*.d