radare2/sys/android-shell.sh

83 lines
1.9 KiB
Bash
Raw Normal View History

#!/bin/sh
# android shell
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
ROOT=`dirname $PWD/$0`
OS=`uname|tr 'A-Z' 'a-z'`
2012-03-31 01:54:44 +00:00
[ "${OS}" = macosx ] && OS=darwin
# TODO: autodetect or gtfo
if [ -f ~/.r2androidrc ]; then
. ~/.r2androidrc
2013-08-27 21:54:06 +00:00
echo "Using data from ${HOME}/.r2androidrc.."
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
fi
2013-08-26 00:43:15 +00:00
if [ ! -d "${SDK}/tools" ]; then
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'
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"
exit 1
fi
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/`
# 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
2012-03-30 11:33:38 +00:00
PATH=$SDK/tools:$SDK/platform-tools:$NDK:${NDKPATH_X86}:${NDKPATH_ARM}:${NDKPATH_MIPS}:$PATH
export PATH
export CFLAGS
export NDK
[ -z "${SHELL}" ] && SHELL=sh
SHELL=sh
cp ${ROOT}/ndk-gcc ${NDK}
chmod +x ${NDK}/ndk-gcc
CC=ndk-gcc
PS1="[r2-android-${NDK_ARCH}]> "
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
A=$@
if [ -n "$A" ]; then
${SHELL} -c "$A"
else
${SHELL}
fi