# Read settings from .termuxrc if existing:
test -f $HOME/.termuxrc && . $HOME/.termuxrc
-# Configurable settings:
-: ${ANDROID_HOME:="${HOME}/lib/android-sdk"}
-: ${NDK:="${HOME}/lib/android-ndk"}
-: ${TERMUX_MAKE_PROCESSES:='4'}
-: ${TERMUX_TOPDIR:="$HOME/.termux-build"}
-: ${TERMUX_ARCH:="aarch64"} # arm, aarch64, i686 or x86_64.
-: ${TERMUX_PREFIX:='/data/data/com.termux/files/usr'}
-: ${TERMUX_ANDROID_HOME:='/data/data/com.termux/files/home'}
-: ${TERMUX_DEBUG:=""}
-: ${TERMUX_PROCESS_DEB:=""}
-: ${TERMUX_API_LEVEL:="21"}
-: ${TERMUX_ANDROID_BUILD_TOOLS_VERSION:="24.0.1"}
-: ${TERMUX_NDK_VERSION:="13"}
-: ${TERMUX_IS_DISABLED:=""}
-
# Handle command-line arguments:
show_usage () {
echo "Usage: ./build-package.sh [-a ARCH] [-d] [-D] PACKAGE"
echo " -D Build a disabled package in disabled-packages/."
exit 1
}
-while getopts :a:hd:D option
+while getopts :a:hdD option
do
case "$option" in
a) TERMUX_ARCH="$OPTARG";;
shift $(($OPTIND-1))
if [ "$#" -ne 1 ]; then show_usage; fi
+# Configurable settings:
+: ${ANDROID_HOME:="${HOME}/lib/android-sdk"}
+: ${NDK:="${HOME}/lib/android-ndk"}
+: ${TERMUX_MAKE_PROCESSES:='4'}
+: ${TERMUX_TOPDIR:="$HOME/.termux-build"}
+: ${TERMUX_ARCH:="aarch64"} # arm, aarch64, i686 or x86_64.
+if [ "x86_64" = $TERMUX_ARCH -o "aarch64" = $TERMUX_ARCH ]; then
+ TERMUX_ARCH_BITS=64
+else
+ TERMUX_ARCH_BITS=32
+fi
+TERMUX_HOST_PLATFORM="${TERMUX_ARCH}-linux-android"
+if [ $TERMUX_ARCH = "arm" ]; then TERMUX_HOST_PLATFORM="${TERMUX_HOST_PLATFORM}eabi"; fi
+: ${TERMUX_PREFIX:='/data/data/com.termux/files/usr'}
+: ${TERMUX_ANDROID_HOME:='/data/data/com.termux/files/home'}
+: ${TERMUX_DEBUG:=""}
+: ${TERMUX_PROCESS_DEB:=""}
+: ${TERMUX_API_LEVEL:="21"}
+: ${TERMUX_ANDROID_BUILD_TOOLS_VERSION:="24.0.1"}
+: ${TERMUX_NDK_VERSION:="13"}
+: ${TERMUX_IS_DISABLED:=""}
+
# Check the NDK:
if [ ! -d "$NDK" ]; then
echo 'ERROR: $NDK not defined as pointing at a directory - define it pointing at a android NDK installation!'
TERMUX_PKG_DESCRIPTION="FIXME:Add description"
TERMUX_PKG_FOLDERNAME=""
TERMUX_PKG_KEEP_STATIC_LIBRARIES="false"
-TERMUX_PKG_KEEP_HEADER_FILES="false"
TERMUX_PKG_ESSENTIAL=""
TERMUX_PKG_CONFLICTS="" # https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
TERMUX_PKG_REPLACES=""
# Optional checksum argument:
local EXPECTED=$3
if [ $EXPECTED != $ACTUAL_CHECKSUM ]; then
- >&2 printf "Wrong checksum for $URL:\nExpected: $EXPECTED\nActual: $ACTUAL_CHECKSUM\n"
+ >&2 printf "Wrong checksum for %s:\nExpected: %s\nActual: %s\n" \
+ "$URL" "$EXPECTED" "$ACTUAL_CHECKSUM"
exit 1
fi
else
- printf "No validation of checksum for $URL:\nActual: $ACTUAL_CHECKSUM\n"
+ printf "No validation of checksum for %s:\nActual: %s\n" \
+ "$URL" "$ACTUAL_CHECKSUM"
fi
mv "$TMPFILE" "$DESTINATION"
return
# After termux_step_post_extract_package() and before termux_step_patch_package()
termux_step_host_build () {
$TERMUX_PKG_SRCDIR/configure ${TERMUX_PKG_EXTRA_HOSTBUILD_CONFIGURE_ARGS}
- make
+ make -j $TERMUX_MAKE_PROCESSES
}
# This should not be overridden
fi
echo "termux - building $1 for arch $TERMUX_ARCH..."
-test -t 1 && printf "\033]0;$1...\007"
+test -t 1 && printf "\033]0;%s...\007" "$1"
# Compute full version:
TERMUX_PKG_FULLVERSION=$TERMUX_PKG_VERSION
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+="-v2"
+TERMUX_STANDALONE_TOOLCHAIN+="-v3"
# We put this after system PATH to avoid picking up toolchain stripped python
export PATH=$PATH:$TERMUX_STANDALONE_TOOLCHAIN/bin
-if [ "x86_64" = $TERMUX_ARCH -o "aarch64" = $TERMUX_ARCH ]; then
- TERMUX_ARCH_BITS=64
-else
- TERMUX_ARCH_BITS=32
-fi
-TERMUX_HOST_PLATFORM="${TERMUX_ARCH}-linux-android"
-if [ $TERMUX_ARCH = "arm" ]; then TERMUX_HOST_PLATFORM="${TERMUX_HOST_PLATFORM}eabi"; fi
-
export AR=$TERMUX_HOST_PLATFORM-ar
if [ "$TERMUX_PKG_CLANG" = "no" ]; then
export AS=${TERMUX_HOST_PLATFORM}-gcc
export CFLAGS="$_SPECSFLAG"
export LDFLAGS="$_SPECSFLAG -L${TERMUX_PREFIX}/lib"
# Android 7 started to support DT_RUNPATH (but not DT_RPATH), so we may want
-# "-Wl,-rpath=$TERMUX_PREFIX/lib -Wl,--enable-new-dtags" here in the future
-# - and no longer remove DT_RUNPATH in termux-elf-cleaner.
+# LDFLAGS+="-Wl,-rpath=$TERMUX_PREFIX/lib -Wl,--enable-new-dtags"
+# and no longer remove DT_RUNPATH in termux-elf-cleaner.
if [ "$TERMUX_ARCH" = "arm" ]; then
CFLAGS+=" -march=armv7-a -mfpu=neon -mfloat-abi=softfp"
$TERMUX_ELF_CLEANER usr/lib/*.so
+ # zlib is really version 1.2.8 in the Android platform (at least
+ # starting from Android 5), not older as the NDK headers claim.
+ for file in zconf.h zlib.h; do
+ curl -o $_TERMUX_TOOLCHAIN_TMPDIR/sysroot/usr/include/$file \
+ https://raw.githubusercontent.com/madler/zlib/v1.2.8/$file
+ done
+ unset file
+
mv $_TERMUX_TOOLCHAIN_TMPDIR $TERMUX_STANDALONE_TOOLCHAIN
fi
cat > $PKG_CONFIG_LIBDIR/zlib.pc <<HERE
Name: zlib
Description: zlib compression library
-Version: 1.2.3
+Version: 1.2.8
Requires:
Libs: -lz
# In the .deb ar file there should be a file "debian-binary" with "2.0" as the content:
TERMUX_PKG_DEBFILE=$TERMUX_DEBDIR/${TERMUX_PKG_NAME}_${TERMUX_PKG_FULLVERSION}_${TERMUX_ARCH}.deb
# Create the actual .deb file:
-ar cr $TERMUX_PKG_DEBFILE \
- $TERMUX_COMMON_CACHEDIR/debian-binary \
- $TERMUX_PKG_PACKAGEDIR/control.tar.xz \
- $TERMUX_PKG_PACKAGEDIR/data.tar.xz
+ar cr "$TERMUX_PKG_DEBFILE" \
+ "$TERMUX_COMMON_CACHEDIR/debian-binary" \
+ "$TERMUX_PKG_PACKAGEDIR/control.tar.xz" \
+ "$TERMUX_PKG_PACKAGEDIR/data.tar.xz"
if [ "$TERMUX_PROCESS_DEB" != "" ]; then
- $TERMUX_PROCESS_DEB $TERMUX_PKG_DEBFILE
+ $TERMUX_PROCESS_DEB "$TERMUX_PKG_DEBFILE"
fi
echo "termux - build of '$1' done"
-test -t 1 && printf "\033]0;$1 - DONE\007"
+test -t 1 && printf "\033]0;%s - DONE\007" "$1"
exit 0