radare2/sys/android-shell.sh

111 lines
2.8 KiB
Bash
Raw Normal View History

#!/bin/sh
# android shell
if [ -n "$1" ]; then
NDK_ARCH="$1"
shift
fi
2015-01-24 23:17:55 +01:00
export ANDROID=1
case "${NDK_ARCH}" in
mips64)
2015-04-13 01:16:01 +02:00
export NDK_ARCH
AR=mips64el-linux-android-ar
RANLIB=mips64el-linux-android-ranlib
;;
mips)
2015-04-13 01:16:01 +02:00
export NDK_ARCH
AR=mipsel-linux-android-ar
RANLIB=mipsel-linux-android-ranlib
;;
x86)
export NDK_ARCH
;;
2014-11-10 01:09:38 +01:00
aarch64)
export NDK_ARCH
AR=aarch64-linux-android-ar
RANLIB=aarch64-linux-android-ranlib
;;
arm)
export NDK_ARCH
AR=arm-linux-androideabi-ar
RANLIB=arm-linux-androideabi-ranlib
;;
2015-01-24 23:17:55 +01:00
local)
export ANDROID=1
;;
*)
echo "Usage: $0 [aarch64|arm|mips|mips64|x86]"
exit 1
;;
esac
2012-03-30 13:33:38 +02:00
LANG=C
export LANG
ROOT=`dirname $PWD/$0`
OS=`uname|tr 'A-Z' 'a-z'`
2012-03-31 03:54:44 +02:00
[ "${OS}" = macosx ] && OS=darwin
# TODO: autodetect or gtfo
if [ -f ~/.r2androidrc ]; then
. ~/.r2androidrc
2013-08-27 23:54:06 +02:00
echo "Using data from ${HOME}/.r2androidrc.."
else
#[ -z "${SDK}" ] && SDK=${HOME}/Downloads/android-sdk-${OS}
2013-08-27 23:54:06 +02:00
[ -z "${NDK}" ] && NDK=${HOME}/Downloads/android-ndk-r7b
fi
#if [ ! -d "${SDK}/tools" ]; then
# echo "Cannot find Android SDK ${SDK}"
# 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 13:55:54 +01: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" | grep -v mips64|sort |head -n 1`
TOOLCHAIN_MIPS64=`ls ${NDK}/toolchains/ |grep "mips64" |sort |head -n 1`
TOOLCHAIN_ARM=`ls ${NDK}/toolchains/ |grep "^arm" |sort |head -n 1`
2014-11-10 01:09:38 +01:00
TOOLCHAIN_AARCH64=`ls ${NDK}/toolchains/ |grep "^aarch64" |sort |head -n 1`
TOOLCHAIN_X86=`ls ${NDK}/toolchains/ |grep "^x86" |sort |head -n 1`
2012-09-20 04:10:08 +02:00
2013-05-21 17:10:58 +02:00
NDKPATH_MIPS=`echo ${NDK}/toolchains/${TOOLCHAIN_MIPS}/prebuilt/${OS}-x86*/bin/`
NDKPATH_MIPS64=`echo ${NDK}/toolchains/${TOOLCHAIN_MIPS64}/prebuilt/${OS}-x86*/bin/`
2013-05-21 17:10:58 +02:00
NDKPATH_ARM=`echo ${NDK}/toolchains/${TOOLCHAIN_ARM}/prebuilt/${OS}-x86*/bin/`
2014-11-10 01:09:38 +01:00
NDKPATH_AARCH64=`echo ${NDK}/toolchains/${TOOLCHAIN_AARCH64}/prebuilt/${OS}-x86*/bin/`
2013-05-21 17:10:58 +02:00
NDKPATH_X86=`echo ${NDK}/toolchains/${TOOLCHAIN_X86}/prebuilt/${OS}-x86*/bin/`
# r7b
2012-09-20 04:10:08 +02:00
#NDKPATH_ARM=`echo ${NDK}/toolchains/arm-*/prebuilt/$(uname|tr A-Z a-z)-x86/bin/`
2011-09-26 02:10:25 +02:00
#INCDIR=${NDK}/platforms/android-8/arch-arm/usr/include/
#CFLAGS=-I${INCDIR}
2012-09-20 02:52:59 +02:00
#echo $NDKPATH_ARM
#PATH=$SDK/tools:$SDK/platform-tools:$NDK:${NDKPATH_X86}:${NDKPATH_ARM}:${NDKPATH_MIPS64}:${NDKPATH_AARCH64}:${NDKPATH_MIPS}:$PATH
PATH=$NDK:${NDKPATH_X86}:${NDKPATH_ARM}:${NDKPATH_MIPS64}:${NDKPATH_AARCH64}:${NDKPATH_MIPS}:$PATH
export PATH
export CFLAGS
export NDK
2014-11-11 01:30:54 +01:00
export NDK_ARCH
[ -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 02:39:46 +02:00
export AR
2013-08-26 02:43:15 +02:00
export RANLIB
A=$@
if [ -n "$A" ]; then
${SHELL} -c "$A"
else
${SHELL}
fi