2014-06-20 11:15:44 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# script to compile yap for Android.
|
2014-07-14 05:47:30 +01:00
|
|
|
#
|
|
|
|
# variables are
|
|
|
|
#
|
|
|
|
# SDK_ROOT: where is the SDK
|
|
|
|
# NDK_ROOT: and the NDK
|
2015-02-17 20:28:05 +00:00
|
|
|
# GMPDIR: get your copy of GMP from
|
2015-03-23 07:27:10 +00:00
|
|
|
# SQLite3DIr: a pre-compiled version of sqlite3
|
2014-07-14 05:47:30 +01:00
|
|
|
# BUILDDROID: where we want to compile yap
|
|
|
|
|
|
|
|
|
|
|
|
# ANDROID_RELEASE= 17 is 4.2.2, 19 is 4.4.2
|
2015-03-04 10:03:25 +00:00
|
|
|
ANDROID_RELEASE=19
|
2014-07-14 05:47:30 +01:00
|
|
|
# ANDROID_ARCH= arm, x86, mips
|
|
|
|
ANDROID_ARCH=arm
|
|
|
|
# ANDROID_BUILD=linux
|
2014-07-15 06:54:45 +01:00
|
|
|
if test `uname` = Darwin
|
|
|
|
then
|
|
|
|
ANDROID_BUILD_TOOLS=macosx
|
|
|
|
ANDROID_BUILD=darwin
|
|
|
|
else
|
|
|
|
ANDROID_BUILD_TOOLS=linux
|
|
|
|
ANDROID_BUILD=linux
|
|
|
|
fi
|
2014-06-20 11:15:44 +01:00
|
|
|
|
2015-02-17 20:28:05 +00:00
|
|
|
# use `android list target` to check for available targets
|
|
|
|
export ANDROID_TARGET=3
|
|
|
|
|
2015-03-23 07:27:10 +00:00
|
|
|
# what android to compile for, use
|
2014-07-14 05:47:30 +01:00
|
|
|
ANDROID_IMAGE=first
|
|
|
|
|
|
|
|
# YAP_SRC="$HOME/Yap/yap-6.3"
|
|
|
|
if test -d "$HOME/git/yap-6.3"
|
2014-07-10 05:28:10 +01:00
|
|
|
then
|
2014-07-14 05:47:30 +01:00
|
|
|
export YAP_SRC="$HOME/git/yap-6.3"
|
|
|
|
elif test -d "$HOME/Yap/yap-6.3"
|
2014-07-10 05:28:10 +01:00
|
|
|
then
|
2014-07-14 05:47:30 +01:00
|
|
|
export YAP_SRC="$HOME/Yap/yap-6.3"
|
2014-07-10 05:28:10 +01:00
|
|
|
fi
|
|
|
|
|
2014-07-14 05:47:30 +01:00
|
|
|
# check if the SDK is at the usual locations
|
2014-06-20 11:15:44 +01:00
|
|
|
|
2014-07-15 06:54:45 +01:00
|
|
|
if test -d $HOME/Yap/android-sdk-"$ANDROID_BUILD_TOOLS"
|
2014-07-14 05:47:30 +01:00
|
|
|
then
|
2014-07-15 06:54:45 +01:00
|
|
|
export SDK_ROOT=$HOME/Yap/android-sdk-"$ANDROID_BUILD_TOOLS"
|
2014-07-14 05:47:30 +01:00
|
|
|
else
|
2014-07-15 06:54:45 +01:00
|
|
|
export SDK_ROOT=/scratch/vitor/android-sdk-"$ANDROID_BUILD_TOOLS"
|
2014-07-14 05:47:30 +01:00
|
|
|
fi
|
2014-06-20 11:15:44 +01:00
|
|
|
|
2014-07-14 05:47:30 +01:00
|
|
|
# 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
|
|
|
|
|
2015-02-17 20:28:05 +00:00
|
|
|
# fetch SQLITE3 from https://github.com/Rupan/gmp,
|
|
|
|
# and have two versions: one to build myddas, the
|
|
|
|
# other to build the app.
|
|
|
|
#
|
|
|
|
# This one is used to build myddas
|
|
|
|
if test -d /scratch
|
|
|
|
then
|
2015-03-23 07:27:10 +00:00
|
|
|
export SQLITE3DIR=/scratch/vitor/sqlite3-android
|
2015-02-17 20:28:05 +00:00
|
|
|
else
|
|
|
|
export SQLITE3DIR="$HOME"/Yap/sqlite3-android
|
|
|
|
fi
|
|
|
|
|
2014-07-14 05:47:30 +01:00
|
|
|
#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
|
2014-06-20 11:15:44 +01:00
|
|
|
|
2014-06-20 20:01:56 +01:00
|
|
|
# which gcc to use
|
|
|
|
GCC_VERSION=4.8
|
2014-07-14 05:47:30 +01:00
|
|
|
|
|
|
|
#========================================================
|
2014-07-15 06:54:45 +01:00
|
|
|
# should need no further work.
|
2014-07-14 05:47:30 +01:00
|
|
|
#========================================================
|
|
|
|
|
|
|
|
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"
|
2014-06-20 20:01:56 +01:00
|
|
|
# which disk
|
2014-07-14 05:47:30 +01:00
|
|
|
IMAGE="$ANDROID_IMAGE"
|
2014-06-20 20:01:56 +01:00
|
|
|
|
2014-07-14 05:47:30 +01:00
|
|
|
export PATH="$BUILDTOOLCHAIN"/bin:"$NDK_ROOT":"$SDK_ROOT/tools":"$SDK_ROOT/platform-tools":$PATH
|
|
|
|
|
|
|
|
echo $PATH
|
|
|
|
|
|
|
|
if test -d "$BUILDTOOLCHAIN"
|
2014-06-20 11:15:44 +01:00
|
|
|
then
|
2014-07-14 05:47:30 +01:00
|
|
|
echo using the setup at "$BUILDTOOLCHAIN"
|
2014-06-20 11:15:44 +01:00
|
|
|
else
|
|
|
|
"$NDK_ROOT"/build/tools/make-standalone-toolchain.sh \
|
2014-07-15 06:54:45 +01:00
|
|
|
--platform="$ANDROID_PLATFORM" \
|
|
|
|
--toolchain="$ANDROID_ARCH"-linux-androideabi-"$GCC_VERSION" \
|
|
|
|
--install-dir="$BUILDTOOLCHAIN"
|
2014-06-20 11:15:44 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2014-07-14 05:47:30 +01:00
|
|
|
mkdir -p $BUILDDROID
|
|
|
|
|
2015-02-17 20:28:05 +00:00
|
|
|
startemulator () {
|
2014-07-15 06:54:45 +01:00
|
|
|
EMS=`ps -ef | grep emulator64| grep -v grep`
|
|
|
|
if test x"$EMS" = x
|
2015-02-17 20:28:05 +00:00
|
|
|
then
|
2014-07-15 06:54:45 +01:00
|
|
|
nohup emulator -avd $IMAGE &
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-04-13 13:28:17 +01:00
|
|
|
androidize () {
|
|
|
|
cd packages/swig
|
|
|
|
mkdir -p "$ANDROID_NDK_ROOT"/build/core/lib
|
|
|
|
make install-android
|
|
|
|
cd ../..
|
|
|
|
}
|
2014-07-15 06:54:45 +01:00
|
|
|
|
2014-07-14 05:47:30 +01:00
|
|
|
cd $BUILDDROID
|
2014-06-20 11:15:44 +01:00
|
|
|
|
2015-04-13 13:28:17 +01:00
|
|
|
export HOST="$ANDROID_ARCH"-linux-androideabi
|
|
|
|
export CPP="$HOST"-cpp
|
|
|
|
export DESTDIR=`pwd`/packages/swig/android
|
|
|
|
export PATH="$PATH":/usr/local/bin
|
|
|
|
|
|
|
|
if test x$1 = xenv
|
2014-06-20 11:15:44 +01:00
|
|
|
then
|
2015-02-09 10:32:17 +00:00
|
|
|
return 0
|
|
|
|
elif test x$1 = xdmake
|
|
|
|
then
|
|
|
|
make
|
2015-04-13 13:28:17 +01:00
|
|
|
elif test x$1 = xmake
|
2015-02-09 10:32:17 +00:00
|
|
|
then
|
2015-04-13 13:28:17 +01:00
|
|
|
pushd packages/swig
|
|
|
|
make clean
|
|
|
|
popd
|
|
|
|
./config.status
|
|
|
|
CFLAGS="-g" make -j install
|
2014-06-20 11:15:44 +01:00
|
|
|
elif test x$1 = xeclipse
|
|
|
|
then
|
2014-07-15 06:54:45 +01:00
|
|
|
startemulator
|
|
|
|
"$ECLIPSE" &
|
2014-06-20 20:01:56 +01:00
|
|
|
return 0
|
2014-06-20 11:15:44 +01:00
|
|
|
else
|
2015-04-13 13:28:17 +01:00
|
|
|
startemulator
|
2014-07-14 05:47:30 +01:00
|
|
|
rm -rf "$BUILDDROID"/*
|
2015-02-17 20:28:05 +00:00
|
|
|
cd "$BUILDDROID"
|
|
|
|
"$YAP_SRC"/configure \
|
2015-03-23 07:27:10 +00:00
|
|
|
--host="$HOST" \
|
2015-02-17 20:28:05 +00:00
|
|
|
--enable-low-level-tracer \
|
|
|
|
--enable-debug-yap \
|
|
|
|
--enable-dynamic-loading \
|
2015-04-13 13:28:17 +01:00
|
|
|
--bindir=/usr/bin \
|
|
|
|
--prefix=/assets \
|
|
|
|
--enable-dynamic-loading \
|
2015-02-17 20:28:05 +00:00
|
|
|
--with-swig \
|
2015-04-13 13:28:17 +01:00
|
|
|
--with-gmp="$GMPDIR" \
|
|
|
|
--with-sqlite3="$SQLITE3DIR"
|
|
|
|
|
|
|
|
#\
|
2015-03-28 20:13:52 +00:00
|
|
|
#--enable-chr=yes #--enable-threads
|
2014-06-20 11:15:44 +01:00
|
|
|
make depend
|
2015-04-13 13:28:17 +01:00
|
|
|
CFLAGS="-g" make -j install
|
2014-06-20 11:15:44 +01:00
|
|
|
fi
|
2015-04-13 13:28:17 +01:00
|
|
|
androidize
|