forked from AMDESE/linux-svsm
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
86 lines (63 loc) · 2.04 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
83
84
85
86
# SPDX-License-Identifier: MIT
GCC = gcc
SHELL := /bin/bash
A_FLAGS := -D__ASSEMBLY__
C_FLAGS := -g -O2
C_FLAGS += -m64 -march=x86-64 -mno-sse2
C_FLAGS += -fno-stack-protector
C_FLAGS += -ffreestanding
C_FLAGS += -Wall -Wstrict-prototypes -Wno-address-of-packed-member
LD_FLAGS := -m64
LD_FLAGS += -nostdlib
LD_FLAGS += -Wl,-Tsrc/start/svsm.lds -Wl,--build-id=none
TARGET_JSON := x86_64-unknown-none
TARGET_DIR := target
TARGET := $(TARGET_DIR)/$(TARGET_JSON)/debug
OBJS := src/start/start.o
OBJS += $(TARGET)/liblinux_svsm.a
FEATURES := ""
## Memory layout
SVSM_GPA := 0x8000000000
SVSM_MEM := 0x10000000
LDS_FLAGS := -DSVSM_GPA_LDS="$(SVSM_GPA)"
LDS_FLAGS += -DSVSM_GPA="$(SVSM_GPA)ULL"
LDS_FLAGS += -DSVSM_MEM="$(SVSM_MEM)ULL"
.PHONY: all doc prereq clean superclean
STATIC_LIBS += ./external/build/lib/libtpm.a
STATIC_LIBS += ./external/build/lib/libplatform.a
STATIC_LIBS += ./external/build/lib/libwolfssl.a
STATIC_LIBS += ./external/build/lib/libcrt.a
STATIC_LIBS += ./external/build/lib/libm.a
all: .prereq svsm.bin
doc: .prereq
cargo doc --open
svsm.bin: svsm.bin.elf
objcopy -g -O binary $< $@
svsm.bin.elf: $(OBJS) src/start/svsm.lds
@xargo build --features $(FEATURES)
$(GCC) $(LD_FLAGS) -o $@ $(OBJS) -Wl,--start-group $(STATIC_LIBS) -Wl,--end-group
%.a: src/*.rs src/cpu/*.rs src/mem/*.rs src/util/*.rs src/vtpm/*.rs
@xargo build --features $(FEATURES)
%.o: %.S src/start/svsm.h
$(GCC) $(C_FLAGS) $(LDS_FLAGS) $(A_FLAGS) -c -o $@ $<
%.lds: %.lds.S src/start/svsm.h
$(GCC) $(A_FLAGS) $(LDS_FLAGS) -E -P -o $@ $<
prereq: .prereq
.prereq:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $(HOME)/.cargo/env
echo "source $(HOME)/.cargo/env" >> ~/.bashrc
rustup +nightly target add x86_64-unknown-none
rustup component add rust-src
rustup component add llvm-tools-preview
rustup override set nightly
cargo install xargo
cargo install bootimage
touch .prereq
clean:
@xargo clean
rm -f svsm.bin svsm.bin.elf $(OBJS) $(STATIC_LIBS)
rm -rf $(TARGET_DIR)
rm -f src/start/svsm.lds
superclean: clean
rm -f .prereq