This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/misc/mkandroid
Vítor Santos Costa 349f2898df small fixes
2014-09-22 18:07:07 +01:00

147 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
#
# 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
# ANDROID_RELEASE= 17 is 4.2.2, 19 is 4.4.2
ANDROID_RELEASE=17
# ANDROID_ARCH= arm, x86, mips
ANDROID_ARCH=arm
# ANDROID_BUILD=linux
if test `uname` = Darwin
then
ANDROID_BUILD_TOOLS=macosx
ANDROID_BUILD=darwin
else
ANDROID_BUILD_TOOLS=linux
ANDROID_BUILD=linux
fi
# what android to compile for
ANDROID_IMAGE=first
# YAP_SRC="$HOME/Yap/yap-6.3"
if test -d "$HOME/git/yap-6.3"
then
export YAP_SRC="$HOME/git/yap-6.3"
elif test -d "$HOME/Yap/yap-6.3"
then
export YAP_SRC="$HOME/Yap/yap-6.3"
fi
# check if the SDK is at the usual locations
if test -d $HOME/Yap/android-sdk-"$ANDROID_BUILD_TOOLS"
then
export SDK_ROOT=$HOME/Yap/android-sdk-"$ANDROID_BUILD_TOOLS"
else
export SDK_ROOT=/scratch/vitor/android-sdk-"$ANDROID_BUILD_TOOLS"
fi
# check if the NDK is at the usual locations
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 gcc to use
GCC_VERSION=4.8
#========================================================
# should need no further work.
#========================================================
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
echo using the setup at "$BUILDTOOLCHAIN"
else
"$NDK_ROOT"/build/tools/make-standalone-toolchain.sh \
--platform="$ANDROID_PLATFORM" \
--toolchain="$ANDROID_ARCH"-linux-androideabi-"$GCC_VERSION" \
--install-dir="$BUILDTOOLCHAIN"
fi
mkdir -p $BUILDDROID
startemulator () {
EMS=`ps -ef | grep emulator64| grep -v grep`
if test x"$EMS" = x
then
nohup emulator -avd $IMAGE &
fi
}
cd $BUILDDROID
if test x$1 = xmake
then
./config.status
make -j install
rm -r packages/swig/android
elif test x$1 = xenv
then
return 0
elif test x$1 = xeclipse
then
startemulator
"$ECLIPSE" &
return 0
else
startemulator
rm -rf "$BUILDDROID"/*
cd "$BUILDDROID"
"$YAP_SRC"/configure --host="$ANDROID_ARCH"-linux-androideabi --prefix=`pwd` --enable-low-level-tracer --enable-debug-yap --enable-dynamic-loading --with-swig --with-gmp=$GMPDIR --with-sqlite=no --disable-chr #--enable-threads
make depend
make -j install
fi
cd packages/swig
mkdir -p "$ANDROID_NDK_ROOT"/build/core/lib
make android
make install-android
adb uninstall pt.up.fc.dcc.yap
adb install android/bin/JavaYap-debug.apk