Setup libstdc++.so -> libgnustl_shared.so early
authorFredrik Fornwall <fredrik@fornwall.net>
Wed, 10 Aug 2016 23:45:41 +0000 (19:45 -0400)
committerFredrik Fornwall <fredrik@fornwall.net>
Wed, 10 Aug 2016 23:45:41 +0000 (19:45 -0400)
Let build-package.sh setup the $PREFIX/lib/libstdc++.so symlink
before building any package, to make sure that all C++ applications
link against a fully featured C++ standard library.

Avoid explicitly declaring a dependency on the libgnustl package
since everyone may link against it at will and instead mark it as
essential.

18 files changed:
build-package.sh
configure.patch [new file with mode: 0644]
packages/aapt/build.sh
packages/apt/build.sh
packages/aria2/build.sh
packages/clang/build.sh
packages/cmake/build.sh
packages/fish/build.sh
packages/gcc/build.sh
packages/lftp/build.sh
packages/libgnustl/build.sh
packages/libvpx/build.sh
packages/libvpx/configure.patch
packages/ltrace/build.sh
packages/mosh/build.sh
packages/ndk-stl/build.sh
packages/nodejs/build.sh
packages/poppler/build.sh

index c925078..c6fe7f7 100755 (executable)
@@ -51,12 +51,16 @@ else
 fi
 
 # Compute standalone toolchain dir, bitness of arch and name of host platform:
-TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_TOPDIR/_lib/android-standalone-toolchain-${TERMUX_ARCH}-ndk${TERMUX_NDK_VERSION}-api${TERMUX_API_LEVEL}-"
+TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_TOPDIR/_lib/toolchain-${TERMUX_ARCH}-ndk${TERMUX_NDK_VERSION}-api${TERMUX_API_LEVEL}-"
 if [ "$TERMUX_CLANG" = "" ]; 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
+# that everyone gets an updated toolchain:
+TERMUX_STANDALONE_TOOLCHAIN+="-v1"
+
 if [ "x86_64" = $TERMUX_ARCH -o "aarch64" = $TERMUX_ARCH ]; then
        TERMUX_ARCH_BITS=64
 else
@@ -208,6 +212,27 @@ if [ ! -d $TERMUX_STANDALONE_TOOLCHAIN ]; then
        mv $_TERMUX_TOOLCHAIN_TMPDIR $TERMUX_STANDALONE_TOOLCHAIN
 fi
 
+if [ ! -f $TERMUX_PREFIX/lib/libstdc++.so ]; then
+       # Setup libgnustl_shared.so in $PREFIX/lib and libstdc++.so as a symlink to it,
+       # so that other C++ using packages links to it instead of the default android
+       # C++ library which does not support exceptions or STL:
+       # https://developer.android.com/ndk/guides/cpp-support.html
+       # We do however want to avoid installing this, to avoid problems # where e.g.
+       # libm.so on some i686 devices links against libstdc++.so.
+       # The libgnustl_shared.so library will be packaged in the libgnustl package
+       # which is part of the base Termux installation.
+       mkdir -p $TERMUX_PREFIX/lib
+       cd $TERMUX_PREFIX/lib
+        _STL_LIBFILE=$TERMUX_STANDALONE_TOOLCHAIN/${TERMUX_HOST_PLATFORM}/lib/libgnustl_shared.so
+       if [ $TERMUX_ARCH = arm ]; then
+               _STL_LIBFILE=$TERMUX_STANDALONE_TOOLCHAIN/${TERMUX_HOST_PLATFORM}/lib/armv7-a/libgnustl_shared.so
+       elif [ $TERMUX_ARCH = x86_64 ]; then
+               _STL_LIBFILE=$TERMUX_STANDALONE_TOOLCHAIN/${TERMUX_HOST_PLATFORM}/lib64/libgnustl_shared.so
+       fi
+       cp $_STL_LIBFILE .
+       ln -f -s libgnustl_shared.so libstdc++.so
+fi
+
 export TERMUX_COMMON_CACHEDIR="$TERMUX_TOPDIR/_cache"
 export TERMUX_DEBDIR="$TERMUX_SCRIPTDIR/debs"
 mkdir -p $TERMUX_COMMON_CACHEDIR $TERMUX_DEBDIR
diff --git a/configure.patch b/configure.patch
new file mode 100644 (file)
index 0000000..77743a3
--- /dev/null
@@ -0,0 +1,12 @@
+diff -u -r ../libvpx-1.5.0/configure ./configure
+--- ../libvpx-1.5.0/configure  2015-11-09 17:12:38.000000000 -0500
++++ ./configure        2015-11-17 15:20:15.792584646 -0500
+@@ -507,7 +507,7 @@
+         # Can only build shared libs on a subset of platforms. Doing this check
+         # here rather than at option parse time because the target auto-detect
+         # magic happens after the command line has been parsed.
+-        if ! enabled linux && ! enabled os2; then
++        if ! enabled linux && ! enabled os2 && ! enabled android; then
+             if enabled gnu; then
+                 echo "--enable-shared is only supported on ELF; assuming this is OK"
+             else
index 95f4d43..5e9e299 100644 (file)
@@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Android Asset Packaging Tool"
 TERMUX_PKG_VERSION=5.1.1
 TERMUX_PKG_BUILD_REVISION=1
 TERMUX_PKG_BUILD_IN_SRC=yes
-TERMUX_PKG_DEPENDS="libexpat, libpng, libgnustl"
+TERMUX_PKG_DEPENDS="libexpat, libpng"
 
 termux_step_make_install () {
         local _TAGNAME=${TERMUX_PKG_VERSION}_r8
index c309faa..514ea6c 100644 (file)
@@ -1,6 +1,6 @@
 TERMUX_PKG_HOMEPAGE=https://packages.debian.org/apt
 TERMUX_PKG_DESCRIPTION="Front-end for the dpkg package manager"
-TERMUX_PKG_DEPENDS="liblzma, libgnustl, dpkg, gnupg"
+TERMUX_PKG_DEPENDS="liblzma, dpkg, gnupg"
 # Wait with updating to later version until the NDK supports std::to_string() and other
 # functions (hopefully in r13):
 TERMUX_PKG_VERSION=1.2.12
@@ -13,9 +13,6 @@ TERMUX_PKG_FOLDERNAME=apt-${TERMUX_PKG_VERSION}
 TERMUX_PKG_ESSENTIAL=yes
 TERMUX_PKG_CONFFILES="etc/apt/sources.list"
 
-# $NDK/docs/STANDALONE-TOOLCHAIN.html: "If you use the GNU libstdc++, you will need to explicitly link with libsupc++ if you use these features"
-export LDFLAGS="$LDFLAGS -lgnustl_shared" # -lsupc++"
-
 # Some files use STD*_FILENO without including <unistd.h> where they are declared.
 # Define them here to avoid having to patch files:
 CXXFLAGS+=" -DSTDIN_FILENO=0 -DSTDOUT_FILENO=1 -DSTDERR_FILENO=2 -DAI_IDN=0"
index 3c31600..4b4a092 100644 (file)
@@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=http://aria2.sourceforge.net/
 TERMUX_PKG_DESCRIPTION="Multi-protocol & multi-source command-line download utility supporting HTTP/HTTPS, FTP, BitTorrent and Metalink"
 TERMUX_PKG_VERSION=1.25.0
 TERMUX_PKG_SRCURL=https://github.com/tatsuhiro-t/aria2/releases/download/release-$TERMUX_PKG_VERSION/aria2-${TERMUX_PKG_VERSION}.tar.xz
-TERMUX_PKG_DEPENDS="c-ares, openssl, libxml2, libgnustl"
+TERMUX_PKG_DEPENDS="c-ares, openssl, libxml2"
 # sqlite3 is only used for loading cookies from firefox or chrome:
 TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--with-openssl --without-gnutls --without-libuv --without-sqlite3 ac_cv_search_getaddrinfo=no ac_cv_func_getaddrinfo=yes ac_cv_func_gettimeofday=yes ac_cv_func_sleep=yes ac_cv_func_usleep=yes ac_cv_func_basename=yes"
 
index 49fa6d6..e15b14a 100644 (file)
@@ -5,7 +5,7 @@ TERMUX_PKG_VERSION=${_PKG_MAJOR_VERSION}.1
 TERMUX_PKG_SRCURL=http://llvm.org/releases/${TERMUX_PKG_VERSION}/llvm-${TERMUX_PKG_VERSION}.src.tar.xz
 TERMUX_PKG_HOSTBUILD=true
 TERMUX_PKG_RM_AFTER_INSTALL="bin/macho-dump bin/bugpoint bin/llvm-tblgen lib/BugpointPasses.so lib/LLVMHello.so"
-TERMUX_PKG_DEPENDS="binutils, libgnustl, ncurses, ndk-sysroot, ndk-stl, libgcc"
+TERMUX_PKG_DEPENDS="binutils, ncurses, ndk-sysroot, ndk-stl, libgcc"
 
 termux_step_post_extract_package () {
        CLANG_SRC_TAR=cfe-${TERMUX_PKG_VERSION}.src.tar.xz
index 11f48b6..ce5fc2c 100644 (file)
@@ -4,7 +4,7 @@ _MAJOR_VERSION=3.5
 TERMUX_PKG_VERSION=${_MAJOR_VERSION}.2
 TERMUX_PKG_BUILD_REVISION=1
 TERMUX_PKG_SRCURL=http://www.cmake.org/files/v${_MAJOR_VERSION}/cmake-${TERMUX_PKG_VERSION}.tar.gz
-TERMUX_PKG_DEPENDS="libarchive, libcurl, libexpat, ncurses, jsoncpp, libgnustl"
+TERMUX_PKG_DEPENDS="libarchive, libcurl, libexpat, ncurses, jsoncpp"
 
 termux_step_configure () {
        cd $TERMUX_PKG_BUILDDIR
index bd72451..3aac8f6 100644 (file)
@@ -5,7 +5,7 @@ TERMUX_PKG_BUILD_REVISION=1
 TERMUX_PKG_SRCURL=https://github.com/fish-shell/fish-shell/releases/download/$TERMUX_PKG_VERSION/fish-${TERMUX_PKG_VERSION}.tar.gz
 # fish calls 'tput' from ncurses-utils, at least when cancelling (Ctrl+C) a command line.
 # man is needed since fish calls apropos during command completion.
-TERMUX_PKG_DEPENDS="ncurses, libgnustl, libandroid-support, ncurses-utils, man"
+TERMUX_PKG_DEPENDS="ncurses, libandroid-support, ncurses-utils, man"
 TERMUX_PKG_BUILD_IN_SRC=yes
 TERMUX_PKG_FOLDERNAME=fish-$TERMUX_PKG_VERSION
 
index 1c28ef8..90f799b 100755 (executable)
@@ -1,6 +1,6 @@
 TERMUX_PKG_HOMEPAGE=http://gcc.gnu.org/
 TERMUX_PKG_DESCRIPTION="GNU C compiler"
-TERMUX_PKG_DEPENDS="binutils, libgmp, libmpfr, libmpc, ndk-sysroot, libgcc, libisl, libgnustl"
+TERMUX_PKG_DEPENDS="binutils, libgmp, libmpfr, libmpc, ndk-sysroot, libgcc, libisl"
 TERMUX_PKG_VERSION=6.1.0
 TERMUX_PKG_BUILD_REVISION=2
 TERMUX_PKG_SRCURL=ftp://ftp.gnu.org/gnu/gcc/gcc-${TERMUX_PKG_VERSION}/gcc-${TERMUX_PKG_VERSION}.tar.bz2
index 4cbedf7..c9e65fc 100644 (file)
@@ -6,7 +6,7 @@ TERMUX_PKG_SRCURL=http://lftp.yar.ru/ftp/lftp-${TERMUX_PKG_VERSION}.tar.xz
 # (2) Use --with-openssl to use openssl instead of gnutls.
 TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_dn_expand=no --with-openssl --with-zlib=$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr --with-expat=$TERMUX_PREFIX"
 TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-readline=$TERMUX_PREFIX"
-TERMUX_PKG_DEPENDS="libexpat, openssl, readline, libutil, libidn, libgnustl"
+TERMUX_PKG_DEPENDS="libexpat, openssl, readline, libutil, libidn"
 
 termux_step_pre_configure () {
        # We have patched an m4 file.
index 6d2cbad..41c4b15 100644 (file)
@@ -2,23 +2,14 @@ TERMUX_PKG_HOMEPAGE=http://gcc.gnu.org/onlinedocs/libstdc++/
 TERMUX_PKG_DESCRIPTION="The GNU Standard C++ Library (a.k.a. libstdc++-v3), necessary on android since the system libstdc++.so is stripped down"
 TERMUX_PKG_VERSION=$TERMUX_NDK_VERSION
 TERMUX_PKG_BUILD_REVISION=4
+# Since every C++ package links against this by default (due
+# to the libstdc++.so -> libgnustl_shared.so setup in
+# build-package.sh) this package is considered essential,
+# and other packages does not need to declare explicit
+# dependency on it.
+TERMUX_PKG_ESSENTIAL=yes
 
 termux_step_make_install () {
-        local LIBFILE=$TERMUX_STANDALONE_TOOLCHAIN/${TERMUX_HOST_PLATFORM}/lib/libgnustl_shared.so
-       if [ $TERMUX_ARCH = arm ]; then
-               LIBFILE=$TERMUX_STANDALONE_TOOLCHAIN/${TERMUX_HOST_PLATFORM}/lib/armv7-a/libgnustl_shared.so
-       elif [ $TERMUX_ARCH = x86_64 ]; then
-               LIBFILE=$TERMUX_STANDALONE_TOOLCHAIN/${TERMUX_HOST_PLATFORM}/lib64/libgnustl_shared.so
-       fi
-
-       cp $LIBFILE $TERMUX_PREFIX/lib/
-}
-
-termux_step_post_massage () {
-       # Setup a libgnustl_shared.so in $PREFIX/lib, so that other C++ using packages
-       # links to it. We do however want to avoid installing this, to avoid problems
-       # where e.g. libm.so on some i686 devices links against libstdc++.so, so do
-       # this here in termux_step_post_massage.
-       cd $TERMUX_PREFIX/lib
-       ln -f -s libgnustl_shared.so libstdc++.so
+       # Just bump timestamp to have it packaged.
+       touch $TERMUX_PREFIX/lib/libgnustl_shared.so
 }
index 36e57ff..7916a8c 100644 (file)
@@ -1,10 +1,8 @@
 TERMUX_PKG_HOMEPAGE=http://www.webmproject.org/
 TERMUX_PKG_DESCRIPTION="VP9 Codec SDK"
-TERMUX_PKG_VERSION=1.5.0
-TERMUX_PKG_BUILD_REVISION=1
+TERMUX_PKG_VERSION=1.6.0
 TERMUX_PKG_SRCURL=https://github.com/webmproject/libvpx/archive/v${TERMUX_PKG_VERSION}.tar.gz
 TERMUX_PKG_FOLDERNAME=libvpx-${TERMUX_PKG_VERSION}
-TERMUX_PKG_DEPENDS="libgnustl"
 
 termux_step_configure () {
        if [ $TERMUX_ARCH = "arm" ]; then
index 77743a3..84ce7f3 100644 (file)
@@ -1,12 +1,12 @@
-diff -u -r ../libvpx-1.5.0/configure ./configure
---- ../libvpx-1.5.0/configure  2015-11-09 17:12:38.000000000 -0500
-+++ ./configure        2015-11-17 15:20:15.792584646 -0500
-@@ -507,7 +507,7 @@
-         # Can only build shared libs on a subset of platforms. Doing this check
-         # here rather than at option parse time because the target auto-detect
-         # magic happens after the command line has been parsed.
--        if ! enabled linux && ! enabled os2; then
-+        if ! enabled linux && ! enabled os2 && ! enabled android; then
-             if enabled gnu; then
+diff -u -r ../libvpx-1.6.0/configure ./configure
+--- ../libvpx-1.6.0/configure  2016-07-20 21:15:41.000000000 -0400
++++ ./configure        2016-08-10 19:36:59.873847660 -0400
+@@ -509,7 +509,7 @@
+             # Supported platforms
+             ;;
+         *)
+-            if enabled gnu; then
++            if enabled gnu || enabled android; then
                  echo "--enable-shared is only supported on ELF; assuming this is OK"
              else
+                 die "--enable-shared only supported on ELF, OS/2, and Darwin for now"
index 364c264..75f7983 100644 (file)
@@ -1,7 +1,7 @@
 TERMUX_PKG_HOMEPAGE=http://www.ltrace.org/
 TERMUX_PKG_DESCRIPTION="Tracks runtime library calls in dynamically linked programs"
 TERMUX_PKG_VERSION=0.7.3.20160411
-TERMUX_PKG_DEPENDS="elfutils, libgnustl"
+TERMUX_PKG_DEPENDS="elfutils"
 
 # TERMUX_PKG_SRCURL=http://www.ltrace.org/ltrace_${TERMUX_PKG_VERSION}.orig.tar.bz2
 # TERMUX_PKG_FOLDERNAME=ltrace-${TERMUX_PKG_VERSION}
index 3511059..b127f21 100644 (file)
@@ -4,7 +4,7 @@ TERMUX_PKG_VERSION=1.2.6
 TERMUX_PKG_SRCURL=https://github.com/mobile-shell/mosh/archive/mosh-${TERMUX_PKG_VERSION}.tar.gz
 TERMUX_PKG_FOLDERNAME=mosh-mosh-$TERMUX_PKG_VERSION
 
-TERMUX_PKG_DEPENDS="libandroid-support, protobuf, ncurses, openssl, openssh, libutil, libgnustl"
+TERMUX_PKG_DEPENDS="libandroid-support, protobuf, ncurses, openssl, openssh, libutil"
 
 export PROTOC=$TERMUX_TOPDIR/protobuf/host-build/src/protoc
 
index b5fc10f..a3a9099 100644 (file)
@@ -1,7 +1,6 @@
 TERMUX_PKG_HOMEPAGE=https://developer.android.com/tools/sdk/ndk/index.html
 TERMUX_PKG_DESCRIPTION="Header files from the Android NDK needed for compiling C++ programs using STL"
 TERMUX_PKG_VERSION=$TERMUX_NDK_VERSION
-TERMUX_PKG_DEPENDS="libgnustl"
 TERMUX_PKG_NO_DEVELSPLIT=yes
 
 termux_step_extract_into_massagedir () {
index 9789145..52961f0 100644 (file)
@@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=http://nodejs.org/
 TERMUX_PKG_DESCRIPTION="Platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications"
 TERMUX_PKG_VERSION=6.3.1
 TERMUX_PKG_SRCURL=https://nodejs.org/dist/v${TERMUX_PKG_VERSION}/node-v${TERMUX_PKG_VERSION}.tar.gz
-TERMUX_PKG_DEPENDS="openssl, libuv, libgnustl, c-ares"
+TERMUX_PKG_DEPENDS="openssl, libuv, c-ares"
 TERMUX_PKG_RM_AFTER_INSTALL="lib/node_modules/npm/html lib/node_modules/npm/make.bat share/systemtap lib/dtrace"
 TERMUX_PKG_BUILD_IN_SRC=yes
 
index 87cb86e..cf05eeb 100644 (file)
@@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="PDF rendering library"
 TERMUX_PKG_VERSION=0.43.0
 TERMUX_PKG_SRCURL=http://poppler.freedesktop.org/poppler-${TERMUX_PKG_VERSION}.tar.xz
 # libcairo and littlecms is used by pdftocairo:
-TERMUX_PKG_DEPENDS="fontconfig, libcairo, libpng, libjpeg-turbo, libtiff, littlecms, libgnustl, openjpeg"
+TERMUX_PKG_DEPENDS="fontconfig, libcairo, libpng, libjpeg-turbo, libtiff, littlecms, openjpeg"
 TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--disable-poppler-glib"
 
 # $NDK/docs/STANDALONE-TOOLCHAIN.html: "If you use the GNU libstdc++, you will need to explicitly link with libsupc++ if you use these features"