Switch to make_standalone_toolchain.py
[termux-packages] / build-package.sh
index dd72ed7..1aec16c 100755 (executable)
@@ -370,8 +370,12 @@ termux_step_massage () {
                rm -Rf share/info
        fi
 
-       # Remove other docs:
-       rm -Rf share/doc share/locale
+       # Remove locale files we're not interested in::
+       rm -Rf share/locale
+       if [ -z ${TERMUX_PKG_KEEP_SHARE_DOC+x} ]; then
+               # Remove info pages:
+               rm -Rf share/doc
+       fi
 
        # Remove old kept libraries (readline):
        find . -name '*.old' -delete
@@ -552,13 +556,8 @@ if [ "$TERMUX_PKG_BUILD_REVISION" != "0" -o "$TERMUX_PKG_FULLVERSION" != "${TERM
 fi
 
 # Compute standalone toolchain dir, bitness of arch and name of host platform:
-TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_TOPDIR/_lib/toolchain-${TERMUX_ARCH}-ndk${TERMUX_NDK_VERSION}-api${TERMUX_API_LEVEL}-"
-if [ "$TERMUX_PKG_CLANG" = "no" ]; then
-       TERMUX_STANDALONE_TOOLCHAIN+="gcc4.9"
-else
-       TERMUX_STANDALONE_TOOLCHAIN+="clang38"
-fi
-# Bump the below version if a change is made in toolchain setup, to ensure
+TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_TOPDIR/_lib/toolchain-${TERMUX_ARCH}-ndk${TERMUX_NDK_VERSION}-api${TERMUX_API_LEVEL}"
+# Bump the below version if a change is made in toolchain setup to ensure
 # that everyone gets an updated toolchain:
 TERMUX_STANDALONE_TOOLCHAIN+="-v1"
 
@@ -633,32 +632,26 @@ export ac_cv_func_getpwnam=no
 export ac_cv_func_getpwuid=no
 
 if [ ! -d $TERMUX_STANDALONE_TOOLCHAIN ]; then
-       # See https://developer.android.com/ndk/guides/standalone_toolchain.html about toolchain naming.
-       if [ "i686" = $TERMUX_ARCH ]; then
-               _TERMUX_NDK_TOOLCHAIN_NAME="x86"
-       elif [ "x86_64" = $TERMUX_ARCH ]; then
-               _TERMUX_NDK_TOOLCHAIN_NAME="x86_64"
-       else
-               _TERMUX_NDK_TOOLCHAIN_NAME="$TERMUX_HOST_PLATFORM"
-       fi
-
-       if [ "$TERMUX_PKG_CLANG" = "no" ]; then
-               _TERMUX_TOOLCHAIN="${_TERMUX_NDK_TOOLCHAIN_NAME}-4.9"
-       else
-               _TERMUX_TOOLCHAIN="${_TERMUX_NDK_TOOLCHAIN_NAME}-clang"
-       fi
-
        # Do not put toolchain in place until we are done with setup, to avoid having a half setup
        # toolchain left in place if something goes wrong (or process is just aborted):
        _TERMUX_TOOLCHAIN_TMPDIR=${TERMUX_STANDALONE_TOOLCHAIN}-tmp
        rm -Rf $_TERMUX_TOOLCHAIN_TMPDIR
 
-       bash $NDK/build/tools/make-standalone-toolchain.sh --platform=android-$TERMUX_API_LEVEL --toolchain=${_TERMUX_TOOLCHAIN} \
-               --install-dir=$_TERMUX_TOOLCHAIN_TMPDIR
-        if [ "arm" = $TERMUX_ARCH ]; then
-                # Fix to allow e.g. <bits/c++config.h> to be included:
-                cp $_TERMUX_TOOLCHAIN_TMPDIR/include/c++/4.9.x/arm-linux-androideabi/armv7-a/bits/* $_TERMUX_TOOLCHAIN_TMPDIR/include/c++/4.9.x/bits
-        fi
+       _NDK_ARCHNAME=$TERMUX_ARCH
+       if [ $TERMUX_ARCH = "aarch64" ]; then
+               _NDK_ARCHNAME=arm64
+       elif [ $TERMUX_ARCH = "i686" ]; then
+               _NDK_ARCHNAME=x86
+       fi
+       $NDK/build/tools/make_standalone_toolchain.py \
+               --api $TERMUX_API_LEVEL \
+               --arch $_NDK_ARCHNAME \
+               --install-dir $_TERMUX_TOOLCHAIN_TMPDIR
+       if [ "arm" = $TERMUX_ARCH ]; then
+               # Fix to allow e.g. <bits/c++config.h> to be included:
+               cp $_TERMUX_TOOLCHAIN_TMPDIR/include/c++/4.9.x/arm-linux-androideabi/armv7-a/bits/* \
+                       $_TERMUX_TOOLCHAIN_TMPDIR/include/c++/4.9.x/bits
+       fi
        cd $_TERMUX_TOOLCHAIN_TMPDIR/sysroot
        for f in $TERMUX_SCRIPTDIR/ndk_patches/*.patch; do
                sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" $f | \
@@ -692,31 +685,26 @@ if [ ! -f $TERMUX_PREFIX/lib/libstdc++.so ]; then
        ln -f -s libgnustl_shared.so libstdc++.so
 fi
 
-if [ ! -f $PKG_CONFIG ]; then
-       echo "Creating pkg-config wrapper..."
-       # We use path to host pkg-config to avoid picking up a cross-compiled pkg-config later on
-       _HOST_PKGCONFIG=`which pkg-config`
-       mkdir -p $TERMUX_STANDALONE_TOOLCHAIN/bin $PKG_CONFIG_LIBDIR
-       cat > $PKG_CONFIG <<HERE
+# Create pkg-config wrapper. We use path to host pkg-config to
+# avoid picking up a cross-compiled pkg-config later on.
+_HOST_PKGCONFIG=`which pkg-config`
+mkdir -p $TERMUX_STANDALONE_TOOLCHAIN/bin $PKG_CONFIG_LIBDIR
+cat > $PKG_CONFIG <<HERE
 #!/bin/sh
 export PKG_CONFIG_DIR=
 export PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR
-# export PKG_CONFIG_SYSROOT_DIR=${TERMUX_PREFIX}
 exec $_HOST_PKGCONFIG "\$@"
 HERE
-       chmod +x $PKG_CONFIG
-
-       # Add a pkg-config file for the system zlib
-       cat > $PKG_CONFIG_LIBDIR/zlib.pc <<HERE
+chmod +x $PKG_CONFIG
+# Add a pkg-config file for the system zlib
+cat > $PKG_CONFIG_LIBDIR/zlib.pc <<HERE
 Name: zlib
 Description: zlib compression library
 Version: 1.2.3
 
 Requires:
-Libs: -L$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib -lz
-Cflags: -I$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/include
+Libs: -lz
 HERE
-fi
 
 # Keep track of when build started so we can see what files have been created.
 # We start by sleeping so that any generated files above (such as zlib.pc) get