From 16a7691ead0e2fdb53fa0ca051700c295e601c60 Mon Sep 17 00:00:00 2001 From: Sergey Shatunov Date: Mon, 17 Feb 2014 17:07:47 +0800 Subject: [PATCH] Build scripts for android arm/x86/mips --- .gitignore | 2 ++ dist-build/Makefile.am | 5 ++++- dist-build/android-arm.sh | 4 ++++ dist-build/android-build.sh | 39 +++++++++++++++++++++++++++++++++++++ dist-build/android-mips.sh | 2 ++ dist-build/android-x86.sh | 2 ++ dist-build/android.sh | 35 --------------------------------- 7 files changed, 53 insertions(+), 36 deletions(-) create mode 100755 dist-build/android-arm.sh create mode 100755 dist-build/android-build.sh create mode 100755 dist-build/android-mips.sh create mode 100755 dist-build/android-x86.sh delete mode 100755 dist-build/android.sh diff --git a/.gitignore b/.gitignore index e1d66b58..15e1f017 100644 --- a/.gitignore +++ b/.gitignore @@ -101,3 +101,5 @@ test/default/stream5 test/default/stream6 test-driver testing +android-toolchain-* +libsodium-android-* diff --git a/dist-build/Makefile.am b/dist-build/Makefile.am index d56d665f..d6a64f65 100644 --- a/dist-build/Makefile.am +++ b/dist-build/Makefile.am @@ -1,6 +1,9 @@ EXTRA_DIST = \ - android.sh \ + android-build.sh \ + android-arm.sh \ + android-x86.sh \ + android-mips.sh \ iphone.sh \ msys-win32.sh \ msys-win64.sh diff --git a/dist-build/android-arm.sh b/dist-build/android-arm.sh new file mode 100755 index 00000000..792c81ce --- /dev/null +++ b/dist-build/android-arm.sh @@ -0,0 +1,4 @@ +#!/bin/sh +export CFLAGS="-Os -mthumb" +export LDFLAGS="-mthumb" +TARGET_ARCH=arm HOST_COMPILER=arm-linux-androideabi "$(dirname "$0")/android-build.sh" diff --git a/dist-build/android-build.sh b/dist-build/android-build.sh new file mode 100755 index 00000000..53578baf --- /dev/null +++ b/dist-build/android-build.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +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 + +if [[ -z $TARGET_ARCH ]] || [[ -z $HOST_COMPILER ]]; then + 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" +export LIBTOOL_EXTRA_FLAGS="-avoid-version" + +# Clean up before build +rm -rf "${TOOLCHAIN_DIR}" "${PREFIX}" + +$MAKE_TOOLCHAIN --platform="${NDK_PLATFORM:-android-14}" \ + --arch="$TARGET_ARCH" \ + --install-dir="$TOOLCHAIN_DIR" && \ + +./configure --host="${HOST_COMPILER}" \ + --with-sysroot="${TOOLCHAIN_DIR}/sysroot" \ + --prefix="${PREFIX}" && \ + +make clean && \ +make -j3 install && \ +echo "libsodium has been installed into $PREFIX" diff --git a/dist-build/android-mips.sh b/dist-build/android-mips.sh new file mode 100755 index 00000000..74c8da6b --- /dev/null +++ b/dist-build/android-mips.sh @@ -0,0 +1,2 @@ +#!/bin/sh +TARGET_ARCH=mips HOST_COMPILER=mipsel-linux-android "$(dirname "$0")/android-build.sh" diff --git a/dist-build/android-x86.sh b/dist-build/android-x86.sh new file mode 100755 index 00000000..669cca10 --- /dev/null +++ b/dist-build/android-x86.sh @@ -0,0 +1,2 @@ +#!/bin/sh +TARGET_ARCH=x86 HOST_COMPILER=i686-linux-android "$(dirname "$0")/android-build.sh" diff --git a/dist-build/android.sh b/dist-build/android.sh deleted file mode 100755 index b02b3aa5..00000000 --- a/dist-build/android.sh +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh - -if [ -z "$NDK_ROOT" ]; then - echo "You should probably set NDK_ROOT to the directory containing" - echo "the Android NDK" -fi - -if [ ! -f ./configure ]; then - echo "Can't find ./configure. Wrong directory or haven't run autogen.sh?" - exit 1 -fi - -export NDK_PLATFORM=${NDK_PLATFORM:-android-14} -export NDK_ROOT=${NDK_ROOT:-/usr/local/Cellar/android-ndk/9} -export TARGET_ARCH=arm -export TARGET="${TARGET_ARCH}-linux-androideabi" -export MAKE_TOOLCHAIN="${NDK_ROOT}/build/tools/make-standalone-toolchain.sh" - -export PREFIX="$(pwd)/libsodium-android" -export TOOLCHAIN_DIR="$(pwd)/android-toolchain" -export PATH="${PATH}:${TOOLCHAIN_DIR}" -export CFLAGS="-Os -mthumb" -export LDFLAGS="-mthumb" - -$MAKE_TOOLCHAIN --platform="$NDK_PLATFORM" --arch="$TARGET_ARCH" \ - --install-dir="$TOOLCHAIN_DIR" - -./configure --host=arm-linux-androideabi \ - --with-sysroot="${TOOLCHAIN_DIR}/sysroot" \ - --disable-pie \ - --disable-shared \ - --prefix="$PREFIX" && \ -make clean && \ -make -j3 install && \ -echo "libsodium has been installed into $PREFIX"