-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
75 lines (59 loc) · 1.78 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Set configuration variables for the build
KERNEL_BIN= kernel.bin
EMULATOR= qemu-system-i386
QEMU_ARGS= -net nic,model=rtl8139 -net user -vga std
DEFINES= -DDEBUG -DDEBUG_HEAP -DTURTLE -DUSE_SERIAL
CC= gcc
AS= $(CC)
ARCH= -m32
CFLAGS= $(ARCH) -Wall -Wextra -Wno-unused-variable -Wno-unused-function -ffreestanding -std=gnu99 -g -I . $(DEFINES)
ASFLAGS= $(ARCH)
LDFLAGS= -T linker.ld -nostdlib -lgcc
# Include our submodules that contain all the object files
# Order must be: 1. boot, 2. kernel, ...
include boot/Makefile.mk
include kernel/Makefile.mk
include cpu/Makefile.mk
include drivers/Makefile.mk
include lib/Makefile.mk
include pci/Makefile.mk
.PHONY: all
all: $(KERNEL_BIN)
$(KERNEL_BIN): linker.ld $(KERNEL_OBJS)
$(CC) $(ARCH) $(LDFLAGS) -o $@ $(KERNEL_OBJS)
.PHONY: qemu
qemu: $(KERNEL_BIN)
$(EMULATOR) -kernel $(KERNEL_BIN) $(QEMU_ARGS)
.PHONY: qemucd
qemucd: $(KERNEL_BIN) bootiso
$(EMULATOR) -cdrom ../grub2/boot.iso $(QEMU_ARGS) -serial stdio
.PHONY: console
console: $(KERNEL_BIN)
$(EMULATOR) -kernel $(KERNEL_BIN) -nographic $(QEMU_ARGS) &
sleep 2
pkill qemu-system-*
.PHONY: debug
debug: $(KERNEL_BIN)
$(EMULATOR) -kernel $(KERNEL_BIN) -s -S $(QEMU_ARGS)
.PHONY: gdb
gdb:
gdb -x ../tools/gdbinitrc
.PHONY: clean
clean:
rm -f $(KERNEL_OBJS) $(KERNEL_OBJS:.o=.d) $(KERNEL_BIN) core.* cpu/vectors.S version.h
make -C ../grub2 clean
.PHONY: bootiso
bootiso:
make -C ../grub2 boot.iso
# pull in existing deps for all our objects
-include $(KERNEL_OBJS:.o=.d)
# this is a PHONY so it is regenerated every time
.PHONY: version_header
version_header:
../tools/make_version_h.sh > version.h
kernel/kernel.o: version_header kernel/kernel.c
cpu/vectors.S: cpu/mkvectors.py
python3 cpu/mkvectors.py > $@
%.o: %.c
$(CC) $(CFLAGS) -c $*.c -o $*.o
$(CC) $(CFLAGS) -MM $*.c > $*.d