Changeset 4594 for pjproject


Ignore:
Timestamp:
Sep 9, 2013 5:53:58 AM (11 years ago)
Author:
ming
Message:

Re #1516: Add support to build for other targets. Example:
TARGET_ABI=armeabi-v7a ./configure-android --use-ndk-cflags

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/configure-android

    r4435 r4594  
    1717  echo "  ANDROID_NDK_ROOT Specify the directory of Android NDK to use." 
    1818  echo "  APP_PLATFORM     Optionally specify the platform level used, e.g." 
    19   echo "                   android-8. By default, configure will use the maximum" 
    20   echo "                   platform level detected." 
    21   echo "  TARGET_ABI       Optionally specify a single target architecture, e.g." 
    22   echo "                   armeabi-v7a. By default, the target architecture is" 
    23   echo "                   armeabi." 
     19  echo "                   android-9. By default, configure will use the" 
     20  echo "                   maximum platform level detected." 
     21  echo "  TARGET_ABI       Optionally specify a single target architecture," 
     22  echo "                   e.g. armeabi-v7a, mips, x86. By default, the target" 
     23  echo "                   architecture is armeabi. Only used when" 
     24  echo "                   --use-ndk-cflags is specified." 
    2425  echo "" 
    2526  exit 0 
     
    5455if test "$1" = "--use-ndk-cflags"; then 
    5556  shift 
     57  ADD_CFLAGS="1" 
    5658  for i in `${ANDROID_NDK_ROOT}/ndk-build -n -C ${ANDROID_NDK_ROOT}/samples/hello-jni NDK_LOG=1 APP_PLATFORM=${APP_PLATFORM} APP_ABI=${TARGET_ABI}`; do 
    57     if test "$i" = "-c"; then break; fi 
    58     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 
    59       NDK_CFLAGS="${NDK_CFLAGS} $i" 
     59    if test "x${NDK_CXX}" != "x" -a "$i" = "-o"; then break; fi 
     60 
     61    # Parse NDK CXXFLAGS 
     62    if test "x${NDK_CXX}" != "x" -a "x`echo $i|grep 'hello-jni'`" = "x"; then 
     63      if test "x`echo $i|grep '\-\-sysroot='`" != "x"; then 
     64        ANDROID_SYSROOT=`echo $i|sed 's/--sysroot=//'`; 
     65      fi 
     66      NDK_CXXFLAGS="${NDK_CXXFLAGS} $i" 
    6067    fi 
    61     if test "x`echo $i | grep 'gcc'`" != "x"; then 
     68 
     69    # Parse NDK CFLAGS 
     70    if test "x${NDK_CC}" != "x" -a "x`echo $i|grep 'hello-jni'`" = "x" -a "x`echo $i|grep '\-M'`" = "x" -a "${ADD_CFLAGS}" = "1"; then 
     71      if test "$i" = "-c"; then ADD_CFLAGS="0"; else 
     72        NDK_CFLAGS="${NDK_CFLAGS} $i" 
     73      fi 
     74    fi 
     75 
     76    # Find gcc toolchain 
     77    if test "x${NDK_CC}" = "x" -a "x`echo $i | grep 'gcc'`" != "x"; then 
    6278      NDK_CC=$i 
    6379    fi 
     80    # Find g++ toolchain 
     81    if test "x`echo $i | grep 'g++'`" != "x"; then 
     82      NDK_CXX=$i 
     83    fi 
    6484  done 
     85 
     86  export CC="${NDK_CC}" 
     87  export CXX="${NDK_CXX}" 
     88 
     89  export LDFLAGS="${LDFLAGS} -nostdlib -L${ANDROID_SYSROOT}/usr/lib/" 
     90  export LIBS="${LIBS} -lc -lgcc" 
    6591  export CFLAGS="${CFLAGS} ${NDK_CFLAGS}" 
     92  export CPPFLAGS="${CFLAGS}" 
     93  export CXXFLAGS="${NDK_CXXFLAGS}" 
     94 
     95else 
     96 
     97  ANDROID_TC_VER=`ls -d ${ANDROID_NDK_ROOT}/toolchains/${TC_DIR}-* | sed 's/clang/0/' | sort -gr | head -1` 
     98  ANDROID_TC=`ls -d ${ANDROID_TC_VER}/prebuilt/*` 
     99  if test ! -d ${ANDROID_TC}; then 
     100    echo "$F error: unable to find directory ${ANDROID_TC} in Android NDK" 
     101    exit 1 
     102  fi 
     103 
     104  export ANDROID_SYSROOT="${ANDROID_NDK_ROOT}/platforms/${APP_PLATFORM}/arch-arm" 
     105  if test ! -d ${ANDROID_SYSROOT}; then 
     106    echo "$F error: unable to find sysroot dir ${ANDROID_SYSROOT} in Android NDK" 
     107    exit 1 
     108  fi 
     109 
     110  export CC="${ANDROID_TC}/bin/${TARGET_HOST}-gcc" 
     111  export CXX="${ANDROID_TC}/bin/${TARGET_HOST}-g++" 
     112 
     113  export LDFLAGS="${LDFLAGS} -nostdlib -L${ANDROID_SYSROOT}/usr/lib/" 
     114  export LIBS="${LIBS} -lc -lgcc" 
     115  export CFLAGS="${CFLAGS} -I${ANDROID_SYSROOT}/usr/include" 
     116  export CPPFLAGS="${CFLAGS}" 
     117  export CXXFLAGS="${CXXFLAGS} -shared --sysroot=${ANDROID_SYSROOT}" 
     118 
    66119fi 
    67  
    68 HOST_OS=$(uname -s) 
    69 case $HOST_OS in 
    70   Darwin) BUILD_MACHINE="darwin-x86";; 
    71   Linux) BUILD_MACHINE="linux-x86";; 
    72   CYGWIN*|*_NT-*) BUILD_MACHINE="windows";; 
    73 esac 
    74  
    75 ANDROID_TC="${ANDROID_NDK_ROOT}/toolchains/${TC_DIR}-4.4.3/prebuilt/${BUILD_MACHINE}" 
    76 if test ! -d ${ANDROID_TC}; then 
    77   echo "$F error: unable to find directory ${ANDROID_TC} in Android NDK" 
    78   exit 1 
    79 fi 
    80  
    81 export ANDROID_SYSROOT="${ANDROID_NDK_ROOT}/platforms/${APP_PLATFORM}/arch-arm" 
    82 if test ! -d ${ANDROID_SYSROOT}; then 
    83   echo "$F error: unable to find sysroot dir ${ANDROID_SYSROOT} in Android NDK" 
    84   exit 1 
    85 fi 
    86  
    87 export CC="${ANDROID_TC}/bin/${TARGET_HOST}-gcc" 
    88 export CXX="${ANDROID_TC}/bin/${TARGET_HOST}-g++" 
    89  
    90 export LDFLAGS="${LDFLAGS} -nostdlib -L${ANDROID_SYSROOT}/usr/lib/" 
    91 export LIBS="${LIBS} -lc -lgcc" 
    92 export CFLAGS="${CFLAGS} -I${ANDROID_SYSROOT}/usr/include" 
    93 export CPPFLAGS="${CFLAGS}" 
    94 export CXXFLAGS="${CXXFLAGS} -shared --sysroot=${ANDROID_SYSROOT}" 
    95120 
    96121# Print settings 
Note: See TracChangeset for help on using the changeset viewer.