2013-09-18 14:50:46 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# This script checks out or updates and builds third party libraries
|
|
|
|
# required for the android build.
|
|
|
|
#
|
|
|
|
# Specifically these are:
|
|
|
|
# - OpenSSL
|
|
|
|
# - Android NDK Profiler
|
2013-11-21 12:46:58 +04:00
|
|
|
# - Jpeg library
|
2013-09-18 14:50:46 +04:00
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# android_setup_build_env.sh <source root>
|
|
|
|
|
2013-11-21 12:46:58 +04:00
|
|
|
OPENSSL_SCM=https://github.com/akallabeth/openssl-android.git
|
2014-07-08 14:44:35 +04:00
|
|
|
OPENSSL_TAG=1.0.1h-fips-2.0.7
|
2013-11-21 12:46:58 +04:00
|
|
|
NDK_PROFILER_SCM=https://github.com/richq/android-ndk-profiler.git
|
|
|
|
JPEG_LIBRARY_SCM=https://github.com/akallabeth/jpeg8d.git
|
2013-09-18 14:50:46 +04:00
|
|
|
|
2014-07-08 14:44:35 +04:00
|
|
|
SCRIPT_NAME=$(basename $0)
|
|
|
|
|
|
|
|
if [ -x $ANDROID_NDK/ndk-build ]; then
|
|
|
|
NDK_BUILD=$ANDROID_NDK/ndk-build
|
|
|
|
else
|
|
|
|
echo "ndk-build not found in NDK directory $ANDROID_NDK"
|
|
|
|
echo "assuming ndk-build is in path..."
|
|
|
|
NDK_BUILD=ndk-build
|
|
|
|
fi
|
2013-11-21 12:46:58 +04:00
|
|
|
|
2013-09-18 14:50:46 +04:00
|
|
|
if [ $# -ne 1 ]; then
|
2013-11-21 12:46:58 +04:00
|
|
|
|
2013-11-18 13:27:11 +04:00
|
|
|
echo "Missing command line argument, current directory as root."
|
|
|
|
ROOT=`pwd`
|
|
|
|
ROOT=$ROOT/external
|
|
|
|
else
|
|
|
|
ROOT=`readlink -f $1`
|
2013-09-18 14:50:46 +04:00
|
|
|
fi
|
|
|
|
|
2013-11-18 13:27:11 +04:00
|
|
|
if [ ! -d $ROOT ]; then
|
|
|
|
echo "Argument '$ROOT' is not a directory."
|
2013-09-18 14:50:46 +04:00
|
|
|
exit -2
|
|
|
|
fi
|
2013-11-18 13:27:11 +04:00
|
|
|
echo "Using '$ROOT' as root."
|
2013-09-18 14:50:46 +04:00
|
|
|
|
|
|
|
echo "Preparing OpenSSL..."
|
2013-11-18 13:27:11 +04:00
|
|
|
OPENSSL_SRC=$ROOT/openssl-build
|
2013-09-18 14:50:46 +04:00
|
|
|
if [ -d $OPENSSL_SRC ]; then
|
|
|
|
cd $OPENSSL_SRC
|
2014-07-13 15:35:11 +04:00
|
|
|
git fetch
|
2013-09-18 14:50:46 +04:00
|
|
|
RETVAL=$?
|
|
|
|
else
|
|
|
|
git clone $OPENSSL_SCM $OPENSSL_SRC
|
|
|
|
RETVAL=$?
|
|
|
|
fi
|
|
|
|
if [ $RETVAL -ne 0 ]; then
|
|
|
|
echo "Failed to execute git command [$RETVAL]"
|
|
|
|
exit -3
|
|
|
|
fi
|
2013-11-18 13:27:11 +04:00
|
|
|
cd $OPENSSL_SRC
|
2014-07-08 12:20:13 +04:00
|
|
|
|
|
|
|
# We want to build a specific TAG
|
|
|
|
git checkout $OPENSSL_TAG
|
|
|
|
|
2013-11-18 13:27:11 +04:00
|
|
|
make clean
|
|
|
|
# The makefile has a bug, which aborts during
|
|
|
|
# first compilation. Rerun make to build the whole lib.
|
|
|
|
make
|
2014-07-13 15:35:11 +04:00
|
|
|
RETVAL=$?
|
2013-09-18 14:50:46 +04:00
|
|
|
if [ $RETVAL -ne 0 ]; then
|
2013-11-18 13:27:11 +04:00
|
|
|
echo "Failed to execute make command [$RETVAL]"
|
2013-09-18 14:50:46 +04:00
|
|
|
exit -4
|
|
|
|
fi
|
2013-11-18 13:27:11 +04:00
|
|
|
# Copy the created library to the default openssl directory,
|
|
|
|
# so that CMake will detect it automatically.
|
|
|
|
SSL_ROOT=`find $OPENSSL_SRC -type d -name "openssl-?.?.*"`
|
2013-11-21 13:05:52 +04:00
|
|
|
if [ -z "$SSL_ROOT" ]; then
|
|
|
|
echo "OpenSSL was not build successfully, aborting."
|
|
|
|
exit -42
|
|
|
|
fi
|
2013-11-21 15:27:26 +04:00
|
|
|
mkdir -p $SSL_ROOT/lib
|
|
|
|
cp $SSL_ROOT/*.a $SSL_ROOT/lib/
|
2013-11-21 13:05:52 +04:00
|
|
|
|
2013-11-18 13:27:11 +04:00
|
|
|
rm -f $ROOT/openssl
|
|
|
|
ln -s $SSL_ROOT $ROOT/openssl
|
|
|
|
|
2013-09-18 14:50:46 +04:00
|
|
|
echo "Preparing NDK profiler..."
|
2013-11-18 13:27:11 +04:00
|
|
|
NDK_PROFILER_SRC=$ROOT/android-ndk-profiler
|
2013-09-18 14:50:46 +04:00
|
|
|
if [ -d $NDK_PROFILER_SRC ]; then
|
|
|
|
cd $NDK_PROFILER_SRC
|
|
|
|
git pull
|
|
|
|
RETVAL=$?
|
|
|
|
else
|
|
|
|
git clone $NDK_PROFILER_SCM $NDK_PROFILER_SRC
|
|
|
|
RETVAL=$?
|
|
|
|
fi
|
|
|
|
if [ $RETVAL -ne 0 ]; then
|
|
|
|
echo "Failed to execute git command [$RETVAL]"
|
|
|
|
exit -5
|
|
|
|
fi
|
2013-11-18 13:27:11 +04:00
|
|
|
cd $NDK_PROFILER_SRC
|
2014-07-08 14:44:35 +04:00
|
|
|
$NDK_BUILD V=1 APP_ABI=armeabi-v7a clean
|
|
|
|
$NDK_BUILD V=1 APP_ABI=armeabi-v7a
|
2013-09-18 14:50:46 +04:00
|
|
|
RETVAL=$?
|
|
|
|
if [ $RETVAL -ne 0 ]; then
|
2014-07-08 14:44:35 +04:00
|
|
|
echo "Failed to execute $NDK_BUILD command [$RETVAL]"
|
2013-09-18 14:50:46 +04:00
|
|
|
exit -6
|
|
|
|
fi
|
|
|
|
|
2013-11-21 12:46:58 +04:00
|
|
|
echo "Preparing JPEG library..."
|
|
|
|
JPEG_LIBRARY_SRC=$ROOT/jpeg8d
|
|
|
|
if [ -d $JPEG_LIBRARY_SRC ]; then
|
|
|
|
cd $JPEG_LIBRARY_SRC
|
|
|
|
git pull
|
|
|
|
RETVAL=$?
|
|
|
|
else
|
|
|
|
git clone $JPEG_LIBRARY_SCM $JPEG_LIBRARY_SRC
|
|
|
|
RETVAL=$?
|
|
|
|
fi
|
|
|
|
if [ $RETVAL -ne 0 ]; then
|
|
|
|
echo "Failed to execute git command [$RETVAL]"
|
|
|
|
exit -6
|
|
|
|
fi
|
|
|
|
cd $JPEG_LIBRARY_SRC
|
2014-07-08 14:44:35 +04:00
|
|
|
$NDK_BUILD V=1 APP_ABI=armeabi-v7a clean
|
|
|
|
$NDK_BUILD V=1 APP_ABI=armeabi-v7a
|
2013-11-21 12:46:58 +04:00
|
|
|
RETVAL=$?
|
|
|
|
if [ $RETVAL -ne 0 ]; then
|
2014-07-08 14:44:35 +04:00
|
|
|
echo "Failed to execute $NDK_BUILD command [$RETVAL]"
|
2013-11-21 12:46:58 +04:00
|
|
|
exit -7
|
|
|
|
fi
|
2013-11-21 15:27:26 +04:00
|
|
|
mkdir -p $JPEG_LIBRARY_SRC/lib
|
|
|
|
cp $JPEG_LIBRARY_SRC/obj/local/armeabi-v7a/*.a $JPEG_LIBRARY_SRC/lib/
|
2013-11-21 12:46:58 +04:00
|
|
|
|
2013-09-18 14:50:46 +04:00
|
|
|
echo "Prepared external libraries, you can now build the application."
|
|
|
|
exit 0
|