foo
[eightysix] / kern / Makefile
1 csrc = $(wildcard src/*.c)
2 ssrc = $(wildcard src/*.asm)
3 obj = $(csrc:.c=.o) $(ssrc:.asm=.o)
4 dep = $(csrc:.c=.d)
5
6 disk_numsec = 720
7 #disk_numsec = 2880
8
9 bin = 86kern
10 img = 86kern.img
11
12 CC = ia16-elf-gcc
13 LD = ia16-elf-ld
14
15 warn = -pedantic -Wall
16 inc = -nostdinc -Isrc -Isrc/libc
17
18 CFLAGS = -march=i8088 -mtune=i8088 $(warn) $(inc) -MMD
19 LDFLAGS = -T kern.ld -Map kern.map
20
21 $(img): $(bin)
22         dd if=/dev/zero of=$@ bs=512 count=$(disk_numsec)
23         dd if=$< of=$@ bs=512 conv=notrunc
24
25 $(bin): $(obj)
26         $(LD) -o $@ $(obj) $(LDFLAGS)
27
28 -include $(dep)
29
30 %.o: %.asm
31         nasm -o $@ -f elf $<
32
33 .PHONY: clean
34 clean:
35         rm -f $(obj) $(bin)
36
37 .PHONY: cleandep
38 cleandep:
39         rm -f $(dep)
40
41
42 .PHONY: run
43 run: $(img)
44         qemu-system-i386 -fda $(img) -serial file:serial.log
45
46 .PHONY: debug
47 debug: $(img)
48         qemu-system-i386 -fda $(img) -serial file:serial.log -s -S
49
50 .PHONY: disasm
51 disasm: $(bin)
52         ndisasm -o 0x600 $< >dis