-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·65 lines (46 loc) · 1.74 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
arch ?= x86_64
kernel := build/tauros-$(arch).bin
iso := build/tauros-$(arch).iso
test-kernel := build/test-tauros-$(arch).bin
test-iso := build/test-tauros-$(arch).iso
tauros_dir := tauros
target ?= $(arch)-tauros
rust_os := $(tauros_dir)/target/$(target)/debug/libtauros.a
rust_flags := -A dead_code
linker_script := src/arch/$(arch)/linker.ld
grub_cfg := src/arch/$(arch)/grub.cfg
target ?= $(arch)-tauros
assembly_source_files := $(wildcard src/arch/$(arch)/*.S)
assembly_object_files := $(patsubst src/arch/$(arch)/%.S, build/arch/$(arch)/%.o, $(assembly_source_files))
QEMU_RAM = 5G
.PHONY: all clean run run-debug run-debug-gdb iso kernel
all: $(kernel)
clean:
@rm -r build
@rm $(rust_os)
run: $(iso)
@qemu-system-x86_64 -m $(QEMU_RAM) -cdrom $(iso)&
@vinagre 127.0.0.1:5900; pkill qemu-system-x86
test: $(iso)
@qemu-system-x86_64 -m $(QEMU_RAM) -cdrom $(iso)&
@vinagre 127.0.0.1:5900; pkill qemu-system-x86
run-debug: $(iso)
@qemu-system-x86_64 -m $(QEMU_RAM) -monitor stdio -cdrom $(iso)
run-debug-gdb: $(iso)
@qemu-system-x86_64 -m $(QEMU_RAM) -S -s -cdrom $(iso)&
@vinagre 127.0.0.1:5900 && pkill qemu-system-x86
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 -d /usr/lib/grub/i386-pc -o $(iso) build/isofiles # 2> /dev/null
@rm -r build/isofiles
$(kernel): kernel $(assembly_object_files) $(linker_script) $(rust_os)
@ld -n -T $(linker_script) -o $(kernel) $(assembly_object_files) $(rust_os)
build/arch/$(arch)/%.o: src/arch/$(arch)/%.S
@mkdir -p $(shell dirname $@)
@gcc -c $< -o $@
$(rust_os): kernel
kernel:
@cd $(tauros_dir);RUSTFLAGS="$(RUSTFLAGS) $(rust_flags)" cargo build #-Z no-index-update