@@ -29,62 +29,87 @@ JOBS=$HOST_NUM_CPUS
29
29
TOOLCHAIN_NAME=arm-eabi-4.2.1
30
30
PLATFORM=android-3
31
31
ABI=arm
32
+ GCC_VERSION=4.2.1
33
+ GDB_VERSION=6.6
32
34
33
35
OPTION_HELP=no
34
36
OPTION_PLATFORM=
35
37
OPTION_FORCE_32=no
36
38
OPTION_REBUILD=no
39
+ OPTION_GCC_VERSION=
40
+ OPTION_GDB_VERSION=
41
+ OPTION_TOOLCHAIN_NAME=
42
+ OPTION_PACKAGE=
37
43
38
44
VERBOSE=no
39
45
for opt do
40
- optarg=` expr " x$opt " : ' x[^=]*=\(.*\)' `
41
- case " $opt " in
42
- --help|-h|-\? ) OPTION_HELP=yes
43
- ;;
44
- --verbose)
45
- if [ " $VERBOSE " = " yes" ] ; then
46
- VERBOSE2=yes
47
- else
48
- VERBOSE=yes
49
- fi
50
- ;;
51
- --toolchain=* )
52
- TOOLCHAIN_NAME=$optarg
53
- ;;
54
- --platform=* )
55
- PLATFORM=$optarg
56
- ;;
57
- --abi=* )
58
- ABI=$optarg
59
- ;;
60
- --force-download)
61
- OPTION_FORCE_DOWNLOAD=yes
62
- OPTION_FORCE_BUILD=yes
46
+ optarg=` expr " x$opt " : ' x[^=]*=\(.*\)' `
47
+ case " $opt " in
48
+ --help|-h|-\? ) OPTION_HELP=yes
63
49
;;
64
- --force-build)
65
- OPTION_FORCE_BUILD=yes
66
- ;;
67
- --verbose)
68
- VERBOSE=yes
69
- ;;
70
- * )
71
- echo " unknown option '$opt ', use --help"
72
- exit 1
73
- esac
50
+ --verbose)
51
+ if [ " $VERBOSE " = " yes" ] ; then
52
+ VERBOSE2=yes
53
+ else
54
+ VERBOSE=yes
55
+ fi
56
+ ;;
57
+ --gcc-version=* )
58
+ OPTION_GCC_VERSION=$optarg
59
+ ;;
60
+ --gdb-version=* )
61
+ OPTION_GDB_VERSION=$optarg
62
+ ;;
63
+ --toolchain=* )
64
+ OPTION_TOOLCHAIN_NAME=$optarg
65
+ ;;
66
+ --package=* )
67
+ OPTION_PACKAGE=" $optarg "
68
+ ;;
69
+ --platform=* )
70
+ PLATFORM=$optarg
71
+ ;;
72
+ --abi=* )
73
+ ABI=$optarg
74
+ ;;
75
+ --force-download)
76
+ OPTION_FORCE_DOWNLOAD=yes
77
+ OPTION_FORCE_BUILD=yes
78
+ ;;
79
+ --force-build)
80
+ OPTION_FORCE_BUILD=yes
81
+ ;;
82
+ --verbose)
83
+ VERBOSE=yes
84
+ ;;
85
+ * )
86
+ echo " unknown option '$opt ', use --help"
87
+ exit 1
88
+ esac
74
89
done
75
90
76
91
if [ $OPTION_HELP = " yes" ] ; then
77
92
echo " Rebuild the prebuilt binaries for the Android NDK toolchain."
93
+ echo " This script will automatically download the sources from the"
94
+ echo " Internet, unless you use the --package=<file> option to specify"
95
+ echo " the exact source package to use."
96
+ echo " "
97
+ echo " See build/tools/download-toolchain-sources.sh for a tool that"
98
+ echo " can create a compatible source package from the current"
99
+ echo " git repositories."
78
100
echo " "
79
- echo " options:"
101
+ echo " options (defaults are within brackets) :"
80
102
echo " "
81
- echo " --help print this message"
82
- echo " --toolchain=<name> toolchain name (default is $TOOLCHAIN_NAME )"
83
- echo " --platform=<name> generate toolchain from platform <name> (default is $PLATFORM )"
84
- echo " --abi=<name> generate toolchain from abi <name> (default is $ABI )"
85
- echo " --build-out=<path> set Android build out directory"
86
- echo " --force-download force a download and unpacking of the toolchain sources"
87
- echo " --force-build force a rebuild of the sources"
103
+ echo " --help print this message"
104
+ echo " --gcc-version=<version> select GCC version [$GCC_VERSION ]"
105
+ echo " --gdb-version=<version> select GDB version [$GDB_VERSION ]"
106
+ echo " --toolchain=<name> toolchain name (default is $TOOLCHAIN_NAME )"
107
+ echo " --package=<file> specify download source package"
108
+ echo " --platform=<name> generate toolchain from platform <name> (default is $PLATFORM )"
109
+ echo " --abi=<name> generate toolchain from abi <name> (default is $ABI )"
110
+ echo " --build-out=<path> set Android build out directory"
111
+ echo " --force-download force a download and unpacking of the toolchain sources"
112
+ echo " --force-build force a rebuild of the sources"
88
113
echo " "
89
114
exit 0
90
115
fi
@@ -105,19 +130,56 @@ if [ $VERBOSE = yes ] ; then
105
130
run ()
106
131
{
107
132
echo " ##### NEW COMMAND"
108
- echo $@
109
- $@ 2>&1 | tee $TMPLOG
133
+ echo " $@ "
134
+ $@ 2>&1
135
+ }
136
+ log ()
137
+ {
138
+ echo " LOG: $@ "
110
139
}
111
140
else
112
- echo " To follow build long , please use in another terminal: tail -F $TMPLOG "
141
+ echo " To follow build, please use in another terminal: tail -F $TMPLOG "
113
142
run ()
114
143
{
115
144
echo " ##### NEW COMMAND" >> $TMPLOG
116
145
echo " $@ " >> $TMPLOG
117
- $@ 1> $TMPLOG 2>&1
146
+ $@ >> $TMPLOG 2>&1
147
+ }
148
+ log ()
149
+ {
150
+ echo " $@ " > /dev/null
118
151
}
119
152
fi
120
153
154
+ if [ -n " $OPTION_GCC_VERSION " ] ; then
155
+ GCC_VERSION=" $OPTION_GCC_VERSION "
156
+ log " Using gcc version $GCC_VERSION "
157
+ else
158
+ log " Using default gcc version $GCC_VERSION "
159
+ fi
160
+
161
+ if [ -n " $OPTION_GDB_VERSION " ] ; then
162
+ GDB_VERSION=" $OPTION_GDB_VERSION "
163
+ log " Using gdb version $GDB_VERSION "
164
+ else
165
+ log " Using default gdb version $GDB_VERSION "
166
+ fi
167
+
168
+ if [ -n " $OPTION_TOOLCHAIN_NAME " ] ; then
169
+ TOOLCHAIN_NAME=" $OPTION_TOOLCHAIN_NAME "
170
+ log " Using toolchain name '$TOOLCHAIN_NAME '"
171
+ else
172
+ TOOLCHAIN_NAME=arm-eabi-$GCC_VERSION
173
+ log " Using default toolchain name '$TOOLCHAIN_NAME '"
174
+ fi
175
+
176
+ if [ -n " $OPTION_PACKAGE " ] ; then
177
+ if [ ! -f " $OPTION_PACKAGE " ] ; then
178
+ echo " Package is not a file: $OPTION_PACKAGE "
179
+ exit 1
180
+ fi
181
+ fi
182
+
121
183
ANDROID_NDK_ROOT=` cd $ANDROID_NDK_ROOT && pwd`
122
184
ANDROID_NDK_ARCHIVE=$ANDROID_NDK_ROOT /build/toolchains/archive
123
185
ANDROID_PLATFORMS_ROOT=$ANDROID_NDK_ROOT /build/platforms
@@ -193,6 +255,7 @@ download_file ()
193
255
TOOLCHAIN_SRC=$ANDROID_TOOLCHAIN_SRC
194
256
TOOLCHAIN_BUILD=$ANDROID_TOOLCHAIN_BUILD
195
257
TOOLCHAIN_PREFIX=$ANDROID_NDK_ROOT /build/prebuilt/$HOST_TAG /$TOOLCHAIN_NAME
258
+ TOOLCHAIN_LICENSES=$ANDROID_NDK_ROOT /build/tools/toolchain-licenses
196
259
197
260
GDBSERVER_BUILD=$ANDROID_GDBSERVER_BUILD
198
261
@@ -315,10 +378,10 @@ unpack_package ()
315
378
echo " Unpack : $1 sources"
316
379
echo " from $SRCPKG "
317
380
echo " into $SRCDIR "
318
- rm -rf $SRCDIR
319
- mkdir -p $SRCDIR
381
+ run rm -rf $SRCDIR
382
+ run mkdir -p $SRCDIR
320
383
TARFLAGS=xjf
321
- if [ $VERBOSE = yes ]; then
384
+ if [ $VERBOSE2 = yes ]; then
322
385
TARFLAGS=" v$TARFLAGS "
323
386
fi
324
387
run tar $TARFLAGS $SRCPKG -C $SRCDIR
@@ -350,7 +413,12 @@ if [ $? != 0 ] ; then
350
413
exit 2
351
414
fi
352
415
353
- download_package toolchain
416
+ if [ -n " $OPTION_PACKAGE " ] ; then
417
+ PKG_toolchain=" $OPTION_PACKAGE "
418
+ else
419
+ download_package toolchain
420
+ fi
421
+
354
422
unpack_package toolchain $ANDROID_TOOLCHAIN_SRC
355
423
356
424
# remove all info files from the unpacked toolchain sources
@@ -363,15 +431,21 @@ find $ANDROID_TOOLCHAIN_SRC -type f -a -name "*.info" -print0 | xargs -0 rm -f
363
431
# configure the toolchain
364
432
if ! timestamp_check toolchain configure; then
365
433
echo " Configure: toolchain build"
434
+ BUILD_SRCDIR=$TOOLCHAIN_SRC /build
435
+ if [ ! -d $BUILD_SRCDIR ] ; then
436
+ BUILD_SRCDIR=$TOOLCHAIN_SRC
437
+ fi
366
438
mkdir -p $TOOLCHAIN_BUILD &&
367
439
cd $TOOLCHAIN_BUILD &&
440
+ export ABI=" 32" && # needed to build a 32-bit gmp
368
441
export CFLAGS=" $HOST_CFLAGS " &&
369
442
export LDFLAGS=" $HOST_LDFLAGS " && run \
370
- $TOOLCHAIN_SRC /configure --target=arm-eabi \
443
+ $BUILD_SRCDIR /configure --target=arm-eabi \
371
444
--disable-nls \
372
445
--prefix=$TOOLCHAIN_PREFIX \
373
- --with-sysroot=$ANDROID_SYSROOT
374
-
446
+ --with-sysroot=$ANDROID_SYSROOT \
447
+ --with-gcc-version=$GCC_VERSION \
448
+ --with-gdb-version=$GDB_VERSION
375
449
if [ $? != 0 ] ; then
376
450
echo " Error while trying to configure toolchain build. See $TMPLOG "
377
451
exit 1
@@ -405,7 +479,7 @@ if ! timestamp_check toolchain install ; then
405
479
exit 1
406
480
fi
407
481
# don't forget to copy the GPL and LGPL license files
408
- cp -f $TOOLCHAIN_SRC /COPYING $TOOLCHAIN_SRC /COPYING.LIB $TOOLCHAIN_PREFIX
482
+ cp -f $TOOLCHAIN_LICENSES /COPYING $TOOLCHAIN_LICENSES /COPYING.LIB $TOOLCHAIN_PREFIX
409
483
# remove some unneeded files
410
484
rm -f $TOOLCHAIN_PREFIX /bin/* -gccbug
411
485
rm -rf $TOOLCHAIN_PREFIX /man $TOOLCHAIN_PREFIX /info
422
496
# configure the gdbserver build now
423
497
if ! timestamp_check gdbserver configure; then
424
498
echo " Configure: gdbserver build."
499
+ if [ -d $TOOLCHAIN_SRC /gdb ] ; then
500
+ GDB_SRCDIR=$TOOLCHAIN_SRC /gdb/gdb-$GDB_VERSION
501
+ else
502
+ GDB_SRCDIR=$TOOLCHAIN_SRC /gdb-$GDB_VERSION
503
+ fi
425
504
mkdir -p $GDBSERVER_BUILD
426
505
cd $GDBSERVER_BUILD &&
427
506
export CC=" $TOOLCHAIN_PREFIX /bin/arm-eabi-gcc" &&
428
- export CFLAGS=" -g -O2 -static -mandroid -I $ANDROID_SYSROOT /usr/include " &&
507
+ export CFLAGS=" -g -O2 -static -mandroid" &&
429
508
export LDFLAGS= &&
430
- run $TOOLCHAIN_SRC /gdb-6.6 /gdb/gdbserver/configure \
509
+ run $GDB_SRCDIR /gdb/gdbserver/configure \
431
510
--host=arm-eabi-linux \
432
511
--with-sysroot=$ANDROID_SYSROOT
433
512
if [ $? != 0 ] ; then
@@ -471,7 +550,7 @@ if ! timestamp_check gdbserver install; then
471
550
fi
472
551
473
552
# package the toolchain
474
- TOOLCHAIN_TARBALL=/tmp/prebuilt-$TOOLCHAIN_NAME -$HOST_TAG .tar.bz2
553
+ TOOLCHAIN_TARBALL=/tmp/android-ndk- prebuilt-$TOOLCHAIN_NAME -$HOST_TAG .tar.bz2
475
554
if ! timestamp_check package toolchain; then
476
555
echo " Package : $HOST_ARCH toolchain binaries"
477
556
echo " into $TOOLCHAIN_TARBALL "
@@ -486,6 +565,7 @@ if ! timestamp_check package toolchain; then
486
565
exit 1
487
566
fi
488
567
timestamp_set package toolchain
568
+ echo " prebuilt toolchain is in $TOOLCHAIN_TARBALL "
489
569
else
490
570
echo " prebuilt toolchain is in $TOOLCHAIN_TARBALL "
491
571
fi
0 commit comments