From f8cc885b6f7cb8512aabcd49ed3a510d5be76260 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 5 Jun 2016 22:00:56 +0200 Subject: [PATCH] Android: compile for platform 24, check compat with 16 or 21 (64 bit) --- dist-build/android-armv8-a.sh | 2 +- dist-build/android-build.sh | 42 ++++++++++++++++++++++++++++++++--- dist-build/android-mips64.sh | 2 +- dist-build/android-x86_64.sh | 4 ++-- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/dist-build/android-armv8-a.sh b/dist-build/android-armv8-a.sh index 275b6ba6..14e61ef2 100755 --- a/dist-build/android-armv8-a.sh +++ b/dist-build/android-armv8-a.sh @@ -1,4 +1,4 @@ #!/bin/sh export TARGET_ARCH=armv8-a export CFLAGS="-Os -march=${TARGET_ARCH}" -ARCH=arm64 HOST_COMPILER=aarch64-linux-android "$(dirname "$0")/android-build.sh" +NDK_PLATFORM_COMPAT=android-21 ARCH=arm64 HOST_COMPILER=aarch64-linux-android "$(dirname "$0")/android-build.sh" diff --git a/dist-build/android-build.sh b/dist-build/android-build.sh index 437d36e3..33f21467 100755 --- a/dist-build/android-build.sh +++ b/dist-build/android-build.sh @@ -1,5 +1,12 @@ #! /bin/sh +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 + if [ -z "$ANDROID_NDK_HOME" ]; then echo "You should probably set ANDROID_NDK_HOME to the directory containing" echo "the Android NDK" @@ -24,14 +31,43 @@ export PATH="${PATH}:${TOOLCHAIN_DIR}/bin" rm -rf "${TOOLCHAIN_DIR}" "${PREFIX}" -bash $MAKE_TOOLCHAIN --platform="${NDK_PLATFORM:-android-16}" \ - --arch="$ARCH" --install-dir="$TOOLCHAIN_DIR" && \ +echo "Building for platform [${NDK_PLATFORM}], retaining compatibility with platform [${NDK_PLATFORM_COMPAT}]" +echo + +bash $MAKE_TOOLCHAIN --platform="$NDK_PLATFORM_COMPAT" \ + --arch="$ARCH" --install-dir="$TOOLCHAIN_DIR" || exit 1 + ./configure \ --disable-soname-versions \ --enable-minimal \ --host="${HOST_COMPILER}" \ --prefix="${PREFIX}" \ - --with-sysroot="${TOOLCHAIN_DIR}/sysroot" && \ + --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 + bash $MAKE_TOOLCHAIN --platform="$NDK_PLATFORM" \ + --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 + make clean && \ make -j3 install && \ echo "libsodium has been installed into ${PREFIX}" diff --git a/dist-build/android-mips64.sh b/dist-build/android-mips64.sh index 579969d3..4eeeda4a 100755 --- a/dist-build/android-mips64.sh +++ b/dist-build/android-mips64.sh @@ -1,4 +1,4 @@ #!/bin/sh export TARGET_ARCH=mips64r6 export CFLAGS="-Os -march=${TARGET_ARCH}" -ARCH=mips64 HOST_COMPILER=mips64el-linux-android "$(dirname "$0")/android-build.sh" +NDK_PLATFORM_COMPAT=android-21 ARCH=mips64 HOST_COMPILER=mips64el-linux-android "$(dirname "$0")/android-build.sh" diff --git a/dist-build/android-x86_64.sh b/dist-build/android-x86_64.sh index b4b168e8..5314d5e9 100755 --- a/dist-build/android-x86_64.sh +++ b/dist-build/android-x86_64.sh @@ -1,4 +1,4 @@ #!/bin/sh -export TARGET_ARCH=x86_64 +export TARGET_ARCH=westmere export CFLAGS="-Os -march=${TARGET_ARCH}" -ARCH=x86_64 HOST_COMPILER=x86_64-linux-android "$(dirname "$0")/android-build.sh" +NDK_PLATFORM_COMPAT=android-21 ARCH=x86_64 HOST_COMPILER=x86_64-linux-android "$(dirname "$0")/android-build.sh"