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