backported malloc fixes from 256boss, plus the addition of calloc and
[bootcensus] / Makefile
index 1a2f734..9622719 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
-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)
+csrc = $(wildcard src/*.c) $(wildcard src/libc/*.c) $(wildcard src/test/*.c)
+ssrc = $(wildcard src/*.s) $(wildcard src/libc/*.s) $(wildcard src/boot/*.s) $(wildcard src/test/*.s)
+Ssrc = $(wildcard src/*.S)
+obj = $(csrc:.c=.o) $(ssrc:.s=.o) $(Ssrc:.S=.o)
 dep = $(obj:.o=.d)
 elf = test
 bin = test.bin
@@ -8,13 +9,14 @@ bin = test.bin
 warn = -pedantic -Wall
 #opt = -O2
 dbg = -g
-inc = -Isrc -Isrc/libc
+inc = -Isrc -Isrc/libc -Isrc/test
 gccopt = -fno-pic -ffreestanding -nostdinc -fno-builtin
 
 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
 
+QEMU_FLAGS = -fda floppy.img -serial file:serial.log -soundhw sb16
 
 ifneq ($(shell uname -m), i386)
        ccarch = -m32
@@ -40,6 +42,9 @@ $(bin): $(elf)
 $(elf): $(obj)
        $(LD) -o $@ $(obj) -Map link.map $(LDFLAGS)
 
+%.o: %.S
+       $(CC) -o $@ $(CFLAGS) -c $<
+
 -include $(dep)
 
 %.d: %.c
@@ -67,11 +72,11 @@ $(elf).sym: $(elf)
 
 .PHONY: run
 run: $(bin)
-       qemu-system-i386 -fda floppy.img -serial file:serial.log
+       qemu-system-i386 $(QEMU_FLAGS)
 
 .PHONY: debug
 debug: $(bin) $(elf).sym
-       qemu-system-i386 -fda floppy.img -serial file:serial.log -s -S
+       qemu-system-i386 $(QEMU_FLAGS) -s -S
 
 .PHONY: sym
 sym: $(elf).sym