-
Notifications
You must be signed in to change notification settings - Fork 4
/
makefile
81 lines (63 loc) · 1.71 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
76
77
78
79
80
81
ifndef GCC_VERSION
GCC_VERSION = 5.4.0
endif
ifndef BINUTILS_VERSION
BINUTILS_VERSION = 2.29
endif
ifndef TARGET
TARGET = i686-elf
endif
DEPS_PREFIX = $(shell pwd)/.deps/cross
BUILD_DIR = build
DISK_IMG = $(BUILD_DIR)/disk.img
BOOTLOADER = $(BUILD_DIR)/bootloader/boot.bin
KERNEL = $(BUILD_DIR)/kernel/kernel.bin
MAKE_FLAGS = -j 8
MAKE_CMD = $(MAKE) \
PREFIX=$(DEPS_PREFIX) \
ARCH=$(TARGET) \
GCC_VERSION=$(GCC_VERSION) \
BINUTILS_VERSION=$(BINUTILS_VERSION) \
$(MAKE_FLAGS)
phony = all
all: $(DISK_IMG)
$(DISK_IMG): $(BUILD_DIR) $(BOOTLOADER) $(KERNEL)
dd if=/dev/zero of=$(DISK_IMG) bs=512 count=2880
dd if=$(BOOTLOADER) of=$(DISK_IMG) bs=512 count=1 seek=0
dd if=$(KERNEL) of=$(DISK_IMG) bs=512 seek=1
phony += $(BUILD_DIR)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
phony += $(BOOTLOADER)
$(BOOTLOADER): bootloader/boot.asm
$(MAKE_CMD) --directory bootloader
phony += $(KERNEL)
$(KERNEL): deps
$(MAKE_CMD) --directory kernel
phony += qemu
qemu: all
@echo "---------------------------------------------"
@echo "The development on the bootloader is paused."
@echo "Use \"make qemu_kernel\" instead."
@echo "---------------------------------------------"
qemu-system-x86_64 -drive format=raw,file=build/disk.img
phony += qemu_kernel
qemu_kernel: $(KERNEL)
$(MAKE_CMD) --directory kernel qemu
phony += lint
lint:
$(MAKE_CMD) --directory kernel lint
phony += clean
clean:
$(MAKE_CMD) --directory bootloader clean
$(MAKE_CMD) --directory kernel clean
rm -f $(DISK_IMG)
distclean:
$(MAKE_CMD) --directory .deps distclean
phony += test
test: all
@echo "No tests added"
phony += deps
deps:
$(MAKE_CMD) --directory .deps all
.PHONY: $(phony)