2011-09-25 04:57:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# android shell
|
|
|
|
|
2012-09-02 23:27:52 +00:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
NDK_ARCH="$1"
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
case "${NDK_ARCH}" in
|
|
|
|
arm|mips|x86)
|
|
|
|
export NDK_ARCH
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 [arm|mips|x86]"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-03-30 11:33:38 +00:00
|
|
|
LANG=C
|
|
|
|
export LANG
|
2011-09-25 04:57:13 +00:00
|
|
|
ROOT=`dirname $PWD/$0`
|
2011-09-25 19:07:34 +00:00
|
|
|
OS=`uname|tr 'A-Z' 'a-z'`
|
2012-03-31 01:54:44 +00:00
|
|
|
[ "${OS}" = macosx ] && OS=darwin
|
2011-09-25 04:57:13 +00:00
|
|
|
|
|
|
|
# TODO: autodetect or gtfo
|
2011-09-26 00:51:55 +00:00
|
|
|
if [ -f ~/.r2androidrc ]; then
|
|
|
|
. ~/.r2androidrc
|
2013-08-27 21:54:06 +00:00
|
|
|
echo "Using data from ${HOME}/.r2androidrc.."
|
2011-09-26 00:51:55 +00:00
|
|
|
else
|
2013-08-27 21:55:33 +00:00
|
|
|
[ -z "${SDK}" ] && SDK=${HOME}/Downloads/android-sdk-${OS}
|
2013-08-27 21:54:06 +00:00
|
|
|
[ -z "${NDK}" ] && NDK=${HOME}/Downloads/android-ndk-r7b
|
2011-09-26 00:51:55 +00:00
|
|
|
fi
|
2011-09-25 04:57:13 +00:00
|
|
|
|
2013-08-26 00:43:15 +00:00
|
|
|
if [ ! -d "${SDK}/tools" ]; then
|
2011-09-25 04:57:13 +00:00
|
|
|
echo "Cannot find Android SDK ${SDK}"
|
2012-03-31 01:54:44 +00:00
|
|
|
echo "Edit ~/.r2androidrc with:"
|
|
|
|
echo 'SDK=~/Downloads/android-sdk-$(uname)'
|
|
|
|
echo 'NDK=~/Downloads/android-ndk-r7b'
|
2011-09-25 04:57:13 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ ! -d "${NDK}" ]; then
|
|
|
|
echo "Cannot find Android NDK ${NDK}"
|
2012-02-17 12:55:54 +00:00
|
|
|
echo "echo NDK=/path/to/ndk > ~/.r2androidrc"
|
|
|
|
echo "echo SDK=/path/to/sdk >> ~/.r2androidrc"
|
2011-09-25 04:57:13 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-01-04 13:34:58 +00:00
|
|
|
TOOLCHAIN_MIPS=`ls ${NDK}/toolchains/ |grep "^mips" |sort |head -n 1`
|
|
|
|
TOOLCHAIN_ARM=`ls ${NDK}/toolchains/ |grep "^arm" |sort |head -n 1`
|
|
|
|
TOOLCHAIN_X86=`ls ${NDK}/toolchains/ |grep "^x86" |sort |head -n 1`
|
2012-09-20 02:10:08 +00:00
|
|
|
|
2013-05-21 15:10:58 +00:00
|
|
|
NDKPATH_MIPS=`echo ${NDK}/toolchains/${TOOLCHAIN_MIPS}/prebuilt/${OS}-x86*/bin/`
|
|
|
|
NDKPATH_ARM=`echo ${NDK}/toolchains/${TOOLCHAIN_ARM}/prebuilt/${OS}-x86*/bin/`
|
|
|
|
NDKPATH_X86=`echo ${NDK}/toolchains/${TOOLCHAIN_X86}/prebuilt/${OS}-x86*/bin/`
|
2012-02-18 00:49:59 +00:00
|
|
|
|
|
|
|
# r7b
|
2012-09-20 02:10:08 +00:00
|
|
|
#NDKPATH_ARM=`echo ${NDK}/toolchains/arm-*/prebuilt/$(uname|tr A-Z a-z)-x86/bin/`
|
2011-09-26 00:10:25 +00:00
|
|
|
#INCDIR=${NDK}/platforms/android-8/arch-arm/usr/include/
|
|
|
|
#CFLAGS=-I${INCDIR}
|
2012-09-20 00:52:59 +00:00
|
|
|
#echo $NDKPATH_ARM
|
2011-09-25 04:57:13 +00:00
|
|
|
|
2012-03-30 11:33:38 +00:00
|
|
|
PATH=$SDK/tools:$SDK/platform-tools:$NDK:${NDKPATH_X86}:${NDKPATH_ARM}:${NDKPATH_MIPS}:$PATH
|
2011-09-25 04:57:13 +00:00
|
|
|
export PATH
|
|
|
|
export CFLAGS
|
2012-02-18 00:49:59 +00:00
|
|
|
export NDK
|
2012-09-02 23:27:52 +00:00
|
|
|
[ -z "${SHELL}" ] && SHELL=sh
|
|
|
|
SHELL=sh
|
2011-09-25 04:57:13 +00:00
|
|
|
cp ${ROOT}/ndk-gcc ${NDK}
|
|
|
|
chmod +x ${NDK}/ndk-gcc
|
|
|
|
CC=ndk-gcc
|
2012-09-02 23:27:52 +00:00
|
|
|
PS1="[r2-android-${NDK_ARCH}]> "
|
2011-09-25 04:57:13 +00:00
|
|
|
export CC
|
|
|
|
export PS1
|
2013-04-12 00:39:46 +00:00
|
|
|
AR=arm-linux-androideabi-ar
|
|
|
|
export AR
|
2013-08-26 00:43:15 +00:00
|
|
|
RANLIB=arm-linux-androideabi-ranlib
|
|
|
|
export RANLIB
|
2012-09-02 23:27:52 +00:00
|
|
|
A=$@
|
|
|
|
if [ -n "$A" ]; then
|
|
|
|
${SHELL} -c "$A"
|
|
|
|
else
|
|
|
|
${SHELL}
|
|
|
|
fi
|