-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
82 lines (68 loc) · 1.8 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
82
ISO:=georgios.iso
DISK:=disk.img
USBDRIVE:=usbdrive.img
BASE_ROOT_DIR:=root
STAGE_ROOT_DIR:=tmp/root
BOOT_DIR:=$(STAGE_ROOT_DIR)/boot
KERNEL:=$(BOOT_DIR)/kernel.elf
ZIG?=zig
GRUB_PREFIX:=/usr
GRUB_LOCATION:=$(GRUB_PREFIX)/lib/grub/i386-pc
DEBUGGER:=gdb
BOCHS?=bochs
zig_build_args="build"
ifdef multiboot_vbe
zig_build_args+="-Dmultiboot_vbe=$(multiboot_vbe)"
vbe?=$(multiboot_vbe)
endif
ifdef vbe
zig_build_args+="-Dvbe=$(vbe)"
endif
ifdef debug_log
zig_build_args+="-Ddebug_log=$(debug_log)"
endif
ifdef wait_for_anykey
zig_build_args+="-Dwait_for_anykey=$(wait_for_anykey)"
endif
ifdef direct_disk
zig_build_args+="-Ddirect_disk=$(direct_disk)"
endif
ifdef run_rc
zig_build_args+="-Drun_rc=$(run_rc)"
endif
ifdef halt_when_done
zig_build_args+="-Dhalt_when_done=$(halt_when_done)"
endif
all: $(ISO) $(DISK) $(USBDRIVE)
$(STAGE_ROOT_DIR): $(shell find $(BASE_ROOT_DIR) -name '*')
@mkdir -p $(dir $@)
cp -rT $(BASE_ROOT_DIR) $@
cp $(GRUB_PREFIX)/share/grub/unicode.pf2 $(BOOT_DIR)/grub
touch $(STAGE_ROOT_DIR)
.PHONY: build_georgios
build_georgios: $(STAGE_ROOT_DIR)
python3 scripts/lint.py
$(ZIG) $(zig_build_args)
grub-file --is-x86-multiboot2 $(KERNEL)
nm --print-size --numeric-sort $(KERNEL) | grep -v '__' > tmp/annotated_kernel
objdump -S $(KERNEL) >> tmp/annotated_kernel
.PHONY: test
test:
$(ZIG) build test
$(ISO): build_georgios
grub-mkrescue --directory=$(GRUB_LOCATION) --output=$(ISO) --modules="$(GRUB_MODULES)" $(STAGE_ROOT_DIR)
$(DISK): build_georgios
rm -f $(DISK)
mke2fs -L '' -N 0 -O none -d $(STAGE_ROOT_DIR) -r 1 -t ext2 $(DISK) 20m
$(USBDRIVE): $(DISK)
cp $(DISK) $(USBDRIVE)
.PHONY: bochs
bochs:
rm -f $(DISK).lock
$(BOCHS) -q -f misc/bochs_config -rc misc/bochs_rc
.PHONY: qemu
qemu:
$(DEBUGGER) -x misc/qemu.gdb
.PHONY: clean
clean:
rm -fr tmp $(ISO) $(DISK) $(USBDRIVE) zig-cache