[Android] [PATCH 1/3] Support compiling on Android-x86

Edward Wang edward.c.wang at compdigitec.com
Wed Jul 25 04:50:09 CEST 2012


This also softens the ground for the upcoming MIPS port too.
---
 compile.sh        |    9 +++++++--
 configure.sh      |   37 +++++++++++++++++++++++--------------
 setup-abi-vars.sh |   19 +++++++++++++++++++
 3 files changed, 49 insertions(+), 16 deletions(-)
 create mode 100755 setup-abi-vars.sh

diff --git a/compile.sh b/compile.sh
index d03a9b9..1b686bf 100755
--- a/compile.sh
+++ b/compile.sh
@@ -31,9 +31,12 @@ if [ -z $REL ]; then
     exit 1
 fi
 
+# Set up ABI variables (TARGET_TUPLE, PATH_HOST)
+source ./setup-abi-vars.sh
+
 # Add the NDK toolchain to the PATH, needed both for contribs and for building
 # stub libraries
-export PATH=${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:${PATH}
+export PATH=${ANDROID_NDK}/toolchains/${PATH_HOST}-4.4.3/prebuilt/linux-x86/bin:${PATH}
 
 # 1/ libvlc, libvlccore and its plugins
 TESTED_HASH=57cace3
@@ -76,7 +79,7 @@ fi
 echo "Building the contribs"
 mkdir -p contrib/android
 cd contrib/android
-../bootstrap --host=arm-linux-androideabi --disable-disc --disable-sout --enable-small \
+../bootstrap --host=${TARGET_TUPLE} --disable-disc --disable-sout --enable-small \
     --disable-sdl \
     --disable-SDL_image \
     --disable-fontconfig \
@@ -115,6 +118,8 @@ elif [ ${ANDROID_ABI} = "armeabi" ] ; then
             EXTRA_CFLAGS="-mfpu=vfp -mcpu=arm1136jf-s -mfloat-abi=softfp"
         fi
     fi
+elif [ ${ANDROID_ABI} = "x86" ] ; then
+    EXTRA_CFLAGS="-march=pentium -ffunction-sections -funwind-tables"
 else
     echo "Unknown ABI. Die, die, die!"
     exit 2
diff --git a/configure.sh b/configure.sh
index 788631b..65a2c5e 100755
--- a/configure.sh
+++ b/configure.sh
@@ -6,32 +6,41 @@ if [ -z "$ANDROID_NDK" -o -z "$ANDROID_ABI" ]; then
     exit 1
 fi
 
+# Set up ABI variables (TARGET_TUPLE, PATH_HOST, HAVE_*)
+source $(dirname $0)/setup-abi-vars.sh
+
 # Must use android-9 here. Any replacement functions needed are in the vlc-android/jni
 # folder.
 ANDROID_API=android-9
 
 VLC_SOURCEDIR=..
 
-CFLAGS="-g -O2 -mlong-calls -fstrict-aliasing -funsafe-math-optimizations"
+CFLAGS="-g -O2 -fstrict-aliasing -funsafe-math-optimizations"
+if [ -n "$HAVE_ARM" ]; then
+    CFLAGS="${CFLAGS} -mlong-calls"
+fi
+
 LDFLAGS="-Wl,-Bdynamic,-dynamic-linker=/system/bin/linker -Wl,--no-undefined"
 
-if [ -z "$NO_NEON" ]; then
-    NO_NEON=0
-fi
+if [ -n "$HAVE_ARM" ]; then
+    if [ -z "$NO_NEON" ]; then
+        NO_NEON=0
+    fi
 
-if [ $NO_NEON -gt 0 ]; then
-    EXTRA_PARAMS=" --disable-neon"
-else
-    EXTRA_PARAMS=" --enable-neon"
-    LDFLAGS="$LDFLAGS -Wl,--fix-cortex-a8"
+    if [ $NO_NEON -gt 0 ]; then
+        EXTRA_PARAMS=" --disable-neon"
+    else
+        EXTRA_PARAMS=" --enable-neon"
+        LDFLAGS="$LDFLAGS -Wl,--fix-cortex-a8"
+    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}"
 
-SYSROOT=$ANDROID_NDK/platforms/$ANDROID_API/arch-arm
-ANDROID_BIN=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/*-x86/bin/
-CROSS_COMPILE=${ANDROID_BIN}/arm-linux-androideabi-
+SYSROOT=$ANDROID_NDK/platforms/$ANDROID_API/arch-$PLATFORM_SHORT_ARCH
+ANDROID_BIN=$ANDROID_NDK/toolchains/${PATH_HOST}-4.4.3/prebuilt/linux-x86/bin/
+CROSS_COMPILE=${ANDROID_BIN}/${TARGET_TUPLE}-
 
 CPPFLAGS="$CPPFLAGS" \
 CFLAGS="$CFLAGS ${VLC_EXTRA_CFLAGS}" \
@@ -43,7 +52,7 @@ NM="${CROSS_COMPILE}nm" \
 STRIP="${CROSS_COMPILE}strip" \
 RANLIB="${CROSS_COMPILE}ranlib" \
 AR="${CROSS_COMPILE}ar" \
-sh $VLC_SOURCEDIR/configure --host=arm-linux-androideabi --build=x86_64-unknown-linux $EXTRA_PARAMS \
+sh $VLC_SOURCEDIR/configure --host=$TARGET_TUPLE --build=x86_64-unknown-linux $EXTRA_PARAMS \
                 --enable-live555 --enable-realrtsp \
                 --enable-avformat \
                 --enable-swscale \
diff --git a/setup-abi-vars.sh b/setup-abi-vars.sh
new file mode 100755
index 0000000..41cf51e
--- /dev/null
+++ b/setup-abi-vars.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Set up architecture specific variables
+if [ ${ANDROID_ABI} = "x86" ] ; then
+    TARGET_TUPLE="i686-android-linux"
+    PATH_HOST="x86"
+    HAVE_X86=1
+    PLATFORM_SHORT_ARCH="x86"
+elif [ ${ANDROID_ABI} = "mips" ] ; then
+    TARGET_TUPLE="mipsel-linux-android"
+    PATH_HOST=$TARGET_TUPLE
+    HAVE_MIPS=1
+    PLATFORM_SHORT_ARCH="mips"
+else
+    TARGET_TUPLE="arm-linux-androideabi"
+    PATH_HOST=$TARGET_TUPLE
+    HAVE_ARM=1
+    PLATFORM_SHORT_ARCH="arm"
+fi
-- 
1.7.5.4



More information about the Android mailing list