-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
82 lines (66 loc) · 2.27 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
74
75
76
77
78
79
80
81
82
# NOTE: I have a Windows machine and a macbook. I only access Linux via the WSL.
# Thus any "Linux"-specific config stuff is for the Windows machine.
UNAME_S = $(shell uname -s)
QEMU = qemu-system-aarch64
HAS_QEMU := $(shell which ${QEMU} 2>/dev/null)
ifndef HAS_QEMU
QEMU = qemu-system-aarch64.exe
endif
ifeq ($(UNAME_S), Linux)
export TELNET = telnet.exe
export GDB = gdb-multiarch
# # WSL can't access the Windows-based qemu through localhost.
# # We have to find the actual IP address of the host.
export GDB_HOST = $(shell dig +short $(shell hostname).local | awk '{print; exit}')
#
endif
ifeq ($(UNAME_S), Darwin)
export TELNET = telnet
export GDB = aarch64-unknown-linux-gnu-gdb
endif
export OCOPY = cargo-objcopy
DO_RELEASE = false
RELEASE_PATH = target/aarch64-unknown-none-softfloat/release
DEBUG_PATH = target/aarch64-unknown-none-softfloat/debug
ifeq ($(DO_RELEASE), true)
RELEASE_FLAG = --release
ELF_PATH = ${RELEASE_PATH}/os_experiments
BUILD_DIR = ${RELEASE_PATH}
else
RELEASE_FLAG =
ELF_PATH = ${DEBUG_PATH}/os_experiments
BUILD_DIR = ${DEBUG_PATH}
endif
.PHONY: build
build: ${ELF_PATH}
.PHONY: clean
clean:
rm -f ${ELF_PATH}
rm -f ${BUILD_DIR}/.cargo-lock
.PHONY: lint-fix
lint-fix:
cargo fix --target aarch64-unknown-linux-gnu ${RELEASE_FLAG} --allow-dirty
.PHONY: qemu
qemu: target/kernel.img
@echo "(Press Ctrl-A X to exit QEMU.)"
${QEMU} -M raspi3b -kernel target/kernel.img -serial null -serial mon:stdio
.PHONY: qemu-gdb
qemu-gdb: target/kernel.img
@echo "(Press Ctrl-A X to exit QEMU.)"
${QEMU} -M raspi3b -s -S -serial null -serial mon:stdio -kernel target/kernel.img
.PHONY: qemu-mon
qemu-mon: target/kernel.img
@echo "(Press Ctrl-A X to exit QEMU.)"
${QEMU} -M raspi3b -monitor telnet:127.0.0.1:55555,server,nowait -s -kernel target/kernel.img -serial null -serial mon:stdio
.PHONY: gdb
gdb:
${GDB} -ex "target remote ${GDB_HOST}:1234" ${ELF_PATH}
.PHONY: telnet
telnet:
${TELNET} 127.0.0.1 55555
target/kernel.img: ${ELF_PATH}
${OCOPY} ${RELEASE_FLAG} -- -O binary target/kernel.img
RUST_SRC = $(wildcard src/*.rs) $(wildcard src/**/*.rs)
ASM_SRC = $(wildcard src/*.s) $(wildcard src/**/*.s)
${ELF_PATH}: ${RUST_SRC} ${ASM_SRC} build.rs kernel8.ld
cargo build -Z build-std=core,compiler_builtins -Z build-std-features=compiler-builtins-mem ${RELEASE_FLAG}