summaryrefslogtreecommitdiff
path: root/contrib/android_build.sh
blob: 65b1d6c10b867578d47bf918a3f0fa69370d9d9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh

show_api_lvl () {
	case $1 in
		 1) ver='Android 1.0' ;;
		 2) ver='Android 1.1' ;;
		 3) ver='Android 1.5 "Cupcake"' ;;
		 4) ver='Android 1.6 "Donut"' ;;
		 5) ver='Android 2.0 "Eclair"' ;;
		 6) ver='Android 2.0.1 "Eclair"' ;;
		 7) ver='Android 2.1 "Eclair"' ;;
		 8) ver='Android 2.2 "Froyo"' ;;
		 9) ver='Android 2.3 "Gingerbread"' ;;
		10) ver='Android 2.3.3+ "Gingerbread"' ;;
		11) ver='Android 3.0 "Honeycomb"' ;;
		12) ver='Android 3.1 "Ice Cream Sandwich"' ;;
	esac
	echo "$1	$ver"
}

if [ -z $ANDROID_NDK ]; then
	echo "The environment variable ANDROID_NDK must be set!"
	exit
fi

platforms=$ANDROID_NDK/platforms
if [ ! -d $platforms ]; then
	platforms=$ANDROID_NDK/build/platforms
fi

if [ ! -d $platforms ]; then
	echo "The environment variable ANDROID_NDK must be pointing to the android NDK!"
	exit
fi

if [ ! -d navit -o ! -f autogen.sh ]; then
	echo "This script must be called from the navit main directory (where autogen.sh is in)"
	exit
fi

api_lvl=${1-$ANDROID_API_LVL}

while [ -z $api_lvl ]; do
	echo "The environment variable ANDROID_API_LVL is not set and the API level was also not given on the commandline."
	echo "Possible API levels for your NDK are:"
	cd $platforms
	for p in android-*; do
		[ -d $p/arch-arm ] || continue
		show_api_lvl ${p#android-}
	done
	cd - > /dev/null
	echo "Enter the desired API level (4 is recommended)"
	read api_lvl
	if [ ! -d $platforms/android-$api_lvl/arch-arm ]; then
		echo "Bad choice, retrying..."; echo ""
		unset api_lvl
	fi
done

ANDROID_API_LVL=$api_lvl
export ANDROID_API_LVL
ANDROID_PLATFORM=$platforms/android-$ANDROID_API_LVL/arch-arm
export ANDROID_PLATFORM
PATH=`echo $ANDROID_NDK/toolchains/arm-eabi-*/prebuilt/linux-x86/bin`:$PATH
export PATH

if [ ! -f Makefile.in ]; then
	echo ""; echo "*** Running autogen.sh ***"; echo ""
	./autogen.sh
fi

if [ ! -f Makefile ]; then
	echo ""; echo "*** Running configure ***"; echo ""
	./configure \
		PKG_CONFIG=arm-eabi-pkgconfig \
		RANLIB=arm-eabi-ranlib \
		AR=arm-eabi-ar \
		CC="arm-eabi-gcc -L$ANDROID_PLATFORM/usr/lib -L. -I$ANDROID_PLATFORM/usr/include" \
		CXX=arm-eabi-g++ \
		--host=arm-eabi-linux_android \
		--enable-avoid-float \
		--enable-avoid-unaligned \
		--enable-cache-size=20971520 \
		--enable-svg2png-scaling=8,16,32,48,64,96 \
		--enable-svg2png-scaling-nav=59 \
		--enable-svg2png-scaling-flag=32 \
		--with-xslts=android,plugin_menu,pedestrian_button,pedestrian \
		--with-saxon=saxonb-xslt \
		--enable-transformation-roll \
		--enable-plugin-pedestrian \
		--with-android-permissions=CAMERA \
		--with-android-project=android-$ANDROID_API_LVL
fi

set -e

echo ""; echo "*** Running make ***"; echo ""
make

echo ""; echo "*** Running make apkg ***"; echo ""
cd navit
make apkg
cd - > /dev/null

apk=`pwd`/navit/android/bin/Navit-debug.apk
if [ -f $apk ]; then
	echo "Great - looks like it worked! The result is"; echo ""
	ls -l $apk
	echo ""
else
	echo "This shouldn't happen! Something went terribly wrong..."
fi