1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-20 02:25:14 -07:00

Merge pull request #118 from Prototik/android-buildscripts

Build scripts for android arm/x86/mips
This commit is contained in:
Frank Denis 2014-02-17 11:03:30 +01:00
commit 464e590969
7 changed files with 53 additions and 36 deletions

2
.gitignore vendored
View File

@ -101,3 +101,5 @@ test/default/stream5
test/default/stream6
test-driver
testing
android-toolchain-*
libsodium-android-*

View File

@ -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

4
dist-build/android-arm.sh Executable file
View File

@ -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"

39
dist-build/android-build.sh Executable file
View File

@ -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"

2
dist-build/android-mips.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
TARGET_ARCH=mips HOST_COMPILER=mipsel-linux-android "$(dirname "$0")/android-build.sh"

2
dist-build/android-x86.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
TARGET_ARCH=x86 HOST_COMPILER=i686-linux-android "$(dirname "$0")/android-build.sh"

View File

@ -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"