1#!/bin/sh
2#
3# Copyright (C) 2011 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17#  This shell script is used to rebuild the prebuilt GNU libsupc++ and
18#  libstdc++ binaries from their sources. It requires an NDK installation
19#  that contains valid plaforms files and toolchain binaries.
20#
21
22# include common function and variable definitions
23. `dirname $0`/prebuilt-common.sh
24
25PROGRAM_PARAMETERS="<src-dir>"
26
27PROGRAM_DESCRIPTION=\
28"Rebuild the prebuilt GNU libsupc++ / libstdc++ binaries for the Android NDK.
29
30This script is called when packaging a new NDK release. It will simply
31rebuild the GNU libsupc++ and libstdc++ static and shared libraries from
32sources.
33
34This requires a temporary NDK installation containing platforms and
35toolchain binaries for all target architectures, as well as the path to
36the corresponding gcc source tree.
37
38By default, this will try with the current NDK directory, unless
39you use the --ndk-dir=<path> option.
40
41The output will be placed in appropriate sub-directories of
42<ndk>/$GNUSTL_SUBDIR/<gcc-version>, but you can override this with the --out-dir=<path>
43option.
44"
45
46GCC_VERSION_LIST=
47register_var_option "--gcc-version-list=<vers>" GCC_VERSION_LIST "List of GCC versions"
48
49PACKAGE_DIR=
50register_var_option "--package-dir=<path>" PACKAGE_DIR "Put prebuilt tarballs into <path>."
51
52NDK_DIR=
53register_var_option "--ndk-dir=<path>" NDK_DIR "Specify NDK root path for the build."
54
55BUILD_DIR=
56OPTION_BUILD_DIR=
57register_var_option "--build-dir=<path>" OPTION_BUILD_DIR "Specify temporary build dir."
58
59OUT_DIR=
60register_var_option "--out-dir=<path>" OUT_DIR "Specify output directory directly."
61
62ABIS=$(spaces_to_commas $PREBUILT_ABIS)
63register_var_option "--abis=<list>" ABIS "Specify list of target ABIs."
64
65NO_MAKEFILE=
66register_var_option "--no-makefile" NO_MAKEFILE "Do not use makefile to speed-up build"
67
68VISIBLE_LIBGNUSTL_STATIC=
69register_var_option "--visible-libgnustl-static" VISIBLE_LIBGNUSTL_STATIC "Do not use hidden visibility for libgnustl_static.a"
70
71WITH_DEBUG_INFO=
72register_var_option "--with-debug-info" WITH_DEBUG_INFO "Build with -g.  STL is still built with optimization but with debug info"
73
74register_jobs_option
75register_try64_option
76
77extract_parameters "$@"
78
79# set compiler version to any even earlier than default
80EXPLICIT_COMPILER_VERSION=1
81if [ -z "$GCC_VERSION_LIST" ]; then
82    EXPLICIT_COMPILER_VERSION=
83    GCC_VERSION_LIST=$DEFAULT_GCC_VERSION_LIST
84fi
85
86SRCDIR=$(echo $PARAMETERS | sed 1q)
87check_toolchain_src_dir "$SRCDIR"
88
89ABIS=$(commas_to_spaces $ABIS)
90
91# Handle NDK_DIR
92if [ -z "$NDK_DIR" ] ; then
93    NDK_DIR=$ANDROID_NDK_ROOT
94    log "Auto-config: --ndk-dir=$NDK_DIR"
95else
96    if [ ! -d "$NDK_DIR" ] ; then
97        echo "ERROR: NDK directory does not exists: $NDK_DIR"
98        exit 1
99    fi
100fi
101
102if [ -z "$OPTION_BUILD_DIR" ]; then
103    BUILD_DIR=$NDK_TMPDIR/build-gnustl
104else
105    BUILD_DIR=$OPTION_BUILD_DIR
106fi
107
108HOST_TAG_LIST="$HOST_TAG $HOST_TAG32"
109
110rm -rf "$BUILD_DIR"
111mkdir -p "$BUILD_DIR"
112fail_panic "Could not create build directory: $BUILD_DIR"
113
114# $1: ABI name
115# $2: Build directory
116# $3: "static" or "shared"
117# $4: GCC version
118# $5: optional "thumb"
119build_gnustl_for_abi ()
120{
121    local ARCH BINPREFIX SYSROOT GNUSTL_SRCDIR
122    local ABI=$1
123    local BUILDDIR="$2"
124    local LIBTYPE="$3"
125    local GCC_VERSION="$4"
126    local THUMB="$5"
127    local DSTDIR=$NDK_DIR/$GNUSTL_SUBDIR/$GCC_VERSION/libs/$ABI/$THUMB
128    local SRC OBJ OBJECTS CFLAGS CXXFLAGS CPPFLAGS
129
130    prepare_target_build $ABI $PLATFORM $NDK_DIR
131    fail_panic "Could not setup target build."
132
133    INSTALLDIR=$BUILDDIR/install-$ABI-$GCC_VERSION/$THUMB
134    BUILDDIR=$BUILDDIR/$LIBTYPE-${ABI}${THUMB}-$GCC_VERSION
135
136    mkdir -p $DSTDIR
137
138    ARCH=$(convert_abi_to_arch $ABI)
139    for TAG in $HOST_TAG_LIST; do
140        BINPREFIX=$NDK_DIR/$(get_toolchain_binprefix_for_arch $ARCH $GCC_VERSION $TAG)
141        if [ -f ${BINPREFIX}gcc ]; then
142            break;
143        fi
144    done
145    GNUSTL_SRCDIR=$SRCDIR/gcc/gcc-$GCC_VERSION/libstdc++-v3
146    # Sanity check
147    if [ ! -d "$GNUSTL_SRCDIR" ]; then
148        echo "ERROR: Not a valid toolchain source tree."
149        echo "Can't find: $GNUSTL_SRCDIR"
150        exit 1
151    fi
152
153    if [ ! -f "$GNUSTL_SRCDIR/configure" ]; then
154        echo "ERROR: Configure script missing: $GNUSTL_SRCDIR/configure"
155        exit 1
156    fi
157
158    SYSROOT=$NDK_DIR/$(get_default_platform_sysroot_for_arch $ARCH)
159    LDIR=$SYSROOT"/usr/"$(get_default_libdir_for_arch $ARCH)
160    # Sanity check
161    if [ ! -f "$LDIR/libc.a" ]; then
162	echo "ERROR: Empty sysroot! you probably need to run gen-platforms.sh before this script."
163	exit 1
164    fi
165    if [ ! -f "$LDIR/libc.so" ]; then
166        echo "ERROR: Sysroot misses shared libraries! you probably need to run gen-platforms.sh"
167        echo "*without* the --minimal flag before running this script."
168        exit 1
169    fi
170
171    EXTRA_CFLAGS="-ffunction-sections -fdata-sections"
172    EXTRA_LDFLAGS=
173    if [ -n "$THUMB" ] ; then
174        EXTRA_CFLAGS="$EXTRA_CFLAGS -mthumb"
175        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -mthumb"
176    fi
177
178    case $ARCH in
179        arm)
180            BUILD_HOST=arm-linux-androideabi
181            ;;
182        arm64)
183            BUILD_HOST=aarch64-linux-android
184            ;;
185        x86)
186            BUILD_HOST=i686-linux-android
187            # ToDo: remove the following once all x86-based device call JNI function with
188            #       stack aligned to 16-byte
189            EXTRA_CFLAGS="$EXTRA_CFLAGS -mstackrealign"
190            ;;
191        x86_64)
192            BUILD_HOST=x86_64-linux-android
193            # ToDo: remove the following once all x86-based device call JNI function with
194            #       stack aligned to 16-byte
195            EXTRA_CFLAGS="$EXTRA_CFLAGS -mstackrealign"
196            ;;
197        mips)
198            BUILD_HOST=mipsel-linux-android
199            ;;
200        mips64)
201            BUILD_HOST=mips64el-linux-android
202            ;;
203    esac
204
205    CFLAGS="-fPIC $CFLAGS --sysroot=$SYSROOT -fexceptions -funwind-tables -D__BIONIC__ -O2 $EXTRA_CFLAGS"
206    CXXFLAGS="-fPIC $CXXFLAGS --sysroot=$SYSROOT -fexceptions -frtti -funwind-tables -D__BIONIC__ -O2 $EXTRA_CFLAGS"
207    CPPFLAGS="$CPPFLAGS --sysroot=$SYSROOT"
208    if [ "$WITH_DEBUG_INFO" ]; then
209        CFLAGS="$CFLAGS -g"
210        CXXFLAGS="$CXXFLAGS -g"
211    fi
212    export CFLAGS CXXFLAGS CPPFLAGS
213
214    export CC=${BINPREFIX}gcc
215    export CXX=${BINPREFIX}g++
216    export AS=${BINPREFIX}as
217    export LD=${BINPREFIX}ld
218    export AR=${BINPREFIX}ar
219    export RANLIB=${BINPREFIX}ranlib
220    export STRIP=${BINPREFIX}strip
221
222    setup_ccache
223
224    export LDFLAGS="-lc $EXTRA_LDFLAGS"
225
226    case $ABI in
227        armeabi-v7a|armeabi-v7a-hard)
228            CXXFLAGS=$CXXFLAGS" -march=armv7-a -mfpu=vfpv3-d16"
229            LDFLAGS=$LDFLAGS" -Wl,--fix-cortex-a8"
230            if [ "$ABI" != "armeabi-v7a-hard" ]; then
231                CXXFLAGS=$CXXFLAGS" -mfloat-abi=softfp"
232            else
233                CXXFLAGS=$CXXFLAGS" -mhard-float -D_NDK_MATH_NO_SOFTFP=1"
234                LDFLAGS=$LDFLAGS" -Wl,--no-warn-mismatch -lm_hard"
235            fi
236            ;;
237        arm64-v8a)
238            CFLAGS="$CFLAGS -mfix-cortex-a53-835769"
239            CXXFLAGS=$CXXFLAGS" -mfix-cortex-a53-835769"
240            ;;
241    esac
242
243    if [ "$ABI" = "armeabi" -o "$ABI" = "armeabi-v7a" -o "$ABI" = "armeabi-v7a-hard" ]; then
244        CFLAGS=$CFLAGS" -minline-thumb1-jumptable"
245        CXXFLAGS=$CXXFLAGS" -minline-thumb1-jumptable"
246    fi
247
248    LIBTYPE_FLAGS=
249    if [ $LIBTYPE = "static" ]; then
250        # Ensure we disable visibility for the static library to reduce the
251        # size of the code that will be linked against it.
252        if [ -z "$VISIBLE_LIBGNUSTL_STATIC" ] ; then
253            LIBTYPE_FLAGS="--enable-static --disable-shared"
254            if [ $GCC_VERSION = "4.4.3" -o $GCC_VERSION = "4.6" ]; then
255                LIBTYPE_FLAGS=$LIBTYPE_FLAGS" --disable-visibility"
256            else
257                LIBTYPE_FLAGS=$LIBTYPE_FLAGS" --disable-libstdcxx-visibility"
258            fi
259            CXXFLAGS=$CXXFLAGS" -fvisibility=hidden -fvisibility-inlines-hidden"
260        fi
261    else
262        LIBTYPE_FLAGS="--disable-static --enable-shared"
263        #LDFLAGS=$LDFLAGS" -lsupc++"
264    fi
265
266    if [ "$ARCH" = "x86_64" -o "$ARCH" = "mips64" -o "$ARCH" = "mips" ] ; then
267        MULTILIB_FLAGS=
268    elif [ "$ARCH" = "mips" -a $GCC_VERSION = "4.9" ] ; then
269        MULTILIB_FLAGS=
270    else
271        MULTILIB_FLAGS=--disable-multilib
272    fi
273
274    PROJECT="gnustl_$LIBTYPE gcc-$GCC_VERSION $ABI $THUMB"
275    echo "$PROJECT: configuring"
276    mkdir -p $BUILDDIR && rm -rf $BUILDDIR/* &&
277    cd $BUILDDIR &&
278    run $GNUSTL_SRCDIR/configure \
279        --prefix=$INSTALLDIR \
280        --host=$BUILD_HOST \
281        $LIBTYPE_FLAGS \
282        --enable-libstdcxx-time \
283        --disable-symvers \
284        $MULTILIB_FLAGS \
285        --disable-nls \
286        --disable-sjlj-exceptions \
287        --disable-tls \
288        --disable-libstdcxx-pch \
289        --with-gxx-include-dir=$INSTALLDIR/include/c++/$GCC_VERSION
290
291    fail_panic "Could not configure $PROJECT"
292
293    echo "$PROJECT: compiling"
294    run make -j$NUM_JOBS
295    fail_panic "Could not build $PROJECT"
296
297    echo "$PROJECT: installing"
298    run make install
299    fail_panic "Could not create $ABI $THUMB prebuilts for GNU libsupc++/libstdc++"
300}
301
302
303HAS_COMMON_HEADERS=
304
305# $1: ABI
306# $2: Build directory
307# $3: GCC_VERSION
308copy_gnustl_libs ()
309{
310    local ABI="$1"
311    local BUILDDIR="$2"
312    local ARCH=$(convert_abi_to_arch $ABI)
313    local GCC_VERSION="$3"
314    local PREFIX=$(get_default_toolchain_prefix_for_arch $ARCH)
315    PREFIX=${PREFIX%%-}
316
317    local SDIR="$BUILDDIR/install-$ABI-$GCC_VERSION"
318    local DDIR="$NDK_DIR/$GNUSTL_SUBDIR/$GCC_VERSION"
319
320    local GCC_VERSION_NO_DOT=$(echo $GCC_VERSION|sed 's/\./_/g')
321    # Copy the common headers only once per gcc version
322    if [ -z `var_value HAS_COMMON_HEADERS_$GCC_VERSION_NO_DOT` ]; then
323        copy_directory "$SDIR/include/c++/$GCC_VERSION" "$DDIR/include"
324        rm -rf "$DDIR/include/$PREFIX"
325	eval HAS_COMMON_HEADERS_$GCC_VERSION_NO_DOT=true
326    fi
327
328    rm -rf "$DDIR/libs/$ABI" &&
329    mkdir -p "$DDIR/libs/$ABI/include"
330
331    # Copy the ABI-specific headers
332    copy_directory "$SDIR/include/c++/$GCC_VERSION/$PREFIX/bits" "$DDIR/libs/$ABI/include/bits"
333    case "$ARCH" in
334        x86_64)
335            copy_directory "$SDIR/include/c++/$GCC_VERSION/$PREFIX/32/bits" "$DDIR/libs/$ABI/include/32/bits"
336            copy_directory "$SDIR/include/c++/$GCC_VERSION/$PREFIX/x32/bits" "$DDIR/libs/$ABI/include/x32/bits"
337            ;;
338        mips64)
339            copy_directory "$SDIR/include/c++/$GCC_VERSION/$PREFIX/32/mips-r1/bits" "$DDIR/libs/$ABI/include/32/mips-r1/bits"
340            copy_directory "$SDIR/include/c++/$GCC_VERSION/$PREFIX/32/mips-r2/bits" "$DDIR/libs/$ABI/include/32/mips-r2/bits"
341            copy_directory "$SDIR/include/c++/$GCC_VERSION/$PREFIX/32/mips-r6/bits" "$DDIR/libs/$ABI/include/32/mips-r6/bits"
342            copy_directory "$SDIR/include/c++/$GCC_VERSION/$PREFIX/mips64-r2/bits" "$DDIR/libs/$ABI/include/mips64-r2/bits"
343            ;;
344        mips)
345            if [ "$GCC_VERSION" = "4.9" ]; then
346                copy_directory "$SDIR/include/c++/$GCC_VERSION/$PREFIX/mips-r2/bits" "$DDIR/libs/$ABI/include/mips-r2/bits"
347                copy_directory "$SDIR/include/c++/$GCC_VERSION/$PREFIX/mips-r6/bits" "$DDIR/libs/$ABI/include/mips-r6/bits"
348	    fi
349            ;;
350    esac
351
352    LDIR=lib
353    if [ "$ABI" = "mips32r6" ]; then
354        LDIR=libr6
355    elif [ "$ARCH" != "${ARCH%%64*}" ]; then
356        #Can't call $(get_default_libdir_for_arch $ARCH) which contain hack for arm64
357        LDIR=lib64
358    fi
359
360    # Copy the ABI-specific libraries
361    # Note: the shared library name is libgnustl_shared.so due our custom toolchain patch
362    copy_file_list "$SDIR/$LDIR" "$DDIR/libs/$ABI" libsupc++.a libgnustl_shared.so
363    # Note: we need to rename libgnustl_shared.a to libgnustl_static.a
364    cp "$SDIR/$LDIR/libgnustl_shared.a" "$DDIR/libs/$ABI/libgnustl_static.a"
365    case "$ARCH" in
366       # for multilib we copy full set. Keep native libs in $ABI dir for compatibility.
367       # TODO: remove it in $ABI top directory
368        x86_64)
369            copy_file_list "$SDIR/lib" "$DDIR/libs/$ABI/lib" libsupc++.a libgnustl_shared.so
370            copy_file_list "$SDIR/lib64" "$DDIR/libs/$ABI/lib64" libsupc++.a libgnustl_shared.so
371            copy_file_list "$SDIR/libx32" "$DDIR/libs/$ABI/libx32" libsupc++.a libgnustl_shared.so
372            cp "$SDIR/lib/libgnustl_shared.a" "$DDIR/libs/$ABI/lib/libgnustl_static.a"
373            cp "$SDIR/lib64/libgnustl_shared.a" "$DDIR/libs/$ABI/lib64/libgnustl_static.a"
374            cp "$SDIR/libx32/libgnustl_shared.a" "$DDIR/libs/$ABI/libx32/libgnustl_static.a"
375            ;;
376        mips64)
377            copy_file_list "$SDIR/lib" "$DDIR/libs/$ABI/lib" libsupc++.a libgnustl_shared.so
378            copy_file_list "$SDIR/libr2" "$DDIR/libs/$ABI/libr2" libsupc++.a libgnustl_shared.so
379            copy_file_list "$SDIR/libr6" "$DDIR/libs/$ABI/libr6" libsupc++.a libgnustl_shared.so
380            copy_file_list "$SDIR/lib64" "$DDIR/libs/$ABI/lib64" libsupc++.a libgnustl_shared.so
381            copy_file_list "$SDIR/lib64r2" "$DDIR/libs/$ABI/lib64r2" libsupc++.a libgnustl_shared.so
382            cp "$SDIR/lib/libgnustl_shared.a" "$DDIR/libs/$ABI/lib/libgnustl_static.a"
383            cp "$SDIR/libr2/libgnustl_shared.a" "$DDIR/libs/$ABI/libr2/libgnustl_static.a"
384            cp "$SDIR/libr6/libgnustl_shared.a" "$DDIR/libs/$ABI/libr6/libgnustl_static.a"
385            cp "$SDIR/lib64/libgnustl_shared.a" "$DDIR/libs/$ABI/lib64/libgnustl_static.a"
386            cp "$SDIR/lib64r2/libgnustl_shared.a" "$DDIR/libs/$ABI/lib64r2/libgnustl_static.a"
387            ;;
388        mips)
389            if [ "$GCC_VERSION" = "4.9" ]; then
390                copy_file_list "$SDIR/lib" "$DDIR/libs/$ABI/lib" libsupc++.a libgnustl_shared.so
391                copy_file_list "$SDIR/libr2" "$DDIR/libs/$ABI/libr2" libsupc++.a libgnustl_shared.so
392                copy_file_list "$SDIR/libr6" "$DDIR/libs/$ABI/libr6" libsupc++.a libgnustl_shared.so
393                cp "$SDIR/lib/libgnustl_shared.a" "$DDIR/libs/$ABI/lib/libgnustl_static.a"
394                cp "$SDIR/libr2/libgnustl_shared.a" "$DDIR/libs/$ABI/libr2/libgnustl_static.a"
395                cp "$SDIR/libr6/libgnustl_shared.a" "$DDIR/libs/$ABI/libr6/libgnustl_static.a"
396	    fi
397            ;;
398    esac
399
400    if [ -d "$SDIR/thumb" ] ; then
401        copy_file_list "$SDIR/thumb/$LDIR" "$DDIR/libs/$ABI/thumb" libsupc++.a libgnustl_shared.so
402        cp "$SDIR/thumb/$LDIR/libgnustl_shared.a" "$DDIR/libs/$ABI/thumb/libgnustl_static.a"
403    fi
404}
405
406GCC_VERSION_LIST=$(commas_to_spaces $GCC_VERSION_LIST)
407for ABI in $ABIS; do
408    ARCH=$(convert_abi_to_arch $ABI)
409    FIRST_GCC_VERSION=$(get_first_gcc_version_for_arch $ARCH)
410    for VERSION in $GCC_VERSION_LIST; do
411        # Only build for this GCC version if it on or after FIRST_GCC_VERSION
412        if [ -z "$EXPLICIT_COMPILER_VERSION" ] && version_is_at_least "${VERSION%%l}" "$FIRST_GCC_VERSION"; then
413            continue
414        fi
415
416        build_gnustl_for_abi $ABI "$BUILD_DIR" static $VERSION
417        build_gnustl_for_abi $ABI "$BUILD_DIR" shared $VERSION
418        # build thumb version of libraries for 32-bit arm
419        if [ "$ABI" != "${ABI%%arm*}" -a "$ABI" = "${ABI%%64*}" ] ; then
420            build_gnustl_for_abi $ABI "$BUILD_DIR" static $VERSION thumb
421            build_gnustl_for_abi $ABI "$BUILD_DIR" shared $VERSION thumb
422        fi
423        copy_gnustl_libs $ABI "$BUILD_DIR" $VERSION
424    done
425done
426
427# If needed, package files into tarballs
428if [ -n "$PACKAGE_DIR" ] ; then
429    for VERSION in $GCC_VERSION_LIST; do
430        # First, the headers as a single package for a given gcc version
431        PACKAGE="$PACKAGE_DIR/gnu-libstdc++-headers-$VERSION.tar.bz2"
432        dump "Packaging: $PACKAGE"
433        pack_archive "$PACKAGE" "$NDK_DIR" "$GNUSTL_SUBDIR/$VERSION/include"
434
435        # Then, one package per version/ABI for libraries
436        for ABI in $ABIS; do
437            if [ ! -d "$NDK_DIR/$GNUSTL_SUBDIR/$VERSION/libs/$ABI" ]; then
438                continue
439            fi
440            FILES=""
441            case "$ABI" in
442                x86_64)
443                    MULTILIB="include/32/bits include/x32/bits
444                              lib/libsupc++.a lib/libgnustl_static.a lib/libgnustl_shared.so
445                              libx32/libsupc++.a libx32/libgnustl_static.a libx32/libgnustl_shared.so
446                              lib64/libsupc++.a lib64/libgnustl_static.a lib64/libgnustl_shared.so"
447                    ;;
448                mips64)
449                    MULTILIB="include/32/mips-r1/bits include/32/mips-r2/bits include/32/mips-r6/bits include/bits include/mips64-r2/bits
450                              lib/libsupc++.a lib/libgnustl_static.a lib/libgnustl_shared.so
451                              libr2/libsupc++.a libr2/libgnustl_static.a libr2/libgnustl_shared.so
452                              libr6/libsupc++.a libr6/libgnustl_static.a libr6/libgnustl_shared.so
453                              lib64/libsupc++.a lib64/libgnustl_static.a lib64/libgnustl_shared.so
454                              lib64r2/libsupc++.a lib64r2/libgnustl_static.a lib64r2/libgnustl_shared.so"
455                    ;;
456                mips|mips32r6)
457                    if [ "$VERSION" = "4.9" ]; then
458                        MULTILIB="include/mips-r2/bits include/mips-r6/bits include/bits
459                                  lib/libsupc++.a lib/libgnustl_static.a lib/libgnustl_shared.so
460                                  libr2/libsupc++.a libr2/libgnustl_static.a libr2/libgnustl_shared.so
461                                  libr6/libsupc++.a libr6/libgnustl_static.a libr6/libgnustl_shared.so"
462                    else
463                        MULTILIB=
464                    fi
465                    ;;
466                *)
467                    MULTILIB=
468                    ;;
469            esac
470            for LIB in include/bits $MULTILIB libsupc++.a libgnustl_static.a libgnustl_shared.so; do
471                FILES="$FILES $GNUSTL_SUBDIR/$VERSION/libs/$ABI/$LIB"
472                THUMB_FILE="$GNUSTL_SUBDIR/$VERSION/libs/$ABI/thumb/$LIB"
473                if [ -f "$NDK_DIR/$THUMB_FILE" ] ; then
474                    FILES="$FILES $THUMB_FILE"
475                fi
476            done
477            PACKAGE="$PACKAGE_DIR/gnu-libstdc++-libs-$VERSION-$ABI"
478            if [ "$WITH_DEBUG_INFO" ]; then
479                PACKAGE="${PACKAGE}-g"
480            fi
481            PACKAGE="${PACKAGE}.tar.bz2"
482            dump "Packaging: $PACKAGE"
483            pack_archive "$PACKAGE" "$NDK_DIR" "$FILES"
484            fail_panic "Could not package $ABI GNU libstdc++ binaries!"
485        done
486    done
487fi
488
489if [ -z "$OPTION_BUILD_DIR" ]; then
490    log "Cleaning up..."
491    rm -rf $BUILD_DIR
492else
493    log "Don't forget to cleanup: $BUILD_DIR"
494fi
495
496log "Done!"
497