added optional button to restart game (door, panel and touch variants)
[rocksndiamonds.git] / build-projects / android / build-scripts / create_sdl.sh
1 #!/bin/bash
2
3 JNI_DIR="app/jni"
4
5 ANDROID_MK_SDL_IMAGE="$JNI_DIR/SDL2_image/Android.mk"
6 ANDROID_MK_SDL_MIXER="$JNI_DIR/SDL2_mixer/Android.mk"
7
8 SDL_BASE_URL_ORIGINAL="https://www.libsdl.org"
9 SDL_BASE_URL_FALLBACK="https://www.artsoft.org"
10 SDL_VERSIONS=`cat SDL_VERSIONS`
11
12 for i in $SDL_VERSIONS; do
13     SDL_SUBDIR=`echo $i | sed -e "s/-.*//"`
14     SDL_SUBURL=`echo $SDL_SUBDIR | tr -d '2'`
15
16     if [ -d "$JNI_DIR/$SDL_SUBDIR" ]; then
17         continue;
18     fi
19
20     if [ "$SDL_SUBURL" = "SDL" ]; then
21         SDL_RELEASE_DIR="release"
22     else
23         SDL_RELEASE_DIR="projects/$SDL_SUBURL/release"
24     fi
25
26     SDL_URL="$SDL_BASE_URL_ORIGINAL/$SDL_RELEASE_DIR/$i.tar.gz"
27
28     wget --timeout=10 -O - "$SDL_URL" | (cd "$JNI_DIR" && tar xzf -)
29
30     if [ "$?" != "0" ]; then
31         echo "ERROR: Installing '$i' from main site failed -- trying fallback!"
32
33         SDL_URL="$SDL_BASE_URL_FALLBACK/RELEASES/sdl/$i.tar.gz"
34
35         wget --timeout=10 -O - "$SDL_URL" | (cd "$JNI_DIR" && tar xzf -)
36
37         if [ "$?" != "0" ]; then
38             echo "ERROR: Installing '$i' from fallback site failed!"
39             exit 10
40         fi
41     fi
42
43     mv "$JNI_DIR/$i" "$JNI_DIR/$SDL_SUBDIR"
44 done
45
46 if [ ! -f "$ANDROID_MK_SDL_IMAGE.dist" ]; then
47     cp -a "$ANDROID_MK_SDL_IMAGE" "$ANDROID_MK_SDL_IMAGE.dist"
48     cat "$ANDROID_MK_SDL_IMAGE.dist"                                    \
49         | sed -e "s/^SUPPORT_JPG ?= true/SUPPORT_JPG ?= false/" \
50         | sed -e "s/^SUPPORT_WEBP ?= true/SUPPORT_WEBP ?= false/"       \
51         > "$ANDROID_MK_SDL_IMAGE"
52 fi
53
54 if [ ! -f "$ANDROID_MK_SDL_MIXER.dist" ]; then
55     cp -a "$ANDROID_MK_SDL_MIXER" "$ANDROID_MK_SDL_MIXER.dist"
56     cat "$ANDROID_MK_SDL_MIXER.dist"                                    \
57         | sed -e "s/^SUPPORT_OGG ?= true/SUPPORT_OGG ?= false/" \
58         | sed -e "s/^SUPPORT_FLAC ?= true/SUPPORT_FLAC ?= false/"       \
59         | sed -e "s/^LOCAL_CFLAGS :=/LOCAL_CFLAGS := -DMUSIC_WAV/"      \
60         > "$ANDROID_MK_SDL_MIXER"
61 fi
62
63 exit 0