-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile.pkgs
212 lines (183 loc) · 6.54 KB
/
Makefile.pkgs
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# ---------------------------------------------------------------------------
PKG_MAINTAINER = 'Jan Tobias Muehlberg <[email protected]>'
# ---------------------------------------------------------------------------
# Package config for LLVM/CLANG
ifeq ($(OTHER),0)
ifeq ($(DEBIAN),1)
ifeq ($(OS_VERS),9.4)
LLVM_VER = 4.0.1
LLVM_PKG_REL = 2
TI_MSPGCC_VER = 6.4.0.32
else
$(error Unsupported OS version: $(OS_VERS))
endif
else
ifeq ($(UBUNTU),1)
ifeq ($(OS_VERS),16.04)
LLVM_VER = 4.0.0
LLVM_PKG_REL =
TI_MSPGCC_VER = 6.4.0.32
else
ifeq ($(OS_VERS),18.04)
LLVM_VER = 4.0.1
LLVM_PKG_REL = 2
TI_MSPGCC_VER = 6.4.0.32
else
ifeq ($(OS_VERS),20.04)
LLVM_VER = 4.0.1
LLVM_PKG_REL = 2
TI_MSPGCC_VER = 6.4.0.32
else
ifeq ($(OS_VERS),22.04)
LLVM_VER = 4.0.1
LLVM_PKG_REL = 2
TI_MSPGCC_VER = 9.3.1.11
else
$(error Unsupported OS version: $(OS_VERS))
endif
endif
endif
endif
else
$(error Unsupported OS: $(shell uname -v))
endif
endif
LLVM_PKG = clang-sancus
LLVM_PKG_SRC = "https://distrinet.cs.kuleuven.be/software/sancus/"
LLVM_PKG_DES = "Clang with Sancus patches."
ifeq ($(LLVM_PKG_REL),)
LLVM_PKG_BAS = $(LLVM_PKG)_$(LLVM_VER)_
else
LLVM_PKG_BAS = $(LLVM_PKG)_$(LLVM_VER)-$(LLVM_PKG_REL)_
endif
ifeq ($(UNAME_M),x86_64)
LLVM_PKG_DEB = $(LLVM_PKG_BAS)amd64.deb
endif
ifeq ($(UNAME_M),armv7l)
LLVM_PKG_DEB = $(LLVM_PKG_BAS)armhf.deb
endif
ifndef LLVM_PKG_DEB
$(error Unsupported architecture!)
else
$(info LLVM/Clang package: $(LLVM_PKG_DEB))
endif
else
TI_MSPGCC_VER = 9.3.1.11
endif
# ---------------------------------------------------------------------------
# Package config for TI MSPGCC
TI_MSPGCC_SRC_DIR = msp430-gcc-$(TI_MSPGCC_VER)-source-full
TI_MSPGCC_SRC_TBZ = $(TI_MSPGCC_SRC_DIR).tar.bz2
TI_MSPGCC_SRC_URL = https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-LlCjWuAbzH/9.3.1.2/$(TI_MSPGCC_SRC_TBZ)
ifeq ($(OTHER),0)
TI_MSPGCC_PKG = ti-mspgcc-binutils-sancus
TI_MSPGCC_PKG_REL = 1
TI_MSPGCC_PKG_SRC = $(TI_MSPGCC_SRC_URL)
TI_MSPGCC_PKG_DES = "TI MSP430-GCC binutils for Sancus."
TI_MSPGCC_PKG_BAS = $(TI_MSPGCC_PKG)_$(TI_MSPGCC_VER)-$(TI_MSPGCC_PKG_REL)_
ifeq ($(UNAME_M),x86_64)
TI_MSPGCC_PKG_DEB = $(TI_MSPGCC_PKG_BAS)amd64.deb
endif
ifeq ($(UNAME_M),armv7l)
TI_MSPGCC_PKG_DEB = $(TI_MSPGCC_PKG_BAS)armhf.deb
endif
ifndef TI_MSPGCC_PKG_DEB
$(error Unsupported architecture!)
else
$(info TI MSPGCC package: $(TI_MSPGCC_PKG_DEB))
endif
endif
# ---------------------------------------------------------------------------
# Configure checkinstall
ifeq ($(OTHER),0)
ifeq ($(UNAME_M),armv7l)
# Default checkinstall is buggy:
# https://github.com/giuliomoro/checkinstall/commit/57ad1473bdfc5aadd2c921d6990e069809f442d4
CHECKINSTALL = /usr/local/sbin/checkinstall
else
CHECKINSTALL = checkinstall
endif
endif
deb-build-deps:
$(info .. Installing system-wide Ubuntu/Debian build dependencies)
$(SUDO) apt-get install -yqq \
build-essential bison flex texinfo checkinstall
# ---------------------------------------------------------------------------
$(TI_MSPGCC_SRC_TBZ):
$(WGET) $(TI_MSPGCC_SRC_URL)
$(TI_MSPGCC_SRC_DIR): $(TI_MSPGCC_SRC_TBZ)
bunzip2 -c $(TI_MSPGCC_SRC_TBZ) | tar -x
ti-mspgcc-build: $(TI_MSPGCC_SRC_DIR)
cd $(TI_MSPGCC_SRC_DIR)/binutils && \
./configure --target=msp430-elf \
--enable-languages=c,c++ --disable-nls \
--prefix=$(SANCUS_INSTALL_PREFIX) \
--disable-sim --disable-gdb --disable-werror
cd $(TI_MSPGCC_SRC_DIR)/binutils && \
$(MAKE) -j 2
ti-mspgcc-deb: deb-build-deps ti-mspgcc-build
$(SUDO) mkdir -p $(SANCUS_INSTALL_PREFIX)/msp430-elf/lib
$(SUDO) mkdir -p $(SANCUS_INSTALL_PREFIX)/share/man
cd $(TI_MSPGCC_SRC_DIR)/binutils && \
echo $(TI_MSPGCC_PKG_DES) >description-pak && \
$(SUDO) $(CHECKINSTALL) -y -D --install=no --backup=no \
--pkgname=$(TI_MSPGCC_PKG) --pkgversion=$(TI_MSPGCC_VER) \
--pkgrelease=$(TI_MSPGCC_PKG_REL) \
--pkgsource="$(TI_MSPGCC_PKG_SRC)" \
--provides=$(TI_MSPGCC_PKG) \
--maintainer=$(PKG_MAINTAINER) \
--reset-uids --pakdir=../../ --exclude=/home \
--deldoc --deldesc --delspec
ti-mspgcc-inst: ti-mspgcc-build
$(SUDO) mkdir -p $(SANCUS_INSTALL_PREFIX)/msp430-elf/lib
cd $(TI_MSPGCC_SRC_DIR)/binutils && \
$(SUDO) $(MAKE) install
ti-mspgcc-clean:
rm -rf $(TI_MSPGCC_SRC_DIR)
rm -f $(TI_MSPGCC_SRC_TBZ)
ti-mspgcc-distclean: ti-mspgcc-clean
rm -f $(TI_MSPGCC_PKG_DEB)
# ---------------------------------------------------------------------------
# Optionally patch LLVM/Clang from source
clang_patch: clang.patch
git submodule init
git submodule update
cd clang && \
patch -p1 --forward < ../clang.patch; \
retCode=$$?; \
if [ $$retCode -gt 1 ]; then exit $$retCode; else exit 0; fi
clang_unpatch:
cd clang && \
patch -p1 -R < ../clang.patch
LLVM_BUILD_FLAGS = -DLLVM_TARGETS_TO_BUILD="host;MSP430" \
-DLLVM_TARGET_ARCH=host \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$(SANCUS_INSTALL_PREFIX)
llvm-build: clang_patch
$(info .. Building and installing patched LLVM/Clang to $(SANCUS_INSTALL_PREFIX))
ifeq ($(UNAME_M),armv7l)
$(info .. Building LLVM/Clang on/for $(UNAME_M): use 2GiB swap and ld.gold)
endif
mkdir -p llvm/build
cd llvm/tools && ln -sf ../../clang clang
cd llvm/build && cmake $(LLVM_BUILD_FLAGS) ..
cd llvm/build && $(MAKE) -j 2
llvm-deb: deb-build-deps llvm-build
$(info .. Building .deb of patched LLVM/Clang to $(SANCUS_INSTALL_PREFIX))
cd llvm/build/ && \
echo $(LLVM_PKG_DES) >description-pak && \
$(SUDO) $(CHECKINSTALL) -y -D --install=no --backup=no \
--pkgname=clang-sancus --pkgversion=$(LLVM_VER) \
--pkgrelease=$(LLVM_PKG_REL) \
--pkgsource=$(LLVM_PKG_SRC) \
--provides=$(LLVM_PKG) \
--maintainer=$(PKG_MAINTAINER) \
--reset-uids --pakdir=../../ --exclude=/home \
--deldoc --deldesc --delspec
llvm-inst: llvm-build
$(info .. Installing patched LLVM/Clang to $(SANCUS_INSTALL_PREFIX))
cd llvm/build && $(SUDO) $(MAKE) install
llvm-clean:
rm -rf llvm/build/
llvm-distclean: llvm-clean
rm -f $(LLVM_PKG_DEB)