2015-02-08 09:04:15 -07:00
|
|
|
#! /bin/sh
|
2014-02-17 02:07:47 -07:00
|
|
|
|
2016-06-05 13:00:56 -07:00
|
|
|
if [ -z "$NDK_PLATFORM" ]; then
|
|
|
|
export NDK_PLATFORM="android-24"
|
|
|
|
export NDK_PLATFORM_COMPAT="${NDK_PLATFORM_COMPAT:-android-16}"
|
|
|
|
else
|
|
|
|
export NDK_PLATFORM_COMPAT="${NDK_PLATFORM_COMPAT:-${NDK_PLATFORM}}"
|
|
|
|
fi
|
|
|
|
|
2014-02-17 02:07:47 -07:00
|
|
|
if [ -z "$ANDROID_NDK_HOME" ]; then
|
|
|
|
echo "You should probably set ANDROID_NDK_HOME to the directory containing"
|
|
|
|
echo "the Android NDK"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f ./configure ]; then
|
|
|
|
echo "Can't find ./configure. Wrong directory or haven't run autogen.sh?"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-02-08 02:34:39 -07:00
|
|
|
if [ "x$TARGET_ARCH" = 'x' ] || [ "x$ARCH" = 'x' ] || [ "x$HOST_COMPILER" = 'x' ]; then
|
2014-02-17 02:07:47 -07:00
|
|
|
echo "You shouldn't use android-build.sh directly, use android-[arch].sh instead"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
export MAKE_TOOLCHAIN="${ANDROID_NDK_HOME}/build/tools/make-standalone-toolchain.sh"
|
|
|
|
|
|
|
|
export PREFIX="$(pwd)/libsodium-android-${TARGET_ARCH}"
|
|
|
|
export TOOLCHAIN_DIR="$(pwd)/android-toolchain-${TARGET_ARCH}"
|
|
|
|
export PATH="${PATH}:${TOOLCHAIN_DIR}/bin"
|
|
|
|
|
|
|
|
rm -rf "${TOOLCHAIN_DIR}" "${PREFIX}"
|
|
|
|
|
2016-06-05 13:04:10 -07:00
|
|
|
echo
|
2016-06-05 13:00:56 -07:00
|
|
|
echo "Building for platform [${NDK_PLATFORM}], retaining compatibility with platform [${NDK_PLATFORM_COMPAT}]"
|
|
|
|
echo
|
|
|
|
|
2016-10-10 05:43:57 -07:00
|
|
|
bash $MAKE_TOOLCHAIN --force --platform="$NDK_PLATFORM_COMPAT" \
|
2016-06-05 13:00:56 -07:00
|
|
|
--arch="$ARCH" --install-dir="$TOOLCHAIN_DIR" || exit 1
|
|
|
|
|
2015-08-05 10:46:36 -07:00
|
|
|
./configure \
|
|
|
|
--disable-soname-versions \
|
|
|
|
--enable-minimal \
|
|
|
|
--host="${HOST_COMPILER}" \
|
|
|
|
--prefix="${PREFIX}" \
|
2016-06-05 13:00:56 -07:00
|
|
|
--with-sysroot="${TOOLCHAIN_DIR}/sysroot" || exit 1
|
|
|
|
|
|
|
|
if [ "$NDK_PLATFORM" != "$NDK_PLATFORM_COMPAT" ]; then
|
|
|
|
egrep '^#define ' config.log | sort -u > config-def-compat.log
|
|
|
|
echo
|
|
|
|
echo "Configuring again for platform [${NDK_PLATFORM}]"
|
|
|
|
echo
|
2016-10-10 05:43:57 -07:00
|
|
|
bash $MAKE_TOOLCHAIN --force --platform="$NDK_PLATFORM" \
|
2016-06-05 13:00:56 -07:00
|
|
|
--arch="$ARCH" --install-dir="$TOOLCHAIN_DIR" || exit 1
|
|
|
|
|
|
|
|
./configure \
|
|
|
|
--disable-soname-versions \
|
|
|
|
--enable-minimal \
|
|
|
|
--host="${HOST_COMPILER}" \
|
|
|
|
--prefix="${PREFIX}" \
|
|
|
|
--with-sysroot="${TOOLCHAIN_DIR}/sysroot" || exit 1
|
|
|
|
|
|
|
|
egrep '^#define ' config.log | sort -u > config-def.log
|
|
|
|
if ! cmp config-def.log config-def-compat.log; then
|
|
|
|
echo "Platform [${NDK_PLATFORM}] is not backwards-compatible with [${NDK_PLATFORM_COMPAT}]" >&2
|
|
|
|
diff -u config-def.log config-def-compat.log >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
rm -f config-def.log config-def-compat.log
|
|
|
|
fi
|
|
|
|
|
2014-02-17 02:07:47 -07:00
|
|
|
make clean && \
|
|
|
|
make -j3 install && \
|
2015-08-05 11:00:15 -07:00
|
|
|
echo "libsodium has been installed into ${PREFIX}"
|