-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-prerequisites.sh
executable file
·351 lines (294 loc) · 9.98 KB
/
build-prerequisites.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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
#! /usr/bin/env bash
# Copyright (c) 2011-2020, ARM Limited
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Arm nor the names of its contributors may be used
# to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
set -e
set -x
set -u
set -o pipefail
PS4='+$(date -u +%Y-%m-%d:%H:%M:%S) (${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
umask 022
exec < /dev/null
script_path=`cd $(dirname $0) && pwd -P`
. $script_path/build-common.sh
# This file contains the sequence of commands used to build the prerequisites
# for GNU Tools Arm Embedded toolchain.
usage ()
{
cat<<EOF
Usage: $(basename $0) [--skip_steps=...]
This script will build dependent libraries for GNU Tools Arm Embedded toolchain.
OPTIONS:
--skip_steps=STEPS specify which build steps you want to skip. Concatenate
them with comma for skipping more than one steps.
Available step is:
howto
md5_checksum
mingw[32]
native
package_bins
package_sources
EOF
}
if [ $# -gt 2 ] ; then
usage
fi
skip_steps=
skip_mingw32=no
skip_native_build=no
for ac_arg; do
case $ac_arg in
--skip_steps=*)
skip_steps=`echo $ac_arg | sed -e "s/--skip_steps=//g" -e "s/,/ /g"`
;;
--help|-h)
usage
exit 1
;;
*)
usage
exit 1
;;
esac
done
if [ "x$skip_steps" != "x" ]; then
for ss in $skip_steps; do
case $ss in
mingw|mingw32)
skip_mingw32=yes
;;
native)
skip_native_build=yes
;;
howto | package_bins | package_sources | md5_checksum | strip)
;;
*)
echo "Unknown build steps: $ss" 1>&2
usage
exit 1
;;
esac
done
fi
if [ "x$BUILD" == "xx86_64-apple-darwin10" ]; then
skip_mingw32=yes
fi
if [ "x$skip_native_build" != "xyes" ] ; then
rm -rf "$BUILDDIR_NATIVE"
mkdir -p "$BUILDDIR_NATIVE"
rm -rf "$INSTALLDIR_NATIVE"
mkdir -p "$INSTALLDIR_NATIVE"
fi
if [ "x$skip_mingw32" != "xyes" ] ; then
rm -rf "$BUILDDIR_MINGW"
mkdir -p "$BUILDDIR_MINGW"
rm -rf "$INSTALLDIR_MINGW"
mkdir -p "$INSTALLDIR_MINGW"
fi
cd "$SRCDIR"
if [ "x$skip_native_build" != "xyes" ] ; then
echo Task [I-0] /$HOST_NATIVE/zlib/ | tee -a "$BUILDDIR_NATIVE/.stage"
rm -rf $BUILDDIR_NATIVE/zlib
copy_dir_clean $SRCDIR/$ZLIB $BUILDDIR_NATIVE/zlib
pushd $BUILDDIR_NATIVE/zlib
#install zlib at .../host-libs/zlib, prevent gcc from linking into this external zlib
./configure --static --prefix=$BUILDDIR_NATIVE/host-libs/zlib
make
make install
popd
echo Task [I-1] /$HOST_NATIVE/gmp/ | tee -a "$BUILDDIR_NATIVE/.stage"
rm -rf $BUILDDIR_NATIVE/gmp && mkdir -p $BUILDDIR_NATIVE/gmp
pushd $BUILDDIR_NATIVE/gmp
CPPFLAGS="-fexceptions" $SRCDIR/$GMP/configure --build=$BUILD \
--host=$HOST_NATIVE \
--prefix=$BUILDDIR_NATIVE/host-libs/usr \
--enable-cxx \
--enable-fft \
--disable-shared
make -j$JOBS
make install
#make check
popd
echo Task [I-2] /$HOST_NATIVE/mpfr/ | tee -a "$BUILDDIR_NATIVE/.stage"
rm -rf $BUILDDIR_NATIVE/mpfr && mkdir -p $BUILDDIR_NATIVE/mpfr
pushd $BUILDDIR_NATIVE/mpfr
$SRCDIR/$MPFR/configure --build=$BUILD \
--host=$HOST_NATIVE \
--target=$TARGET \
--prefix=$BUILDDIR_NATIVE/host-libs/usr \
--disable-shared \
--with-gmp=$BUILDDIR_NATIVE/host-libs/usr
make -j$JOBS
make install
#make check
popd
echo Task [I-3] /$HOST_NATIVE/mpc/ | tee -a "$BUILDDIR_NATIVE/.stage"
rm -rf $BUILDDIR_NATIVE/mpc && mkdir -p $BUILDDIR_NATIVE/mpc
pushd $BUILDDIR_NATIVE/mpc
$SRCDIR/$MPC/configure --build=$BUILD \
--host=$HOST_NATIVE \
--target=$TARGET \
--prefix=$BUILDDIR_NATIVE/host-libs/usr \
--disable-shared \
--with-gmp=$BUILDDIR_NATIVE/host-libs/usr \
--with-mpfr=$BUILDDIR_NATIVE/host-libs/usr
make -j$JOBS
make install
#make check
popd
echo Task [I-4] /$HOST_NATIVE/isl/ | tee -a "$BUILDDIR_NATIVE/.stage"
rm -rf $BUILDDIR_NATIVE/isl && mkdir -p $BUILDDIR_NATIVE/isl
pushd $BUILDDIR_NATIVE/isl
$SRCDIR/$ISL/configure --build=$BUILD \
--host=$HOST_NATIVE \
--target=$TARGET \
--prefix=$BUILDDIR_NATIVE/host-libs/usr \
--disable-shared \
--with-gmp-prefix=$BUILDDIR_NATIVE/host-libs/usr
make
make install
#make check
popd
echo Task [I-5] /$HOST_NATIVE/expat/ | tee -a "$BUILDDIR_NATIVE/.stage"
rm -rf $BUILDDIR_NATIVE/expat && mkdir -p $BUILDDIR_NATIVE/expat
pushd $BUILDDIR_NATIVE/expat
$SRCDIR/$EXPAT/configure --build=$BUILD \
--host=$HOST_NATIVE \
--target=$TARGET \
--prefix=$BUILDDIR_NATIVE/host-libs/usr \
--without-docbook \
--without-xmlwf \
--disable-shared
make -j$JOBS
make install
popd
fi # if [ "x$skip_native_build" != "xyes" ] ; then
# skip building mingw32 toolchain if "--skip_mingw32" specified
if [ "x$skip_mingw32" == "xyes" ] ; then
exit 0
fi
saveenv
saveenvvar CC_FOR_BUILD gcc
saveenvvar CC $HOST_MINGW_TOOL-gcc
saveenvvar CXX $HOST_MINGW_TOOL-g++
saveenvvar AR $HOST_MINGW_TOOL-ar
saveenvvar RANLIB $HOST_MINGW_TOOL-ranlib
saveenvvar STRIP $HOST_MINGW_TOOL-strip
saveenvvar NM $HOST_MINGW_TOOL-nm
saveenvvar AS $HOST_MINGW_TOOL-as
saveenvvar OBJDUMP $HOST_MINGW_TOOL-objdump
saveenvvar RC $HOST_MINGW_TOOL-windres
saveenvvar WINDRES $HOST_MINGW_TOOL-windres
echo Generate /$HOST_MINGW/liblongpath-win32 | tee -a "$BUILDDIR_MINGW/.stage"
rm -rf $BUILDDIR_MINGW/liblongpath-win32
$SRCDIR/liblongpath-win32/helper.py --generate $BUILDDIR_MINGW/liblongpath-win32 --triplet $HOST_MINGW_TOOL
echo Task [II-0] /$HOST_MINGW/zlib/ | tee -a "$BUILDDIR_MINGW/.stage"
rm -rf $BUILDDIR_MINGW/zlib
copy_dir_clean $SRCDIR/$ZLIB $BUILDDIR_MINGW/zlib
#saveenv
#saveenvvar AR "$HOST_MINGW_TOOL-ar"
pushd $BUILDDIR_MINGW/zlib
#install zlib at .../host-libs/zlib, prevent gcc from linking into this external zlib
./configure --static --prefix=$BUILDDIR_MINGW/host-libs/zlib
make
make install
popd
#restoreenv
echo Task [II-1] /$HOST_MINGW/libiconv/ | tee -a "$BUILDDIR_MINGW/.stage"
rm -rf $BUILDDIR_MINGW/libiconv && mkdir -p $BUILDDIR_MINGW/libiconv
pushd $BUILDDIR_MINGW/libiconv
$SRCDIR/$LIBICONV/configure --build=$BUILD \
--host=$HOST_MINGW \
--target=$TARGET \
--prefix=$BUILDDIR_MINGW/host-libs/usr \
--disable-shared \
--disable-nls
make -j$JOBS
make install
popd
echo Task [II-2] /$HOST_MINGW/gmp/ | tee -a "$BUILDDIR_MINGW/.stage"
rm -rf $BUILDDIR_MINGW/gmp && mkdir -p $BUILDDIR_MINGW/gmp
pushd $BUILDDIR_MINGW/gmp
$SRCDIR/$GMP/configure --build=$BUILD \
--host=$HOST_MINGW \
--prefix=$BUILDDIR_MINGW/host-libs/usr \
--disable-shared \
--enable-fft \
--enable-cxx
make -j$JOBS
make install
popd
echo Task [II-3] /$HOST_MINGW/mpfr/ | tee -a "$BUILDDIR_MINGW/.stage"
rm -rf $BUILDDIR_MINGW/mpfr && mkdir -p $BUILDDIR_MINGW/mpfr
pushd $BUILDDIR_MINGW/mpfr
$SRCDIR/$MPFR/configure --build=$BUILD \
--host=$HOST_MINGW \
--target=$TARGET \
--prefix=$BUILDDIR_MINGW/host-libs/usr \
--disable-shared \
--with-gmp=$BUILDDIR_MINGW/host-libs/usr
make -j$JOBS
make install
popd
echo Task [II-4] /$HOST_MINGW/mpc/ | tee -a "$BUILDDIR_MINGW/.stage"
rm -rf $BUILDDIR_MINGW/mpc && mkdir -p $BUILDDIR_MINGW/mpc
pushd $BUILDDIR_MINGW/mpc
$SRCDIR/$MPC/configure --build=$BUILD \
--host=$HOST_MINGW \
--target=$TARGET \
--prefix=$BUILDDIR_MINGW/host-libs/usr \
--disable-shared \
--with-gmp=$BUILDDIR_MINGW/host-libs/usr \
--with-mpfr=$BUILDDIR_MINGW/host-libs/usr
make -j$JOBS
make install
popd
echo Task [II-5] /$HOST_MINGW/isl/ | tee -a "$BUILDDIR_MINGW/.stage"
rm -rf $BUILDDIR_MINGW/isl && mkdir -p $BUILDDIR_MINGW/isl
pushd $BUILDDIR_MINGW/isl
$SRCDIR/$ISL/configure --build=$BUILD \
--host=$HOST_MINGW \
--target=$TARGET \
--prefix=$BUILDDIR_MINGW/host-libs/usr \
--disable-shared \
--with-gmp-prefix=$BUILDDIR_MINGW/host-libs/usr
make
make install
popd
echo Task [II-6] /$HOST_MINGW/expat/ | tee -a "$BUILDDIR_MINGW/.stage"
rm -rf $BUILDDIR_MINGW/expat && mkdir -p $BUILDDIR_MINGW/expat
pushd $BUILDDIR_MINGW/expat
$SRCDIR/$EXPAT/configure --build=$BUILD \
--host=$HOST_MINGW \
--target=$TARGET \
--prefix=$BUILDDIR_MINGW/host-libs/usr \
--without-docbook \
--without-xmlwf \
--disable-shared
make -j$JOBS
make install
popd
restoreenv