+: ${TERMUX_ANDROID_BUILD_TOOLS_VERSION:="24.0.1"}
+: ${TERMUX_NDK_VERSION:="12"}
+
+# Handle command-line arguments:
+show_usage () {
+ echo "Usage: ./build-package.sh [-a ARCH] PACKAGE"
+ echo "Build a package."
+ echo ""
+ exit 1
+}
+while getopts :a:h option
+do
+ case "$option" in
+ a) TERMUX_ARCH="$OPTARG";;
+ h) show_usage;;
+ ?) echo "./build-package.sh: illegal option -$OPTARG"; exit 1;;
+ esac
+done
+shift $(($OPTIND-1))
+if [ "$#" -ne 1 ]; then show_usage; fi
+
+# 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!'
+ exit 1
+fi
+if grep -s -q "Pkg.Revision = $TERMUX_NDK_VERSION" $NDK/source.properties; then
+ :
+else
+ echo "Wrong NDK version - we need $TERMUX_NDK_VERSION"
+ exit 1
+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}-"