radare2/sys/ndk-gcc
2012-03-31 03:54:44 +02:00

58 lines
1.2 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
;;
x86)
ANDROID_SDK_VERSION=9 #x86
NDKPFX=i686-android-linux
;;
esac
PLATFORM=android-${ANDROID_SDK_VERSION}
PLATFORM_ROOT=${PROGDIR}/platforms/${PLATFORM}/arch-${ARCH}
PLATFORM_PATH=${PLATFORM_ROOT}/usr
NDK_BINS=`echo ${PROGDIR}/toolchains/${ARCH}-*/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
EXT_SO=so
export PATH=${NDK_BINS}:$PATH
export EXT_SO CC CFLAGS LDFLAGS PATH
#echo ${CC} ${CFLAGS} ${LDFLAGS} $@
${CC} ${CFLAGS} ${LDFLAGS} $@