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