X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=Makefile;h=0722ce4d6f5a5cd0ea4dc8c0dd357e5bcc9cc6d0;hb=34ae2440d7cd133051523bce2aac0760cf8296eb;hp=7e0f1b02dd141b81704f24256aa00ec8732af30a;hpb=e552b31989dbb36f780428332be1b4958d26a37b;p=bootcensus diff --git a/Makefile b/Makefile index 7e0f1b0..0722ce4 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,8 @@ warn = -pedantic -Wall dbg = -g inc = -Isrc -Isrc/libc -CFLAGS = $(ccarch) $(warn) $(dbg) -nostdinc -fno-builtin $(inc) $(def) -ASFLAGS = $(asarch) $(dbg) -nostdinc -fno-builtin $(inc) +CFLAGS = $(ccarch) -march=i386 $(warn) $(dbg) -nostdinc -fno-builtin $(inc) $(def) +ASFLAGS = $(asarch) -march=i386 $(dbg) -nostdinc -fno-builtin $(inc) LDFLAGS = $(ldarch) -T pcboot.ld -print-gc-sections @@ -20,12 +20,20 @@ ifneq ($(shell uname -m), i386) ldarch = -m elf_i386 endif -floppy.img: $(bin) +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) @@ -37,12 +45,21 @@ $(elf): $(obj) .PHONY: clean clean: - rm -f $(obj) $(bin) floppy.img + 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 >$@ + .PHONY: run run: $(bin) qemu-system-i386 -fda floppy.img -serial file:serial.log