1 csrc = $(wildcard src/*.c) $(wildcard src/libc/*.c) $(wildcard src/test/*.c)
2 ssrc = $(wildcard src/*.s) $(wildcard src/libc/*.s) $(wildcard src/boot/*.s)
3 Ssrc = $(wildcard src/*.S)
4 obj = $(csrc:.c=.o) $(ssrc:.s=.o) $(Ssrc:.S=.o)
12 inc = -Isrc -Isrc/libc -Isrc/test
13 gccopt = -fno-pic -ffreestanding -nostdinc -fno-builtin
15 CFLAGS = $(ccarch) -march=i386 $(warn) $(opt) $(dbg) $(gccopt) $(inc) $(def)
16 ASFLAGS = $(asarch) -march=i386 $(dbg) -nostdinc -fno-builtin $(inc)
17 LDFLAGS = $(ldarch) -nostdlib -T pcboot.ld -print-gc-sections
20 ifneq ($(shell uname -m), i386)
27 dd if=/dev/zero of=$@ bs=512 count=2880
28 dd if=$< of=$@ conv=notrunc
30 boot.img: bootldr.bin $(bin)
31 cat bootldr.bin $(bin) >$@
33 # bootldr.bin will contain only .boot and .boot2
35 objcopy -O binary -j '.boot*' $< $@
37 # the main binary will contain every section *except* .boot and .boot2
39 objcopy -O binary -R '.boot*' $< $@
42 $(LD) -o $@ $(obj) -Map link.map $(LDFLAGS)
45 $(CC) -o $@ $(CFLAGS) -c $<
50 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
54 rm -f $(obj) $(bin) boot.img floppy.img link.map
61 disasm: bootldr.disasm $(elf).disasm
63 bootldr.disasm: $(elf)
64 objdump -d $< -j .boot -j .boot2 -m i8086 >$@
67 objdump -d $< -j .startup -j .text -m i386 >$@
70 objcopy --only-keep-debug $< $@
74 qemu-system-i386 -fda floppy.img -serial file:serial.log
77 debug: $(bin) $(elf).sym
78 qemu-system-i386 -fda floppy.img -serial file:serial.log -s -S