-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
129 lines (106 loc) · 4.3 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
-include Makefile.config
WGET = wget -nv
RM = rm -Rf
CMAKE = $(SET_ENV) cmake
MAKE = $(SET_ENV) make
ifeq ($(NO_SUDO),1)
SUDO =
else
SUDO = sudo
endif
# ---------------------------------------------------------------------------
# Main installation targets
all: sancus-core sancus-compiler sancus-support sancus-examples
install_deps: debian-deps pip-deps ti-mspgcc clang-sancus
install: install_deps core-install compiler-install support-install sancus-examples
test: examples-sim
# Convenience targets for developers
update: core-update compiler-update support-update examples-update
build: core-build compiler-build support-build
# ---------------------------------------------------------------------------
# apt-get prerequisites as provided by Ubuntu 18.04/20.04 LTS
debian-deps:
$(info .. Installing system-wide Ubuntu/Debian packages)
$(SUDO) apt-get install -yqq \
build-essential bzip2 wget curl git cmake vim-common expect-dev \
python3 python3-pip flex bison libstdc++6 \
iverilog tk binutils-msp430 gcc-msp430 msp430-libc msp430mcu \
verilator libtinfo5 unzip
touch debian-deps
# ---------------------------------------------------------------------------
# Python3 PIP packages
pip-deps: debian-deps
$(info .. Installing system-wide Python3 PIP packages)
python3 -m pip install pyelftools pyyaml \
&& printf "import elftools\nprint(elftools)" | python3 \
&& printf "import yaml\nprint(yaml)" | python3
touch pip-deps
# ---------------------------------------------------------------------------
# Package generation targets:
-include Makefile.pkgs
# ---------------------------------------------------------------------------
# TI's MSP430 GCC compiler port (needed for most recent MSP430 GNU binutils)
# check here: http://www.ti.com/tool/msp430-gcc-opensource
# 'make ti-mspgcc-deb' to build this locally.
$(TI_MSPGCC_PKG_DEB):
$(WGET) $(SUPPORT_PKGS_URL)/$(TI_MSPGCC_PKG_DEB)
ti-mspgcc: $(TI_MSPGCC_PKG_DEB)
$(info .. Installing TI MSPGCC binutils: $(TI_MSPGCC_PKG_DEB))
$(SUDO) dpkg -i $(TI_MSPGCC_PKG_DEB)
$(SET_ENV) msp430-elf-objcopy --version
touch ti-mspgcc
# ---------------------------------------------------------------------------
# Patched LLVM/Clang package since annotation patch didn't get upstream yet
# 'make llvm-deb' to build this locally.
$(LLVM_PKG_DEB):
$(WGET) $(SUPPORT_PKGS_URL)/$(LLVM_PKG_DEB)
clang-sancus: $(LLVM_PKG_DEB)
$(info .. Installing LLVM/Clang for Sancus: $(LLVM_PKG_DEB))
$(SUDO) dpkg -i $(LLVM_PKG_DEB)
$(SET_ENV) clang --version
touch clang-sancus
# ---------------------------------------------------------------------------
# Sancus project GitHub repositories
REMOTE_IS_SSH = $(shell git config --get remote.origin.url | grep "[email protected]" >/dev/null; echo $$?)
sancus-%:
ifeq ($(REMOTE_IS_SSH), 1)
git clone https://github.com/sancus-tee/[email protected]
else
git clone [email protected]:sancus-tee/[email protected]
endif
%-update: sancus-%
cd sancus-$*/ ; git pull
%-build: sancus-%
mkdir -p sancus-$*/build
cd sancus-$*/build && \
git submodule init && \
git submodule update && \
$(CMAKE) -DCMAKE_INSTALL_PREFIX=$(SANCUS_INSTALL_PREFIX) \
-DSECURITY=$(SANCUS_SECURITY) -DMASTER_KEY=$(SANCUS_KEY) -DATOMICITY_MONITOR=$(ATOMICITY_MONITOR) ..
%-install: %-build
$(info .. Installing sancus-$* to $(SANCUS_INSTALL_PREFIX))
cd sancus-$*/build && $(SUDO) bash -c "$(MAKE) install"
# ---------------------------------------------------------------------------
.PHONY: docker
docker:
$(MAKE) -C docker all
# ---------------------------------------------------------------------------
examples:
$(MAKE) -C sancus-examples
examples-sim:
$(MAKE) -C sancus-examples sim
examples-clean:
$(MAKE) -C sancus-examples clean
# ---------------------------------------------------------------------------
clean: ti-mspgcc-clean llvm-clean
$(RM) ti-mspgcc sancus-clang debian-deps pip-deps clang-deb-install
$(RM) sancus-*/build
$(RM) $(LLVM_PKG_DEB) $(TI_MSPGCC_PKG_DEB)
distclean: clean ti-mspgcc-distclean llvm-distclean
$(RM) sancus-core sancus-compiler sancus-support sancus-examples
uninstall: distclean
$(RM) $(SANCUS_INSTALL_PREFIX)/share/sancus*
$(RM) $(SANCUS_INSTALL_PREFIX)/bin/sancus-*
$(RM) $(SANCUS_INSTALL_PREFIX)/lib/SancusModuleCreator.so
$(SUDO) dpkg -r $(LLVM_PKG)
$(SUDO) dpkg -r $(TI_MSPGCC_PKG)