-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (32 loc) · 1.08 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
arch ?= x86_64
target ?= $(arch)-custom
kernel := build/kernel-$(arch).bin
iso := build/image-$(arch).iso
rust_kernel := target/$(target)/release/libkernel.a
ld_script := arch/$(arch)/linker.ld
grub_cfg := arch/$(arch)/grub.cfg
asm_src := $(wildcard arch/$(arch)/*.asm)
asm_obj := $(patsubst arch/$(arch)/%.asm, build/arch/$(arch)/%.o, $(asm_src))
.PHONY: all clean run iso kernel
all: $(kernel)
clean:
@rm -rf build
$(kernel): kernel $(asm_obj) $(ld_script)
@ld -n -T $(ld_script) -static -o $(kernel) $(asm_obj) $(rust_kernel)
kernel:
@RUST_TARGET_PATH=$(shell pwd)/targets cargo build --target $(target) --release
build/arch/$(arch)/%.o: arch/$(arch)/%.asm
@mkdir -p $(shell dirname $@)
@nasm -f elf64 $< -o $@
# ISO files
iso: $(iso)
$(iso): $(kernel) $(grub_cfg)
@mkdir -p build/iso/boot/grub
@cp $(kernel) build/iso/boot/vos-kernel
@cp $(grub_cfg) build/iso/boot/grub/
@grub-mkrescue -o $(iso) build/iso
@rm -r build/iso
run: $(iso)
@qemu-system-x86_64 -cdrom $(iso) -enable-kvm -serial stdio
test:
@cargo test -p allocator --target x86_64-unknown-linux-gnu -Zbuild-std