projects
/
bootcensus
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of github.com:jtsiomb/pcboot
[bootcensus]
/
Makefile
diff --git
a/Makefile
b/Makefile
index
9117c3f
..
0438d12
100644
(file)
--- a/
Makefile
+++ b/
Makefile
@@
-1,17
+1,20
@@
csrc = $(wildcard src/*.c) $(wildcard src/libc/*.c)
ssrc = $(wildcard src/*.s) $(wildcard src/libc/*.s) $(wildcard src/boot/*.s)
csrc = $(wildcard src/*.c) $(wildcard src/libc/*.c)
ssrc = $(wildcard src/*.s) $(wildcard src/libc/*.s) $(wildcard src/boot/*.s)
-obj = $(csrc:.c=.o) $(ssrc:.s=.o)
+Ssrc = $(wildcard src/*.S)
+obj = $(csrc:.c=.o) $(ssrc:.s=.o) $(Ssrc:.S=.o)
dep = $(obj:.o=.d)
elf = test
bin = test.bin
warn = -pedantic -Wall
dep = $(obj:.o=.d)
elf = test
bin = test.bin
warn = -pedantic -Wall
+#opt = -O2
dbg = -g
inc = -Isrc -Isrc/libc
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)
ifneq ($(shell uname -m), i386)
@@
-20,16
+23,27
@@
ifneq ($(shell uname -m), i386)
ldarch = -m elf_i386
endif
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
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)
$(bin): $(elf)
- objcopy -O binary $< $@
+ objcopy -O binary -R '.boot*' $< $@
$(elf): $(obj)
$(LD) -o $@ $(obj) -Map link.map $(LDFLAGS)
$(elf): $(obj)
$(LD) -o $@ $(obj) -Map link.map $(LDFLAGS)
+%.o: %.S
+ $(CC) -o $@ $(CFLAGS) -c $<
+
-include $(dep)
%.d: %.c
-include $(dep)
%.d: %.c
@@
-37,12
+51,31
@@
$(elf): $(obj)
.PHONY: clean
clean:
.PHONY: clean
clean:
- rm -f $(obj) $(bin)
+ rm -f $(obj) $(bin) boot.img floppy.img link.map
.PHONY: cleandep
cleandep:
rm -f $(dep)
.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)
.PHONY: run
run: $(bin)
- qemu-system-i386 -fda floppy.img
+ 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