improve script portability

This commit is contained in:
Vitor Santos Costa 2014-07-13 23:47:30 -05:00
parent da985b999b
commit 0be1e7def1

View File

@ -1,42 +1,105 @@
#!/bin/bash #!/bin/bash
# #
# script to compile yap for Android. # script to compile yap for Android.
#
# variables are
#
# SDK_ROOT: where is the SDK
# NDK_ROOT: and the NDK
# GMPDIR: get your copy of GMP from
# BUILDDROID: where we want to compile yap
if test -d $HOME/Yap/android-sdk-linux
# ANDROID_RELEASE= 17 is 4.2.2, 19 is 4.4.2
ANDROID_RELEASE=19
# ANDROID_ARCH= arm, x86, mips
ANDROID_ARCH=arm
# ANDROID_BUILD=linux
ANDROID_BUILD=linux
# what android to compile for
ANDROID_IMAGE=first
# YAP_SRC="$HOME/Yap/yap-6.3"
if test -d "$HOME/git/yap-6.3"
then then
export SDK_ROOT=$HOME/Yap/android-sdk-linux export YAP_SRC="$HOME/git/yap-6.3"
elif test -d $HOME/Yap/android-sdk-macosx elif test -d "$HOME/Yap/yap-6.3"
then then
export SDK_ROOT=$HOME/Yap/android-sdk-macosx export YAP_SRC="$HOME/Yap/yap-6.3"
fi fi
export NDK_ROOT=$HOME/Yap/android-ndk-r9d # check if the SDK is at the usual locations
export GMPDIR=$HOME/Yap/gmp-android if test -d $HOME/Yap/android-sdk-"$ANDROID_BUILD"
then
export SDK_ROOT=$HOME/Yap/android-sdk-"$ANDROID_BUILD"
else
export SDK_ROOT=/scratch/vitor/android-sdk-"$ANDROID_BUILD"
fi
export ANDROID_NDK_ROOT="$NDK_ROOT"/ # check if the NDK is at the usual locations
export ANDROID_SYSROOT="$NDK_ROOT"/platforms/android-17/arch-arm if test -d $HOME/Yap/android-ndk-r9d
then
export NDK_ROOT=$HOME/Yap/android-ndk-r9d
elif test -d /scratch/vitor/android-ndk-r9d
then
export NDK_ROOT=/scratch/vitor/android-ndk-r9d
fi
# fetch GMP from https://github.com/Rupan/gmp,
# or compile it.
if test -d /scratch
then
export GMPDIR=/scratch/vitor/gmp-android
else
export GMPDIR="$HOME"/Yap/gmp-android
fi
#where I want to compile
#export BUILDTOOLCHAIN="$HOME/Yap/my-android-toolchain"
if test -d /scratch
then
export BUILDTOOLCHAIN="/scratch/vitor/my-android-toolchain"
export BUILDDROID="/scratch/vitor/yap-android"
else
export BUILDTOOLCHAIN="$HOME/Yap/my-android-toolchain"
export BUILDDROID="$HOME/Yap/bins/android"
fi
# which platform to compile for
ANDROID_PLATFORM=android-17
# which gcc to use # which gcc to use
GCC_VERSION=4.8 GCC_VERSION=4.8
# which disk
IMAGE=first
if test -d $HOME/Yap/my-android-toolchain #========================================================
# should be fine
#========================================================
export ANDROID_NDK_ROOT="$NDK_ROOT"/
export ANDROID_SYSROOT="$NDK_ROOT"/platforms/android-"$ANDROID_RELEASE"/arch-"$ANDROID_ARCH"
# which platform to compile for
ANDROID_PLATFORM=android-"$ANDROID_RELEASE"
# which disk
IMAGE="$ANDROID_IMAGE"
export PATH="$BUILDTOOLCHAIN"/bin:"$NDK_ROOT":"$SDK_ROOT/tools":"$SDK_ROOT/platform-tools":$PATH
echo $PATH
if test -d "$BUILDTOOLCHAIN"
then then
echo using the setup at $HOME/Yap/my-android-toolchain echo using the setup at "$BUILDTOOLCHAIN"
else else
"$NDK_ROOT"/build/tools/make-standalone-toolchain.sh \ "$NDK_ROOT"/build/tools/make-standalone-toolchain.sh \
--platform="$ANDROID_PLATFORM" \ --platform="$ANDROID_PLATFORM" \
--toolchain=arm-linux-androideabi-"$GCC_VERSION" \ --toolchain="$ANDROID_ARCH"-"$ANDROID_BUILD"-androideabi-"$GCC_VERSION" \
--install-dir="$HOME"/Yap/my-android-toolchain --install-dir="$BUILDTOOLCHAIN"
fi fi
export PATH="$HOME"/Yap/my-android-toolchain/bin:"$NDK_ROOT":"$SDK_ROOT/tools":"$SDK_ROOT/platform-tools":$PATH
cd ~/Yap/bins/android mkdir -p $BUILDDROID
cd $BUILDDROID
if test x$1 = xmake if test x$1 = xmake
then then
@ -48,18 +111,22 @@ then
elif test x$1 = xeclipse elif test x$1 = xeclipse
then then
emulator -avd $IMAGE & emulator -avd $IMAGE &
~/eclipse/eclipse & "$ECLIPSE"eclipse &
return 0 return 0
else else
EMS=`ps -ef | grep emulator64| grep -v grep`
if test x"$EMS" = x
then
emulator -avd $IMAGE & emulator -avd $IMAGE &
rm -rf ~/Yap/bins/android/* fi
cd ~/Yap/bins/android rm -rf "$BUILDDROID"/*
~/git/yap-6.3/configure --host=arm-linux-androideabi --prefix=`pwd` --enable-low-level-tracer --enable-debug-yap --enable-dynamic-loading --with-swig --with-gmp=$GMPDIR --disable-chr #--enable-threads cd "$BUILDDROID"
"$YAP_SRC"/configure --host="$ANDROID_ARCH"-"$ANDROID_BUILD"-androideabi --prefix=`pwd` --enable-low-level-tracer --enable-debug-yap --enable-dynamic-loading --with-swig --with-gmp=$GMPDIR --disable-chr #--enable-threads
make depend make depend
make -j install make -j install
fi fi
cd packages/swig cd packages/swig
mkdir -p $ANDROID_NDK_ROOT/build/core/lib mkdir -p "$ANDROID_NDK_ROOT"/build/core/lib
make android make android
make install-android make install-android
adb uninstall pt.up.fc.dcc.yap adb uninstall pt.up.fc.dcc.yap