1
dnl This Source Code Form is subject to the terms of the Mozilla Public
2
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
3
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
AC_DEFUN([MOZ_ANDROID_NDK],
8
MOZ_ARG_WITH_STRING(android-ndk,
9
[ --with-android-ndk=DIR
10
location where the Android NDK can be found],
13
MOZ_ARG_WITH_STRING(android-toolchain,
14
[ --with-android-toolchain=DIR
15
location of the android toolchain],
16
android_toolchain=$withval)
18
dnl default android_version is different per target cpu
28
MOZ_ARG_WITH_STRING(android-version,
29
[ --with-android-version=VER
30
android platform version, default 5 for arm, 9 for x86/mips],
31
android_version=$withval)
33
MOZ_ARG_WITH_STRING(android-platform,
34
[ --with-android-platform=DIR
35
location of platform dir],
36
android_platform=$withval)
39
arm-linux*-android*|*-linuxandroid*)
40
android_tool_prefix="arm-linux-androideabi"
43
android_tool_prefix="i686-android-linux"
46
android_tool_prefix="mipsel-linux-android"
49
android_tool_prefix="$target_os"
54
*-android*|*-linuxandroid*)
55
if test -z "$android_ndk" ; then
56
AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
59
if test -z "$android_toolchain" ; then
60
AC_MSG_CHECKING([for android toolchain directory])
62
kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
66
target_name=arm-linux-androideabi-4.4.3
72
target_name=mipsel-linux-android-4.4.3
75
android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
77
if test -d "$android_toolchain" ; then
78
AC_MSG_RESULT([$android_toolchain])
80
AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
84
if test -z "$android_platform" ; then
85
AC_MSG_CHECKING([for android platform directory])
99
android_platform="$android_ndk"/platforms/android-"$android_version"/arch-"$target_name"
101
if test -d "$android_platform" ; then
102
AC_MSG_RESULT([$android_platform])
104
AC_MSG_ERROR([not found. You have to specify --with-android-platform=/path/to/ndk/platform.])
109
TOOLCHAIN_PREFIX="$android_toolchain/bin/$android_tool_prefix-"
110
AS="$android_toolchain"/bin/"$android_tool_prefix"-as
111
CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
112
CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
113
CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
114
LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
115
AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
116
RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
117
STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
118
OBJCOPY="$android_toolchain"/bin/"$android_tool_prefix"-objcopy
120
CPPFLAGS="-isystem $android_platform/usr/include $CPPFLAGS"
121
CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
122
CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS"
123
ASFLAGS="-isystem $android_platform/usr/include -DANDROID $ASFLAGS"
125
dnl Add -llog by default, since we use it all over the place.
126
dnl Add --allow-shlib-undefined, because libGLESv2 links to an
127
dnl undefined symbol (present on the hardware, just not in the
129
LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform -llog -Wl,--allow-shlib-undefined $LDFLAGS"
130
dnl prevent cross compile section from using these flags as host flags
131
if test -z "$HOST_CPPFLAGS" ; then
134
if test -z "$HOST_CFLAGS" ; then
137
if test -z "$HOST_CXXFLAGS" ; then
140
if test -z "$HOST_LDFLAGS" ; then
144
ANDROID_NDK="${android_ndk}"
145
ANDROID_TOOLCHAIN="${android_toolchain}"
146
ANDROID_PLATFORM="${android_platform}"
147
ANDROID_VERSION="${android_version}"
150
AC_DEFINE_UNQUOTED(ANDROID_VERSION, $android_version)
151
AC_SUBST(ANDROID_VERSION)
153
AC_SUBST(ANDROID_NDK)
154
AC_SUBST(ANDROID_TOOLCHAIN)
155
AC_SUBST(ANDROID_PLATFORM)
162
AC_DEFUN([MOZ_ANDROID_STLPORT],
165
if test "$OS_TARGET" = "Android" -a -z "$gonkdir"; then
166
case "${CPU_ARCH}-${MOZ_ARCH}" in
168
ANDROID_CPU_ARCH=armeabi-v7a
171
ANDROID_CPU_ARCH=armeabi
176
mips-*) # When target_cpu is mipsel, CPU_ARCH is mips
177
ANDROID_CPU_ARCH=mips
181
if test -z "$STLPORT_CPPFLAGS$STLPORT_LDFLAGS$STLPORT_LIBS"; then
182
if test -e "$android_ndk/sources/cxx-stl/stlport/src/iostream.cpp" ; then
183
if test -e "$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a"; then
184
STLPORT_LDFLAGS="-L$_objdir/build/stlport -L$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
185
elif test -e "$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a"; then
186
STLPORT_LDFLAGS="-L$_objdir/build/stlport -L$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
188
AC_MSG_ERROR([Couldn't find path to stlport in the android ndk])
190
STLPORT_SOURCES="$android_ndk/sources/cxx-stl/stlport"
191
STLPORT_CPPFLAGS="-I$_objdir/build/stlport -I$android_ndk/sources/cxx-stl/stlport/stlport"
192
STLPORT_LIBS="-lstlport_static"
193
elif test "$target" != "arm-android-eabi"; then
194
dnl fail if we're not building with NDKr4
195
AC_MSG_ERROR([Couldn't find path to stlport in the android ndk])
198
CXXFLAGS="$CXXFLAGS $STLPORT_CPPFLAGS"
199
LDFLAGS="$LDFLAGS $STLPORT_LDFLAGS"
200
LIBS="$LIBS $STLPORT_LIBS"
202
AC_SUBST([STLPORT_SOURCES])
206
AC_DEFUN([MOZ_ANDROID_SDK],
209
MOZ_ARG_WITH_STRING(android-sdk,
210
[ --with-android-sdk=DIR
211
location where the Android SDK can be found (base directory, e.g. .../android/platforms/android-6)],
212
android_sdk=$withval)
215
*-android*|*-linuxandroid*)
216
if test -z "$android_sdk" ; then
217
AC_MSG_ERROR([You must specify --with-android-sdk=/path/to/sdk when targeting Android.])
219
if ! test -e "$android_sdk"/source.properties ; then
220
AC_MSG_ERROR([The path in --with-android-sdk isn't valid (source.properties hasn't been found).])
223
# Get the api level from "$android_sdk"/source.properties.
224
android_api_level=`$AWK -F = changequote(<<, >>)'<<$>>1 == "AndroidVersion.ApiLevel" {print <<$>>2}'changequote([, ]) "$android_sdk"/source.properties`
226
if test -z "$android_api_level" ; then
227
AC_MSG_ERROR([Unexpected error: no AndroidVersion.ApiLevel field has been found in source.properties.])
230
if ! test "$android_api_level" -eq "$android_api_level" ; then
231
AC_MSG_ERROR([Unexpected error: the found android api value isn't a number! (found $android_api_level)])
234
if test $android_api_level -lt $1 ; then
235
AC_MSG_ERROR([The given Android SDK provides API level $android_api_level ($1 or higher required).])
239
android_platform_tools="$android_sdk"/../../platform-tools
240
if test ! -d "$android_platform_tools" ; then
241
android_platform_tools="$android_sdk"/tools # SDK Tools < r8
243
ANDROID_SDK="${android_sdk}"
244
ANDROID_PLATFORM_TOOLS="${android_platform_tools}"
245
AC_SUBST(ANDROID_SDK)
246
AC_SUBST(ANDROID_PLATFORM_TOOLS)