[Android] Support NDK r8b with gcc 4.6

Rafaël Carré git at videolan.org
Fri Aug 3 15:29:51 CEST 2012


android | branch: master | Rafaël Carré <funman at videolan.org> | Fri Aug  3 15:28:25 2012 +0200| [11c2b7c721ae8e6fde7a73512fee6c88d2d778c6] | committer: Rafaël Carré

Support NDK r8b with gcc 4.6

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=11c2b7c721ae8e6fde7a73512fee6c88d2d778c6
---

 compile.sh                 |   38 ++++++++++++++++++++++++++++----------
 configure.sh               |    6 +++---
 vlc-android/jni/Android.mk |    2 +-
 3 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/compile.sh b/compile.sh
index 4add5ae..d141c98 100755
--- a/compile.sh
+++ b/compile.sh
@@ -12,6 +12,27 @@ if [ -z "$ANDROID_NDK" -o -z "$ANDROID_SDK" -o -z "$ANDROID_ABI" ]; then
    echo "ANDROID_ABI should match your ABI: armeabi-v7a, armeabi or ..."
    exit 1
 fi
+# try to detect NDK version
+REL=$(grep -o '^r[0-9]*.*' $ANDROID_NDK/RELEASE.TXT 2>/dev/null|cut -b2-)
+case "$REL" in
+    7|8)
+        # NDK > v7, only gcc 4.4.3 available
+        GCCVER=4.4.3
+        CXXSTL=""
+    ;;
+    8?)
+        # NDK >= v8b, both 4.4.3 and 4.6 available, we use 4.6
+        GCCVER=4.6
+        CXXSTL="/4.6"
+    ;;
+    *)
+        echo "You need the NDKv7 or later"
+        exit 1
+    ;;
+esac
+
+export GCCVER
+export CXXSTL
 
 # XXX : important!
 cat << EOF
@@ -24,12 +45,6 @@ $ export NO_ARMV6=1
 
 If you plan to use a release build, run 'compile.sh release'
 EOF
-# try to detect NDK version
-REL=$(grep -o '^r[0-9]*' $ANDROID_NDK/RELEASE.TXT 2>/dev/null|cut -b2-)
-if [ -z $REL ]; then
-    echo "You need the NDKv7 or later"
-    exit 1
-fi
 
 # Set up ABI variables
 if [ ${ANDROID_ABI} = "x86" ] ; then
@@ -57,11 +72,10 @@ export PLATFORM_SHORT_ARCH
 
 # Add the NDK toolchain to the PATH, needed both for contribs and for building
 # stub libraries
-export PATH=${ANDROID_NDK}/toolchains/${PATH_HOST}-4.4.3/prebuilt/darwin-x86/bin:${PATH}
-export PATH=${ANDROID_NDK}/toolchains/${PATH_HOST}-4.4.3/prebuilt/linux-x86/bin:${PATH}
+export PATH=${ANDROID_NDK}/toolchains/${PATH_HOST}-${GCCVER}/prebuilt/`uname|tr A-Z a-z`-x86/bin:${PATH}
 
 # 1/ libvlc, libvlccore and its plugins
-TESTED_HASH=57cace3
+TESTED_HASH=17fbcd4ed8
 if [ ! -d "vlc" ]; then
     echo "VLC source not found, cloning"
     git clone git://git.videolan.org/vlc.git vlc
@@ -147,6 +161,10 @@ else
     exit 2
 fi
 
+EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/include"
+EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/libs/${ANDROID_ABI}/include"
+
+
 # Release or not?
 if [ $# -ne 0 ] && [ "$1" == "release" ]; then
     OPTS=""
@@ -189,4 +207,4 @@ export ANDROID_LIBS=${PWD}/android-libs
 export VLC_BUILD_DIR=vlc/android
 
 make distclean
-make TARGET_TUPLE=$TARGET_TUPLE PLATFORM_SHORT_ARCH=$PLATFORM_SHORT_ARCH $RELEASEFLAG
+make TARGET_TUPLE=$TARGET_TUPLE PLATFORM_SHORT_ARCH=$PLATFORM_SHORT_ARCH CXXSTL=$CXXSTL $RELEASEFLAG
diff --git a/configure.sh b/configure.sh
index 71e39b4..241ac59 100755
--- a/configure.sh
+++ b/configure.sh
@@ -32,11 +32,11 @@ if [ -n "$HAVE_ARM" ]; then
     fi
 fi
 
-CPPFLAGS="-I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/include -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_ABI}/include"
-LDFLAGS="$LDFLAGS -L${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_ABI}"
+CPPFLAGS="-I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/include -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/libs/${ANDROID_ABI}/include"
+LDFLAGS="$LDFLAGS -L${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/libs/${ANDROID_ABI}"
 
 SYSROOT=$ANDROID_NDK/platforms/$ANDROID_API/arch-$PLATFORM_SHORT_ARCH
-ANDROID_BIN=$ANDROID_NDK/toolchains/${PATH_HOST}-4.4.3/prebuilt/*-x86/bin/
+ANDROID_BIN=$ANDROID_NDK/toolchains/${PATH_HOST}-${GCCVER}/prebuilt/`uname|tr A-Z a-z`-x86/bin/
 CROSS_COMPILE=${ANDROID_BIN}/${TARGET_TUPLE}-
 
 CPPFLAGS="$CPPFLAGS" \
diff --git a/vlc-android/jni/Android.mk b/vlc-android/jni/Android.mk
index ca3b56e..81a9116 100644
--- a/vlc-android/jni/Android.mk
+++ b/vlc-android/jni/Android.mk
@@ -9,7 +9,7 @@ LOCAL_C_INCLUDES := $(VLC_SRC_DIR)/include
 
 ARCH=$(ANDROID_ABI)
 
-CPP_STATIC=$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/libs/$(ARCH)/libgnustl_static.a
+CPP_STATIC=$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++$(CXXSTL)/libs/$(ARCH)/libgnustl_static.a
 
 LOCAL_CFLAGS := -std=gnu99
 ifeq ($(ARCH), armeabi)



More information about the Android mailing list