summaryrefslogtreecommitdiff
path: root/configure-android
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2013-09-09 05:53:58 +0000
committerLiong Sauw Ming <ming@teluu.com>2013-09-09 05:53:58 +0000
commit93384987920caa35c0de8739d1ba0233c3279a8b (patch)
treeb7dc829be4f0f291dfe9973e29bf38d8605f675e /configure-android
parent253d6c05a6235543cd40fedc142b054720af1f4d (diff)
Re #1516: Add support to build for other targets. Example:
TARGET_ABI=armeabi-v7a ./configure-android --use-ndk-cflags git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4594 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'configure-android')
-rwxr-xr-xconfigure-android93
1 files changed, 59 insertions, 34 deletions
diff --git a/configure-android b/configure-android
index d749b681..ca5d9f08 100755
--- a/configure-android
+++ b/configure-android
@@ -16,11 +16,12 @@ if test "$*" = "--help" -o "$*" = "-h"; then
echo "Environment variables:"
echo " ANDROID_NDK_ROOT Specify the directory of Android NDK to use."
echo " APP_PLATFORM Optionally specify the platform level used, e.g."
- echo " android-8. By default, configure will use the maximum"
- echo " platform level detected."
- echo " TARGET_ABI Optionally specify a single target architecture, e.g."
- echo " armeabi-v7a. By default, the target architecture is"
- echo " armeabi."
+ echo " android-9. By default, configure will use the"
+ echo " maximum platform level detected."
+ echo " TARGET_ABI Optionally specify a single target architecture,"
+ echo " e.g. armeabi-v7a, mips, x86. By default, the target"
+ echo " architecture is armeabi. Only used when"
+ echo " --use-ndk-cflags is specified."
echo ""
exit 0
fi
@@ -53,45 +54,69 @@ fi
if test "$1" = "--use-ndk-cflags"; then
shift
+ ADD_CFLAGS="1"
for i in `${ANDROID_NDK_ROOT}/ndk-build -n -C ${ANDROID_NDK_ROOT}/samples/hello-jni NDK_LOG=1 APP_PLATFORM=${APP_PLATFORM} APP_ABI=${TARGET_ABI}`; do
- if test "$i" = "-c"; then break; fi
- if test "x${NDK_CC}" != "x" -a "$i" != "-MF" -a "x`echo $i|grep '\.o\.d'`" = "x" -a "x`echo $i|grep 'include'`" = "x"; then
- NDK_CFLAGS="${NDK_CFLAGS} $i"
+ if test "x${NDK_CXX}" != "x" -a "$i" = "-o"; then break; fi
+
+ # Parse NDK CXXFLAGS
+ if test "x${NDK_CXX}" != "x" -a "x`echo $i|grep 'hello-jni'`" = "x"; then
+ if test "x`echo $i|grep '\-\-sysroot='`" != "x"; then
+ ANDROID_SYSROOT=`echo $i|sed 's/--sysroot=//'`;
+ fi
+ NDK_CXXFLAGS="${NDK_CXXFLAGS} $i"
+ fi
+
+ # Parse NDK CFLAGS
+ if test "x${NDK_CC}" != "x" -a "x`echo $i|grep 'hello-jni'`" = "x" -a "x`echo $i|grep '\-M'`" = "x" -a "${ADD_CFLAGS}" = "1"; then
+ if test "$i" = "-c"; then ADD_CFLAGS="0"; else
+ NDK_CFLAGS="${NDK_CFLAGS} $i"
+ fi
fi
- if test "x`echo $i | grep 'gcc'`" != "x"; then
+
+ # Find gcc toolchain
+ if test "x${NDK_CC}" = "x" -a "x`echo $i | grep 'gcc'`" != "x"; then
NDK_CC=$i
fi
+ # Find g++ toolchain
+ if test "x`echo $i | grep 'g++'`" != "x"; then
+ NDK_CXX=$i
+ fi
done
+
+ export CC="${NDK_CC}"
+ export CXX="${NDK_CXX}"
+
+ export LDFLAGS="${LDFLAGS} -nostdlib -L${ANDROID_SYSROOT}/usr/lib/"
+ export LIBS="${LIBS} -lc -lgcc"
export CFLAGS="${CFLAGS} ${NDK_CFLAGS}"
-fi
+ export CPPFLAGS="${CFLAGS}"
+ export CXXFLAGS="${NDK_CXXFLAGS}"
-HOST_OS=$(uname -s)
-case $HOST_OS in
- Darwin) BUILD_MACHINE="darwin-x86";;
- Linux) BUILD_MACHINE="linux-x86";;
- CYGWIN*|*_NT-*) BUILD_MACHINE="windows";;
-esac
-
-ANDROID_TC="${ANDROID_NDK_ROOT}/toolchains/${TC_DIR}-4.4.3/prebuilt/${BUILD_MACHINE}"
-if test ! -d ${ANDROID_TC}; then
- echo "$F error: unable to find directory ${ANDROID_TC} in Android NDK"
- exit 1
-fi
+else
-export ANDROID_SYSROOT="${ANDROID_NDK_ROOT}/platforms/${APP_PLATFORM}/arch-arm"
-if test ! -d ${ANDROID_SYSROOT}; then
- echo "$F error: unable to find sysroot dir ${ANDROID_SYSROOT} in Android NDK"
- exit 1
-fi
+ ANDROID_TC_VER=`ls -d ${ANDROID_NDK_ROOT}/toolchains/${TC_DIR}-* | sed 's/clang/0/' | sort -gr | head -1`
+ ANDROID_TC=`ls -d ${ANDROID_TC_VER}/prebuilt/*`
+ if test ! -d ${ANDROID_TC}; then
+ echo "$F error: unable to find directory ${ANDROID_TC} in Android NDK"
+ exit 1
+ fi
-export CC="${ANDROID_TC}/bin/${TARGET_HOST}-gcc"
-export CXX="${ANDROID_TC}/bin/${TARGET_HOST}-g++"
+ export ANDROID_SYSROOT="${ANDROID_NDK_ROOT}/platforms/${APP_PLATFORM}/arch-arm"
+ if test ! -d ${ANDROID_SYSROOT}; then
+ echo "$F error: unable to find sysroot dir ${ANDROID_SYSROOT} in Android NDK"
+ exit 1
+ fi
-export LDFLAGS="${LDFLAGS} -nostdlib -L${ANDROID_SYSROOT}/usr/lib/"
-export LIBS="${LIBS} -lc -lgcc"
-export CFLAGS="${CFLAGS} -I${ANDROID_SYSROOT}/usr/include"
-export CPPFLAGS="${CFLAGS}"
-export CXXFLAGS="${CXXFLAGS} -shared --sysroot=${ANDROID_SYSROOT}"
+ export CC="${ANDROID_TC}/bin/${TARGET_HOST}-gcc"
+ export CXX="${ANDROID_TC}/bin/${TARGET_HOST}-g++"
+
+ export LDFLAGS="${LDFLAGS} -nostdlib -L${ANDROID_SYSROOT}/usr/lib/"
+ export LIBS="${LIBS} -lc -lgcc"
+ export CFLAGS="${CFLAGS} -I${ANDROID_SYSROOT}/usr/include"
+ export CPPFLAGS="${CFLAGS}"
+ export CXXFLAGS="${CXXFLAGS} -shared --sysroot=${ANDROID_SYSROOT}"
+
+fi
# Print settings
if test "1" = "1"; then