Search
lxdream.org :: lxdream/m4/android.m4
lxdream 0.9.1
released Jun 29
Download Now
filename m4/android.m4
changeset 1239:be3121267597
next1245:01e0020adf88
author nkeynes
date Sat Feb 25 21:30:49 2012 +1000 (7 years ago)
permissions -rw-r--r--
last change Android support WIP
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-8"] )
    11    if test "x$with_android" != "x"; then
    12       if test "$with_android" = "yes"; then
    13          AC_MSG_ERROR( [--with-android option must be given with the path to the Android SDK] )
    14       fi
    15       if test "x$with_android_ndk" = "x" -o "x$with_android_ndk" = "xyes"; then
    16          AC_MSG_ERROR( [--with-android-ndk=/path/to/ndk option must be used with --with-android] )
    17       fi
    19       ANDROID_SDK_HOME="$with_android"
    20       ANDROID_NDK_HOME="$with_android_ndk"
    21       ANDROID_SDK_VERSION="$with_android_version"
    23       AC_CHECK_FILE( [$ANDROID_SDK_HOME/tools/ant/pre_setup.xml], [], [ AC_MSG_ERROR([Android SDK not found in $ANDROID_SDK_HOME]) ])
    24       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]) ])
    25       AC_CHECK_FILE( [$ANDROID_NDK_HOME/toolchains], [], [ AC_MSG_ERROR([Android NDK not found in $ANDROID_NDK_HOME]) ])
    27       case $host_alias in
    28          arm-* | "") 
    29             host_alias="arm-linux-androideabi"
    30             host_cpu="arm"
    31             host_vendor="unknown";
    32             host_os="linux-androideabi"
    33             ANDROID_NDK_BIN=`echo $ANDROID_NDK_HOME/toolchains/arm-*/prebuilt/*/bin`
    34             ANDROID_GDBSERVER=`echo $ANDROID_NDK_HOME/toolchains/arm-*/prebuilt/gdbserver`
    35             ANDROID_SYSROOT="$ANDROID_NDK_HOME/platforms/$ANDROID_SDK_VERSION/arch-arm"
    36             TARGETFLAGS="-ffunction-sections -funwind-tables -fstack-protector -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wno-psabi -Wa,--noexecstack"
    37             TARGETFLAGS="$TARGETFLAGS -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -march=armv5te -mtune=xscale -msoft-float -mthumb -Os"
    38             ;;
    39          i686-*)
    40             host_alias="i686-android-linux"
    41             host_cpu="i686"
    42             host_vendor="android"
    43             host_os="linux"
    44             ANDROID_NDK_BIN=`echo $ANDROID_NDK_HOME/toolchains/x86-*/prebuilt/*/bin`
    45             ANDROID_GDBSERVER=`echo $ANDROID_NDK_HOME/toolchains/x86-*/prebuilt/gdbserver`
    46             ANDROID_SYSROOT="$ANDROID_NDK_HOME/platforms/$ANDROID_SDK_VERSION/arch-x86"
    47             TARGETFLAGS=""
    48             ;;
    49          *)
    50             AC_MSG_ERROR([Unsupported android host $host_alias])
    51       	    ;;
    52       esac
    54       AC_PATH_PROG( ANT, [ant] )
    56       CC="$ANDROID_NDK_BIN/${host_alias}-gcc"
    57       CXX="$ANDROID_NDK_BIN/${host_alias}-g++"
    58       CPP="$ANDROID_NDK_BIN/${host_alias}-cpp"
    59       LD="$ANDROID_NDK_BIN/${host_alias}-ld"
    60       AR="$ANDROID_NDK_BIN/${host_alias}-ar"
    61       RANLIB="$ANDROID_NDK_BIN/${host_alias}-ranlib"
    62       STRIP="$ANDROID_NDK_BIN/${host_alias}-strip"
    63       OBJDUMP="$ANDROID_NDK_BIN/${host_alias}-objdump"
    64       CPPFLAGS="-fPIC --sysroot=$ANDROID_SYSROOT -I$ANDROID_SYSROOT/usr/include $TARGETFLAGS $CPPFLAGS"
    65       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"
    66       LIBS="$LIBS -liconv -llog -lgcc -lc"
    68       AC_SUBST(ANDROID_SDK_HOME)
    69       AC_SUBST(ANDROID_NDK_HOME)
    70       AC_SUBST(ANDROID_SDK_VERSION)
    71       AC_SUBST(ANDROID_GDBSERVER)
    73       ANDROID_BUILD=yes
    74       cross_compiling=yes
    75    fi
    77    AM_CONDITIONAL(GUI_ANDROID, [test "$ANDROID_BUILD" = "yes"])
    79 ])
.