-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
44 lines (33 loc) · 944 Bytes
/
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
kernel := build/kernel-$(arch).elf
iso := build/os-$(arch).iso
linker_script := arch/$(arch)/link.ld
grub_cfg := arch/$(arch)/grub.cfg
assembly := $(shell find ./arch/$(arch)/ -name "*.asm")
object := $(assembly:%.asm=%.o)
rust_os := target/$(arch)-rsos/debug/librsos.a
.PHONY: all clean run debug iso kernel
all: $(kernel)
clean:
rm -r build
rm $(object)
run:
qemu-system-x86_64 -cdrom $(iso) \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
-serial stdio
debug:
qemu-system-x86_64 -cdrom $(iso) -s -S
iso: $(iso)
$(iso): $(kernel) $(grub_cfg)
mkdir -p build/iso/boot/grub
cp $(kernel) build/iso/boot/kernel.elf
cp $(grub_cfg) build/iso/boot/grub
grub-mkrescue -o $(iso) build/iso
rm -r build/iso
$(kernel): $(object) $(linker_script) kernel
mkdir -p build
ld -n -T $(linker_script) -o $(kernel) $(object) $(rust_os)
kernel:
cargo xbuild --target $(arch)-rsos.json
%.o: %.asm
nasm -f elf64 $< -o $@