Add SDL2_mixer support.
[runemen.git] / android / prep.sh
blobede29c97bdcc95cb2d11769c9f78f655a16fa47f
1 #!/bin/sh
3 echo " * * * "
4 echo "Preparing android build directory"
5 echo "You'll need android-sdk, android-ndk, SDL2 sources and ant"
6 echo "You'll also need open-jdk and open-jre"
7 echo " * * * "
9 # See if user has 'ant' installed
10 if [ `which ant` = "" ]; then
11 echo "Can't find `ant` program."
12 echo "Install it using your package manager."
13 echo "NOTE: If `ant-optinal` exists in your package manager, install it too."
14 exit 1
17 ## NDK
18 # See if NDK is in the Makefile.local already
19 NDK_BUILD=`cat Makefile.local | grep NDK_BUILD= | sed 's/NDK_BUILD=//'`
20 if [ "$NDK_BUILD" = "" ]; then
21 echo "ndk-build not found in Makefile.local"
23 # See if NDK is in the PATH
24 NDK_BUILD=`which ndk-build`
26 if [ "$NDK_BUILD" = "" ]; then
27 echo "ndk-build not found in PATH."
29 echo -n "Enter path to android-ndk:"
30 read -r TMP
31 NDK=`echo ${TMP} | sed 's/\/$//'` # remove trailing slash
33 NDK_BUILD="${NDK}/ndk-build"
34 else
35 echo "Found ndk-build at $NDK_BUILD"
38 else
39 echo "Found ndk-build in Makefile.local, $NDK_BUILD"
42 # Verify NDK-BUILD is correct
43 NDK_TEST=`${NDK_BUILD} --version | grep GNU`
44 if [ "${NDK_TEST}" != "" ]; then
45 echo "(re)Writing Makefile.local"
46 echo "NDK_BUILD=${NDK_BUILD}" > Makefile.local
47 echo "WWW_PATH=/tmp" >> Makefile.local
48 else
49 echo "Path to ndk-build is wrong."
50 exit 1
53 ## SDK
54 # See if SDK is in the local.properties already
55 ANDROID_SDK_PATH=`cat local.properties | grep sdk.dir= | sed 's/sdk\.dir=//'`
56 if [ "$ANDROID_SDK_PATH" = "" ]; then
57 # Or ask user to enter it
58 echo -n "Enter path to android-sdk:"
59 read -r TMP
60 ANDROID_SDK_PATH=`echo ${TMP} | sed 's/\/$//'` # remove trailing slash
61 else
62 echo "Using sdk.dir from local.properties."
65 # See if SDK path is correct
66 if [ -f ${ANDROID_SDK_PATH}/platform-tools/adb ]; then
67 # WRITE SDK PATH
68 echo "(re)Writing local.properties"
69 echo "sdk.dir=$ANDROID_SDK_PATH" > local.properties
70 echo "target=android-17" >> local.properties
71 else
72 echo "Error: Unable to find ${ANDROID_SDK_PATH}/platform-tools/adb"
73 echo "Aborting"
74 exit 1
77 ## SDL2 sources
79 # See if it's already symlinked/copied
80 if [ -f jni/SDL/README.android ]; then
81 echo "SDL2 sources found"
82 else
83 echo -n "Enter path to SDL source dir:"
84 read -r TMP
85 SDL_SOURCE_PATH=`echo ${TMP} | sed 's/\/$//'` # remove trailing slash
87 # Verify SDL_SOURCE_PATH is correct
88 if [ -f "${SDL_SOURCE_PATH}/README.android" ]; then
89 echo "Symlinking to jni/SDL"
90 ln -s ${SDL_SOURCE_PATH} jni/SDL
91 else
92 echo "Error: Unable to find ${SDL_SOURCE_PATH}/README.android"
93 echo "Aborting"
94 exit 1