1#!/bin/sh 2# 3# Build the Android libraries without needing a project 4# (AndroidManifest.xml, jni/{Application,Android}.mk, etc.) 5# 6# Usage: androidbuildlibs.sh [arg for ndk-build ...]" 7# 8# Useful NDK arguments: 9# 10# NDK_DEBUG=1 - build debug version 11# NDK_LIBS_OUT=<dest> - specify alternate destination for installable 12# modules. 13# 14# Note that SDLmain is not an installable module (.so) so libSDLmain.a 15# can be found in $obj/local/<abi> along with the unstripped libSDL.so. 16# 17 18 19# Android.mk is in srcdir 20srcdir=`dirname $0`/.. 21srcdir=`cd $srcdir && pwd` 22cd $srcdir 23 24 25# 26# Create the build directories 27# 28 29build=build 30buildandroid=$build/android 31obj= 32lib= 33ndk_args= 34 35# Allow an external caller to specify locations. 36for arg in $* 37do 38 if [ "${arg:0:8}" == "NDK_OUT=" ]; then 39 obj=${arg#NDK_OUT=} 40 elif [ "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then 41 lib=${arg#NDK_LIBS_OUT=} 42 else 43 ndk_args="$ndk_args $arg" 44 fi 45done 46 47if [ -z $obj ]; then 48 obj=$buildandroid/obj 49fi 50if [ -z $lib ]; then 51 lib=$buildandroid/lib 52fi 53 54for dir in $build $buildandroid $obj $lib; do 55 if test -d $dir; then 56 : 57 else 58 mkdir $dir || exit 1 59 fi 60done 61 62 63# APP_* variables set in the environment here will not be seen by the 64# ndk-build makefile segments that use them, e.g., default-application.mk. 65# For consistency, pass all values on the command line. 66ndk-build \ 67 NDK_PROJECT_PATH=null \ 68 NDK_OUT=$obj \ 69 NDK_LIBS_OUT=$lib \ 70 APP_BUILD_SCRIPT=Android.mk \ 71 APP_ABI="armeabi-v7a arm64-v8a x86 x86_64" \ 72 APP_PLATFORM=android-16 \ 73 APP_MODULES="SDL2 SDL2_main" \ 74 $ndk_args 75