forked from xyzz/vitasdk-buildscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-prerequisites.sh
417 lines (350 loc) · 11.2 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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
#! /usr/bin/env bash
# Copyright (c) 2011-2015, 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
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 ARM EABI toolchain.
usage ()
{
cat<<EOF
Usage: $0 [--build_tools=...] [--skip_steps=...]
This script will build dependent libraries for gcc arm embedded toolchain.
OPTIONS:
--build_tools=TOOLS specify where to find the native build tools that
will be used for building gcc arm embedded toolchain
and related dependent libraries. If not specified,
the ones in your system will be used.
Please refer to howto-build document to find out how
to download and deploy prebuilt native tools for 32bit
build platform.
The prebuilt ones provided by arm embedded toolchain
team are supposed to run on 32bit build platform, thus
not suitable for 64bit platform.
--skip_steps=STEPS specify which build steps you want to skip. Concatenate
them with comma for skipping more than one steps.
Available step is: mingw32.
EOF
}
if [ $# -gt 2 ] ; then
usage
fi
skip_steps=
skip_mingw32=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"`
;;
--build_tools=*)
build_tools=`echo $ac_arg | sed -e "s/--build_tools=//g"`
build_tools_abs_path=`cd $build_tools && pwd -P`
if [ -d $build_tools_abs_path ]; then
export PATH=$build_tools_abs_path/gcc/bin:$PATH
export PATH=$build_tools_abs_path/mingw-w64-gcc/bin:$PATH
else
echo "The specified folder of build tools don't exist: $build_tools" 1>&2
exit 1
fi
;;
*)
usage
exit 1
;;
esac
done
if [ "x$skip_steps" != "x" ]; then
for ss in $skip_steps; do
case $ss in
mingw32)
skip_mingw32=yes
;;
*)
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
rm -rf $BUILDDIR_NATIVE && mkdir -p $BUILDDIR_NATIVE
rm -rf $INSTALLDIR_NATIVE && mkdir -p $INSTALLDIR_NATIVE
if [ "x$skip_mingw32" != "xyes" ] ; then
rm -rf $BUILDDIR_MINGW && mkdir -p $BUILDDIR_MINGW
rm -rf $INSTALLDIR_MINGW && mkdir -p $INSTALLDIR_MINGW
fi
rm -rf $PACKAGEDIR && mkdir -p $PACKAGEDIR
cd $SRCDIR
echo Task [I-0] /$HOST_NATIVE/zlib/
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/
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 \
--disable-shared \
--disable-nls
make -j$JOBS
make install
#make check
popd
echo Task [I-2] /$HOST_NATIVE/mpfr/
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 \
--disable-nls \
--with-gmp=$BUILDDIR_NATIVE/host-libs/usr
make -j$JOBS
make install
#make check
popd
echo Task [I-3] /$HOST_NATIVE/mpc/
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 \
--disable-nls \
--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/
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 \
--disable-nls \
--with-gmp-prefix=$BUILDDIR_NATIVE/host-libs/usr
make
make install
#make check
popd
echo Task [I-5] /$HOST_NATIVE/cloog/
rm -rf $BUILDDIR_NATIVE/cloog && mkdir -p $BUILDDIR_NATIVE/cloog
pushd $BUILDDIR_NATIVE/cloog
$SRCDIR/$CLOOG/configure --build=$BUILD \
--host=$HOST_NATIVE \
--target=$TARGET \
--prefix=$BUILDDIR_NATIVE/host-libs/usr \
--disable-shared \
--disable-nls \
--with-bits=gmp \
--with-host-libstdcxx='-lstdc++' \
--with-gmp-prefix=$BUILDDIR_NATIVE/host-libs/usr \
--with-isl-prefix=$BUILDDIR_NATIVE/host-libs/usr
make -j$JOBS
make install
#make check
popd
echo Task [I-6] /$HOST_NATIVE/libelf/
rm -rf $BUILDDIR_NATIVE/libelf && mkdir -p $BUILDDIR_NATIVE/libelf
pushd $BUILDDIR_NATIVE/libelf
$SRCDIR/$LIBELF/configure --build=$BUILD \
--host=$HOST_NATIVE \
--target=$TARGET \
--prefix=$BUILDDIR_NATIVE/host-libs/usr \
--disable-shared \
--disable-nls
make -j$JOBS
make install
#make check
popd
echo Task [I-7] /$HOST_NATIVE/expat/
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 \
--disable-shared \
--disable-nls
make -j$JOBS
make install
popd
# 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 Task [II-0] /$HOST_MINGW/zlib/
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/
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/
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-cxx \
--disable-nls
make -j$JOBS
make install
popd
echo Task [II-3] /$HOST_MINGW/mpfr/
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 \
--disable-nls \
--with-gmp=$BUILDDIR_MINGW/host-libs/usr
make -j$JOBS
make install
popd
echo Task [II-4] /$HOST_MINGW/mpc/
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 \
--disable-nls \
--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/
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 \
--disable-nls \
--with-gmp-prefix=$BUILDDIR_MINGW/host-libs/usr
make
make install
popd
echo Task [II-6] /$HOST_MINGW/cloog/
rm -rf $BUILDDIR_MINGW/cloog && mkdir -p $BUILDDIR_MINGW/cloog
pushd $BUILDDIR_MINGW/cloog
$SRCDIR/$CLOOG/configure --build=$BUILD \
--host=$HOST_MINGW \
--target=$TARGET \
--prefix=$BUILDDIR_MINGW/host-libs/usr \
--disable-shared \
--disable-nls \
--with-bits=gmp \
--with-host-libstdcxx='-lstdc++' \
--with-gmp-prefix=$BUILDDIR_MINGW/host-libs/usr \
--with-isl-prefix=$BUILDDIR_MINGW/host-libs/usr
make -j$JOBS
make install
popd
echo Task [II-7] /$HOST_MINGW/libelf/
rm -rf $BUILDDIR_MINGW/libelf && mkdir -p $BUILDDIR_MINGW/libelf
pushd $BUILDDIR_MINGW/libelf
$SRCDIR/$LIBELF/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-8] /$HOST_MINGW/expat/
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 \
--disable-shared \
--disable-nls
make -j$JOBS
make install
popd
restoreenv