-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-prerequisities.sh
261 lines (205 loc) · 6.01 KB
/
build-prerequisities.sh
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#!/bin/bash
set -e
BUILD=${BUILD:-`gcc -dumpmachine`}
TARGET=${TARGET:-arm-none-eabi}
AUTOCONF=${AUTOCONF:-autoconf-2.64}
ICONV=${ICONV:-libiconv-1.15}
NEWLIB=${NEWLIB:-newlib-2.5.0}
BINUTILS=${BINUTILS:-binutils-2.29.1}
GCC=${GCC:-gcc-7.2.0}
GDB=${GDB:-gdb-8.0.1}
EXPAT_VERSION=${EXPAT:-2.2.5}
EXPAT=${EXPAT:-expat-${EXPAT_VERSION}}
NPROC=${NPROC:-$((`nproc`*2))}
PARALLEL=${PARALLEL:--j${NPROC}}
echo "# ==============================================================="
echo "# download"
mkdir -p artifacts
pushd artifacts
if [ ! -f ${AUTOCONF}.tar.bz2 ] ; then
wget http://ftpmirror.gnu.org/autoconf/${AUTOCONF}.tar.bz2
fi
if [ ! -f ${ICONV}.tar.gz ] ; then
wget http://ftpmirror.gnu.org/libiconv/${ICONV}.tar.gz
fi
if [ ! -f ${BINUTILS}.tar.bz2 ] ; then
wget http://ftpmirror.gnu.org/binutils/${BINUTILS}.tar.bz2
fi
if [ ! -f ${GCC}.tar.gz ] ; then
wget http://ftpmirror.gnu.org/gcc/${GCC}/${GCC}.tar.gz
fi
if [ ! -f ${GDB}.tar.gz ] ; then
wget http://ftpmirror.gnu.org/gdb/${GDB}.tar.gz
fi
if [ ! -f ${EXPAT}.tar.bz2 ] ; then
wget https://github.com/libexpat/libexpat/releases/download/R_${EXPAT_VERSION//\./_}/${EXPAT}.tar.bz2
fi
if [ ! -f ${NEWLIB}.tar.gz ] ; then
wget http://sourceware.org/pub/newlib/${NEWLIB}.tar.gz
fi
popd
echo "# ==============================================================="
echo "# extract"
mkdir -p stage
pushd stage
if [ ! -d ${AUTOCONF} ] ; then
echo "Extracting: ${AUTOCONF}"
tar -jxf ../artifacts/${AUTOCONF}.tar.bz2
fi
if [ ! -d ${ICONV} ] ; then
echo "Extracting: ${ICONV}"
tar -zxf ../artifacts/${ICONV}.tar.gz
fi
if [ ! -d ${NEWLIB} ] ; then
echo "Extracting: ${NEWLIB}"
tar -zxf ../artifacts/${NEWLIB}.tar.gz
# Patching reentrancy
echo 'newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"' >> ${NEWLIB}/newlib/configure.host
fi
if [ ! -d ${BINUTILS} ] ; then
echo "Extracting: ${BINUTILS}"
tar -jxf ../artifacts/${BINUTILS}.tar.bz2
fi
if [ ! -d ${GCC} ] ; then
echo "Extracting: ${GCC}"
tar -zxf ../artifacts/${GCC}.tar.gz
fi
if [ ! -d ${EXPAT} ] ; then
echo "Extracting: ${EXPAT}"
tar -jxf ../artifacts/${EXPAT}.tar.bz2
fi
if [ ! -d ${GDB} ] ; then
echo "Extracting: ${GDB}"
tar -zxf ../artifacts/${GDB}.tar.gz
fi
popd
echo "# ==============================================================="
echo "# download and extract by gcc's prerequisities"
pushd stage
cd ${GCC}
contrib/download_prerequisites --directory=..
cd ..
rm *.bz2
rm *.gz
popd
echo "# ==============================================================="
echo "# remove last bootstraps"
pushd stage
BOOTSTRAP_PATH=`pwd`/${BUILD}/gcc-bootstrap
rm -rf ${BOOTSTRAP_PATH}
popd
# ==========================================================================
# bootstrap builds
pushd stage
echo "# ==============================================================="
echo "# autoconf"
pushd ${AUTOCONF}
rm -rf build
mkdir -p build
cd build
../configure --prefix=${BOOTSTRAP_PATH}
make ${PARALLEL}
make install
# Autoconf's test too long
#make ${PARALLEL} check
popd
pushd ${BINUTILS}
# binutils contains unstable configure script, so we have to regenerate by autoconf.
${BOOTSTRAP_PATH}/bin/autoconf
popd
echo "# ==============================================================="
echo "# libiconv (bootstrap)"
pushd libiconv*
rm -rf build-bootstrap
mkdir -p build-bootstrap
cd build-bootstrap
../configure --prefix=${BOOTSTRAP_PATH} \
--disable-shared \
--disable-rpath \
--disable-nls \
--enable-relocatable \
CFLAGS="-O2 -fomit-frame-pointer -static -I${BOOTSTRAP_PATH}/include" \
CPPFLAGS="-fexceptions" \
LDFLAGS=-"-static -L${BOOTSTRAP_PATH}/lib"
make ${PARALLEL}
make install
popd
echo "# ==============================================================="
echo "# gmp (bootstrap)"
pushd gmp*
rm -rf build-bootstrap
mkdir -p build-bootstrap
cd build-bootstrap
../configure --prefix=${BOOTSTRAP_PATH} \
--disable-shared \
CFLAGS="-O2 -fomit-frame-pointer -static -I${BOOTSTRAP_PATH}/include" \
CPPFLAGS="-fexceptions" \
LDFLAGS=-"-static -L${BOOTSTRAP_PATH}/lib"
make ${PARALLEL}
make install
make ${PARALLEL} check
popd
echo "# ==============================================================="
echo "# mpfr (bootstrap)"
pushd mpfr*
rm -rf build-bootstrap
mkdir -p build-bootstrap
cd build-bootstrap
../configure --prefix=${BOOTSTRAP_PATH} \
--disable-shared \
--with-gmp=${BOOTSTRAP_PATH} \
CFLAGS="-O2 -fomit-frame-pointer -static -I${BOOTSTRAP_PATH}/include" \
CPPFLAGS="-fexceptions" \
LDFLAGS=-"-static -L${BOOTSTRAP_PATH}/lib"
make ${PARALLEL}
make install
make ${PARALLEL} check
popd
echo "# ==============================================================="
echo "# mpc (bootstrap)"
pushd mpc*
rm -rf build-bootstrap
mkdir -p build-bootstrap
cd build-bootstrap
../configure --prefix=${BOOTSTRAP_PATH} \
--disable-shared \
--with-gmp=${BOOTSTRAP_PATH} \
--with-mpfr=${BOOTSTRAP_PATH} \
CFLAGS="-O2 -fomit-frame-pointer -static -I${BOOTSTRAP_PATH}/include" \
CPPFLAGS="-fexceptions" \
LDFLAGS=-"-static -L${BOOTSTRAP_PATH}/lib"
make ${PARALLEL}
make install
make ${PARALLEL} check
popd
echo "# ==============================================================="
echo "# isl (bootstrap)"
pushd isl*
rm -rf build-bootstrap
mkdir -p build-bootstrap
cd build-bootstrap
../configure --prefix=${BOOTSTRAP_PATH} \
--disable-shared \
--with-gmp-prefix=${BOOTSTRAP_PATH} \
CFLAGS="-O2 -fomit-frame-pointer -static -I${BOOTSTRAP_PATH}/include" \
CPPFLAGS="-fexceptions" \
LDFLAGS=-"-static -L${BOOTSTRAP_PATH}/lib"
make ${PARALLEL}
make install
make ${PARALLEL} check
popd
echo "# ==============================================================="
echo "# expat (bootstrap)"
pushd expat*
rm -rf build-bootstrap
mkdir -p build-bootstrap
cd build-bootstrap
../configure --prefix=${BOOTSTRAP_PATH} \
--disable-shared \
CFLAGS="-O2 -fomit-frame-pointer -static -I${BOOTSTRAP_PATH}/include" \
CPPFLAGS="-fexceptions" \
LDFLAGS=-"-static -L${BOOTSTRAP_PATH}/lib"
make ${PARALLEL}
make install
popd
popd