-
Notifications
You must be signed in to change notification settings - Fork 82
/
Makefile
37 lines (30 loc) · 881 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
export RUST_TARGET_PATH=targets
ifeq ($(TARGET),)
ARCH?=$(shell uname -a)
else
ARCH?=$(shell echo "$(TARGET)" | cut -d - -f1)
endif
BUILD?=target/$(ARCH)-unknown-kernel
all: $(BUILD)/kernel $(BUILD)/kernel.sym
LD_SCRIPT=linkers/$(ARCH).ld
TARGET_SPEC=targets/$(ARCH)-unknown-kernel.json
$(BUILD)/kernel.all: $(LD_SCRIPT) $(TARGET_SPEC) $(shell find . -name "*.rs" -type f)
cargo rustc \
--bin kernel \
--target "$(TARGET_SPEC)" \
--release \
-Z build-std=core,alloc \
-- \
-C link-arg=-T -Clink-arg="$(LD_SCRIPT)" \
-C link-arg=-z -Clink-arg=max-page-size=0x1000 \
--emit link="$(BUILD)/kernel.all"
$(BUILD)/kernel.sym: $(BUILD)/kernel.all
$(TARGET)-objcopy \
--only-keep-debug \
"$(BUILD)/kernel.all" \
"$(BUILD)/kernel.sym"
$(BUILD)/kernel: $(BUILD)/kernel.all
$(TARGET)-objcopy \
--strip-debug \
"$(BUILD)/kernel.all" \
"$(BUILD)/kernel"