Search
lxdream.org :: lxdream/m4/android.m4
lxdream 0.9.1
released Jun 29
Download Now
filename m4/android.m4
changeset 1245:01e0020adf88
prev1239:be3121267597
next1255:d63f73cc586f
author nkeynes
date Fri Mar 02 23:49:10 2012 +1000 (9 years ago)
permissions -rw-r--r--
last change Android WIP:
* Rename gui_jni.c to gui_android.c - now quite android specific.
* Implement generic EGL driver with very minimal Java wrapper
* Run emulation in separate thread, and implement simple queue for
inter-thread communication.
* Add menu/action-bar items for start + reset
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"] )
    12    if test "x$with_android" != "x"; then
    13       if test "$with_android" = "yes"; then
    14          AC_MSG_ERROR( [--with-android option must be given with the path to the Android SDK] )
    15       fi
    16       if test "x$with_android_ndk" = "x" -o "x$with_android_ndk" = "xyes"; then
    17          AC_MSG_ERROR( [--with-android-ndk=/path/to/ndk option must be used with --with-android] )
    18       fi
    20       ANDROID_SDK_HOME="$with_android"
    21       ANDROID_NDK_HOME="$with_android_ndk"
    22       ANDROID_SDK_VERSION="$with_android_version"
    23       ANDROID_NDK_VERSION="$with_ndk_version"
    25       AC_CHECK_FILE( [$ANDROID_SDK_HOME/tools/ant/pre_setup.xml], [], [ AC_MSG_ERROR([Android SDK not found in $ANDROID_SDK_HOME]) ])
    26       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]) ])
    27       AC_CHECK_FILE( [$ANDROID_NDK_HOME/toolchains], [], [ AC_MSG_ERROR([Android NDK not found in $ANDROID_NDK_HOME]) ])
    29       case $host_alias in
    30          arm-* | "") 
    31             host_alias="arm-linux-androideabi"
    32             host_cpu="arm"
    33             host_vendor="unknown";
    34             host_os="linux-androideabi"
    35             ANDROID_NDK_BIN=`echo $ANDROID_NDK_HOME/toolchains/arm-*/prebuilt/*/bin`
    36             ANDROID_GDBSERVER=`echo $ANDROID_NDK_HOME/toolchains/arm-*/prebuilt/gdbserver`
    37             ANDROID_SYSROOT="$ANDROID_NDK_HOME/platforms/$ANDROID_NDK_VERSION/arch-arm"
    38             TARGETFLAGS="-ffunction-sections -funwind-tables -fstack-protector -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wno-psabi -Wa,--noexecstack"
    39             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"
    40             ;;
    41          i686-*)
    42             host_alias="i686-android-linux"
    43             host_cpu="i686"
    44             host_vendor="android"
    45             host_os="linux"
    46             ANDROID_NDK_BIN=`echo $ANDROID_NDK_HOME/toolchains/x86-*/prebuilt/*/bin`
    47             ANDROID_GDBSERVER=`echo $ANDROID_NDK_HOME/toolchains/x86-*/prebuilt/gdbserver`
    48             ANDROID_SYSROOT="$ANDROID_NDK_HOME/platforms/$ANDROID_NDK_VERSION/arch-x86"
    49             TARGETFLAGS=""
    50             ;;
    51          *)
    52             AC_MSG_ERROR([Unsupported android host $host_alias])
    53       	    ;;
    54       esac
    56       AC_PATH_PROG( ANT, [ant] )
    58       CC="$ANDROID_NDK_BIN/${host_alias}-gcc"
    59       CXX="$ANDROID_NDK_BIN/${host_alias}-g++"
    60       CPP="$ANDROID_NDK_BIN/${host_alias}-cpp"
    61       LD="$ANDROID_NDK_BIN/${host_alias}-ld"
    62       AR="$ANDROID_NDK_BIN/${host_alias}-ar"
    63       RANLIB="$ANDROID_NDK_BIN/${host_alias}-ranlib"
    64       STRIP="$ANDROID_NDK_BIN/${host_alias}-strip"
    65       OBJDUMP="$ANDROID_NDK_BIN/${host_alias}-objdump"
    66       CPPFLAGS="-fPIC --sysroot=$ANDROID_SYSROOT -I$ANDROID_SYSROOT/usr/include $TARGETFLAGS $CPPFLAGS"
    67       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"
    68       LIBS="$LIBS -liconv -landroid -llog -lgcc -lc -lm"
    70       AC_SUBST(ANDROID_SDK_HOME)
    71       AC_SUBST(ANDROID_NDK_HOME)
    72       AC_SUBST(ANDROID_SDK_VERSION)
    73       AC_SUBST(ANDROID_NDK_VERSION)
    74       AC_SUBST(ANDROID_GDBSERVER)
    76       ANDROID_BUILD=yes
    77       cross_compiling=yes
    78    fi
    80    AM_CONDITIONAL(GUI_ANDROID, [test "$ANDROID_BUILD" = "yes"])
    82 ])
.