moving some standard library functions to assembly
[bootcensus] / Makefile
index 0722ce4..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)
-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
+#opt = -O2
 dbg = -g
 inc = -Isrc -Isrc/libc
+gccopt = -fno-pic -ffreestanding -nostdinc -fno-builtin
 
-CFLAGS = $(ccarch) -march=i386 $(warn) $(dbg) -nostdinc -fno-builtin $(inc) $(def)
+CFLAGS = $(ccarch) -march=i386 $(warn) $(opt) $(dbg) $(gccopt) $(inc) $(def)
 ASFLAGS = $(asarch) -march=i386 $(dbg) -nostdinc -fno-builtin $(inc)
-LDFLAGS = $(ldarch) -T pcboot.ld -print-gc-sections
+LDFLAGS = $(ldarch) -nostdlib -T pcboot.ld -print-gc-sections
 
 
 ifneq ($(shell uname -m), i386)
@@ -38,6 +41,9 @@ $(bin): $(elf)
 $(elf): $(obj)
        $(LD) -o $@ $(obj) -Map link.map $(LDFLAGS)
 
+%.o: %.S
+       $(CC) -o $@ $(CFLAGS) -c $<
+
 -include $(dep)
 
 %.d: %.c
@@ -60,6 +66,16 @@ bootldr.disasm: $(elf)
 $(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 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