radare2/sys/ndk-gcc

67 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/bin/sh
# android gcc wrapper
if [ -n "${NDK_ARCH}" ]; then
ARCH=${NDK_ARCH}
else
2012-03-30 11:33:38 +00:00
ARCH=mips
ARCH=arm
ARCH=x86
fi
#------------------------------------------#
PROGDIR=`dirname $0`
PROGDIR=`cd $PROGDIR && pwd`
OS=`uname | tr 'A-Z' 'a-z'`
2012-03-31 01:54:44 +00:00
[ "${OS}" = macos ] && OS=darwin
2012-03-30 11:33:38 +00:00
case "${ARCH}" in
arm)
ANDROID_SDK_VERSION=8
NDKPFX=${ARCH}-linux-androideabi
;;
mips)
ANDROID_SDK_VERSION=9 #mips
2012-09-20 02:10:08 +00:00
NDKPFX=mips-linux-android
${NDKPFX}-gcc 2>/dev/null
if [ $? -gt 1 ]; then
NDKPFX=mipsel-linux-android
fi
2012-03-30 11:33:38 +00:00
;;
x86)
ANDROID_SDK_VERSION=9 #x86
NDKPFX=i686-android-linux
2012-09-20 02:10:08 +00:00
${NDKPFX}-gcc 2>/dev/null
if [ $? -gt 1 ]; then
NDKPFX=i686-linux-android
fi
2012-03-30 11:33:38 +00:00
;;
esac
2013-04-12 00:39:46 +00:00
PLATFORM=android-${ANDROID_SDK_VERSION}
2011-09-26 00:10:25 +00:00
PLATFORM_ROOT=${PROGDIR}/platforms/${PLATFORM}/arch-${ARCH}
PLATFORM_PATH=${PLATFORM_ROOT}/usr
2012-09-20 02:10:08 +00:00
TOOLCHAIN=`ls ${PROGDIR}/toolchains/ |grep "^${ARCH}" |sort |tail -n 1`
NDK_BINS=${PROGDIR}/toolchains/${TOOLCHAIN}/prebuilt/${OS}-x86/bin
2011-09-26 00:10:25 +00:00
CFLAGS="--sysroot=${PLATFORM_ROOT}"
CFLAGS="${CFLAGS} -I${PLATFORM_PATH}/include"
LDFLAGS=-L${PLATFORM_PATH}/lib
2011-09-26 00:10:25 +00:00
#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
2013-04-12 00:39:46 +00:00
AR=${NDKPFX}-ar
EXT_SO=so
export PATH=${NDK_BINS}:$PATH
2013-04-12 00:39:46 +00:00
export EXT_SO AR CC CFLAGS LDFLAGS PATH
#echo ${CC} ${CFLAGS} ${LDFLAGS} $@
${CC} ${CFLAGS} ${LDFLAGS} $@