build/autoconf/android.m4

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 dnl This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4
michael@0 5 AC_DEFUN([MOZ_ANDROID_NDK],
michael@0 6 [
michael@0 7
michael@0 8 MOZ_ARG_WITH_STRING(android-ndk,
michael@0 9 [ --with-android-ndk=DIR
michael@0 10 location where the Android NDK can be found],
michael@0 11 android_ndk=$withval)
michael@0 12
michael@0 13 MOZ_ARG_WITH_STRING(android-toolchain,
michael@0 14 [ --with-android-toolchain=DIR
michael@0 15 location of the android toolchain],
michael@0 16 android_toolchain=$withval)
michael@0 17
michael@0 18 MOZ_ARG_WITH_STRING(android-gnu-compiler-version,
michael@0 19 [ --with-android-gnu-compiler-version=VER
michael@0 20 gnu compiler version to use],
michael@0 21 android_gnu_compiler_version=$withval)
michael@0 22
michael@0 23 MOZ_ARG_ENABLE_BOOL(android-libstdcxx,
michael@0 24 [ --enable-android-libstdcxx
michael@0 25 use GNU libstdc++ instead of STLPort],
michael@0 26 MOZ_ANDROID_LIBSTDCXX=1,
michael@0 27 MOZ_ANDROID_LIBSTDCXX= )
michael@0 28
michael@0 29 define([MIN_ANDROID_VERSION], [9])
michael@0 30 android_version=MIN_ANDROID_VERSION
michael@0 31
michael@0 32 MOZ_ARG_WITH_STRING(android-version,
michael@0 33 [ --with-android-version=VER
michael@0 34 android platform version, default] MIN_ANDROID_VERSION,
michael@0 35 android_version=$withval)
michael@0 36
michael@0 37 if test $android_version -lt MIN_ANDROID_VERSION ; then
michael@0 38 AC_MSG_ERROR([--with-android-version must be at least MIN_ANDROID_VERSION.])
michael@0 39 fi
michael@0 40
michael@0 41 case "$target" in
michael@0 42 arm-linux*-android*|*-linuxandroid*)
michael@0 43 android_tool_prefix="arm-linux-androideabi"
michael@0 44 ;;
michael@0 45 i?86-*android*)
michael@0 46 android_tool_prefix="i686-linux-android"
michael@0 47 ;;
michael@0 48 mipsel-*android*)
michael@0 49 android_tool_prefix="mipsel-linux-android"
michael@0 50 ;;
michael@0 51 *)
michael@0 52 android_tool_prefix="$target_os"
michael@0 53 ;;
michael@0 54 esac
michael@0 55
michael@0 56 case "$target" in
michael@0 57 *-android*|*-linuxandroid*)
michael@0 58 if test -z "$android_ndk" ; then
michael@0 59 AC_MSG_ERROR([You must specify --with-android-ndk=/path/to/ndk when targeting Android.])
michael@0 60 fi
michael@0 61
michael@0 62 if test -z "$android_toolchain" ; then
michael@0 63 AC_MSG_CHECKING([for android toolchain directory])
michael@0 64
michael@0 65 kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
michael@0 66
michael@0 67 for version in $android_gnu_compiler_version 4.7 4.6 4.4.3 ; do
michael@0 68 case "$target_cpu" in
michael@0 69 arm)
michael@0 70 target_name=arm-linux-androideabi-$version
michael@0 71 ;;
michael@0 72 i?86)
michael@0 73 target_name=x86-$version
michael@0 74 ;;
michael@0 75 mipsel)
michael@0 76 target_name=mipsel-linux-android-$version
michael@0 77 ;;
michael@0 78 *)
michael@0 79 AC_MSG_ERROR([target cpu is not supported])
michael@0 80 ;;
michael@0 81 esac
michael@0 82 case "$host_cpu" in
michael@0 83 i*86)
michael@0 84 android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
michael@0 85 ;;
michael@0 86 x86_64)
michael@0 87 android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86_64
michael@0 88 if ! test -d "$android_toolchain" ; then
michael@0 89 android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
michael@0 90 fi
michael@0 91 ;;
michael@0 92 *)
michael@0 93 AC_MSG_ERROR([No known toolchain for your host cpu])
michael@0 94 ;;
michael@0 95 esac
michael@0 96 if test -d "$android_toolchain" ; then
michael@0 97 android_gnu_compiler_version=$version
michael@0 98 break
michael@0 99 elif test -n "$android_gnu_compiler_version" ; then
michael@0 100 AC_MSG_ERROR([not found. Your --with-android-gnu-compiler-version may be wrong.])
michael@0 101 fi
michael@0 102 done
michael@0 103
michael@0 104 if test -z "$android_gnu_compiler_version" ; then
michael@0 105 AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
michael@0 106 else
michael@0 107 AC_MSG_RESULT([$android_toolchain])
michael@0 108 fi
michael@0 109 NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-android-toolchain=$android_toolchain"
michael@0 110 fi
michael@0 111
michael@0 112 NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-android-version=$android_version"
michael@0 113
michael@0 114 AC_MSG_CHECKING([for android platform directory])
michael@0 115
michael@0 116 case "$target_cpu" in
michael@0 117 arm)
michael@0 118 target_name=arm
michael@0 119 ;;
michael@0 120 i?86)
michael@0 121 target_name=x86
michael@0 122 ;;
michael@0 123 mipsel)
michael@0 124 target_name=mips
michael@0 125 ;;
michael@0 126 esac
michael@0 127
michael@0 128 android_platform="$android_ndk"/platforms/android-"$android_version"/arch-"$target_name"
michael@0 129
michael@0 130 if test -d "$android_platform" ; then
michael@0 131 AC_MSG_RESULT([$android_platform])
michael@0 132 else
michael@0 133 AC_MSG_ERROR([not found. Please check your NDK. With the current configuration, it should be in $android_platform])
michael@0 134 fi
michael@0 135
michael@0 136 dnl Old NDK support. If minimum requirement is changed to NDK r8b,
michael@0 137 dnl please remove this.
michael@0 138 case "$target_cpu" in
michael@0 139 i?86)
michael@0 140 if ! test -e "$android_toolchain"/bin/"$android_tool_prefix"-gcc; then
michael@0 141 dnl Old NDK toolchain name
michael@0 142 android_tool_prefix="i686-android-linux"
michael@0 143 fi
michael@0 144 ;;
michael@0 145 esac
michael@0 146
michael@0 147 dnl set up compilers
michael@0 148 TOOLCHAIN_PREFIX="$android_toolchain/bin/$android_tool_prefix-"
michael@0 149 AS="$android_toolchain"/bin/"$android_tool_prefix"-as
michael@0 150 if test -z "$CC"; then
michael@0 151 CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
michael@0 152 fi
michael@0 153 if test -z "$CXX"; then
michael@0 154 CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
michael@0 155 fi
michael@0 156 if test -z "$CPP"; then
michael@0 157 CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
michael@0 158 fi
michael@0 159 LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
michael@0 160 AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
michael@0 161 RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
michael@0 162 STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
michael@0 163 OBJCOPY="$android_toolchain"/bin/"$android_tool_prefix"-objcopy
michael@0 164
michael@0 165 CPPFLAGS="-idirafter $android_platform/usr/include $CPPFLAGS"
michael@0 166 CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
michael@0 167 CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS"
michael@0 168 ASFLAGS="-idirafter $android_platform/usr/include -DANDROID $ASFLAGS"
michael@0 169
michael@0 170 dnl Add -llog by default, since we use it all over the place.
michael@0 171 dnl Add --allow-shlib-undefined, because libGLESv2 links to an
michael@0 172 dnl undefined symbol (present on the hardware, just not in the
michael@0 173 dnl NDK.)
michael@0 174 LDFLAGS="-mandroid -L$android_platform/usr/lib -Wl,-rpath-link=$android_platform/usr/lib --sysroot=$android_platform -llog -Wl,--allow-shlib-undefined $LDFLAGS"
michael@0 175 dnl prevent cross compile section from using these flags as host flags
michael@0 176 if test -z "$HOST_CPPFLAGS" ; then
michael@0 177 HOST_CPPFLAGS=" "
michael@0 178 fi
michael@0 179 if test -z "$HOST_CFLAGS" ; then
michael@0 180 HOST_CFLAGS=" "
michael@0 181 fi
michael@0 182 if test -z "$HOST_CXXFLAGS" ; then
michael@0 183 HOST_CXXFLAGS=" "
michael@0 184 fi
michael@0 185 if test -z "$HOST_LDFLAGS" ; then
michael@0 186 HOST_LDFLAGS=" "
michael@0 187 fi
michael@0 188
michael@0 189 ANDROID_NDK="${android_ndk}"
michael@0 190 ANDROID_TOOLCHAIN="${android_toolchain}"
michael@0 191 ANDROID_PLATFORM="${android_platform}"
michael@0 192
michael@0 193 AC_DEFINE(ANDROID)
michael@0 194 AC_SUBST(ANDROID_NDK)
michael@0 195 AC_SUBST(ANDROID_TOOLCHAIN)
michael@0 196 AC_SUBST(ANDROID_PLATFORM)
michael@0 197
michael@0 198 ;;
michael@0 199 esac
michael@0 200
michael@0 201 ])
michael@0 202
michael@0 203 AC_DEFUN([MOZ_ANDROID_STLPORT],
michael@0 204 [
michael@0 205
michael@0 206 if test "$OS_TARGET" = "Android" -a -z "$gonkdir"; then
michael@0 207 case "${CPU_ARCH}-${MOZ_ARCH}" in
michael@0 208 arm-armv7*)
michael@0 209 ANDROID_CPU_ARCH=armeabi-v7a
michael@0 210 ;;
michael@0 211 arm-*)
michael@0 212 ANDROID_CPU_ARCH=armeabi
michael@0 213 ;;
michael@0 214 x86-*)
michael@0 215 ANDROID_CPU_ARCH=x86
michael@0 216 ;;
michael@0 217 mips-*) # When target_cpu is mipsel, CPU_ARCH is mips
michael@0 218 ANDROID_CPU_ARCH=mips
michael@0 219 ;;
michael@0 220 esac
michael@0 221
michael@0 222 AC_SUBST(ANDROID_CPU_ARCH)
michael@0 223
michael@0 224 if test -z "$STLPORT_CPPFLAGS$STLPORT_LDFLAGS$STLPORT_LIBS"; then
michael@0 225 if test -n "$MOZ_ANDROID_LIBSTDCXX" ; then
michael@0 226 if test -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/libs/$ANDROID_CPU_ARCH/libgnustl_static.a"; then
michael@0 227 # android-ndk-r8b
michael@0 228 STLPORT_LIBS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/libs/$ANDROID_CPU_ARCH/ -lgnustl_static"
michael@0 229 STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/libs/$ANDROID_CPU_ARCH/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/include/backward"
michael@0 230 elif test -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/libgnustl_static.a"; then
michael@0 231 # android-ndk-r7, android-ndk-r7b, android-ndk-r8
michael@0 232 STLPORT_LIBS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/ -lgnustl_static"
michael@0 233 STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/include"
michael@0 234 elif test -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/libstdc++.a"; then
michael@0 235 # android-ndk-r5c, android-ndk-r6, android-ndk-r6b
michael@0 236 STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/include"
michael@0 237 STLPORT_LIBS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/ -lstdc++"
michael@0 238 else
michael@0 239 AC_MSG_ERROR([Couldn't find path to gnu-libstdc++ in the android ndk])
michael@0 240 fi
michael@0 241 else
michael@0 242 STLPORT_CPPFLAGS="-isystem $_topsrcdir/build/stlport/stlport -isystem $android_ndk/sources/cxx-stl/system/include"
michael@0 243 STLPORT_LIBS="$_objdir/build/stlport/libstlport_static.a -static-libstdc++"
michael@0 244 fi
michael@0 245 fi
michael@0 246 CXXFLAGS="$CXXFLAGS $STLPORT_CPPFLAGS"
michael@0 247 fi
michael@0 248 AC_SUBST([MOZ_ANDROID_LIBSTDCXX])
michael@0 249 AC_SUBST([STLPORT_LIBS])
michael@0 250
michael@0 251 ])
michael@0 252
michael@0 253 AC_DEFUN([MOZ_ANDROID_SDK],
michael@0 254 [
michael@0 255
michael@0 256 MOZ_ARG_WITH_STRING(android-sdk,
michael@0 257 [ --with-android-sdk=DIR
michael@0 258 location where the Android SDK can be found (base directory, e.g. .../android/platforms/android-6)],
michael@0 259 android_sdk=$withval)
michael@0 260
michael@0 261 android_sdk_root=${withval%/platforms/android-*}
michael@0 262
michael@0 263 case "$target" in
michael@0 264 *-android*|*-linuxandroid*)
michael@0 265 if test -z "$android_sdk" ; then
michael@0 266 AC_MSG_ERROR([You must specify --with-android-sdk=/path/to/sdk when targeting Android.])
michael@0 267 else
michael@0 268 if ! test -e "$android_sdk"/source.properties ; then
michael@0 269 AC_MSG_ERROR([The path in --with-android-sdk isn't valid (source.properties hasn't been found).])
michael@0 270 fi
michael@0 271
michael@0 272 # Get the api level from "$android_sdk"/source.properties.
michael@0 273 ANDROID_TARGET_SDK=`$AWK -F = changequote(<<, >>)'<<$>>1 == "AndroidVersion.ApiLevel" {print <<$>>2}'changequote([, ]) "$android_sdk"/source.properties`
michael@0 274
michael@0 275 if test -z "$ANDROID_TARGET_SDK" ; then
michael@0 276 AC_MSG_ERROR([Unexpected error: no AndroidVersion.ApiLevel field has been found in source.properties.])
michael@0 277 fi
michael@0 278
michael@0 279 AC_DEFINE_UNQUOTED(ANDROID_TARGET_SDK,$ANDROID_TARGET_SDK)
michael@0 280 AC_SUBST(ANDROID_TARGET_SDK)
michael@0 281
michael@0 282 if ! test "$ANDROID_TARGET_SDK" -eq "$ANDROID_TARGET_SDK" ; then
michael@0 283 AC_MSG_ERROR([Unexpected error: the found android api value isn't a number! (found $ANDROID_TARGET_SDK)])
michael@0 284 fi
michael@0 285
michael@0 286 if test $ANDROID_TARGET_SDK -lt $1 ; then
michael@0 287 AC_MSG_ERROR([The given Android SDK provides API level $ANDROID_TARGET_SDK ($1 or higher required).])
michael@0 288 fi
michael@0 289 fi
michael@0 290
michael@0 291 android_tools="$android_sdk_root"/tools
michael@0 292 android_platform_tools="$android_sdk_root"/platform-tools
michael@0 293 if test ! -d "$android_platform_tools" ; then
michael@0 294 android_platform_tools="$android_sdk"/tools # SDK Tools < r8
michael@0 295 fi
michael@0 296
michael@0 297 dnl The build tools got moved around to different directories in SDK
michael@0 298 dnl Tools r22. Try to locate them. This is awful, but, from
michael@0 299 dnl http://stackoverflow.com/a/4495368, the following sorts versions
michael@0 300 dnl of the form x.y.z.a.b from newest to oldest:
michael@0 301 dnl sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr
michael@0 302 dnl We want to favour the newer versions that start with 'android-';
michael@0 303 dnl that's what the sed is about.
michael@0 304 dnl We might iterate over directories that aren't build-tools at all;
michael@0 305 dnl we use the presence of aapt as a marker.
michael@0 306 AC_MSG_CHECKING([for android build-tools directory])
michael@0 307 android_build_tools=""
michael@0 308 for suffix in `ls "$android_sdk_root/build-tools" | sed -e "s,android-,999.," | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr`; do
michael@0 309 tools_directory=`echo "$android_sdk_root/build-tools/$suffix" | sed -e "s,999.,android-,"`
michael@0 310 if test -d "$tools_directory" -a -f "$tools_directory/aapt"; then
michael@0 311 android_build_tools="$tools_directory"
michael@0 312 break
michael@0 313 fi
michael@0 314 done
michael@0 315 if test -z "$android_build_tools" ; then
michael@0 316 android_build_tools="$android_platform_tools" # SDK Tools < r22
michael@0 317 fi
michael@0 318
michael@0 319 if test -d "$android_build_tools" -a -f "$android_build_tools/aapt"; then
michael@0 320 AC_MSG_RESULT([$android_build_tools])
michael@0 321 else
michael@0 322 AC_MSG_ERROR([not found. Please check your SDK for the subdirectory of build-tools. With the current configuration, it should be in $android_sdk_root/build_tools])
michael@0 323 fi
michael@0 324
michael@0 325 ANDROID_SDK="${android_sdk}"
michael@0 326 ANDROID_SDK_ROOT="${android_sdk_root}"
michael@0 327 if test -e "${ANDROID_SDK_ROOT}/extras/android/compatibility/v4/android-support-v4.jar" ; then
michael@0 328 ANDROID_COMPAT_LIB="${ANDROID_SDK_ROOT}/extras/android/compatibility/v4/android-support-v4.jar"
michael@0 329 else
michael@0 330 ANDROID_COMPAT_LIB="${ANDROID_SDK_ROOT}/extras/android/support/v4/android-support-v4.jar";
michael@0 331 fi
michael@0 332 ANDROID_TOOLS="${android_tools}"
michael@0 333 ANDROID_PLATFORM_TOOLS="${android_platform_tools}"
michael@0 334 ANDROID_BUILD_TOOLS="${android_build_tools}"
michael@0 335 AC_SUBST(ANDROID_SDK_ROOT)
michael@0 336 AC_SUBST(ANDROID_SDK)
michael@0 337 AC_SUBST(ANDROID_COMPAT_LIB)
michael@0 338 if ! test -e $ANDROID_COMPAT_LIB ; then
michael@0 339 AC_MSG_ERROR([You must download the Android support library when targeting Android. Run the Android SDK tool and install Android Support Library under Extras. See https://developer.android.com/tools/extras/support-library.html for more info. (looked for $ANDROID_COMPAT_LIB)])
michael@0 340 fi
michael@0 341
michael@0 342 dnl Google has a history of moving the Android tools around. We don't
michael@0 343 dnl care where they are, so let's try to find them anywhere we can.
michael@0 344 ALL_ANDROID_TOOLS_PATHS="$ANDROID_TOOLS:$ANDROID_BUILD_TOOLS:$ANDROID_PLATFORM_TOOLS"
michael@0 345 MOZ_PATH_PROG(ZIPALIGN, zipalign, :, [$ALL_ANDROID_TOOLS_PATHS])
michael@0 346 MOZ_PATH_PROG(DX, dx, :, [$ALL_ANDROID_TOOLS_PATHS])
michael@0 347 MOZ_PATH_PROG(AAPT, aapt, :, [$ALL_ANDROID_TOOLS_PATHS])
michael@0 348 MOZ_PATH_PROG(AIDL, aidl, :, [$ALL_ANDROID_TOOLS_PATHS])
michael@0 349 MOZ_PATH_PROG(ADB, adb, :, [$ALL_ANDROID_TOOLS_PATHS])
michael@0 350
michael@0 351 if test -z "$ZIPALIGN" -o "$ZIPALIGN" = ":"; then
michael@0 352 AC_MSG_ERROR([The program zipalign was not found. Use --with-android-sdk={android-sdk-dir}.])
michael@0 353 fi
michael@0 354 if test -z "$DX" -o "$DX" = ":"; then
michael@0 355 AC_MSG_ERROR([The program dx was not found. Use --with-android-sdk={android-sdk-dir}.])
michael@0 356 fi
michael@0 357 if test -z "$AAPT" -o "$AAPT" = ":"; then
michael@0 358 AC_MSG_ERROR([The program aapt was not found. Use --with-android-sdk={android-sdk-dir}.])
michael@0 359 fi
michael@0 360 if test -z "$AIDL" -o "$AIDL" = ":"; then
michael@0 361 AC_MSG_ERROR([The program aidl was not found. Use --with-android-sdk={android-sdk-dir}.])
michael@0 362 fi
michael@0 363 if test -z "$ADB" -o "$ADB" = ":"; then
michael@0 364 AC_MSG_ERROR([The program adb was not found. Use --with-android-sdk={android-sdk-dir}.])
michael@0 365 fi
michael@0 366 ;;
michael@0 367 esac
michael@0 368
michael@0 369 ])

mercurial