X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=Makefile;h=1a2f7341865eb90a822bccce0edae32380f29789;hb=d1e8a437c1fab4535f82c4c214ec3330ac32e48d;hp=d03487663b0f0945c2dd1fff40fe4e359fac05a3;hpb=e5b5905eb3134a409638a5a20462000ef159e1e6;p=bootcensus diff --git a/Makefile b/Makefile index d034876..1a2f734 100644 --- a/Makefile +++ b/Makefile @@ -6,12 +6,14 @@ elf = test bin = test.bin warn = -pedantic -Wall +#opt = -O2 dbg = -g inc = -Isrc -Isrc/libc +gccopt = -fno-pic -ffreestanding -nostdinc -fno-builtin -CFLAGS = $(ccarch) $(warn) $(dbg) -nostdinc -fno-builtin $(inc) $(def) -ASFLAGS = $(asarch) $(dbg) -nostdinc -fno-builtin $(inc) -LDFLAGS = $(ldarch) -T pcboot.ld -print-gc-sections +CFLAGS = $(ccarch) -march=i386 $(warn) $(opt) $(dbg) $(gccopt) $(inc) $(def) +ASFLAGS = $(asarch) -march=i386 $(dbg) -nostdinc -fno-builtin $(inc) +LDFLAGS = $(ldarch) -nostdlib -T pcboot.ld -print-gc-sections ifneq ($(shell uname -m), i386) @@ -20,8 +22,20 @@ ifneq ($(shell uname -m), i386) ldarch = -m elf_i386 endif +floppy.img: boot.img + dd if=/dev/zero of=$@ bs=512 count=2880 + dd if=$< of=$@ conv=notrunc + +boot.img: bootldr.bin $(bin) + cat bootldr.bin $(bin) >$@ + +# bootldr.bin will contain only .boot and .boot2 +bootldr.bin: $(elf) + objcopy -O binary -j '.boot*' $< $@ + +# the main binary will contain every section *except* .boot and .boot2 $(bin): $(elf) - objcopy -O binary $< $@ + objcopy -O binary -R '.boot*' $< $@ $(elf): $(obj) $(LD) -o $@ $(obj) -Map link.map $(LDFLAGS) @@ -33,12 +47,31 @@ $(elf): $(obj) .PHONY: clean clean: - rm -f $(obj) $(bin) + rm -f $(obj) $(bin) boot.img floppy.img link.map .PHONY: cleandep cleandep: rm -f $(dep) +.PHONY: disasm +disasm: bootldr.disasm $(elf).disasm + +bootldr.disasm: $(elf) + objdump -d $< -j .boot -j .boot2 -m i8086 >$@ + +$(elf).disasm: $(elf) + objdump -d $< -j .startup -j .text -m i386 >$@ + +$(elf).sym: $(elf) + objcopy --only-keep-debug $< $@ + .PHONY: run run: $(bin) - qemu-system-i386 -fda $(bin) + qemu-system-i386 -fda floppy.img -serial file:serial.log + +.PHONY: debug +debug: $(bin) $(elf).sym + qemu-system-i386 -fda floppy.img -serial file:serial.log -s -S + +.PHONY: sym +sym: $(elf).sym