From e8b6e4a4d3f15dfeb33e6d26f8a501d0b63bf274 Mon Sep 17 00:00:00 2001 From: Sergey Shatunov Date: Mon, 24 Feb 2014 17:12:55 +0800 Subject: [PATCH] Main buildscripts for android --- .gitignore | 4 +++ Makefile.am | 7 ++++- dist-build/android-arm.sh | 3 ++ dist-build/android-armv7.sh | 3 ++ dist-build/android-build.sh | 63 +++++++++++++++++++++++++++++++++++++ dist-build/android-mips.sh | 3 ++ dist-build/android-x86.sh | 3 ++ 7 files changed, 85 insertions(+), 1 deletion(-) create mode 100755 dist-build/android-arm.sh create mode 100755 dist-build/android-armv7.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 diff --git a/.gitignore b/.gitignore index e903e3ca..43bbae7a 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,7 @@ nbproject # astyle *.orig + +# Android buildscript +android-toolchain-* +toxcore-android-* diff --git a/Makefile.am b/Makefile.am index b58e7bae..9ef4afed 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,6 +12,11 @@ CLEANFILES = $(top_builddir)/libtoxcore.pc EXTRA_DIST = \ libtoxcore.pc.in \ + dist-build/android-arm.sh \ + dist-build/android-armv7.sh \ + dist-build/android-x86.sh \ + dist-build/android-mips.sh \ + dist-build/android-build.sh \ $(top_srcdir)/docs/updates/Crypto.md \ $(top_srcdir)/docs/updates/Spam-Prevention.md \ $(top_srcdir)/docs/updates/Symmetric-NAT-Transversal.md \ @@ -27,4 +32,4 @@ CLEANFILES += $(top_builddir)/libtoxav.pc EXTRA_DIST += libtoxav.pc.in -endif \ No newline at end of file +endif diff --git a/dist-build/android-arm.sh b/dist-build/android-arm.sh new file mode 100755 index 00000000..af736da3 --- /dev/null +++ b/dist-build/android-arm.sh @@ -0,0 +1,3 @@ +#!/bin/sh +export CFLAGS="-Ofast -mthumb -marm -march=armv6" +TARGET_ARCH=arm TOOLCHAIN_NAME=arm-linux-androideabi-4.8 HOST_COMPILER=arm-linux-androideabi "$(dirname "$0")/android-build.sh" diff --git a/dist-build/android-armv7.sh b/dist-build/android-armv7.sh new file mode 100755 index 00000000..838a62f9 --- /dev/null +++ b/dist-build/android-armv7.sh @@ -0,0 +1,3 @@ +#!/bin/sh +export CFLAGS="-Ofast -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a" +TARGET_ARCH=armv7 TOOLCHAIN_NAME=arm-linux-androideabi-4.8 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..984a531d --- /dev/null +++ b/dist-build/android-build.sh @@ -0,0 +1,63 @@ +#!/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 [ -z "$SODIUM_HOME" ]; then + echo "You should probably set SODIUM_HOME to the directory containing root sodium sources" + exit +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 + +if [ ! -f ./configure ]; then + echo "Can't find ./configure. Wrong directory or haven't run autogen.sh?" + exit 1 +fi + +if [ -z "$TOOLCHAIN_DIR" ]; then + export TOOLCHAIN_DIR="$(pwd)/android-toolchain-${TARGET_ARCH}" + export MAKE_TOOLCHAIN="${ANDROID_NDK_HOME}/build/tools/make-standalone-toolchain.sh" + + if [ -z "$MAKE_TOOLCHAIN" ]; then + echo "Cannot find a make-standalone-toolchain.sh in ndk dir, interrupt..." + exit 1 + fi + + $MAKE_TOOLCHAIN --platform="${NDK_PLATFORM:-android-14}" \ + --arch="${TARGET_ARCH}" \ + --toolchain="${TOOLCHAIN_NAME:-arm-linux-androideabi-4.8}" \ + --install-dir="${TOOLCHAIN_DIR}" +fi + +export PREFIX="$(pwd)/toxcore-android-${TARGET_ARCH}" +export SYSROOT="${TOOLCHAIN_DIR}/sysroot" +export PATH="${PATH}:${TOOLCHAIN_DIR}/bin" + +# Clean up before build +rm -rf "${PREFIX}" + +export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include" +export CPPFLAGS="${CFLAGS}" +export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib" + +./configure --host="${HOST_COMPILER}" \ + --with-sysroot="${SYSROOT}" \ + --with-libsodium-headers="${SODIUM_HOME}/libsodium-android-${TARGET_ARCH}/include" \ + --with-libsodium-libs="${SODIUM_HOME}/libsodium-android-${TARGET_ARCH}/lib" \ + --disable-soname-versions \ + --disable-av \ + --disable-ntox \ + --disable-daemon \ + --disable-phone \ + --prefix="${PREFIX}" && \ + +make clean && \ +make -j3 install && \ +echo "libtoxcore 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..6e105c2f --- /dev/null +++ b/dist-build/android-mips.sh @@ -0,0 +1,3 @@ +#!/bin/sh +export CFLAGS="-Ofast" +TARGET_ARCH=mips TOOLCHAIN_NAME=mipsel-linux-android-4.8 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..6768b887 --- /dev/null +++ b/dist-build/android-x86.sh @@ -0,0 +1,3 @@ +#!/bin/sh +export CFLAGS="-Ofast" +TARGET_ARCH=x86 TOOLCHAIN_NAME=x86-4.8 HOST_COMPILER=i686-linux-android "$(dirname "$0")/android-build.sh"