-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
73 lines (58 loc) · 1.86 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
66
67
68
69
70
71
72
73
# stolen from https://github.com/mit-pdos/xv6-riscv/blob/riscv/Makefile
QEMU = /opt/qemu/bin/qemu-system-riscv64
GDB = /opt/gdb/bin/gdb
# TODO: UP for the minute
CPUS = 1
STAGE1 = target/riscv64imac-mu-shoo-elf/release/shoo
CARGOFLAGS = --release
# RUST_TARGET_PATH = $(shell realpath ..)
# export RUST_TARGET_PATH
QEMUOPTS = -machine virt -bios none -kernel $(STAGE1) -initrd initrd -m 128M \
-smp $(CPUS) -nographic -trace enable=riscv_trap
# debug on port 1234
#QEMUOPTS += -s
#QEMUOPTS += -drive file=fs.img,if=none,format=raw,id=x0
#QEMUOPTS += -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
user_targets = init
user_target_prefix = target/riscv64imac-mu-user-elf/release
user_target_files = $(addprefix $(user_target_prefix)/,$(user_targets))
kern = target/riscv64imac-mu-kern-elf/release/kern
shoo = target/riscv64imac-mu-shoo-elf/release/shoo
.PHONY: qemu clean doc gdb build.rs
initrd: $(kern) $(user_target_files)
cargo run -p uflop -- new -o initrd $^
$(shoo).d: $(shoo)
ifneq ("$(wildcard $(shoo).d)","")
include $(shoo).d
endif
$(shoo):
(cd shoo; cargo build $(CARGOFLAGS))
$(kern).d: $(kern)
ifneq ("$(wildcard $(kern).d)","")
include $(kern).d
endif
$(kern):
(cd kern; cargo build $(CARGOFLAGS))
$(user_target_prefix)/%.d: $(user_target_prefix)/$*
ifneq ("$(wildcard $(user_target_prefix)/*.d)","")
include $(wildcard $(user_target_prefix)/*.d)
endif
$(user_target_prefix)/%:
(cd user/$*; cargo build $(CARGOFLAGS))
clean:
rm initrd
cargo clean
# always open a gdb socket but only block if we request a debugger. reasoning:
# the qemu monitor is rather broken and e.g. doesn't allow reading regs
qemu: initrd $(shoo)
$(QEMU) $(QEMUOPTS) -s
qemu-gdb: initrd $(shoo)
@echo "Run 'make gdb' in another terminal to connect"
$(QEMU) $(QEMUOPTS) -s -S
gdb:
$(GDB)
ifeq ($(OPEN),1)
DOC = --open
endif
doc:
(cd shoo; cargo doc -p shoo $(CARGOFLAGS) $(DOC))