-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
54 lines (39 loc) · 977 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
45
46
47
48
49
50
51
52
53
target := riscv64imac-unknown-none-elf
mode := debug
kernel := target/$(target)/$(mode)/os
bin := target/$(target)/$(mode)/kernel.bin
objdump := rust-objdump --arch-name=riscv64
objcopy := rust-objcopy --binary-architecture=riscv64
.PHONY: kernel build clean qemu run env
env:
cargo install cargo-binutils
rustup component add llvm-tools-preview rustfmt
rustup target add $(target)
kernel:
cargo build
$(bin): kernel
$(objcopy) $(kernel) --strip-all -O binary $@
asm:
$(objdump) -d $(kernel) | less
header:
$(objdump) -h $(kernel) | less
build: $(bin)
clean:
cargo clean
qemu: build
qemu-system-riscv64 \
-machine virt \
-nographic \
-bios default \
-device loader,file=$(bin),addr=0x80200000
qemu-debug: build
qemu-system-riscv64 \
-machine virt \
-nographic \
-bios default \
-device loader,file=$(bin),addr=0x80200000 \
-s -S
run: build qemu
debug: build qemu-debug
gdb:
riscv64-unknown-elf-gdb $(kernel) -command=gdb.script