ref: cd8dc521a6038d92396d2571df5ff9365e1b6635
parent: 4afcad303bb3d907bdbd174de37e332a382b2020
author: Paul Brossier <piem@piem.org>
date: Sun Jan 8 11:38:04 EST 2017
scripts/build_android: add an example script to build aubio on android, add reference to it in doc/android.rst
--- /dev/null
+++ b/doc/android.rst
@@ -1,0 +1,9 @@
+.. _android:
+
+Building aubio for Android
+--------------------------
+
+To compile aubio for android, you will need to get the `Android Native
+Development Toolkit (NDK) <https://developer.android.com/ndk/>`_, prepare a
+standalone toolchain, and tell waf to use the NDK toolchain. An example script
+to complete these tasks is available in ``scripts/build_android``.
--- /dev/null
+++ b/scripts/build_android
@@ -1,0 +1,41 @@
+#! /bin/bash
+
+set -e
+set -x
+
+# location of android NDK
+NDK_PATH=$PWD/../contrib/android-ndk-r12
+
+WAFOPTS="--disable-avcodec --disable-samplerate --disable-jack --disable-sndfile"
+
+# set these variables to change the default values
+[ -z $PLATFORM ] && PLATFORM=android-19
+[ -z $ARCH ] && ARCH=arm
+
+# location nof the standalone toolchains, created with
+# $NDK_PATH/build/tools/make-standalone-toolchains.sh
+NDK_TOOLCHAINS=$PWD/contrib
+
+# location of the current toolchain
+CURRENT_TOOLCHAIN=$NDK_TOOLCHAINS/toolchain-$PLATFORM-$ARCH
+
+# if it does not exist, create the toolchain
+[ -d $CURRENT_TOOLCHAIN ] || \
+ $NDK_PATH/build/tools/make-standalone-toolchain.sh \
+ --platform=$PLATFORM --arch=$ARCH \
+ --install-dir=$CURRENT_TOOLCHAIN
+
+# aubio install destination directory
+DESTDIR=$PWD/dist-$PLATFORM-$ARCH
+
+# wipe it out if it exists
+[ -d $DESTDIR ] && rm -rf $DESTDIR
+
+# get the link to gcc
+CC=`ls $CURRENT_TOOLCHAIN/*-linux-android*/bin/gcc`
+
+CFLAGS="-Os" \
+ CC=$CC \
+ ./waf distclean configure build install --destdir=$DESTDIR \
+ --verbose \
+ --with-target-platform=android $WAFOPTS