2017-08-26 22:56:25 +02:00
|
|
|
TERMUX_PKG_HOMEPAGE=https://developer.android.com/tools/sdk/ndk/index.html
|
2017-12-05 22:33:04 +01:00
|
|
|
TERMUX_PKG_DESCRIPTION="Multilib binaries for cross-compilation"
|
2019-01-21 15:00:12 +01:00
|
|
|
TERMUX_PKG_LICENSE="NCSA"
|
2020-12-20 14:16:34 +01:00
|
|
|
TERMUX_PKG_MAINTAINER="@termux"
|
2017-08-26 22:56:25 +02:00
|
|
|
TERMUX_PKG_VERSION=$TERMUX_NDK_VERSION
|
2022-04-16 18:10:22 +02:00
|
|
|
TERMUX_PKG_REVISION=3
|
2019-08-14 13:27:16 +02:00
|
|
|
TERMUX_PKG_SKIP_SRC_EXTRACT=true
|
2017-08-26 22:56:25 +02:00
|
|
|
TERMUX_PKG_PLATFORM_INDEPENDENT=true
|
2019-08-12 17:28:41 +02:00
|
|
|
TERMUX_PKG_NO_STATICSPLIT=true
|
2017-08-26 22:56:25 +02:00
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
prepare_libs() {
|
2017-08-26 22:56:25 +02:00
|
|
|
local ARCH="$1"
|
|
|
|
local SUFFIX="$2"
|
|
|
|
local NDK_SUFFIX=$SUFFIX
|
|
|
|
|
|
|
|
if [ $ARCH = x86 ] || [ $ARCH = x86_64 ]; then
|
|
|
|
NDK_SUFFIX=$ARCH
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/$SUFFIX/lib
|
2021-08-16 18:28:01 +02:00
|
|
|
local BASEDIR=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/$SUFFIX/${TERMUX_PKG_API_LEVEL}
|
2017-08-26 22:56:25 +02:00
|
|
|
cp $BASEDIR/*.o $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/$SUFFIX/lib
|
2019-09-10 23:10:16 +02:00
|
|
|
cp $BASEDIR/lib{c,dl,log,m}.so $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/$SUFFIX/lib
|
|
|
|
cp $BASEDIR/lib{c,dl,m}.a $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/$SUFFIX/lib
|
2021-08-16 18:28:01 +02:00
|
|
|
cp $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/${SUFFIX}/libc++_shared.so \
|
|
|
|
$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/$SUFFIX/lib
|
|
|
|
cp $TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/${SUFFIX}/lib{c++_static,c++abi}.a \
|
|
|
|
$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/$SUFFIX/lib
|
2019-09-10 23:22:18 +02:00
|
|
|
echo 'INPUT(-lc++_static -lc++abi)' > $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/$SUFFIX/lib/libc++_shared.a
|
2017-08-26 22:56:25 +02:00
|
|
|
|
2021-08-16 18:28:01 +02:00
|
|
|
if [ $ARCH == "x86" ]; then
|
|
|
|
LIBATOMIC=$NDK/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/*/lib/linux/i386
|
|
|
|
elif [ $ARCH == "arm64" ]; then
|
|
|
|
LIBATOMIC=$NDK/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/*/lib/linux/aarch64
|
|
|
|
else
|
|
|
|
LIBATOMIC=$NDK/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/*/lib/linux/$ARCH
|
|
|
|
fi
|
2018-02-15 17:57:03 +01:00
|
|
|
|
2021-08-16 18:28:01 +02:00
|
|
|
cp $LIBATOMIC/libatomic.a $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/$SUFFIX/lib/
|
2022-03-07 09:47:20 +01:00
|
|
|
|
|
|
|
cp $LIBATOMIC/libunwind.a $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/$SUFFIX/lib/
|
|
|
|
}
|
|
|
|
|
|
|
|
add_cross_compiler_rt() {
|
|
|
|
RT_PREFIX=$NDK/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/*/lib/linux
|
|
|
|
RT_OPT_DIR=$TERMUX_PREFIX/opt/ndk-multilib/cross-compiler-rt
|
|
|
|
LIBLLVM_VERSION=$(. $TERMUX_SCRIPTDIR/packages/libllvm/build.sh; echo $TERMUX_PKG_VERSION)
|
2022-04-16 18:10:22 +02:00
|
|
|
RT_PATH=$TERMUX_PREFIX/lib/clang/$LIBLLVM_VERSION/lib/linux
|
2022-03-07 09:47:20 +01:00
|
|
|
mkdir -p $TERMUX_PKG_MASSAGEDIR/$RT_OPT_DIR
|
|
|
|
cp $RT_PREFIX/* $TERMUX_PKG_MASSAGEDIR/$RT_OPT_DIR || true
|
|
|
|
# Reserve this folder to make its existance be handled by dpkg.
|
|
|
|
mkdir -p $TERMUX_PKG_MASSAGEDIR/$RT_PATH
|
|
|
|
touch $TERMUX_PKG_MASSAGEDIR/$RT_PATH/.keep-ndk-multilib
|
2017-08-26 22:56:25 +02:00
|
|
|
}
|
|
|
|
|
2019-02-08 10:37:29 +01:00
|
|
|
termux_step_extract_into_massagedir() {
|
2017-08-26 22:56:25 +02:00
|
|
|
prepare_libs "arm" "arm-linux-androideabi"
|
|
|
|
prepare_libs "arm64" "aarch64-linux-android"
|
|
|
|
prepare_libs "x86" "i686-linux-android"
|
|
|
|
prepare_libs "x86_64" "x86_64-linux-android"
|
2022-03-07 09:47:20 +01:00
|
|
|
add_cross_compiler_rt
|
|
|
|
}
|
|
|
|
|
|
|
|
termux_step_create_debscripts() {
|
|
|
|
# Install the symlinks.
|
|
|
|
cat <<- POSTINST_EOF > ./postinst
|
|
|
|
#!$TERMUX_PREFIX/bin/sh
|
|
|
|
echo "Installing symlinks to $RT_PATH..."
|
|
|
|
find $RT_OPT_DIR -type f ! -name "libclang_rt*\$(dpkg --print-architecture)*" -exec ln -sf "{}" $RT_PATH \;
|
|
|
|
exit 0
|
|
|
|
POSTINST_EOF
|
|
|
|
|
|
|
|
# Uninstall the symlinks.
|
|
|
|
cat <<- PRERM_EOF > ./prerm
|
|
|
|
#!$TERMUX_PREFIX/bin/sh
|
|
|
|
if [ "$TERMUX_PACKAGE_FORMAT" != "pacman" ] && [ "\$1" != "remove" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
echo "Uninstalling symlinks..."
|
|
|
|
find $RT_PATH -type l ! -name "libclang_rt*\$(dpkg --print-architecture)*" -exec rm -rf "{}" \;
|
|
|
|
exit 0
|
|
|
|
PRERM_EOF
|
|
|
|
|
|
|
|
chmod 0755 postinst prerm
|
2017-08-26 22:56:25 +02:00
|
|
|
}
|