-export TERMUX_COMMON_CACHEDIR="$TERMUX_TOPDIR/_cache"
-export TERMUX_COMMON_DEBDIR="$TERMUX_TOPDIR/_deb"
-mkdir -p $TERMUX_COMMON_CACHEDIR $TERMUX_COMMON_DEBDIR
+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