67 lines
1.5 KiB
Bash
Executable File
67 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# android gcc wrapper
|
|
if [ -n "${NDK_ARCH}" ]; then
|
|
ARCH=${NDK_ARCH}
|
|
else
|
|
ARCH=mips
|
|
ARCH=arm
|
|
ARCH=x86
|
|
fi
|
|
|
|
#------------------------------------------#
|
|
|
|
PROGDIR=`dirname $0`
|
|
PROGDIR=`cd $PROGDIR && pwd`
|
|
|
|
OS=`uname | tr 'A-Z' 'a-z'`
|
|
[ "${OS}" = macos ] && OS=darwin
|
|
|
|
case "${ARCH}" in
|
|
arm)
|
|
ANDROID_SDK_VERSION=8
|
|
NDKPFX=${ARCH}-linux-androideabi
|
|
;;
|
|
mips)
|
|
ANDROID_SDK_VERSION=9 #mips
|
|
NDKPFX=mips-linux-android
|
|
${NDKPFX}-gcc 2>/dev/null
|
|
if [ $? -gt 1 ]; then
|
|
NDKPFX=mipsel-linux-android
|
|
fi
|
|
;;
|
|
x86)
|
|
ANDROID_SDK_VERSION=9 #x86
|
|
NDKPFX=i686-android-linux
|
|
${NDKPFX}-gcc 2>/dev/null
|
|
if [ $? -gt 1 ]; then
|
|
NDKPFX=i686-linux-android
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
|
|
PLATFORM=android-${ANDROID_SDK_VERSION}
|
|
PLATFORM_ROOT=${PROGDIR}/platforms/${PLATFORM}/arch-${ARCH}
|
|
PLATFORM_PATH=${PLATFORM_ROOT}/usr
|
|
TOOLCHAIN=`ls ${PROGDIR}/toolchains/ |grep "^${ARCH}" |sort |tail -n 1`
|
|
NDK_BINS=${PROGDIR}/toolchains/${TOOLCHAIN}/prebuilt/${OS}-x86/bin
|
|
CFLAGS="--sysroot=${PLATFORM_ROOT}"
|
|
CFLAGS="${CFLAGS} -I${PLATFORM_PATH}/include"
|
|
LDFLAGS=-L${PLATFORM_PATH}/lib
|
|
#LDFLAGS="${LDFLAGS} -nostdlib"
|
|
#LDFLAGS="${LDFLAGS} -lc -ldl"
|
|
#LDFLAGS="${LDFLAGS} -Wl,-dynamic-linker=/system/bin/linker"
|
|
|
|
LDFLAGS="${LDFLAGS} --sysroot=${PLATFORM_ROOT}"
|
|
#if [ -z "`echo $@ | grep shared`" ]; then
|
|
#LDFLAGS="${LDFLAGS} ${PLATFORM_PATH}/lib/crtbegin_dynamic.o"
|
|
#fi
|
|
CC=${NDKPFX}-gcc
|
|
AR=${NDKPFX}-ar
|
|
EXT_SO=so
|
|
|
|
export PATH=${NDK_BINS}:$PATH
|
|
export EXT_SO AR CC CFLAGS LDFLAGS PATH
|
|
#echo ${CC} ${CFLAGS} ${LDFLAGS} $@
|
|
${CC} ${CFLAGS} ${LDFLAGS} $@
|