-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
53 lines (39 loc) · 1.28 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
arch := x86_64
kernel := build/$(arch)/kernel.bin
iso := build/$(arch)/os.iso
rs_target := $(arch)-sparkle
rs_kernel := target/$(rs_target)/debug/libsparkle_os.a
asm_src := $(wildcard src/arch/$(arch)/bload/*.asm)
asm_obj := $(patsubst src/arch/$(arch)/bload/%.asm, build/$(arch)/bload/%.o, $(asm_src))
linker_script := src/arch/$(arch)/linker.ld
grub_cfg := src/arch/$(arch)/grub.cfg
qemu_flags := -serial mon:stdio -monitor vc
.PHONY: all clean run iso doc
all: $(kernel)
clean:
rm -r build/ target/
check:
cargo check
run: $(iso)
qemu-system-x86_64 $(qemu_flags) -cdrom $(iso) -s
run-trif: $(iso)
qemu-system-x86_64 $(qemu_flags) -cdrom $(iso) -no-reboot -d int -s
debug: $(iso)
qemu-system-x86_64 $(qemu_flags) -cdrom $(iso) -s -S
iso: $(iso)
$(iso): $(kernel)
mkdir -p build/isofiles/boot/grub
cp $(kernel) build/isofiles/boot/kernel.bin
cp $(grub_cfg) build/isofiles/boot/grub
grub-mkrescue -o $(iso) build/isofiles
rm -r build/isofiles
$(kernel): $(asm_obj) $(rs_kernel)
ld -n --gc-sections -T $(linker_script) -o $(kernel) $^
.PHONY: $(rs_kernel) # always run this dep
$(rs_kernel):
cargo xbuild --target $(rs_target).json
build/$(arch)/%.o: src/arch/$(arch)/%.asm
@mkdir -p $(shell dirname $@)
nasm -felf64 $< -o $@
doc:
cargo rustdoc --lib -- --document-private-items