filename | m4/android.m4 |
changeset | 1255:d63f73cc586f |
prev | 1245:01e0020adf88 |
author | nkeynes |
date | Wed Mar 21 14:45:27 2012 +1000 (12 years ago) |
permissions | -rw-r--r-- |
last change | Make sure we destroy the render buffers as part of the GL shutdown (fixes bug with render buffers not being recreated when we re-init the GL). |
view | annotate | diff | log | raw |
1 # LX_ANDROID_BUILD
2 # Defines --with-android, --with-android-ndk, and --with-android-version
3 # If specified, checks for a working install, and sets build parameters
4 # appropriately for an Android host.
5 AC_DEFUN([LX_ANDROID_BUILD], [
6 AC_REQUIRE([AC_CANONICAL_HOST])
7 AC_ARG_WITH( android, AS_HELP_STRING( [--with-android=SDK], [Specify the location of the Android SDK] ) )
8 AC_ARG_WITH( android-ndk, AS_HELP_STRING( [--with-android-ndk=NDK], [Specify the location of the Android NDK] ) )
9 AC_ARG_WITH( android-version, AS_HELP_STRING( [--with-android-version], [Specify target Android SDK version]), [], [with_android_version="android-11"] )
10 AC_ARG_WITH( android-ndk-version, AS_HELP_STRING( [--with-android-version], [Specify target Android NDK version]), [], [with_ndk_version="android-9"] )
11 AC_ARG_WITH( android-abi, AS_HELP_STRING( [--with-android-abi], [Specify target Android ABI]), [], [ANDROID_ABI="armeabi-v7a"] )
13 if test "x$with_android" != "x"; then
14 if test "$with_android" = "yes"; then
15 AC_MSG_ERROR( [--with-android option must be given with the path to the Android SDK] )
16 fi
17 if test "x$with_android_ndk" = "x" -o "x$with_android_ndk" = "xyes"; then
18 AC_MSG_ERROR( [--with-android-ndk=/path/to/ndk option must be used with --with-android] )
19 fi
21 ANDROID_SDK_HOME="$with_android"
22 ANDROID_NDK_HOME="$with_android_ndk"
23 ANDROID_SDK_VERSION="$with_android_version"
24 ANDROID_NDK_VERSION="$with_ndk_version"
26 AC_CHECK_FILE( [$ANDROID_SDK_HOME/tools/ant/pre_setup.xml], [], [ AC_MSG_ERROR([Android SDK not found in $ANDROID_SDK_HOME]) ])
27 AC_CHECK_FILE( [$ANDROID_SDK_HOME/platforms/$ANDROID_SDK_VERSION/sdk.properties], [], [ AC_MSG_ERROR([Android platform version $ANDROID_SDK_VERSION not found in $ANDROID_SDK_HOME]) ])
28 AC_CHECK_FILE( [$ANDROID_NDK_HOME/toolchains], [], [ AC_MSG_ERROR([Android NDK not found in $ANDROID_NDK_HOME]) ])
30 dnl common flags
31 TARGETFLAGS="-ffunction-sections -funwind-tables -fomit-frame-pointer -DANDROID -Wa,--noexecstack"
33 case $ANDROID_ABI in
34 armeabi | armeabi-v7a)
35 host_alias="arm-linux-androideabi"
36 host_cpu="arm"
37 host_vendor="unknown";
38 host_os="linux-androideabi"
39 ANDROID_NDK_BIN=`echo $ANDROID_NDK_HOME/toolchains/arm-*/prebuilt/*/bin`
40 ANDROID_GDBSERVER=`echo $ANDROID_NDK_HOME/toolchains/arm-*/prebuilt/gdbserver`
41 ANDROID_SYSROOT="$ANDROID_NDK_HOME/platforms/$ANDROID_NDK_VERSION/arch-arm"
42 dnl Common ARM flags
43 TARGETFLAGS="$TARGETFLAGS -fstack-protector -finline-limit=64 -fno-strict-aliasing -Wno-psabi -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__"
44 if test "x$with_abi" = "armeabi"; then
45 TARGETFLAGS="$TARGETFLAGS -march=armv5te -mtune=xscale -msoft-float"
46 else
47 TARGETFLAGS="$TARGETFLAGS -march=armv7-a -mtune=cortex-a8 -mfloat-abi=softfp -mfpu=vfp"
48 fi
49 ;;
50 x86)
51 host_alias="i686-android-linux"
52 host_cpu="i686"
53 host_vendor="android"
54 host_os="linux"
55 ANDROID_NDK_BIN=`echo $ANDROID_NDK_HOME/toolchains/x86-*/prebuilt/*/bin`
56 ANDROID_GDBSERVER=`echo $ANDROID_NDK_HOME/toolchains/x86-*/prebuilt/gdbserver`
57 ANDROID_SYSROOT="$ANDROID_NDK_HOME/platforms/$ANDROID_NDK_VERSION/arch-x86"
58 TARGETFLAGS="$TARGETFLAGS -finline-limit=300 -fno-rtti -funswitch-loops -fstrict-aliasing"
59 ;;
60 *)
61 AC_MSG_ERROR([Unsupported android ABI $ANDROID_ABI])
62 ;;
63 esac
65 AC_PATH_PROG( ANT, [ant] )
67 CC="$ANDROID_NDK_BIN/${host_alias}-gcc"
68 CXX="$ANDROID_NDK_BIN/${host_alias}-g++"
69 CPP="$ANDROID_NDK_BIN/${host_alias}-cpp"
70 LD="$ANDROID_NDK_BIN/${host_alias}-ld"
71 AR="$ANDROID_NDK_BIN/${host_alias}-ar"
72 RANLIB="$ANDROID_NDK_BIN/${host_alias}-ranlib"
73 STRIP="$ANDROID_NDK_BIN/${host_alias}-strip"
74 OBJDUMP="$ANDROID_NDK_BIN/${host_alias}-objdump"
75 CPPFLAGS="-fPIC --sysroot=$ANDROID_SYSROOT -I$ANDROID_SYSROOT/usr/include $TARGETFLAGS $CPPFLAGS"
76 LDFLAGS="-nostdlib -Wl,--no-undefined -L${ANDROID_SYSROOT}/usr/lib -Wl,-rpath-link,${ANDROID_SYSROOT}/usr/lib -Wl,-allow-shlib-undefined -Wl,-z,noexecstack $LDFLAGS"
77 LIBS="$LIBS -liconv -landroid -llog -lgcc -lc -lm"
79 AC_SUBST(ANDROID_ABI)
80 AC_SUBST(ANDROID_SDK_HOME)
81 AC_SUBST(ANDROID_NDK_HOME)
82 AC_SUBST(ANDROID_SDK_VERSION)
83 AC_SUBST(ANDROID_NDK_VERSION)
84 AC_SUBST(ANDROID_GDBSERVER)
86 ANDROID_BUILD=yes
87 cross_compiling=yes
88 fi
90 AM_CONDITIONAL(GUI_ANDROID, [test "$ANDROID_BUILD" = "yes"])
92 ])
.