Ticket #863: android_build.sh

File android_build.sh, 2.9 KB (added by themroc.myopenid.com, 8 years ago)
Line 
1#!/bin/sh
2
3show_api_lvl () {
4        case $1 in
5                 1) ver='Android 1.0' ;;
6                 2) ver='Android 1.1' ;;
7                 3) ver='Android 1.5 "Cupcake"' ;;
8                 4) ver='Android 1.6 "Donut"' ;;
9                 5) ver='Android 2.0 "Eclair"' ;;
10                 6) ver='Android 2.0.1 "Eclair"' ;;
11                 7) ver='Android 2.1 "Eclair"' ;;
12                 8) ver='Android 2.2 "Froyo"' ;;
13                 9) ver='Android 2.3 "Gingerbread"' ;;
14                10) ver='Android 2.3.3+ "Gingerbread"' ;;
15                11) ver='Android 3.0 "Honeycomb"' ;;
16                12) ver='Android 3.1 "Ice Cream Sandwich"' ;;
17        esac
18        echo "$1        $ver"
19}
20
21if [ -z $ANDROID_NDK ]; then
22        echo "The environment variable ANDROID_NDK must be set!"
23        exit
24fi
25
26platforms=$ANDROID_NDK/platforms
27if [ ! -d $platforms ]; then
28        platforms=$ANDROID_NDK/build/platforms
29fi
30
31if [ ! -d $platforms ]; then
32        echo "The environment variable ANDROID_NDK must be pointing to the android NDK!"
33        exit
34fi
35
36if [ ! -d navit -o ! -f autogen.sh ]; then
37        echo "This script must be called from the navit main directory (where autogen.sh is in)"
38        exit
39fi
40
41api_lvl=${1-$ANDROID_API_LVL}
42
43while [ -z $api_lvl ]; do
44        echo "The environment variable ANDROID_API_LVL is not set and the API level was also not given on the commandline."
45        echo "Possible API levels for your NDK are:"
46        cd $platforms
47        for p in android-*; do
48                [ -d $p/arch-arm ] || continue
49                show_api_lvl ${p#android-}
50        done
51        cd - > /dev/null
52        echo "Enter the desired API level (4 is recommended)"
53        read api_lvl
54        if [ ! -d $platforms/android-$api_lvl/arch-arm ]; then
55                echo "Bad choice, retrying..."; echo ""
56                unset api_lvl
57        fi
58done
59
60ANDROID_API_LVL=$api_lvl
61export ANDROID_API_LVL
62ANDROID_PLATFORM=$platforms/android-$ANDROID_API_LVL/arch-arm
63export ANDROID_PLATFORM
64PATH=`echo $ANDROID_NDK/toolchains/arm-eabi-*/prebuilt/linux-x86/bin`:$PATH
65export PATH
66
67if [ ! -f Makefile.in ]; then
68        echo ""; echo "*** Running autogen.sh ***"; echo ""
69        ./autogen.sh
70fi
71
72if [ ! -f Makefile ]; then
73        echo ""; echo "*** Running configure ***"; echo ""
74        ./configure \
75                PKG_CONFIG=arm-eabi-pkgconfig \
76                RANLIB=arm-eabi-ranlib \
77                AR=arm-eabi-ar \
78                CC="arm-eabi-gcc -L$ANDROID_PLATFORM/usr/lib -L. -I$ANDROID_PLATFORM/usr/include" \
79                CXX=arm-eabi-g++ \
80                --host=arm-eabi-linux_android \
81                --enable-avoid-float \
82                --enable-avoid-unaligned \
83                --enable-cache-size=20971520 \
84                --enable-svg2png-scaling=8,16,32,48,64,96 \
85                --enable-svg2png-scaling-nav=59 \
86                --enable-svg2png-scaling-flag=32 \
87                --with-xslts=android,plugin_menu,pedestrian_button,pedestrian \
88                --with-saxon=saxonb-xslt \
89                --enable-transformation-roll \
90                --enable-plugin-pedestrian \
91                --with-android-permissions=CAMERA \
92                --with-android-project=android-$ANDROID_API_LVL
93fi
94
95set -e
96
97echo ""; echo "*** Running make ***"; echo ""
98make
99
100echo ""; echo "*** Running make apkg ***"; echo ""
101cd navit
102make apkg
103cd - > /dev/null
104
105apk=`pwd`/navit/android/bin/Navit-debug.apk
106if [ -f $apk ]; then
107        echo "Great - looks like it worked! The result is"; echo ""
108        ls -l $apk
109        echo ""
110else
111        echo "This shouldn't happen! Something went terribly wrong..."
112fi