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
file annotate diff log raw
nkeynes@1239
     1
# LX_ANDROID_BUILD
nkeynes@1239
     2
# Defines --with-android, --with-android-ndk, and --with-android-version
nkeynes@1239
     3
# If specified, checks for a working install, and sets build parameters
nkeynes@1239
     4
# appropriately for an Android host. 
nkeynes@1239
     5
AC_DEFUN([LX_ANDROID_BUILD], [
nkeynes@1239
     6
   AC_REQUIRE([AC_CANONICAL_HOST])
nkeynes@1239
     7
   AC_ARG_WITH( android, AS_HELP_STRING( [--with-android=SDK], [Specify the location of the Android SDK] ) )
nkeynes@1239
     8
   AC_ARG_WITH( android-ndk, AS_HELP_STRING( [--with-android-ndk=NDK], [Specify the location of the Android NDK] ) )
nkeynes@1245
     9
   AC_ARG_WITH( android-version, AS_HELP_STRING( [--with-android-version], [Specify target Android SDK version]), [], [with_android_version="android-11"] )
nkeynes@1245
    10
   AC_ARG_WITH( android-ndk-version, AS_HELP_STRING( [--with-android-version], [Specify target Android NDK version]), [], [with_ndk_version="android-9"] )
nkeynes@1239
    11
nkeynes@1239
    12
   if test "x$with_android" != "x"; then
nkeynes@1239
    13
      if test "$with_android" = "yes"; then
nkeynes@1239
    14
         AC_MSG_ERROR( [--with-android option must be given with the path to the Android SDK] )
nkeynes@1239
    15
      fi
nkeynes@1239
    16
      if test "x$with_android_ndk" = "x" -o "x$with_android_ndk" = "xyes"; then
nkeynes@1239
    17
         AC_MSG_ERROR( [--with-android-ndk=/path/to/ndk option must be used with --with-android] )
nkeynes@1239
    18
      fi
nkeynes@1239
    19
nkeynes@1239
    20
      ANDROID_SDK_HOME="$with_android"
nkeynes@1239
    21
      ANDROID_NDK_HOME="$with_android_ndk"
nkeynes@1239
    22
      ANDROID_SDK_VERSION="$with_android_version"
nkeynes@1245
    23
      ANDROID_NDK_VERSION="$with_ndk_version"
nkeynes@1239
    24
      
nkeynes@1239
    25
      AC_CHECK_FILE( [$ANDROID_SDK_HOME/tools/ant/pre_setup.xml], [], [ AC_MSG_ERROR([Android SDK not found in $ANDROID_SDK_HOME]) ])
nkeynes@1239
    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]) ])
nkeynes@1239
    27
      AC_CHECK_FILE( [$ANDROID_NDK_HOME/toolchains], [], [ AC_MSG_ERROR([Android NDK not found in $ANDROID_NDK_HOME]) ])
nkeynes@1239
    28
nkeynes@1239
    29
      case $host_alias in
nkeynes@1239
    30
         arm-* | "") 
nkeynes@1239
    31
            host_alias="arm-linux-androideabi"
nkeynes@1239
    32
            host_cpu="arm"
nkeynes@1239
    33
            host_vendor="unknown";
nkeynes@1239
    34
            host_os="linux-androideabi"
nkeynes@1239
    35
            ANDROID_NDK_BIN=`echo $ANDROID_NDK_HOME/toolchains/arm-*/prebuilt/*/bin`
nkeynes@1239
    36
            ANDROID_GDBSERVER=`echo $ANDROID_NDK_HOME/toolchains/arm-*/prebuilt/gdbserver`
nkeynes@1245
    37
            ANDROID_SYSROOT="$ANDROID_NDK_HOME/platforms/$ANDROID_NDK_VERSION/arch-arm"
nkeynes@1239
    38
            TARGETFLAGS="-ffunction-sections -funwind-tables -fstack-protector -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wno-psabi -Wa,--noexecstack"
nkeynes@1239
    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"
nkeynes@1239
    40
            ;;
nkeynes@1239
    41
         i686-*)
nkeynes@1239
    42
            host_alias="i686-android-linux"
nkeynes@1239
    43
            host_cpu="i686"
nkeynes@1239
    44
            host_vendor="android"
nkeynes@1239
    45
            host_os="linux"
nkeynes@1239
    46
            ANDROID_NDK_BIN=`echo $ANDROID_NDK_HOME/toolchains/x86-*/prebuilt/*/bin`
nkeynes@1239
    47
            ANDROID_GDBSERVER=`echo $ANDROID_NDK_HOME/toolchains/x86-*/prebuilt/gdbserver`
nkeynes@1245
    48
            ANDROID_SYSROOT="$ANDROID_NDK_HOME/platforms/$ANDROID_NDK_VERSION/arch-x86"
nkeynes@1239
    49
            TARGETFLAGS=""
nkeynes@1239
    50
            ;;
nkeynes@1239
    51
         *)
nkeynes@1239
    52
            AC_MSG_ERROR([Unsupported android host $host_alias])
nkeynes@1239
    53
      	    ;;
nkeynes@1239
    54
      esac
nkeynes@1239
    55
   
nkeynes@1239
    56
      AC_PATH_PROG( ANT, [ant] )
nkeynes@1239
    57
      
nkeynes@1239
    58
      CC="$ANDROID_NDK_BIN/${host_alias}-gcc"
nkeynes@1239
    59
      CXX="$ANDROID_NDK_BIN/${host_alias}-g++"
nkeynes@1239
    60
      CPP="$ANDROID_NDK_BIN/${host_alias}-cpp"
nkeynes@1239
    61
      LD="$ANDROID_NDK_BIN/${host_alias}-ld"
nkeynes@1239
    62
      AR="$ANDROID_NDK_BIN/${host_alias}-ar"
nkeynes@1239
    63
      RANLIB="$ANDROID_NDK_BIN/${host_alias}-ranlib"
nkeynes@1239
    64
      STRIP="$ANDROID_NDK_BIN/${host_alias}-strip"
nkeynes@1239
    65
      OBJDUMP="$ANDROID_NDK_BIN/${host_alias}-objdump"
nkeynes@1239
    66
      CPPFLAGS="-fPIC --sysroot=$ANDROID_SYSROOT -I$ANDROID_SYSROOT/usr/include $TARGETFLAGS $CPPFLAGS"
nkeynes@1239
    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"
nkeynes@1245
    68
      LIBS="$LIBS -liconv -landroid -llog -lgcc -lc -lm"
nkeynes@1239
    69
      
nkeynes@1239
    70
      AC_SUBST(ANDROID_SDK_HOME)
nkeynes@1239
    71
      AC_SUBST(ANDROID_NDK_HOME)
nkeynes@1239
    72
      AC_SUBST(ANDROID_SDK_VERSION)
nkeynes@1245
    73
      AC_SUBST(ANDROID_NDK_VERSION)
nkeynes@1239
    74
      AC_SUBST(ANDROID_GDBSERVER)
nkeynes@1239
    75
      
nkeynes@1239
    76
      ANDROID_BUILD=yes
nkeynes@1239
    77
      cross_compiling=yes
nkeynes@1239
    78
   fi
nkeynes@1239
    79
   
nkeynes@1239
    80
   AM_CONDITIONAL(GUI_ANDROID, [test "$ANDROID_BUILD" = "yes"])
nkeynes@1239
    81
        
nkeynes@1239
    82
])
.