-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
46 lines (35 loc) · 1.24 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
arch ?= x86_64
kernel := build/kernel-$(arch).bin
iso := build/os-$(arch).iso
target ?= $(arch)-kurumi
rust_os := target/$(target)/release/libkurumi.a
filesystem := build/disk.img
linker_script := src/arch/$(arch)/linker.ld
grub_cfg := src/arch/$(arch)/grub.cfg
assembly_source_files := $(wildcard src/arch/$(arch)/*.asm)
assembly_object_files := $(patsubst src/arch/$(arch)/%.asm, \
build/arch/$(arch)/%.o, $(assembly_source_files))
.PHONY: all clean run iso filesystem
all: $(kernel)
clean:
@rm -r build
run: $(iso) filesystem
@qemu-system-x86_64 -hda $(filesystem) -cdrom $(iso) -boot d
iso: $(iso)
$(iso): $(kernel) $(grub_cfg)
@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): kernel $(rust_os) $(assembly_object_files) $(linker_script)
@ld -n --gc-sections -T $(linker_script) -o $(kernel) $(assembly_object_files) $(rust_os)
kernel:
@RUST_TARGET_PATH="$(shell pwd)" xargo build --release --target $(target)
filesystem:
@bash makefat32.sh
@mv disk.img $(filesystem)
# compile assembly files
build/arch/$(arch)/%.o: src/arch/$(arch)/%.asm
@mkdir -p $(shell dirname $@)
@nasm -f elf64 $< -o $@