Home | History | Annotate | Download | only in tools
      1 # Copyright (C) 2010 The Android Open Source Project
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
      4 # you may not use this file except in compliance with the License.
      5 # You may obtain a copy of the License at
      6 #
      7 #      http://www.apache.org/licenses/LICENSE-2.0
      8 #
      9 # Unless required by applicable law or agreed to in writing, software
     10 # distributed under the License is distributed on an "AS IS" BASIS,
     11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     14 #
     15 
     16 # Create a standalone toolchain package for Android.
     17 
     18 . `dirname $0`/prebuilt-common.sh
     19 
     20 PROGRAM_PARAMETERS=""
     21 PROGRAM_DESCRIPTION=\
     22 "Generate a customized Android toolchain installation that includes
     23 a working sysroot. The result is something that can more easily be
     24 used as a standalone cross-compiler, e.g. to run configure and
     25 make scripts."
     26 
     27 # For now, this is the only toolchain that works reliably.
     28 TOOLCHAIN_NAME=
     29 register_var_option "--toolchain=<name>" TOOLCHAIN_NAME "Specify toolchain name"
     30 
     31 LLVM_VERSION=
     32 register_var_option "--llvm-version=<ver>" LLVM_VERSION "Specify LLVM version"
     33 
     34 STL=gnustl
     35 register_var_option "--stl=<name>" STL "Specify C++ STL"
     36 
     37 ARCH=
     38 register_option "--arch=<name>" do_arch "Specify target architecture" "arm"
     39 do_arch () { ARCH=$1; }
     40 
     41 NDK_DIR=`dirname $0`
     42 NDK_DIR=`dirname $NDK_DIR`
     43 NDK_DIR=`dirname $NDK_DIR`
     44 register_var_option "--ndk-dir=<path>" NDK_DIR "Take source files from NDK at <path>"
     45 
     46 if [ -d "$NDK_DIR/prebuilt/$HOST_TAG" ]; then
     47   SYSTEM=$HOST_TAG
     48 else
     49   SYSTEM=$HOST_TAG32
     50 fi
     51 register_var_option "--system=<name>" SYSTEM "Specify host system"
     52 
     53 PACKAGE_DIR=/tmp/ndk-$USER
     54 register_var_option "--package-dir=<path>" PACKAGE_DIR "Place package file in <path>"
     55 
     56 INSTALL_DIR=
     57 register_var_option "--install-dir=<path>" INSTALL_DIR "Don't create package, install files to <path> instead."
     58 
     59 PLATFORM=
     60 register_option "--platform=<name>" do_platform "Specify target Android platform/API level." "android-3"
     61 do_platform () { PLATFORM=$1; }
     62 
     63 extract_parameters "$@"
     64 
     65 # Check NDK_DIR
     66 if [ ! -d "$NDK_DIR/build/core" ] ; then
     67     echo "Invalid source NDK directory: $NDK_DIR"
     68     echo "Please use --ndk-dir=<path> to specify the path of an installed NDK."
     69     exit 1
     70 fi
     71 
     72 # Check ARCH
     73 if [ -z "$ARCH" ]; then
     74     case $TOOLCHAIN_NAME in
     75         arm-*)
     76             ARCH=arm
     77             ;;
     78         x86-*)
     79             ARCH=x86
     80             ;;
     81         mips*)
     82             ARCH=mips
     83             ;;
     84         *)
     85             ARCH=arm
     86             ;;
     87     esac
     88     ARCH_INC=$ARCH
     89     log "Auto-config: --arch=$ARCH"
     90 else
     91     ARCH_INC=$ARCH
     92     case $ARCH in
     93         *arm)
     94             ARCH=arm
     95             ;;
     96         *x86)
     97             ARCH=x86
     98             ;;
     99         *mips)
    100             ARCH=mips
    101             ;;
    102         *)
    103             ARCH=arm
    104             ;;
    105     esac
    106 fi
    107 test "$ARCH_INC" != "$ARCH" && ARCH_INC=$(find_ndk_unknown_archs)
    108 test -z "$ARCH_INC" && ARCH_INC="$ARCH"
    109 
    110 # Check toolchain name
    111 if [ -z "$TOOLCHAIN_NAME" ]; then
    112     TOOLCHAIN_NAME=$(get_default_toolchain_name_for_arch $ARCH)
    113     echo "Auto-config: --toolchain=$TOOLCHAIN_NAME"
    114 fi
    115 
    116 test "$ARCH_INC" != "$ARCH" && STL=stlport && TARGET_ABI=$(convert_arch_to_abi $ARCH | tr ',' '\n' | tail -n 1)
    117 test "$ARCH_INC" != "$ARCH" -a -z "$LLVM_VERSION" && LLVM_VERSION=$DEFAULT_LLVM_VERSION
    118 # Detect LLVM version from toolchain name
    119 if [ -z "$LLVM_VERSION" ]; then
    120     LLVM_VERSION_EXTRACT=$(echo "$TOOLCHAIN_NAME" | grep 'clang[0-9]\.[0-9]$' | sed -e 's/.*-clang//')
    121     if [ -n "$LLVM_VERSION_EXTRACT" ]; then
    122         TOOLCHAIN_NAME=$(get_default_toolchain_name_for_arch $ARCH)
    123         LLVM_VERSION=$LLVM_VERSION_EXTRACT
    124         echo "Auto-config: --toolchain=$TOOLCHAIN_NAME, --llvm-version=$LLVM_VERSION"
    125     fi
    126 fi
    127 
    128 # Check PLATFORM
    129 if [ -z "$PLATFORM" ]; then
    130     case $ARCH in
    131         arm) PLATFORM=android-3
    132             ;;
    133         x86)
    134             PLATFORM=android-9
    135             ;;
    136         mips)
    137             # Set it to android-9
    138             PLATFORM=android-9
    139             ;;
    140     esac
    141     log "Auto-config: --platform=$PLATFORM"
    142 fi
    143 
    144 if [ ! -d "$NDK_DIR/platforms/$PLATFORM" ] ; then
    145     echo "Invalid platform name: $PLATFORM"
    146     echo "Please use --platform=<name> with one of:" `(cd "$NDK_DIR/platforms" && ls)`
    147     exit 1
    148 fi
    149 
    150 # Check toolchain name
    151 TOOLCHAIN_PATH="$NDK_DIR/toolchains/$TOOLCHAIN_NAME"
    152 if [ ! -d "$TOOLCHAIN_PATH" ] ; then
    153     echo "Invalid toolchain name: $TOOLCHAIN_NAME"
    154     echo "Please use --toolchain=<name> with the name of a toolchain supported by the source NDK."
    155     echo "Try one of: " `(cd "$NDK_DIR/toolchains" && ls)`
    156     exit 1
    157 fi
    158 
    159 # Extract architecture from platform name
    160 parse_toolchain_name $TOOLCHAIN_NAME
    161 
    162 # Check that there are any platform files for it!
    163 (cd $NDK_DIR/platforms && ls -d */arch-$ARCH_INC >/dev/null 2>&1 )
    164 if [ $? != 0 ] ; then
    165     echo "Platform $PLATFORM doesn't have any files for this architecture: $ARCH_INC"
    166     echo "Either use --platform=<name> or --toolchain=<name> to select a different"
    167     echo "platform or arch-dependent toolchain name (respectively)!"
    168     exit 1
    169 fi
    170 
    171 # Compute source sysroot
    172 SRC_SYSROOT_INC="$NDK_DIR/platforms/$PLATFORM/arch-$ARCH_INC/usr/include"
    173 SRC_SYSROOT_LIB="$NDK_DIR/platforms/$PLATFORM/arch-$ARCH/usr/lib"
    174 if [ ! -d "$SRC_SYSROOT_INC" -o ! -d "$SRC_SYSROOT_LIB" ] ; then
    175     echo "No platform files ($PLATFORM) for this architecture: $ARCH"
    176     exit 1
    177 fi
    178 
    179 # Check that we have any prebuilts GCC toolchain here
    180 if [ ! -d "$TOOLCHAIN_PATH/prebuilt" ] ; then
    181     echo "Toolchain is missing prebuilt files: $TOOLCHAIN_NAME"
    182     echo "You must point to a valid NDK release package!"
    183     exit 1
    184 fi
    185 
    186 if [ ! -d "$TOOLCHAIN_PATH/prebuilt/$SYSTEM" ] ; then
    187     echo "Host system '$SYSTEM' is not supported by the source NDK!"
    188     echo "Try --system=<name> with one of: " `(cd $TOOLCHAIN_PATH/prebuilt && ls) | grep -v gdbserver`
    189     exit 1
    190 fi
    191 
    192 TOOLCHAIN_PATH="$TOOLCHAIN_PATH/prebuilt/$SYSTEM"
    193 TOOLCHAIN_GCC=$TOOLCHAIN_PATH/bin/$ABI_CONFIGURE_TARGET-gcc
    194 
    195 if [ ! -f "$TOOLCHAIN_GCC" ] ; then
    196     echo "Toolchain $TOOLCHAIN_GCC is missing!"
    197     exit 1
    198 fi
    199 
    200 if [ -n "$LLVM_VERSION" ]; then
    201     LLVM_TOOLCHAIN_PATH="$NDK_DIR/toolchains/llvm-$LLVM_VERSION"
    202     # Check that we have any prebuilts LLVM toolchain here
    203     if [ ! -d "$LLVM_TOOLCHAIN_PATH/prebuilt" ] ; then
    204         echo "LLVM Toolchain is missing prebuilt files"
    205         echo "You must point to a valid NDK release package!"
    206         exit 1
    207     fi
    208 
    209     if [ ! -d "$LLVM_TOOLCHAIN_PATH/prebuilt/$SYSTEM" ] ; then
    210         echo "Host system '$SYSTEM' is not supported by the source NDK!"
    211         echo "Try --system=<name> with one of: " `(cd $LLVM_TOOLCHAIN_PATH/prebuilt && ls)`
    212         exit 1
    213     fi
    214     LLVM_TOOLCHAIN_PATH="$LLVM_TOOLCHAIN_PATH/prebuilt/$SYSTEM"
    215 fi
    216 
    217 # Get GCC_BASE_VERSION.  Note that GCC_BASE_VERSION may be slightly different from GCC_VERSION.
    218 # eg. In gcc4.6 GCC_BASE_VERSION is "4.6.x-google"
    219 LIBGCC_PATH=`$TOOLCHAIN_GCC -print-libgcc-file-name`
    220 LIBGCC_BASE_PATH=${LIBGCC_PATH%/*}         # base path of libgcc.a
    221 GCC_BASE_VERSION=${LIBGCC_BASE_PATH##*/}   # stuff after the last /
    222 
    223 # Create temporary directory
    224 TMPDIR=$NDK_TMPDIR/standalone/$TOOLCHAIN_NAME
    225 
    226 dump "Copying prebuilt binaries..."
    227 # Now copy the GCC toolchain prebuilt binaries
    228 run copy_directory "$TOOLCHAIN_PATH" "$TMPDIR"
    229 
    230 # Replace soft-link mcld by real file
    231 ALL_LDS=`find $TMPDIR -name "*mcld"`
    232 for LD in $ALL_LDS; do
    233   rm -f "$LD"
    234   cp -a "$NDK_DIR/toolchains/llvm-$DEFAULT_LLVM_VERSION/prebuilt/$SYSTEM/bin/ld.mcld" "$LD"
    235 done
    236 
    237 # Copy python-related to for gdb.exe
    238 PYTHON=python
    239 PYTHON_x=python$(echo "$DEFAULT_PYTHON_VERSION" | cut -d . -f 1)
    240 PYTHON_xdotx=python$(echo "$DEFAULT_PYTHON_VERSION" | cut -d . -f 1).$(echo "$DEFAULT_PYTHON_VERSION" | cut -d . -f 2)
    241 copy_directory "$NDK_DIR/prebuilt/$SYSTEM/include/$PYTHON_xdotx" "$TMPDIR/include/$PYTHON_xdotx"
    242 copy_directory "$NDK_DIR/prebuilt/$SYSTEM/lib/$PYTHON_xdotx" "$TMPDIR/lib/$PYTHON_xdotx"
    243 copy_file_list "$NDK_DIR/prebuilt/$SYSTEM/bin" "$TMPDIR/bin" "$PYTHON$HOST_EXE" "$PYTHON_x$HOST_EXE" "$PYTHON_xdotx$HOST_EXE"
    244 if [ "$HOST_TAG32" = "windows" ]; then
    245   copy_file_list "$NDK_DIR/prebuilt/$SYSTEM/bin" "$TMPDIR/bin" lib$PYTHON_xdotx.dll
    246 fi
    247 
    248 dump_extra_compile_commands () {
    249   if [ "$ARCH_INC" = "$ARCH" ]; then
    250     return
    251   fi
    252 
    253   if [ -z "$HOST_EXE" ]; then
    254     echo '# Call bc2native if needed'
    255     echo ''
    256     echo 'if [ -n "`echo $@ | grep '\'\\ \\-c\''`" ] || [ "$1" = "-c" ]; then'
    257     echo '  exit'
    258     echo 'fi'
    259 
    260     echo 'while [ -n "$1" ]; do'
    261     echo '  if [ "$1" = "-o" ]; then'
    262     echo '    output="$2"'
    263     echo '    break'
    264     echo '  fi'
    265     echo '  shift'
    266     echo 'done'
    267     echo 'test -z "$output" && output=a.out'
    268     echo 'export PYTHONPATH=`dirname $0`/../lib/python2.7/'
    269     echo '`dirname $0`/python `dirname $0`/ndk-bc2native.py --sysroot=`dirname $0`/../sysroot --abi='$TARGET_ABI' --platform='$PLATFORM' --file $output $output'
    270   else
    271     echo 'rem Call bc2native if needed'
    272     echo ''
    273     echo '  if not "%1" == "-c" goto :keep_going'
    274     echo '  echo %* | grep "\\ \\-c"'
    275     echo '  if ERRORLEVEL 1 goto :keep_going'
    276     echo '  exit'
    277     echo ':keep_going'
    278 
    279     echo ':keep_find_output'
    280     echo '  if not "%1" == "-o" goto :check_next'
    281     echo '  set output=%2'
    282     echo ':check_next'
    283     echo '  shift'
    284     echo '  if "%1" == "" goto :keep_find_output'
    285     echo '  if not "%output%" == "" goto :check_done'
    286     echo '  set output=a.out'
    287     echo ':check_done'
    288     echo 'set PYTHONPATH=%~dp0\\..\\lib\\python2.7\\'
    289     echo '%~dp0\\python'$HOST_EXE' %~dp0\\ndk-bc2native.py --sysroot=%~dp0\\..\\sysroot --abi='$TARGET_ABI' --platform='$PLATFORM' --file %output% %output%'
    290   fi
    291 }
    292 
    293 if [ -n "$LLVM_VERSION" ]; then
    294   # Copy the clang/llvm toolchain prebuilt binaries
    295   run copy_directory "$LLVM_TOOLCHAIN_PATH" "$TMPDIR"
    296 
    297   # Move clang and clang++ to clang${LLVM_VERSION} and clang${LLVM_VERSION}++,
    298   # then create scripts linking them with predefined -target flag.  This is to
    299   # make clang/++ easier drop-in replacement for gcc/++ in NDK standalone mode.
    300   # Note that the file name of "clang" isn't important, and the trailing
    301   # "++" tells clang to compile in C++ mode
    302   LLVM_TARGET=
    303   case "$ARCH" in
    304       arm) # NOte: -target may change by clang based on the
    305            #        presence of subsequent -march=armv7-a and/or -mthumb
    306           LLVM_TARGET=armv5te-none-linux-androideabi
    307           TOOLCHAIN_PREFIX=$DEFAULT_ARCH_TOOLCHAIN_PREFIX_arm
    308           ;;
    309       x86)
    310           LLVM_TARGET=i686-none-linux-android
    311           TOOLCHAIN_PREFIX=$DEFAULT_ARCH_TOOLCHAIN_PREFIX_x86
    312           ;;
    313       mips)
    314           LLVM_TARGET=mipsel-none-linux-android
    315           TOOLCHAIN_PREFIX=$DEFAULT_ARCH_TOOLCHAIN_PREFIX_mips
    316           ;;
    317       *)
    318         dump "ERROR: Unsupported NDK architecture!"
    319   esac
    320   # Need to remove '.' from LLVM_VERSION when constructing new clang name,
    321   # otherwise clang3.3++ may still compile *.c code as C, not C++, which
    322   # is not consistent with g++
    323   LLVM_VERSION_WITHOUT_DOT=$(echo "$LLVM_VERSION" | sed -e "s!\.!!")
    324   mv "$TMPDIR/bin/clang${HOST_EXE}" "$TMPDIR/bin/clang${LLVM_VERSION_WITHOUT_DOT}${HOST_EXE}"
    325   if [ -h "$TMPDIR/bin/clang++${HOST_EXE}" ] ; then
    326     ## clang++ is a link to clang.  Remove it and reconstruct
    327     rm "$TMPDIR/bin/clang++${HOST_EXE}"
    328     ln -s "clang${LLVM_VERSION_WITHOUT_DOT}${HOST_EXE}" "$TMPDIR/bin/clang${LLVM_VERSION_WITHOUT_DOT}++${HOST_EXE}"
    329   else
    330     mv "$TMPDIR/bin/clang++${HOST_EXE}" "$TMPDIR/bin/clang$LLVM_VERSION_WITHOUT_DOT++${HOST_EXE}"
    331   fi
    332 
    333   EXTRA_CLANG_FLAGS=
    334   EXTRA_CLANGXX_FLAGS=
    335   if [ "$ARCH_INC" != "$ARCH" ]; then
    336     LLVM_TARGET=le32-none-ndk
    337     EXTRA_CLANG_FLAGS="-emit-llvm"
    338     EXTRA_CLANGXX_FLAGS="$EXTRA_CLANG_FLAGS -I\`dirname \$0\`/../include/c++/$GCC_BASE_VERSION"
    339   fi
    340 
    341   cat > "$TMPDIR/bin/clang" <<EOF
    342 if [ "\$1" != "-cc1" ]; then
    343     \`dirname \$0\`/clang$LLVM_VERSION_WITHOUT_DOT -target $LLVM_TARGET "\$@" $EXTRA_CLANG_FLAGS
    344     $(dump_extra_compile_commands)
    345 else
    346     # target/triple already spelled out.
    347     \`dirname \$0\`/clang$LLVM_VERSION_WITHOUT_DOT "\$@" $EXTRA_CLANG_FLAGS
    348 fi
    349 EOF
    350   cat > "$TMPDIR/bin/clang++" <<EOF
    351 if [ "\$1" != "-cc1" ]; then
    352     \`dirname \$0\`/clang$LLVM_VERSION_WITHOUT_DOT++ -target $LLVM_TARGET "\$@" $EXTRA_CLANGXX_FLAGS
    353     $(dump_extra_compile_commands)
    354 else
    355     # target/triple already spelled out.
    356     \`dirname \$0\`/clang$LLVM_VERSION_WITHOUT_DOT++ "\$@" $EXTRA_CLANGXX_FLAGS
    357 fi
    358 EOF
    359   chmod 0755 "$TMPDIR/bin/clang" "$TMPDIR/bin/clang++"
    360   cp -a "$TMPDIR/bin/clang" "$TMPDIR/bin/$TOOLCHAIN_PREFIX-clang"
    361   cp -a "$TMPDIR/bin/clang++" "$TMPDIR/bin/$TOOLCHAIN_PREFIX-clang++"
    362 
    363   if [ -n "$HOST_EXE" ] ; then
    364     cat > "$TMPDIR/bin/clang.cmd" <<EOF
    365 @echo off
    366 if "%1" == "-cc1" goto :L
    367 %~dp0\\clang${LLVM_VERSION_WITHOUT_DOT}${HOST_EXE} -target $LLVM_TARGET %* $EXTRA_CLANG_FLAGS
    368 $(dump_extra_compile_commands)
    369 if ERRORLEVEL 1 exit /b 1
    370 goto :done
    371 :L
    372 rem target/triple already spelled out.
    373 %~dp0\\clang${LLVM_VERSION_WITHOUT_DOT}${HOST_EXE} %* $EXTRA_CLANG_FLAGS
    374 if ERRORLEVEL 1 exit /b 1
    375 :done
    376 EOF
    377     cat > "$TMPDIR/bin/clang++.cmd" <<EOF
    378 @echo off
    379 if "%1" == "-cc1" goto :L
    380 %~dp0\\clang${LLVM_VERSION_WITHOUT_DOT}++${HOST_EXE} -target $LLVM_TARGET %* $EXTRA_CLANGXX_FLAGS
    381 $(dump_extra_compile_commands)
    382 if ERRORLEVEL 1 exit /b 1
    383 goto :done
    384 :L
    385 rem target/triple already spelled out.
    386 %~dp0\\clang${LLVM_VERSION_WITHOUT_DOT}++${HOST_EXE} %* $EXTRA_CLANGXX_FLAGS
    387 if ERRORLEVEL 1 exit /b 1
    388 :done
    389 EOF
    390     cp -a "$TMPDIR/bin/clang.cmd" "$TMPDIR/bin/$TOOLCHAIN_PREFIX-clang.cmd"
    391     cp -a "$TMPDIR/bin/clang++.cmd" "$TMPDIR/bin/$TOOLCHAIN_PREFIX-clang++.cmd"
    392   fi
    393 fi
    394 
    395 dump "Copying sysroot headers and libraries..."
    396 # Copy the sysroot under $TMPDIR/sysroot. The toolchain was built to
    397 # expect the sysroot files to be placed there!
    398 run copy_directory_nolinks "$SRC_SYSROOT_INC" "$TMPDIR/sysroot/usr/include"
    399 run copy_directory_nolinks "$SRC_SYSROOT_LIB" "$TMPDIR/sysroot/usr/lib"
    400 if [ "$ARCH_INC" != "$ARCH" ]; then
    401     cp -a $NDK_DIR/$LIBPORTABLE_SUBDIR/libs/$ABI/* $TMPDIR/sysroot/usr/lib
    402     cp -a $NDK_DIR/$GABIXX_SUBDIR/libs/$ABI/* $TMPDIR/sysroot/usr/lib
    403     cp -a $NDK_DIR/$COMPILER_RT_SUBDIR/libs/$ABI/* $TMPDIR/sysroot/usr/lib
    404 fi
    405 
    406 dump "Copying libstdc++ headers and libraries..."
    407 
    408 GNUSTL_DIR=$NDK_DIR/$GNUSTL_SUBDIR/$GCC_VERSION
    409 GNUSTL_LIBS=$GNUSTL_DIR/libs
    410 
    411 STLPORT_DIR=$NDK_DIR/$STLPORT_SUBDIR
    412 STLPORT_LIBS=$STLPORT_DIR/libs
    413 
    414 ABI_STL="$TMPDIR/$ABI_CONFIGURE_TARGET"
    415 ABI_STL_INCLUDE="$TMPDIR/include/c++/$GCC_BASE_VERSION"
    416 ABI_STL_INCLUDE_TARGET="$ABI_STL_INCLUDE/$ABI_CONFIGURE_TARGET"
    417 
    418 # $1: filenames of headers
    419 copy_gabixx_headers () {
    420   for header in $@; do
    421     (cd $ABI_STL_INCLUDE && ln -s ../../gabi++/include/$header $header)
    422   done
    423 }
    424 
    425 # Copy common STL headers (i.e. the non-arch-specific ones)
    426 copy_stl_common_headers () {
    427     case $STL in
    428         gnustl)
    429             copy_directory "$GNUSTL_DIR/include" "$ABI_STL_INCLUDE"
    430             ;;
    431         stlport)
    432             copy_directory "$STLPORT_DIR/stlport" "$ABI_STL_INCLUDE"
    433             copy_directory "$STLPORT_DIR/../gabi++/include" "$ABI_STL_INCLUDE/../../gabi++/include"
    434             copy_gabixx_headers cxxabi.h unwind.h unwind-arm.h unwind-itanium.h
    435             ;;
    436     esac
    437 }
    438 
    439 # $1: Source ABI (e.g. 'armeabi')
    440 # $2: Optional extra ABI variant, or empty (e.g. "", "thumb", "armv7-a/thumb")
    441 copy_stl_libs () {
    442     local ABI=$1
    443     local ABI2=$2
    444     case $STL in
    445         gnustl)
    446             copy_directory "$GNUSTL_LIBS/$ABI/include/bits" "$ABI_STL_INCLUDE_TARGET/$ABI2/bits"
    447             copy_file_list "$GNUSTL_LIBS/$ABI" "$ABI_STL/lib/$ABI2" "libgnustl_shared.so"
    448             copy_file_list "$GNUSTL_LIBS/$ABI" "$ABI_STL/lib/$ABI2" "libsupc++.a"
    449             cp -p "$GNUSTL_LIBS/$ABI/libgnustl_static.a" "$ABI_STL/lib/$ABI2/libstdc++.a"
    450             ;;
    451         stlport)
    452             if [ "$ARCH_INC" != "$ARCH" ]; then
    453               tmp_lib_dir=$TMPDIR/stl
    454               $NDK_DIR/build/tools/build-cxx-stl.sh --stl=stlport --out-dir=$tmp_lib_dir --abis=unknown
    455               cp -p "`ls $tmp_lib_dir/sources/cxx-stl/stlport/libs/*/libstlport_static.a`" "$ABI_STL/lib/$ABI2/libstdc++.a"
    456               cp -p "`ls $tmp_lib_dir/sources/cxx-stl/stlport/libs/*/libstlport_shared.so`" "$ABI_STL/lib/$ABI2/libstlport_shared.so"
    457               rm -rf $tmp_lib_dir
    458             else
    459               copy_file_list "$STLPORT_LIBS/$ABI" "$ABI_STL/lib/$ABI2" "libstlport_shared.so"
    460               cp -p "$STLPORT_LIBS/$ABI/libstlport_static.a" "$ABI_STL/lib/$ABI2/libstdc++.a"
    461             fi
    462             ;;
    463         *)
    464             dump "ERROR: Unsupported STL: $STL"
    465             exit 1
    466             ;;
    467     esac
    468 }
    469 
    470 mkdir -p "$ABI_STL_INCLUDE_TARGET"
    471 fail_panic "Can't create directory: $ABI_STL_INCLUDE_TARGET"
    472 copy_stl_common_headers
    473 case $ARCH in
    474     arm)
    475         copy_stl_libs armeabi ""
    476         copy_stl_libs armeabi "thumb"
    477         copy_stl_libs armeabi-v7a "armv7-a"
    478         copy_stl_libs armeabi-v7a "armv7-a/thumb"
    479         ;;
    480     x86|mips)
    481         copy_stl_libs "$ARCH" ""
    482         ;;
    483     *)
    484         dump "ERROR: Unsupported NDK architecture: $ARCH"
    485         exit 1
    486         ;;
    487 esac
    488 
    489 # Install or Package
    490 if [ -n "$INSTALL_DIR" ] ; then
    491     dump "Copying files to: $INSTALL_DIR"
    492     run copy_directory "$TMPDIR" "$INSTALL_DIR"
    493 else
    494     PACKAGE_FILE="$PACKAGE_DIR/$TOOLCHAIN_NAME.tar.bz2"
    495     dump "Creating package file: $PACKAGE_FILE"
    496     pack_archive "$PACKAGE_FILE" "`dirname $TMPDIR`" "$TOOLCHAIN_NAME"
    497     fail_panic "Could not create tarball from $TMPDIR"
    498 fi
    499 dump "Cleaning up..."
    500 run rm -rf $TMPDIR
    501 
    502 dump "Done."
    503