Bug 1188336 - Enable Mulet TaskCluster Gbu. r=garndt
[gecko.git] / configure.in
blobf76c761739d2065f66b1e93e6a31278e58eb76c4
1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2 dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4:
3 dnl This Source Code Form is subject to the terms of the Mozilla Public
4 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
5 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 dnl Process this file with autoconf to produce a configure script.
8 dnl ========================================================
10 AC_PREREQ(2.13)
11 AC_INIT(config/config.mk)
12 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
13 AC_CANONICAL_SYSTEM
14 TARGET_CPU="${target_cpu}"
15 TARGET_VENDOR="${target_vendor}"
16 TARGET_OS="${target_os}"
18 dnl ========================================================
19 dnl =
20 dnl = Don't change the following two lines.  Doing so breaks:
21 dnl =
22 dnl = CFLAGS="-foo" ./configure
23 dnl =
24 dnl ========================================================
25 CFLAGS="${CFLAGS=}"
26 CPPFLAGS="${CPPFLAGS=}"
27 CXXFLAGS="${CXXFLAGS=}"
28 LDFLAGS="${LDFLAGS=}"
29 HOST_CFLAGS="${HOST_CFLAGS=}"
30 HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
31 HOST_LDFLAGS="${HOST_LDFLAGS=}"
32 RUSTFLAGS="${RUSTFLAGS=}"
34 dnl ========================================================
35 dnl = Preserve certain environment flags passed to configure
36 dnl = We want sub projects to receive the same flags
37 dnl = untainted by this configure script
38 dnl ========================================================
39 _SUBDIR_CC="$CC"
40 _SUBDIR_CXX="$CXX"
41 _SUBDIR_CFLAGS="$CFLAGS"
42 _SUBDIR_CPPFLAGS="$CPPFLAGS"
43 _SUBDIR_CXXFLAGS="$CXXFLAGS"
44 _SUBDIR_LDFLAGS="$LDFLAGS"
45 _SUBDIR_HOST_CC="$HOST_CC"
46 _SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
47 _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
48 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
49 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
51 dnl Set the version number of the libs included with mozilla
52 dnl ========================================================
53 MOZJPEG=62
54 MOZPNG=10617
55 NSPR_VERSION=4
56 NSPR_MINVER=4.10.8
57 NSS_VERSION=3
59 dnl Set the minimum version of toolkit libs used by mozilla
60 dnl ========================================================
61 GLIB_VERSION=2.22
62 # 2_26 is the earliest version we can set GLIB_VERSION_MIN_REQUIRED.
63 # The macro won't be used when compiling with earlier versions anyway.
64 GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26
65 GIO_VERSION=2.22
66 PERL_VERSION=5.006
67 CAIRO_VERSION=1.10
68 PANGO_VERSION=1.22.0
69 GTK2_VERSION=2.18.0
70 GTK3_VERSION=3.4.0
71 WINDRES_VERSION=2.14.90
72 W32API_VERSION=3.14
73 GNOMEUI_VERSION=2.2.0
74 GCONF_VERSION=1.2.1
75 STARTUP_NOTIFICATION_VERSION=0.8
76 DBUS_VERSION=0.60
77 SQLITE_VERSION=3.8.10.1
79 MSMANIFEST_TOOL=
81 dnl Set various checks
82 dnl ========================================================
83 MISSING_X=
84 AC_PROG_AWK
86 dnl Initialize the Pthread test variables early so they can be
87 dnl  overridden by each platform.
88 dnl ========================================================
89 MOZ_USE_PTHREADS=
90 _PTHREAD_LDFLAGS=""
92 dnl Do not allow objdir == srcdir builds.
93 dnl ==============================================================
94 _topsrcdir=`cd \`dirname $0\`; pwd`
95 _objdir=`pwd`
98 dnl TODO Don't exempt L10N builds once bug 842760 is resolved.
99 if test "$_topsrcdir" = "$_objdir" -a "${with_l10n_base+set}" != set; then
100   echo "  ***"
101   echo "  * Building directly in the main source directory is not allowed."
102   echo "  *"
103   echo "  * To build, you must run configure from a separate directory"
104   echo "  * (referred to as an object directory)."
105   echo "  *"
106   echo "  * If you are building with a mozconfig, you will need to change your"
107   echo "  * mozconfig to point to a different object directory."
108   echo "  ***"
109   exit 1
112 # Check for a couple representative files in the source tree
113 _conflict_files=
114 for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
115   if test -f $file; then
116     _conflict_files="$_conflict_files $file"
117   fi
118 done
119 if test "$_conflict_files"; then
120   echo "***"
121   echo "*   Your source tree contains these files:"
122   for file in $_conflict_files; do
123     echo "*         $file"
124   done
125   cat 1>&2 <<-EOF
126   *   This indicates that you previously built in the source tree.
127   *   A source tree build can confuse the separate objdir build.
128   *
129   *   To clean up the source tree:
130   *     1. cd $_topsrcdir
131   *     2. gmake distclean
132   ***
134   exit 1
135   break
137 MOZ_BUILD_ROOT=`pwd -W 2>/dev/null || pwd`
139 MOZ_PYTHON
141 MOZ_DEFAULT_COMPILER
143 COMPILE_ENVIRONMENT=1
144 MOZ_ARG_DISABLE_BOOL(compile-environment,
145 [  --disable-compile-environment
146                           Disable compiler/library checks.],
147     COMPILE_ENVIRONMENT= )
148 AC_SUBST(COMPILE_ENVIRONMENT)
150 MOZ_ARG_WITH_STRING(l10n-base,
151 [  --with-l10n-base=DIR    path to l10n repositories],
152     L10NBASEDIR=$withval)
153 if test -n "$L10NBASEDIR"; then
154     if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
155         AC_MSG_ERROR([--with-l10n-base must specify a path])
156     elif test -d "$L10NBASEDIR"; then
157         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd`
158     else
159         AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
160     fi
162 AC_SUBST(L10NBASEDIR)
164 dnl Check for Perl first -- needed for win32 SDK checks
165 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
166 if test -z "$PERL" -o "$PERL" = ":"; then
167     AC_MSG_ERROR([perl not found in \$PATH])
170 if test -n "$MOZTTDIR" -a ! -d "$MOZTTDIR" ; then
171     AC_MSG_ERROR([MOZTTDIR '$MOZTTDIR' isn't a valid directory])
174 AC_SUBST(MOZTTDIR)
175 if test -n "$MOZTTDIR" ; then
176     AC_DEFINE(PACKAGE_MOZTT)
179 MOZ_ARG_WITH_STRING(gonk,
180 [  --with-gonk=DIR
181                location of gonk dir],
182     gonkdir=$withval)
184 MOZ_ARG_WITH_STRING(gonk-toolchain-prefix,
185 [  --with-gonk-toolchain-prefix=DIR
186                           prefix to gonk toolchain commands],
187     gonk_toolchain_prefix=$withval)
189 if test -n "$gonkdir" ; then
190     kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
191     android_source="$gonkdir"
192     ANDROID_SOURCE="$android_source"
193     ANDROID_NDK="${ANDROID_SOURCE}/ndk"
194     dnl Default to ICS
195     ANDROID_VERSION=15
196     if test -n "${PLATFORM_SDK_VERSION}"; then
197         ANDROID_VERSION="${PLATFORM_SDK_VERSION}"
198     fi
200     dnl set up compilers
201     TOOLCHAIN_PREFIX="$gonk_toolchain_prefix"
202     AS="$gonk_toolchain_prefix"as
203     CC="$gonk_toolchain_prefix"gcc
204     CXX="$gonk_toolchain_prefix"g++
205     CPP="$gonk_toolchain_prefix"cpp
206     LD="$gonk_toolchain_prefix"ld
207     AR="$gonk_toolchain_prefix"ar
208     RANLIB="$gonk_toolchain_prefix"ranlib
209     STRIP="$gonk_toolchain_prefix"strip
210     OBJCOPY="$gonk_toolchain_prefix"objcopy
212     if ! test -e "$gonkdir/ndk/sources/cxx-stl/stlport/src/iostream.cpp"; then
213         AC_MSG_ERROR([Couldn't find path to stlport sources in the gonk tree])
214     fi
215     STLPORT_CPPFLAGS="-I$_topsrcdir/build/stlport/stlport -I$gonkdir/ndk/sources/cxx-stl/system/include"
217     case "$ANDROID_VERSION" in
218     15)
219         GONK_INCLUDES="-I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/frameworks/base/include -I$gonkdir/frameworks/base/services/camera -I$gonkdir/frameworks/base/include/media/ -I$gonkdir/frameworks/base/include/media/stagefright -I$gonkdir/frameworks/base/include/media/stagefright/openmax -I$gonkdir/frameworks/base/media/libstagefright/rtsp -I$gonkdir/frameworks/base/media/libstagefright/include -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib -I$gonkdir/dalvik/libnativehelper/include/nativehelper"
220         MOZ_B2G_BT=1
221         MOZ_B2G_BT_BLUEZ=1
222         MOZ_NFC=1
223         MOZ_B2G_CAMERA=1
224         MOZ_OMX_DECODER=1
225         AC_SUBST(MOZ_OMX_DECODER)
226         MOZ_RTSP=1
227         MOZ_FMP4=1
228         MOZ_SECUREELEMENT=1
229         ;;
230     17|18)
231         GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include -I$gonkdir/external/mdnsresponder/mDNSShared"
232         if test -d "$gonkdir/external/bluetooth/bluez"; then
233           GONK_INCLUDES="$GONK_INCLUDES -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib"
234             MOZ_B2G_BT=1
235             MOZ_B2G_BT_BLUEZ=1
236         elif test -d "$gonkdir/external/bluetooth/bluedroid"; then
237             MOZ_B2G_BT=1
238             MOZ_B2G_BT_BLUEDROID=1
239             if test -d "$gonkdir/system/bluetoothd"; then
240                 MOZ_B2G_BT_DAEMON=1
241             fi
242         fi
244         MOZ_RTSP=1
245         MOZ_NFC=1
246         MOZ_B2G_CAMERA=1
247         MOZ_OMX_DECODER=1
248         AC_SUBST(MOZ_OMX_DECODER)
249         MOZ_OMX_ENCODER=1
250         AC_SUBST(MOZ_OMX_ENCODER)
251         AC_DEFINE(MOZ_OMX_ENCODER)
252         MOZ_FMP4=1
253         MOZ_SECUREELEMENT=1
254         ;;
255     19)
256         GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include -I$gonkdir/external/mdnsresponder/mDNSShared"
257         MOZ_B2G_CAMERA=1
258         MOZ_B2G_BT=1
259         MOZ_B2G_BT_BLUEDROID=1
260         if test -d "$gonkdir/system/bluetoothd"; then
261             MOZ_B2G_BT_DAEMON=1
262         fi
263         MOZ_NFC=1
264         MOZ_RTSP=1
265         MOZ_OMX_DECODER=1
266         MOZ_OMX_ENCODER=1
267         AC_DEFINE(MOZ_OMX_ENCODER)
268         MOZ_AUDIO_OFFLOAD=1
269         MOZ_SECUREELEMENT=1
270         AC_SUBST(MOZ_AUDIO_OFFLOAD)
271         AC_DEFINE(MOZ_AUDIO_OFFLOAD)
272         MOZ_FMP4=1
273         ;;
274     21|22)
275         GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include -I$gonkdir/external/mdnsresponder/mDNSShared"
276         MOZ_AUDIO_OFFLOAD=1
277         MOZ_OMX_DECODER=1
278         MOZ_OMX_ENCODER=1
279         AC_DEFINE(MOZ_OMX_ENCODER)
280         AC_SUBST(MOZ_AUDIO_OFFLOAD)
281         AC_DEFINE(MOZ_AUDIO_OFFLOAD)
282         MOZ_FMP4=
283         MOZ_B2G_CAMERA=1
284         MOZ_B2G_BT=1
285         MOZ_B2G_BT_BLUEDROID=1
286         if test -d "$gonkdir/system/bluetoothd"; then
287             MOZ_B2G_BT_DAEMON=1
288         fi
289         MOZ_NFC=1
290         MOZ_RTSP=1
291         ;;
292     *)
293         AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION])
294         ;;
295     esac
296     CPPFLAGS="-DANDROID $TARGET_C_INCLUDES -I$gonkdir/system -I$gonkdir/system/core/include -isystem $gonkdir/bionic -I$gonkdir/hardware/libhardware/include -I$gonkdir/external/valgrind/fxos-include $GONK_INCLUDES $CPPFLAGS"
297     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
298     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS $STLPORT_CPPFLAGS"
299     dnl Add -llog by default, since we use it all over the place.
300     LIBS="$LIBS -llog"
302     LDFLAGS="-mandroid -L$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib -Wl,-rpath-link=$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib --sysroot=$gonkdir/out/target/product/$GONK_PRODUCT/obj/ $LDFLAGS"
304     dnl prevent cross compile section from using these flags as host flags
305     if test -z "$HOST_CPPFLAGS" ; then
306         HOST_CPPFLAGS=" "
307     fi
308     if test -z "$HOST_CFLAGS" ; then
309         HOST_CFLAGS=" "
310     fi
311     if test -z "$HOST_CXXFLAGS" ; then
312         HOST_CXXFLAGS=" "
313     fi
314     if test -z "$HOST_LDFLAGS" ; then
315         HOST_LDFLAGS=" "
316     fi
318     AC_DEFINE(ANDROID)
319     AC_DEFINE_UNQUOTED(ANDROID_VERSION, $ANDROID_VERSION)
320     AC_SUBST(ANDROID_VERSION)
321     AC_DEFINE(HAVE_SYS_UIO_H)
322     AC_DEFINE(HAVE_PTHREADS)
323     MOZ_CHROME_FILE_FORMAT=omni
324     direct_nspr_config=1
325 else
326     MOZ_ANDROID_NDK
328     case "$target" in
329     *-android*|*-linuxandroid*)
330         if test -z "$ANDROID_PACKAGE_NAME" ; then
331             ANDROID_PACKAGE_NAME='org.mozilla.$(MOZ_APP_NAME)'
332         fi
333         MOZ_CHROME_FILE_FORMAT=omni
334         ZLIB_DIR=yes
335         ;;
336     *-linux*)
337         AC_PATH_PROG(OBJCOPY,objcopy)
338         ;;
339     esac
342 case "$target" in
343 *-apple-darwin*)
344     MOZ_IOS_SDK
345     ;;
346 esac
348 AC_SUBST(ANDROID_SOURCE)
349 AC_SUBST(ANDROID_PACKAGE_NAME)
350 AC_SUBST(OBJCOPY)
352 dnl ========================================================
353 dnl Checks for compilers.
354 dnl ========================================================
356 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
357 AR_FLAGS='crs $@'
359 if test -z "$COMPILE_ENVIRONMENT"; then
360 if test "$target" != "$host"; then
361 # Assert that we're cross compiling, but don't require a compile toolchain (as
362 # MOZ_CROSS_COMPILER does below).
363 CROSS_COMPILE=1
364 AC_DEFINE(CROSS_COMPILE)
366 fi # !COMPILE_ENVIRONMENT
368 if test "$COMPILE_ENVIRONMENT"; then
370 if test "$target" != "$host"; then
371     MOZ_CROSS_COMPILER
372 else
373     AC_PROG_CC
374     case "$target" in
375     *-mingw*)
376       # Work around the conftest.exe access problem on Windows
377       sleep 2
378     esac
379     AC_PROG_CXX
380     AC_PROG_RANLIB
381     MOZ_PATH_PROGS(AS, $AS as, $CC)
382     AC_CHECK_PROGS(AR, ar, :)
383     AC_CHECK_PROGS(LD, ld, :)
384     AC_CHECK_PROGS(STRIP, strip, :)
385     AC_CHECK_PROGS(WINDRES, windres, :)
386     AC_CHECK_PROGS(OTOOL, otool, :)
387     if test -z "$HOST_CC"; then
388         HOST_CC="$CC"
389     fi
390     if test -z "$HOST_CFLAGS"; then
391         HOST_CFLAGS="$CFLAGS"
392     fi
393     if test -z "$HOST_CXX"; then
394         HOST_CXX="$CXX"
395     fi
396     if test -z "$HOST_CXXFLAGS"; then
397         HOST_CXXFLAGS="$CXXFLAGS"
398     fi
399     if test -z "$HOST_LDFLAGS"; then
400         HOST_LDFLAGS="$LDFLAGS"
401     fi
402     if test -z "$HOST_RANLIB"; then
403         HOST_RANLIB="$RANLIB"
404     fi
405     if test -z "$HOST_AR"; then
406         HOST_AR="$AR"
407     fi
408     if test -z "$HOST_AR_FLAGS"; then
409         HOST_AR_FLAGS="$AR_FLAGS"
410     fi
413 if test -n "$MOZ_WINCONSOLE"; then
414     AC_DEFINE(MOZ_WINCONSOLE)
417 MOZ_TOOL_VARIABLES
419 MOZ_CHECK_COMPILER_WRAPPER
421 MOZ_PATH_PROG(RUSTC, rustc)
422 if test -n "$RUSTC"; then
423   AC_MSG_CHECKING([rustc version])
424   RUSTC_VERSION=`$RUSTC --version | cut -d ' ' -f 2`
425   # Parse out semversion elements.
426   _RUSTC_MAJOR_VERSION=`echo ${RUSTC_VERSION} | cut -d . -f 1`
427   _RUSTC_MINOR_VERSION=`echo ${RUSTC_VERSION} | cut -d . -f 2`
428   _RUSTC_EXTRA_VERSION=`echo ${RUSTC_VERSION} | cut -d . -f 3 | cut -d + -f 1`
429   _RUSTC_PATCH_VERSION=`echo ${_RUSTC_EXTRA_VERSION} | cut -d '-' -f 1`
430   AC_MSG_RESULT([$RUSTC_VERSION (v${_RUSTC_MAJOR_VERSION}.${_RUSTC_MINOR_VERSION}.${_RUSTC_PATCH_VERSION})])
432 MOZ_ARG_ENABLE_BOOL([rust],
433                     [  --enable-rust           Include Rust language sources],
434                     [MOZ_RUST=1],
435                     [MOZ_RUST= ])
436 if test -z "$RUSTC" -a -n "$MOZ_RUST"; then
437   AC_MSG_ERROR([Rust compiler not found.
438     To compile rust language sources, you must have 'rustc' in your path.
439     See http://www.rust-lang.org/ for more information.])
441 if test -n "$MOZ_RUST" && test -z "$_RUSTC_MAJOR_VERSION" -o \
442   "$_RUSTC_MAJOR_VERSION" -lt 1; then
443   AC_MSG_ERROR([Rust compiler ${RUSTC_VERSION} is too old.
444     To compile Rust language sources please install at least
445     version 1.0 of the 'rustc' toolchain and make sure it is
446     first in your path.
447     You can verify this by typing 'rustc --version'.])
449 AC_SUBST(MOZ_RUST)
451 dnl ========================================================
452 dnl Check for MacOS deployment target version
453 dnl ========================================================
455 MOZ_ARG_ENABLE_STRING(macos-target,
456                       [  --enable-macos-target=VER (default=10.6)
457                           Set the minimum MacOS version needed at runtime],
458                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
460 case "$target" in
461 *-darwin*)
462     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
463         dnl Use the specified value
464         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
465     else
466         dnl No value specified on the command line or in the environment,
467         dnl use architecture minimum.
468         export MACOSX_DEPLOYMENT_TARGET=10.6
469     fi
470     ;;
471 esac
473 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
475 dnl ========================================================
476 dnl Special MacOS X checks
477 dnl ========================================================
479 if test -n "$MACOSX_DEPLOYMENT_TARGET" -a -n "$MOZ_RUST"; then
480   AC_MSG_CHECKING([rustc compatibility with MacOS X])
481   # Stock rustc doesn't support MacOS X 10.6 or earlier.
482   # https://github.com/rust-lang/rust/issues/25342
483   _MACOSX_TARGET_MINOR=`echo "$MACOSX_DEPLOYMENT_TARGET" | cut -d. -f2`
484   if test "$_MACOSX_TARGET_MINOR" -lt 7; then
485     dnl Test C linkage against rust code to see if the rust
486     dnl toolchain output is compatible.
487     cat > conftest.rs <<EOF
488       [#[no_mangle]]
489       pub extern fn rusty_answer() -> u8 { 42 }
491     ac_try="$RUSTC --crate-type staticlib -o conftest.a conftest.rs >/dev/null"
492     AC_TRY_EVAL(ac_try)
493     save_LDFLAGS=$LDFLAGS
494     LDFLAGS="$LDFLAGS conftest.a -lpthread -lm"
495     AC_TRY_LINK_FUNC([rusty_answer], [
496       AC_MSG_RESULT([$MACOSX_DEPLOYMENT_TARGET is ok with this rustc])
497     ], [
498       AC_MSG_RESULT([cannot link on $MACOSX_DEPLOYMENT_TARGET])
499       MOZ_RUST=
500     ])
501     LDFLAGS=$save_LDFLAGS
502     rm -rf conftest*
503   else
504     AC_MSG_RESULT([$MACOSX_DEPLOYMENT_TARGET is ok])
505   fi
506   if test -z "$MOZ_RUST"; then
507     AC_MSG_ERROR([rustc does not support MacOS X $MACOSX_DEPLOYMENT_TARGET
508       Add 'ac_add_options --enable-macos-target=10.7' (or later)
509       to mozconfig, disable Rust support, or use an alternate toolchain.])
510   fi
513 dnl ========================================================
514 dnl Special win32 checks
515 dnl ========================================================
517 # Target the Windows 8.1 SDK by default
518 WINSDK_TARGETVER=603
519 WINVER=502
521 MOZ_ARG_WITH_STRING(windows-version,
522 [  --with-windows-version=WINSDK_TARGETVER
523                           Windows SDK version to target. Win8.1 (603) is
524                           currently the minimum supported version.],
525   WINSDK_TARGETVER=$withval)
527 # Currently only version 603 is allowed
528 case "$WINSDK_TARGETVER" in
529 603)
530     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
531     ;;
534     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER)]);
535     ;;
536 esac
538 case "$target" in
539 *-mingw*)
540     if test "$GCC" != "yes"; then
541         # Check to see if we are really running in a msvc environemnt
542         _WIN32_MSVC=1
543         AC_CHECK_PROGS(MIDL, midl)
545         # Make sure compilers are valid
546         CFLAGS="$CFLAGS -TC -nologo"
547         CXXFLAGS="$CXXFLAGS -TP -nologo"
548         AC_LANG_SAVE
549         AC_LANG_C
550         AC_TRY_COMPILE([#include <stdio.h>],
551             [ printf("Hello World\n"); ],,
552             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
554         AC_LANG_CPLUSPLUS
555         AC_TRY_COMPILE([#include <new.h>],
556             [ unsigned *test = new unsigned(42); ],,
557             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
558         AC_LANG_RESTORE
560         changequote(,)
561         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
562         changequote([,])
564         # Determine compiler version
565         _CC_MAJOR_VERSION=`echo ${MSVC_VERSION_FULL} | cut -c 1-2`
566         _CC_MINOR_VERSION=`echo ${MSVC_VERSION_FULL} | cut -c 3-4`
567         _CC_BUILD_VERSION=`echo ${MSVC_VERSION_FULL} | cut -c 5-`
568         _MSC_VER=${CC_VERSION}
570         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | cut -c 1-2`
572         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
573             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
574         fi
576         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
577         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
579         if test "$_CC_MAJOR_VERSION" = "18" -a "$_CC_BUILD_VERSION" -ge "30723"; then
580             _CC_SUITE=12
581             MSVS_VERSION=2013
582             MSVC_C_RUNTIME_DLL=msvcr120.dll
583             MSVC_CXX_RUNTIME_DLL=msvcp120.dll
584         elif test "$_CC_MAJOR_VERSION" = "19"; then
585             _CC_SUITE=14
586             MSVS_VERSION=2015
587             MSVC_C_RUNTIME_DLL=vcruntime140.dll
588             MSVC_CXX_RUNTIME_DLL=msvcp140.dll
589             MSVC_APPCRT_DLL=appcrt140.dll
590             MSVC_DESKTOPCRT_DLL=desktopcrt140.dll
592             # -Wv:18 disables all warnings introduced after VS2013
593             # See http://blogs.msdn.com/b/vcblog/archive/2014/11/12/improvements-to-warnings-in-the-c-compiler.aspx
594             CFLAGS="$CFLAGS -Wv:18"
595             CXXFLAGS="$CXXFLAGS -Wv:18"
597             # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
598             CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
600             # https://connect.microsoft.com/VisualStudio/feedback/details/888527/warnings-on-dbghelp-h
601             # for dbghelp.h, imagehlp.h, and shobj.h
602             # C4091: 'typedef ': ignored on left of '' when no variable is declared
603             CFLAGS="$CFLAGS -wd4091"
604             CXXFLAGS="$CXXFLAGS -wd4091"
605         else
606             AC_MSG_ERROR([This version (${_CC_MAJOR_VERSION}.${_CC_MINOR_VERSION}.${_CC_BUILD_VERSION}) of the MSVC compiler is unsupported.
607 You must install Visual C++ 2013 Update 3 or newer in order to build.
608 See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
609         fi
610         AC_SUBST(MSVS_VERSION)
611         AC_SUBST(MSVC_C_RUNTIME_DLL)
612         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
613         AC_SUBST(MSVC_APPCRT_DLL)
614         AC_SUBST(MSVC_DESKTOPCRT_DLL)
616         # Disable SEH on clang-cl because it doesn't implement them yet.
617         if test -z "$CLANG_CL"; then
618             AC_DEFINE(HAVE_SEH_EXCEPTIONS)
619         else
620             # Send our CFLAGS to NSS
621             MOZ_CFLAGS_NSS=1
622             AC_DEFINE_UNQUOTED(GTEST_HAS_SEH, 0)
623         fi
625         if test -n "$WIN32_REDIST_DIR"; then
626           if test ! -d "$WIN32_REDIST_DIR"; then
627             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
628           fi
629           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
630         fi
632         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
633         dnl not something else like "magnetic tape manipulation utility".
634         MSMT_TOOL=`${MT-mt} 2>&1|grep 'Microsoft (R) Manifest Tool'`
635         if test -z "$MSMT_TOOL"; then
636           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
637         fi
639         changequote(,)
640         _MSMT_VER_FILTER='s|.*[^!-~]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
641         changequote([,])
642         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
643         if test -z "$MSMANIFEST_TOOL_VERSION"; then
644           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
645         fi
647         MSMANIFEST_TOOL=1
648         unset MSMT_TOOL
650         # Check linker version
651         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
652         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
653         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
654             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
655         fi
657         INCREMENTAL_LINKER=1
659         # Set midl environment
660         case "$target" in
661         i*86-*)
662             MIDL_FLAGS="${MIDL_FLAGS} -env win32"
663             ;;
664         x86_64-*)
665             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
666             ;;
667         esac
669         unset _MSVC_VER_FILTER
671         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
672             [
673                 AC_LANG_SAVE
674                 AC_LANG_CPLUSPLUS
675                 _SAVE_CXXFLAGS="$CXXFLAGS"
676                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
677                 AC_TRY_COMPILE([#include <exception>],
678                             [std::_Throw(std::exception()); return 0;],
679                             ac_cv_have_std__Throw="yes",
680                             ac_cv_have_std__Throw="no")
681                 CXXFLAGS="$_SAVE_CXXFLAGS"
682                 AC_LANG_RESTORE
683             ])
685         if test "$ac_cv_have_std__Throw" = "yes"; then
686             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
687                            ac_cv_have_dllimport_exception_bug,
688                 [
689                     AC_LANG_SAVE
690                     AC_LANG_CPLUSPLUS
691                     _SAVE_CXXFLAGS="$CXXFLAGS"
692                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
693                     AC_TRY_LINK([#include <vector>],
694                                 [std::vector<int> v; return v.at(1);],
695                                 ac_cv_have_dllimport_exception_bug="no",
696                                 ac_cv_have_dllimport_exception_bug="yes")
697                     CXXFLAGS="$_SAVE_CXXFLAGS"
698                     AC_LANG_RESTORE
699                 ])
700             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
701                 WRAP_STL_INCLUDES=1
702                 MOZ_MSVC_STL_WRAP_Throw=1
703                 AC_DEFINE(MOZ_MSVC_STL_WRAP_Throw)
704             fi
705         else
706             AC_CACHE_CHECK(for overridable _RAISE,
707                            ac_cv_have__RAISE,
708                 [
709                     AC_LANG_SAVE
710                     AC_LANG_CPLUSPLUS
711                     _SAVE_CXXFLAGS="$CXXFLAGS"
712                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
713                     AC_TRY_COMPILE([#include <xstddef>
714                                     #undef _RAISE
715                                     #define _RAISE(x) externallyDefinedFunction((x).what())
716                                     #include <vector>
717                                    ],
718                                    [std::vector<int> v; return v.at(1);],
719                                    ac_cv_have__RAISE="no",
720                                    ac_cv_have__RAISE="yes")
721                     CXXFLAGS="$_SAVE_CXXFLAGS"
722                     AC_LANG_RESTORE
723                 ])
724             if test "$ac_cv_have__RAISE" = "yes"; then
725                 WRAP_STL_INCLUDES=1
726                 MOZ_MSVC_STL_WRAP_RAISE=1
727                 AC_DEFINE(MOZ_MSVC_STL_WRAP_RAISE)
728             else
729                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
730             fi
731         fi
733         if test "$WRAP_STL_INCLUDES" = "1"; then
734             STL_FLAGS='-I$(DIST)/stl_wrappers'
735         fi
736         CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
737         CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
739         MOZ_FIND_WINSDK_VERSION
740     else
741         # Check w32api version
742         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
743         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
744         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
745         AC_TRY_COMPILE([#include <w32api.h>],
746             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
747                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
748                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
749                 #error "test failed."
750             #endif
751             , [ res=yes ], [ res=no ])
752         AC_MSG_RESULT([$res])
753         if test "$res" != "yes"; then
754             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
755         fi
756         # Check windres version
757         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
758         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
759         AC_MSG_RESULT([$_WINDRES_VERSION])
760         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
761         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
762         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
763         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
764         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
765         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
766         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
767                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
768                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
769                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
770                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
771                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
772         then
773             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
774         fi
776         AC_CHECK_PROGS(MIDL, $target-widl widl)
777         if test -n "$MIDL"; then
778             case "$target" in
779             i*86-*)
780                 MIDL_FLAGS="$MIDL_FLAGS --win32 -m32"
781                 ;;
782             x86_64-*)
783                 MIDL_FLAGS="$MIDL_FLAGS --win64 -m64"
784                 ;;
785             esac
786         fi
788         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
789         # causing problems with local implementations with the same name.
790         AC_DEFINE(STRSAFE_NO_DEPRECATE)
792         MOZ_WINSDK_MAXVER=0x06030000
793     fi # !GNU_CC
795     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
796     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
797     # Require OS features provided by IE 6.0 SP2 (XP SP2)
798     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
800     # If the maximum version supported by this SDK is lower than the target
801     # version, error out
802     AC_MSG_CHECKING([for Windows SDK being recent enough])
803     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
804         AC_MSG_RESULT("yes")
805     else
806         AC_MSG_RESULT("no")
807         AC_MSG_ERROR([You are targeting Windows version 0x$MOZ_WINSDK_TARGETVER, but your SDK only supports up to version $MOZ_WINSDK_MAXVER. Install and use an updated SDK, or target a lower version using --with-windows-version. Alternatively, try running the Windows SDK Configuration Tool and selecting a newer SDK. See https://developer.mozilla.org/En/Windows_SDK_versions for more details on fixing this.])
808     fi
810     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
811     # Definitions matching sdkddkver.h
812     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
813     AC_DEFINE_UNQUOTED(MOZ_WINSDK_MAXVER,$MOZ_WINSDK_MAXVER)
814     AC_SUBST(MOZ_WINSDK_MAXVER)
815     ;;
816 esac
818 AC_PROG_CPP
819 AC_PROG_CXXCPP
821 if test -n "$_WIN32_MSVC"; then
822     SKIP_PATH_CHECKS=1
823     SKIP_COMPILER_CHECKS=1
824     SKIP_LIBRARY_CHECKS=1
826     # Since we're skipping compiler and library checks, hard-code
827     # some facts here.
828     AC_DEFINE(HAVE_IO_H)
829     AC_DEFINE(HAVE_SETBUF)
830     AC_DEFINE(HAVE_ISATTY)
833 fi # COMPILE_ENVIRONMENT
835 AC_SUBST(MIDL_FLAGS)
836 AC_SUBST(_MSC_VER)
838 AC_SUBST(GNU_AS)
839 AC_SUBST(GNU_LD)
840 AC_SUBST(GNU_CC)
841 AC_SUBST(GNU_CXX)
842 AC_SUBST(INTEL_CC)
843 AC_SUBST(INTEL_CXX)
845 AC_SUBST(STL_FLAGS)
846 AC_SUBST(WRAP_STL_INCLUDES)
847 AC_SUBST(MOZ_MSVC_STL_WRAP_Throw)
848 AC_SUBST(MOZ_MSVC_STL_WRAP_RAISE)
850 dnl ========================================================
851 dnl Checks for programs.
852 dnl ========================================================
853 AC_PROG_INSTALL
854 AC_PROG_LN_S
856 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
857 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
858 _perl_res=$?
859 AC_MSG_RESULT([$_perl_version])
861 if test "$_perl_res" != 0; then
862     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
865 AC_MSG_CHECKING([for full perl installation])
866 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
867 _perl_res=$?
868 if test "$_perl_res" != 0; then
869     AC_MSG_RESULT([no])
870     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
871 else
872     AC_MSG_RESULT([yes])
875 if test -z "$COMPILE_ENVIRONMENT"; then
876     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
878 AC_SUBST(NSINSTALL_BIN)
880 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
881 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
882 MOZ_PATH_PROGS(UNZIP, unzip)
883 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
884     AC_MSG_ERROR([unzip not found in \$PATH])
886 MOZ_PATH_PROGS(ZIP, zip)
887 if test -z "$ZIP" -o "$ZIP" = ":"; then
888     AC_MSG_ERROR([zip not found in \$PATH])
890 MOZ_PATH_PROG(XARGS, xargs)
891 if test -z "$XARGS" -o "$XARGS" = ":"; then
892     AC_MSG_ERROR([xargs not found in \$PATH .])
895 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
896 AC_SUBST(RPMBUILD)
898 if test "$COMPILE_ENVIRONMENT"; then
900 dnl ========================================================
901 dnl = Mac OS X toolchain support
902 dnl ========================================================
904 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
905 dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
906 dnl when we can run target binaries.
907 AC_SUBST(UNIVERSAL_BINARY)
908 AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
910 MOZ_ARG_WITH_STRING(unify-dist,
911 [  --with-unify-dist=dir   Location of the dist directory to unify with at packaging time (Mac OS X universal build only)],
912     UNIFY_DIST=$withval)
913 if test -n "$UNIVERSAL_BINARY"; then
914     if test -z "$UNIFY_DIST"; then
915         AC_MSG_ERROR([You need to provide the --with-unify-dist=dir argument when performing a universal build])
916     fi
917     case "$UNIFY_DIST" in
918     /*)
919         ;;
920     *)
921         UNIFY_DIST="${MOZ_BUILD_ROOT}/${UNIFY_DIST}"
922         ;;
923     esac
925 AC_SUBST(UNIFY_DIST)
927 dnl ========================================================
928 dnl = Mac OS X SDK support
929 dnl ========================================================
930 MACOS_SDK_DIR=
931 MOZ_ARG_WITH_STRING(macos-sdk,
932 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
933     MACOS_SDK_DIR=$withval)
935 MACOS_PRIVATE_FRAMEWORKS_DIR_DEFAULTED=
936 MOZ_ARG_WITH_STRING(macos-private-frameworks,
937 [  --with-macos-private-frameworks=dir    Location of private frameworks to use (Mac OS X only)],
938     MACOS_PRIVATE_FRAMEWORKS_DIR=$withval,
939     MACOS_PRIVATE_FRAMEWORKS_DIR=/System/Library/PrivateFrameworks
940     MACOS_PRIVATE_FRAMEWORKS_DEFAULTED=1)
942 if test -z "${MACOS_PRIVATE_FRAMEWORKS_DEFAULTED}"; then
943   if test -z "$CROSS_COMPILE"; then
944     AC_MSG_WARN([You should only be using --with-macos-private-frameworks when cross-compiling.])
945   fi
946   if test ! -d "$MACOS_PRIVATE_FRAMEWORKS_DIR"; then
947     AC_MSG_ERROR([PrivateFrameworks directory not found.])
948   fi
951 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
952 AC_SUBST(MACOS_SDK_DIR)
953 AC_SUBST(MACOS_PRIVATE_FRAMEWORKS_DIR)
955 if test "$MACOS_SDK_DIR"; then
956   dnl Sync this section with the ones in NSPR and NSS.
957   dnl Changes to the cross environment here need to be accounted for in
958   dnl the libIDL checks (below) and xpidl build.
960   if test ! -d "$MACOS_SDK_DIR"; then
961     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
962 specify a valid SDK.  SDKs are installed when the optional cross-development
963 tools are selected during the Xcode/Developer Tools installation.])
964   fi
966   CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
967   CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
969   dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
970   CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
971   CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
973   AC_LANG_SAVE
974   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
975   AC_LANG_CPLUSPLUS
976   AC_TRY_COMPILE([#include <new>],[],
977    result=yes,
978    result=no)
979   AC_LANG_RESTORE
980   AC_MSG_RESULT($result)
982   if test "$result" = "no" ; then
983     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
984   fi
987 fi # COMPILE_ENVIRONMENT
989 if test -n "$MAKE"; then
990   if test `echo $MAKE | grep -c make.py` != 1; then
991      NOT_PYMAKE=$MAKE
992   fi
995 case "$host_os" in
996 mingw*)
997     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
998     ;;
1000     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
1001     ;;
1002 esac
1003 if test "$GMAKE" = ":"; then
1004    AC_MSG_ERROR([GNU make not found])
1006 AC_SUBST(GMAKE)
1008 if test -z "$MAKE"; then
1009   MAKE=$GMAKE
1012 if test "$COMPILE_ENVIRONMENT"; then
1014 AC_PATH_XTRA
1016 XCFLAGS="$X_CFLAGS"
1018 fi # COMPILE_ENVIRONMENT
1020 dnl ========================================================
1021 dnl set the defaults first
1022 dnl ========================================================
1023 AS_BIN=$AS
1024 AR_LIST='$(AR) t'
1025 AR_EXTRACT='$(AR) x'
1026 AR_DELETE='$(AR) d'
1027 AS='$(CC)'
1028 AS_DASH_C_FLAG='-c'
1029 DLL_PREFIX=lib
1030 LIB_PREFIX=lib
1031 DLL_SUFFIX=.so
1032 OBJ_SUFFIX=o
1033 LIB_SUFFIX=a
1034 ASM_SUFFIX=s
1035 IMPORT_LIB_SUFFIX=
1036 TARGET_MD_ARCH=unix
1037 DIRENT_INO=d_ino
1038 MOZ_USER_DIR=".mozilla"
1040 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
1042 MOZ_FS_LAYOUT=unix
1044 USE_DEPENDENT_LIBS=1
1046 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk3
1048 if test -n "$CROSS_COMPILE"; then
1049     OS_TARGET="${target_os}"
1050     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
1051     OS_RELEASE=
1052     case "${target_os}" in
1053         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
1054         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU/kFreeBSD ;;
1055         gnu*)         OS_ARCH=GNU ;;
1056         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
1057         mingw*)       OS_ARCH=WINNT OS_TARGET=WINNT ;;
1058         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
1059         dragonfly*)   OS_ARCH=DragonFly OS_TARGET=DragonFly ;;
1060         freebsd*)     OS_ARCH=FreeBSD OS_TARGET=FreeBSD ;;
1061         netbsd*)      OS_ARCH=NetBSD OS_TARGET=NetBSD ;;
1062         openbsd*)     OS_ARCH=OpenBSD OS_TARGET=OpenBSD ;;
1063     esac
1064     case "${target}" in
1065         *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
1066     esac
1067 else
1068     OS_TARGET=`uname -s`
1069     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
1070     OS_RELEASE=`uname -r`
1073 # Before this used `uname -m` when not cross compiling
1074 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
1075 OS_TEST="${target_cpu}"
1077 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
1079 #######################################################################
1080 # Master "Core Components" macros for getting the OS target           #
1081 #######################################################################
1084 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
1085 # cross-compilation.
1089 # Define and override various archtecture-specific variables, including
1090 # HOST_OS_ARCH
1091 # OS_ARCH
1092 # OS_TEST
1093 # OS_TARGET
1094 # OS_RELEASE
1095 # OS_MINOR_RELEASE
1098 case "$HOST_OS_ARCH" in
1099 mingw*)
1100     HOST_OS_ARCH=WINNT
1101     ;;
1102 darwin*)
1103     HOST_OS_ARCH=Darwin
1104     ;;
1105 linux*)
1106     HOST_OS_ARCH=Linux
1107     ;;
1108 kfreebsd*-gnu)
1109     HOST_OS_ARCH=GNU_kFreeBSD
1110     ;;
1111 gnu*)
1112     HOST_OS_ARCH=GNU
1113     ;;
1114 dragonfly*)
1115     HOST_OS_ARCH=DragonFly
1116     ;;
1117 freebsd*)
1118     HOST_OS_ARCH=FreeBSD
1119     ;;
1120 netbsd*)
1121     HOST_OS_ARCH=NetBSD
1122     ;;
1123 openbsd*)
1124     HOST_OS_ARCH=OpenBSD
1125     ;;
1126 solaris*)
1127     HOST_OS_ARCH=SunOS
1128     SOLARIS_SUNPRO_CC=
1129     SOLARIS_SUNPRO_CXX=
1130     if test -z "$GNU_CC"; then
1131         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1132             SOLARIS_SUNPRO_CC=1
1133        fi
1134     fi
1136     if test -z "$GNU_CXX"; then
1137        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1138            SOLARIS_SUNPRO_CXX=1
1139        fi
1140     fi
1141     AC_SUBST(SOLARIS_SUNPRO_CC)
1142     AC_SUBST(SOLARIS_SUNPRO_CXX)
1143     ;;
1144 esac
1146 case "$OS_ARCH" in
1147 WINNT)
1148     if test -z "$CROSS_COMPILE" ; then
1149         OS_TEST=`uname -p`
1150     fi
1151     ;;
1152 Windows_NT)
1154 # If uname -s returns "Windows_NT", we assume that we are using
1155 # the uname.exe in MKS toolkit.
1157 # The -r option of MKS uname only returns the major version number.
1158 # So we need to use its -v option to get the minor version number.
1159 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1161     OS_ARCH=WINNT
1162     OS_TARGET=WINNT
1163     OS_MINOR_RELEASE=`uname -v`
1164     if test "$OS_MINOR_RELEASE" = "00"; then
1165         OS_MINOR_RELEASE=0
1166     fi
1167     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1168     ;;
1169 MINGW*_NT*)
1171 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1172 # the uname.exe in the MSYS tools.
1174     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1175     OS_ARCH=WINNT
1176     OS_TARGET=WINNT
1177     ;;
1178 AIX)
1179     OS_RELEASE=`uname -v`.`uname -r`
1180     OS_TEST=${target_cpu}
1181     ;;
1182 Darwin)
1183     case "${target_cpu}" in
1184     powerpc*)
1185         OS_TEST=ppc
1186         ;;
1187     i*86*)
1188         OS_TEST=i386
1189         ;;
1190     x86_64)
1191         OS_TEST=x86_64
1192         ;;
1193     *)
1194         if test -z "$CROSS_COMPILE" ; then
1195             OS_TEST=`uname -p`
1196         fi
1197         ;;
1198     esac
1199     ;;
1200 esac
1202 # Only set CPU_ARCH if we recognize the value of OS_TEST
1204 case "$OS_TEST" in
1205 *86 | i86pc)
1206     CPU_ARCH=x86
1207     ;;
1209 powerpc64 | ppc64 | powerpc64le | ppc64le)
1210     CPU_ARCH=ppc64
1211     ;;
1213 powerpc | ppc | rs6000)
1214     CPU_ARCH=ppc
1215     ;;
1217 Alpha | alpha | ALPHA)
1218     CPU_ARCH=Alpha
1219     ;;
1221 s390)
1222     CPU_ARCH=s390
1223     ;;
1225 s390x)
1226     CPU_ARCH=s390x
1227     ;;
1229 hppa* | parisc)
1230     CPU_ARCH=hppa
1231     ;;
1233 sun4u | sparc*)
1234     CPU_ARCH=sparc
1235     ;;
1237 x86_64 | ia64)
1238     CPU_ARCH="$OS_TEST"
1239     ;;
1241 arm*)
1242     CPU_ARCH=arm
1243     ;;
1245 mips|mipsel)
1246     CPU_ARCH="mips"
1247     ;;
1249 aarch64*)
1250     CPU_ARCH=aarch64
1251     ;;
1252 esac
1254 if test -z "$OS_TARGET"; then
1255     OS_TARGET=$OS_ARCH
1257 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1259 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1260 dnl ===============================================================
1261 INTEL_ARCHITECTURE=
1262 case "$OS_TEST" in
1263     x86_64|i?86)
1264       INTEL_ARCHITECTURE=1
1265 esac
1267 dnl Configure platform-specific CPU architecture compiler options.
1268 dnl ==============================================================
1269 MOZ_ARCH_OPTS
1271 dnl =================================================================
1272 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1273 dnl which is bad when cross compiling.
1274 dnl =================================================================
1275 if test "$COMPILE_ENVIRONMENT"; then
1276 configure_static_assert_macros='
1277 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1278 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1279 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1282 dnl test that the macros actually work:
1283 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1284 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1285  [AC_LANG_SAVE
1286   AC_LANG_C
1287   ac_cv_static_assertion_macros_work="yes"
1288   AC_TRY_COMPILE([$configure_static_assert_macros],
1289                  [CONFIGURE_STATIC_ASSERT(1)],
1290                  ,
1291                  ac_cv_static_assertion_macros_work="no")
1292   AC_TRY_COMPILE([$configure_static_assert_macros],
1293                  [CONFIGURE_STATIC_ASSERT(0)],
1294                  ac_cv_static_assertion_macros_work="no",
1295                  )
1296   AC_LANG_CPLUSPLUS
1297   AC_TRY_COMPILE([$configure_static_assert_macros],
1298                  [CONFIGURE_STATIC_ASSERT(1)],
1299                  ,
1300                  ac_cv_static_assertion_macros_work="no")
1301   AC_TRY_COMPILE([$configure_static_assert_macros],
1302                  [CONFIGURE_STATIC_ASSERT(0)],
1303                  ac_cv_static_assertion_macros_work="no",
1304                  )
1305   AC_LANG_RESTORE
1306  ])
1307 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1308 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1309     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1311 fi # COMPILE_ENVIRONMENT
1313 dnl ========================================================
1314 dnl Android libstdc++, placed here so it can use MOZ_ARCH
1315 dnl computed above.
1316 dnl ========================================================
1318 MOZ_ANDROID_STLPORT
1320 dnl ========================================================
1321 dnl Suppress Clang Argument Warnings
1322 dnl ========================================================
1323 if test -n "${CLANG_CC}${CLANG_CL}"; then
1324     _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
1325     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
1327 if test -n "${CLANG_CXX}${CLANG_CL}"; then
1328     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
1331 dnl ========================================================
1332 dnl = Use Address Sanitizer
1333 dnl ========================================================
1334 MOZ_ARG_ENABLE_BOOL(address-sanitizer,
1335 [  --enable-address-sanitizer       Enable Address Sanitizer (default=no)],
1336     MOZ_ASAN=1,
1337     MOZ_ASAN= )
1338 if test -n "$MOZ_ASAN"; then
1339     MOZ_LLVM_HACKS=1
1340     if test -n "$CLANG_CL"; then
1341         # Look for clang_rt.asan_dynamic-i386.dll
1342         MOZ_CLANG_RT_ASAN_LIB=clang_rt.asan_dynamic-i386.dll
1343         # We use MOZ_PATH_PROG in order to get a Windows style path.
1344         MOZ_PATH_PROG(MOZ_CLANG_RT_ASAN_LIB_PATH, $MOZ_CLANG_RT_ASAN_LIB)
1345         if test -z "$MOZ_CLANG_RT_ASAN_LIB_PATH"; then
1346             AC_MSG_ERROR([Couldn't find $MOZ_CLANG_RT_ASAN_LIB.  It should be available in the same location as clang-cl.])
1347         fi
1348         AC_SUBST(MOZ_CLANG_RT_ASAN_LIB_PATH)
1349     fi
1350     AC_DEFINE(MOZ_ASAN)
1351     MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
1353 AC_SUBST(MOZ_ASAN)
1355 dnl ========================================================
1356 dnl = Use Memory Sanitizer
1357 dnl ========================================================
1358 MOZ_ARG_ENABLE_BOOL(memory-sanitizer,
1359 [  --enable-memory-sanitizer       Enable Memory Sanitizer (default=no)],
1360     MOZ_MSAN=1,
1361     MOZ_MSAN= )
1362 if test -n "$MOZ_MSAN"; then
1363     MOZ_LLVM_HACKS=1
1364     AC_DEFINE(MOZ_MSAN)
1365     MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
1367 AC_SUBST(MOZ_MSAN)
1369 dnl ========================================================
1370 dnl = Use Thread Sanitizer
1371 dnl ========================================================
1372 MOZ_ARG_ENABLE_BOOL(thread-sanitizer,
1373 [  --enable-thread-sanitizer       Enable Thread Sanitizer (default=no)],
1374    MOZ_TSAN=1,
1375    MOZ_TSAN= )
1376 if test -n "$MOZ_TSAN"; then
1377     MOZ_LLVM_HACKS=1
1378     AC_DEFINE(MOZ_TSAN)
1379     MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
1381 AC_SUBST(MOZ_TSAN)
1383 # The LLVM symbolizer is used by all sanitizers
1384 AC_SUBST(LLVM_SYMBOLIZER)
1386 dnl ========================================================
1387 dnl = Enable hacks required for LLVM instrumentations
1388 dnl ========================================================
1389 MOZ_ARG_ENABLE_BOOL(llvm-hacks,
1390 [  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)],
1391     MOZ_LLVM_HACKS=1,
1392     MOZ_LLVM_HACKS= )
1393 if test -n "$MOZ_LLVM_HACKS"; then
1394     MOZ_NO_WLZDEFS=1
1395     MOZ_CFLAGS_NSS=1
1397 AC_SUBST(MOZ_NO_WLZDEFS)
1398 AC_SUBST(MOZ_CFLAGS_NSS)
1400 dnl ========================================================
1401 dnl = Enable treating compiler warnings as errors
1402 dnl ========================================================
1403 MOZ_ARG_ENABLE_BOOL(warnings-as-errors,
1404 [  --enable-warnings-as-errors
1405                           Enable treating warnings as errors],
1406     MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
1407     MOZ_ENABLE_WARNINGS_AS_ERRORS=)
1409 dnl ========================================================
1410 dnl GNU specific defaults
1411 dnl ========================================================
1412 if test "$GNU_CC"; then
1413     MMX_FLAGS="-mmmx"
1414     SSE_FLAGS="-msse"
1415     SSE2_FLAGS="-msse2"
1416     # Per bug 719659 comment 2, some of the headers on ancient build machines
1417     # may require gnu89 inline semantics.  But otherwise, we use C99.
1418     # But on OS X we just use C99 plus GNU extensions, in order to fix
1419     # bug 917526.
1420     CFLAGS="$CFLAGS -std=gnu99"
1421     if test "${OS_ARCH}" != Darwin; then
1422         CFLAGS="$CFLAGS -fgnu89-inline"
1423     fi
1424     # FIXME: Let us build with strict aliasing. bug 414641.
1425     CFLAGS="$CFLAGS -fno-strict-aliasing"
1426     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@'
1427     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@'
1428     WARNINGS_AS_ERRORS='-Werror'
1429     DSO_CFLAGS=''
1430     DSO_PIC_CFLAGS='-fPIC'
1431     ASFLAGS="$ASFLAGS -fPIC"
1432     AC_MSG_CHECKING([for --noexecstack option to as])
1433     _SAVE_CFLAGS=$CFLAGS
1434     CFLAGS="$CFLAGS -Wa,--noexecstack"
1435     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
1436                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
1437                      AC_MSG_RESULT([no]))
1438     CFLAGS=$_SAVE_CFLAGS
1439     AC_MSG_CHECKING([for -z noexecstack option to ld])
1440     _SAVE_LDFLAGS=$LDFLAGS
1441     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
1442     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
1443                   AC_MSG_RESULT([no])
1444                   LDFLAGS=$_SAVE_LDFLAGS)
1446     AC_MSG_CHECKING([for -z text option to ld])
1447     _SAVE_LDFLAGS=$LDFLAGS
1448     LDFLAGS="$LDFLAGS -Wl,-z,text"
1449     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1450                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,text"],
1451                   AC_MSG_RESULT([no])
1452                   LDFLAGS=$_SAVE_LDFLAGS)
1454     AC_MSG_CHECKING([for --build-id option to ld])
1455     _SAVE_LDFLAGS=$LDFLAGS
1456     LDFLAGS="$LDFLAGS -Wl,--build-id"
1457     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1458                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,--build-id"],
1459                   AC_MSG_RESULT([no])
1460                   LDFLAGS=$_SAVE_LDFLAGS)
1462     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
1463     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
1464     _SAVE_LDFLAGS=$LDFLAGS
1465     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
1466     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1467                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
1468                   AC_MSG_RESULT([no]))
1469     LDFLAGS=$_SAVE_LDFLAGS
1471     # Check for -mssse3 on $CC
1472     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
1473     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
1474     _SAVE_CFLAGS=$CFLAGS
1475     CFLAGS="$CFLAGS -mssse3"
1476     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
1477                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
1478                      AC_MSG_RESULT([no]))
1479     CFLAGS=$_SAVE_CFLAGS
1481     # Check for -msse4.1 on $CC
1482     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
1483     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
1484     _SAVE_CFLAGS=$CFLAGS
1485     CFLAGS="$CFLAGS -msse4.1"
1486     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
1487                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
1488                      AC_MSG_RESULT([no]))
1489     CFLAGS=$_SAVE_CFLAGS
1491     case "${CPU_ARCH}" in
1492     x86 | x86_64)
1493       AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
1494       AC_TRY_COMPILE([],
1495                      [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
1496                      result="yes", result="no")
1497       AC_MSG_RESULT("$result")
1498       if test "$result" = "yes"; then
1499           HAVE_X86_AVX2=1
1500       fi
1501     esac
1503     DSO_LDOPTS='-shared'
1504     if test "$GCC_USE_GNU_LD"; then
1505         # Some tools like ASan use a runtime library that is only
1506         # linked against executables, so we must allow undefined
1507         # symbols for shared objects in some cases.
1508         if test -z "$MOZ_NO_WLZDEFS"; then
1509             # Don't allow undefined symbols in libraries
1510             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1512             # BSDs need `environ' exposed for posix_spawn (bug 753046)
1513             case "$OS_TARGET" in
1514             DragonFly|FreeBSD|NetBSD|OpenBSD)
1515                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
1516                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
1517                 else
1518                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
1519                 fi
1520                 ;;
1521             esac
1522         fi
1523     fi
1525     # Turn on gcc/clang warnings:
1526     # https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Warning-Options.html
1527     #
1528     # -Wall - turn on a lot of warnings
1529     # -Wchar-subscripts - catches array index using signed char
1530     # -Wcomment - catches nested comments
1531     # -Wdeclaration-after-statement - MSVC doesn't like these
1532     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1533     # -Wendif-labels - catches `#else FOO` and `#endif FOO` not in comment
1534     # -Wenum-compare - catches comparison of different enum types
1535     # -Wignored-qualifiers - catches returns types with qualifiers like const
1536     # -Wint-to-pointer-cast - catches cast to pointer from integer of different size
1537     # -Wmultichar - catches multicharacter integer constants like 'THIS'
1538     # -Wnon-literal-null-conversion - catches expressions used as a null pointer constant
1539     # -Wnonnull - catches NULL used with functions arguments marked as non-null
1540     # -Wpointer-arith - catches pointer arithmetic using NULL or sizeof(void)
1541     # -Wpointer-sign - catches mixing pointers to signed and unsigned types
1542     # -Wpointer-to-int-cast - catches casts from pointer to different sized int
1543     # -Wreturn-type - catches missing returns, zero false positives
1544     # -Wsequence-point - catches undefined order behavior like `a = a++`
1545     # -Wsign-compare - catches comparison of signed and unsigned types
1546     # -Wtrigraphs - catches unlikely use of trigraphs
1547     # -Wtype-limits - catches overflow bugs, few false positives
1548     # -Wunknown-pragmas - catches unexpected #pragma directives
1549     #
1550     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall"
1551     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wdeclaration-after-statement"
1552     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wempty-body"
1553     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wpointer-to-int-cast"
1554     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wsign-compare"
1555     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wtype-limits"
1557     # Treat some warnings as errors if --enable-warnings-as-errors:
1558     if test "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
1559         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=char-subscripts"
1560         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=comment"
1561         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=endif-labels"
1562         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=enum-compare"
1563         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=ignored-qualifiers"
1564         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=int-to-pointer-cast"
1565         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=multichar"
1566         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=nonnull"
1567         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-arith"
1568         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=pointer-sign"
1569         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=return-type"
1570         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=sequence-point"
1571         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=trigraphs"
1572         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=uninitialized"
1573         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Werror=unknown-pragmas"
1575         MOZ_C_SUPPORTS_WARNING(-Werror=, non-literal-null-conversion, ac_c_has_werror_non_literal_null_conversion)
1576         MOZ_C_SUPPORTS_WARNING(-Werror=, sometimes-uninitialized, ac_c_has_sometimes_uninitialized)
1577     fi
1579     # Turn off the following warnings that -Wall turns on:
1580     # -Wno-unused - lots of violations in third-party code
1581     #
1582     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
1584     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
1585        # Don't use -Wcast-align with ICC or clang
1586        case "$CPU_ARCH" in
1587            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1588            hppa | ia64 | sparc | arm)
1589            ;;
1590            *)
1591         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1592            ;;
1593        esac
1594     fi
1596     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1597     _USE_CPP_INCLUDE_FLAG=1
1598     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
1600 elif test "$SOLARIS_SUNPRO_CC"; then
1601     DSO_CFLAGS=''
1602     if test "$CPU_ARCH" = "sparc"; then
1603         # for Sun Studio on Solaris/SPARC
1604         DSO_PIC_CFLAGS='-xcode=pic32'
1605     else
1606         DSO_PIC_CFLAGS='-KPIC'
1607     fi
1608     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1609 else
1610     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@'
1611     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@'
1613     DSO_LDOPTS='-shared'
1614     if test "$GNU_LD"; then
1615         # Don't allow undefined symbols in libraries
1616         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1617     fi
1619     DSO_CFLAGS=''
1620     DSO_PIC_CFLAGS='-KPIC'
1621     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1624 if test "$GNU_CXX"; then
1625     # FIXME: Let us build with strict aliasing. bug 414641.
1626     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
1628     # Turn on gcc/clang warnings:
1629     # https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Warning-Options.html
1630     #
1631     # -Wall - turn on a lot of warnings
1632     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1633     # -Wendif-labels - catches `#else FOO` and `#endif FOO` not in comment
1634     # -Wint-to-pointer-cast - catches cast to pointer from integer of different size
1635     # -Wmissing-braces - catches aggregate initializers missing nested braces
1636     # -Wnon-literal-null-conversion - catches expressions used as a null pointer constant
1637     # -Woverloaded-virtual - function declaration hides virtual function from base class
1638     # -Wparentheses - catches `if (a=b)` and operator precedence bugs
1639     # -Wpointer-arith - catches pointer arithmetic using NULL or sizeof(void)
1640     # -Wreturn-type - catches missing returns, zero false positives
1641     # -Wsequence-point - catches undefined order behavior like `a = a++`
1642     # -Wsign-compare - catches comparison of signed and unsigned types
1643     # -Wswitch - catches switches without all enum cases or default case
1644     # -Wtrigraphs - catches unlikely use of trigraphs
1645     # -Wtype-limits - catches overflow bugs, few false positives
1646     # -Wunused-label - catches unused goto labels
1647     # -Wwrite-strings - catches non-const char* pointers to string literals
1648     #
1649     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall"
1650     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wempty-body"
1651     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Woverloaded-virtual"
1652     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wsign-compare"
1653     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wwrite-strings"
1655     # Treat some warnings as errors if --enable-warnings-as-errors:
1656     if test "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
1657         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=endif-labels"
1658         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=int-to-pointer-cast"
1659         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=missing-braces"
1660         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=parentheses"
1661         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=pointer-arith"
1662         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
1663         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=sequence-point"
1664         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=switch"
1665         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=trigraphs"
1666         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=type-limits"
1667         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=uninitialized"
1668         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=unused-label"
1670         MOZ_CXX_SUPPORTS_WARNING(-Werror=, non-literal-null-conversion, ac_cxx_has_werror_non_literal_null_conversion)
1671         MOZ_CXX_SUPPORTS_WARNING(-Werror=, sometimes-uninitialized, ac_cxx_has_sometimes_uninitialized)
1672     fi
1674     # Turn off the following warnings that -Wall turns on:
1675     # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
1676     # -Wno-inline-new-delete - we inline 'new' and 'delete' in mozalloc
1677     #   for performance reasons, and because GCC and clang accept it (though
1678     #   clang warns about it).
1679     #
1680     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-invalid-offsetof"
1682     MOZ_CXX_SUPPORTS_WARNING(-Wno-, inline-new-delete, ac_cxx_has_wno_inline_new_delete)
1684     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
1685        # Don't use -Wcast-align with ICC or clang
1686        case "$CPU_ARCH" in
1687            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1688            hppa | ia64 | sparc | arm)
1689            ;;
1690            *)
1691         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1692            ;;
1693        esac
1694     fi
1696     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1697     _USE_CPP_INCLUDE_FLAG=1
1699     # Recent clang and gcc support C++11 deleted functions without warnings if
1700     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
1701     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
1702     # unused.  But clang's warning can be disabled, so when compiling with clang
1703     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
1704     # deleted function syntax.
1705     if test "$CLANG_CXX"; then
1706         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
1707         MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
1708     fi
1710 else
1711     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
1714 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1715 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1716 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1717 dnl normal behavior.
1718 dnl ========================================================
1719 MKSHLIB_FORCE_ALL=
1720 MKSHLIB_UNFORCE_ALL=
1722 if test "$COMPILE_ENVIRONMENT"; then
1723 if test "$GNU_CC"; then
1724   AC_MSG_CHECKING(whether ld has archive extraction flags)
1725   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1726    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1727     ac_cv_mkshlib_force_and_unforce="no"
1728     exec 3<&0 <<LOOP_INPUT
1729   force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1730   force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1731   force="-Wl,-all";              unforce="-Wl,-none"
1732 LOOP_INPUT
1733     while read line
1734     do
1735       eval $line
1736       LDFLAGS=$force
1737       LIBS=$unforce
1738       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1739     done
1740     exec 0<&3 3<&-
1741     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1742    ])
1743   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1744     AC_MSG_RESULT(no)
1745   else
1746     AC_MSG_RESULT(yes)
1747     eval $ac_cv_mkshlib_force_and_unforce
1748     MKSHLIB_FORCE_ALL=$force
1749     MKSHLIB_UNFORCE_ALL=$unforce
1750   fi
1751 fi # GNU_CC
1752 fi # COMPILE_ENVIRONMENT
1754 dnl ========================================================
1755 dnl Checking for 64-bit OS
1756 dnl ========================================================
1757 if test "$COMPILE_ENVIRONMENT"; then
1758 AC_LANG_SAVE
1759 AC_LANG_C
1760 AC_MSG_CHECKING(for 64-bit OS)
1761 AC_TRY_COMPILE([$configure_static_assert_macros],
1762                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1763                result="yes", result="no")
1764 AC_MSG_RESULT("$result")
1765 if test "$result" = "yes"; then
1766     AC_DEFINE(HAVE_64BIT_BUILD)
1767     HAVE_64BIT_BUILD=1
1769 AC_SUBST(HAVE_64BIT_BUILD)
1770 AC_LANG_RESTORE
1771 fi # COMPILE_ENVIRONMENT
1773 dnl ========================================================
1774 dnl = Use profiling compile flags
1775 dnl ========================================================
1776 MOZ_ARG_ENABLE_BOOL(profiling,
1777 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1778     MOZ_PROFILING=1,
1779     MOZ_PROFILING= )
1781 dnl ========================================================
1782 dnl = Turn on systrace for android/b2g.
1783 dnl ========================================================
1784 MOZ_ARG_ENABLE_BOOL(systrace,
1785 [  --enable-systrace       Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1786     MOZ_USE_SYSTRACE=1,
1787     MOZ_USE_SYSTRACE= )
1788 if test -n "$MOZ_USE_SYSTRACE"; then
1789     AC_DEFINE(MOZ_USE_SYSTRACE)
1792 # For profiling builds keep the symbol information
1793 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
1794     case "$OS_TARGET" in
1795     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
1796         STRIP_FLAGS="--strip-debug"
1797         ;;
1798     esac
1801 dnl ========================================================
1802 dnl = Use Valgrind
1803 dnl ========================================================
1804 MOZ_ARG_ENABLE_BOOL(valgrind,
1805 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
1806     MOZ_VALGRIND=1,
1807     MOZ_VALGRIND= )
1808 if test -n "$MOZ_VALGRIND"; then
1809     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1810         AC_MSG_ERROR(
1811             [--enable-valgrind specified but Valgrind is not installed]))
1812     AC_DEFINE(MOZ_VALGRIND)
1814 AC_SUBST(MOZ_VALGRIND)
1816 dnl ========================================================
1817 dnl jprof
1818 dnl ========================================================
1819 MOZ_ARG_ENABLE_BOOL(jprof,
1820 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
1821     MOZ_JPROF=1,
1822     MOZ_JPROF= )
1823 if test -n "$MOZ_JPROF"; then
1824     MOZ_PROFILING=1
1825     AC_DEFINE(MOZ_JPROF)
1828 dnl ========================================================
1829 dnl SPS Profiler
1830 dnl ========================================================
1831 MOZ_ENABLE_PROFILER_SPS=1
1833 case "${OS_TARGET}" in
1834 Android)
1835     case "${CPU_ARCH}" in
1836     x86 | arm) ;;
1837     *)
1838         MOZ_ENABLE_PROFILER_SPS=
1839     esac
1840     ;;
1841 Linux)
1842     case "${CPU_ARCH}" in
1843     x86 | x86_64) ;;
1844     *)
1845         MOZ_ENABLE_PROFILER_SPS=
1846     esac
1847     ;;
1848 WINNT) ;;
1849 Darwin)
1850     if test -n "$MOZ_IOS"; then
1851         MOZ_ENABLE_PROFILER_SPS=
1852     fi
1853     ;;
1855     MOZ_ENABLE_PROFILER_SPS=
1856     ;;
1857 esac
1859 if test -n "$MOZ_ENABLE_PROFILER_SPS"; then
1860     AC_DEFINE(MOZ_ENABLE_PROFILER_SPS)
1863 dnl ========================================================
1864 dnl instruments
1865 dnl ========================================================
1866 MOZ_ARG_ENABLE_BOOL(instruments,
1867 [  --enable-instruments    Enable instruments remote profiling. Implies --enable-profiling.],
1868     MOZ_INSTRUMENTS=1,
1869     MOZ_INSTRUMENTS= )
1870 if test -n "$MOZ_INSTRUMENTS"; then
1871     MOZ_PROFILING=1
1872     AC_DEFINE(MOZ_INSTRUMENTS)
1875 dnl ========================================================
1876 dnl callgrind
1877 dnl ========================================================
1878 MOZ_ARG_ENABLE_BOOL(callgrind,
1879 [  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.],
1880     MOZ_CALLGRIND=1,
1881     MOZ_CALLGRIND= )
1882 if test -n "$MOZ_CALLGRIND"; then
1883     MOZ_PROFILING=1
1884     AC_DEFINE(MOZ_CALLGRIND)
1887 dnl ========================================================
1888 dnl vtune
1889 dnl ========================================================
1890 MOZ_ARG_ENABLE_BOOL(vtune,
1891 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
1892     MOZ_VTUNE=1,
1893     MOZ_VTUNE= )
1894 if test -n "$MOZ_VTUNE"; then
1895     MOZ_PROFILING=1
1896     AC_DEFINE(MOZ_VTUNE)
1899 dnl ========================================================
1900 dnl Profiling
1901 dnl ========================================================
1902 if test -n "$MOZ_PROFILING"; then
1903     AC_DEFINE(MOZ_PROFILING)
1906 dnl ========================================================
1907 dnl System overrides of the defaults for host
1908 dnl ========================================================
1909 case "$host" in
1910 *mingw*)
1911     if test -n "$_WIN32_MSVC"; then
1912         HOST_AR=lib
1913         HOST_AR_FLAGS='-NOLOGO -OUT:$@'
1914         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo"
1915         HOST_RANLIB='echo ranlib'
1916     else
1917         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
1918     fi
1919     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
1920     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1921     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1922     HOST_BIN_SUFFIX=.exe
1923     case "$host" in
1924     *mingw*)
1925         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1926         ;;
1927     esac
1929     case "${host_cpu}" in
1930     i*86)
1931         if test -n "$_WIN32_MSVC"; then
1932             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
1933         fi
1934         ;;
1935     x86_64)
1936         if test -n "$_WIN32_MSVC"; then
1937             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
1938         fi
1939         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1940         ;;
1941     esac
1942     ;;
1944 *-darwin*)
1945     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1946     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1947     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1948     ;;
1950 *-linux*|*-kfreebsd*-gnu|*-gnu*)
1951     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1952     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1953     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1954     ;;
1957     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1958     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1959     ;;
1960 esac
1962 dnl ==============================================================
1963 dnl Get mozilla version from central milestone file
1964 dnl ==============================================================
1965 MOZILLA_VERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir`
1966 MOZILLA_UAVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --uaversion`
1967 MOZILLA_SYMBOLVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --symbolversion`
1969 dnl Get version of various core apps from the version files.
1970 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
1971 FIREFOX_VERSION_DISPLAY=`cat $_topsrcdir/browser/config/version_display.txt`
1973 if test -z "$FIREFOX_VERSION"; then
1974     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
1977 if test -z "$FIREFOX_VERSION_DISPLAY"; then
1978     AC_MSG_ERROR([FIREFOX_VERSION_DISPLAY is unexpectedly blank.])
1981 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
1982 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
1983 AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
1984 AC_SUBST(MOZILLA_SYMBOLVERSION)
1986 MOZ_DOING_LTO(lto_is_enabled)
1988 dnl ========================================================
1989 dnl System overrides of the defaults for target
1990 dnl ========================================================
1992 case "$target" in
1993 *-aix*)
1994     AC_DEFINE(AIX)
1995     if test ! "$GNU_CC"; then
1996         if test ! "$HAVE_64BIT_BUILD"; then
1997             # Compiling with Visual Age C++ object model compat is the
1998             # default. To compile with object model ibm, add
1999             # AIX_OBJMODEL=ibm to .mozconfig.
2000             if test "$AIX_OBJMODEL" = "ibm"; then
2001                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
2002             else
2003                 AIX_OBJMODEL=compat
2004             fi
2005         else
2006             AIX_OBJMODEL=compat
2007         fi
2008         AC_SUBST(AIX_OBJMODEL)
2009         DSO_LDOPTS='-qmkshrobj=1'
2010         DSO_CFLAGS='-qflag=w:w'
2011         DSO_PIC_CFLAGS=
2012         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
2013         MOZ_FIX_LINK_PATHS=
2014         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2015         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2016         if test "$COMPILE_ENVIRONMENT"; then
2017             AC_LANG_SAVE
2018             AC_LANG_CPLUSPLUS
2019             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
2020             AC_TRY_COMPILE([],
2021                 [#if (__IBMCPP__ < 900)
2022                  #error "Bad compiler"
2023                  #endif],
2024                 _BAD_COMPILER=,_BAD_COMPILER=1)
2025             if test -n "$_BAD_COMPILER"; then
2026                 AC_MSG_RESULT([no])
2027                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
2028             else
2029                 AC_MSG_RESULT([yes])
2030             fi
2031             AC_LANG_RESTORE
2032             TARGET_COMPILER_ABI="ibmc"
2033             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
2034             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
2035         fi # COMPILE_ENVIRONMENT
2036     fi
2037     case "${target_os}" in
2038     aix4.1*)
2039         DLL_SUFFIX='_shr.a'
2040         ;;
2041     esac
2042     if test "$COMPILE_ENVIRONMENT"; then
2043         MOZ_CHECK_HEADERS(sys/inttypes.h)
2044     fi # COMPILE_ENVIRONMENT
2045     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2046     ;;
2048 *-darwin*)
2049     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2050     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2051     MOZ_OPTIMIZE_FLAGS="-O3"
2052     # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
2053     if test "$HAVE_64BIT_BUILD"; then
2054         MOZ_MEMORY=1
2055     fi
2056     DLL_SUFFIX=".dylib"
2057     DSO_LDOPTS=''
2058     STRIP_FLAGS="$STRIP_FLAGS -x -S"
2059     # Ensure that if we're targeting iOS an SDK was provided.
2060     AC_CACHE_CHECK(for iOS target,
2061                    ac_cv_ios_target,
2062                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
2063 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
2064 #error not iOS
2065 #endif],
2066                                    [],
2067                                    ac_cv_ios_target="yes",
2068                                    ac_cv_ios_target="no")])
2069     if test "$ac_cv_ios_target" = "yes" -a -z $MOZ_IOS; then
2070        AC_MSG_ERROR([targeting iOS but not using an iOS SDK?])
2071     fi
2072     if test -n "$MOZ_IOS"; then
2073         AC_DEFINE(XP_IOS)
2074         AC_DEFINE(XP_DARWIN)
2075         _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
2076     else
2077         AC_DEFINE(XP_MACOSX)
2078         AC_DEFINE(XP_DARWIN)
2079         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
2080         # The ExceptionHandling framework is needed for Objective-C exception
2081         # logging code in nsObjCExceptions.h. Currently we only use that in debug
2082         # builds.
2083         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
2084     fi
2085     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
2087     if test "x$lto_is_enabled" = "xyes"; then
2088         echo "Skipping -dead_strip because lto is enabled."
2089     dnl DTrace and -dead_strip don't interact well. See bug 403132.
2090     dnl ===================================================================
2091     elif test "x$enable_dtrace" = "xyes"; then
2092         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
2093     else
2094         dnl check for the presence of the -dead_strip linker flag
2095         AC_MSG_CHECKING([for -dead_strip option to ld])
2096         _SAVE_LDFLAGS=$LDFLAGS
2097         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
2098         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
2099         if test -n "$_HAVE_DEAD_STRIP" ; then
2100             AC_MSG_RESULT([yes])
2101             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
2102         else
2103             AC_MSG_RESULT([no])
2104         fi
2106         LDFLAGS=$_SAVE_LDFLAGS
2107     fi
2109     dnl With newer linkers we need to pass -allow_heap_execute because of
2110     dnl Microsoft Silverlight (5.1.10411.0 at least).
2111     AC_MSG_CHECKING([for -allow_heap_execute option to ld])
2112     _SAVE_LDFLAGS=$LDFLAGS
2113     LDFLAGS="$LDFLAGS -Wl,-allow_heap_execute"
2114     AC_TRY_LINK(,[return 0;],_HAVE_ALLOW_HEAP_EXECUTE=1,
2115                 _HAVE_ALLOW_HEAP_EXECUTE=)
2116     if test -n "$_HAVE_ALLOW_HEAP_EXECUTE" ; then
2117         AC_MSG_RESULT([yes])
2118         MOZ_ALLOW_HEAP_EXECUTE_FLAGS="-Wl,-allow_heap_execute"
2119     else
2120         AC_MSG_RESULT([no])
2121     fi
2122     LDFLAGS=$_SAVE_LDFLAGS
2124     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
2125     ;;
2127 ia64*-hpux*)
2128     DLL_SUFFIX=".so"
2129     if test ! "$GNU_CC"; then
2130        DSO_LDOPTS='-b'
2131        DSO_CFLAGS=""
2132        DSO_PIC_CFLAGS=
2133        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
2134        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
2135        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2136     else
2137        DSO_LDOPTS='-b -E'
2138        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2139        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2140     fi
2141     MOZ_FIX_LINK_PATHS=
2142     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2143     AC_DEFINE(_LARGEFILE64_SOURCE)
2144     ;;
2146 *-hpux*)
2147     DLL_SUFFIX=".sl"
2148     if test ! "$GNU_CC"; then
2149         DSO_LDOPTS='-b -Wl,+s'
2150         DSO_CFLAGS=""
2151         DSO_PIC_CFLAGS="+Z"
2152         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
2153         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
2154         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2155     else
2156         DSO_LDOPTS='-b -E +s'
2157         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2158         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2159     fi
2160     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
2161     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2162     ;;
2164 *-android*|*-linuxandroid*)
2165     AC_DEFINE(NO_PW_GECOS)
2166     no_x=yes
2167     if test -n "$gonkdir"; then
2168         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
2169         _PLATFORM_HAVE_RIL=1
2170         MOZ_B2G_FM=1
2171         MOZ_SYNTH_PICO=1
2172     else
2173         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
2174         if test "$COMPILE_ENVIRONMENT"; then
2175             MOZ_LINKER=1
2176         fi
2177     fi
2178     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2180     MOZ_GFX_OPTIMIZE_MOBILE=1
2181     MOZ_OPTIMIZE_FLAGS="-Os -fno-reorder-functions"
2182     if test -z "$CLANG_CC"; then
2183        MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
2184     fi
2185     ;;
2187 *-*linux*)
2188     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2189     # Similarly for GNU_CXX and INTEL_CXX.
2190     if test "$INTEL_CC" -o "$INTEL_CXX"; then
2191         # -Os has been broken on Intel's C/C++ compilers for quite a
2192         # while; Intel recommends against using it.
2193         MOZ_OPTIMIZE_FLAGS="-O2"
2194     elif test "$GNU_CC" -o "$GNU_CXX"; then
2195         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
2196         MOZ_OPTIMIZE_FLAGS="-Os"
2197         if test -z "$CLANG_CC"; then
2198            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
2199         fi
2200     fi
2202     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2204     MOZ_MEMORY=1
2206     case "${target_cpu}" in
2207     alpha*)
2208         CFLAGS="$CFLAGS -mieee"
2209         CXXFLAGS="$CXXFLAGS -mieee"
2210     ;;
2211     esac
2213     if test -z "$MC"; then
2214         MC=mc.exe
2215     fi
2216     ;;
2217 *-mingw*)
2218     DSO_CFLAGS=
2219     DSO_PIC_CFLAGS=
2220     DLL_SUFFIX=.dll
2221     RC=rc.exe
2222     MC=mc.exe
2223     # certain versions of cygwin's makedepend barf on the
2224     # #include <string> vs -I./dist/include/string issue so don't use it
2225     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
2226         CC="$CC -mwindows"
2227         CXX="$CXX -mwindows"
2228         CPP="$CPP -mwindows"
2229         CFLAGS="$CFLAGS -mms-bitfields"
2230         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2231         DSO_LDOPTS='-shared'
2232         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2233         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2234         RC='$(WINDRES)'
2235         # Use static libgcc and libstdc++
2236         LDFLAGS="$LDFLAGS -static"
2237         NSPR_LDFLAGS="$NSPR_LDFLAGS -static-libgcc"
2238         # Use temp file for windres (bug 213281)
2239         RCFLAGS='-O coff --use-temp-file'
2240         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2241         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32 -lnetapi32"
2242         MOZ_FIX_LINK_PATHS=
2243         DLL_PREFIX=
2244         IMPORT_LIB_SUFFIX=a
2246         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
2247         WIN32_GUI_EXE_LDFLAGS=-mwindows
2249         # We use mix of both POSIX and Win32 printf format across the tree, so format
2250         # warnings are useless on mingw.
2251         MOZ_C_SUPPORTS_WARNING(-Wno-, format, ac_c_has_wno_format)
2252         MOZ_CXX_SUPPORTS_WARNING(-Wno-, format, ac_cxx_has_wno_format)
2253     else
2254         TARGET_COMPILER_ABI=msvc
2255         HOST_CC='$(CC)'
2256         HOST_CXX='$(CXX)'
2257         HOST_LD='$(LD)'
2258         if test "$AS_BIN"; then
2259             AS="$(basename "$AS_BIN")"
2260         fi
2261         AR='lib'
2262         AR_FLAGS='-NOLOGO -OUT:$@'
2263         AR_EXTRACT=
2264         RANLIB='echo not_ranlib'
2265         STRIP='echo not_strip'
2266         PKG_SKIP_STRIP=1
2267         XARGS=xargs
2268         ZIP=zip
2269         UNZIP=unzip
2270         DOXYGEN=:
2271         ASM_SUFFIX=asm
2272         OBJ_SUFFIX=obj
2273         LIB_SUFFIX=lib
2274         DLL_PREFIX=
2275         LIB_PREFIX=
2276         IMPORT_LIB_SUFFIX=lib
2277         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2278         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2279         MKSHLIB_FORCE_ALL=
2280         MKSHLIB_UNFORCE_ALL=
2281         dnl Set subsystem version 5 for Windows XP.
2282         if test "$CPU_ARCH" = "x86"; then
2283             WIN32_SUBSYSTEM_VERSION=5.01
2284         else
2285             WIN32_SUBSYSTEM_VERSION=6.01
2286         fi
2287         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
2288         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
2289         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
2290         _USE_CPP_INCLUDE_FLAG=1
2291         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2292         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2293         CFLAGS="$CFLAGS -W3 -Gy"
2294         CXXFLAGS="$CXXFLAGS -W3 -Gy"
2295         if test "$CPU_ARCH" = "x86"; then
2296             dnl VS2012+ defaults to -arch:SSE2.
2297             CFLAGS="$CFLAGS -arch:IA32"
2298             CXXFLAGS="$CXXFLAGS -arch:IA32"
2299         fi
2300         dnl VS2013+ requires -FS when parallel building by make -jN.
2301         dnl If nothing, compiler sometimes causes C1041 error.
2302         CFLAGS="$CFLAGS -FS"
2303         CXXFLAGS="$CXXFLAGS -FS"
2304         # khuey says we can safely ignore MSVC warning C4251
2305         # MSVC warning C4244 (implicit type conversion may lose data) warns
2306         # and requires workarounds for perfectly valid code.  Also, GCC/clang
2307         # don't warn about it by default. So for consistency/sanity, we turn
2308         # it off on MSVC, too.
2309         # MSVC warning C4267 warns for narrowing type conversions from size_t
2310         # to 32-bit integer types on 64-bit platforms.  Since this is virtually
2311         # the same thing as C4244, we disable C4267, too.
2312         # MSVC warning C4345 warns of newly conformant behavior as of VS2003.
2313         # MSVC warning C4351 warns of newly conformant behavior as of VS2005.
2314         # MSVC warning C4482 warns when an enum value is refered specifing the
2315         # name of the enum itself.  This behavior is allowed in C++11, and the
2316         # warning has been removed in VS2012.
2317         # MSVC warning C4800 warns when a value is implicitly cast to bool,
2318         # because this also forces narrowing to a single byte, which can be a
2319         # perf hit.  But this matters so little in practice (and often we want
2320         # that behavior) that it's better to turn it off.
2321         # MSVC warning C4819 warns some UTF-8 characters (e.g. copyright sign)
2322         # on non-Western system locales even if it is in a comment.
2323         CFLAGS="$CFLAGS -wd4244 -wd4267 -wd4819"
2324         CXXFLAGS="$CXXFLAGS -wd4251 -wd4244 -wd4267 -wd4345 -wd4351 -wd4482 -wd4800 -wd4819"
2325         if test -n "$CLANG_CL"; then
2326             # Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
2327             CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
2328         fi
2329         # make 'foo == bar;' error out
2330         CFLAGS="$CFLAGS -we4553"
2331         CXXFLAGS="$CXXFLAGS -we4553"
2332         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib netapi32.lib"
2333         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2334         WARNINGS_AS_ERRORS='-WX'
2335         MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
2336         MOZ_FIX_LINK_PATHS=
2337         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2338         # Disable these flags on clang-cl since it doesn't ignore unknown arguments by default, and
2339         # autoconf insists on passing $LDFLAGS to the compiler.
2340         if test -z "$CLANG_CL"; then
2341             LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2342             if test -z "$DEVELOPER_OPTIONS"; then
2343                 LDFLAGS="$LDFLAGS -RELEASE"
2344             fi
2345         fi
2346         dnl For profile-guided optimization
2347         PROFILE_GEN_CFLAGS="-GL"
2348         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2349         dnl XXX: PGO builds can fail with warnings treated as errors,
2350         dnl specifically "no profile data available" appears to be
2351         dnl treated as an error sometimes. This might be a consequence
2352         dnl of using WARNINGS_AS_ERRORS in some modules, combined
2353         dnl with the linker doing most of the work in the whole-program
2354         dnl optimization/PGO case. I think it's probably a compiler bug,
2355         dnl but we work around it here.
2356         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2357         dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2358         dnl Probably also a compiler bug, but what can you do?
2359         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2360         LDFLAGS="$LDFLAGS -DYNAMICBASE"
2361         if test "$_CC_MAJOR_VERSION" = "18" -a "$_CC_BUILD_VERSION" = "31101"; then
2362             dnl Use MaxILKSize as a workaround for LNK1248 in VS2013update4
2363             dnl See https://connect.microsoft.com/VisualStudio/feedback/details/1044914/fatal-error-lnk1248
2364             LDFLAGS="$LDFLAGS -MaxILKSize:0x7FF00000"
2365         fi
2366         dnl Minimum reqiurement of Gecko is VS2010 or later which supports
2367         dnl both SSSE3 and SSE4.1.
2368         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
2369         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
2370         dnl allow AVX2 code from VS2012
2371         HAVE_X86_AVX2=1
2372         MOZ_MEMORY=1
2373     fi
2374     AC_DEFINE(HAVE_SNPRINTF)
2375     AC_DEFINE(_WINDOWS)
2376     AC_DEFINE(WIN32)
2377     AC_DEFINE(XP_WIN)
2378     AC_DEFINE(XP_WIN32)
2379     AC_DEFINE(HW_THREADS)
2380     AC_DEFINE(STDC_HEADERS)
2381     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2382     TARGET_MD_ARCH=win32
2383     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2384     BIN_SUFFIX='.exe'
2385     MOZ_USER_DIR="Mozilla"
2387     dnl Hardcode to win95 for now - cls
2388     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2390     dnl set NO_X11 defines here as the general check is skipped on win32
2391     no_x=yes
2392     AC_DEFINE(NO_X11)
2394     case "$host" in
2395     *-mingw*)
2396         if test -n "$L10NBASEDIR"; then
2397             L10NBASEDIR=`cd $L10NBASEDIR && pwd -W`
2398         fi
2399         ;;
2400     esac
2402     case "$host_os" in
2403     cygwin*|msvc*|mks*)
2404         AC_MSG_ERROR([Using a Cygwin build environment is unsupported. Configure cannot check for presence of necessary headers. Please upgrade to MozillaBuild; see https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
2405         ;;
2406     esac
2408     case "$target" in
2409     i*86-*)
2410         if test "$HAVE_64BIT_BUILD"; then
2411             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2412         fi
2414         if test -n "$GNU_CC"; then
2415             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
2416             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
2417             LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup -Wl,--large-address-aware"
2418         else
2419             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
2420             # Disable this flag on clang-cl since it doesn't ignore unknown arguments by default, and
2421             # autoconf insists on passing $LDFLAGS to the compiler.
2422             if test -z "$CLANG_CL"; then
2423                 LDFLAGS="$LDFLAGS -SAFESEH"
2424             fi
2425         fi
2427         AC_DEFINE(_X86_)
2428         ;;
2429     x86_64-*)
2430         if test -z "$HAVE_64BIT_BUILD"; then
2431             AC_MSG_ERROR([You are targeting 64-bit but using the 32-bit compiler.])
2432         fi
2433         if test -n "$_WIN32_MSVC"; then
2434             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
2435         fi
2436         AC_DEFINE(_AMD64_)
2437         ;;
2438     *)
2439         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2440         ;;
2441     esac
2442     ;;
2444 *-netbsd*)
2445     DSO_CFLAGS=''
2446     CFLAGS="$CFLAGS -Dunix"
2447     CXXFLAGS="$CXXFLAGS -Dunix"
2448     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2449         DLL_SUFFIX=".so"
2450         DSO_PIC_CFLAGS='-fPIC -DPIC'
2451         DSO_LDOPTS='-shared'
2452         BIN_FLAGS='-Wl,--export-dynamic'
2453     else
2454         DSO_PIC_CFLAGS='-fPIC -DPIC'
2455         DLL_SUFFIX=".so.1.0"
2456         DSO_LDOPTS='-shared'
2457     fi
2458     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2459     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2460     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2461     if test "$LIBRUNPATH"; then
2462         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2463     fi
2464     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(DSO_SONAME) -o $@'
2465     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(DSO_SONAME) -o $@'
2466     ;;
2468 *-openbsd*)
2469     if test "$SO_VERSION"; then
2470         DLL_SUFFIX=".so.$SO_VERSION"
2471     else
2472         DLL_SUFFIX=".so.1.0"
2473     fi
2474     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
2475     DSO_CFLAGS=''
2476     DSO_PIC_CFLAGS='-fPIC'
2477     DSO_LDOPTS='-shared -fPIC'
2478     if test "$LIBRUNPATH"; then
2479         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2480     fi
2481     ;;
2483 *-solaris*)
2484     AC_DEFINE(SOLARIS)
2485     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2486     MOZ_FIX_LINK_PATHS=
2487     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2488     # libraries one level up (e.g. libnspr4.so)
2489     if test "$SOLARIS_SUNPRO_CC"; then
2490        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2491        LIBS="-lCrun -lCstd -lc $LIBS"
2492        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2493        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2494        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2495        LDFLAGS="-xildoff $LDFLAGS"
2496        MMX_FLAGS="-xarch=mmx -xO4"
2497        SSE_FLAGS="-xarch=sse"
2498        SSE2_FLAGS="-xarch=ssei2 -xO4"
2499        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2500            _SAVE_LDFLAGS=$LDFLAGS
2501            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
2502            AC_TRY_LINK([#include <stdio.h>],
2503                        [printf("Hello World\n");],
2504                        ,
2505                        [LDFLAGS=$_SAVE_LDFLAGS])
2506        fi
2507        MOZ_OPTIMIZE_FLAGS="-xO4"
2508        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@'
2509        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(DSO_SONAME) -o $@'
2510        MKSHLIB_FORCE_ALL='-z allextract'
2511        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2512        DSO_LDOPTS='-G'
2513        AR_LIST="$AR t"
2514        AR_EXTRACT="$AR x"
2515        AR_DELETE="$AR d"
2516        AR='$(CXX) -xar'
2517        AR_FLAGS='-o $@'
2518        AS='/usr/ccs/bin/as'
2519        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2520        AS_DASH_C_FLAG=''
2521        TARGET_COMPILER_ABI="sunc"
2522        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2523        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2524        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2525        AC_LANG_SAVE
2526        AC_LANG_CPLUSPLUS
2527        AC_TRY_COMPILE([],
2528            [#if (__SUNPRO_CC < 0x590)
2529            #error "Denied"
2530            #endif],
2531            _BAD_COMPILER=,_BAD_COMPILER=1)
2532        if test -n "$_BAD_COMPILER"; then
2533            _res="no"
2534            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2535        else
2536            _res="yes"
2537        fi
2538        AC_TRY_COMPILE([],
2539            [#if (__SUNPRO_CC >= 0x5100)
2540            #error "Sun C++ 5.10 or above"
2541            #endif],
2542            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2543        if test "$_ABOVE_SS12U1"; then
2544            # disable xannotate
2545            CXXFLAGS="$CXXFLAGS -xannotate=no"
2546        fi
2547        AC_MSG_RESULT([$_res])
2548        AC_LANG_RESTORE
2549     else
2550        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2551        LIBS="-lc $LIBS"
2552        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2553        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2554        ASFLAGS="$ASFLAGS -fPIC"
2555        DSO_LDOPTS='-shared'
2556        WARNINGS_AS_ERRORS='-Werror'
2557        _WARNINGS_CFLAGS=''
2558        _WARNINGS_CXXFLAGS=''
2559        if test "$OS_RELEASE" = "5.3"; then
2560            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2561        fi
2562     fi
2563     if test "$OS_RELEASE" = "5.5.1"; then
2564         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2565     fi
2566     ;;
2568 *-sunos*)
2569     DSO_LDOPTS='-Bdynamic'
2570     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2571     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2572     AC_DEFINE(SUNOS4)
2573     AC_DEFINE(SPRINTF_RETURNS_STRING)
2574     case "$(target_os)" in
2575     sunos4.1*)
2576         DLL_SUFFIX='.so.1.0'
2577         ;;
2578     esac
2579     ;;
2581 esac
2583 AC_SUBST_LIST(MMX_FLAGS)
2584 AC_SUBST_LIST(SSE_FLAGS)
2585 AC_SUBST_LIST(SSE2_FLAGS)
2587 case "$target" in
2588 *-*linux*)
2589     # Includes linux-android
2590     AC_DEFINE(XP_LINUX)
2591     ;;
2592 esac
2594 AC_SUBST(MOZ_LINKER)
2595 if test -n "$MOZ_LINKER"; then
2596   AC_DEFINE(MOZ_LINKER)
2599 dnl Only one oddball right now (QNX), but this gives us flexibility
2600 dnl if any other platforms need to override this in the future.
2601 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2603 dnl ========================================================
2604 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2605 dnl by now will not have any way to link most binaries (tests
2606 dnl as well as viewer, apprunner, etc.), because some symbols
2607 dnl will be left out of the "composite" .so's by ld as unneeded.
2608 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2609 dnl they can link in the static libs that provide the missing
2610 dnl symbols.
2611 dnl ========================================================
2612 NO_LD_ARCHIVE_FLAGS=
2613 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2614     NO_LD_ARCHIVE_FLAGS=1
2616 case "$target" in
2617 *-aix4.3*|*-aix5*)
2618     NO_LD_ARCHIVE_FLAGS=
2619     ;;
2620 *-mingw*)
2621     if test -z "$GNU_CC"; then
2622         NO_LD_ARCHIVE_FLAGS=
2623     fi
2624     ;;
2625 esac
2626 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2628 dnl ========================================================
2629 dnl = Flags to strip unused symbols from .so components and
2630 dnl = to export jemalloc symbols when linking a program
2631 dnl ========================================================
2632 case "$target" in
2633     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2634         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2635         ;;
2636     *-solaris*)
2637         if test -z "$GNU_CC"; then
2638          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2639         else
2640          if test -z "$GCC_USE_GNU_LD"; then
2641           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2642          else
2643           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2644          fi
2645         fi
2646         ;;
2647     *-darwin*)
2648         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2649         ;;
2650     *-mingw*)
2651         if test -n "$GNU_CC"; then
2652            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2653         fi
2654         ;;
2655 esac
2657 if test -z "$COMPILE_ENVIRONMENT"; then
2658     SKIP_COMPILER_CHECKS=1
2659     SKIP_LIBRARY_CHECKS=1
2660 else
2661     MOZ_COMPILER_OPTS
2662 fi # COMPILE_ENVIRONMENT
2664 if test -z "$SKIP_COMPILER_CHECKS"; then
2665 dnl Checks for typedefs, structures, and compiler characteristics.
2666 dnl ========================================================
2667 AC_HEADER_STDC
2668 AC_C_CONST
2669 AC_TYPE_MODE_T
2670 AC_TYPE_OFF_T
2671 AC_TYPE_PID_T
2672 AC_TYPE_SIZE_T
2673 AC_LANG_CPLUSPLUS
2674 AC_LANG_C
2676 AC_LANG_CPLUSPLUS
2678 MOZ_CXX11
2680 AC_LANG_C
2682 dnl Check for .hidden assembler directive and visibility attribute.
2683 dnl Borrowed from glibc configure.in
2684 dnl ===============================================================
2685 if test "$GNU_CC" -a "$OS_TARGET" != WINNT; then
2686   AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
2687   AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
2688   case "$OS_TARGET" in
2689   Darwin)
2690     VISIBILITY_FLAGS='-fvisibility=hidden -fvisibility-inlines-hidden'
2691     ;;
2692   *)
2693     VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(MOZILLA_DIR)/config/gcc_hidden.h'
2694     WRAP_SYSTEM_INCLUDES=1
2695     ;;
2696   esac
2697 fi         # GNU_CC
2699 # visibility hidden flag for Sun Studio on Solaris
2700 if test "$SOLARIS_SUNPRO_CC"; then
2701 VISIBILITY_FLAGS='-xldscope=hidden'
2702 fi         # Sun Studio on Solaris
2704 case "${OS_TARGET}" in
2705 WINNT|Darwin|Android)
2706   ;;
2708   STL_FLAGS='-I$(DIST)/stl_wrappers'
2709   WRAP_STL_INCLUDES=1
2710   ;;
2711 esac
2713 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2714 AC_SUBST(VISIBILITY_FLAGS)
2716 MOZ_GCC_PR49911
2717 MOZ_LLVM_PR8927
2719 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
2720 dnl ========================================================
2721 if test "$GNU_CC"; then
2722   CFLAGS_save="${CFLAGS}"
2723   CFLAGS="${CFLAGS} -Werror"
2724   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
2725                  ac_cv_force_align_arg_pointer,
2726                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
2727                                  [],
2728                                  ac_cv_force_align_arg_pointer="yes",
2729                                  ac_cv_force_align_arg_pointer="no")])
2730   CFLAGS="${CFLAGS_save}"
2731   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
2732     HAVE_GCC_ALIGN_ARG_POINTER=1
2733   else
2734     HAVE_GCC_ALIGN_ARG_POINTER=
2735   fi
2737 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
2739 dnl Checks for header files.
2740 dnl ========================================================
2741 AC_HEADER_DIRENT
2742 case "$target_os" in
2743 freebsd*|openbsd*)
2744 # for stuff like -lXshm
2745     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
2746     ;;
2747 esac
2748 MOZ_CHECK_COMMON_HEADERS
2750 dnl These are all the places some variant of statfs can be hiding.
2751 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
2753 dnl Quota support
2754 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
2755 MOZ_CHECK_HEADERS([linux/quota.h],,,[#include <sys/socket.h>])
2757 dnl SCTP support - needs various network include headers
2758 MOZ_CHECK_HEADERS([linux/if_addr.h linux/rtnetlink.h],,,[#include <sys/socket.h>])
2759 MOZ_CHECK_HEADERS(sys/queue.h)
2761 MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
2763 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
2764 AC_CACHE_CHECK(for sockaddr_in.sin_len,
2765                    ac_cv_sockaddr_in_sin_len,
2766                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2767                                     #include <sys/types.h>
2768                                     #endif
2769                                     #include <netinet/in.h>
2770                                     struct sockaddr_in x;
2771                                     void *foo = (void*) &x.sin_len;],
2772                                    [],
2773                                    [ac_cv_sockaddr_in_sin_len=true],
2774                                    [ac_cv_sockaddr_in_sin_len=false])])
2775 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
2776   AC_DEFINE(HAVE_SIN_LEN)
2777 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
2778   AC_DEFINE(HAVE_SCONN_LEN)
2781 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
2782                ac_cv_sockaddr_in6_sin6_len,
2783                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2784                                 #include <sys/types.h>
2785                                 #endif
2786                                 #include <netinet/in.h>
2787                                 struct sockaddr_in6 x;
2788                                 void *foo = (void*) &x.sin6_len;],
2789                                [],
2790                                [ac_cv_sockaddr_in6_sin6_len=true],
2791                                [ac_cv_sockaddr_in6_sin6_len=false])])
2792 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
2793   AC_DEFINE(HAVE_SIN6_LEN)
2796 AC_CACHE_CHECK(for sockaddr.sa_len,
2797                ac_cv_sockaddr_sa_len,
2798                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2799                                 #include <sys/types.h>
2800                                 #endif
2801                                 #include <sys/socket.h>
2802                                 struct sockaddr x;
2803                                 void *foo = (void*) &x.sa_len;],
2804                                [],
2805                                [ac_cv_sockaddr_sa_len=true],
2806                                [ac_cv_sockaddr_sa_len=false])])
2807 if test "$ac_cv_sockaddr_sa_len" = true ; then
2808   AC_DEFINE(HAVE_SA_LEN)
2811 MOZ_ARG_ENABLE_BOOL(dtrace,
2812               [  --enable-dtrace         build with dtrace support if available (default=no)],
2813               [enable_dtrace="yes"],)
2814 if test "x$enable_dtrace" = "xyes"; then
2815   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
2816   if test -n "$HAVE_DTRACE"; then
2817       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
2818   else
2819       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
2820   fi
2822 AC_SUBST(HAVE_DTRACE)
2824 case $target in
2825 *-aix4.3*|*-aix5*)
2826     ;;
2828     MOZ_CHECK_HEADERS(sys/cdefs.h)
2829     ;;
2830 esac
2832 MOZ_LINUX_PERF_EVENT
2834 dnl Checks for libraries.
2835 dnl ========================================================
2836 case $target in
2837 *-hpux11.*)
2838     ;;
2840     AC_CHECK_LIB(c_r, gethostbyname_r)
2841     ;;
2842 esac
2844 dnl We don't want to link with libdl even if it's present on OS X, since
2845 dnl it's not used and not part of the default installation. OS/2 has dlfcn
2846 dnl in libc.
2847 dnl We don't want to link against libm or libpthread on Darwin since
2848 dnl they both are just symlinks to libSystem and explicitly linking
2849 dnl against libSystem causes issues when debugging (see bug 299601).
2850 case $target in
2851 *-darwin*)
2852     ;;
2854     AC_SEARCH_LIBS(dlopen, dl,
2855         MOZ_CHECK_HEADER(dlfcn.h,
2856         AC_DEFINE(HAVE_DLOPEN)))
2857     ;;
2858 esac
2860 _SAVE_CFLAGS="$CFLAGS"
2861 CFLAGS="$CFLAGS -D_GNU_SOURCE"
2862 AC_CHECK_FUNCS(dladdr memmem)
2863 CFLAGS="$_SAVE_CFLAGS"
2865 if test ! "$GNU_CXX"; then
2867     case $target in
2868     *-aix*)
2869         AC_CHECK_LIB(C_r, demangle)
2870         ;;
2871      *)
2872         AC_CHECK_LIB(C, demangle)
2873         ;;
2874      esac
2877 AC_CHECK_LIB(socket, socket)
2879 XLDFLAGS="$X_LIBS"
2880 XLIBS="$X_EXTRA_LIBS"
2882 dnl ========================================================
2883 dnl Checks for X libraries.
2884 dnl Ordering is important.
2885 dnl Xt is dependent upon SM as of X11R6
2886 dnl ========================================================
2887 if test "$no_x" = "yes"; then
2888     AC_DEFINE(NO_X11)
2889 else
2890     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
2891     XLIBS="-lX11 $XLIBS"
2892     _SAVE_LDFLAGS="$LDFLAGS"
2893     LDFLAGS="$XLDFLAGS $LDFLAGS"
2894     AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
2895         [MISSING_X="$MISSING_X -lX11"], $XLIBS)
2896     AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
2897         [MISSING_X="$MISSING_X -lXext"], $XLIBS)
2899     AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
2900         unset ac_cv_lib_Xt_XtFree
2901         AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
2902         AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
2903         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
2904             [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
2905         ])
2907     # AIX needs the motif library linked before libXt to prevent
2908     # crashes in plugins linked against Motif - Bug #98892
2909     case "${target_os}" in
2910     aix*)
2911         XT_LIBS="-lXm $XT_LIBS"
2912         ;;
2913     esac
2915     dnl ========================================================
2916     dnl = Check for XShm
2917     dnl ========================================================
2918     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
2919         $XLIBS $XEXT_LIBS)
2921     dnl ========================================================
2922     dnl = Check for Xss
2923     dnl ========================================================
2924     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
2925         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
2926             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
2927              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
2929     LDFLAGS="$_SAVE_LDFLAGS"
2930 fi # $no_x
2932 AC_SUBST_LIST(XCFLAGS)
2933 AC_SUBST_LIST(XLDFLAGS)
2934 AC_SUBST_LIST(XLIBS)
2935 AC_SUBST_LIST(XEXT_LIBS)
2936 AC_SUBST_LIST(XT_LIBS)
2937 AC_SUBST_LIST(XSS_LIBS)
2939 dnl ========================================================
2940 dnl = pthread support
2941 dnl = Start by checking whether the system support pthreads
2942 dnl ========================================================
2943 case "$target_os" in
2944 darwin*)
2945     MOZ_USE_PTHREADS=1
2946     ;;
2948     AC_CHECK_LIB(pthreads, pthread_create,
2949         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2950         AC_CHECK_LIB(pthread, pthread_create,
2951             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2952             AC_CHECK_LIB(c_r, pthread_create,
2953                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2954                 AC_CHECK_LIB(c, pthread_create,
2955                     MOZ_USE_PTHREADS=1
2956                 )
2957             )
2958         )
2959     )
2960     ;;
2961 esac
2963 dnl ========================================================
2964 dnl Check the command line for --with-pthreads
2965 dnl ========================================================
2966 MOZ_ARG_WITH_BOOL(pthreads,
2967 [  --with-pthreads         Force use of system pthread library with NSPR ],
2968 [ if test "$MOZ_USE_PTHREADS"x = x; then
2969     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2970 fi],
2971     MOZ_USE_PTHREADS=
2972     _PTHREAD_LDFLAGS=
2975 dnl ========================================================
2976 dnl Do the platform specific pthread hackery
2977 dnl ========================================================
2978 if test "$MOZ_USE_PTHREADS"x != x
2979 then
2980     dnl
2981     dnl See if -pthread is supported.
2982     dnl
2983     rm -f conftest*
2984     ac_cv_have_dash_pthread=no
2985     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2986     echo 'int main() { return 0; }' | cat > conftest.c
2987     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2988     if test $? -eq 0; then
2989         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2990             ac_cv_have_dash_pthread=yes
2991             case "$target_os" in
2992             freebsd*)
2993 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2994                 ;;
2995             *)
2996                 CFLAGS="$CFLAGS -pthread"
2997                 CXXFLAGS="$CXXFLAGS -pthread"
2998                 ;;
2999             esac
3000         fi
3001     fi
3002     rm -f conftest*
3003     AC_MSG_RESULT($ac_cv_have_dash_pthread)
3005     dnl
3006     dnl See if -pthreads is supported.
3007     dnl
3008     ac_cv_have_dash_pthreads=no
3009     if test "$ac_cv_have_dash_pthread" = "no"; then
3010         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
3011         echo 'int main() { return 0; }' | cat > conftest.c
3012         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
3013         if test $? -eq 0; then
3014             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3015                 ac_cv_have_dash_pthreads=yes
3016                 CFLAGS="$CFLAGS -pthreads"
3017                 CXXFLAGS="$CXXFLAGS -pthreads"
3018             fi
3019         fi
3020         rm -f conftest*
3021         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
3022     fi
3024     case "$target" in
3025         *-*-freebsd*)
3026             AC_DEFINE(_REENTRANT)
3027             AC_DEFINE(_THREAD_SAFE)
3028             dnl -pthread links in -lpthread, so don't specify it explicitly.
3029             if test "$ac_cv_have_dash_pthread" = "yes"; then
3030                 _PTHREAD_LDFLAGS="-pthread"
3031             fi
3032             ;;
3034         *-*-openbsd*|*-*-bsdi*)
3035             AC_DEFINE(_REENTRANT)
3036             AC_DEFINE(_THREAD_SAFE)
3037             dnl -pthread links in -lc_r, so don't specify it explicitly.
3038             if test "$ac_cv_have_dash_pthread" = "yes"; then
3039                 _PTHREAD_LDFLAGS="-pthread"
3040             fi
3041             ;;
3043         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3044             AC_DEFINE(_REENTRANT)
3045             ;;
3047         *-aix4.3*|*-aix5*)
3048             AC_DEFINE(_REENTRANT)
3049             ;;
3051         *-hpux11.*)
3052             AC_DEFINE(_REENTRANT)
3053             ;;
3055         *-*-solaris*)
3056             AC_DEFINE(_REENTRANT)
3057             if test "$SOLARIS_SUNPRO_CC"; then
3058                 CFLAGS="$CFLAGS -mt"
3059                 CXXFLAGS="$CXXFLAGS -mt"
3060             fi
3061             ;;
3062     esac
3063     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3064     AC_SUBST(MOZ_USE_PTHREADS)
3065     MOZ_CHECK_HEADERS(pthread.h)
3069 dnl Checks for library functions.
3070 dnl ========================================================
3071 AC_PROG_GCC_TRADITIONAL
3072 AC_FUNC_MEMCMP
3073 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf)
3075 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
3076 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
3077                ac_cv_clock_monotonic,
3078                [for libs in "" -lrt; do
3079                     _SAVE_LIBS="$LIBS"
3080                     LIBS="$LIBS $libs"
3081                     AC_TRY_LINK([#include <time.h>],
3082                                  [ struct timespec ts;
3083                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
3084                                  ac_cv_clock_monotonic=$libs
3085                                  LIBS="$_SAVE_LIBS"
3086                                  break,
3087                                  ac_cv_clock_monotonic=no)
3088                     LIBS="$_SAVE_LIBS"
3089                 done])
3090 if test "$ac_cv_clock_monotonic" != "no"; then
3091     HAVE_CLOCK_MONOTONIC=1
3092     REALTIME_LIBS=$ac_cv_clock_monotonic
3093     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3094     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3095     AC_SUBST_LIST(REALTIME_LIBS)
3098 dnl check for wcrtomb/mbrtowc
3099 dnl =======================================================================
3100 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3101 AC_LANG_SAVE
3102 AC_LANG_CPLUSPLUS
3103 AC_CACHE_CHECK(for wcrtomb,
3104     ac_cv_have_wcrtomb,
3105     [AC_TRY_LINK([#include <wchar.h>],
3106                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3107                  ac_cv_have_wcrtomb="yes",
3108                  ac_cv_have_wcrtomb="no")])
3109 if test "$ac_cv_have_wcrtomb" = "yes"; then
3110     AC_DEFINE(HAVE_WCRTOMB)
3112 AC_CACHE_CHECK(for mbrtowc,
3113     ac_cv_have_mbrtowc,
3114     [AC_TRY_LINK([#include <wchar.h>],
3115                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3116                  ac_cv_have_mbrtowc="yes",
3117                  ac_cv_have_mbrtowc="no")])
3118 if test "$ac_cv_have_mbrtowc" = "yes"; then
3119     AC_DEFINE(HAVE_MBRTOWC)
3121 AC_LANG_RESTORE
3124 AC_CACHE_CHECK(
3125     [for res_ninit()],
3126     ac_cv_func_res_ninit,
3127     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
3128         dnl no need for res_ninit() on NetBSD and OpenBSD
3129         ac_cv_func_res_ninit=no
3130      else
3131         AC_TRY_LINK([
3132             #ifdef linux
3133             #define _BSD_SOURCE 1
3134             #endif
3135             #include <sys/types.h>
3136             #include <netinet/in.h>
3137             #include <arpa/nameser.h>
3138             #include <resolv.h>
3139             ],
3140             [int foo = res_ninit(&_res);],
3141             [ac_cv_func_res_ninit=yes],
3142             [ac_cv_func_res_ninit=no])
3143      fi
3144     ])
3146 if test "$ac_cv_func_res_ninit" = "yes"; then
3147     AC_DEFINE(HAVE_RES_NINIT)
3148 dnl must add the link line we do something as foolish as this... dougt
3149 dnl else
3150 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3151 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3154 AC_LANG_CPLUSPLUS
3156 ICONV_LIBS=
3158 case $target_os in
3159     darwin*|mingw*)
3160         ;;
3161     *)
3163 AC_CHECK_LIB(c, iconv, [ICONV_LIBS=],
3164     AC_CHECK_LIB(iconv, iconv, [ICONV_LIBS="-liconv"],
3165         AC_CHECK_LIB(iconv, libiconv, [ICONV_LIBS="-liconv"])))
3166 _SAVE_LIBS=$LIBS
3167 LIBS="$LIBS $ICONV_LIBS"
3168 AC_CACHE_CHECK(
3169     [for iconv()],
3170     ac_cv_func_iconv,
3171     [AC_TRY_LINK([
3172         #include <stdlib.h>
3173         #include <iconv.h>
3174         ],
3175         [
3176             iconv_t h = iconv_open("", "");
3177             iconv(h, NULL, NULL, NULL, NULL);
3178             iconv_close(h);
3179         ],
3180         [ac_cv_func_iconv=yes],
3181         [ac_cv_func_iconv=no]
3182         )]
3183     )
3184 if test "$ac_cv_func_iconv" = "yes"; then
3185     AC_DEFINE(HAVE_ICONV)
3186     LIBICONV="$ICONV_LIBS"
3187     AC_CACHE_CHECK(
3188         [for iconv() with const input],
3189         ac_cv_func_const_iconv,
3190         [AC_TRY_COMPILE([
3191             #include <stdlib.h>
3192             #include <iconv.h>
3193             ],
3194             [
3195                 const char *input = "testing";
3196                 iconv_t h = iconv_open("", "");
3197                 iconv(h, &input, NULL, NULL, NULL);
3198                 iconv_close(h);
3199             ],
3200             [ac_cv_func_const_iconv=yes],
3201             [ac_cv_func_const_iconv=no]
3202             )]
3203         )
3204     if test "$ac_cv_func_const_iconv" = "yes"; then
3205         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3206     fi
3208 LIBS=$_SAVE_LIBS
3210     ;;
3211 esac
3213 AC_SUBST_LIST(ICONV_LIBS)
3215 AM_LANGINFO_CODESET
3217 AC_LANG_C
3219 dnl **********************
3220 dnl *** va_copy checks ***
3221 AC_CACHE_CHECK([for an implementation of va_copy()],
3222                ac_cv_va_copy,
3223     [AC_TRY_COMPILE([#include <stdarg.h>
3224                      #include <stdlib.h>
3225         void f (int i, ...) {
3226             va_list args1, args2;
3227             va_start (args1, i);
3228             va_copy (args2, args1);
3229             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3230                 exit (1);
3231             va_end (args1); va_end (args2);
3232         }],
3233         [f(0, 42); return 0],
3234         [ac_cv_va_copy=yes],
3235         [ac_cv_va_copy=no]
3236     )]
3238 AC_CACHE_CHECK([whether va_list can be copied by value],
3239                ac_cv_va_val_copy,
3240     [AC_TRY_COMPILE([#include <stdarg.h>
3241                      #include <stdlib.h>
3242         void f (int i, ...) {
3243             va_list args1, args2;
3244             va_start (args1, i);
3245             args2 = args1;
3246             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3247                 exit (1);
3248             va_end (args1); va_end (args2);
3249         }],
3250         [f(0, 42); return 0],
3251         [ac_cv_va_val_copy=yes],
3252         [ac_cv_va_val_copy=no],
3253     )]
3255 if test "x$ac_cv_va_copy" = "xyes"; then
3256     AC_DEFINE(VA_COPY, va_copy)
3257     AC_DEFINE(HAVE_VA_COPY)
3260 if test "x$ac_cv_va_val_copy" = "xno"; then
3261    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3264 dnl ===================================================================
3265 dnl ========================================================
3266 dnl Put your C++ language/feature checks below
3267 dnl ========================================================
3268 AC_LANG_CPLUSPLUS
3270 ARM_ABI_PREFIX=
3271 if test "$GNU_CC"; then
3272   if test "$CPU_ARCH" = "arm" ; then
3273     AC_CACHE_CHECK(for ARM EABI,
3274         ac_cv_gcc_arm_eabi,
3275         [AC_TRY_COMPILE([],
3276                         [
3277 #if defined(__ARM_EABI__)
3278   return 0;
3279 #else
3280 #error Not ARM EABI.
3281 #endif
3282                         ],
3283                         ac_cv_gcc_arm_eabi="yes",
3284                         ac_cv_gcc_arm_eabi="no")])
3285     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
3286         HAVE_ARM_EABI=1
3287         ARM_ABI_PREFIX=eabi-
3288     else
3289         ARM_ABI_PREFIX=oabi-
3290     fi
3291   fi
3293   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
3296 dnl Check to see if we can resolve ambiguity with |using|.
3297 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
3298                ac_cv_cpp_ambiguity_resolving_using,
3299                [AC_TRY_COMPILE(class X {
3300                                  public: int go(const X&) {return 3;}
3301                                          int jo(const X&) {return 3;}
3302                                };
3303                                class Y : public X {
3304                                  public:  int go(int) {return 2;}
3305                                           int jo(int) {return 2;}
3306                                           using X::jo;
3307                                  private: using X::go;
3308                                };,
3309                                X x; Y y; y.jo(x);,
3310                                ac_cv_cpp_ambiguity_resolving_using=yes,
3311                                ac_cv_cpp_ambiguity_resolving_using=no)])
3312 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
3313    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
3316 dnl See if a dynamic_cast to void* gives the most derived object.
3317 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
3318                ac_cv_cpp_dynamic_cast_void_ptr,
3319                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
3320                             class Y { int j; public: virtual ~Y() { } };
3321                             class Z : public X, public Y { int k; };
3323                             int main() {
3324                                  Z mdo;
3325                                  X *subx = (X*)&mdo;
3326                                  Y *suby = (Y*)&mdo;
3327                                  return !((((void*)&mdo != (void*)subx) &&
3328                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
3329                                           (((void*)&mdo != (void*)suby) &&
3330                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
3331                             }],
3332                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
3333                            ac_cv_cpp_dynamic_cast_void_ptr=no,
3334                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
3335 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
3336    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
3340 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
3341 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
3342 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
3343 # linking XUL.
3344 _SAVE_LDFLAGS=$LDFLAGS
3345 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
3346 AC_CACHE_CHECK(for __thread keyword for TLS variables,
3347                ac_cv_thread_keyword,
3348                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
3349                             [return tlsIsMainThread;],
3350                             ac_cv_thread_keyword=yes,
3351                             ac_cv_thread_keyword=no)])
3352 LDFLAGS=$_SAVE_LDFLAGS
3353 # The custom dynamic linker doesn't support TLS variables
3354 MOZ_TLS=
3355 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
3356   # mips builds fail with TLS variables because of a binutils bug.
3357   # See bug 528687
3358   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
3359   case "${target}" in
3360     mips*-*)
3361       :
3362       ;;
3363     *-android*|*-linuxandroid*)
3364       :
3365       ;;
3366     *-openbsd*)
3367       :
3368       ;;
3369     *)
3370       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
3371       MOZ_TLS=1
3372       ;;
3373   esac
3376 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
3377 if test -n "$MOZ_LINKER"; then
3378   if test "$CPU_ARCH" = arm; then
3379     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
3380     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
3381       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3382       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3383     fi
3384   fi
3386 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
3387 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
3388 dnl Since the linker only understands the sysv ones, no need to build the
3389 dnl gnu style tables anyways.
3390   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
3393 dnl The custom linker doesn't support text relocations, but NDK >= r6b
3394 dnl creates some (http://code.google.com/p/android/issues/detail?id=23203)
3395 dnl We however want to avoid these text relocations, and this can be done
3396 dnl by making gcc not link crtbegin and crtend. In the broken NDKs, crtend
3397 dnl doesn't contain anything at all, beside placeholders for some sections,
3398 dnl and crtbegin only contains a finalizer function that calls
3399 dnl __cxa_finalize. The custom linker actually takes care of calling
3400 dnl __cxa_finalize when the library doesn't call it itself, which makes it
3401 dnl safe not to link crtbegin. Besides, previous versions of the NDK didn't
3402 dnl link crtbegin and crtend at all.
3403 if test -n "$MOZ_LINKER" -a "$OS_TARGET" = "Android"; then
3404   AC_CACHE_CHECK([whether the CRT objects have text relocations],
3405     ac_cv_crt_has_text_relocations,
3406     [echo 'int foo() { return 0; }' > conftest.cpp
3407      if AC_TRY_COMMAND(${CXX-g++} -o conftest${DLL_SUFFIX} $CXXFLAGS $DSO_LDOPTS $LDFLAGS conftest.cpp $LIBS 1>&5) &&
3408         test -s conftest${DLL_SUFFIX}; then
3409        if ${TOOLCHAIN_PREFIX}readelf -d conftest${DLL_SUFFIX} | grep TEXTREL > /dev/null; then
3410          ac_cv_crt_has_text_relocations=yes
3411        else
3412          ac_cv_crt_has_text_relocations=no
3413        fi
3414      else
3415        AC_ERROR([couldn't compile a simple C file])
3416      fi
3417      rm -rf conftest*])
3418   if test "$ac_cv_crt_has_text_relocations" = yes; then
3419     dnl While we want libraries to skip the CRT files, we don't want
3420     dnl executables to be treated the same way. We thus set the flag
3421     dnl in DSO_LDOPTS and not LDFLAGS. However, to pass it to nspr,
3422     dnl we need to use LDFLAGS because nspr doesn't inherit DSO_LDOPTS.
3423     dnl Using LDFLAGS in nspr is safe, since we only really build
3424     dnl libraries there.
3425     DSO_LDOPTS="$DSO_LDOPTS -nostartfiles"
3426     NSPR_LDFLAGS="$NSPR_LDFLAGS -nostartfiles"
3427   fi
3430 dnl See if compiler supports some gcc-style attributes
3432 AC_CACHE_CHECK(for __attribute__((always_inline)),
3433                ac_cv_attribute_always_inline,
3434                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
3435                                [],
3436                                ac_cv_attribute_always_inline=yes,
3437                                ac_cv_attribute_always_inline=no)])
3439 dnl End of C++ language/feature checks
3440 AC_LANG_C
3442 dnl ========================================================
3443 dnl =  Internationalization checks
3444 dnl ========================================================
3446 dnl Internationalization and Locale support is different
3447 dnl on various UNIX platforms.  Checks for specific i18n
3448 dnl features go here.
3450 dnl check for LC_MESSAGES
3451 AC_CACHE_CHECK(for LC_MESSAGES,
3452                ac_cv_i18n_lc_messages,
3453                [AC_TRY_COMPILE([#include <locale.h>],
3454                                [int category = LC_MESSAGES;],
3455                                ac_cv_i18n_lc_messages=yes,
3456                                ac_cv_i18n_lc_messages=no)])
3457 if test "$ac_cv_i18n_lc_messages" = yes; then
3458    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
3461 AC_HAVE_FUNCS(localeconv)
3462 fi # ! SKIP_COMPILER_CHECKS
3464 MOZ_CHECK_ALLOCATOR
3466 TARGET_XPCOM_ABI=
3467 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
3468     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
3469     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
3472 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
3473 dnl features that Windows actually does support.
3475 if test -n "$SKIP_COMPILER_CHECKS"; then
3476    dnl Windows has malloc.h
3477    AC_DEFINE(MALLOC_H, [<malloc.h>])
3478    AC_DEFINE(HAVE_FORCEINLINE)
3479    AC_DEFINE(HAVE_LOCALECONV)
3480 fi # SKIP_COMPILER_CHECKS
3482 dnl Mozilla specific options
3483 dnl ========================================================
3484 dnl The macros used for command line options
3485 dnl are defined in build/autoconf/altoptions.m4.
3487 dnl ========================================================
3488 dnl =
3489 dnl = Check for external package dependencies
3490 dnl =
3491 dnl ========================================================
3492 MOZ_ARG_HEADER(External Packages)
3494 MOZ_ARG_WITH_STRING(libxul-sdk,
3495 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
3496   AC_MSG_ERROR([--with-libxul-sdk is not supported anymore.]))
3498 LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
3499 AC_SUBST(LIBXUL_DIST)
3501 MOZ_CONFIG_NSPR()
3503 dnl set GRE_MILESTONE
3504 dnl ========================================================
3505 if test -n "$LIBXUL_SDK"; then
3506     GRE_MILESTONE=`$PYTHON "$_topsrcdir"/config/printconfigsetting.py "$LIBXUL_DIST"/bin/platform.ini Build Milestone`
3507 else
3508     GRE_MILESTONE=`tail -n 1 "$_topsrcdir"/config/milestone.txt 2>/dev/null || tail -1 "$_topsrcdir"/config/milestone.txt`
3510 AC_SUBST(GRE_MILESTONE)
3512 # set RELEASE_BUILD and NIGHTLY_BUILD variables depending on the cycle we're in
3513 # The logic works like this:
3514 # - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
3515 # - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
3516 # - otherwise, we're building Release/Beta (define RELEASE_BUILD)
3517 case "$GRE_MILESTONE" in
3518   *a1*)
3519       NIGHTLY_BUILD=1
3520       AC_DEFINE(NIGHTLY_BUILD)
3521       ;;
3522   *a*)
3523       ;;
3524   *)
3525       RELEASE_BUILD=1
3526       AC_DEFINE(RELEASE_BUILD)
3527       ;;
3528 esac
3529 AC_SUBST(NIGHTLY_BUILD)
3530 AC_SUBST(RELEASE_BUILD)
3532 dnl ========================================================
3533 dnl Multiprocess Firefox Testing UI - Nightly and Aurora
3534 dnl To be removed in Bug 1003313
3535 dnl ========================================================
3536 if test -z "$RELEASE_BUILD"; then
3537     E10S_TESTING_ONLY=1
3538     AC_DEFINE(E10S_TESTING_ONLY)
3541 AC_SUBST(E10S_TESTING_ONLY)
3543 dnl ========================================================
3544 dnl system libevent Support
3545 dnl ========================================================
3546 MOZ_ARG_WITH_STRING(system-libevent,
3547 [  --with-system-libevent[=PFX]
3548                           Use system libevent [installed at prefix PFX]],
3549     LIBEVENT_DIR=$withval)
3551 _SAVE_CFLAGS=$CFLAGS
3552 _SAVE_LDFLAGS=$LDFLAGS
3553 _SAVE_LIBS=$LIBS
3554 if test "$LIBEVENT_DIR" = yes; then
3555     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
3556         MOZ_NATIVE_LIBEVENT=1,
3557         LIBEVENT_DIR=/usr)
3559 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
3560     MOZ_NATIVE_LIBEVENT=
3561 elif test -z "$MOZ_NATIVE_LIBEVENT"; then
3562     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
3563     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
3564     MOZ_CHECK_HEADER(event.h,
3565         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
3566              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
3567          fi],
3568         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
3569     AC_CHECK_LIB(event, event_init,
3570                  [MOZ_NATIVE_LIBEVENT=1
3571                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
3572                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
3573                  [MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
3575 CFLAGS=$_SAVE_CFLAGS
3576 LDFLAGS=$_SAVE_LDFLAGS
3577 LIBS=$_SAVE_LIBS
3579 AC_SUBST(MOZ_NATIVE_LIBEVENT)
3581 dnl ========================================================
3582 dnl = If NSS was not detected in the system,
3583 dnl = use the one in the source tree (mozilla/security/nss)
3584 dnl ========================================================
3586 MOZ_ARG_WITH_BOOL(system-nss,
3587 [  --with-system-nss       Use system installed NSS],
3588     _USE_SYSTEM_NSS=1 )
3590 if test -n "$_USE_SYSTEM_NSS"; then
3591     AM_PATH_NSS(3.19.2, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
3594 if test -n "$MOZ_NATIVE_NSS"; then
3595    NSS_LIBS="$NSS_LIBS -lcrmf"
3596 else
3597    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
3599    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT"; then
3600        NSS_LIBS="\
3601         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
3602         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
3603         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
3604         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
3605         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
3606    else
3607        NSS_LIBS='-L$(LIBXUL_DIST)/lib'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
3608    fi
3611 dnl ======================
3612 dnl Detect yasm
3613 dnl ======================
3615 AC_MSG_CHECKING([for YASM assembler])
3616 AC_CHECK_PROGS(YASM, yasm, "")
3618 if test -n "$YASM"; then
3619   dnl Pull out yasm's version string
3620   YASM_VERSION=`yasm --version | $AWK '/^yasm/ { print $2 }'`
3621   _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
3622   _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
3623   _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
3624   _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
3627 if test -z "$SKIP_LIBRARY_CHECKS"; then
3628 dnl system JPEG support
3629 dnl ========================================================
3630 MOZ_ARG_WITH_STRING(system-jpeg,
3631 [  --with-system-jpeg[=PFX]
3632                           Use system libjpeg [installed at prefix PFX]],
3633     JPEG_DIR=$withval)
3635 _SAVE_CFLAGS=$CFLAGS
3636 _SAVE_LDFLAGS=$LDFLAGS
3637 _SAVE_LIBS=$LIBS
3638 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
3639     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
3640     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
3642 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
3643     MOZ_NATIVE_JPEG=
3644 else
3645     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_NATIVE_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_NATIVE_JPEG=)
3648 if test "$MOZ_NATIVE_JPEG" = 1; then
3649     AC_TRY_COMPILE([ #include <stdio.h>
3650                      #include <sys/types.h>
3651                      #include <jpeglib.h> ],
3652                    [ #if JPEG_LIB_VERSION < $MOZJPEG
3653                      #error "Insufficient JPEG library version ($MOZJPEG required)."
3654                      #endif
3655                      #ifndef JCS_EXTENSIONS
3656                      #error "libjpeg-turbo JCS_EXTENSIONS required"
3657                      #endif
3658                      ],
3659                    MOZ_NATIVE_JPEG=1,
3660                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
3662 CFLAGS=$_SAVE_CFLAGS
3663 LDFLAGS=$_SAVE_LDFLAGS
3664 LIBS=$_SAVE_LIBS
3666 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
3667     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
3668     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
3670 fi # SKIP_LIBRARY_CHECKS
3672 dnl system ZLIB support
3673 dnl ========================================================
3674 MOZ_ZLIB_CHECK([1.2.3])
3676 if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
3677     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
3680 MOZ_PNG_ARM_NEON=
3682 if test -z "$SKIP_LIBRARY_CHECKS"; then
3683 dnl system BZIP2 Support
3684 dnl ========================================================
3685 MOZ_ARG_WITH_STRING(system-bz2,
3686 [  --with-system-bz2[=PFX]
3687                           Use system libbz2 [installed at prefix PFX]],
3688     BZ2_DIR=$withval)
3690 _SAVE_CFLAGS=$CFLAGS
3691 _SAVE_LDFLAGS=$LDFLAGS
3692 _SAVE_LIBS=$LIBS
3693 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
3694     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
3695     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
3697 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
3698     MOZ_NATIVE_BZ2=
3699 else
3700     AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_NATIVE_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
3701     [MOZ_NATIVE_BZ2= MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS=])
3703 CFLAGS=$_SAVE_CFLAGS
3704 LDFLAGS=$_SAVE_LDFLAGS
3705 LIBS=$_SAVE_LIBS
3707 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_NATIVE_BZ2" = 1; then
3708     MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
3709     MOZ_BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
3712 dnl ========================================================
3713 dnl system PNG Support
3714 dnl ========================================================
3715 MOZ_ARG_WITH_STRING(system-png,
3716 [  --with-system-png[=PFX]
3717                           Use system libpng [installed at prefix PFX]],
3718     PNG_DIR=$withval)
3720 _SAVE_CFLAGS=$CFLAGS
3721 _SAVE_LDFLAGS=$LDFLAGS
3722 _SAVE_LIBS=$LIBS
3723 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
3724     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
3725     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
3727 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
3728     MOZ_NATIVE_PNG=
3729 else
3730     AC_CHECK_LIB(png, png_get_valid, [MOZ_NATIVE_PNG=1 MOZ_PNG_LIBS="-lpng"],
3731                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
3732     AC_CHECK_LIB(png, png_get_acTL, ,
3733                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
3735 if test "$MOZ_NATIVE_PNG" = 1; then
3736     AC_TRY_COMPILE([ #include <stdio.h>
3737                      #include <sys/types.h>
3738                      #include <png.h> ],
3739                    [ #if PNG_LIBPNG_VER < $MOZPNG
3740                      #error "Insufficient libpng version ($MOZPNG required)."
3741                      #endif
3742                      #ifndef PNG_UINT_31_MAX
3743                      #error "Insufficient libpng version."
3744                      #endif ],
3745                    MOZ_NATIVE_PNG=1,
3746                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
3748 CFLAGS=$_SAVE_CFLAGS
3749 LDFLAGS=$_SAVE_LDFLAGS
3750 LIBS=$_SAVE_LIBS
3752 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_NATIVE_PNG" = 1; then
3753     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
3754     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
3757 MOZ_PNG_ARM_NEON_CHECK=
3758 if test "$MOZ_NATIVE_PNG" != 1 -a "$CPU_ARCH" = "arm" ; then
3759     MOZ_ARG_ENABLE_STRING(png-arm-neon-support,
3760         [  --enable-png-arm-neon-support=TYPE
3761              Options include:
3762                  no
3763                  check (default)
3764                  nocheck (faster but unsafe)],
3765         [MOZ_PNG_ARM_NEON_SUPPORT=$enableval ] )
3766     case "$MOZ_PNG_ARM_NEON_SUPPORT" in
3767         no)
3768             # enable-png-arm-neon-support = no
3769             ;;
3770         nocheck)
3771             # enable-png-arm-neon-support = nocheck
3772             MOZ_PNG_ARM_NEON=1
3773             ;;
3774         *)
3775             MOZ_PNG_ARM_NEON=1
3776             MOZ_PNG_ARM_NEON_CHECK=1
3777             ;;
3778     esac
3781 AC_SUBST(MOZ_PNG_ARM_NEON_CHECK)
3783 fi # SKIP_LIBRARY_CHECKS
3785 AC_SUBST(MOZ_PNG_ARM_NEON)
3787 dnl ========================================================
3788 dnl system HunSpell Support
3789 dnl ========================================================
3790 MOZ_ARG_ENABLE_BOOL(system-hunspell,
3791 [  --enable-system-hunspell
3792                           Use system hunspell (located with pkgconfig)],
3793     MOZ_NATIVE_HUNSPELL=1 )
3795 if test -n "$MOZ_NATIVE_HUNSPELL"; then
3796     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
3799 AC_SUBST(MOZ_NATIVE_HUNSPELL)
3801 dnl ========================================================
3802 dnl system libffi Support
3803 dnl ========================================================
3804 MOZ_CONFIG_FFI()
3806 MOZ_ARG_ENABLE_BOOL(shared-js,
3807 [  --enable-shared-js
3808                           Create a shared JavaScript library.],
3809     JS_SHARED_LIBRARY=1,
3810     JS_SHARED_LIBRARY=)
3812 dnl ========================================================
3813 dnl Java SDK support
3814 dnl ========================================================
3816 JAVA_BIN_PATH=
3817 MOZ_ARG_WITH_STRING(java-bin-path,
3818 [  --with-java-bin-path=dir
3819                           Location of Java binaries (java, javac, jar)],
3820     JAVA_BIN_PATH=$withval)
3822 dnl ========================================================
3823 dnl =
3824 dnl = Application
3825 dnl =
3826 dnl ========================================================
3828 MOZ_ARG_HEADER(Application)
3830 ENABLE_TESTS=1
3831 ENABLE_SYSTEM_EXTENSION_DIRS=1
3832 MOZ_BRANDING_DIRECTORY=
3833 MOZ_OFFICIAL_BRANDING=
3834 MOZ_FEEDS=1
3835 MOZ_WEBAPP_RUNTIME=
3836 MOZ_AUTH_EXTENSION=1
3837 if test "$MOZ_IOS"; then
3838    MOZ_AUTH_EXTENSION=
3840 MOZ_RAW=
3841 MOZ_VORBIS=
3842 MOZ_TREMOR=
3843 MOZ_WAVE=1
3844 MOZ_SAMPLE_TYPE_FLOAT32=
3845 MOZ_SAMPLE_TYPE_S16=
3846 MOZ_WEBM=1
3847 MOZ_GSTREAMER=
3848 MOZ_DIRECTSHOW=
3849 MOZ_WMF=
3850 if test -n "$MOZ_FMP4"; then
3851   MOZ_FMP4=1
3852 else
3853   MOZ_FMP4=
3855 MOZ_FFMPEG=
3856 MOZ_WEBRTC=1
3857 MOZ_PEERCONNECTION=
3858 MOZ_SRTP=
3859 MOZ_WEBRTC_SIGNALING=
3860 MOZ_WEBRTC_ASSERT_ALWAYS=1
3861 MOZ_WEBRTC_HARDWARE_AEC_NS=
3862 MOZ_SCTP=
3863 MOZ_ANDROID_OMX=
3864 MOZ_MEDIA_NAVIGATOR=
3865 MOZ_OMX_PLUGIN=
3866 MOZ_VPX=
3867 MOZ_VPX_ERROR_CONCEALMENT=
3868 MOZ_WEBSPEECH=1
3869 MOZ_WEBSPEECH_MODELS=
3870 MOZ_WEBSPEECH_POCKETSPHINX=
3871 MOZ_WEBSPEECH_TEST_BACKEND=1
3872 VPX_AS=
3873 VPX_ASFLAGS=
3874 VPX_AS_CONVERSION=
3875 VPX_ASM_SUFFIX=
3876 VPX_X86_ASM=
3877 VPX_ARM_ASM=
3878 LIBJPEG_TURBO_AS=
3879 LIBJPEG_TURBO_ASFLAGS=
3880 MOZ_PERMISSIONS=1
3881 MOZ_PLACES=1
3882 MOZ_SOCIAL=1
3883 MOZ_PREF_EXTENSIONS=1
3884 MOZ_PROFILELOCKING=1
3885 MOZ_REFLOW_PERF=
3886 MOZ_SAFE_BROWSING=
3887 MOZ_HELP_VIEWER=
3888 MOZ_SPELLCHECK=1
3889 MOZ_ANDROID_APZ=
3890 MOZ_TOOLKIT_SEARCH=1
3891 MOZ_UI_LOCALE=en-US
3892 MOZ_UNIVERSALCHARDET=1
3893 MOZ_URL_CLASSIFIER=
3894 MOZ_XUL=1
3895 MOZ_ZIPWRITER=1
3896 NS_PRINTING=1
3897 if test "$MOZ_IOS"; then
3898    NS_PRINTING=
3900 MOZ_PDF_PRINTING=
3901 MOZ_NO_SMART_CARDS=
3902 NSS_DISABLE_DBM=
3903 NECKO_COOKIES=1
3904 NECKO_PROTOCOLS_DEFAULT="about app data file ftp http res viewsource websocket wyciwyg device"
3905 if test -n "$MOZ_RTSP"; then
3906   NECKO_PROTOCOLS_DEFAULT="$NECKO_PROTOCOLS_DEFAULT rtsp"
3908 USE_ARM_KUSER=
3909 BUILD_CTYPES=1
3910 MOZ_USE_NATIVE_POPUP_WINDOWS=
3911 MOZ_ANDROID_HISTORY=
3912 MOZ_WEBSMS_BACKEND=
3913 MOZ_ANDROID_BEAM=
3914 MOZ_LOCALE_SWITCHER=
3915 MOZ_ANDROID_READING_LIST_SERVICE=
3916 MOZ_ANDROID_SEARCH_ACTIVITY=
3917 MOZ_ANDROID_DOWNLOADS_INTEGRATION=
3918 MOZ_ANDROID_MLS_STUMBLER=
3919 MOZ_ANDROID_SHARE_OVERLAY=
3920 MOZ_INSTALL_TRACKING=
3921 ACCESSIBILITY=1
3922 MOZ_TIME_MANAGER=
3923 MOZ_SIMPLEPUSH=
3924 MOZ_PAY=
3925 MOZ_AUDIO_CHANNEL_MANAGER=
3926 MOZ_CONTENT_SANDBOX=
3927 MOZ_GMP_SANDBOX=
3928 MOZ_SANDBOX=1
3929 MOZ_BINARY_EXTENSIONS=
3930 MOZ_ADDON_SIGNING=
3931 MOZ_REQUIRE_SIGNING=
3933 case "$target_os" in
3934     mingw*)
3935         NS_ENABLE_TSF=1
3936         AC_DEFINE(NS_ENABLE_TSF)
3937         ;;
3938 esac
3940 case "${target}" in
3941     *-android*|*-linuxandroid*)
3942         if test "$CPU_ARCH" = "arm" ; then
3943           USE_ARM_KUSER=1
3944         fi
3946         NSS_DISABLE_DBM=1
3947         MOZ_THEME_FASTSTRIPE=1
3948         MOZ_TREE_FREETYPE=1
3949         if test "$COMPILE_ENVIRONMENT"; then
3950             MOZ_MEMORY=1
3951         fi
3952         MOZ_RAW=1
3953         ;;
3955 esac
3957 MOZ_ARG_WITH_STRING(external-source-dir,
3958 [  --with-external-source-dir=dir
3959                           External directory containing additional build files.],
3960 [ EXTERNAL_SOURCE_DIR=$withval])
3961 AC_SUBST(EXTERNAL_SOURCE_DIR)
3963 MOZ_ARG_ENABLE_STRING(application,
3964 [  --enable-application=APP
3965                           Options include:
3966                             browser (Firefox)
3967                             xulrunner
3968                             tools/update-packaging (AUS-related packaging tools)],
3969 [ MOZ_BUILD_APP=$enableval ] )
3971 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
3972 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
3973   XULRUNNER_STUB_NAME=$withval)
3975 if test -z "$XULRUNNER_STUB_NAME"; then
3976   XULRUNNER_STUB_NAME=xulrunner-stub
3978 AC_SUBST(XULRUNNER_STUB_NAME)
3980 AC_MSG_CHECKING([for application to build])
3981 if test -z "$MOZ_BUILD_APP"; then
3982   AC_MSG_RESULT([browser])
3983   MOZ_BUILD_APP=browser
3984 else
3985   # "mobile" no longer exists.
3986   if test "$MOZ_BUILD_APP" = "mobile" ; then
3987     AC_MSG_RESULT([none])
3988     AC_MSG_ERROR([--enable-application=mobile is no longer supported.])
3989   fi
3990   # Support comm-central.
3991   if test -n "$EXTERNAL_SOURCE_DIR" ; then
3992     MOZ_BUILD_APP="$EXTERNAL_SOURCE_DIR/$MOZ_BUILD_APP"
3993     MOZ_BUILD_APP=`${PYTHON} -c "import mozpack.path as mozpath; print(mozpath.relpath(\"${MOZ_BUILD_APP}\", \"${srcdir}\"))"`
3994   fi
3995   # We have a valid application only if it has a build.mk file in its top
3996   # directory.
3997   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
3998     AC_MSG_RESULT([none])
3999     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
4000   else
4001     AC_MSG_RESULT([$MOZ_BUILD_APP])
4002   fi
4005 # The app update channel is 'default' when not supplied. The value is used in
4006 # the application's confvars.sh so it must be set before confvars.sh is called.
4007 MOZ_ARG_ENABLE_STRING([update-channel],
4008 [  --enable-update-channel=CHANNEL
4009                           Select application update channel (default=default)],
4010     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
4012 if test -z "$MOZ_UPDATE_CHANNEL"; then
4013     MOZ_UPDATE_CHANNEL=default
4015 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
4016 AC_SUBST(MOZ_UPDATE_CHANNEL)
4018 # Allow to specify a Mozilla API key file that contains the secret key to be
4019 # used for various Mozilla API requests.
4020 MOZ_ARG_WITH_STRING(mozilla-api-keyfile,
4021 [  --with-mozilla-api-keyfile=file   Use the secret key contained in the given keyfile for Mozilla API requests],
4022   MOZ_MOZILLA_API_KEY=`cat $withval`)
4023 if test -z "$MOZ_MOZILLA_API_KEY"; then
4024     MOZ_MOZILLA_API_KEY=no-mozilla-api-key
4026 AC_SUBST(MOZ_MOZILLA_API_KEY)
4028 # Allow to specify a Google API key file that contains the secret key to be
4029 # used for various Google API requests.
4030 MOZ_ARG_WITH_STRING(google-api-keyfile,
4031 [  --with-google-api-keyfile=file   Use the secret key contained in the given keyfile for Google API requests],
4032   MOZ_GOOGLE_API_KEY=`cat $withval`)
4033 if test -z "$MOZ_GOOGLE_API_KEY"; then
4034     MOZ_GOOGLE_API_KEY=no-google-api-key
4036 AC_SUBST(MOZ_GOOGLE_API_KEY)
4038 # Allow to specify a Google OAuth API key file that contains the client ID and
4039 # the secret key to be used for various Google OAuth API requests.
4040 MOZ_ARG_WITH_STRING(google-oauth-api-keyfile,
4041 [ --with-google-oauth-api-keyfile=file  Use the client id and secret key contained in the given keyfile for Google OAuth API requests],
4042  [MOZ_GOOGLE_OAUTH_API_CLIENTID=`cat $withval | cut -f 1 -d " "`
4043   MOZ_GOOGLE_OAUTH_API_KEY=`cat $withval | cut -f 2 -d " "`])
4044 if test -z "$MOZ_GOOGLE_OAUTH_API_CLIENTID"; then
4045     MOZ_GOOGLE_OAUTH_API_CLIENTID=no-google-oauth-api-clientid
4046     MOZ_GOOGLE_OAUTH_API_KEY=no-google-oauth-api-key
4048 AC_SUBST(MOZ_GOOGLE_OAUTH_API_CLIENTID)
4049 AC_SUBST(MOZ_GOOGLE_OAUTH_API_KEY)
4051 # Allow specifying a Bing API key file that contains the client ID and the
4052 # secret key to be used for the Bing Translation API requests.
4053 MOZ_ARG_WITH_STRING(bing-api-keyfile,
4054 [  --with-bing-api-keyfile=file   Use the client id and secret key contained in the given keyfile for Bing API requests],
4055  [MOZ_BING_API_CLIENTID=`cat $withval | cut -f 1 -d " "`
4056   MOZ_BING_API_KEY=`cat $withval | cut -f 2 -d " "`])
4057 if test -z "$MOZ_BING_API_CLIENTID"; then
4058     MOZ_BING_API_CLIENTID=no-bing-api-clientid
4059     MOZ_BING_API_KEY=no-bing-api-key
4061 AC_SUBST(MOZ_BING_API_CLIENTID)
4062 AC_SUBST(MOZ_BING_API_KEY)
4064 # Allow specifying an Adjust SDK key file that contains the app token used for
4065 # Adjust SDK requests.
4066 MOZ_ARG_WITH_STRING(adjust-sdk-keyfile,
4067 [  --with-adjust-sdk-keyfile=file   Use the app token contained in the given keyfile for Adjust SDK requests],
4068   MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN=`cat $withval`)
4069 AC_SUBST(MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN)
4071 # Whether to include optional-but-large font files in the final APK.
4072 # We want this in mobile/android/confvars.sh, so it goes early.
4073 MOZ_ARG_DISABLE_BOOL(android-include-fonts,
4074 [  --disable-android-include-fonts
4075                           Disable the inclusion of fonts into the final APK],
4076     MOZ_ANDROID_EXCLUDE_FONTS=1)
4078 if test -n "$MOZ_ANDROID_EXCLUDE_FONTS"; then
4079     AC_DEFINE(MOZ_ANDROID_EXCLUDE_FONTS)
4081 AC_SUBST(MOZ_ANDROID_EXCLUDE_FONTS)
4083 # Whether this APK is destined for resource constrained devices.
4084 # We want this in mobile/android/confvars.sh, so it goes early.
4085 MOZ_ARG_ENABLE_BOOL(android-resource-constrained,
4086 [  --enable-android-resource-constrained
4087                           Exclude hi-res images and similar from the final APK],
4088     MOZ_ANDROID_RESOURCE_CONSTRAINED=1)
4090 if test -n "$MOZ_ANDROID_RESOURCE_CONSTRAINED"; then
4091     AC_DEFINE(MOZ_ANDROID_RESOURCE_CONSTRAINED)
4093 AC_SUBST(MOZ_ANDROID_RESOURCE_CONSTRAINED)
4095 dnl ========================================================
4096 dnl = Trademarked Branding
4097 dnl ========================================================
4098 MOZ_ARG_ENABLE_BOOL(official-branding,
4099 [  --enable-official-branding
4100                           Enable Official mozilla.org Branding
4101                           Do not distribute builds with
4102                           --enable-official-branding unless you have
4103                           permission to use trademarks per
4104                           http://www.mozilla.org/foundation/trademarks/ .],
4105     MOZ_OFFICIAL_BRANDING=1,
4106     MOZ_OFFICIAL_BRANDING=)
4108 # Allow the application to influence configure with a confvars.sh script.
4109 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4110 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4111   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4112   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4113 else
4114   AC_MSG_RESULT([no])
4117 # Allow influencing configure with a defines.sh script.
4118 . "${srcdir}/build/defines.sh"
4120 # If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
4121 # set in defines.sh
4122 if test "$BUILDING_RELEASE"; then
4123   # Override value in defines.sh, if any
4124   EARLY_BETA_OR_EARLIER=
4125 elif test "$EARLY_BETA_OR_EARLIER"; then
4126   AC_DEFINE(EARLY_BETA_OR_EARLIER)
4128 AC_SUBST(EARLY_BETA_OR_EARLIER)
4130 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
4131 MOZ_ARG_WITH_STRING(app-name,
4132 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
4133 WITH_APP_NAME=$withval,
4136 if test -n "$WITH_APP_NAME" ; then
4137     MOZ_APP_NAME="$WITH_APP_NAME"
4140 MOZ_ARG_WITH_STRING(app-basename,
4141 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
4142 WITH_APP_BASENAME=$withval,
4145 if test -n "$WITH_APP_BASENAME" ; then
4146     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
4149 # Now is a good time to test for logic errors, define mismatches, etc.
4150 case "$MOZ_BUILD_APP" in
4151 xulrunner)
4152   if test "$LIBXUL_SDK"; then
4153     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4154   fi
4155   ;;
4156 esac
4158 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4159 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4160 # MOZ_BUILD_APP.
4161 case "$MOZ_BUILD_APP" in
4162 browser)
4163   AC_DEFINE(MOZ_PHOENIX)
4164   ;;
4166 xulrunner)
4167   AC_DEFINE(MOZ_XULRUNNER)
4168   ;;
4169 b2g)
4170   AC_DEFINE(MOZ_B2G)
4171   ;;
4172 b2g/dev)
4173   AC_DEFINE(MOZ_B2G)
4174   AC_DEFINE(MOZ_MULET)
4175   ;;
4176 esac
4178 AC_SUBST(MOZ_BUILD_APP)
4179 AC_SUBST(MOZ_PHOENIX)
4180 AC_SUBST(MOZ_XULRUNNER)
4181 AC_SUBST(MOZ_B2G)
4182 AC_SUBST(MOZ_MULET)
4183 AC_SUBST(MOZ_B2G_VERSION)
4185 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4187 case "$OS_TARGET" in
4188 WINNT|Darwin|Android)
4189   MOZ_FOLD_LIBS=1
4190   ;;
4192   MOZ_FOLD_LIBS=
4193   ;;
4194 esac
4196 dnl ========================================================
4197 dnl Check Android SDK version depending on mobile target.
4198 dnl ========================================================
4200 if test -z "$gonkdir" ; then
4201     # Minimum Android SDK API Level we require.
4202     case "$MOZ_BUILD_APP" in
4203     mobile/android)
4204         android_min_api_level=20
4205         case "$target" in
4206         *-android*|*-linuxandroid*)
4207             :
4208             ;;
4209         *)
4210             AC_MSG_ERROR([You must specify --target=arm-linux-androideabi (or some other valid android target) when building with --enable-application=mobile/android. See https://wiki.mozilla.org/Mobile/Fennec/Android#Setup_Fennec_mozconfig for more information about the necessary options])
4211             ;;
4212         esac
4213         ;;
4214     esac
4216     MOZ_ANDROID_SDK($android_min_api_level)
4219 dnl ========================================================
4220 dnl =
4221 dnl = Toolkit Options
4222 dnl =
4223 dnl ========================================================
4224 MOZ_ARG_HEADER(Toolkit Options)
4226     dnl ========================================================
4227     dnl = Select the default toolkit
4228     dnl ========================================================
4229     MOZ_ARG_ENABLE_STRING(default-toolkit,
4230     [  --enable-default-toolkit=TK
4231                           Select default toolkit
4232                           Platform specific defaults:
4233                             Mac OS X - cairo-cocoa
4234                             Win32 - cairo-windows
4235                             * - cairo-gtk2
4236                             * - cairo-gtk3
4237                             * - cairo-qt],
4238     [ _DEFAULT_TOOLKIT=$enableval ],
4239     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4241     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4242         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4243         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4244         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk3" \
4245         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4246         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
4247         -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
4248         -o "$_DEFAULT_TOOLKIT" = "cairo-android" \
4249         -o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
4250     then
4251         dnl nglayout only supports building with one toolkit,
4252         dnl so ignore everything after the first comma (",").
4253         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4254     else
4255         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4256     fi
4258 MOZ_ARG_WITHOUT_BOOL(x,
4259 [  --without-x              Build without X11],
4260     WITHOUT_X11=1)
4262 dnl ========================================================
4263 dnl = Enable the toolkit as needed                         =
4264 dnl ========================================================
4266 MOZ_WIDGET_GTK=
4268 case "$MOZ_WIDGET_TOOLKIT" in
4270 cairo-windows)
4271     MOZ_WIDGET_TOOLKIT=windows
4272     MOZ_PDF_PRINTING=1
4273     MOZ_INSTRUMENT_EVENT_LOOP=1
4274     if test -n "$GNU_CC"; then
4275         MOZ_FOLD_LIBS=
4276     fi
4277     ;;
4279 cairo-gtk3)
4280     MOZ_WIDGET_TOOLKIT=gtk3
4281     MOZ_ENABLE_GTK=1
4282     MOZ_ENABLE_GTK3=1
4283     MOZ_ENABLE_XREMOTE=1
4284     MOZ_GL_DEFAULT_PROVIDER=GLX
4286     AC_DEFINE(MOZ_X11)
4287     MOZ_X11=1
4288     USE_FC_FREETYPE=1
4290     TK_CFLAGS='$(MOZ_GTK3_CFLAGS)'
4291     MOZ_WIDGET_GTK=3
4292     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4293     MOZ_PDF_PRINTING=1
4294     MOZ_INSTRUMENT_EVENT_LOOP=1
4295     ;;
4297 cairo-gtk2|cairo-gtk2-x11)
4298     MOZ_WIDGET_TOOLKIT=gtk2
4299     MOZ_ENABLE_GTK=1
4300     MOZ_ENABLE_GTK2=1
4301     MOZ_ENABLE_XREMOTE=1
4302     MOZ_GL_DEFAULT_PROVIDER=GLX
4304     AC_DEFINE(MOZ_X11)
4305     MOZ_X11=1
4306     USE_FC_FREETYPE=1
4308     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4309     TK_LIBS='$(MOZ_GTK2_LIBS)'
4310     AC_DEFINE(MOZ_WIDGET_GTK2)
4311     MOZ_WIDGET_GTK=2
4312     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4313     MOZ_PDF_PRINTING=1
4314     MOZ_INSTRUMENT_EVENT_LOOP=1
4315     ;;
4317 cairo-qt)
4318     MOZ_WIDGET_TOOLKIT=qt
4319     MOZ_ENABLE_QT=1
4320     if test -z "$WITHOUT_X11"; then
4321       MOZ_ENABLE_XREMOTE=1
4322       MOZ_GL_DEFAULT_PROVIDER=GLX
4323       MOZ_X11=1
4324       AC_DEFINE(MOZ_X11)
4325       XT_LIBS=
4326     fi
4328     USE_FC_FREETYPE=1
4329     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4330     TK_LIBS='$(MOZ_QT_LIBS)'
4331     AC_DEFINE(MOZ_WIDGET_QT)
4332     MOZ_PDF_PRINTING=1
4333     AC_DEFINE(QT_NO_KEYWORDS)
4334     ;;
4336 cairo-cocoa)
4337     MOZ_WIDGET_TOOLKIT=cocoa
4338     AC_DEFINE(MOZ_WIDGET_COCOA)
4339     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
4340     # Use -Wl as a trick to avoid -framework and framework names from
4341     # being separated by AC_SUBST_LIST.
4342     TK_LIBS='-Wl,-framework,CoreLocation -Wl,-framework,QuartzCore -Wl,-framework,Carbon -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,AddressBook -Wl,-framework,OpenGL'
4343     TK_CFLAGS="-DNO_X11"
4344     CFLAGS="$CFLAGS $TK_CFLAGS"
4345     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4346     MOZ_USER_DIR="Mozilla"
4347     MOZ_FS_LAYOUT=bundle
4348     # skip event loop instrumentation on UIKit for now
4349     if test "$MOZ_WIDGET_TOOLKIT" == "cocoa"; then
4350       MOZ_INSTRUMENT_EVENT_LOOP=1
4351     fi
4352     ;;
4354 cairo-uikit)
4355     MOZ_WIDGET_TOOLKIT=uikit
4356     AC_DEFINE(MOZ_WIDGET_UIKIT)
4357     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
4358     TK_CFLAGS="-DNO_X11"
4359     TK_LIBS='-Wl,-framework,Foundation -Wl,-framework,CoreFoundation -Wl,-framework,CoreGraphics -Wl,-framework,CoreText -Wl,-framework,AVFoundation -Wl,-framework,AudioToolbox -Wl,-framework,CoreMedia -Wl,-framework,CoreVideo -Wl,-framework,OpenGLES -Wl,-framework,QuartzCore'
4360     CFLAGS="$CFLAGS $TK_CFLAGS"
4361     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4362     MOZ_USER_DIR="Mozilla"
4363     MOZ_FS_LAYOUT=bundle
4364     ;;
4366 cairo-android)
4367     AC_DEFINE(MOZ_WIDGET_ANDROID)
4368     MOZ_WIDGET_TOOLKIT=android
4369     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4370     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4371     MOZ_PDF_PRINTING=1
4372     MOZ_INSTRUMENT_EVENT_LOOP=1
4373     ;;
4375 cairo-gonk)
4376     AC_DEFINE(MOZ_WIDGET_GONK)
4377     AC_DEFINE(MOZ_TOUCH)
4378     MOZ_WIDGET_TOOLKIT=gonk
4379     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4380     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4381     MOZ_PDF_PRINTING=1
4382     MOZ_TOUCH=1
4383     MOZ_INSTRUMENT_EVENT_LOOP=1
4384     ;;
4386 esac
4388 AC_SUBST(MOZ_PDF_PRINTING)
4389 if test "$MOZ_PDF_PRINTING"; then
4390    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
4391    AC_DEFINE(MOZ_PDF_PRINTING)
4394 if test "$MOZ_ENABLE_XREMOTE"; then
4395     AC_DEFINE(MOZ_ENABLE_XREMOTE)
4398 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
4399    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
4402 if test "$COMPILE_ENVIRONMENT"; then
4403   if test "$MOZ_ENABLE_GTK3"; then
4404     PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4405     MOZ_GTK3_CFLAGS="-I${_topsrcdir}/widget/gtk/compat-gtk3 $MOZ_GTK3_CFLAGS"
4406     dnl Contrary to MOZ_GTK2_LIBS, MOZ_GTK3_LIBS needs to be literally added to TK_LIBS instead
4407     dnl of a make reference because of how TK_LIBS is mangled in toolkit/library/moz.build
4408     dnl for GTK+3 builds.
4409     TK_LIBS=$MOZ_GTK3_LIBS
4410     GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32
4411   fi
4412   if test "$MOZ_ENABLE_GTK2"; then
4413     GLIB_VERSION_MAX_ALLOWED=$GLIB_VERSION_MIN_REQUIRED
4414   fi
4415   if test "$MOZ_ENABLE_GTK"; then
4416     if test "$MOZ_X11"; then
4417       GDK_PACKAGES=gdk-x11-2.0
4418     fi
4419     AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
4420     AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)
4422     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 >= $GLIB_VERSION gobject-2.0 $GDK_PACKAGES)
4423     MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
4424   fi
4426 fi # COMPILE_ENVIRONMENT
4428 AC_SUBST(MOZ_FS_LAYOUT)
4430 dnl ========================================================
4431 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4432 dnl their usage and use them in spidermonkey.
4433 dnl ========================================================
4434 MOZ_ARG_WITH_BOOL(arm-kuser,
4435 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4436     USE_ARM_KUSER=1,)
4437 if test -n "$USE_ARM_KUSER"; then
4438    AC_DEFINE(USE_ARM_KUSER)
4441 dnl ========================================================
4442 dnl = startup-notification support module
4443 dnl ========================================================
4445 if test "$MOZ_ENABLE_GTK"
4446 then
4447     MOZ_ENABLE_STARTUP_NOTIFICATION=
4449     MOZ_ARG_ENABLE_BOOL(startup-notification,
4450     [  --enable-startup-notification
4451                           Enable startup-notification support (default: disabled) ],
4452         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
4453         MOZ_ENABLE_STARTUP_NOTIFICATION=)
4454     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
4455     then
4456         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
4457                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
4458         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
4459             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
4460             then
4461                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
4462             fi
4463             MOZ_ENABLE_STARTUP_NOTIFICATION=
4464         ])
4465     fi
4467     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
4468         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
4469     fi
4471     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
4473 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
4475 dnl ========================================================
4476 dnl Disable printing
4477 dnl ========================================================
4478 MOZ_ARG_DISABLE_BOOL(printing,
4479 [  --disable-printing      Disable printing support],
4480     NS_PRINTING=,
4481     NS_PRINTING=1)
4483 if test -n "$MOZ_IOS" -a -n "$NS_PRINTING"; then
4484    AC_MSG_ERROR([Printing is not supported on iOS.])
4487 if test "$NS_PRINTING"; then
4488     AC_DEFINE(NS_PRINTING)
4489     AC_DEFINE(NS_PRINT_PREVIEW)
4492 dnl ========================================================
4493 dnl = QT support
4494 dnl ========================================================
4495 if test "$MOZ_ENABLE_QT"
4496 then
4497     MOZ_ARG_WITH_STRING(qtdir,
4498     [  --with-qtdir=\$dir       Specify Qt directory ],
4499     [ QTDIR=$withval])
4501     if test -z "$QTDIR"; then
4502         AC_CHECK_PROGS(HOST_QMAKE, $HOST_QMAKE qmake, "")
4503     else
4504         HOST_QMAKE="$QTDIR/bin/qmake"
4505     fi
4506     QT_VERSION=`$HOST_QMAKE -v | grep 'Using Qt version' | egrep -o '[[0-9]]+\.[[0-9]]+\.[[0-9]]+'`
4508     if test -z "$QTDIR"; then
4509         case $QT_VERSION in
4510         5.*)
4511             AC_MSG_RESULT("Using qt5: $QT_VERSION")
4512             PKG_CHECK_MODULES(MOZ_QT, Qt5Gui Qt5Network Qt5Core Qt5Quick, ,
4513             [
4514               AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qtbase development packages, (On Ubuntu, you might try installing the packages qtbase5-dev libqt5opengl5-dev.)])
4515             ])
4516             QT5INCDIR=`pkg-config --variable=includedir Qt5Gui`
4517             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QT5INCDIR/QtGui/$QT_VERSION/QtGui"
4518             if test "$NS_PRINTING"; then
4519                 PKG_CHECK_MODULES(MOZ_QT_WIDGETS, Qt5PrintSupport, ,
4520                 [
4521                   AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qt5 printsupport development package])
4522                 ])
4523                 MOZ_QT_LIBS="$MOZ_QT_LIBS $MOZ_QT_WIDGETS_LIBS"
4524                 MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $MOZ_QT_WIDGETS_CFLAGS"
4525             fi
4526             ;;
4527         *)
4528             AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION])
4529             ;;
4530         esac
4532         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
4533         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
4534     else
4535         MOZ_QT_CFLAGS="-DQT_SHARED"
4536         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
4537         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
4538         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
4539         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
4540         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
4541         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative"
4542         case $QT_VERSION in
4543         5.*)
4544             AC_MSG_RESULT("Using qt5: $QT_VERSION")
4545             MOZ_QT_LIBS="$MOZ_QT_LIBS -L$QTDIR/lib/ -lQt5Gui -lQt5Network -lQt5Core -lQt5Xml"
4546             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui/$QT_VERSION/QtGui"
4547             if test "$NS_PRINTING"; then
4548                 MOZ_QT_LIBS="$MOZ_QT_LIBS -lQt5Widgets -lQt5PrintSupport"
4549                 MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport"
4550             fi
4551             ;;
4552         *)
4553             AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION])
4554             ;;
4555         esac
4557         HOST_MOC="$QTDIR/bin/moc"
4558         HOST_RCC="$QTDIR/bin/rcc"
4559     fi
4560     if test -z "$HOST_MOC"; then
4561         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is incorrect])
4562     fi
4563     if test -z "$HOST_RCC"; then
4564         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is incorrect])
4565     fi
4567     MOC=$HOST_MOC
4568     RCC=$HOST_RCC
4570     MOZ_ENABLE_QMSYSTEM2=
4571     PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
4572                       MOZ_ENABLE_QMSYSTEM2=1,
4573                       MOZ_ENABLE_QMSYSTEM2=)
4575     if test "$MOZ_ENABLE_QMSYSTEM2"; then
4576       MOZ_ENABLE_QMSYSTEM2=1
4577       MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
4578       MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
4579       AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
4580     fi
4582     MOZ_ENABLE_QTNETWORK=
4583     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
4584                       MOZ_ENABLE_QTNETWORK=1,
4585                       MOZ_ENABLE_QTNETWORK=)
4587     if test "$MOZ_ENABLE_QTNETWORK"; then
4588       MOZ_ENABLE_QTNETWORK=1
4589       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
4590     fi
4592     MOZ_ENABLE_QTMOBILITY=
4593     PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
4594                       MOZ_ENABLE_QTMOBILITY=1,
4595                       MOZ_ENABLE_QTMOBILITY=)
4596     if test "$MOZ_ENABLE_QTMOBILITY"; then
4597        MOZ_ENABLE_QTMOBILITY=1
4598        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
4599        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
4600        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
4601        AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4602     else
4603        AC_CHECK_LIB(QtSensors, main, [
4604           MOZ_ENABLE_QTMOBILITY=1
4605           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMobility"
4606           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtSensors"
4607           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtFeedback"
4608           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtLocation"
4609           MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
4610        ])
4611     fi
4613     MOZ_ENABLE_QT5FEEDBACK=
4614     PKG_CHECK_MODULES(_QT5FEEDBACK, Qt0Feedback,
4615                       MOZ_ENABLE_QT5FEEDBACK=1,
4616                       MOZ_ENABLE_QT5FEEDBACK=)
4617     if test "$MOZ_ENABLE_QT5FEEDBACK"; then
4618        MOZ_ENABLE_QT5FEEDBACK=1
4619        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QT5FEEDBACK_CFLAGS"
4620        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QT5FEEDBACK_LIBS"
4621        AC_DEFINE(MOZ_ENABLE_QT5FEEDBACK)
4622        AC_SUBST(MOZ_ENABLE_QT5FEEDBACK)
4623     fi
4625     MOZ_ENABLE_QT5GEOPOSITION=
4626     PKG_CHECK_MODULES(_QT5GEOPOSITION, Qt5Positioning,
4627                       MOZ_ENABLE_QT5GEOPOSITION=1,
4628                       MOZ_ENABLE_QT5GEOPOSITION=)
4629     if test "$MOZ_ENABLE_QT5GEOPOSITION"; then
4630        MOZ_ENABLE_QT5GEOPOSITION=1
4631        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QT5GEOPOSITION_CFLAGS"
4632        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QT5GEOPOSITION_LIBS"
4633        AC_DEFINE(MOZ_ENABLE_QT5GEOPOSITION)
4634        AC_SUBST(MOZ_ENABLE_QT5GEOPOSITION)
4635     fi
4637     if test "$MOZ_ENABLE_CONTENTACTION"; then
4638       MOZ_ENABLE_CONTENTACTION=1
4639       AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
4640     fi
4642     MOZ_ENABLE_CONTENTACTION=
4643     PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
4644     if test "$MOZ_ENABLE_CONTENTACTION"; then
4645        MOZ_ENABLE_CONTENTACTION=1
4646        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_CONTENTACTION_CFLAGS"
4647        MOZ_QT_LIBS="$MOZ_QT_LIBS $_CONTENTACTION_LIBS"
4648        AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
4649        AC_SUBST(MOZ_ENABLE_CONTENTACTION)
4650     fi
4653 AC_SUBST(GTK_CONFIG)
4654 AC_SUBST_LIST(TK_CFLAGS)
4655 AC_SUBST_LIST(TK_LIBS)
4657 AC_SUBST(MOZ_ENABLE_GTK2)
4658 AC_SUBST(MOZ_ENABLE_GTK3)
4659 AC_SUBST(MOZ_ENABLE_GTK)
4660 AC_SUBST(MOZ_ENABLE_QT)
4661 AC_SUBST(MOZ_ENABLE_QTNETWORK)
4662 AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
4663 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4664 AC_SUBST(MOZ_ENABLE_XREMOTE)
4665 AC_SUBST(MOZ_WIDGET_GTK)
4666 AC_SUBST_LIST(MOZ_QT_CFLAGS)
4667 AC_SUBST_LIST(MOZ_QT_LIBS)
4669 AC_SUBST(MOC)
4670 AC_SUBST(RCC)
4672 AC_SUBST(MOZ_X11)
4674 dnl ========================================================
4675 dnl =
4676 dnl = Components & Features
4677 dnl =
4678 dnl ========================================================
4679 MOZ_ARG_HEADER(Components and Features)
4681 dnl ========================================================
4682 dnl = Localization
4683 dnl ========================================================
4684 MOZ_ARG_ENABLE_STRING(ui-locale,
4685 [  --enable-ui-locale=ab-CD
4686                           Select the user interface locale (default: en-US)],
4687     MOZ_UI_LOCALE=$enableval )
4688 AC_SUBST(MOZ_UI_LOCALE)
4690 AC_SUBST(MOZ_OFFICIAL_BRANDING)
4691 if test -n "$MOZ_OFFICIAL_BRANDING"; then
4692   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
4693     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
4694   else
4695     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
4696     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
4697   fi
4700 MOZ_ARG_WITH_STRING(branding,
4701 [  --with-branding=dir     Use branding from the specified directory.],
4702     MOZ_BRANDING_DIRECTORY=$withval)
4704 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
4705 if test -z "$REAL_BRANDING_DIRECTORY"; then
4706   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
4709 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
4710   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
4711 elif test -f "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
4712   . "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"
4715 AC_SUBST(MOZ_BRANDING_DIRECTORY)
4717 dnl ========================================================
4718 dnl = Distribution ID
4719 dnl ========================================================
4720 MOZ_ARG_WITH_STRING(distribution-id,
4721 [  --with-distribution-id=ID
4722                           Set distribution-specific id (default=org.mozilla)],
4723 [ val=`echo $withval`
4724     MOZ_DISTRIBUTION_ID="$val"])
4726 if test -z "$MOZ_DISTRIBUTION_ID"; then
4727    MOZ_DISTRIBUTION_ID="org.mozilla"
4730 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
4731 AC_SUBST(MOZ_DISTRIBUTION_ID)
4734 dnl ========================================================
4735 dnl Google Play Services, placed here so it can depend on
4736 dnl values set by configure.sh above.
4737 dnl ========================================================
4739 MOZ_ANDROID_GOOGLE_PLAY_SERVICES
4742 dnl ========================================================
4743 dnl = Pango
4744 dnl ========================================================
4745 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4746 then
4747     PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
4749     PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
4752 dnl ========================================================
4753 dnl = GIO and GConf support module
4754 dnl ========================================================
4756 if test "$MOZ_X11"
4757 then
4758     dnl build the GIO extension by default only when the
4759     dnl GTK2 toolkit is in use.
4760     if test "$MOZ_ENABLE_GTK"
4761     then
4762         MOZ_ENABLE_GIO=1
4763         MOZ_ENABLE_GCONF=1
4764     fi
4766     dnl ========================================================
4767     dnl = GIO support module
4768     dnl ========================================================
4769     MOZ_ARG_DISABLE_BOOL(gio,
4770     [  --disable-gio           Disable GIO support],
4771         MOZ_ENABLE_GIO=,
4772         MOZ_ENABLE_GIO=force)
4774     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK"
4775     then
4776         if test "$MOZ_ENABLE_GTK2"
4777         then
4778             PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
4779                               [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
4780         fi
4781         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
4782             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
4783             MOZ_ENABLE_GIO=1
4784             AC_DEFINE(MOZ_ENABLE_GIO)
4785         ],[
4786             if test "$MOZ_ENABLE_GIO" = "force"
4787             then
4788                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
4789             fi
4790             MOZ_ENABLE_GIO=
4791         ])
4792     fi
4794     AC_SUBST(MOZ_ENABLE_GIO)
4796     dnl ========================================================
4797     dnl = GConf support module
4798     dnl ========================================================
4799     MOZ_ARG_DISABLE_BOOL(gconf,
4800     [  --disable-gconf      Disable Gconf support ],
4801         MOZ_ENABLE_GCONF=,
4802         MOZ_ENABLE_GCONF=1)
4804     if test "$MOZ_ENABLE_GCONF"
4805     then
4806         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
4807             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
4808             MOZ_ENABLE_GCONF=1
4809         ],[
4810             if test -n "$MOZ_ENABLE_GCONF";
4811             then
4812                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
4813             else
4814                 AC_MSG_WARN([Many automated tests will fail with --disable-gconf. See bug 1167201.])
4815             fi
4816         ])
4817     fi
4819     if test "$MOZ_ENABLE_GCONF"; then
4820         AC_DEFINE(MOZ_ENABLE_GCONF)
4821     fi
4823     AC_SUBST(MOZ_ENABLE_GCONF)
4826 dnl ========================================================
4827 dnl = libproxy support
4828 dnl ========================================================
4830 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4831 then
4832     MOZ_ENABLE_LIBPROXY=
4834     MOZ_ARG_ENABLE_BOOL(libproxy,
4835     [  --enable-libproxy         Enable libproxy support ],
4836     MOZ_ENABLE_LIBPROXY=1,
4837     MOZ_ENABLE_LIBPROXY=)
4839     if test "$MOZ_ENABLE_LIBPROXY"
4840     then
4841         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
4842         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
4843     fi
4845 AC_SUBST(MOZ_ENABLE_LIBPROXY)
4847 dnl ========================================================
4848 dnl = GNOME component (mozgnome)
4849 dnl ========================================================
4851 if test "$MOZ_ENABLE_GTK"
4852 then
4853     MOZ_ENABLE_GNOME_COMPONENT=1
4855 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
4857 dnl ========================================================
4858 dnl = libgnomeui support module
4859 dnl ========================================================
4861 if test "$MOZ_ENABLE_GTK"
4862 then
4863     MOZ_ARG_ENABLE_BOOL(gnomeui,
4864     [  --enable-gnomeui        Enable libgnomeui instead of GIO & GTK for icon theme support ],
4865         MOZ_ENABLE_GNOMEUI=force,
4866         MOZ_ENABLE_GNOMEUI=)
4868     if test "$MOZ_ENABLE_GNOMEUI"
4869     then
4870         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
4871         [
4872             MOZ_ENABLE_GNOMEUI=1
4873         ],[
4874             if test "$MOZ_ENABLE_GNOMEUI" = "force"
4875             then
4876                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
4877             fi
4878             MOZ_ENABLE_GNOMEUI=
4879         ])
4880     fi
4882     if test "$MOZ_ENABLE_GNOMEUI"; then
4883         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
4884     fi
4887 AC_SUBST(MOZ_ENABLE_GNOMEUI)
4889 dnl ========================================================
4890 dnl = dbus support
4891 dnl ========================================================
4893 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4894 then
4895     MOZ_ENABLE_DBUS=1
4897     MOZ_ARG_DISABLE_BOOL(dbus,
4898     [  --disable-dbus          Disable dbus support ],
4899         MOZ_ENABLE_DBUS=,
4900         MOZ_ENABLE_DBUS=1)
4902     if test "$MOZ_ENABLE_DBUS"
4903     then
4904         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
4905         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
4906         AC_DEFINE(MOZ_ENABLE_DBUS)
4907     fi
4909 AC_SUBST(MOZ_ENABLE_DBUS)
4911 dnl ========================================================
4912 dnl = Enable Android History instead of Places
4913 dnl ========================================================
4914 if test -n "$MOZ_ANDROID_HISTORY"; then
4915     if test -z "$MOZ_PLACES"; then
4916         AC_DEFINE(MOZ_ANDROID_HISTORY)
4917     else
4918         AC_MSG_ERROR([Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.])
4919     fi
4922 dnl ========================================================
4923 dnl = Enable the C++ async pan/zoom code instead of the Java version
4924 dnl ========================================================
4925 MOZ_ARG_ENABLE_BOOL(android-apz,
4926 [  --enable-android-apz      Switch to C++ pan/zoom code],
4927     MOZ_ANDROID_APZ=1,
4928     MOZ_ANDROID_APZ=)
4929 if test -n "$MOZ_ANDROID_APZ"; then
4930      dnl Do this if defined in confvars.sh
4931      AC_DEFINE(MOZ_ANDROID_APZ)
4934 dnl ========================================================
4935 dnl = Disable WebSMS backend
4936 dnl ========================================================
4937 MOZ_ARG_DISABLE_BOOL(websms-backend,
4938 [  --disable-websms-backend
4939                            Disable WebSMS backend],
4940     MOZ_WEBSMS_BACKEND=,
4941     MOZ_WEBSMS_BACKEND=1)
4943 if test -n "$MOZ_WEBSMS_BACKEND"; then
4944     AC_DEFINE(MOZ_WEBSMS_BACKEND)
4947 dnl ========================================================
4948 dnl = Enable runtime locale switching on Android
4949 dnl ========================================================
4950 if test -n "$MOZ_LOCALE_SWITCHER"; then
4951     AC_DEFINE(MOZ_LOCALE_SWITCHER)
4954 dnl ========================================================
4955 dnl = Enable system download manager on Android
4956 dnl ========================================================
4957 if test -n "$MOZ_ANDROID_DOWNLOADS_INTEGRATION"; then
4958     AC_DEFINE(MOZ_ANDROID_DOWNLOADS_INTEGRATION)
4961 dnl ========================================================
4962 dnl = Enable NFC permission on Android
4963 dnl ========================================================
4964 if test -n "$MOZ_ANDROID_BEAM"; then
4965     AC_DEFINE(MOZ_ANDROID_BEAM)
4968 dnl ========================================================
4969 dnl = Include Search Activity on Android
4970 dnl ========================================================
4971 if test -n "$MOZ_ANDROID_SEARCH_ACTIVITY"; then
4972     AC_DEFINE(MOZ_ANDROID_SEARCH_ACTIVITY)
4975 dnl ========================================================
4976 dnl = Include Reading List service on Android
4977 dnl ========================================================
4978 if test -n "$MOZ_ANDROID_READING_LIST_SERVICE"; then
4979     AC_DEFINE(MOZ_ANDROID_READING_LIST_SERVICE)
4982 dnl ========================================================
4983 dnl = Include Mozilla Location Service Stumbler on Android
4984 dnl ========================================================
4985 if test -n "$MOZ_ANDROID_MLS_STUMBLER"; then
4986     AC_DEFINE(MOZ_ANDROID_MLS_STUMBLER)
4989 dnl ========================================================
4990 dnl = Include share overlay on Android
4991 dnl ========================================================
4992 if test -n "$MOZ_ANDROID_SHARE_OVERLAY"; then
4993     AC_DEFINE(MOZ_ANDROID_SHARE_OVERLAY)
4996 dnl ========================================================
4997 dnl = Show Firefox Account profile details on Android
4998 dnl ========================================================
4999 if test -n "$MOZ_ANDROID_FIREFOX_ACCOUNT_PROFILES"; then
5000     AC_DEFINE(MOZ_ANDROID_FIREFOX_ACCOUNT_PROFILES)
5003 dnl = Include Tab Queue on Android
5004 dnl = Temporary build flag to allow development in Nightly
5005 dnl ========================================================
5006 if test -n "$MOZ_ANDROID_TAB_QUEUE"; then
5007     AC_DEFINE(MOZ_ANDROID_TAB_QUEUE)
5010 dnl ========================================================
5011 dnl = Include install tracking on Android
5012 dnl ========================================================
5013 if test -n "$MOZ_INSTALL_TRACKING"; then
5014     AC_DEFINE(MOZ_INSTALL_TRACKING)
5017 dnl ========================================================
5018 dnl = Enable IPDL's "expensive" unit tests
5019 dnl ========================================================
5020 MOZ_IPDL_TESTS=
5022 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
5023 [  --enable-ipdl-tests     Enable expensive IPDL tests],
5024     MOZ_IPDL_TESTS=1,
5025     MOZ_IPDL_TESTS=)
5027 if test -n "$MOZ_IPDL_TESTS"; then
5028     AC_DEFINE(MOZ_IPDL_TESTS)
5031 AC_SUBST(MOZ_IPDL_TESTS)
5033 dnl ========================================================
5034 dnl = Disable building dbm
5035 dnl ========================================================
5036 MOZ_ARG_DISABLE_BOOL(dbm,
5037 [  --disable-dbm           Disable building dbm],
5038     NSS_DISABLE_DBM=1,
5039     NSS_DISABLE_DBM=)
5041 dnl ========================================================
5042 dnl accessibility support on by default on all platforms
5043 dnl ========================================================
5044 MOZ_ARG_DISABLE_BOOL(accessibility,
5045 [  --disable-accessibility Disable accessibility support],
5046     ACCESSIBILITY=,
5047     ACCESSIBILITY=1 )
5048 if test "$ACCESSIBILITY"; then
5049     case "$target" in
5050     *-mingw*)
5051         if test -z "$MIDL"; then
5052             if test "$GCC" != "yes"; then
5053                 AC_MSG_ERROR([MIDL could not be found. Building accessibility without MIDL is not supported.])
5054             else
5055                 AC_MSG_ERROR([You have accessibility enabled, but widl could not be found. Add --disable-accessibility to your mozconfig or install widl. See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details.])
5056             fi
5057         fi
5058     esac
5059     AC_DEFINE(ACCESSIBILITY)
5062 dnl ========================================================
5063 dnl Accessibility is required for the linuxgl widget
5064 dnl backend
5065 dnl ========================================================
5066 if test "${MOZ_WIDGET_TOOLKIT}" = "linuxgl" -a "$ACCESSIBILITY" != "1"; then
5067     AC_MSG_ERROR(["Accessibility is required for the linuxgl widget backend"])
5070 dnl Turn off webrtc for OS's we don't handle yet, but allow
5071 dnl --enable-webrtc to override.  Can disable for everything in
5072 dnl the master list above.
5073 if test -n "$MOZ_WEBRTC"; then
5074     case "$target" in
5075     *-linux*|*-mingw*|*-darwin*|*-android*|*-linuxandroid*|*-dragonfly*|*-freebsd*|*-netbsd*|*-openbsd*)
5076         dnl Leave enabled
5077         ;;
5078     *)
5079         dnl default to disabled for all others
5080         MOZ_WEBRTC=
5081         ;;
5082     esac
5085 AC_TRY_COMPILE([#include <linux/ethtool.h>],
5086                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
5087                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
5089 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
5091 # target_arch is from {ia32|x64|arm|ppc}
5092 case "$CPU_ARCH" in
5093 x86_64 | arm | x86 | ppc* | ia64)
5094     :
5095     ;;
5097 # unsupported arch for webrtc
5098     MOZ_WEBRTC=
5099     ;;
5101 esac
5103 dnl ========================================================
5104 dnl = Disable WebRTC code
5105 dnl ========================================================
5106 MOZ_ARG_DISABLE_BOOL(webrtc,
5107 [  --disable-webrtc        Disable support for WebRTC],
5108     MOZ_WEBRTC=,
5109     MOZ_WEBRTC=1)
5111 if test -n "$MOZ_WEBRTC"; then
5112     AC_DEFINE(MOZ_WEBRTC)
5113     dnl MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
5114     dnl opt/production builds (via MOZ_CRASH())
5115     AC_DEFINE(MOZ_WEBRTC_ASSERT_ALWAYS)
5116     MOZ_RAW=1
5117     MOZ_VPX=1
5118     MOZ_VPX_ERROR_CONCEALMENT=1
5120 dnl enable once Signaling lands
5121     MOZ_WEBRTC_SIGNALING=1
5122     AC_DEFINE(MOZ_WEBRTC_SIGNALING)
5123 dnl enable once PeerConnection lands
5124     MOZ_PEERCONNECTION=1
5125     AC_DEFINE(MOZ_PEERCONNECTION)
5126     MOZ_SCTP=1
5127     MOZ_SRTP=1
5128     AC_DEFINE(MOZ_SCTP)
5129     AC_DEFINE(MOZ_SRTP)
5130     if test -n "$MOZ_X11"; then
5131       MOZ_WEBRTC_X11_LIBS="-lXext -lXdamage -lXfixes -lXcomposite"
5132     fi
5133 else
5134     MOZ_SYNTH_PICO=
5137 dnl ========================================================
5138 dnl = Force hardware AEC, disable webrtc.org AEC
5139 dnl ========================================================
5140 MOZ_ARG_ENABLE_BOOL(hardware-aec-ns,
5141 [  --enable-hardware-aec-ns   Enable support for hardware AEC and noise suppression],
5142     MOZ_WEBRTC_HARDWARE_AEC_NS=1,
5143     MOZ_WEBRTC_HARDWARE_AEC_NS=)
5145 if test -n "$MOZ_WEBRTC_HARDWARE_AEC_NS"; then
5146     AC_DEFINE(MOZ_WEBRTC_HARDWARE_AEC_NS)
5149 AC_SUBST(MOZ_WEBRTC)
5150 AC_SUBST(MOZ_WEBRTC_LEAKING_TESTS)
5151 AC_SUBST(MOZ_WEBRTC_SIGNALING)
5152 AC_SUBST(MOZ_PEERCONNECTION)
5153 AC_SUBST(MOZ_WEBRTC_ASSERT_ALWAYS)
5154 AC_SUBST(MOZ_WEBRTC_HARDWARE_AEC_NS)
5155 AC_SUBST(MOZ_SCTP)
5156 AC_SUBST(MOZ_SRTP)
5157 AC_SUBST_LIST(MOZ_WEBRTC_X11_LIBS)
5159 dnl Use integers over floats for audio on B2G and Android
5160 dnl (regarless of the CPU architecture, because audio
5161 dnl backends for those platforms don't support floats. We also
5162 dnl use integers on ARM with other OS, because it's more efficient.
5163 if test "$OS_TARGET" = "Android" -o "$CPU_ARCH" = "arm"; then
5164     MOZ_SAMPLE_TYPE_S16=1
5165     AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
5166     AC_SUBST(MOZ_SAMPLE_TYPE_S16)
5167 else
5168     MOZ_SAMPLE_TYPE_FLOAT32=1
5169     AC_DEFINE(MOZ_SAMPLE_TYPE_FLOAT32)
5170     AC_SUBST(MOZ_SAMPLE_TYPE_FLOAT32)
5173 dnl ========================================================
5174 dnl = Disable Speech API pocketsphinx backend
5175 dnl ========================================================
5176 if test -n "$MOZ_WEBSPEECH_POCKETSPHINX"; then
5177     AC_DEFINE(MOZ_WEBSPEECH_POCKETSPHINX)
5180 AC_SUBST(MOZ_WEBSPEECH_POCKETSPHINX)
5182 dnl ========================================================
5183 dnl = Disable Speech API code
5184 dnl ========================================================
5185 MOZ_ARG_DISABLE_BOOL(webspeech,
5186 [  --disable-webspeech        Disable support for HTML Speech API],
5187     MOZ_WEBSPEECH=,
5188     MOZ_WEBSPEECH=1)
5190 if test -n "$MOZ_WEBSPEECH"; then
5191     AC_DEFINE(MOZ_WEBSPEECH)
5194 AC_SUBST(MOZ_WEBSPEECH)
5196 dnl ========================================================
5197 dnl = Disable Speech API test backend
5198 dnl ========================================================
5199 MOZ_ARG_DISABLE_BOOL(webspeechtestbackend,
5200 [  --disable-webspeechtestbackend        Disable support for HTML Speech API Test Backend],
5201     MOZ_WEBSPEECH_TEST_BACKEND=,
5202     MOZ_WEBSPEECH_TEST_BACKEND=1)
5204 if test -z "$MOZ_WEBSPEECH"; then
5205 MOZ_WEBSPEECH_TEST_BACKEND=
5208 if test -n "$MOZ_WEBSPEECH_TEST_BACKEND"; then
5209     AC_DEFINE(MOZ_WEBSPEECH_TEST_BACKEND)
5212 AC_SUBST(MOZ_WEBSPEECH_TEST_BACKEND)
5214 dnl ========================================================
5215 dnl = Disable Speech API models
5216 dnl ========================================================
5217 if test -z "$MOZ_WEBSPEECH"; then
5218 MOZ_WEBSPEECH_MODELS=
5221 if test -n "$MOZ_WEBSPEECH_MODELS"; then
5222     AC_DEFINE(MOZ_WEBSPEECH_MODELS)
5225 AC_SUBST(MOZ_WEBSPEECH_MODELS)
5227 dnl ========================================================
5228 dnl = Enable Raw Codecs
5229 dnl ========================================================
5230 MOZ_ARG_ENABLE_BOOL(raw,
5231 [  --enable-raw           Enable support for RAW media],
5232     MOZ_RAW=1,
5233     MOZ_RAW=)
5235 if test -n "$MOZ_RAW"; then
5236     AC_DEFINE(MOZ_RAW)
5239 AC_SUBST(MOZ_RAW)
5241 dnl Checks for __attribute__(aligned()) directive need by libogg
5242 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5243     [ac_cv_c_attribute_aligned],
5244     [ac_cv_c_attribute_aligned=0
5245      CFLAGS_save="${CFLAGS}"
5246      CFLAGS="${CFLAGS} -Werror"
5247      for ac_cv_c_attr_align_try in 64 32 16 8; do
5248        echo "trying $ac_cv_c_attr_align_try"
5249        AC_TRY_COMPILE([],
5250                       [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5251                       [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5252        if test "$ac_cv_c_attribute_aligned" != 0; then
5253          break;
5254        fi
5255      done
5256        CFLAGS="${CFLAGS_save}"])
5257 if test "${ac_cv_c_attribute_aligned}" != "0"; then
5258   AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5259                      [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5262 dnl ========================================================
5263 dnl = Disable VP8 decoder support
5264 dnl ========================================================
5265 MOZ_ARG_DISABLE_BOOL(webm,
5266 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
5267     MOZ_WEBM=,
5268     MOZ_WEBM=1)
5270 if test -n "$MOZ_WEBM"; then
5271     AC_DEFINE(MOZ_WEBM)
5272     MOZ_VPX=1
5275 dnl ========================================================
5276 dnl = Apple platform decoder support
5277 dnl ========================================================
5278 if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
5279   MOZ_APPLEMEDIA=1
5282 if test "$COMPILE_ENVIRONMENT"; then
5283 if test -n "$MOZ_APPLEMEDIA"; then
5284   AC_DEFINE(MOZ_APPLEMEDIA)
5285   # hack in frameworks for fmp4 - see bug 1029974
5286   # We load VideoToolbox and CoreMedia dynamically, so they don't appear here.
5287   LDFLAGS="$LDFLAGS -framework AudioToolbox"
5288   dnl Verify CoreMedia is available.
5289   AC_CHECK_HEADER([CoreMedia/CoreMedia.h], [],
5290     [AC_MSG_ERROR([MacOS X 10.7 SDK or later is required])])
5292 fi # COMPILE_ENVIRONMENT
5294 dnl ========================================================
5295 dnl = DirectShow support
5296 dnl ========================================================
5297 if test "$OS_ARCH" = "WINNT"; then
5298     dnl Enable DirectShow support by default.
5299     MOZ_DIRECTSHOW=1
5302 MOZ_ARG_DISABLE_BOOL(directshow,
5303 [  --disable-directshow  Disable support for DirectShow],
5304     MOZ_DIRECTSHOW=,
5305     MOZ_DIRECTSHOW=1)
5307 if test -n "$MOZ_DIRECTSHOW"; then
5308     AC_DEFINE(MOZ_DIRECTSHOW)
5311 dnl ========================================================
5312 dnl = Windows Media Foundation support
5313 dnl ========================================================
5314 if test "$OS_ARCH" = "WINNT"; then
5315     dnl Enable Windows Media Foundation support by default.
5316     dnl Note our minimum SDK version is Windows 7 SDK, so we are (currently)
5317     dnl guaranteed to have a recent-enough SDK to build WMF.
5318     MOZ_WMF=1
5321 MOZ_ARG_DISABLE_BOOL(wmf,
5322 [  --disable-wmf  Disable support for Windows Media Foundation],
5323     MOZ_WMF=,
5324     MOZ_WMF=1)
5326 if test -n "$MOZ_WMF"; then
5327     AC_DEFINE(MOZ_WMF)
5330 dnl ========================================================
5331 dnl FFmpeg H264/AAC Decoding Support
5332 dnl ========================================================
5333 case "$OS_TARGET" in
5334 WINNT|Darwin|Android)
5335     ;;
5337     MOZ_FFMPEG=1
5338     ;;
5339 esac
5341 MOZ_ARG_DISABLE_BOOL(ffmpeg,
5342 [  --disable-ffmpeg         Disable FFmpeg for fragmented H264/AAC decoding],
5343     MOZ_FFMPEG=,
5344     MOZ_FFMPEG=1
5347 if test -n "$MOZ_FFMPEG"; then
5348     AC_DEFINE(MOZ_FFMPEG)
5351 dnl ========================================================
5352 dnl = Built-in fragmented MP4 support.
5353 dnl ========================================================
5355 if test "$OS_TARGET" = Android -a -z "$gonkdir"; then
5356     MOZ_FMP4=1
5359 if test -n "$MOZ_WMF" -o -n "$MOZ_FFMPEG" -o -n "$MOZ_APPLEMEDIA"; then
5360     dnl Enable fragmented MP4 parser on Windows by default.
5361     dnl We will also need to enable it on other platforms as we implement
5362     dnl platform decoder support there too.
5363     MOZ_FMP4=1
5366 MOZ_ARG_DISABLE_BOOL(fmp4,
5367 [  --disable-fmp4  Disable support for in built Fragmented MP4 parsing],
5368     MOZ_FMP4=,
5369     MOZ_FMP4=1)
5371 if test -n "$MOZ_FFMPEG" -a -z "$MOZ_FMP4"; then
5372     AC_MSG_ERROR([Fragmented MP4 support must be enabled if using FFMPEG])
5375 if test -n "$MOZ_FMP4"; then
5376     AC_DEFINE(MOZ_FMP4)
5377     MOZ_EME=1
5380 if test x"$MOZ_WIDGET_TOOLKIT" = x"gonk" -a -n "$MOZ_FMP4" -a -n "$ANDROID_VERSION"; then
5381     # we now know for sure that $ANDROID_VERSION is not an empty string!
5382     if test "$ANDROID_VERSION" -ge "18"; then
5383         MOZ_GONK_MEDIACODEC=1
5384         AC_SUBST(MOZ_GONK_MEDIACODEC)
5385     fi
5389 dnl ========================================================
5390 dnl = EME support
5391 dnl ========================================================
5393 MOZ_ARG_ENABLE_STRING(eme,
5394 [  --enable-eme[=adobe]  Enable support for Encrypted Media Extensions  ],
5395     MOZ_EME_ARGS=$enableval)
5397 if test "$MOZ_EME_ARGS"; then
5398     if test "$MOZ_EME_ARGS" = "no"; then
5399         dnl EME explicitly disabled with --disable-eme
5400         MOZ_EME=
5401     elif test "$MOZ_EME_ARGS" = "yes"; then
5402         dnl EME explicitly enabled with --enable-eme
5403         MOZ_EME=1
5404     else
5405         dnl EME explicitly enabled with --enable-eme=<args>
5406         MOZ_EME=1
5407         MOZ_EME_MODULES=`echo $MOZ_EME_ARGS | sed -e 's/,/ /g'`
5408     fi
5411 AC_SUBST_SET(MOZ_EME_MODULES)
5412 if test -n "$MOZ_EME"; then
5413     if test -z "$MOZ_FMP4"; then
5414         AC_MSG_ERROR([Encrypted Media Extension support requires Fragmented MP4 support])
5415     fi
5416     AC_DEFINE(MOZ_EME)
5419 dnl ========================================================
5420 dnl = Enable media plugin support
5421 dnl ========================================================
5422 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5423   dnl Enable support on android by default
5424   MOZ_ANDROID_OMX=1
5427 MOZ_ARG_ENABLE_BOOL(android-omx,
5428 [  --enable-android-omx  Enable support for Android OMX media backend],
5429     MOZ_ANDROID_OMX=1,
5430     MOZ_ANDROID_OMX=)
5432 if test -n "$MOZ_ANDROID_OMX"; then
5433   AC_DEFINE(MOZ_ANDROID_OMX)
5436 dnl ========================================================
5437 dnl = Enable getUserMedia support
5438 dnl ========================================================
5439 MOZ_ARG_ENABLE_BOOL(media-navigator,
5440 [  --enable-media-navigator  Enable support for getUserMedia],
5441     MOZ_MEDIA_NAVIGATOR=1,
5442     MOZ_MEDIA_NAVIGATOR=)
5444 if test -n "$MOZ_MEDIA_NAVIGATOR"; then
5445   AC_DEFINE(MOZ_MEDIA_NAVIGATOR)
5448 dnl ========================================================
5449 dnl = Enable building OMX media plugin (B2G or Android)
5450 dnl ========================================================
5451 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5452   dnl Enable support on android by default
5453   MOZ_OMX_PLUGIN=1
5456 MOZ_ARG_ENABLE_BOOL(omx-plugin,
5457 [  --enable-omx-plugin      Enable building OMX plugin (B2G)],
5458     MOZ_OMX_PLUGIN=1,
5459     MOZ_OMX_PLUGIN=)
5461 if test -n "$MOZ_OMX_PLUGIN"; then
5462     if test "$OS_TARGET" = "Android"; then
5463         dnl Only allow building OMX plugin on Gonk (B2G) or Android
5464         AC_DEFINE(MOZ_OMX_PLUGIN)
5465     else
5466        dnl fail if we're not building on Gonk or Android
5467        AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
5468     fi
5471 dnl system libvpx Support
5472 dnl ========================================================
5473 MOZ_ARG_WITH_BOOL(system-libvpx,
5474 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
5475     MOZ_NATIVE_LIBVPX=1)
5477 MOZ_LIBVPX_CFLAGS=
5478 MOZ_LIBVPX_LIBS=
5480 if test -n "$MOZ_VPX"; then
5481     AC_DEFINE(MOZ_VPX)
5482     if test -n "$MOZ_VPX_ERROR_CONCEALMENT" ; then
5483         AC_DEFINE(MOZ_VPX_ERROR_CONCEALMENT)
5484     fi
5486     _SAVE_CFLAGS=$CFLAGS
5487     _SAVE_LIBS=$LIBS
5488     if test -n "$MOZ_NATIVE_LIBVPX"; then
5489         dnl ============================
5490         dnl === libvpx Version check ===
5491         dnl ============================
5492         dnl Check to see if we have a system libvpx package.
5493         PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.3.0)
5495         CFLAGS="$CFLAGS $MOZ_LIBVPX_CFLAGS"
5496         LIBS="$LIBS $MOZ_LIBVPX_LIBS"
5498         MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [],
5499          [AC_MSG_ERROR([Couldn't find vpx/vpx_decoder.h which is required for build with system libvpx. Use --without-system-libvpx to build with in-tree libvpx.])])
5501         AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [],
5502          [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
5504         MOZ_CHECK_HEADER([vpx_mem/vpx_mem.h],
5505          [AC_CHECK_FUNC(vpx_mem_set_functions)])
5506         if test "$ac_cv_header_vpx_mem_vpx_mem_h" = no -o \
5507                 "$ac_cv_func_vpx_mem_set_functions" = no; then
5508             AC_DEFINE(MOZ_VPX_NO_MEM_REPORTING)
5509         fi
5510     fi
5511     CFLAGS=$_SAVE_CFLAGS
5512     LIBS=$_SAVE_LIBS
5515 AC_SUBST(MOZ_NATIVE_LIBVPX)
5516 AC_SUBST_LIST(MOZ_LIBVPX_CFLAGS)
5517 AC_SUBST_LIST(MOZ_LIBVPX_LIBS)
5519 if test "$MOZ_WEBM"; then
5520     if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then
5521         MOZ_VORBIS=1
5522     else
5523         MOZ_TREMOR=1
5524     fi
5527 if test -n "$MOZ_VPX" -a -z "$MOZ_NATIVE_LIBVPX"; then
5529     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
5530     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
5531     dnl We currently require gcc on all arm platforms.
5532     VPX_AS=$YASM
5533     VPX_ASM_SUFFIX=asm
5534     VPX_NEED_OBJ_INT_EXTRACT=
5536     dnl See if we have assembly on this platform.
5537     case "$OS_ARCH:$CPU_ARCH" in
5538     Darwin:x86)
5539       VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
5540       VPX_X86_ASM=1
5541     ;;
5542     Darwin:x86_64)
5543       VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
5544       VPX_X86_ASM=1
5545     ;;
5546     WINNT:x86_64)
5547       VPX_ASFLAGS="-f x64 -rnasm -pnasm"
5548       VPX_X86_ASM=1
5549     ;;
5550     WINNT:x86)
5551       dnl Check for yasm 1.1 or greater.
5552       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
5553         AC_MSG_ERROR([yasm 1.1 or greater is required to build libvpx on Win32, but it appears not to be installed.  Install it (included in MozillaBuild 1.5.1 and newer) or configure with --disable-webm (which disables the WebM video format). See https://developer.mozilla.org/en/YASM for more details.])
5554       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5555         AC_MSG_ERROR([yasm 1.1 or greater is required to build libvpx on Win32, but you appear to have version $_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.  Upgrade to the newest version (included in MozillaBuild 1.5.1 and newer) or configure with --disable-webm (which disables the WebM video format). See https://developer.mozilla.org/en/YASM for more details.])
5556       else
5557         VPX_ASFLAGS="-f win32 -rnasm -pnasm -DPIC"
5558         VPX_X86_ASM=1
5559         dnl The encoder needs obj_int_extract to get asm offsets.
5560       fi # COMPILE_ENVIRONMENT and others
5561     ;;
5562     *:arm*)
5563       if test -n "$GNU_AS" ; then
5564         VPX_AS=$AS
5565         dnl These flags are a lie; they're just used to enable the requisite
5566         dnl opcodes; actual arch detection is done at runtime.
5567         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
5568         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
5569         VPX_ASM_SUFFIX="$ASM_SUFFIX"
5570         VPX_ARM_ASM=1
5571       fi
5572     ;;
5573     *:x86)
5574       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5575         VPX_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC"
5576         VPX_X86_ASM=1
5577       fi
5578     ;;
5579     *:x86_64)
5580       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5581         VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5582         VPX_X86_ASM=1
5583       fi
5584     ;;
5585     esac
5587     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_X86_ASM" -a -z "$VPX_AS"; then
5588       AC_MSG_ERROR([yasm is a required build tool for this architecture when webm is enabled. You may either install yasm or --disable-webm (which disables the WebM video format). See https://developer.mozilla.org/en/YASM for more details.])
5589     fi # COMPILE_ENVIRONMENT and others
5591     if test -z "$GNU_CC" -a -z "$INTEL_CC" -a -z "$CLANG_CC" ; then
5592       dnl We prefer to get asm offsets using inline assembler, which the above
5593       dnl compilers can do. When we're not using one of those, we have to fall
5594       dnl back to obj_int_extract, which reads them from a compiled object
5595       dnl file. Unfortunately, that only works if we're compiling on a system
5596       dnl with the header files for the appropriate object file format.
5597       VPX_NEED_OBJ_INT_EXTRACT=1
5598     fi
5600     if test -n "$VPX_X86_ASM"; then
5601       AC_DEFINE(VPX_X86_ASM)
5602     elif test -n "$VPX_ARM_ASM"; then
5603       AC_DEFINE(VPX_ARM_ASM)
5604     else
5605       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
5606     fi
5608     dnl native libvpx no longer has vpx_mem_set_functions
5609     AC_DEFINE(MOZ_VPX_NO_MEM_REPORTING)
5612 dnl ========================================================
5613 dnl = Disable Wave decoder support
5614 dnl ========================================================
5615 MOZ_ARG_DISABLE_BOOL(wave,
5616 [  --disable-wave          Disable Wave decoder support],
5617     MOZ_WAVE=,
5618     MOZ_WAVE=1)
5620 if test -n "$MOZ_WAVE"; then
5621     AC_DEFINE(MOZ_WAVE)
5624 dnl ========================================================
5625 dnl = Handle dependent MEDIA defines
5626 dnl ========================================================
5628 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
5629     AC_MSG_ERROR([MOZ_VORBIS and MOZ_TREMOR are mutually exclusive!  The build system should not allow them both to be set, but they are.  Please file a bug at https://bugzilla.mozilla.org/])
5632 if test -n "$MOZ_VORBIS"; then
5633     AC_DEFINE(MOZ_VORBIS)
5636 if test -n "$MOZ_TREMOR"; then
5637     AC_DEFINE(MOZ_TREMOR)
5638     # Tremor doesn't have an encoder.
5639     MOZ_WEBM_ENCODER=
5642 if test -n "$MOZ_WEBM_ENCODER"; then
5643     AC_DEFINE(MOZ_WEBM_ENCODER)
5645 AC_SUBST(MOZ_WEBM_ENCODER)
5647 dnl ==================================
5648 dnl = Check alsa availability on Linux
5649 dnl ==================================
5651 dnl If using Linux, ensure that the alsa library is available
5652 if test "$OS_TARGET" = "Linux"; then
5653     MOZ_ALSA=1
5656 MOZ_ARG_ENABLE_BOOL(alsa,
5657 [  --enable-alsa          Enable Alsa support (default on Linux)],
5658    MOZ_ALSA=1,
5659    MOZ_ALSA=)
5661 if test -n "$MOZ_ALSA"; then
5662     PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5663          [echo "$MOZ_ALSA_PKG_ERRORS"
5664           AC_MSG_ERROR([Need alsa for audio output on Linux. (On Ubuntu, you might try installing the package libasound2-dev.)])])
5667 AC_SUBST(MOZ_ALSA)
5669 dnl ========================================================
5670 dnl = Disable PulseAudio
5671 dnl ========================================================
5673 dnl If using Linux, ensure that the PA library is available
5674 case "$OS_TARGET" in
5675 WINNT|Darwin|Android|OpenBSD)
5676     ;;
5678     if test -z "$MOZ_B2G"; then
5679         MOZ_PULSEAUDIO=1
5680     fi
5681     ;;
5682 esac
5684 MOZ_ARG_DISABLE_BOOL(pulseaudio,
5685 [  --disable-pulseaudio          Disable PulseAudio support],
5686    MOZ_PULSEAUDIO=,
5687    MOZ_PULSEAUDIO=1)
5689 if test -n "$MOZ_PULSEAUDIO"; then
5690     if test -z "$gonkdir"; then
5691         PKG_CHECK_MODULES(MOZ_PULSEAUDIO, libpulse, ,
5692              [echo "$MOZ_PULSEAUDIO_PKG_ERRORS"
5693               AC_MSG_ERROR([pulseaudio audio backend requires libpulse development package])])
5694     else
5695         MOZ_PULSEAUDIO_CFLAGS="-I$gonkdir/external/pulseaudio/pulseaudio/src"
5696     fi
5699 AC_SUBST(MOZ_PULSEAUDIO)
5701 dnl ========================================================
5702 dnl = Enable GStreamer
5703 dnl ========================================================
5704 case "$OS_TARGET" in
5705 WINNT|Darwin|Android)
5706     ;;
5708     MOZ_GSTREAMER=1
5709     GST_API_VERSION=0.10
5710     ;;
5711 esac
5713 MOZ_ARG_ENABLE_STRING(gstreamer,
5714 [  --enable-gstreamer[=0.10]           Enable GStreamer support],
5715 [ MOZ_GSTREAMER=1
5716   # API version, eg 0.10, 1.0 etc
5717   if test -z "$enableval" -o "$enableval" = "yes"; then
5718     GST_API_VERSION=0.10
5719   elif test "$enableval" = "no"; then
5720     MOZ_GSTREAMER=
5721   else
5722     GST_API_VERSION=$enableval
5723   fi],
5726 if test -n "$MOZ_GSTREAMER"; then
5727     # core/base release number
5728     if test "$GST_API_VERSION" = "1.0"; then
5729       GST_VERSION=1.0
5730     else
5731       GST_VERSION=0.10.25
5732     fi
5734     PKG_CHECK_MODULES(GSTREAMER,
5735                       gstreamer-$GST_API_VERSION >= $GST_VERSION
5736                       gstreamer-app-$GST_API_VERSION
5737                       gstreamer-plugins-base-$GST_API_VERSION,
5738                       [_HAVE_GSTREAMER=1],
5739                       [_HAVE_GSTREAMER=])
5740     if test -z "$_HAVE_GSTREAMER"; then
5741         AC_MSG_ERROR([gstreamer and gstreamer-plugins-base development packages are needed to build gstreamer backend. Install them or disable gstreamer support with --disable-gstreamer])
5742     fi
5744     _SAVE_LDFLAGS=$LDFLAGS
5745     LDFLAGS="$LDFLAGS $GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5746     AC_TRY_LINK(,[return 0;],_HAVE_LIBGSTVIDEO=1,_HAVE_LIBGSTVIDEO=)
5747     if test -n "$_HAVE_LIBGSTVIDEO" ; then
5748         GSTREAMER_LIBS="$GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5749     else
5750         AC_MSG_ERROR([gstreamer-plugins-base found, but no libgstvideo. Something has gone terribly wrong. Try reinstalling gstreamer-plugins-base; failing that, disable the gstreamer backend with --disable-gstreamer.])
5751     fi
5752     LDFLAGS=$_SAVE_LDFLAGS
5755 AC_SUBST(MOZ_GSTREAMER)
5756 AC_SUBST(GST_API_VERSION)
5758 if test -n "$MOZ_GSTREAMER"; then
5759      AC_DEFINE(MOZ_GSTREAMER)
5760      AC_DEFINE_UNQUOTED(GST_API_VERSION, "$GST_API_VERSION")
5764 dnl ========================================================
5765 dnl Permissions System
5766 dnl ========================================================
5767 MOZ_ARG_DISABLE_BOOL(permissions,
5768 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5769     MOZ_PERMISSIONS=,
5770     MOZ_PERMISSIONS=1
5773 AC_SUBST(MOZ_PERMISSIONS)
5774 if test -n "$MOZ_PERMISSIONS"; then
5775     AC_DEFINE(MOZ_PERMISSIONS)
5778 dnl ========================================================
5779 dnl Child permissions, currently only used for b2g
5780 dnl ========================================================
5781 if test -n "$MOZ_B2G"; then
5782     if test -n "$MOZ_PERMISSIONS"; then
5783         MOZ_CHILD_PERMISSIONS=1
5784         AC_DEFINE(MOZ_CHILD_PERMISSIONS)
5785     else
5786         AC_MSG_ERROR([You need to enable MOZ_PERMISSIONS for MOZ_CHILD_PERMISSIONS])
5787     fi
5789 AC_SUBST(MOZ_CHILD_PERMISSIONS)
5791 dnl ========================================================
5792 dnl NegotiateAuth
5793 dnl ========================================================
5795 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5796 [  --disable-negotiateauth Disable GSS-API negotiation ],
5797     MOZ_AUTH_EXTENSION=,
5798     MOZ_AUTH_EXTENSION=1 )
5800 if test -n "$MOZ_IOS" -a -n "$MOZ_AUTH_EXTENSION"; then
5801    AC_MSG_ERROR([negotiateauth is not supported on iOS.])
5804 dnl ========================================================
5805 dnl Pref extensions (autoconfig)
5806 dnl ========================================================
5807 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5808 [  --disable-pref-extensions
5809                           Disable pref extensions such as autoconfig],
5810   MOZ_PREF_EXTENSIONS=,
5811   MOZ_PREF_EXTENSIONS=1 )
5813 dnl ========================================================
5814 dnl Searching of system directories for extensions.
5815 dnl Note: this switch is meant to be used for test builds
5816 dnl whose behavior should not depend on what happens to be
5817 dnl installed on the local machine.
5818 dnl ========================================================
5819 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
5820 [  --disable-system-extension-dirs
5821                           Disable searching system- and account-global
5822                           directories for extensions of any kind; use
5823                           only profile-specific extension directories],
5824   ENABLE_SYSTEM_EXTENSION_DIRS=,
5825   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
5826 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
5827   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
5830 dnl ========================================================
5831 dnl = Universalchardet
5832 dnl ========================================================
5833 MOZ_ARG_DISABLE_BOOL(universalchardet,
5834 [  --disable-universalchardet
5835                           Disable universal encoding detection],
5836   MOZ_UNIVERSALCHARDET=,
5837   MOZ_UNIVERSALCHARDET=1 )
5839 if test -n "${JAVA_BIN_PATH}"; then
5840   dnl Look for javac and jar in the specified path.
5841   JAVA_PATH="$JAVA_BIN_PATH"
5842 else
5843   dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5844   JAVA_PATH="$JAVA_HOME/bin:$PATH"
5847 MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5848 MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5849 MOZ_PATH_PROG(JAVAH, javah, :, [$JAVA_PATH])
5850 MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5851 MOZ_PATH_PROG(JARSIGNER, jarsigner, :, [$JAVA_PATH])
5852 MOZ_PATH_PROG(KEYTOOL, keytool, :, [$JAVA_PATH])
5854 if test -n "${JAVA_BIN_PATH}" -o \
5855   \( "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk" \); then
5856   if test -z "$JAVA" -o "$JAVA" = ":"; then
5857     AC_MSG_ERROR([The program java was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5858   fi
5859   if test -z "$JAVAC" -o "$JAVAC" = ":"; then
5860     AC_MSG_ERROR([The program javac was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5861   fi
5862   if test -z "$JAVAH" -o "$JAVAH" = ":"; then
5863     AC_MSG_ERROR([The program javah was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5864   fi
5865   if test -z "$JAR" -o "$JAR" = ":"; then
5866     AC_MSG_ERROR([The program jar was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5867   fi
5868   if test -z "$JARSIGNER" -o "$JARSIGNER" = ":"; then
5869     AC_MSG_ERROR([The program jarsigner was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5870   fi
5871   if test -z "$KEYTOOL" -o "$KEYTOOL" = ":"; then
5872     AC_MSG_ERROR([The program keytool was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5873   fi
5875   AC_MSG_CHECKING([for minimum required javac version >= 1.7])
5877   dnl Javac spits out something like `javac 1.7.0`. This line cuts off the 'javac'
5878   _javac_version=$($JAVAC -version 2>&1 | cut -d ' ' -f 2)
5880   dnl Here, we extract the major (1) and minor (7) version numbers from the
5881   dnl acquired version string.
5882   _javac_major_version=$(echo $_javac_version | cut -d '.' -f 1)
5883   _javac_minor_version=$(echo $_javac_version | cut -d '.' -f 2)
5885   AC_MSG_RESULT([$_javac_version])
5887   dnl Fail if we have a version other than 1.7.X
5888   if test "$_javac_major_version" -ne "1" -o \
5889        \( "$_javac_minor_version" -lt "7" \); then
5890       AC_MSG_ERROR([javac 1.7 or higher is required.])
5891   fi
5894 dnl ========================================================
5895 dnl = ANGLE OpenGL->D3D translator for WebGL
5896 dnl = * only applies to win32
5897 dnl ========================================================
5899 MOZ_ANGLE_RENDERER=
5900 MOZ_D3D_CPU_SUFFIX=
5901 MOZ_HAS_WINSDK_WITH_D3D=
5902 MOZ_D3DCOMPILER_VISTA_DLL=
5903 MOZ_D3DCOMPILER_VISTA_DLL_PATH=
5904 MOZ_DIRECTX_SDK_PATH=
5905 MOZ_D3DCOMPILER_XP_DLL=
5906 MOZ_D3DCOMPILER_XP_CAB=
5908 case "$target_os" in
5909 *mingw*)
5910     MOZ_ANGLE_RENDERER=1
5911     ;;
5912 esac
5914 # The DirectX SDK libraries are split into x86 and x64 sub-directories
5915 case "${target_cpu}" in
5916 i*86)
5917   MOZ_D3D_CPU_SUFFIX=x86
5918   ;;
5919 x86_64)
5920   MOZ_D3D_CPU_SUFFIX=x64
5921   ;;
5922 esac
5924 MOZ_ARG_ENABLE_BOOL(require-all-d3dc-versions,
5925 [  --enable-require-all-d3dc-versions Require all versions of the D3D compiler needed for supported Windows systems.],
5926     MOZ_REQUIRE_ALL_D3DCS=1,
5927     MOZ_REQUIRE_ALL_D3DCS=)
5929 # This is potentially set in external mozconfig files; if it's set,
5930 # then the build exposes the "webgl" context name, which is reserved
5931 # for conformant implementations.
5932 if test -n "$MOZ_WEBGL_CONFORMANT"; then
5933   AC_DEFINE(MOZ_WEBGL_CONFORMANT)
5936 dnl ========================================================
5937 dnl D3D compiler DLL
5938 dnl ========================================================
5939 MOZ_FOUND_D3D_COMPILERS=
5941 if test -n "$MOZ_ANGLE_RENDERER"; then
5942   if test -z "$MOZ_D3D_CPU_SUFFIX"; then
5943     AC_MSG_ERROR([Couldn't determine MOZ_D3D_CPU_SUFFIX.])
5944   fi
5946   ######################################
5947   # Find _46+ for use by Vista+.
5949   # Find a D3D compiler DLL in a Windows SDK.
5950   MOZ_D3DCOMPILER_VISTA_DLL=
5951   case "$MOZ_WINSDK_MAXVER" in
5952   0x0603*)
5953     MOZ_D3DCOMPILER_VISTA_DLL=d3dcompiler_47.dll
5954     AC_MSG_RESULT([Found D3D compiler in Windows SDK 8.1.])
5955   ;;
5956   esac
5958   if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
5959     # We have a name, now track down the path.
5960     if test -n "$WINDOWSSDKDIR"; then
5961       MOZ_D3DCOMPILER_VISTA_DLL_PATH="$WINDOWSSDKDIR/Redist/D3D/$MOZ_D3D_CPU_SUFFIX/$MOZ_D3DCOMPILER_VISTA_DLL"
5962       if test -f "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
5963         AC_MSG_RESULT([Found MOZ_D3DCOMPILER_VISTA_DLL_PATH: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
5964         MOZ_HAS_WINSDK_WITH_D3D=1
5965       else
5966         AC_MSG_RESULT([MOZ_D3DCOMPILER_VISTA_DLL_PATH doesn't exist: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
5967         AC_MSG_ERROR([Windows SDK at "$WINDOWSSDKDIR" appears broken. Try updating to MozillaBuild 1.9 final or higher.])
5968         MOZ_D3DCOMPILER_VISTA_DLL_PATH=
5969       fi
5970     else
5971       AC_MSG_RESULT([Windows SDK not found.])
5972     fi
5973   fi
5975   if test -z "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
5976     MOZ_D3DCOMPILER_VISTA_DLL=
5977   fi
5979   # On mingw, check if headers are provided by toolchain.
5980   if test -n "$GNU_CC"; then
5981     MOZ_CHECK_HEADER(d3d10.h, MOZ_HAS_WINSDK_WITH_D3D=1)
5982   fi
5984   ######################################
5985   # Find _43 for use by XP.
5987   if test "$HAVE_64BIT_BUILD"; then
5988     AC_MSG_RESULT([We are building a 64-bit binary, skip checking d3dcompiler_43.])
5989   else
5990     # Get the SDK path from the registry.
5991     # First try to get the June 2010 SDK
5992     MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK (June 2010)' | head -n 1`
5993     if test -z "$MOZ_DIRECTX_SDK_REG_KEY" ; then
5994       # Otherwise just take whatever comes first
5995       MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK' | head -n 1`
5996     fi
5997     MOZ_DIRECTX_SDK_PATH=`reg query "$MOZ_DIRECTX_SDK_REG_KEY" //v InstallPath | grep REG_SZ | sed 's/.*\([[a-zA-Z]]\)\\:\\\\/\\1\\:\\\\/' | sed 's,\\\\,/,g'`
5999     if test -n "$MOZ_DIRECTX_SDK_PATH" &&
6000        test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_D3D_CPU_SUFFIX/dxguid.lib ; then
6001       AC_MSG_RESULT([Found DirectX SDK via registry, using $MOZ_DIRECTX_SDK_PATH])
6002     else
6003       AC_MSG_RESULT([DirectX SDK not found.])
6004       MOZ_DIRECTX_SDK_PATH=
6005     fi
6007     # Check that our DirectX SDK is acceptable.
6008     if test -n "$MOZ_DIRECTX_SDK_PATH"; then
6009       if test -n "`echo $MOZ_DIRECTX_SDK_REG_KEY | grep 'February 2010'`" ; then
6010         AC_MSG_RESULT([Found the February 2010 DirectX SDK, which is unacceptable to ANGLE.])
6011         MOZ_DIRECTX_SDK_PATH=
6012       fi
6013     fi
6015     if test -n "$MOZ_DIRECTX_SDK_PATH"; then
6016       # Find a D3D compiler DLL in the DirectX SDK, if we didn't find one already.
6017       # Get the SDK numeric version (e.g. 43) by looking at the dependencies of d3dx9.lib
6018       MOZ_D3DX9_VERSION=`dumpbin //headers "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_D3D_CPU_SUFFIX/d3dx9.lib | egrep d3dx9_[[0-9]][[0-9]]\.dll | head -n1 | sed 's/.*\([[0-9]][[0-9]]\).*/\\1/g'`
6020       if test -n "$MOZ_D3DX9_VERSION" ; then
6021         MOZ_D3DCOMPILER_XP_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *D3DCompiler_${MOZ_D3DX9_VERSION}_${MOZ_D3D_CPU_SUFFIX}.cab | head -n1`
6023         if test -n "$MOZ_D3DCOMPILER_XP_CAB"; then
6024           MOZ_D3DCOMPILER_XP_DLL=D3DCompiler_$MOZ_D3DX9_VERSION.dll
6025         else
6026           AC_MSG_RESULT([Couldn't find a CAB containing the D3D compiler DLL.])
6027           AC_MSG_ERROR([DirectX SDK at "$MOZ_DIRECTX_SDK_PATH" appears broken.])
6028           MOZ_DIRECTX_SDK_PATH=
6029         fi
6030       else
6031         AC_MSG_RESULT([Couldn't determine the D3DX9 version for the DirectX SDK.])
6032         MOZ_DIRECTX_SDK_PATH=
6033       fi
6034     else
6035       AC_MSG_RESULT([Couldn't find an acceptable DirectX SDK for ANGLE, needed for d3dcompiler_43.])
6036     fi
6037   fi
6039   ######################################
6040   # Check that we found what we needed.
6041   MOZ_FOUND_A_D3D_COMPILER=
6042   MOZ_FOUND_BOTH_D3D_COMPILERS=1
6044   if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
6045     MOZ_FOUND_A_D3D_COMPILER=1
6046     AC_MSG_RESULT([Found d3dcompiler DLL for Vista+: $MOZ_D3DCOMPILER_VISTA_DLL])
6047   else
6048     MOZ_FOUND_BOTH_D3D_COMPILERS=
6049   fi
6051   if test -n "$MOZ_D3DCOMPILER_XP_DLL"; then
6052     MOZ_FOUND_A_D3D_COMPILER=1
6053     AC_MSG_RESULT([Found d3dcompiler DLL for XP: $MOZ_D3DCOMPILER_XP_DLL])
6054   else
6055     MOZ_FOUND_BOTH_D3D_COMPILERS=
6056   fi
6058   if test -z "$CROSS_COMPILE"; then
6059     if test -z "MOZ_FOUND_A_D3D_COMPILER"; then
6060       AC_MSG_ERROR([Couldn't find an acceptable D3D compiler DLL.])
6061     fi
6063     if test -n "$MOZ_REQUIRE_ALL_D3DCS" -a -z "$MOZ_FOUND_BOTH_D3D_COMPILERS"; then
6064       AC_MSG_ERROR([Both D3D compilers _43 and _46+ are required by --enable-require-d3d-compilers.])
6065       AC_MSG_ERROR([  Install Windows SDK 8.0+, as well as DirectX SDK (June 2010 version or newer), or reconfigure without this flag.])
6066     fi
6067   fi
6071 dnl ========================================================
6072 dnl Gamepad support
6073 dnl ========================================================
6074 MOZ_GAMEPAD=
6075 MOZ_GAMEPAD_BACKEND=stub
6077 # Gamepad DOM is built on supported platforms by default.
6078 case "$OS_TARGET" in
6079      WINNT|Linux)
6080        MOZ_GAMEPAD=1
6081        ;;
6082      Darwin)
6083        if test -z "$MOZ_IOS"; then
6084          MOZ_GAMEPAD=1
6085        fi
6086        ;;
6087      Android)
6088        if test "$MOZ_WIDGET_TOOLKIT" != "gonk"; then
6089          MOZ_GAMEPAD=1
6090        fi
6091        ;;
6092      *)
6093        ;;
6094 esac
6096 MOZ_ARG_DISABLE_BOOL(gamepad,
6097 [  --disable-gamepad   Disable gamepad support],
6098     MOZ_GAMEPAD=,
6099     MOZ_GAMEPAD=1)
6101 if test "$MOZ_GAMEPAD"; then
6102     case "$OS_TARGET" in
6103     Darwin)
6104         if test -z "$MOZ_IOS"; then
6105             MOZ_GAMEPAD_BACKEND=cocoa
6106         fi
6107         ;;
6108     WINNT)
6109         MOZ_GAMEPAD_BACKEND=windows
6110         ;;
6111     Linux)
6112         MOZ_CHECK_HEADER([linux/joystick.h])
6113         if test "$ac_cv_header_linux_joystick_h" != "yes"; then
6114           AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers or reconfigure with --disable-gamepad to disable gamepad support.])
6115         fi
6116         MOZ_GAMEPAD_BACKEND=linux
6117         ;;
6118     Android)
6119         MOZ_GAMEPAD_BACKEND=android
6120         ;;
6121     *)
6122         ;;
6123    esac
6125   AC_DEFINE(MOZ_GAMEPAD)
6127 AC_SUBST(MOZ_GAMEPAD)
6128 AC_SUBST(MOZ_GAMEPAD_BACKEND)
6130 dnl ========================================================
6131 dnl = Breakpad crash reporting (on by default on supported platforms)
6132 dnl ========================================================
6134 case $target in
6135 i?86-*-mingw*|x86_64-*-mingw*)
6136   MOZ_CRASHREPORTER=1
6137   ;;
6138 i?86-apple-darwin*|x86_64-apple-darwin*)
6139   if test -z "$MOZ_IOS"; then
6140     MOZ_CRASHREPORTER=1
6141   fi
6142   ;;
6143 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
6144   if test "$MOZ_ENABLE_GTK"; then
6145     MOZ_CRASHREPORTER=1
6146   fi
6147   ;;
6148 *-android*|*-linuxandroid*)
6149   MOZ_CRASHREPORTER=1
6150   ;;
6151 *solaris*)
6152   MOZ_CRASHREPORTER=1
6153   ;;
6154 esac
6156 MOZ_ARG_DISABLE_BOOL(crashreporter,
6157 [  --disable-crashreporter Disable breakpad crash reporting],
6158     [MOZ_CRASHREPORTER=],
6159     [MOZ_CRASHREPORTER=F # Force enable breakpad])
6161 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT"; then
6162   if test "$MOZ_CRASHREPORTER" = F; then
6163     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
6164   fi
6165   MOZ_CRASHREPORTER=
6168 if test -n "$MOZ_CRASHREPORTER"; then
6169    AC_DEFINE(MOZ_CRASHREPORTER)
6171   if test "$OS_TARGET" = "Linux" -o "$OS_ARCH" = "SunOS" && \
6172     test -z "$SKIP_LIBRARY_CHECKS"; then
6173     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
6174   fi
6176   if test "$OS_ARCH" = "WINNT"; then
6177     if test -z "$HAVE_64BIT_BUILD"; then
6178       MOZ_CRASHREPORTER_INJECTOR=1
6179       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
6180     fi
6181   fi
6184 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
6185 [  --with-crashreporter-enable-percent=NN
6186                           Enable sending crash reports by default on NN% of users. (default=100)],
6187 [ val=`echo $withval | sed 's/[^0-9]//g'`
6188     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
6190 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
6191    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
6193 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
6195 dnl ========================================================
6196 dnl = libjpeg-turbo configuration
6197 dnl ========================================================
6198 MOZ_LIBJPEG_TURBO=
6199 if test -z "$MOZ_NATIVE_JPEG"; then
6200     MOZ_LIBJPEG_TURBO=1
6203 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
6204 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
6205     MOZ_LIBJPEG_TURBO=,
6206     MOZ_LIBJPEG_TURBO=1)
6208 if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
6209     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
6212 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
6213 dnl files.
6215 if test -n "$MOZ_LIBJPEG_TURBO"; then
6217   dnl Do we support libjpeg-turbo on this platform?
6218   case "$OS_ARCH:$CPU_ARCH" in
6219   Darwin:x86)
6220     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
6221   ;;
6222   Darwin:x86_64)
6223     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
6224   ;;
6225   Darwin:arm*)
6226   ;;
6227   WINNT:x86)
6228     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
6229   ;;
6230   WINNT:x86_64)
6231     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
6232   ;;
6233   *:arm)
6234     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
6235   ;;
6236   *:aarch64)
6237     LIBJPEG_TURBO_ASFLAGS="-march=armv8-a"
6238   ;;
6239   *:mips)
6240     LIBJPEG_TURBO_ASFLAGS="-mdspr2"
6241   ;;
6242   *:x86)
6243     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6244       LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6245     fi
6246   ;;
6247   *:x86_64)
6248     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6249       LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6250     fi
6251   ;;
6252   esac
6255 if test -n "$LIBJPEG_TURBO_ASFLAGS"; then
6256   case "$CPU_ARCH" in
6257 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
6258 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
6259 dnl it doesn't exist or we have too old of a version.
6260   x86_64|x86)
6261     LIBJPEG_TURBO_AS=$YASM
6263     if test -z "$LIBJPEG_TURBO_AS" ; then
6264         AC_MSG_ERROR([Yasm is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you do not appear to have Yasm installed.  Either install it or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder.  See https://developer.mozilla.org/en/YASM for more details.])
6265     fi
6267     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
6268     dnl on Linux and 1.1 or newer everywhere else.
6269     if test "$OS_ARCH" = "Linux" ; then
6270         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -eq "0" -a "$_YASM_RELEASE" -lt "1" \) ; then
6271             AC_MSG_ERROR([Yasm 1.0.1 or greater is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you appear to have version $_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.$_YASM_RELEASE.  Upgrade to the newest version or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder.  See https://developer.mozilla.org/en/YASM for more details.])
6272         fi
6273     else
6274         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
6275             AC_MSG_ERROR([Yasm 1.1 or greater is required to build with libjpeg-turbo's optimized JPEG decoding routines, but you appear to have version $_YASM_MAJOR_VERSION.$_YASM_MINOR_VERSION.  Upgrade to the newest version or configure with --disable-libjpeg-turbo to use the pure C JPEG decoder.  See https://developer.mozilla.org/en/YASM for more details.])
6276         fi
6277     fi
6278   ;;
6279 dnl On other platforms, use the C compiler as the assembler.
6280   *)
6281     LIBJPEG_TURBO_AS=$AS
6282   ;;
6283   esac
6284 elif test -n "$MOZ_LIBJPEG_TURBO"; then
6285     dnl Warn if we're not building the optimized routines, even though the user
6286     dnl didn't specify --disable-libjpeg-turbo.
6287     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
6290 dnl ========================================================
6291 dnl = libav-fft configuration
6292 dnl ========================================================
6294 MOZ_LIBAV_FFT=
6296 dnl Turn on libav-fft for 32-bit windows, and all 64-bit supported platforms.
6297 dnl 32-bit linux/os x have text relocation issues.
6299 case "$OS_ARCH:$CPU_ARCH" in
6300   WINNT:x86)
6301       MOZ_LIBAV_FFT=1
6302   ;;
6303   *:x86_64)
6304       MOZ_LIBAV_FFT=1
6305   ;;
6306 esac
6308 dnl Detect if we can use yasm to compile libav's assembly
6310 if test -n "$MOZ_LIBAV_FFT"; then
6311   AC_DEFINE(MOZ_LIBAV_FFT)
6312   dnl Do we support libav-fft on this platform?
6313   case "$OS_ARCH:$CPU_ARCH" in
6314   Darwin:x86_64)
6315     LIBAV_FFT_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
6316   ;;
6317   WINNT:x86)
6318     LIBAV_FFT_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
6319   ;;
6320   WINNT:x86_64)
6321     LIBAV_FFT_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
6322   ;;
6323   *:x86_64)
6324     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6325       LIBAV_FFT_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6326     fi
6327   ;;
6328   *)
6329     AC_MSG_ERROR([libav's FFT routines are only available for 32-bit windows or 64-bit x86 based platforms.])
6330   ;;
6331   esac
6334 if test -n "$LIBAV_FFT_ASFLAGS"; then
6335   dnl If we're on an x86 or x64 system which supports libav-fft's asm routines
6336   dnl check for Yasm, and error out if it doesn't exist or we have too old of a
6337   dnl version.
6338   LIBAV_FFT_AS=$YASM
6339   if test -z "$LIBAV_FFT_AS" ; then
6340     AC_MSG_ERROR([Yasm is required to build with libav's optimized FFT routines, but you do not appear to have Yasm installed. See https://developer.mozilla.org/en/YASM for more details.])
6341   fi
6342   dnl Check that we have the right yasm version.  We require 1.0.1 or newer
6343   dnl on Linux and 1.1 or newer everywhere else.
6344   if test "$OS_ARCH" = "Linux" ; then
6345     if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -eq "0" -a "$_YASM_RELEASE" -lt "1" \) ; then
6346       AC_MSG_ERROR([Yasm 1.0.1 or greater is required to build with libav's optimized FFT routines, but you do not appear to have Yasm installed.  See https://developer.mozilla.org/en/YASM for more details.])
6347     fi
6348   else
6349     if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
6350       AC_MSG_ERROR([Yasm 1.1 or greater is required to build with libav's optimized FFT routines, but you do not appear to have Yasm installed.  See https://developer.mozilla.org/en/YASM for more details.])
6351     fi
6352   fi
6353 elif test -n "$MOZ_LIBAV_FFT" -a "${CPU_ARCH}" != "arm"; then
6354   dnl Warn if we're not building either libav or opendl-max optimized routines.
6355   AC_MSG_WARN([No assembler or assembly support for libav-fft.  Using unoptimized C routines.])
6358 dnl ========================================================
6359 dnl = Enable compilation of specific extension modules
6360 dnl ========================================================
6362 MOZ_ARG_ENABLE_STRING(extensions,
6363 [  --enable-extensions     Enable extensions],
6364 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6365     if test "$option" = "yes" -o "$option" = "all"; then
6366         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
6367     elif test "$option" = "no" -o "$option" = "none"; then
6368         MOZ_EXTENSIONS=""
6369     elif test "$option" = "default"; then
6370         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
6371     elif test `echo "$option" | grep -c \^-` != 0; then
6372         option=`echo $option | sed 's/^-//'`
6373         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
6374     else
6375         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
6376     fi
6377 done],
6378     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
6380 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6381     # Suppress warning on non-X11 platforms
6382     if test -n "$MOZ_X11"; then
6383         AC_MSG_WARN([Removing gio from MOZ_EXTENSIONS due to --disable-gio.])
6384     fi
6385     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6388 dnl Do not build gio with libxul based apps
6389 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6390     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6393 if test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6394     MOZ_GIO_COMPONENT=1
6395     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6397 AC_SUBST(MOZ_GIO_COMPONENT)
6399 dnl Remove dupes
6400 MOZ_EXTENSIONS=`$PYTHON ${srcdir}/build/unix/uniq.py ${MOZ_EXTENSIONS}`
6402 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6403 dnl when trying to build a nonexistent extension.
6404 for extension in $MOZ_EXTENSIONS; do
6405     if test ! -d "${srcdir}/extensions/${extension}"; then
6406         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6407     fi
6408 done
6410 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
6411   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
6414 dnl ========================================================
6415 dnl Build Freetype in the tree
6416 dnl ========================================================
6417 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6418 [  --enable-tree-freetype  Enable Tree FreeType],
6419     MOZ_TREE_FREETYPE=1,
6420     MOZ_TREE_FREETYPE= )
6421 if test -n "$MOZ_TREE_FREETYPE"; then
6422    if test -n "$_WIN32_MSVC"; then
6423       AC_ERROR("building with in-tree freetype is not supported on MSVC")
6424    fi
6425    AC_DEFINE(MOZ_TREE_FREETYPE)
6426    AC_SUBST(MOZ_TREE_FREETYPE)
6427    MOZ_ENABLE_CAIRO_FT=1
6428    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6429    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6430    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6431    CAIRO_FT_OSLIBS=''
6432    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6433    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6434    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6435    AC_SUBST_LIST(CAIRO_FT_CFLAGS)
6438 dnl ========================================================
6439 dnl Installer
6440 dnl ========================================================
6441 dnl Abort Windows build if the required major version and
6442 dnl minimum minor version of Unicode NSIS isn't in the path
6443 dnl (unless in case of cross compiling, for which Unicode
6444 dnl is not yet sufficient).
6445 if test "$OS_ARCH" = "WINNT"; then
6446     MIN_NSIS_MAJOR_VER=2
6447     MIN_NSIS_MINOR_VER=46
6448     MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensis-3.0b1.exe makensisu-3.0a2.exe makensisu-2.46.exe makensis)
6449     if test -n "$MAKENSISU" -a "$MAKENSISU" != ":"; then
6450       AC_MSG_RESULT([yes])
6451       MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null`
6452       changequote(,)
6453       MAKENSISU_PARSED_VER=`echo "$MAKENSISU_VER" | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\).*\-Unicode$/\1/g'`
6454       changequote([,])
6455       if test "$MAKENSISU_PARSED_VER" = ""; then
6456           changequote(,)
6457           MAKENSISU_PARSED_VER=`echo "$MAKENSISU_VER" | sed -e 's/^v\([0-9]\+\.[0-9]\+\).*$/\1/g'`
6458           changequote([,])
6459       fi
6460       MAKENSISU_MAJOR_VER=0
6461       MAKENSISU_MINOR_VER=0
6462       if test ! "$MAKENSISU_PARSED_VER" = ""; then
6463           MAKENSISU_MAJOR_VER=`echo $MAKENSISU_PARSED_VER | $AWK -F\. '{ print $1 }'`
6464           MAKENSISU_MINOR_VER=`echo $MAKENSISU_PARSED_VER | $AWK -F\. '{ print $2 }'`
6465       fi
6466       AC_MSG_CHECKING([for Unicode NSIS version $MIN_NSIS_MAJOR_VER.$MIN_NSIS_MINOR_VER or greater])
6467       if test "$MAKENSISU_MAJOR_VER" -eq $MIN_NSIS_MAJOR_VER -a \
6468               "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER ||
6469          test "$MAKENSISU_MAJOR_VER" -gt $MIN_NSIS_MAJOR_VER; then
6470           AC_MSG_RESULT([yes])
6471       else
6472           AC_MSG_RESULT([no])
6473           if test -z "$CROSS_COMPILE"; then
6474             AC_MSG_ERROR([To build the installer you must have the latest MozillaBuild or Unicode NSIS version $MIN_NSIS_MAJOR_VER.$MIN_NSIS_MINOR_VER or greater in your path.])
6475           else
6476             MAKENSISU=
6477           fi
6478       fi
6479     elif test -z "$CROSS_COMPILE"; then
6480       AC_MSG_ERROR([To build the installer you must have the latest MozillaBuild or Unicode NSIS version $MIN_NSIS_MAJOR_VER.$MIN_NSIS_MINOR_VER or greater in your path.])
6481     else
6482       MAKENSISU=
6483     fi
6486 dnl ========================================================
6487 dnl Web App Runtime
6488 dnl ========================================================
6489 MOZ_ARG_DISABLE_BOOL(webapp-runtime,
6490 [  --disable-webapp-runtime  Disable Web App Runtime],
6491     MOZ_WEBAPP_RUNTIME=,
6492     MOZ_WEBAPP_RUNTIME=1)
6493 if test "$MOZ_WIDGET_TOOLKIT" != "windows" -a "$MOZ_WIDGET_TOOLKIT" != "cocoa" -a -z "$MOZ_WIDGET_GTK" ; then
6494     MOZ_WEBAPP_RUNTIME=
6496 if test "$OS_ARCH" = "WINNT" -a -z "$MAKENSISU" -a -n "$CROSS_COMPILE"; then
6497     MOZ_WEBAPP_RUNTIME=
6499 AC_SUBST(MOZ_WEBAPP_RUNTIME)
6500 if test "$MOZ_WEBAPP_RUNTIME"; then
6501     AC_DEFINE(MOZ_WEBAPP_RUNTIME)
6504 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6505 if test -z "$TAR"; then
6506     AC_MSG_ERROR([no tar archiver found in \$PATH])
6508 AC_SUBST(TAR)
6510 AC_CHECK_PROGS(WGET, wget, "")
6511 AC_SUBST(WGET)
6513 dnl ========================================================
6514 dnl Signing
6515 dnl ========================================================
6517 if test -n "$MOZ_SIGN_CMD"; then
6518     AC_DEFINE(MOZ_SIGNING)
6521 dnl ========================================================
6522 dnl Maintenance Service
6523 dnl ========================================================
6525 MOZ_ARG_ENABLE_BOOL(maintenance-service,
6526 [  --enable-maintenance-service       Enable building of maintenanceservice],
6527     MOZ_MAINTENANCE_SERVICE=1,
6528     MOZ_MAINTENANCE_SERVICE= )
6530 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
6531   if test "$OS_ARCH" = "WINNT"; then
6532     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
6533   else
6534     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
6535   fi
6538 dnl ========================================================
6539 dnl Bundled fonts on desktop platforms
6540 dnl ========================================================
6542 MOZ_ARG_ENABLE_BOOL(bundled-fonts,
6543 [  --enable-bundled-fonts  Enable support for bundled fonts on desktop platforms],
6544     MOZ_BUNDLED_FONTS=1,
6545     MOZ_BUNDLED_FONTS=)
6547 if test -n "$MOZ_BUNDLED_FONTS"; then
6548   AC_DEFINE(MOZ_BUNDLED_FONTS)
6551 dnl ========================================================
6552 dnl Verify MAR signatures
6553 dnl ========================================================
6555 MOZ_ARG_ENABLE_BOOL(verify-mar,
6556 [  --enable-verify-mar     Enable verifying MAR signatures],
6557     MOZ_VERIFY_MAR_SIGNATURE=1,
6558     MOZ_VERIFY_MAR_SIGNATURE= )
6560 if test -n "$MOZ_VERIFY_MAR_SIGNATURE"; then
6561   AC_DEFINE(MOZ_VERIFY_MAR_SIGNATURE)
6564 dnl ========================================================
6565 dnl Enable building the signmar program.
6566 dnl This option is much different than the --enable-verify-mar option.
6567 dnl --enable-verify-mar is for enabling the verification check on MAR
6568 dnl files in the updater.  The --enable-signmar option is for building
6569 dnl the signmar program.
6570 dnl ========================================================
6572 MOZ_ARG_ENABLE_BOOL(signmar,
6573 [  --enable-signmar     Enable building the signmar program],
6574     MOZ_ENABLE_SIGNMAR=1,
6575     MOZ_ENABLE_SIGNMAR= )
6577 if test -n "$MOZ_ENABLE_SIGNMAR"; then
6578   AC_DEFINE(MOZ_ENABLE_SIGNMAR)
6581 dnl ========================================================
6582 dnl Updater
6583 dnl ========================================================
6585 if test "$MOZ_IOS"; then
6586   MOZ_UPDATER=
6589 MOZ_ARG_DISABLE_BOOL(updater,
6590 [  --disable-updater       Disable building of updater],
6591     MOZ_UPDATER=,
6592     MOZ_UPDATER=1 )
6594 if test -n "$MOZ_UPDATER"; then
6595     AC_DEFINE(MOZ_UPDATER)
6598 # tools/update-packaging is not checked out by default.
6599 MOZ_ARG_ENABLE_BOOL(update-packaging,
6600 [  --enable-update-packaging
6601                           Enable tools/update-packaging],
6602     MOZ_UPDATE_PACKAGING=1,
6603     MOZ_UPDATE_PACKAGING= )
6604 AC_SUBST(MOZ_UPDATE_PACKAGING)
6606 dnl ========================================================
6607 dnl build the tests by default
6608 dnl ========================================================
6609 MOZ_ARG_DISABLE_BOOL(tests,
6610 [  --disable-tests         Do not build test libraries & programs],
6611     ENABLE_TESTS=,
6612     ENABLE_TESTS=1 )
6614 if test -n "$ENABLE_TESTS"; then
6615     GTEST_HAS_RTTI=0
6616     AC_DEFINE(ENABLE_TESTS)
6617     AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0)
6618     AC_SUBST(GTEST_HAS_RTTI)
6619     if test -n "$_WIN32_MSVC"; then
6620           AC_DEFINE_UNQUOTED(_VARIADIC_MAX, 10)
6621     fi
6622     if test "${OS_TARGET}" = "Android"; then
6623         AC_DEFINE(GTEST_OS_LINUX_ANDROID)
6624         AC_DEFINE(GTEST_USE_OWN_TR1_TUPLE)
6625         AC_DEFINE_UNQUOTED(GTEST_HAS_CLONE, 0)
6626         AC_SUBST(GTEST_OS_LINUX_ANDROID)
6627         AC_SUBST(GTEST_USE_OWN_TR1_TUPLE)
6628         AC_SUBST(GTEST_HAS_CLONE)
6629     fi
6632 dnl ========================================================
6633 dnl parental controls (for Windows Vista)
6634 dnl ========================================================
6635 MOZ_ARG_DISABLE_BOOL(parental-controls,
6636 [  --disable-parental-controls
6637                           Do not build parental controls],
6638    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6639    MOZ_DISABLE_PARENTAL_CONTROLS=)
6640 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6641     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6644 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6646 dnl ========================================================
6647 dnl = Disable smartcard support
6648 dnl ========================================================
6649 if test -n "$MOZ_NO_SMART_CARDS"; then
6650     AC_DEFINE(MOZ_NO_SMART_CARDS)
6652 AC_SUBST(MOZ_NO_SMART_CARDS)
6654 dnl ========================================================
6655 dnl = Disable EV certificate verification
6656 dnl ========================================================
6657 if test -n "$MOZ_NO_EV_CERTS"; then
6658     AC_DEFINE(MOZ_NO_EV_CERTS)
6660 AC_SUBST(MOZ_NO_EV_CERTS)
6662 dnl ========================================================
6663 dnl = Sandboxing support
6664 dnl ========================================================
6665 if test -n "$MOZ_TSAN"; then
6666     # Bug 1182565: TSan conflicts with sandboxing on Linux.
6667     case $OS_TARGET in
6668     Linux|Android)
6669         MOZ_SANDBOX=
6670         ;;
6671     esac
6674 MOZ_ARG_DISABLE_BOOL(sandbox,
6675 [  --disable-sandbox        Disable sandboxing support],
6676     MOZ_SANDBOX=,
6677     MOZ_SANDBOX=1)
6679 dnl ========================================================
6680 dnl = Content process sandboxing
6681 dnl ========================================================
6682 if test -n "$gonkdir"; then
6683     MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
6686 case "$OS_TARGET:$NIGHTLY_BUILD" in
6687 WINNT:1)
6688     MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
6689     ;;
6690 Darwin:1)
6691     MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
6692     ;;
6693 esac
6695 MOZ_ARG_ENABLE_BOOL(content-sandbox,
6696 [  --enable-content-sandbox Enable sandboxing support for content-processes
6697   --disable-content-sandbox Disable sandboxing support for content-processes],
6698     MOZ_CONTENT_SANDBOX=1,
6699     MOZ_CONTENT_SANDBOX=)
6701 if test -n "$MOZ_CONTENT_SANDBOX" -a -z "$MOZ_SANDBOX"; then
6702     AC_MSG_ERROR([--enable-content-sandbox and --disable-sandbox are conflicting options])
6705 if test -n "$MOZ_CONTENT_SANDBOX"; then
6706     AC_DEFINE(MOZ_CONTENT_SANDBOX)
6709 AC_SUBST(MOZ_CONTENT_SANDBOX)
6711 dnl ========================================================
6712 dnl = Gecko Media Plugin sandboxing
6713 dnl ========================================================
6714 case $OS_TARGET in
6715 WINNT)
6716     MOZ_GMP_SANDBOX=$MOZ_SANDBOX
6717     ;;
6718 Linux)
6719     case $CPU_ARCH in
6720     x86_64|x86)
6721         MOZ_GMP_SANDBOX=$MOZ_SANDBOX
6722         ;;
6723     esac
6724     ;;
6725 Darwin)
6726     MOZ_GMP_SANDBOX=$MOZ_SANDBOX
6727     ;;
6728 esac
6730 if test -n "$MOZ_GMP_SANDBOX"; then
6731     AC_DEFINE(MOZ_GMP_SANDBOX)
6734 AC_SUBST(MOZ_GMP_SANDBOX)
6736 if test -z "$MOZ_CONTENT_SANDBOX" -a -z "$MOZ_GMP_SANDBOX"; then
6737     MOZ_SANDBOX=
6740 if test -n "$MOZ_SANDBOX"; then
6741     AC_DEFINE(MOZ_SANDBOX)
6744 AC_SUBST(MOZ_SANDBOX)
6747 dnl ========================================================
6748 dnl =
6749 dnl = Module specific options
6750 dnl =
6751 dnl ========================================================
6752 MOZ_ARG_HEADER(Individual module options)
6754 dnl ========================================================
6755 dnl = Disable feed handling components
6756 dnl ========================================================
6757 MOZ_ARG_DISABLE_BOOL(feeds,
6758 [  --disable-feeds         Disable feed handling and processing components],
6759     MOZ_FEEDS=,
6760     MOZ_FEEDS=1 )
6761 if test -n "$MOZ_FEEDS"; then
6762     AC_DEFINE(MOZ_FEEDS)
6763 else
6764     if test "$MOZ_BUILD_APP" = "browser"; then
6765         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6766     fi
6769 dnl ========================================================
6770 dnl Check for sqlite
6771 dnl ========================================================
6773 MOZ_NATIVE_SQLITE=
6774 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6775 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6776 MOZ_NATIVE_SQLITE=1,
6777 MOZ_NATIVE_SQLITE= )
6779 if test -n "$MOZ_NATIVE_SQLITE"
6780 then
6781     dnl ============================
6782     dnl === SQLite Version check ===
6783     dnl ============================
6784     dnl Check to see if the system SQLite package is new enough.
6785     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6787     dnl ==================================
6788     dnl === SQLITE_SECURE_DELETE check ===
6789     dnl ==================================
6790     dnl Check to see if the system SQLite package is compiled with
6791     dnl SQLITE_SECURE_DELETE enabled.
6792     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
6793     _SAVE_CFLAGS="$CFLAGS"
6794     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6795     _SAVE_LIBS="$LIBS"
6796     LIBS="$LIBS $SQLITE_LIBS"
6797     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6798         AC_TRY_RUN([
6799             #include "sqlite3.h"
6801             int main(int argc, char **argv){
6802               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
6803             }],
6804             ac_cv_sqlite_secure_delete=yes,
6805             ac_cv_sqlite_secure_delete=no,
6806             ac_cv_sqlite_secure_delete=no
6807         )
6808     ])
6809     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6810     CFLAGS="$_SAVE_CFLAGS"
6811     LIBS="$_SAVE_LIBS"
6812     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6813         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
6814     fi
6816     dnl ===============================
6817     dnl === SQLITE_THREADSAFE check ===
6818     dnl ===============================
6819     dnl Check to see if the system SQLite package is compiled with
6820     dnl SQLITE_THREADSAFE enabled.
6821     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
6822     _SAVE_CFLAGS="$CFLAGS"
6823     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6824     _SAVE_LIBS="$LIBS"
6825     LIBS="$LIBS $SQLITE_LIBS"
6826     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
6827         AC_TRY_RUN([
6828             #include "sqlite3.h"
6830             int main(int argc, char **argv){
6831               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
6832             }],
6833             ac_cv_sqlite_threadsafe=yes,
6834             ac_cv_sqlite_threadsafe=no,
6835             ac_cv_sqlite_threadsafe=no
6836         )
6837     ])
6838     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
6839     CFLAGS="$_SAVE_CFLAGS"
6840     LIBS="$_SAVE_LIBS"
6841     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
6842         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
6843     fi
6845     dnl ================================
6846     dnl === SQLITE_ENABLE_FTS3 check ===
6847     dnl ================================
6848     dnl check to see if the system SQLite package is compiled with
6849     dnl SQLITE_ENABLE_FTS3 enabled.
6850     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
6851     _SAVE_CFLAGS="$CFLAGS"
6852     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6853     _SAVE_LIBS="$LIBS"
6854     LIBS="$LIBS $SQLITE_LIBS"
6855     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
6856         AC_TRY_RUN([
6857             #include "sqlite3.h"
6859             int main(int argc, char **argv){
6860               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
6861             }],
6862             ac_cv_sqlite_enable_fts3=yes,
6863             ac_cv_sqlite_enable_fts3=no,
6864             ac_cv_sqlite_enable_fts3=no
6865         )
6866     ])
6867     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
6868     CFLAGS="$_SAVE_CFLAGS"
6869     LIBS="$_SAVE_LIBS"
6870     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
6871         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
6872     fi
6874     dnl =========================================
6875     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
6876     dnl =========================================
6877     dnl check to see if the system SQLite package is compiled with
6878     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
6879     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
6880     _SAVE_CFLAGS="$CFLAGS"
6881     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6882     _SAVE_LIBS="$LIBS"
6883     LIBS="$LIBS $SQLITE_LIBS"
6884     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
6885         AC_TRY_RUN([
6886             #include "sqlite3.h"
6888             int main(int argc, char **argv){
6889               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
6890             }],
6891             ac_cv_sqlite_enable_unlock_notify=yes,
6892             ac_cv_sqlite_enable_unlock_notify=no,
6893             ac_cv_sqlite_enable_unlock_notify=no
6894         )
6895     ])
6896     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
6897     CFLAGS="$_SAVE_CFLAGS"
6898     LIBS="$_SAVE_LIBS"
6899     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
6900         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
6901     fi
6903     dnl =========================================
6904     dnl === SQLITE_ENABLE_DBSTAT_VTAB check ===
6905     dnl =========================================
6906     dnl check to see if the system SQLite package is compiled with
6907     dnl SQLITE_ENABLE_DBSTAT_VTAB.
6908     AC_MSG_CHECKING(for SQLITE_ENABLE_DBSTAT_VTAB support in system SQLite)
6909     _SAVE_CFLAGS="$CFLAGS"
6910     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6911     _SAVE_LIBS="$LIBS"
6912     LIBS="$LIBS $SQLITE_LIBS"
6913     AC_CACHE_VAL(ac_cv_sqlite_dbstat_vtab,[
6914         AC_TRY_RUN([
6915             #include "sqlite3.h"
6917             int main(int argc, char **argv){
6918               return !sqlite3_compileoption_used("SQLITE_ENABLE_DBSTAT_VTAB");
6919             }],
6920             ac_cv_sqlite_dbstat_vtab=yes,
6921             ac_cv_sqlite_dbstat_vtab=no,
6922             ac_cv_sqlite_dbstat_vtab=no
6923         )
6924     ])
6925     AC_MSG_RESULT($ac_cv_sqlite_dbstat_vtab)
6926     CFLAGS="$_SAVE_CFLAGS"
6927     LIBS="$_SAVE_LIBS"
6928     if test "x$ac_cv_sqlite_dbstat_vtab" = "xno"; then
6929         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_DBSTAT_VTAB.])
6930     fi
6933 if test -n "$MOZ_NATIVE_SQLITE"; then
6934     AC_DEFINE(MOZ_NATIVE_SQLITE)
6936 AC_SUBST(MOZ_NATIVE_SQLITE)
6938 dnl ========================================================
6939 dnl = Enable help viewer (off by default)
6940 dnl ========================================================
6941 if test -n "$MOZ_HELP_VIEWER"; then
6942      dnl Do this if defined in confvars.sh
6943      AC_DEFINE(MOZ_HELP_VIEWER)
6946 dnl ========================================================
6947 dnl = Enable safe browsing (anti-phishing)
6948 dnl ========================================================
6949 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6950 [  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation],
6951     MOZ_SAFE_BROWSING=1,
6952     MOZ_SAFE_BROWSING= )
6953 if test -n "$MOZ_SAFE_BROWSING"; then
6954     AC_DEFINE(MOZ_SAFE_BROWSING)
6956 AC_SUBST(MOZ_SAFE_BROWSING)
6958 dnl ========================================================
6959 dnl = Enable url-classifier
6960 dnl ========================================================
6961 dnl Implicitly enabled by default if building with safe-browsing
6962 if test -n "$MOZ_SAFE_BROWSING"; then
6963     MOZ_URL_CLASSIFIER=1
6965 MOZ_ARG_ENABLE_BOOL(url-classifier,
6966 [  --enable-url-classifier Enable url classifier module],
6967     MOZ_URL_CLASSIFIER=1,
6968     MOZ_URL_CLASSIFIER= )
6969 if test -n "$MOZ_URL_CLASSIFIER"; then
6970     AC_DEFINE(MOZ_URL_CLASSIFIER)
6972 AC_SUBST(MOZ_URL_CLASSIFIER)
6974 dnl ========================================================
6975 dnl = Disable zipwriter
6976 dnl ========================================================
6977 MOZ_ARG_DISABLE_BOOL(zipwriter,
6978 [  --disable-zipwriter     Disable zipwriter component],
6979     MOZ_ZIPWRITER=,
6980     MOZ_ZIPWRITER=1 )
6981 AC_SUBST(MOZ_ZIPWRITER)
6983 dnl ========================================================
6984 dnl GL provider
6985 dnl ========================================================
6986 MOZ_GL_PROVIDER=
6987 MOZ_ARG_WITH_STRING(gl-provider,
6988 [  --with-gl-provider=ID
6989                           Set GL provider backend type],
6990 [ val=`echo $withval`
6991     MOZ_GL_PROVIDER="$val"])
6993 if test -n "$MOZ_GL_PROVIDER"; then
6994 MOZ_GL_DEFAULT_PROVIDER=$MOZ_GL_PROVIDER
6995 AC_SUBST(MOZ_GL_PROVIDER)
6996 AC_DEFINE_UNQUOTED(MOZ_GL_PROVIDER, GLContextProvider$MOZ_GL_PROVIDER)
6998 AC_SUBST(MOZ_GL_DEFAULT_PROVIDER)
6999 AC_DEFINE_UNQUOTED(GL_PROVIDER_$MOZ_GL_DEFAULT_PROVIDER)
7001 dnl ========================================================
7002 dnl = faststripe theme
7003 dnl ========================================================
7004 MOZ_ARG_ENABLE_BOOL(faststripe,
7005 [  --enable-faststripe     Use faststripe theme],
7006     MOZ_THEME_FASTSTRIPE=1,
7007     MOZ_THEME_FASTSTRIPE= )
7008 AC_SUBST(MOZ_THEME_FASTSTRIPE)
7010 dnl ========================================================
7011 dnl =
7012 dnl = Feature options that require extra sources to be pulled
7013 dnl =
7014 dnl ========================================================
7015 dnl MOZ_ARG_HEADER(Features that require extra sources)
7017 dnl ========================================================
7018 dnl =
7019 dnl = Runtime debugging and Optimization Options
7020 dnl =
7021 dnl ========================================================
7022 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
7024 dnl ========================================================
7025 dnl enable mobile optimizations
7026 dnl ========================================================
7027 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
7028 [  --enable-mobile-optimize
7029                           Enable mobile optimizations],
7030     MOZ_GFX_OPTIMIZE_MOBILE=1)
7032 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
7034 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
7035     # We ignore paint will resample on mobile for performance.
7036     # We may want to revisit this later.
7037     MOZ_IGNORE_PAINT_WILL_RESAMPLE=1
7039     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
7040     AC_DEFINE(MOZ_IGNORE_PAINT_WILL_RESAMPLE)
7043 dnl ========================================================
7044 dnl = Enable code optimization. ON by default.
7045 dnl ========================================================
7046 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
7047     MOZ_OPTIMIZE_FLAGS="-O"
7050 if test -z "$MOZ_OPTIMIZE_RUSTFLAGS"; then
7051     MOZ_OPTIMIZE_RUSTFLAGS="-O"
7054 MOZ_ARG_ENABLE_STRING(optimize,
7055 [  --disable-optimize      Disable compiler optimization
7056   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
7057 [ if test "$enableval" != "no"; then
7058     MOZ_OPTIMIZE=1
7059     if test -n "$enableval" -a "$enableval" != "yes"; then
7060         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
7061         MOZ_OPTIMIZE=2
7062     fi
7063 else
7064     MOZ_OPTIMIZE=
7065 fi ], MOZ_OPTIMIZE=1)
7067 MOZ_SET_FRAMEPTR_FLAGS
7069 if test "$COMPILE_ENVIRONMENT"; then
7070 if test -n "$MOZ_OPTIMIZE"; then
7071     AC_MSG_CHECKING([for valid C compiler optimization flags])
7072     _SAVE_CFLAGS=$CFLAGS
7073     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
7074     AC_TRY_COMPILE([#include <stdio.h>],
7075         [printf("Hello World\n");],
7076         _results=yes,
7077         _results=no)
7078     AC_MSG_RESULT([$_results])
7079     if test "$_results" = "no"; then
7080         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
7081     fi
7082     CFLAGS=$_SAVE_CFLAGS
7084 fi # COMPILE_ENVIRONMENT
7086 AC_SUBST(MOZ_OPTIMIZE)
7087 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
7088 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
7089 AC_SUBST(MOZ_OPTIMIZE_RUSTFLAGS)
7090 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
7091 AC_SUBST(MOZ_ALLOW_HEAP_EXECUTE_FLAGS)
7092 AC_SUBST(MOZ_PGO)
7093 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
7095 dnl ========================================================
7096 dnl = Enable NS_StackWalk.
7097 dnl ========================================================
7099 # On Windows, NS_StackWalk will only work correctly if we have frame pointers
7100 # available. That will only be true for non-optimized builds, debug builds or
7101 # builds with --enable-profiling in the .mozconfig (which is turned on in
7102 # Nightly by default.)
7103 case "$OS_TARGET" in
7104 WINNT)
7105     if test -z "$MOZ_OPTIMIZE" -o -n "$MOZ_PROFILING" -o -n "$MOZ_DEBUG"; then
7106         MOZ_STACKWALKING=1
7107     else
7108         MOZ_STACKWALKING=
7109     fi
7110     ;;
7112     MOZ_STACKWALKING=1
7113     ;;
7114 esac
7116 if test -n "$MOZ_STACKWALKING"; then
7117     AC_DEFINE(MOZ_STACKWALKING)
7120 AC_SUBST(MOZ_STACKWALKING)
7122 dnl ========================================================
7123 dnl = Disable treating compiler warnings as errors
7124 dnl ========================================================
7125 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
7126    WARNINGS_AS_ERRORS=''
7127 elif test "$GNU_CC"; then
7128     # Prevent the following GCC warnings from being treated as errors:
7129     # -Wmaybe-uninitialized - too many false positives
7130     # -Wdeprecated-declarations - we don't want our builds held hostage when a
7131     #   platform-specific API becomes deprecated.
7132     # -Wfree-nonheap-object - false positives during PGO
7133     # -Warray-bounds - false positives depending on optimization
7134     MOZ_C_SUPPORTS_WARNING(-W, no-error=maybe-uninitialized, ac_c_has_noerror_maybe_uninitialized)
7135     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=maybe-uninitialized, ac_cxx_has_noerror_maybe_uninitialized)
7136     MOZ_C_SUPPORTS_WARNING(-W, no-error=deprecated-declarations, ac_c_has_noerror_deprecated_declarations)
7137     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=deprecated-declarations, ac_cxx_has_noerror_deprecated_declarations)
7138     MOZ_C_SUPPORTS_WARNING(-W, no-error=array-bounds, ac_c_has_noerror_array_bounds)
7139     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=array-bounds, ac_cxx_has_noerror_array_bounds)
7141     if test -n "$MOZ_PGO"; then
7142         MOZ_C_SUPPORTS_WARNING(-W, no-error=coverage-mismatch, ac_c_has_noerror_coverage_mismatch)
7143         MOZ_CXX_SUPPORTS_WARNING(-W, no-error=coverage-mismatch, ac_cxx_has_noerror_coverage_mismatch)
7144         MOZ_C_SUPPORTS_WARNING(-W, no-error=free-nonheap-object, ac_c_has_noerror_free_nonheap_object)
7145         MOZ_CXX_SUPPORTS_WARNING(-W, no-error=free-nonheap-object, ac_cxx_has_noerror_free_nonheap_object)
7146     fi
7149 dnl ========================================================
7150 dnl = Disable runtime logging checks
7151 dnl ========================================================
7152 MOZ_ARG_DISABLE_BOOL(logging,
7153 [  --disable-logging       Disable logging facilities],
7154     NS_DISABLE_LOGGING=1,
7155     NS_DISABLE_LOGGING= )
7156 if test "$NS_DISABLE_LOGGING"; then
7157     AC_DEFINE(NS_DISABLE_LOGGING)
7158 else
7159     AC_DEFINE(MOZ_LOGGING)
7160     AC_DEFINE(FORCE_PR_LOG)
7163 dnl ========================================================
7164 dnl = This will enable logging of addref, release, ctor, dtor.
7165 dnl ========================================================
7166 _ENABLE_LOGREFCNT=42
7167 MOZ_ARG_ENABLE_BOOL(logrefcnt,
7168 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
7169     _ENABLE_LOGREFCNT=1,
7170     _ENABLE_LOGREFCNT= )
7171 if test "$_ENABLE_LOGREFCNT" = "1"; then
7172     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
7173 elif test -z "$_ENABLE_LOGREFCNT"; then
7174     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
7177 dnl ========================================================
7178 dnl moz_aproximate_location
7179 dnl ========================================================
7180 MOZ_ARG_ENABLE_BOOL(approximate_location,
7181 [ --enable-approximate-location    Enable approximate location ],
7182     MOZ_APPROX_LOCATION=1,
7183     MOZ_APPROX_LOCATION= )
7184 if test -n "$MOZ_APPROX_LOCATION"; then
7185     AC_DEFINE(MOZ_APPROX_LOCATION)
7188 dnl ========================================================
7189 dnl moz_gps_debug
7190 dnl ========================================================
7191 MOZ_ARG_ENABLE_BOOL(gps_debug,
7192 [ --enable-gps-debug    Enable gps specific debug messages ],
7193     MOZ_GPS_DEBUG=1,
7194     MOZ_GPS_DEBUG= )
7195 if test -n "$MOZ_GPS_DEBUG"; then
7196     AC_DEFINE(MOZ_GPS_DEBUG)
7198 if test -n "$MOZ_DEBUG"; then
7199     AC_DEFINE(MOZ_GPS_DEBUG)
7202 dnl ========================================================
7203 dnl moz_dump_painting
7204 dnl ========================================================
7205 MOZ_ARG_ENABLE_BOOL(dump-painting,
7206 [  --enable-dump-painting          Enable paint debugging.],
7207     MOZ_DUMP_PAINTING=1,
7208     MOZ_DUMP_PAINTING= )
7209 if test -n "$MOZ_DUMP_PAINTING"; then
7210     AC_DEFINE(MOZ_DUMP_PAINTING)
7211     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
7213 if test -n "$MOZ_DEBUG"; then
7214     AC_DEFINE(MOZ_DUMP_PAINTING)
7217 dnl ========================================================
7218 dnl = Enable DMD
7219 dnl ========================================================
7221 MOZ_ARG_ENABLE_BOOL(dmd,
7222 [  --enable-dmd            Enable DMD; also enables jemalloc and replace-malloc],
7223     MOZ_DMD=1,
7224     MOZ_DMD= )
7226 if test "$MOZ_DMD"; then
7227     AC_DEFINE(MOZ_DMD)
7229     if test "${CPU_ARCH}" = "arm"; then
7230         CFLAGS="$CFLAGS -funwind-tables"
7231         CXXFLAGS="$CXXFLAGS -funwind-tables"
7232     fi
7234     MOZ_MEMORY=1                        # DMD enables jemalloc
7235     MOZ_REPLACE_MALLOC=1                # DMD enables replace-malloc
7237 AC_SUBST(MOZ_DMD)
7239 dnl ========================================================
7240 dnl = Enable jemalloc
7241 dnl ========================================================
7242 MOZ_ARG_ENABLE_BOOL(jemalloc,
7243 [  --enable-jemalloc       Replace memory allocator with jemalloc],
7244     MOZ_MEMORY=1,
7245     MOZ_MEMORY=)
7247 case "${OS_TARGET}" in
7248 Android|WINNT|Darwin)
7249   MOZ_GLUE_IN_PROGRAM=
7250   ;;
7252   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
7253   MOZ_GLUE_IN_PROGRAM=1
7254   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
7255   ;;
7256 esac
7258 dnl ========================================================
7259 dnl = Enable dynamic replacement of malloc implementation
7260 dnl ========================================================
7261 if test -n "$NIGHTLY_BUILD" -a -n "$MOZ_MEMORY"; then
7262   # Enable on central for the debugging opportunities it adds.
7263   MOZ_REPLACE_MALLOC=1
7265 MOZ_ARG_ENABLE_BOOL(replace-malloc,
7266 [  --enable-replace-malloc   Enable ability to dynamically replace the malloc implementation],
7267     MOZ_REPLACE_MALLOC=1,
7268     MOZ_REPLACE_MALLOC= )
7270 if test -n "$MOZ_REPLACE_MALLOC" -a -z "$MOZ_MEMORY"; then
7271     dnl We don't want to enable jemalloc unconditionally because it may be a
7272     dnl deliberate choice not to enable it (bug 702250, for instance)
7273     AC_MSG_ERROR([--enable-replace-malloc requires --enable-jemalloc])
7274 elif test -n "$MOZ_REPLACE_MALLOC"; then
7275     AC_DEFINE(MOZ_REPLACE_MALLOC)
7276     MOZ_NATIVE_JEMALLOC=
7278     dnl Replace-malloc Mac linkage quirks
7279     if test -n "$MACOSX_DEPLOYMENT_TARGET"; then
7280         AC_CACHE_CHECK([how to do weak dynamic linking],
7281             ac_cv_weak_dynamic_linking,
7282             [echo 'extern void foo() __attribute__((weak_import));int bar() { if (foo) foo(); return 0; }' > conftest.c
7283              if AC_TRY_COMMAND([${CC-cc} -o conftest${DLL_SUFFIX} $CFLAGS -dynamiclib $LDFLAGS -Wl,-U,_foo conftest.c $LIBS 1>&5]) &&
7284                 test -s conftest${DLL_SUFFIX}; then
7285                  dnl There are several ways the linker can put link edit rules in a binary:
7286                  dnl - classic info only (for OSX < 10.6)
7287                  dnl - dyld info only
7288                  dnl - both
7289                  if "$OTOOL" -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO_ONLY" > /dev/null; then
7290                      _CLASSIC_INFO=
7291                  else
7292                      _CLASSIC_INFO=1
7293                  fi
7294                  if "$OTOOL" -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO" > /dev/null; then
7295                      _DYLD_INFO=1
7296                  else
7297                      _DYLD_INFO=
7298                  fi
7299                  dnl With classic info, we need to build with -flat_namespace.
7300                  dnl With dyld info, Xcode 4.5 does the right thing without additional flags,
7301                  dnl but Xcode < 4.5 requires a dummy library and -flat_namespace because it
7302                  dnl forgets to set the weak flag in the dyld info.
7303                  dnl See http://glandium.org/blog/?p=2764 for more details.
7304                  dnl
7305                  dnl Values for ac_cv_weak_dynamic_linking, and subsequently
7306                  dnl MOZ_REPLACE_MALLOC_LINKAGE are thus:
7307                  dnl - "flat namespace" when -flat_namespace alone is needed
7308                  dnl - "dummy library" when a dummy library and -flat_namespace are needed
7309                  dnl - "compiler support" when nothing is needed
7310                  if test -n "$_DYLD_INFO" && dyldinfo -bind conftest${DLL_SUFFIX} 2> /dev/null | grep "_foo (weak import)" > /dev/null; then
7311                      if test -n "$_CLASSIC_INFO"; then
7312                          ac_cv_weak_dynamic_linking="flat namespace"
7313                      else
7314                          ac_cv_weak_dynamic_linking="compiler support"
7315                      fi
7316                  else
7317                      if test -n "$_DYLD_INFO"; then
7318                          ac_cv_weak_dynamic_linking="dummy library"
7319                      else
7320                          ac_cv_weak_dynamic_linking="flat namespace"
7321                      fi
7322                  fi
7323              else
7324                  AC_ERROR([couldn't compile a simple C file])
7325              fi
7326              rm -rf conftest*])
7327         MOZ_REPLACE_MALLOC_LINKAGE="$ac_cv_weak_dynamic_linking"
7328     fi
7330 AC_SUBST(MOZ_REPLACE_MALLOC)
7331 AC_SUBST(MOZ_REPLACE_MALLOC_LINKAGE)
7333 dnl ========================================================
7334 dnl = Jemalloc build setup
7335 dnl ========================================================
7336 if test -z "$MOZ_MEMORY"; then
7337   if test -n "$MOZ_JEMALLOC3" -a -z "$MOZ_REPLACE_MALLOC"; then
7338     MOZ_NATIVE_JEMALLOC=1
7339     AC_CHECK_FUNCS(mallctl nallocx,,
7340       [MOZ_NATIVE_JEMALLOC=
7341        break])
7342     if test -n "$MOZ_NATIVE_JEMALLOC"; then
7343       MOZ_MEMORY=1
7344       AC_DEFINE(MOZ_MEMORY)
7345       AC_DEFINE(MOZ_JEMALLOC3)
7346       AC_DEFINE(MOZ_NATIVE_JEMALLOC)
7347     fi
7348   fi
7349   case "${target}" in
7350     *-mingw*)
7351       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
7352         AC_MSG_WARN([When not building jemalloc, you need to set WIN32_REDIST_DIR to the path to the Visual C++ Redist (usually VCINSTALLDIR\redist\x86\Microsoft.VC80.CRT, for VC++ v8) if you intend to distribute your build.])
7353       fi
7354       ;;
7355   esac
7356 else
7357   AC_DEFINE(MOZ_MEMORY)
7358   if test -n "$MOZ_JEMALLOC3"; then
7359     AC_DEFINE(MOZ_JEMALLOC3)
7360   fi
7361   if test "x$MOZ_DEBUG" = "x1"; then
7362     AC_DEFINE(MOZ_MEMORY_DEBUG)
7363   fi
7364   dnl The generic feature tests that determine how to compute ncpus are long and
7365   dnl complicated.  Therefore, simply define special cpp variables for the
7366   dnl platforms we have special knowledge of.
7367   case "${target}" in
7368   *-darwin*)
7369     AC_DEFINE(MOZ_MEMORY_DARWIN)
7370     ;;
7371   *-*freebsd*)
7372     AC_DEFINE(MOZ_MEMORY_BSD)
7373     ;;
7374   *-android*|*-linuxandroid*)
7375     AC_DEFINE(MOZ_MEMORY_LINUX)
7376     AC_DEFINE(MOZ_MEMORY_ANDROID)
7377     if test -n "$gonkdir"; then
7378       AC_DEFINE(MOZ_MEMORY_GONK)
7379     fi
7380     ;;
7381   *-*linux*)
7382     AC_DEFINE(MOZ_MEMORY_LINUX)
7383     ;;
7384   *-netbsd*)
7385     AC_DEFINE(MOZ_MEMORY_BSD)
7386     ;;
7387   *-solaris*)
7388     AC_DEFINE(MOZ_MEMORY_SOLARIS)
7389     ;;
7390   *-mingw*)
7391     AC_DEFINE(MOZ_MEMORY_WINDOWS)
7392     export MOZ_NO_DEBUG_RTL=1
7393     WIN32_CRT_LIBS="msvcrt.lib msvcprt.lib"
7394     dnl Look for a broken crtdll.obj
7395     WIN32_CRTDLL_FULLPATH=`lib -nologo -list $WIN32_CRT_LIBS | grep crtdll\\.obj`
7396     lib -NOLOGO -OUT:crtdll.obj $WIN32_CRT_LIBS -EXTRACT:$WIN32_CRTDLL_FULLPATH
7397     if grep -q '__imp__\{0,1\}free' crtdll.obj; then
7398       MOZ_CRT=1
7399     fi
7400     rm crtdll.obj
7401     ;;
7402   *)
7403     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
7404     ;;
7405   esac
7406 fi # MOZ_MEMORY
7407 AC_SUBST(MOZ_MEMORY)
7408 AC_SUBST(MOZ_JEMALLOC3)
7409 AC_SUBST(MOZ_NATIVE_JEMALLOC)
7410 AC_SUBST(MOZ_CRT)
7411 export MOZ_CRT
7412 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
7413 AC_SUBST_LIST(WIN32_CRT_LIBS)
7415 # Allow the application to provide a subconfigure script.
7416 # This should be after 'export MOZ_NO_DEBUG_RTL=1' since
7417 # ldap/c-sdk/configure refers to the enviroment value.
7418 if test -f "${srcdir}/${MOZ_BUILD_APP}/configure.in" ; then
7419   do_output_subdirs() {
7420     if test -n "$_subconfigure_subdirs"; then
7421       AC_MSG_ERROR([Cannot specify more than one sub-sub-configure])
7422      fi
7423     _subconfigure_subdir="$1"
7424     _subconfigure_config_args="$ac_configure_args"
7425   }
7426   tmpscript=`$PYTHON -c 'import os, tempfile; print tempfile.mktemp(prefix="subscript.").replace(os.sep, "/")'` || exit 1
7427   m4 "${srcdir}/build/autoconf/subconfigure.m4" \
7428      "${srcdir}/build/autoconf/altoptions.m4" \
7429      "${srcdir}/${MOZ_BUILD_APP}/configure.in" > $tmpscript
7430   . $tmpscript
7431   rm -f $tmpscript
7434 dnl We need to wrap dlopen and related functions on Android because we use
7435 dnl our own linker.
7436 if test "$OS_TARGET" = Android; then
7437     MOZ_GLUE_WRAP_LDFLAGS="${MOZ_GLUE_WRAP_LDFLAGS} -Wl,--wrap=PR_GetEnv,--wrap=PR_SetEnv"
7438     if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_NUWA_PROCESS"; then
7439         MOZ_GLUE_WRAP_LDFLAGS="${MOZ_GLUE_WRAP_LDFLAGS} -Wl,--wrap=pthread_create,--wrap=epoll_wait,--wrap=poll,--wrap=pthread_cond_timedwait,--wrap=pthread_cond_wait,--wrap=epoll_create,--wrap=epoll_ctl,--wrap=close,--wrap=pthread_key_create,--wrap=pthread_key_delete,--wrap=socketpair,--wrap=pthread_self,--wrap=pthread_mutex_lock,--wrap=pthread_mutex_trylock,--wrap=pthread_join,--wrap=pipe,--wrap=pipe2"
7440     fi
7441     if test "$MOZ_WIDGET_TOOLKIT" = android -a "$MOZ_ANDROID_MIN_SDK_VERSION" -lt 11; then
7442         MOZ_GLUE_WRAP_LDFLAGS="${MOZ_GLUE_WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
7443     fi
7446 AC_SUBST_LIST(MOZ_GLUE_WRAP_LDFLAGS)
7447 export MOZ_GLUE_WRAP_LDFLAGS
7449 dnl ========================================================
7450 dnl = Enable static checking using gcc-dehydra
7451 dnl ========================================================
7453 MOZ_ARG_WITH_STRING(static-checking,
7454 [  --with-static-checking=path/to/gcc_dehydra.so
7455                           Enable static checking of code using GCC-dehydra],
7456     DEHYDRA_PATH=$withval,
7457     DEHYDRA_PATH= )
7459 if test -n "$DEHYDRA_PATH"; then
7460     if test ! -f "$DEHYDRA_PATH"; then
7461         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7462     fi
7463     AC_DEFINE(NS_STATIC_CHECKING)
7465 AC_SUBST(DEHYDRA_PATH)
7467 dnl ========================================================
7468 dnl = Enable using the clang plugin to build
7469 dnl ========================================================
7471 MOZ_CONFIG_CLANG_PLUGIN
7473 dnl ========================================================
7474 dnl = Enable stripping of libs & executables
7475 dnl ========================================================
7476 MOZ_ARG_ENABLE_BOOL(strip,
7477 [  --enable-strip          Enable stripping of libs & executables ],
7478     ENABLE_STRIP=1,
7479     ENABLE_STRIP= )
7481 dnl ========================================================
7482 dnl = Enable stripping of libs & executables when packaging
7483 dnl ========================================================
7484 MOZ_ARG_ENABLE_BOOL(install-strip,
7485 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7486     PKG_SKIP_STRIP= ,
7487     PKG_SKIP_STRIP=1)
7489 dnl ========================================================
7490 dnl = --disable-elf-hack
7491 dnl ========================================================
7493 USE_ELF_HACK=1
7494 MOZ_ARG_DISABLE_BOOL(elf-hack,
7495 [  --disable-elf-hack      Disable elf hacks],
7496     [USE_ELF_HACK=],
7497     [USE_ELF_HACK=1])
7499 # Only enable elfhack where supported
7500 if test "$USE_ELF_HACK" = 1; then
7501     case "${HOST_OS_ARCH},${OS_ARCH}" in
7502     Linux,Linux)
7503         case "${CPU_ARCH}" in
7504         arm | x86 | x86_64)
7505             USE_ELF_HACK=1
7506             ;;
7507         *)
7508             USE_ELF_HACK=
7509             ;;
7510         esac
7511         ;;
7512     *)
7513         USE_ELF_HACK=
7514         ;;
7515     esac
7518 if test -n "$COMPILE_ENVIRONMENT" -a -n "$USE_ELF_HACK"; then
7519     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
7520     dnl memory addresses it maps to. The result is that by the time elfhack
7521     dnl kicks in, it is not possible to apply relocations because of that,
7522     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
7523     dnl segment. It makes elfhack mostly useless, so considering the problems
7524     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
7525     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
7526     dnl the linker creates PT_GNU_RELRO segments. However, when we do want
7527     dnl elfhack enabled, disable PT_GNU_RELRO instead.
7528     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
7529         LINK_WITH_PT_GNU_RELRO,
7530         [echo "int main() {return 0;}" > conftest.${ac_ext}
7531          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
7532             test -s conftest${ac_exeext}; then
7533             if ${TOOLCHAIN_PREFIX}readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
7534                 LINK_WITH_PT_GNU_RELRO=yes
7535             else
7536                 LINK_WITH_PT_GNU_RELRO=no
7537             fi
7538          else
7539              dnl We really don't expect to get here, but just in case
7540              AC_ERROR([couldn't compile a simple C file])
7541          fi
7542          rm -rf conftest*])
7543     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
7544         if test "$USE_ELF_HACK" = F; then
7545             AC_MSG_CHECKING([for -z norelro option to ld])
7546             _SAVE_LDFLAGS=$LDFLAGS
7547             LDFLAGS="$LDFLAGS -Wl,-z,norelro"
7548             AC_TRY_LINK(,,AC_MSG_RESULT([yes])
7549                         [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,norelro"],
7550                         AC_ERROR([--enable-elf-hack is not compatible with a linker creating a PT_GNU_RELRO segment and that doesn't support the "-z norelro" option.]))
7551             USE_ELF_HACK=1
7552         else
7553             AC_MSG_WARN([Disabling elfhack])
7554             USE_ELF_HACK=
7555         fi
7556     fi
7557 fi # COMPILE_ENVIRONMENT and others.
7559 dnl ========================================================
7560 dnl = libstdc++ compatibility hacks
7561 dnl ========================================================
7563 STDCXX_COMPAT=
7564 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
7565 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
7566     STDCXX_COMPAT=1)
7568 if test -n "$STDCXX_COMPAT"; then
7569    eval $(CXX="$CXX" HOST_CXX="$HOST_CXX" $PYTHON -m mozbuild.configure.libstdcxx)
7570    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
7571    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
7572    CXXFLAGS="$CXXFLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
7573    HOST_CXXFLAGS="$HOST_CXXFLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
7576 dnl ========================================================
7577 dnl =
7578 dnl = Profiling and Instrumenting
7579 dnl =
7580 dnl ========================================================
7581 MOZ_ARG_HEADER(Profiling and Instrumenting)
7583 dnl ========================================================
7584 dnl = Enable TaskTracer
7585 dnl ========================================================
7586 MOZ_ARG_ENABLE_BOOL(tasktracer,
7587 [  --enable-tasktracer       Set compile flags necessary for using TaskTracer],
7588     MOZ_TASK_TRACER=1,
7589     MOZ_TASK_TRACER= )
7590 if test "$MOZ_WIDGET_TOOLKIT" = "gonk" -a -n "$MOZ_TASK_TRACER"; then
7591     AC_DEFINE(MOZ_TASK_TRACER)
7592     AC_SUBST(MOZ_TASK_TRACER)
7595 dnl ========================================================
7596 dnl Turn on reflow counting
7597 dnl ========================================================
7598 MOZ_ARG_ENABLE_BOOL(reflow-perf,
7599 [  --enable-reflow-perf    Enable reflow performance tracing],
7600     MOZ_REFLOW_PERF=1,
7601     MOZ_REFLOW_PERF= )
7602 if test -n "$MOZ_REFLOW_PERF"; then
7603     AC_DEFINE(MOZ_REFLOW_PERF)
7606 dnl ========================================================
7607 dnl = Offer a way to disable the startup cache
7608 dnl ========================================================
7610 MOZ_ARG_DISABLE_BOOL(startupcache,
7611 [  --disable-startupcache          Disable startup cache ],
7612     MOZ_DISABLE_STARTUPCACHE=1,
7613     MOZ_DISABLE_STARTUPCACHE=)
7615 dnl bug 988880: disable startup cache on b2g
7616 if test -n "$MOZ_B2G"; then
7617   MOZ_DISABLE_STARTUPCACHE=1
7619 if test -n "$MOZ_DISABLE_STARTUPCACHE"; then
7620   AC_DEFINE(MOZ_DISABLE_STARTUPCACHE)
7622 AC_SUBST(MOZ_DISABLE_STARTUPCACHE)
7624 dnl ========================================================
7625 dnl = Enable packaging Gaia with B2G desktop
7626 dnl ========================================================
7627 if test x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
7628     if test -n "$GAIADIR" -a ! -d "$GAIADIR" ; then
7629         AC_MSG_ERROR([GAIADIR '$GAIADIR' isn't a valid directory])
7630     fi
7632     AC_SUBST(GAIADIR)
7633     if test -n "$GAIADIR" ; then
7634         AC_DEFINE(PACKAGE_GAIA)
7635     fi
7637     if test -n "$FXOS_SIMULATOR" -a -z "$GAIADIR" ; then
7638         AC_MSG_ERROR([FXOS_SIMULATOR=1 requires GAIADIR to be defined])
7639     fi
7641     if test -n "$FXOS_SIMULATOR" ; then
7642         AC_DEFINE(FXOS_SIMULATOR)
7643         AC_SUBST(FXOS_SIMULATOR)
7644     fi
7647 dnl ========================================================
7648 dnl = Enable Radio Interface for B2G (Gonk usually)
7649 dnl ========================================================
7650 MOZ_ARG_ENABLE_BOOL(b2g-ril,
7651 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
7652     MOZ_B2G_RIL=1,
7653     MOZ_B2G_RIL=,
7654     MOZ_B2G_RIL=$_PLATFORM_HAVE_RIL )
7655 if test -n "$MOZ_B2G_RIL"; then
7656     if test -n "$_PLATFORM_HAVE_RIL"; then
7657         AC_DEFINE(MOZ_B2G_RIL)
7658     else
7659         AC_MSG_ERROR([b2g-ril cannot be enabled because target platform doesn't support it.])
7660     fi
7662 AC_SUBST(MOZ_B2G_RIL)
7664 dnl ========================================================
7665 dnl = Enable Radio FM for B2G (Gonk usually)
7666 dnl ========================================================
7667 if test -n "$MOZ_B2G_FM"; then
7668     AC_DEFINE(MOZ_B2G_FM)
7670 AC_SUBST(MOZ_B2G_FM)
7672 dnl ========================================================
7673 dnl = Enable Bluetooth Interface for B2G (Gonk usually)
7674 dnl ========================================================
7675 MOZ_ARG_ENABLE_BOOL(b2g-bt,
7676 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
7677     MOZ_B2G_BT=1,
7678     MOZ_B2G_BT= )
7679 if test -n "$MOZ_B2G_BT"; then
7680     AC_DEFINE(MOZ_B2G_BT)
7682 AC_SUBST(MOZ_B2G_BT)
7683 AC_SUBST(MOZ_B2G_BT_BLUEZ)
7684 AC_SUBST(MOZ_B2G_BT_BLUEDROID)
7685 AC_SUBST(MOZ_B2G_BT_DAEMON)
7687 dnl ========================================================
7688 dnl = Enable NFC Interface for B2G (Gonk usually)
7689 dnl ========================================================
7690 MOZ_ARG_ENABLE_BOOL(nfc,
7691 [  --enable-nfc         Set compile flags necessary for compiling NFC API ],
7692     MOZ_NFC=1,
7693     MOZ_NFC= )
7694 if test -n "$MOZ_NFC"; then
7695    AC_DEFINE(MOZ_NFC)
7697 AC_SUBST(MOZ_NFC)
7699 dnl ========================================================
7700 dnl = Enable Pico Speech Synthesis (Gonk usually)
7701 dnl ========================================================
7702 MOZ_ARG_ENABLE_BOOL(synth-pico,
7703 [  --enable-synth-pico  Set compile flags necessary for compiling Pico Web Speech API ],
7704     MOZ_SYNTH_PICO=1,
7705     MOZ_SYNTH_PICO= )
7706 if test -n "$MOZ_SYNTH_PICO"; then
7707     AC_DEFINE(MOZ_SYNTH_PICO)
7709 AC_SUBST(MOZ_SYNTH_PICO)
7711 dnl ========================================================
7712 dnl = Enable Support for Time Manager API
7713 dnl ========================================================
7714 if test -n "$MOZ_TIME_MANAGER"; then
7715     AC_DEFINE(MOZ_TIME_MANAGER)
7717 AC_SUBST(MOZ_TIME_MANAGER)
7719 dnl ========================================================
7720 dnl = Enable Camera Interface for B2G (Gonk usually)
7721 dnl ========================================================
7722 MOZ_ARG_ENABLE_BOOL(b2g-camera,
7723 [  --enable-b2g-camera      Set compile flags necessary for compiling camera API for B2G ],
7724     MOZ_B2G_CAMERA=1,
7725     MOZ_B2G_CAMERA= )
7726 if test -n "$MOZ_B2G_CAMERA"; then
7727    AC_DEFINE(MOZ_B2G_CAMERA)
7729 AC_SUBST(MOZ_B2G_CAMERA)
7731 dnl ========================================================
7732 dnl = Enable Support for SimplePush (Gonk usually)
7733 dnl   This will disable the Push API.
7734 dnl ========================================================
7735 if test -n "$MOZ_SIMPLEPUSH"; then
7736     AC_DEFINE(MOZ_SIMPLEPUSH)
7738 AC_SUBST(MOZ_SIMPLEPUSH)
7740 dnl ========================================================
7741 dnl = Enable Support for Payment API
7742 dnl ========================================================
7743 if test -n "$MOZ_PAY"; then
7744     AC_DEFINE(MOZ_PAY)
7746 AC_SUBST(MOZ_PAY)
7748 dnl ========================================================
7749 dnl = Enable Browser Support for Activities
7750 dnl ========================================================
7751 if test -n "$MOZ_ACTIVITIES"; then
7752     AC_DEFINE(MOZ_ACTIVITIES)
7754 AC_SUBST(MOZ_ACTIVITIES)
7756 dnl ========================================================
7757 dnl = Enable Support for AudioChannelManager API
7758 dnl ========================================================
7759 if test -n "$MOZ_AUDIO_CHANNEL_MANAGER"; then
7760     AC_DEFINE(MOZ_AUDIO_CHANNEL_MANAGER)
7762 AC_SUBST(MOZ_AUDIO_CHANNEL_MANAGER)
7764 dnl ========================================================
7765 dnl = Enable Support for Secure Element API
7766 dnl ========================================================
7767    MOZ_SECUREELEMENT=1,
7768 if test -n "$MOZ_SECUREELEMENT"; then
7769    AC_DEFINE(MOZ_SECUREELEMENT)
7771  AC_SUBST(MOZ_SECUREELEMENT)
7773 dnl ========================================================
7774 dnl = Support for demangling undefined symbols
7775 dnl ========================================================
7776 if test -z "$SKIP_LIBRARY_CHECKS"; then
7777     AC_LANG_SAVE
7778     AC_LANG_CPLUSPLUS
7779     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7780     AC_LANG_RESTORE
7783 # Demangle only for debug or DMD builds
7784 MOZ_DEMANGLE_SYMBOLS=
7785 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
7786     MOZ_DEMANGLE_SYMBOLS=1
7787     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7789 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7791 dnl ========================================================
7792 dnl = Support for gcc stack unwinding (from gcc 3.3)
7793 dnl ========================================================
7794 if test -z "$SKIP_LIBRARY_CHECKS"; then
7795     AC_LANG_SAVE
7796     AC_LANG_CPLUSPLUS
7797     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7798     AC_LANG_RESTORE
7801 dnl ========================================================
7802 dnl JIT observers
7803 dnl ========================================================
7805 MOZ_ARG_WITH_STRING(jitreport-granularity,
7806 [  --jitreport-granularity=N
7807                            Default granularity at which to report JIT code
7808                            to external tools
7809                              0 - no info
7810                              1 - code ranges for whole functions only
7811                              2 - per-line information
7812                              3 - per-op information],
7813   JITREPORT_GRANULARITY=$withval,
7814   JITREPORT_GRANULARITY=3)
7816 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
7818 dnl ========================================================
7819 dnl = Disable Mozilla's versions of RIL and Geolocation
7820 dnl ========================================================
7821 MOZ_ARG_DISABLE_BOOL(mozril-geoloc,
7822 [  --disable-mozril-geoloc         Disable Mozilla's RIL and geolocation],
7823     DISABLE_MOZ_RIL_GEOLOC=1,
7824     DISABLE_MOZ_RIL_GEOLOC= )
7825 if test -n "$DISABLE_MOZ_RIL_GEOLOC"; then
7826    AC_DEFINE(DISABLE_MOZ_RIL_GEOLOC)
7828 AC_SUBST(DISABLE_MOZ_RIL_GEOLOC)
7830 dnl ========================================================
7831 dnl =
7832 dnl = Misc. Options
7833 dnl =
7834 dnl ========================================================
7835 MOZ_ARG_HEADER(Misc. Options)
7837 dnl ========================================================
7838 dnl update xterm title
7839 dnl ========================================================
7840 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7841 [  --enable-xterm-updates  Update XTERM titles with current command.],
7842     MOZ_UPDATE_XTERM=1,
7843     MOZ_UPDATE_XTERM= )
7845 dnl =========================================================
7846 dnl = Chrome format
7847 dnl =========================================================
7848 MOZ_ARG_ENABLE_STRING([chrome-format],
7849 [  --enable-chrome-format=jar|flat|omni
7850                           Select FORMAT of chrome files during packaging],
7851     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7853 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7854     MOZ_CHROME_FILE_FORMAT=jar
7857 if test "$MOZ_CHROME_FILE_FORMAT" = "symlink"; then
7858     AC_MSG_ERROR([--enable-chrome-format=symlink has been deprecated. It is now used by default in $DIST/bin on platforms that support it])
7861 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
7862     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7863     test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
7864     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, or omni])
7867 dnl =========================================================
7868 dnl Omnijar packaging (bug 552121)
7869 dnl =========================================================
7870 dnl Omnijar packaging is compatible with flat packaging.
7871 dnl In unpackaged builds, omnijar looks for files as if
7872 dnl things were flat packaged. After packaging, all files
7873 dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
7874 dnl is set to flat since putting files into jars is only
7875 dnl done during packaging with omnijar.
7876 if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
7877     MOZ_OMNIJAR=1
7878     AC_DEFINE(MOZ_OMNIJAR)
7880 MOZ_PACKAGER_FORMAT="$MOZ_CHROME_FILE_FORMAT"
7881 if test "$OS_ARCH" = "WINNT" -o "$MOZ_WIDGET_TOOLKIT" = "android"; then
7882     MOZ_CHROME_FILE_FORMAT=flat
7883 else
7884     MOZ_CHROME_FILE_FORMAT=symlink
7887 if test "$MOZ_WIDGET_TOOLKIT" = "android"; then
7888     dnl Fennec's static resources live in the assets/ folder of the
7889     dnl APK.  Adding a path to the name here works because we only
7890     dnl have one omnijar file in the final package (which is not the
7891     dnl case on desktop), and necessitates some contortions during
7892     dnl packaging so that the resources in the omnijar are considered
7893     dnl as rooted at / and not as rooted at assets/ (which again is
7894     dnl not the case on desktop: there are omnijars rooted at webrtc/,
7895     dnl etc). packager.mk handles changing the rooting of the single
7896     dnl omnijar.
7897     OMNIJAR_NAME=assets/omni.ja
7898 else
7899     OMNIJAR_NAME=omni.ja
7902 AC_SUBST(OMNIJAR_NAME)
7903 AC_SUBST(MOZ_OMNIJAR)
7904 AC_SUBST(MOZ_PACKAGER_FORMAT)
7906 dnl ========================================================
7907 dnl = Define default location for MOZILLA_FIVE_HOME
7908 dnl ========================================================
7909 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7910 [  --with-default-mozilla-five-home
7911                           Set the default value for MOZILLA_FIVE_HOME],
7912 [ val=`echo $withval`
7913   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7915 dnl ========================================================
7916 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7917 dnl ========================================================
7918 MOZ_ARG_WITH_STRING(user-appdir,
7919 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7920 [ val=`echo $withval`
7921 if echo "$val" | grep "\/" >/dev/null; then
7922     AC_MSG_ERROR("Homedir must be single relative path.")
7923 else
7924     MOZ_USER_DIR="$val"
7925 fi])
7927 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7929 dnl ========================================================
7930 dnl = Doxygen configuration
7931 dnl ========================================================
7932 dnl Use commas to specify multiple dirs to this arg
7933 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7934 MOZ_ARG_WITH_STRING(doc-input-dirs,
7935 [  --with-doc-input-dirs=DIRS
7936                           Header/idl dirs to create docs from],
7937 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7938 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7940 dnl Use commas to specify multiple dirs to this arg
7941 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7942 MOZ_ARG_WITH_STRING(doc-include-dirs,
7943 [  --with-doc-include-dirs=DIRS
7944                           Include dirs to preprocess doc headers],
7945 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7946 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7948 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7949 MOZ_ARG_WITH_STRING(doc-output-dir,
7950 [  --with-doc-output-dir=DIR
7951                           Dir to generate docs into],
7952 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7953 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7955 if test -z "$SKIP_COMPILER_CHECKS"; then
7956 dnl ========================================================
7957 dnl =
7958 dnl = Compiler Options
7959 dnl =
7960 dnl ========================================================
7961 MOZ_ARG_HEADER(Compiler Options)
7963 dnl ========================================================
7964 dnl Check for gcc -pipe support
7965 dnl ========================================================
7966 AC_MSG_CHECKING([for -pipe support])
7967 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
7968     dnl Any gcc that supports firefox supports -pipe.
7969     CFLAGS="$CFLAGS -pipe"
7970     CXXFLAGS="$CXXFLAGS -pipe"
7971     AC_MSG_RESULT([yes])
7972 else
7973     AC_MSG_RESULT([no])
7976 dnl ========================================================
7977 dnl Profile guided optimization (gcc checks)
7978 dnl ========================================================
7979 dnl Test for profiling options
7980 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7982 _SAVE_CFLAGS="$CFLAGS"
7983 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
7985 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7986 AC_TRY_COMPILE([], [return 0;],
7987                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7988                  result="yes" ], result="no")
7989 AC_MSG_RESULT([$result])
7991 if test $result = "yes"; then
7992   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7993   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
7994   PROFILE_USE_LDFLAGS="-fprofile-use"
7997 CFLAGS="$_SAVE_CFLAGS"
7999 if test -n "$INTEL_CC"; then
8000   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
8001   PROFILE_GEN_LDFLAGS=
8002   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
8003   PROFILE_USE_LDFLAGS=
8006 dnl Sun Studio on Solaris
8007 if test "$SOLARIS_SUNPRO_CC"; then
8008   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
8009   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
8010   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
8011   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
8014 AC_SUBST(PROFILE_GEN_CFLAGS)
8015 AC_SUBST(PROFILE_GEN_LDFLAGS)
8016 AC_SUBST(PROFILE_USE_CFLAGS)
8017 AC_SUBST(PROFILE_USE_LDFLAGS)
8019 dnl =============================================
8020 dnl Support for -fno-integrated-as (recent clang)
8021 dnl =============================================
8022 dnl Under clang 3.4+, use -fno-integrated-as to
8023 dnl build libvpx's vp8_asm_enc_offsets.c
8025 _SAVE_CFLAGS="$CFLAGS"
8026 CFLAGS="$CFLAGS -fno-integrated-as -S"
8028 AC_MSG_CHECKING([whether C compiler supports -fno-integrated-as])
8029 AC_TRY_COMPILE([], [return 0;],
8030                [ NO_INTEGRATED_AS_CFLAGS="-fno-integrated-as"
8031                  result="yes" ], result="no")
8032 AC_MSG_RESULT([$result])
8034 CFLAGS="$_SAVE_CFLAGS"
8036 AC_SUBST(NO_INTEGRATED_AS_CFLAGS)
8038 fi # ! SKIP_COMPILER_CHECKS
8040 AC_DEFINE(CPP_THROW_NEW, [throw()])
8041 AC_LANG_C
8043 if test "$COMPILE_ENVIRONMENT"; then
8044 MOZ_EXPAND_LIBS
8045 fi # COMPILE_ENVIRONMENT
8047 dnl ========================================================
8048 dnl =
8049 dnl = Build depencency options
8050 dnl =
8051 dnl ========================================================
8052 MOZ_ARG_HEADER(Build dependencies)
8054 if test "$GNU_CC" -a "$GNU_CXX"; then
8055   _DEPEND_CFLAGS='-MD -MP -MF $(MDDEPDIR)/$(@F).pp'
8056 dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
8057 elif test "$SOLARIS_SUNPRO_CC"; then
8058   _DEPEND_CFLAGS=
8059 else
8060   dnl Don't override this for MSVC
8061   if test -z "$_WIN32_MSVC"; then
8062     _USE_CPP_INCLUDE_FLAG=
8063     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
8064     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
8065   else
8066     echo '#include <stdio.h>' > dummy-hello.c
8067     changequote(,)
8068     dnl This output is localized, split at the first double space or colon and space.
8069     _CL_PREFIX_REGEX="^\([^:]*:.*[ :] \)\(.*\\\stdio.h\)$"
8070     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\1/p'`
8071     _CL_STDIO_PATH=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\2/p'`
8072     changequote([,])
8073     if ! test -e "$_CL_STDIO_PATH"; then
8074         AC_MSG_ERROR([Unable to parse cl -showIncludes prefix. This compiler's locale has an unsupported formatting.])
8075     fi
8076     if test -z "$CL_INCLUDES_PREFIX"; then
8077         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
8078     fi
8079     AC_SUBST(CL_INCLUDES_PREFIX)
8080     rm -f dummy-hello.c
8082     dnl Make sure that the build system can handle non-ASCII characters
8083     dnl in environment variables to prevent it from breaking silently on
8084     dnl non-English systems.
8085     NONASCII=$'\241\241'
8086     AC_SUBST(NONASCII)
8087   fi
8090 dnl ========================================================
8091 dnl =
8092 dnl = Static Build Options
8093 dnl =
8094 dnl ========================================================
8095 MOZ_ARG_HEADER(Static build options)
8097 if test -n "$GKMEDIAS_SHARED_LIBRARY"; then
8098   AC_DEFINE(GKMEDIAS_SHARED_LIBRARY)
8100 AC_SUBST(GKMEDIAS_SHARED_LIBRARY)
8102 if test -z "$MOZ_NATIVE_ZLIB"; then
8103 if test -n "$JS_SHARED_LIBRARY" -o "$GKMEDIAS_SHARED_LIBRARY"; then
8104   ZLIB_IN_MOZGLUE=1
8105   AC_DEFINE(ZLIB_IN_MOZGLUE)
8109 AC_SUBST(ZLIB_IN_MOZGLUE)
8111 dnl ========================================================
8112 dnl =
8113 dnl = Standalone module options
8114 dnl =
8115 dnl ========================================================
8116 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
8118 dnl Check for GLib.
8119 dnl ========================================================
8121 if test -z "$SKIP_PATH_CHECKS"; then
8122 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
8123     if test "$MOZ_ENABLE_GTK" ; then
8124         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
8125     fi
8129 if test -z "${GLIB_GMODULE_LIBS}" \
8130    -a -n "${GLIB_CONFIG}"\
8131     -a "${GLIB_CONFIG}" != no\
8132 ; then
8133     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
8136 AC_SUBST_LIST(GLIB_GMODULE_LIBS)
8138 dnl ========================================================
8139 dnl Graphics checks.
8140 dnl ========================================================
8142 if test "${OS_TARGET}" = "WINNT" -o \
8143         "${OS_ARCH}" = "Darwin" -o \
8144         "${MOZ_WIDGET_TOOLKIT}" = "android" -o \
8145         "${MOZ_WIDGET_TOOLKIT}" = "gonk" -o \
8146         "${MOZ_WIDGET_TOOLKIT}" = "gtk2" -o \
8147         "${MOZ_WIDGET_TOOLKIT}" = "gtk3"; then
8148     case "${CPU_ARCH}" in
8149     x86|x86_64|arm)
8150         MOZ_ENABLE_SKIA=1
8151         ;;
8152     *)
8153         MOZ_ENABLE_SKIA=
8154         ;;
8155     esac
8156 else
8157 MOZ_ENABLE_SKIA=
8160 MOZ_ARG_ENABLE_BOOL(skia,
8161 [  --enable-skia   Enable use of Skia],
8162 MOZ_ENABLE_SKIA=1,
8163 MOZ_ENABLE_SKIA=)
8165 MOZ_ARG_DISABLE_BOOL(skia-gpu,
8166 [  --disable-skia-gpu  Disable use of Skia-GPU],
8167 MOZ_DISABLE_SKIA_GPU=1,
8168 MOZ_DISABLE_SKIA_GPU=)
8170 if test "$USE_FC_FREETYPE"; then
8171     if test "$COMPILE_ENVIRONMENT"; then
8172         dnl ========================================================
8173         dnl = Check for freetype2 and its functionality
8174         dnl ========================================================
8175         PKG_CHECK_MODULES(FT2, freetype2 >= 6.1.0, _HAVE_FREETYPE2=1, _HAVE_FREETYPE2=)
8177         if test "$_HAVE_FREETYPE2"; then
8178             _SAVE_LIBS="$LIBS"
8179             _SAVE_CFLAGS="$CFLAGS"
8180             LIBS="$LIBS $FT2_LIBS"
8181             CFLAGS="$CFLAGS $FT2_CFLAGS"
8183             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
8184                 ac_cv_member_FT_Bitmap_Size_y_ppem,
8185                 [AC_TRY_COMPILE([#include <ft2build.h>
8186                                  #include FT_FREETYPE_H],
8187                                 [FT_Bitmap_Size s;
8188                                  if (sizeof s.y_ppem) return 0;
8189                                  return 1],
8190                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
8191                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
8192             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
8193                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
8194             else
8195                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
8196             fi
8197             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
8198                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
8199                                [FT_Bitmap_Size structure includes y_ppem field])
8201             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table)
8203             LIBS="$_SAVE_LIBS"
8204             CFLAGS="$_SAVE_CFLAGS"
8205         fi
8207         _SAVE_CPPFLAGS="$CPPFLAGS"
8208         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
8209         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
8210             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
8211         CPPFLAGS="$_SAVE_CPPFLAGS"
8212     else
8213         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
8214     fi
8216     PKG_CHECK_MODULES(_FONTCONFIG, fontconfig,
8217     [
8218         if test "$MOZ_PANGO"; then
8219             MOZ_PANGO_CFLAGS="$MOZ_PANGO_CFLAGS $_FONTCONFIG_CFLAGS"
8220             MOZ_PANGO_LIBS="$MOZ_PANGO_LIBS $_FONTCONFIG_LIBS"
8221         else
8222             FT2_CFLAGS="$FT2_CFLAGS $_FONTCONFIG_CFLAGS"
8223             FT2_LIBS="$FT2_LIBS $_FONTCONFIG_LIBS"
8224         fi
8225     ])
8228 dnl ========================================================
8229 dnl Check for pixman and cairo
8230 dnl ========================================================
8232 MOZ_TREE_CAIRO=1
8233 MOZ_ARG_ENABLE_BOOL(system-cairo,
8234 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
8235 MOZ_TREE_CAIRO=,
8236 MOZ_TREE_CAIRO=1 )
8238 MOZ_TREE_PIXMAN=1
8239 MOZ_ARG_ENABLE_BOOL(system-pixman,
8240 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
8241 MOZ_TREE_PIXMAN=,
8242 MOZ_TREE_PIXMAN=force,
8243 MOZ_TREE_PIXMAN=1 )
8245 # System cairo depends on system pixman
8246 if test "$MOZ_TREE_PIXMAN" = "force"; then
8247     if test -z "$MOZ_TREE_CAIRO"; then
8248         AC_MSG_ERROR([--disable-system-pixman is incompatible with --enable-system-cairo.])
8249     else
8250         MOZ_TREE_PIXMAN=1
8251     fi
8252 elif test -z "$MOZ_TREE_CAIRO"; then
8253     MOZ_TREE_PIXMAN=
8256 if test "$MOZ_TREE_PIXMAN"; then
8257     AC_DEFINE(MOZ_TREE_PIXMAN)
8258 else
8259     PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.19.2)
8260     MOZ_PIXMAN_CFLAGS="$PIXMAN_CFLAGS"
8261     MOZ_PIXMAN_LIBS="$PIXMAN_LIBS"
8263 AC_SUBST(MOZ_PIXMAN_CFLAGS)
8264 AC_SUBST_LIST(MOZ_PIXMAN_LIBS)
8266 # Check for headers defining standard int types.
8267 if test -n "$COMPILE_ENVIRONMENT"; then
8268     MOZ_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
8270     if test "${ac_cv_header_inttypes_h}" = "yes"; then
8271         HAVE_INTTYPES_H=1
8272     fi
8275 AC_SUBST(HAVE_INTTYPES_H)
8277 if test "$MOZ_TREE_CAIRO"; then
8278     MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
8279     AC_DEFINE(MOZ_TREE_CAIRO)
8281     if test "$OS_ARCH" = "WINNT"; then
8282         # For now we assume that we will have a uint64_t available through
8283         # one of the above headers or mozstdint.h.
8284         AC_DEFINE(HAVE_UINT64_T)
8285     fi
8287     # Define macros for cairo-features.h
8288     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
8289     if test "$MOZ_X11"; then
8290         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
8291         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
8292         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
8293     fi
8294     if test "$_HAVE_FREETYPE2"; then
8295         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8296         MOZ_ENABLE_CAIRO_FT=1
8297         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
8298     fi
8300     case "$MOZ_WIDGET_TOOLKIT" in
8301       qt)
8302         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
8303         ;;
8304       cocoa | uikit)
8305         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
8306         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
8307         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
8308         ;;
8309       windows)
8310         WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
8311         WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
8312         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
8313         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
8314         MOZ_ENABLE_D2D_SURFACE=1
8315         MOZ_ENABLE_DWRITE_FONT=1
8317         MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
8319         dnl D3D10 Layers depend on D2D Surfaces.
8320         if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
8321           MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
8322         fi
8323         ;;
8324     esac
8325     if test "$USE_FC_FREETYPE"; then
8326         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
8327     fi
8328     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
8329     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
8330     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
8331     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
8332     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
8334     AC_SUBST(PS_SURFACE_FEATURE)
8335     AC_SUBST(PDF_SURFACE_FEATURE)
8336     AC_SUBST(SVG_SURFACE_FEATURE)
8337     AC_SUBST(XLIB_SURFACE_FEATURE)
8338     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
8339     AC_SUBST(QUARTZ_SURFACE_FEATURE)
8340     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
8341     AC_SUBST(WIN32_SURFACE_FEATURE)
8342     AC_SUBST(OS2_SURFACE_FEATURE)
8343     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
8344     AC_SUBST(FT_FONT_FEATURE)
8345     AC_SUBST(FC_FONT_FEATURE)
8346     AC_SUBST(WIN32_FONT_FEATURE)
8347     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
8348     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
8349     AC_SUBST(QUARTZ_FONT_FEATURE)
8350     AC_SUBST(PNG_FUNCTIONS_FEATURE)
8351     AC_SUBST(QT_SURFACE_FEATURE)
8352     AC_SUBST(TEE_SURFACE_FEATURE)
8354     MOZ_CAIRO_OSLIBS='${CAIRO_FT_OSLIBS}'
8356     if test "$MOZ_X11"; then
8357         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
8358     fi
8360     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
8361 else
8362     PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION)
8363     MOZ_CAIRO_CFLAGS="$CAIRO_CFLAGS"
8364     MOZ_CAIRO_LIBS="$CAIRO_LIBS"
8365     PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
8366     if test "$MOZ_X11"; then
8367         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
8368         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
8369         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_LIBS"
8370         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
8371     fi
8374 AC_SUBST(MOZ_TREE_CAIRO)
8375 AC_SUBST_LIST(MOZ_CAIRO_CFLAGS)
8376 AC_SUBST_LIST(MOZ_CAIRO_LIBS)
8377 AC_SUBST_LIST(MOZ_CAIRO_OSLIBS)
8378 AC_SUBST(MOZ_TREE_PIXMAN)
8380 dnl ========================================================
8381 dnl Skia
8382 dnl ========================================================
8383 if test "$MOZ_ENABLE_SKIA"; then
8384   AC_DEFINE(MOZ_ENABLE_SKIA)
8385   AC_DEFINE(USE_SKIA)
8386   if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
8387     AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
8388   fi
8390   if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64" -a "${CPU_ARCH}" != "sparc" -a -z "$MOZ_DISABLE_SKIA_GPU" ; then
8391     MOZ_ENABLE_SKIA_GPU=1
8392     AC_DEFINE(USE_SKIA_GPU)
8393     AC_SUBST(MOZ_ENABLE_SKIA_GPU)
8394   fi
8396 AC_SUBST(MOZ_ENABLE_SKIA)
8398 dnl ========================================================
8399 dnl disable xul
8400 dnl ========================================================
8401 MOZ_ARG_DISABLE_BOOL(xul,
8402 [  --disable-xul           Disable XUL],
8403     MOZ_XUL= )
8404 if test "$MOZ_XUL"; then
8405   AC_DEFINE(MOZ_XUL)
8406 else
8407   dnl remove extensions that require XUL
8408   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/irc//' -e 's/tasks//'`
8411 AC_SUBST(MOZ_XUL)
8413 dnl ========================================================
8414 dnl disable profile locking
8415 dnl   do no use this in applications that can have more than
8416 dnl   one process accessing the profile directory.
8417 dnl ========================================================
8418 MOZ_ARG_DISABLE_BOOL(profilelocking,
8419 [  --disable-profilelocking
8420                           Disable profile locking],
8421     MOZ_PROFILELOCKING=,
8422     MOZ_PROFILELOCKING=1 )
8423 if test "$MOZ_PROFILELOCKING"; then
8424   AC_DEFINE(MOZ_PROFILELOCKING)
8427 dnl ========================================================
8428 dnl necko configuration options
8429 dnl ========================================================
8432 dnl option to disable various necko protocols
8434 MOZ_ARG_ENABLE_STRING(necko-protocols,
8435 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8436                           Enable/disable specific protocol handlers],
8437 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8438     if test "$option" = "yes" -o "$option" = "all"; then
8439         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8440     elif test "$option" = "no" -o "$option" = "none"; then
8441         NECKO_PROTOCOLS=""
8442     elif test "$option" = "default"; then
8443         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8444     elif test `echo "$option" | grep -c \^-` != 0; then
8445         option=`echo $option | sed 's/^-//'`
8446         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8447     else
8448         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8449     fi
8450 done],
8451     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8452 dnl Remove dupes
8453 NECKO_PROTOCOLS=`$PYTHON ${srcdir}/build/unix/uniq.py ${NECKO_PROTOCOLS}`
8454 AC_SUBST_SET(NECKO_PROTOCOLS)
8455 for p in $NECKO_PROTOCOLS; do
8456     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8457     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_PROTOCOL_$p"
8458 done
8461 dnl option to disable necko's wifi scanner
8464 case "$OS_TARGET" in
8465   Android)
8466     if test -n "$gonkdir"; then
8467       NECKO_WIFI=1
8468     fi
8469     ;;
8470   Darwin)
8471     if test -z "$MOZ_IOS"; then
8472       NECKO_WIFI=1
8473     fi
8474     ;;
8475   DragonFly|FreeBSD|SunOS|WINNT)
8476     NECKO_WIFI=1
8477     ;;
8478   Linux)
8479     NECKO_WIFI=1
8480     NECKO_WIFI_DBUS=1
8481     ;;
8482 esac
8484 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8485 [  --disable-necko-wifi    Disable necko wifi scanner],
8486     NECKO_WIFI=,
8487     NECKO_WIFI=1)
8489 if test "$NECKO_WIFI"; then
8490   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
8491     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
8492   fi
8493   AC_DEFINE(NECKO_WIFI)
8494   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
8496 AC_SUBST(NECKO_WIFI)
8497 AC_SUBST(NECKO_WIFI_DBUS)
8500 dnl option to disable cookies
8502 MOZ_ARG_DISABLE_BOOL(cookies,
8503 [  --disable-cookies       Disable cookie support],
8504     NECKO_COOKIES=,
8505     NECKO_COOKIES=1)
8506 AC_SUBST(NECKO_COOKIES)
8507 if test "$NECKO_COOKIES"; then
8508     AC_DEFINE(NECKO_COOKIES)
8509     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
8513 dnl Always build Marionette if not Android or B2G
8515 if test "$OS_TARGET" != Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
8516     AC_DEFINE(ENABLE_MARIONETTE)
8518 AC_SUBST(ENABLE_MARIONETTE)
8519 if test "$ENABLE_MARIONETTE"; then
8520     AC_DEFINE(ENABLE_MARIONETTE)
8524 dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
8526 MOZ_ARG_DISABLE_BOOL(ctypes,
8527 [  --disable-ctypes        Disable js-ctypes],
8528     BUILD_CTYPES=,
8529     BUILD_CTYPES=1)
8530 AC_SUBST(BUILD_CTYPES)
8531 if test "$BUILD_CTYPES"; then
8532     AC_DEFINE(BUILD_CTYPES)
8535 dnl Build Places if required
8536 if test "$MOZ_PLACES"; then
8537   AC_DEFINE(MOZ_PLACES)
8540 dnl Build SocialAPI if required
8541 if test "$MOZ_SOCIAL"; then
8542   AC_DEFINE(MOZ_SOCIAL)
8545 dnl Build Common JS modules provided by services.
8546 AC_SUBST(MOZ_SERVICES_COMMON)
8547 if test -n "$MOZ_SERVICES_COMMON"; then
8548   AC_DEFINE(MOZ_SERVICES_COMMON)
8551 dnl Build Services crypto component (used by Sync)
8552 AC_SUBST(MOZ_SERVICES_CRYPTO)
8553 if test -n "$MOZ_SERVICES_CRYPTO"; then
8554   AC_DEFINE(MOZ_SERVICES_CRYPTO)
8557 dnl Build Firefox Health Reporter Service
8558 AC_SUBST(MOZ_SERVICES_HEALTHREPORT)
8559 if test -n "$MOZ_SERVICES_HEALTHREPORT"; then
8560   AC_DEFINE(MOZ_SERVICES_HEALTHREPORT)
8563 dnl Build Services metrics component
8564 AC_SUBST(MOZ_SERVICES_METRICS)
8565 if test -n "$MOZ_SERVICES_METRICS"; then
8566   AC_DEFINE(MOZ_SERVICES_METRICS)
8569 dnl Build Notifications if required
8570 AC_SUBST(MOZ_SERVICES_NOTIFICATIONS)
8571 if test -n "$MOZ_SERVICES_NOTIFICATIONS"; then
8572   AC_DEFINE(MOZ_SERVICES_NOTIFICATIONS)
8575 dnl Build Sync Services if required
8576 AC_SUBST(MOZ_SERVICES_SYNC)
8577 if test -n "$MOZ_SERVICES_SYNC"; then
8578   AC_DEFINE(MOZ_SERVICES_SYNC)
8581 dnl Build Services/CloudSync if required
8582 AC_SUBST(MOZ_SERVICES_CLOUDSYNC)
8583 if test -n "$MOZ_SERVICES_CLOUDSYNC"; then
8584   AC_DEFINE(MOZ_SERVICES_CLOUDSYNC)
8587 dnl Build second screen and casting features for external devices if required
8588 AC_SUBST(MOZ_DEVICES)
8589 if test -n "$MOZ_DEVICES"; then
8590   AC_DEFINE(MOZ_DEVICES)
8593 dnl ========================================================
8594 if test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
8595     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8598 dnl ========================================================
8599 dnl =
8600 dnl = Maintainer debug option (no --enable equivalent)
8601 dnl =
8602 dnl ========================================================
8604 AC_SUBST(AR)
8605 AC_SUBST(AR_FLAGS)
8606 AC_SUBST(AR_LIST)
8607 AC_SUBST(AR_EXTRACT)
8608 AC_SUBST(AR_DELETE)
8609 AC_SUBST(AS)
8610 AC_SUBST(ASFLAGS)
8611 AC_SUBST(AS_DASH_C_FLAG)
8612 AC_SUBST(LD)
8613 AC_SUBST(RC)
8614 AC_SUBST(RCFLAGS)
8615 AC_SUBST(MC)
8616 AC_SUBST(WINDRES)
8617 AC_SUBST(IMPLIB)
8618 AC_SUBST(FILTER)
8619 AC_SUBST(BIN_FLAGS)
8620 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8621 AC_SUBST(MOZ_UPDATE_XTERM)
8622 AC_SUBST(MOZ_AUTH_EXTENSION)
8623 AC_SUBST(MOZ_PREF_EXTENSIONS)
8624 AC_SUBST(MOZ_DEBUG)
8625 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8626 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8627 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8628 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8629 AC_SUBST(WARNINGS_AS_ERRORS)
8630 AC_SUBST(MOZ_EXTENSIONS)
8631 AC_SUBST(MOZ_ENABLE_PROFILER_SPS)
8632 AC_SUBST(MOZ_JPROF)
8633 AC_SUBST(MOZ_INSTRUMENTS)
8634 AC_SUBST(MOZ_CALLGRIND)
8635 AC_SUBST(MOZ_VTUNE)
8636 AC_SUBST(MOZ_PROFILING)
8637 AC_SUBST(LIBICONV)
8638 AC_SUBST(MOZ_PLACES)
8639 AC_SUBST(MOZ_SOCIAL)
8640 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8641 AC_SUBST(MOZ_FEEDS)
8642 AC_SUBST(NS_PRINTING)
8643 AC_SUBST(MOZ_HELP_VIEWER)
8644 AC_SUBST(TOOLCHAIN_PREFIX)
8646 AC_SUBST(JAVA)
8647 AC_SUBST(JAVAC)
8648 AC_SUBST(JAVAH)
8649 AC_SUBST(JAR)
8650 AC_SUBST(JARSIGNER)
8651 AC_SUBST(KEYTOOL)
8653 AC_SUBST(MOZ_PROFILELOCKING)
8655 AC_SUBST(ENABLE_TESTS)
8656 AC_SUBST(MOZ_UNIVERSALCHARDET)
8657 AC_SUBST(ACCESSIBILITY)
8658 AC_SUBST(MOZ_SPELLCHECK)
8659 AC_SUBST(MOZ_ANDROID_APZ)
8660 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
8661 AC_SUBST(MOZ_CRASHREPORTER)
8662 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
8663 AC_SUBST(MOZ_CRASHREPORTER_UPLOAD_FULL_SYMBOLS)
8664 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
8665 AC_SUBST(MOZ_STUB_INSTALLER)
8666 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
8667 AC_SUBST(MOZ_ENABLE_SIGNMAR)
8668 AC_SUBST(MOZ_UPDATER)
8670 AC_SUBST(MOZ_ANGLE_RENDERER)
8671 AC_SUBST(MOZ_D3D_CPU_SUFFIX)
8672 AC_SUBST(MOZ_HAS_WINSDK_WITH_D3D)
8673 AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL)
8674 AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL_PATH)
8675 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
8676 AC_SUBST(MOZ_D3DCOMPILER_XP_DLL)
8677 AC_SUBST(MOZ_D3DCOMPILER_XP_CAB)
8679 AC_SUBST(MOZ_ANDROID_HISTORY)
8680 AC_SUBST(MOZ_WEBSMS_BACKEND)
8681 AC_SUBST(MOZ_ANDROID_BEAM)
8682 AC_SUBST(MOZ_LOCALE_SWITCHER)
8683 AC_SUBST(MOZ_DISABLE_GECKOVIEW)
8684 AC_SUBST(MOZ_ANDROID_GECKOLIBS_AAR)
8685 AC_SUBST(MOZ_ANDROID_READING_LIST_SERVICE)
8686 AC_SUBST(MOZ_ANDROID_SEARCH_ACTIVITY)
8687 AC_SUBST(MOZ_ANDROID_SHARE_OVERLAY)
8688 AC_SUBST(MOZ_ANDROID_FIREFOX_ACCOUNT_PROFILES)
8689 AC_SUBST(MOZ_ANDROID_TAB_QUEUE)
8690 AC_SUBST(MOZ_ANDROID_MLS_STUMBLER)
8691 AC_SUBST(MOZ_ANDROID_DOWNLOADS_INTEGRATION)
8692 AC_SUBST(MOZ_ANDROID_APPLICATION_CLASS)
8693 AC_SUBST(MOZ_ANDROID_BROWSER_INTENT_CLASS)
8694 AC_SUBST(MOZ_ANDROID_SEARCH_INTENT_CLASS)
8695 AC_SUBST(MOZ_INSTALL_TRACKING)
8696 AC_SUBST(ENABLE_STRIP)
8697 AC_SUBST(PKG_SKIP_STRIP)
8698 AC_SUBST(STRIP_FLAGS)
8699 AC_SUBST(USE_ELF_HACK)
8700 AC_SUBST(INCREMENTAL_LINKER)
8701 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8702 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8704 AC_SUBST(MOZ_FIX_LINK_PATHS)
8706 AC_SUBST(USE_DEPENDENT_LIBS)
8708 AC_SUBST(MOZ_BUILD_ROOT)
8710 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8711 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8712 AC_SUBST(MOZ_LINKER_EXTRACT)
8714 AC_SUBST(MOZ_ADDON_SIGNING)
8715 AC_SUBST(MOZ_REQUIRE_SIGNING)
8717 if test -n "$MOZ_BINARY_EXTENSIONS"; then
8718   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
8721 AC_SUBST(MOZ_JSDOWNLOADS)
8722 if test -n "$MOZ_JSDOWNLOADS"; then
8723   AC_DEFINE(MOZ_JSDOWNLOADS)
8726 dnl ========================================================
8727 dnl = Mac bundle name prefix
8728 dnl ========================================================
8729 MOZ_ARG_WITH_STRING(macbundlename-prefix,
8730 [  --with-macbundlename-prefix=prefix
8731                           Prefix for MOZ_MACBUNDLE_NAME],
8732 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
8734 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
8735 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
8736   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
8739 if test "$MOZ_DEBUG"; then
8740   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
8741 else
8742   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
8744 AC_SUBST(MOZ_MACBUNDLE_NAME)
8746 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
8747 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr '[A-Z]' '[a-z]'`
8748 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
8749 if test "$MOZ_DEBUG"; then
8750   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
8753 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
8754 AC_SUBST(MOZ_MACBUNDLE_ID)
8756 dnl ========================================================
8757 dnl = Child Process Name for IPC
8758 dnl ========================================================
8759 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
8760   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
8761 else
8762   # We want to let Android unpack the file at install time, but it only does
8763   # so if the file is named libsomething.so. The lib/ path is also required
8764   # because the unpacked file will be under the lib/ subdirectory and will
8765   # need to be executed from that path.
8766   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
8767   MOZ_CHILD_PROCESS_NAME_PIE="libplugin-container-pie.so"
8768   AC_SUBST(MOZ_CHILD_PROCESS_NAME_PIE)
8770 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
8772 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
8773 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
8775 # The following variables are available to branding and application
8776 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
8777 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
8778 # impacts profile location and user-visible fields.
8779 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
8780 # versions of a given application (e.g. Aurora and Firefox both use
8781 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
8782 # for application.ini's "Name" field, which controls profile location in
8783 # the absence of a "Profile" field (see below), and various system
8784 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
8785 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
8786 # Mac Bundle name, Updater, Installer), it is typically used for nightly
8787 # builds (e.g. Aurora for Firefox).
8788 # - MOZ_APP_VERSION: Defines the application version number.
8789 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
8790 # in the "About" window. If not set, defaults to MOZ_APP_VERSION.
8791 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
8792 # defaults to a lowercase form of MOZ_APP_BASENAME.
8793 # - MOZ_APP_REMOTINGNAME: Used for the internal program name, which affects
8794 # profile name and remoting. If not set, defaults to MOZ_APP_NAME.
8795 # - MOZ_APP_PROFILE: When set, used for application.ini's
8796 # "Profile" field, which controls profile location.
8797 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
8798 # crash reporter server url.
8799 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
8801 if test -z "$MOZ_APP_NAME"; then
8802    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
8805 if test -z "$MOZ_APP_REMOTINGNAME"; then
8806    MOZ_APP_REMOTINGNAME=$MOZ_APP_NAME
8809 if test -z "$MOZ_APP_VERSION_DISPLAY"; then
8810    MOZ_APP_VERSION_DISPLAY=$MOZ_APP_VERSION
8813 # For extensions and langpacks, we require a max version that is compatible
8814 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
8815 # 24.0a1 and 24.0a2 aren't affected
8816 # 24.0 becomes 24.*
8817 # 24.1.1 becomes 24.*
8818 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
8819 if test -z "$IS_ALPHA"; then
8820   changequote(,)
8821   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
8822     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
8823   else
8824     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
8825   fi
8826   changequote([,])
8827 else
8828   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
8831 MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"}
8832 AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION")
8833 AC_DEFINE_UNQUOTED(MOZ_B2G_OS_NAME,"$MOZ_B2G_OS_NAME")
8835 AC_SUBST(MOZ_APP_NAME)
8836 AC_SUBST(MOZ_APP_REMOTINGNAME)
8837 AC_SUBST(MOZ_APP_DISPLAYNAME)
8838 AC_SUBST(MOZ_APP_BASENAME)
8839 AC_SUBST(MOZ_APP_VENDOR)
8840 AC_SUBST(MOZ_APP_PROFILE)
8841 AC_SUBST(MOZ_APP_ID)
8842 AC_SUBST(MAR_CHANNEL_ID)
8843 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
8844 AC_SUBST(MOZ_PROFILE_MIGRATOR)
8845 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
8846 AC_SUBST(MOZ_APP_UA_NAME)
8847 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
8848 AC_SUBST(MOZ_APP_VERSION)
8849 AC_SUBST(MOZ_APP_VERSION_DISPLAY)
8850 AC_SUBST(MOZ_APP_MAXVERSION)
8851 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
8852 AC_SUBST(FIREFOX_VERSION)
8853 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
8854 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
8855   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
8858 AC_SUBST(MOZ_APP_STATIC_INI)
8860 AC_SUBST(MOZ_PKG_SPECIAL)
8862 AC_SUBST(MOZILLA_OFFICIAL)
8864 # Build revisions should always be present in official builds
8865 if test "$MOZILLA_OFFICIAL"; then
8866     MOZ_INCLUDE_SOURCE_INFO=1
8869 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
8871 AC_DEFINE_UNQUOTED(MOZ_TELEMETRY_DISPLAY_REV, 2)
8872 AC_SUBST(MOZ_TELEMETRY_DISPLAY_REV)
8874 if test "$MOZ_TELEMETRY_REPORTING"; then
8875     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
8877     # Enable Telemetry by default for nightly and aurora channels
8878     if test -z "$RELEASE_BUILD"; then
8879       AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
8880     fi
8883 dnl If we have any service that uploads data (and requires data submission
8884 dnl policy alert), set MOZ_DATA_REPORTING.
8885 dnl We need SUBST for build system and DEFINE for xul preprocessor.
8886 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"; then
8887   MOZ_DATA_REPORTING=1
8888   AC_DEFINE(MOZ_DATA_REPORTING)
8889   AC_SUBST(MOZ_DATA_REPORTING)
8892 dnl win32 options
8893 AC_SUBST(MOZ_BROWSE_INFO)
8894 AC_SUBST(WIN32_REDIST_DIR)
8895 AC_SUBST(MAKENSISU)
8897 dnl Echo the CFLAGS to remove extra whitespace.
8898 CFLAGS=`echo \
8899     $_WARNINGS_CFLAGS \
8900     $CFLAGS`
8902 CXXFLAGS=`echo \
8903     $_WARNINGS_CXXFLAGS \
8904     $CXXFLAGS`
8906 COMPILE_CFLAGS=`echo \
8907     $_DEFINES_CFLAGS \
8908     $_DEPEND_CFLAGS \
8909     $COMPILE_CFLAGS`
8911 COMPILE_CXXFLAGS=`echo \
8912     $_DEFINES_CXXFLAGS \
8913     $_DEPEND_CFLAGS \
8914     $COMPILE_CXXFLAGS`
8916 HOST_CFLAGS=`echo \
8917     $HOST_CFLAGS \
8918     $_DEPEND_CFLAGS`
8920 HOST_CXXFLAGS=`echo \
8921     $HOST_CXXFLAGS \
8922     $_DEPEND_CFLAGS`
8924 AC_SUBST(MOZ_NATIVE_JPEG)
8925 AC_SUBST(MOZ_NATIVE_PNG)
8926 AC_SUBST(MOZ_NATIVE_BZ2)
8928 AC_SUBST(MOZ_JPEG_CFLAGS)
8929 AC_SUBST_LIST(MOZ_JPEG_LIBS)
8930 AC_SUBST(MOZ_BZ2_CFLAGS)
8931 AC_SUBST_LIST(MOZ_BZ2_LIBS)
8932 AC_SUBST(MOZ_PNG_CFLAGS)
8933 AC_SUBST_LIST(MOZ_PNG_LIBS)
8935 if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_NUWA_PROCESS"; then
8936     export MOZ_NUWA_PROCESS
8937     AC_DEFINE(MOZ_NUWA_PROCESS)
8939 AC_SUBST(MOZ_NUWA_PROCESS)
8940 if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_B2G_LOADER"; then
8941     if test -z "$MOZ_NUWA_PROCESS"; then
8942        AC_MSG_ERROR([B2G loader works with Nuwa]);
8943     fi
8944     export MOZ_B2G_LOADER
8945     AC_DEFINE(MOZ_B2G_LOADER)
8947 AC_SUBST(MOZ_B2G_LOADER)
8949 AC_SUBST(NSPR_CFLAGS)
8950 AC_SUBST(MOZ_NATIVE_NSPR)
8952 AC_SUBST(NSS_CFLAGS)
8953 AC_SUBST(MOZ_NATIVE_NSS)
8954 AC_SUBST(NSS_DISABLE_DBM)
8956 OS_CFLAGS="$CFLAGS"
8957 OS_CXXFLAGS="$CXXFLAGS"
8958 OS_CPPFLAGS="$CPPFLAGS"
8959 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
8960 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
8961 OS_LDFLAGS="$LDFLAGS"
8962 OS_LIBS="$LIBS"
8963 AC_SUBST(OS_CFLAGS)
8964 AC_SUBST(OS_CXXFLAGS)
8965 AC_SUBST(OS_CPPFLAGS)
8966 AC_SUBST(OS_COMPILE_CFLAGS)
8967 AC_SUBST(OS_COMPILE_CXXFLAGS)
8968 AC_SUBST(OS_LDFLAGS)
8969 AC_SUBST(OS_LIBS)
8970 AC_SUBST(CROSS_COMPILE)
8971 AC_SUBST(WCHAR_CFLAGS)
8973 AC_SUBST(HOST_CC)
8974 AC_SUBST(HOST_CXX)
8975 AC_SUBST(HOST_CFLAGS)
8976 AC_SUBST(HOST_CXXFLAGS)
8977 AC_SUBST(HOST_LDFLAGS)
8978 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8979 AC_SUBST(HOST_AR)
8980 AC_SUBST(HOST_AR_FLAGS)
8981 AC_SUBST(HOST_LD)
8982 AC_SUBST(HOST_RANLIB)
8983 AC_SUBST(HOST_NSPR_MDCPUCFG)
8984 AC_SUBST(HOST_BIN_SUFFIX)
8985 AC_SUBST(HOST_OS_ARCH)
8987 AC_SUBST(TARGET_CPU)
8988 AC_SUBST(TARGET_VENDOR)
8989 AC_SUBST(TARGET_OS)
8990 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8991 AC_SUBST(TARGET_MD_ARCH)
8992 AC_SUBST(TARGET_XPCOM_ABI)
8993 AC_SUBST(OS_TARGET)
8994 AC_SUBST(OS_ARCH)
8995 AC_SUBST(OS_RELEASE)
8996 AC_SUBST(OS_TEST)
8997 AC_SUBST(CPU_ARCH)
8998 AC_SUBST(INTEL_ARCHITECTURE)
8999 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
9000 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
9001 AC_SUBST(HAVE_X86_AVX2)
9002 AC_SUBST(GCC_USE_GNU_LD)
9004 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
9006 AC_SUBST(WRAP_LDFLAGS)
9007 AC_SUBST(MKSHLIB)
9008 AC_SUBST(MKCSHLIB)
9009 AC_SUBST(MKSHLIB_FORCE_ALL)
9010 AC_SUBST(MKSHLIB_UNFORCE_ALL)
9011 AC_SUBST(DSO_CFLAGS)
9012 AC_SUBST(DSO_PIC_CFLAGS)
9013 AC_SUBST(DSO_LDOPTS)
9014 AC_SUBST(LIB_PREFIX)
9015 AC_SUBST(DLL_PREFIX)
9016 AC_SUBST(DLL_SUFFIX)
9017 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
9018 AC_SUBST(LIB_SUFFIX)
9019 AC_SUBST(OBJ_SUFFIX)
9020 AC_SUBST(BIN_SUFFIX)
9021 AC_SUBST(ASM_SUFFIX)
9022 AC_SUBST(IMPORT_LIB_SUFFIX)
9023 AC_SUBST(USE_N32)
9024 AC_SUBST(CC_VERSION)
9025 AC_SUBST(CXX_VERSION)
9026 AC_SUBST(MSMANIFEST_TOOL)
9027 AC_SUBST(NS_ENABLE_TSF)
9028 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
9029 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
9031 AC_SUBST(MOZ_WAVE)
9032 AC_SUBST(MOZ_VORBIS)
9033 AC_SUBST(MOZ_TREMOR)
9034 AC_SUBST(MOZ_WEBM)
9035 AC_SUBST(MOZ_WMF)
9036 AC_SUBST(MOZ_FFMPEG)
9037 AC_SUBST(MOZ_FMP4)
9038 AC_SUBST(MOZ_EME)
9039 AC_SUBST(MOZ_DIRECTSHOW)
9040 AC_SUBST(MOZ_ANDROID_OMX)
9041 AC_SUBST(MOZ_APPLEMEDIA)
9042 AC_SUBST(MOZ_OMX_PLUGIN)
9043 AC_SUBST(MOZ_VPX_ERROR_CONCEALMENT)
9044 AC_SUBST(MOZ_VPX)
9045 AC_SUBST(VPX_AS)
9046 AC_SUBST_LIST(VPX_ASFLAGS)
9047 AC_SUBST(VPX_AS_CONVERSION)
9048 AC_SUBST(VPX_ASM_SUFFIX)
9049 AC_SUBST(VPX_X86_ASM)
9050 AC_SUBST(VPX_ARM_ASM)
9051 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
9052 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
9053 AC_SUBST(MOZ_CODE_COVERAGE)
9054 AC_SUBST(LIBJPEG_TURBO_AS)
9055 AC_SUBST_LIST(LIBJPEG_TURBO_ASFLAGS)
9056 AC_SUBST(MOZ_LIBAV_FFT)
9057 AC_SUBST(LIBAV_FFT_AS)
9058 AC_SUBST_LIST(LIBAV_FFT_ASFLAGS)
9060 AC_SUBST(MOZ_PACKAGE_JSSHELL)
9061 AC_SUBST(MOZ_FOLD_LIBS)
9062 AC_SUBST(SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE)
9064 AC_SUBST(MOZ_ENABLE_SZIP)
9065 AC_SUBST(MOZ_SZIP_FLAGS)
9067 dnl Host JavaScript runtime, if any, to use during cross compiles.
9068 AC_SUBST(JS_BINARY)
9070 if test "$MOZ_DEBUG"; then
9071     MOZ_EM_DEBUG=1
9073 AC_SUBST(MOZ_EM_DEBUG)
9075 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
9077 if test -n "$COMPILE_ENVIRONMENT"; then
9078 AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
9080 dnl Check for missing components
9081 if test "$MOZ_X11"; then
9082     if test "$WITHOUT_X11"; then
9083         AC_MSG_ERROR([--without-x specified and MOZ_X11 still defined])
9084     fi
9085     dnl ====================================================
9086     dnl = Check if X headers exist
9087     dnl ====================================================
9088     _SAVE_CFLAGS=$CFLAGS
9089     CFLAGS="$CFLAGS $XCFLAGS"
9090     AC_TRY_COMPILE([
9091         #include <stdio.h>
9092         #include <stdlib.h>
9093         #include <X11/Xlib.h>
9094         #include <X11/Intrinsic.h>
9095         #include <X11/extensions/XShm.h>
9096     ],
9097     [
9098         Display *dpy = 0;
9099         if ((dpy = XOpenDisplay(NULL)) == NULL) {
9100             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
9101             exit(1);
9102         }
9103     ], [],
9104     [ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
9105     CFLAGS="$_SAVE_CFLAGS"
9107     if test -n "$MISSING_X"; then
9108         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
9109     fi
9111 fi # MOZ_X11
9113 fi # COMPILE_ENVIRONMENT
9115 dnl Set various defines and substitutions
9116 dnl ========================================================
9118 if test "$OS_ARCH" != "WINNT"; then
9119   AC_DEFINE(XP_UNIX)
9122 if test "$MOZ_DEBUG"; then
9123     AC_DEFINE(MOZ_REFLOW_PERF)
9124     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
9127 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
9128     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
9129     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
9130     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
9131     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
9132     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
9133     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
9134     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
9135     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
9138 if test -n "$MOZ_DEV_EDITION"; then
9139     AC_DEFINE(MOZ_DEV_EDITION)
9142 if test "$MOZ_DEBUG"; then
9143     A11Y_LOG=1
9145 case "$MOZ_UPDATE_CHANNEL" in
9146 aurora|beta|release|esr)
9147     ;;
9149     A11Y_LOG=1
9150     ;;
9151 esac
9152 AC_SUBST(A11Y_LOG)
9153 if test -n "$A11Y_LOG"; then
9154     AC_DEFINE(A11Y_LOG)
9157 AC_SUBST(MOZILLA_VERSION)
9159 AC_SUBST(ac_configure_args)
9161 dnl Spit out some output
9162 dnl ========================================================
9164 dnl The following defines are used by xpcom
9165 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
9166 CPP_THROW_NEW
9167 HAVE_CPP_AMBIGUITY_RESOLVING_USING
9168 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
9169 HAVE_CPP_PARTIAL_SPECIALIZATION
9170 HAVE_GETPAGESIZE
9171 HAVE_ICONV
9172 HAVE_ICONV_WITH_CONST_INPUT
9173 HAVE_MBRTOWC
9174 HAVE_WCRTOMB
9175 HAVE_STATVFS64
9176 HAVE_STATVFS
9177 HAVE_STATFS64
9178 HAVE_STATFS
9179 HAVE_SYS_STATVFS_H
9180 HAVE_SYS_STATFS_H
9181 HAVE_SYS_VFS_H
9182 HAVE_SYS_MOUNT_H
9185 dnl ========================================================
9186 dnl ICU Support
9187 dnl ========================================================
9189 # Internationalization isn't built or exposed by default in non-desktop
9190 # builds.  Bugs to enable:
9192 #   Android:  bug 864843
9194 if test "$MOZ_WIDGET_TOOLKIT" = "android"; then
9195     _INTL_API=no
9196 else
9197     _INTL_API=yes
9200 if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
9201     USE_ICU=1
9204 MOZ_CONFIG_ICU()
9206 if test -z "$JS_SHARED_LIBRARY"; then
9207   AC_DEFINE(MOZ_STATIC_JS)
9209 AC_SUBST(JS_SHARED_LIBRARY)
9211 MOZ_CREATE_CONFIG_STATUS()
9213 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9214 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9215   MOZ_SUBCONFIGURE_ICU()
9216   MOZ_SUBCONFIGURE_FFI()
9219 # Hack around an Apple bug that affects the egrep that comes with OS X 10.7.
9220 # "env ARCHPREFERENCE=i386,x86_64 arch egrep" first tries to use the 32-bit
9221 # Intel part of the egrep fat binary, even on 64-bit systems, and falls back on
9222 # the 64-bit part if it's not a fat binary, as can happen with MacPorts. We
9223 # (apparently) only need this hack when egrep's "pattern" is particularly long
9224 # (as in the following code) and the first egrep on our $PATH is Apple's.  See
9225 # bug 655339.
9226 case "$host" in
9227 *-apple-darwin11*)
9228     FIXED_EGREP="env ARCHPREFERENCE=i386,x86_64 arch egrep"
9229     ;;
9231     FIXED_EGREP="egrep"
9232     ;;
9233 esac
9235 # Run jemalloc configure script
9237 if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC3" -o -n "$MOZ_REPLACE_MALLOC"; then
9238   ac_configure_args="--build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_ --disable-valgrind"
9239   # We're using memalign for _aligned_malloc in memory/build/mozmemory_wrap.c
9240   # on Windows, so just export memalign on all platforms.
9241   ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
9242   if test -n "$MOZ_REPLACE_MALLOC"; then
9243     # When using replace_malloc, we always want valloc exported from jemalloc.
9244     ac_configure_args="$ac_configure_args ac_cv_func_valloc=yes"
9245   fi
9246   if test -n "$MOZ_JEMALLOC3"; then
9247     case "${OS_ARCH}" in
9248       WINNT|Darwin)
9249         # We want jemalloc functions to be kept hidden on both Mac and Windows
9250         # See memory/build/mozmemory_wrap.h for details.
9251         ac_configure_args="$ac_configure_args --without-export"
9252         ;;
9253     esac
9254   elif test "${OS_ARCH}" = Darwin; then
9255     # When building as a replace-malloc lib, disabling the zone allocator
9256     # forces to use pthread_atfork.
9257     ac_configure_args="$ac_configure_args --disable-zone-allocator"
9258   fi
9259   _MANGLE="malloc posix_memalign aligned_alloc calloc realloc free memalign valloc malloc_usable_size"
9260   JEMALLOC_WRAPPER=
9261   if test -z "$MOZ_REPLACE_MALLOC"; then
9262     case "$OS_ARCH" in
9263       Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
9264         MANGLE=$_MANGLE
9265         ;;
9266     esac
9267   elif test -z "$MOZ_JEMALLOC3"; then
9268     MANGLE=$_MANGLE
9269     JEMALLOC_WRAPPER=replace_
9270   fi
9271   if test -n "$MANGLE"; then
9272     MANGLED=
9273     for mangle in ${MANGLE}; do
9274       if test -n "$MANGLED"; then
9275         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle,$MANGLED"
9276       else
9277         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle"
9278       fi
9279     done
9280     ac_configure_args="$ac_configure_args --with-mangling=$MANGLED"
9281   fi
9282   unset CONFIG_FILES
9283   if test -z "$MOZ_TLS"; then
9284     ac_configure_args="$ac_configure_args --disable-tls"
9285   fi
9286   EXTRA_CFLAGS="$CFLAGS"
9287   for var in AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS EXTRA_CFLAGS LDFLAGS; do
9288     ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
9289   done
9290   if test "$CROSS_COMPILE"; then
9291     ac_configure_args="$ac_configure_args je_cv_static_page_shift=12"
9292   fi
9293   # Force disable DSS support in jemalloc.
9294   ac_configure_args="$ac_configure_args ac_cv_func_sbrk=false"
9296   # Make Linux builds munmap freed chunks instead of recycling them.
9297   ac_configure_args="$ac_configure_args --enable-munmap"
9299   if ! test -e memory/jemalloc; then
9300     mkdir -p memory/jemalloc
9301   fi
9303   AC_OUTPUT_SUBDIRS(memory/jemalloc/src)
9304   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9307 # Run freetype configure script
9309 if test "$MOZ_TREE_FREETYPE"; then
9310    export CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS -std=c99"
9311    export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS"
9312    export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS"
9313    export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS"
9314    # Spaces in the *_CFLAGS and *_LIBS variables are intentionally placed
9315    # to force freetype to use our settings rather than autodetecting
9316    if test -n "$MOZ_NATIVE_PNG"; then
9317      export LIBPNG_CFLAGS="$MOZ_PNG_CFLAGS "
9318    else
9319      export LIBPNG_CFLAGS="-I$_objdir/dist/include"
9320    fi
9321    export LIBPNG_LIBS="$MOZ_PNG_LIBS "
9322    export ZLIB_CFLAGS="$MOZ_ZLIB_CFLAGS "
9323    export ZLIB_LIBS="$MOZ_ZLIB_LIBS "
9324    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
9325    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes --with-zlib=yes --without-bzip2 --with-png=yes --without-harfbuzz"
9327    if ! test -e modules; then
9328      mkdir modules
9329    fi
9330    # Only export CC, CXX and RANLIB for the subconfigure, and avoid spilling
9331    # that further down the road.
9332    (export CC CXX RANLIB;
9333     AC_OUTPUT_SUBDIRS(modules/freetype2)
9334    ) || exit 1
9337 if test -z "$direct_nspr_config"; then
9338     dnl ========================================================
9339     dnl = Setup a nice relatively clean build environment for
9340     dnl = sub-configures.
9341     dnl ========================================================
9342     CC="$_SUBDIR_CC"
9343     CXX="$_SUBDIR_CXX"
9344     CFLAGS="$_SUBDIR_CFLAGS"
9345     CPPFLAGS="$_SUBDIR_CPPFLAGS"
9346     CXXFLAGS="$_SUBDIR_CXXFLAGS"
9347     LDFLAGS="$_SUBDIR_LDFLAGS"
9348     HOST_CC="$_SUBDIR_HOST_CC"
9349     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9350     HOST_CXXFLAGS="$_SUBDIR_HOST_CXXFLAGS"
9351     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9352     RC=
9355 unset MAKEFILES
9356 unset CONFIG_FILES
9358 # Run all configure scripts specified by a subconfigure
9359 if test -n "$_subconfigure_subdir"; then
9360   _save_srcdir="$srcdir"
9361   srcdir="$srcdir/.."
9362   _save_ac_configure_args="$ac_configure_args"
9363   ac_configure_args="$_subconfigure_config_args"
9364   AC_OUTPUT_SUBDIRS_NOW("$_subconfigure_subdir",$cache_file)
9365   ac_configure_args="$_save_ac_configure_args"
9366   srcdir="$_save_srcdir"
9369 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9370 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9372 export WRAP_LDFLAGS
9374 MOZ_SUBCONFIGURE_NSPR()
9376 dnl ========================================================
9377 dnl = Setup a nice relatively clean build environment for
9378 dnl = sub-configures.
9379 dnl ========================================================
9380 CC="$_SUBDIR_CC"
9381 CXX="$_SUBDIR_CXX"
9382 CFLAGS="$_SUBDIR_CFLAGS"
9383 CPPFLAGS="$_SUBDIR_CPPFLAGS"
9384 CXXFLAGS="$_SUBDIR_CXXFLAGS"
9385 LDFLAGS="$_SUBDIR_LDFLAGS"
9386 HOST_CC="$_SUBDIR_HOST_CC"
9387 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9388 HOST_CXXFLAGS="$_SUBDIR_HOST_CXXFLAGS"
9389 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9392 # Run the SpiderMonkey 'configure' script.
9393 dist=$MOZ_BUILD_ROOT/dist
9394 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9396 # --with-system-nspr will have been converted into the relevant $NSPR_CFLAGS
9397 # and $NSPR_LIBS.
9398 ac_configure_args="`echo $ac_configure_args | sed -e 's/--with-system-nspr\S* *//'`"
9400 ac_configure_args="$ac_configure_args --enable-threadsafe"
9402 if test "$_INTL_API" = no; then
9403     ac_configure_args="$ac_configure_args --without-intl-api"
9406 if test "$BUILD_CTYPES"; then
9407     # Build js-ctypes on the platforms we can.
9408     ac_configure_args="$ac_configure_args --enable-ctypes"
9410 if test -z "$JS_SHARED_LIBRARY" ; then
9411     ac_configure_args="$ac_configure_args --disable-shared-js"
9412     if test -n "$MOZ_DISABLE_EXPORT_JS"; then
9413         ac_configure_args="$ac_configure_args --disable-export-js"
9414     fi
9416 if test -n "$NSPR_CFLAGS" -o -n "$NSPR_LIBS"; then
9417     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
9418     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
9420 ac_configure_args="$ac_configure_args --prefix=$dist"
9421 if test "$MOZ_MEMORY"; then
9422    ac_configure_args="$ac_configure_args --enable-jemalloc"
9424 if test -n "$ZLIB_IN_MOZGLUE"; then
9425    MOZ_ZLIB_LIBS=
9427 export MOZ_NATIVE_ZLIB
9428 export MOZ_ZLIB_CFLAGS
9429 export MOZ_ZLIB_LIBS
9430 export MOZ_APP_NAME
9431 export MOZ_APP_REMOTINGNAME
9432 export DONT_POPULATE_VIRTUALENV=1
9433 export PYTHON
9434 export MOZILLA_CENTRAL_PATH=$_topsrcdir
9435 export STLPORT_CPPFLAGS
9436 export STLPORT_LIBS
9437 export JS_STANDALONE=no
9438 export MOZ_LINKER
9439 export ZLIB_IN_MOZGLUE
9440 export MOZ_MEMORY
9442 if ! test -e js; then
9443     mkdir js
9446 AC_OUTPUT_SUBDIRS(js/src,$cache_file)
9447 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9449 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR
9451 export WRITE_MOZINFO=1
9452 dnl we need to run config.status after js/src subconfigure because we're
9453 dnl traversing its moz.build and we need its config.status for that.
9454 dnl However, writing our own config.status needs to happen before
9455 dnl subconfigures because the setup surrounding subconfigures alters
9456 dnl many AC_SUBSTed variables.
9457 MOZ_RUN_CONFIG_STATUS()
9458 unset WRITE_MOZINFO