Changeset 4202 for pjproject


Ignore:
Timestamp:
Jul 9, 2012 9:02:13 AM (12 years ago)
Author:
ming
Message:

Re #1516: Add automatic Android API level detection and option to use ndk-build compilation flags

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/android/configure-android

    r4195 r4202  
    55 
    66if test "$*" = "--help" -o "$*" = "-h"; then 
    7   echo "$F [OPTIONS]" 
     7  echo "$F [--use-ndk-cflags] [OPTIONS]" 
    88  echo "" 
    99  echo "where:" 
    10   echo "  --simulator Optional parameter to specify that the compilation" 
    11   echo "              target is a simulator." 
     10  echo "  --use-ndk-cflags" 
     11  echo "              Optional parameter to use the same compilation flags" 
     12  echo "              as the one used by ndk-build" 
    1213  echo "  OPTIONS     Other options that will be passed directly to" 
    1314  echo "              ./aconfigure script. Run ./aconfigure --help" 
     
    1617fi 
    1718 
    18 if test "$1" = "--simulator"; then 
     19if test "x${ANDROID_NDK}" = "x"; then 
     20  echo "$F error: ANDROID_NDK must be specified" 
     21  exit 0 
     22fi 
     23 
     24#if test "$1" = "--simulator"; then 
     25if test "1" = "0"; then 
    1926  shift 
    2027  TARGET_HOST="i686-android-linux" 
     
    2330  TARGET_HOST="arm-linux-androideabi" 
    2431  TC_DIR=${TARGET_HOST} 
     32fi 
     33 
     34if test "$1" = "--use-ndk-cflags"; then 
     35  shift 
     36  for i in `${ANDROID_NDK}/ndk-build --dry-run --directory=${ANDROID_NDK}/samples/hello-jni`; do 
     37    if test "$i" = "-c"; then break; fi 
     38    if test "x${NDK_CC}" != "x" -a "$i" != "-MF" -a "x`echo $i|grep '\.o\.d'`" = "x" -a "x`echo $i|grep 'include'`" = "x"; then 
     39      NDK_CFLAGS="${NDK_CFLAGS} $i" 
     40    fi 
     41    if test "x`echo $i | grep 'gcc'`" != "x"; then 
     42      NDK_CC=$i 
     43    fi 
     44  done 
     45  export CFLAGS+="${NDK_CFLAGS}" 
    2546fi 
    2647 
     
    3253esac 
    3354 
    34 API_VERSION="14" 
     55if test "x$API_LEVEL" = "x"; then 
     56  API_LEVEL=`ls ${ANDROID_NDK}/platforms/ | sed 's/android-//' | sort -gr | head -1` 
     57  echo "$F: API_LEVEL not specified, using android-${API_LEVEL}" 
     58fi 
    3559 
    3660ANDROID_TC="${ANDROID_NDK}/toolchains/${TC_DIR}-4.4.3/prebuilt/${BUILD_MACHINE}" 
     61if test ! -d ${ANDROID_TC}; then 
     62  echo "$F error: unable to find directory ${ANDROID_TC} in Android NDK" 
     63  exit 1 
     64fi 
    3765 
    38 export ANDROID_SYSROOT="${ANDROID_NDK}/platforms/android-${API_VERSION}/arch-arm" 
     66export ANDROID_SYSROOT="${ANDROID_NDK}/platforms/android-${API_LEVEL}/arch-arm" 
     67if test ! -d ${ANDROID_SYSROOT}; then 
     68  echo "$F error: unable to find sysroot dir ${ANDROID_SYSROOT} in Android NDK" 
     69  exit 1 
     70fi 
     71 
    3972export CC="${ANDROID_TC}/bin/${TARGET_HOST}-gcc" 
    4073export CXX="${ANDROID_TC}/bin/${TARGET_HOST}-g++" 
     74 
    4175export LDFLAGS+=" -nostdlib -L${ANDROID_SYSROOT}/usr/lib/" 
    4276export LIBS+=" -lc -lgcc" 
     
    4579export CXXFLAGS+=" -shared --sysroot=${ANDROID_SYSROOT}" 
    4680 
     81# Print settings 
     82if test "1" = "1"; then 
     83  echo "$F: calling ./configure with env vars:" 
     84  echo " CC = ${CC}" 
     85  echo " CXX = ${CXX}" 
     86  echo " CFLAGS = ${CFLAGS}" 
     87  echo " CXXFLAGS = ${CXXFLAGS}" 
     88  echo " LDFLAGS = ${LDFLAGS}" 
     89  echo " LIBS = ${LIBS}" 
     90fi 
     91 
    4792./configure --host=${TARGET_HOST} --disable-video $* 
Note: See TracChangeset for help on using the changeset viewer.