Merge fx-team to m-c.
[gecko.git] / configure.in
blobe81138257e93800e9bde5bb66dd8965f62e03f01
2 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
3 dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4:
4 dnl This Source Code Form is subject to the terms of the Mozilla Public
5 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
6 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 dnl Process this file with autoconf to produce a configure script.
9 dnl ========================================================
11 AC_PREREQ(2.13)
12 AC_INIT(config/config.mk)
13 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
14 AC_CANONICAL_SYSTEM
15 TARGET_CPU="${target_cpu}"
16 TARGET_VENDOR="${target_vendor}"
17 TARGET_OS="${target_os}"
19 dnl ========================================================
20 dnl =
21 dnl = Don't change the following two lines.  Doing so breaks:
22 dnl =
23 dnl = CFLAGS="-foo" ./configure
24 dnl =
25 dnl ========================================================
26 CFLAGS="${CFLAGS=}"
27 CPPFLAGS="${CPPFLAGS=}"
28 CXXFLAGS="${CXXFLAGS=}"
29 LDFLAGS="${LDFLAGS=}"
30 HOST_CFLAGS="${HOST_CFLAGS=}"
31 HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
32 HOST_LDFLAGS="${HOST_LDFLAGS=}"
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=10517
55 NSPR_VERSION=4
56 NSS_VERSION=3
58 dnl Set the minimum version of toolkit libs used by mozilla
59 dnl ========================================================
60 GLIB_VERSION=1.2.0
61 PERL_VERSION=5.006
62 CAIRO_VERSION=1.10
63 PANGO_VERSION=1.14.0
64 GTK2_VERSION=2.10.0
65 GTK3_VERSION=3.0.0
66 WINDRES_VERSION=2.14.90
67 W32API_VERSION=3.14
68 GNOMEVFS_VERSION=2.0
69 GNOMEUI_VERSION=2.2.0
70 GCONF_VERSION=1.2.1
71 GIO_VERSION=2.20
72 STARTUP_NOTIFICATION_VERSION=0.8
73 DBUS_VERSION=0.60
74 SQLITE_VERSION=3.7.17
76 MSMANIFEST_TOOL=
78 dnl Set various checks
79 dnl ========================================================
80 MISSING_X=
81 AC_PROG_AWK
83 dnl Initialize the Pthread test variables early so they can be
84 dnl  overridden by each platform.
85 dnl ========================================================
86 MOZ_USE_PTHREADS=
87 _PTHREAD_LDFLAGS=""
89 dnl Do not allow a separate objdir build if a srcdir build exists.
90 dnl ==============================================================
91 _topsrcdir=`cd \`dirname $0\`; pwd`
92 _objdir=`pwd`
94 if test "$_topsrcdir" != "$_objdir"
95 then
96   # Check for a couple representative files in the source tree
97   _conflict_files=
98   for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
99     if test -f $file; then
100       _conflict_files="$_conflict_files $file"
101     fi
102   done
103   if test "$_conflict_files"; then
104     echo "***"
105     echo "*   Your source tree contains these files:"
106     for file in $_conflict_files; do
107       echo "*         $file"
108     done
109     cat 1>&2 <<-EOF
110         *   This indicates that you previously built in the source tree.
111         *   A source tree build can confuse the separate objdir build.
112         *
113         *   To clean up the source tree:
114         *     1. cd $_topsrcdir
115         *     2. gmake distclean
116         ***
117         EOF
118     exit 1
119     break
120   fi
122 MOZ_BUILD_ROOT=`pwd`
124 MOZ_PYTHON
126 MOZ_DEFAULT_COMPILER
128 COMPILE_ENVIRONMENT=1
129 MOZ_ARG_DISABLE_BOOL(compile-environment,
130 [  --disable-compile-environment
131                           Disable compiler/library checks.],
132     COMPILE_ENVIRONMENT= )
133 AC_SUBST(COMPILE_ENVIRONMENT)
135 MOZ_ARG_WITH_STRING(l10n-base,
136 [  --with-l10n-base=DIR    path to l10n repositories],
137     L10NBASEDIR=$withval)
138 if test -n "$L10NBASEDIR"; then
139     if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
140         AC_MSG_ERROR([--with-l10n-base must specify a path])
141     elif test -d "$L10NBASEDIR"; then
142         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd`
143     else
144         AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
145     fi
147 AC_SUBST(L10NBASEDIR)
149 dnl Check for Perl first -- needed for win32 SDK checks
150 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
151 if test -z "$PERL" -o "$PERL" = ":"; then
152     AC_MSG_ERROR([perl not found in \$PATH])
155 AC_SUBST(GAIADIR)
156 if test -n "$GAIADIR" ; then
157     AC_DEFINE(PACKAGE_GAIA)
160 MOZ_ARG_WITH_STRING(gonk,
161 [  --with-gonk=DIR
162                location of gonk dir],
163     gonkdir=$withval)
165 MOZ_ARG_WITH_STRING(gonk-toolchain-prefix,
166 [  --with-gonk-toolchain-prefix=DIR
167                           prefix to gonk toolchain commands],
168     gonk_toolchain_prefix=$withval)
170 if test -n "$gonkdir" ; then
171     kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
172     android_source="$gonkdir"
173     ANDROID_SOURCE="$android_source"
174     ANDROID_NDK="${ANDROID_SOURCE}/ndk"
175     dnl Default to ICS
176     ANDROID_VERSION=15
177     if test -n "${PLATFORM_SDK_VERSION}"; then
178         ANDROID_VERSION="${PLATFORM_SDK_VERSION}"
179     fi
181     dnl set up compilers
182     TOOLCHAIN_PREFIX="$gonk_toolchain_prefix"
183     AS="$gonk_toolchain_prefix"as
184     CC="$gonk_toolchain_prefix"gcc
185     CXX="$gonk_toolchain_prefix"g++
186     CPP="$gonk_toolchain_prefix"cpp
187     LD="$gonk_toolchain_prefix"ld
188     AR="$gonk_toolchain_prefix"ar
189     RANLIB="$gonk_toolchain_prefix"ranlib
190     STRIP="$gonk_toolchain_prefix"strip
191     OBJCOPY="$gonk_toolchain_prefix"objcopy
193     if ! test -e "$gonkdir/ndk/sources/cxx-stl/stlport/src/iostream.cpp"; then
194         AC_MSG_ERROR([Couldn't find path to stlport sources in the gonk tree])
195     fi
196     STLPORT_CPPFLAGS="-I$_topsrcdir/build/stlport/stlport -I$gonkdir/ndk/sources/cxx-stl/system/include"
197     STLPORT_LIBS="$_objdir/build/stlport/libstlport_static.a"
199     case "$target_cpu" in
200     arm)
201         ARCH_DIR=arch-arm
202         ;;
203     i?86)
204         ARCH_DIR=arch-x86
205         ;;
206     esac
208     case "$ANDROID_VERSION" in
209     15)
210         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/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"
211         MOZ_B2G_BT=1
212         MOZ_B2G_CAMERA=1
213         MOZ_OMX_DECODER=1
214         AC_DEFINE(MOZ_OMX_DECODER)
215         AC_SUBST(MOZ_OMX_DECODER)
216         ;;
217     18)
218         GONK_INCLUDES="-I$gonkdir/frameworks/native/include"
219         if test -d "$gonkdir/external/bluetooth/bluez"; then
220             GONK_INCLUDES+=" -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib"
221             MOZ_B2G_BT=1
222         fi
223         ;;
224     *)
225         AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION])
226         ;;
227     esac
228     CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/$ARCH_DIR/include -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/kernel/$ARCH_DIR -isystem $gonkdir/bionic/libm/include -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"
229     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
230     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS $STLPORT_CPPFLAGS"
231     dnl Add -llog by default, since we use it all over the place.
232     LIBS="$LIBS -llog"
234     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"
236     dnl prevent cross compile section from using these flags as host flags
237     if test -z "$HOST_CPPFLAGS" ; then
238         HOST_CPPFLAGS=" "
239     fi
240     if test -z "$HOST_CFLAGS" ; then
241         HOST_CFLAGS=" "
242     fi
243     if test -z "$HOST_CXXFLAGS" ; then
244         HOST_CXXFLAGS=" "
245     fi
246     if test -z "$HOST_LDFLAGS" ; then
247         HOST_LDFLAGS=" "
248     fi
250     AC_DEFINE(ANDROID)
251     AC_DEFINE_UNQUOTED(ANDROID_VERSION, $ANDROID_VERSION)
252     AC_SUBST(ANDROID_VERSION)
253     AC_DEFINE(HAVE_SYS_UIO_H)
254     AC_DEFINE(HAVE_PTHREADS)
255     CROSS_COMPILE=1
256     MOZ_CHROME_FILE_FORMAT=omni
257     direct_nspr_config=1
258 else
259     MOZ_ANDROID_NDK
261     case "$target" in
262     *-android*|*-linuxandroid*)
263         if test -z "$ANDROID_PACKAGE_NAME" ; then
264             ANDROID_PACKAGE_NAME='org.mozilla.$(MOZ_APP_NAME)'
265         fi
266         MOZ_CHROME_FILE_FORMAT=omni
267         ZLIB_DIR=yes
268         ;;
269     *-linux*)
270         AC_PATH_PROG(OBJCOPY,objcopy)
271         ;;
272     esac
275 AC_SUBST(ANDROID_SOURCE)
276 AC_SUBST(ANDROID_PACKAGE_NAME)
277 AC_SUBST(OBJCOPY)
279 dnl ========================================================
280 dnl Checks for compilers.
281 dnl ========================================================
282 dnl Set CROSS_COMPILE in the environment when running configure
283 dnl to use the cross-compile setup for now
284 dnl ========================================================
286 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
287 AR_FLAGS='cr $@'
289 if test "$COMPILE_ENVIRONMENT"; then
291 if test -n "$CROSS_COMPILE" -a "$target" != "$host"; then
292     MOZ_CROSS_COMPILER
293 else
294     AC_PROG_CC
295     case "$target" in
296     *-mingw*)
297       # Work around the conftest.exe access problem on Windows
298       sleep 2
299     esac
300     AC_PROG_CXX
301     AC_PROG_RANLIB
302     MOZ_PATH_PROGS(AS, $AS as, $CC)
303     AC_CHECK_PROGS(AR, ar, :)
304     AC_CHECK_PROGS(LD, ld, :)
305     AC_CHECK_PROGS(STRIP, strip, :)
306     AC_CHECK_PROGS(WINDRES, windres, :)
307     if test -z "$HOST_CC"; then
308         HOST_CC="$CC"
309     fi
310     if test -z "$HOST_CFLAGS"; then
311         HOST_CFLAGS="$CFLAGS"
312     fi
313     if test -z "$HOST_CXX"; then
314         HOST_CXX="$CXX"
315     fi
316     if test -z "$HOST_CXXFLAGS"; then
317         HOST_CXXFLAGS="$CXXFLAGS"
318     fi
319     if test -z "$HOST_LDFLAGS"; then
320         HOST_LDFLAGS="$LDFLAGS"
321     fi
322     if test -z "$HOST_RANLIB"; then
323         HOST_RANLIB="$RANLIB"
324     fi
325     if test -z "$HOST_AR"; then
326         HOST_AR="$AR"
327     fi
328     if test -z "$HOST_AR_FLAGS"; then
329         HOST_AR_FLAGS="$AR_FLAGS"
330     fi
333 if test -n "$MOZ_WINCONSOLE"; then
334     AC_DEFINE(MOZ_WINCONSOLE)
337 MOZ_TOOL_VARIABLES
339 if test -n "$GNU_CC" -a -z "$CLANG_CC" ; then
340     if test "$GCC_MAJOR_VERSION" -eq 4 -a "$GCC_MINOR_VERSION" -lt 4 ||
341        test "$GCC_MAJOR_VERSION" -lt 4; then
342         AC_MSG_ERROR([Only GCC 4.4 or newer supported])
343     fi
346 dnl ========================================================
347 dnl Special win32 checks
348 dnl ========================================================
350 MOZ_ARG_ENABLE_BOOL(metro,
351 [  --enable-metro           Enable Windows Metro build targets],
352     MOZ_METRO=1,
353     MOZ_METRO=)
354 if test -n "$MOZ_METRO"; then
355     AC_DEFINE(MOZ_METRO)
356     # Target the Windows 8 Kit
357     WINSDK_TARGETVER=602
358     WINVER=502
359     # toolkit/library/makefile.in needs these, see nsDllMain.
360     CRTDLLVERSION=110
361     CRTEXPDLLVERSION=1-1-0
362 else
363     # Target the Windows 7 SDK by default
364     WINSDK_TARGETVER=601
365     WINVER=502
368 AC_SUBST(CRTDLLVERSION)
369 AC_SUBST(CRTEXPDLLVERSION)
371 MOZ_ARG_WITH_STRING(windows-version,
372 [  --with-windows-version=WINSDK_TARGETVER
373                           Windows SDK version to target. Lowest version
374                           currently allowed is 601 (Win7), highest is 602 (Win8)],
375   WINSDK_TARGETVER=$withval)
377 # Currently only two sdk versions allowed, 601 and 602
378 case "$WINSDK_TARGETVER" in
379 601|602)
380     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
381     ;;
384     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER)]);
385     ;;
386 esac
388 case "$target" in
389 *-mingw*)
390     if test "$GCC" != "yes" -a -z "$CLANG_CC"; then
391         # Check to see if we are really running in a msvc environemnt
392         _WIN32_MSVC=1
393         AC_CHECK_PROGS(MIDL, midl)
395         # Make sure compilers are valid
396         CFLAGS="$CFLAGS -TC -nologo"
397         CXXFLAGS="$CXXFLAGS -TP -nologo"
398         AC_LANG_SAVE
399         AC_LANG_C
400         AC_TRY_COMPILE([#include <stdio.h>],
401             [ printf("Hello World\n"); ],,
402             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
404         AC_LANG_CPLUSPLUS
405         AC_TRY_COMPILE([#include <new.h>],
406             [ unsigned *test = new unsigned(42); ],,
407             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
408         AC_LANG_RESTORE
410         changequote(,)
411         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
412         changequote([,])
414         # Determine compiler version
415         CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
416         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
417         _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
418         _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
419         _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
420         _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
422         CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
423         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
425         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
426             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
427         fi
429         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
430         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
432         if test "$_CC_MAJOR_VERSION" = "16"; then
433             _CC_SUITE=10
434             _MSVS_VERSION=2010
435         elif test "$_CC_MAJOR_VERSION" = "17"; then
436             _CC_SUITE=11
437             _MSVS_VERSION=2012
438         elif test "$_CC_MAJOR_VERSION" = "18"; then
439             _CC_SUITE=12
440             _MSVS_VERSION=2013
441         else
442             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
443         fi
445         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
447         if test -n "$WIN32_REDIST_DIR"; then
448           if test ! -d "$WIN32_REDIST_DIR"; then
449             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
450           fi
451           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
452         fi
454         dnl Confirm we have the pri tools on win8 builds
455         if test -n "$MOZ_METRO"; then
456           AC_MSG_CHECKING([for makepri])
457           AC_CHECK_PROGS(MAKEPRI, makepri, "")
458           if test -z "MAKEPRI" ; then
459               AC_MSG_ERROR([makepri.exe is required for generating metro browser install components. It should be in the Win8 SDK.])
460           fi
461           AC_SUBST(MAKEPRI)
462         fi
464         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
465         dnl not something else like "magnetic tape manipulation utility".
466         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
467         if test -z "$MSMT_TOOL"; then
468           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
469         fi
471         changequote(,)
472         _MSMT_VER_FILTER='s|.*[^!-~]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
473         changequote([,])
474         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
475         if test -z "$MSMANIFEST_TOOL_VERSION"; then
476           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
477         fi
479         MSMANIFEST_TOOL=1
480         unset MSMT_TOOL
482         # Check linker version
483         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
484         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
485         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
486             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
487         fi
489         INCREMENTAL_LINKER=1
491         # Check midl version
492         _MIDL_FULL_VERSION=`"${MIDL}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
493         _MIDL_MAJOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
494         _MIDL_MINOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
495         _MIDL_REV_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
496         # Add flags if necessary
497         AC_MSG_CHECKING([for midl flags])
498         case "$target" in
499         i*86-*)
500             if test \( "$_MIDL_MAJOR_VERSION" = "7" -a "$_MIDL_MINOR_VERSION" = "00" -a "$_MIDL_REV_VERSION" = "0499" \); then
501                 # MIDL version 7.00.0499 defaults /env win64 on x64 platforms.
502                 # MIDL version 7.00.0500 or later has no problem.
503                 MIDL_FLAGS="${MIDL_FLAGS} -env win32"
504                 AC_MSG_RESULT([need -env win32])
505             else
506                 AC_MSG_RESULT([none needed])
507             fi
508             ;;
509         x86_64-*)
510             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
511             ;;
512         *)
513             AC_MSG_RESULT([none needed])
514             ;;
515         esac
517         unset _MSVC_VER_FILTER
519         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
520             [
521                 AC_LANG_SAVE
522                 AC_LANG_CPLUSPLUS
523                 _SAVE_CXXFLAGS="$CXXFLAGS"
524                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
525                 AC_TRY_COMPILE([#include <exception>],
526                             [std::_Throw(std::exception()); return 0;],
527                             ac_cv_have_std__Throw="yes",
528                             ac_cv_have_std__Throw="no")
529                 CXXFLAGS="$_SAVE_CXXFLAGS"
530                 AC_LANG_RESTORE
531             ])
533         if test "$ac_cv_have_std__Throw" = "yes"; then
534             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
535                            ac_cv_have_dllimport_exception_bug,
536                 [
537                     AC_LANG_SAVE
538                     AC_LANG_CPLUSPLUS
539                     _SAVE_CXXFLAGS="$CXXFLAGS"
540                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
541                     AC_TRY_LINK([#include <vector>],
542                                 [std::vector<int> v; return v.at(1);],
543                                 ac_cv_have_dllimport_exception_bug="no",
544                                 ac_cv_have_dllimport_exception_bug="yes")
545                     CXXFLAGS="$_SAVE_CXXFLAGS"
546                     AC_LANG_RESTORE
547                 ])
548             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
549                 WRAP_STL_INCLUDES=1
550                 MOZ_MSVC_STL_WRAP__Throw=1
551                 AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
552             fi
553         else
554             AC_CACHE_CHECK(for overridable _RAISE,
555                            ac_cv_have__RAISE,
556                 [
557                     AC_LANG_SAVE
558                     AC_LANG_CPLUSPLUS
559                     _SAVE_CXXFLAGS="$CXXFLAGS"
560                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
561                     AC_TRY_COMPILE([#include <xstddef>
562                                     #undef _RAISE
563                                     #define _RAISE(x) externallyDefinedFunction((x).what())
564                                     #include <vector>
565                                    ],
566                                    [std::vector<int> v; return v.at(1);],
567                                    ac_cv_have__RAISE="no",
568                                    ac_cv_have__RAISE="yes")
569                     CXXFLAGS="$_SAVE_CXXFLAGS"
570                     AC_LANG_RESTORE
571                 ])
572             if test "$ac_cv_have__RAISE" = "yes"; then
573                 WRAP_STL_INCLUDES=1
574                 MOZ_MSVC_STL_WRAP__RAISE=1
575                 AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
576             else
577                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
578             fi
579         fi
581         if test "$WRAP_STL_INCLUDES" = "1"; then
582             STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
583         fi
584     elif test -z "$CLANG_CC"; then
585         # Check w32api version
586         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
587         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
588         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
589         AC_TRY_COMPILE([#include <w32api.h>],
590             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
591                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
592                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
593                 #error "test failed."
594             #endif
595             , [ res=yes ], [ res=no ])
596         AC_MSG_RESULT([$res])
597         if test "$res" != "yes"; then
598             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
599         fi
600         # Check windres version
601         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
602         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
603         AC_MSG_RESULT([$_WINDRES_VERSION])
604         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
605         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
606         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
607         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
608         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
609         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
610         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
611                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
612                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
613                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
614                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
615                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
616         then
617             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
618         fi
620         AC_CHECK_PROGS(MIDL, $target-widl widl)
621         if test -n "$MIDL"; then
622             case "$target" in
623             i*86-*)
624                 MIDL_FLAGS="$MIDL_FLAGS --win32 -m32"
625                 ;;
626             x86_64-*)
627                 MIDL_FLAGS="$MIDL_FLAGS --win64 -m64"
628                 ;;
629             esac
630         fi
632         MOZ_WINSDK_MAXVER=0x06020000
633     fi # !GNU_CC
635     # If MSVC or clang
636     if test "$GCC" != "yes" -o -n "$CLANG_CC" ; then
637         MOZ_FIND_WINSDK_VERSION
638     fi
640     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
641     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
642     # Require OS features provided by IE 6.0 SP2 (XP SP2)
643     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
645     # If the maximum version supported by this SDK is lower than the target
646     # version, error out
647     AC_MSG_CHECKING([for Windows SDK being recent enough])
648     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
649         AC_MSG_RESULT("yes")
650     else
651         AC_MSG_RESULT("no")
652         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.])
653     fi
654     
655     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
656     # Definitions matching sdkddkver.h
657     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
658     AC_DEFINE_UNQUOTED(MOZ_WINSDK_MAXVER,$MOZ_WINSDK_MAXVER)
659     AC_SUBST(MOZ_WINSDK_MAXVER)
660     ;;
661 esac
663 AC_PROG_CPP
664 AC_PROG_CXXCPP
666 if test -n "$_WIN32_MSVC"; then
667     SKIP_PATH_CHECKS=1
668     SKIP_COMPILER_CHECKS=1
669     SKIP_LIBRARY_CHECKS=1
671     # Since we're skipping compiler and library checks, hard-code
672     # some facts here.
673     AC_DEFINE(HAVE_IO_H)
674     AC_DEFINE(HAVE_SETBUF)
675     AC_DEFINE(HAVE_ISATTY)
678 fi # COMPILE_ENVIRONMENT
680 AC_SUBST(MIDL_FLAGS)
681 AC_SUBST(_MSC_VER)
683 AC_SUBST(GNU_AS)
684 AC_SUBST(GNU_LD)
685 AC_SUBST(GNU_CC)
686 AC_SUBST(GNU_CXX)
687 AC_SUBST(INTEL_CC)
688 AC_SUBST(INTEL_CXX)
690 AC_SUBST(STL_FLAGS)
691 AC_SUBST(WRAP_STL_INCLUDES)
692 AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
693 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
695 dnl ========================================================
696 dnl Checks for programs.
697 dnl ========================================================
698 AC_PROG_INSTALL
699 AC_PROG_LN_S
701 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
702 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
703 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
704 _perl_res=$?
705 AC_MSG_RESULT([$_perl_version])
707 if test "$_perl_res" != 0; then
708     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
712 AC_MSG_CHECKING([for full perl installation])
713 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
714 _perl_res=$?
715 if test "$_perl_res" != 0; then
716     AC_MSG_RESULT([no])
717     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
718 else
719     AC_MSG_RESULT([yes])
722 MOZ_ARG_WITH_BOOL(system-ply,
723 [  --with-system-ply       Use system installed python ply library],
724     [if $PYTHON -c 'import ply' 2>&5; then
725          MOZ_SYSTEM_PLY=1
726      else
727          AC_MSG_ERROR([python ply library is not found but --with-system-ply was requested])
728      fi])
730 AC_SUBST(MOZ_SYSTEM_PLY)
732 if test -z "$COMPILE_ENVIRONMENT"; then
733     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
735 AC_SUBST(NSINSTALL_BIN)
737 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
738 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
739 MOZ_PATH_PROGS(UNZIP, unzip)
740 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
741     AC_MSG_ERROR([unzip not found in \$PATH])
743 MOZ_PATH_PROGS(ZIP, zip)
744 if test -z "$ZIP" -o "$ZIP" = ":"; then
745     AC_MSG_ERROR([zip not found in \$PATH])
747 MOZ_PATH_PROG(XARGS, xargs)
748 if test -z "$XARGS" -o "$XARGS" = ":"; then
749     AC_MSG_ERROR([xargs not found in \$PATH .])
752 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
753 AC_SUBST(RPMBUILD)
755 if test "$COMPILE_ENVIRONMENT"; then
757 dnl ========================================================
758 dnl = Mac OS X toolchain support
759 dnl ========================================================
761 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
762 dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
763 dnl when we can run target binaries.
764 AC_SUBST(UNIVERSAL_BINARY)
765 AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
767 MOZ_ARG_WITH_STRING(unify-dist,
768 [  --with-unify-dist=dir   Location of the dist directory to unify with at packaging time (Mac OS X universal build only)],
769     UNIFY_DIST=$withval)
770 if test -n "$UNIVERSAL_BINARY"; then
771     if test -z "$UNIFY_DIST"; then
772         AC_MSG_ERROR([You need to provide the --with-unify-dist=dir argument when performing a universal build])
773     fi
774     case "$UNIFY_DIST" in
775     /*)
776         ;;
777     *)
778         UNIFY_DIST="${MOZ_BUILD_ROOT}/${UNIFY_DIST}"
779         ;;
780     esac
782 AC_SUBST(UNIFY_DIST)
784 dnl ========================================================
785 dnl Check for MacOS deployment target version
786 dnl ========================================================
788 MOZ_ARG_ENABLE_STRING(macos-target,
789                       [  --enable-macos-target=VER (default=10.6)
790                           Set the minimum MacOS version needed at runtime],
791                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
793 case "$target" in
794 *-darwin*)
795     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
796         dnl Use the specified value
797         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
798     else
799         dnl No value specified on the command line or in the environment,
800         dnl use architecture minimum.
801         export MACOSX_DEPLOYMENT_TARGET=10.6
802     fi
803     ;;
804 esac
806 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
808 dnl ========================================================
809 dnl = Mac OS X SDK support
810 dnl ========================================================
811 MACOS_SDK_DIR=
812 NEXT_ROOT=
813 MOZ_ARG_WITH_STRING(macos-sdk,
814 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
815     MACOS_SDK_DIR=$withval)
817 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
818 dnl NEXT_ROOT will be set and exported only if it's needed.
819 AC_SUBST(MACOS_SDK_DIR)
820 AC_SUBST(NEXT_ROOT)
822 if test "$MACOS_SDK_DIR"; then
823   dnl Sync this section with the ones in NSPR and NSS.
824   dnl Changes to the cross environment here need to be accounted for in
825   dnl the libIDL checks (below) and xpidl build.
827   if test ! -d "$MACOS_SDK_DIR"; then
828     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
829 specify a valid SDK.  SDKs are installed when the optional cross-development
830 tools are selected during the Xcode/Developer Tools installation.])
831   fi
833   CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
834   CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
836   dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
837   CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
838   CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
840   AC_LANG_SAVE
841   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
842   AC_LANG_CPLUSPLUS
843   AC_TRY_COMPILE([#include <new>],[],
844    result=yes,
845    result=no)
846   AC_LANG_RESTORE
847   AC_MSG_RESULT($result)
849   if test "$result" = "no" ; then
850     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
851   fi
854 fi # COMPILE_ENVIRONMENT
856 AC_MSG_CHECKING([compiler version])
857 # Just print it so it shows up in the logs.
858 cc_version=$($CC --version)
859 AC_MSG_RESULT([$cc_version])
861 if test -n "$MAKE"; then
862   if test `echo $MAKE | grep -c make.py` != 1; then
863      NOT_PYMAKE=$MAKE
864   fi
867 case "$host_os" in
868 mingw*)
869     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
870     ;;
872     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
873     ;;
874 esac
875 if test "$GMAKE" = ":"; then
876    AC_MSG_ERROR([GNU make not found])
878 AC_SUBST(GMAKE)
880 if test -z "$MAKE"; then
881   MAKE=$GMAKE
884 if test "$COMPILE_ENVIRONMENT"; then
886 AC_PATH_XTRA
888 XCFLAGS="$X_CFLAGS"
890 fi # COMPILE_ENVIRONMENT
892 dnl ========================================================
893 dnl set the defaults first
894 dnl ========================================================
895 AS_BIN=$AS
896 AR_LIST='$(AR) t'
897 AR_EXTRACT='$(AR) x'
898 AR_DELETE='$(AR) d'
899 AS='$(CC)'
900 AS_DASH_C_FLAG='-c'
901 DLL_PREFIX=lib
902 LIB_PREFIX=lib
903 DLL_SUFFIX=.so
904 OBJ_SUFFIX=o
905 LIB_SUFFIX=a
906 ASM_SUFFIX=s
907 IMPORT_LIB_SUFFIX=
908 TARGET_MD_ARCH=unix
909 DIRENT_INO=d_ino
910 MOZ_USER_DIR=".mozilla"
912 MOZ_JPEG_CFLAGS=
913 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)'
914 MOZ_BZ2_CFLAGS=
915 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
916 MOZ_PNG_CFLAGS=
917 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
919 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
920 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
921 DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxul -lxpcom_core -lmozalloc'
922 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
923 XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxul -lmozalloc'
924 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS)'
925 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
926 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
928 # These are specially defined on Windows only
929 case "$target" in
930 *-mingw*)
931   XPCOM_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
932   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime.$(LIB_SUFFIX)'
933   ;;
935   XPCOM_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_GLUE_LDOPTS
936   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_STANDALONE_GLUE_LDOPTS
937   ;;
938 esac
940 MOZ_FS_LAYOUT=unix
942 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
944 USE_DEPENDENT_LIBS=1
946 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
948 if test -n "$CROSS_COMPILE"; then
949     OS_TARGET="${target_os}"
950     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
951     OS_RELEASE=
952     case "${target_os}" in
953         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
954         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
955         gnu*)         OS_ARCH=GNU ;;
956         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
957         mingw*)       OS_ARCH=WINNT OS_TARGET=WINNT ;;
958         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
959     esac
960     case "${target}" in
961         *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
962     esac
963 else
964     OS_TARGET=`uname -s`
965     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
966     OS_RELEASE=`uname -r`
969 # Before this used `uname -m` when not cross compiling
970 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
971 OS_TEST="${target_cpu}"
973 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
975 #######################################################################
976 # Master "Core Components" macros for getting the OS target           #
977 #######################################################################
980 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
981 # cross-compilation.
985 # Define and override various archtecture-specific variables, including
986 # HOST_OS_ARCH
987 # OS_ARCH
988 # OS_TEST
989 # OS_TARGET
990 # OS_RELEASE
991 # OS_MINOR_RELEASE
994 case "$HOST_OS_ARCH" in
995 mingw*)
996     HOST_OS_ARCH=WINNT
997     ;;
998 darwin*)
999     HOST_OS_ARCH=Darwin
1000     ;;
1001 linux*)
1002     HOST_OS_ARCH=Linux
1003     ;;
1004 solaris*)
1005     HOST_OS_ARCH=SunOS
1006     SOLARIS_SUNPRO_CC=
1007     SOLARIS_SUNPRO_CXX=
1008     if test -z "$GNU_CC"; then
1009         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1010             SOLARIS_SUNPRO_CC=1
1011        fi
1012     fi
1014     if test -z "$GNU_CXX"; then
1015        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1016            SOLARIS_SUNPRO_CXX=1
1017        fi
1018     fi
1019     AC_SUBST(SOLARIS_SUNPRO_CC)
1020     AC_SUBST(SOLARIS_SUNPRO_CXX)
1021     ;;
1022 OS_2)
1023     HOST_OS_ARCH=OS2
1024     ;;
1025 esac
1027 case "$OS_ARCH" in
1028 WINNT)
1029     if test -z "$CROSS_COMPILE" ; then
1030         OS_TEST=`uname -p`
1031     fi
1032     ;;
1033 Windows_NT)
1035 # If uname -s returns "Windows_NT", we assume that we are using
1036 # the uname.exe in MKS toolkit.
1038 # The -r option of MKS uname only returns the major version number.
1039 # So we need to use its -v option to get the minor version number.
1040 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1042     OS_ARCH=WINNT
1043     OS_TARGET=WINNT
1044     OS_MINOR_RELEASE=`uname -v`
1045     if test "$OS_MINOR_RELEASE" = "00"; then
1046         OS_MINOR_RELEASE=0
1047     fi
1048     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1049     ;;
1050 MINGW*_NT*)
1052 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1053 # the uname.exe in the MSYS tools.
1055     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1056     OS_ARCH=WINNT
1057     OS_TARGET=WINNT
1058     ;;
1059 AIX)
1060     OS_RELEASE=`uname -v`.`uname -r`
1061     OS_TEST=${target_cpu}
1062     ;;
1063 OS_2)
1064     OS_ARCH=OS2
1065     OS_TARGET=OS2
1066     OS_RELEASE=`uname -v`
1067     ;;
1068 Darwin)
1069     case "${target_cpu}" in
1070     powerpc*)
1071         OS_TEST=ppc
1072         ;;
1073     i*86*)
1074         OS_TEST=i386
1075         ;;
1076     x86_64)
1077         OS_TEST=x86_64
1078         ;;
1079     *)
1080         if test -z "$CROSS_COMPILE" ; then
1081             OS_TEST=`uname -p`
1082         fi
1083         ;;
1084     esac
1085     ;;
1086 esac
1088 # Only set CPU_ARCH if we recognize the value of OS_TEST
1090 case "$OS_TEST" in
1091 *86 | i86pc)
1092     CPU_ARCH=x86
1093     ;;
1095 powerpc64 | ppc64)
1096     CPU_ARCH=ppc64
1097     ;;
1099 powerpc | ppc | rs6000)
1100     CPU_ARCH=ppc
1101     ;;
1103 Alpha | alpha | ALPHA)
1104     CPU_ARCH=Alpha
1105     ;;
1107 s390)
1108     CPU_ARCH=s390
1109     ;;
1111 s390x)
1112     CPU_ARCH=s390x
1113     ;;
1115 hppa* | parisc)
1116     CPU_ARCH=hppa
1117     ;;
1119 sun4u | sparc*)
1120     CPU_ARCH=sparc
1121     ;;
1123 x86_64 | ia64)
1124     CPU_ARCH="$OS_TEST"
1125     ;;
1127 arm*)
1128     CPU_ARCH=arm
1129     ;;
1131 mips|mipsel)
1132     CPU_ARCH="mips"
1133     ;;
1134 esac
1136 if test -z "$OS_TARGET"; then
1137     OS_TARGET=$OS_ARCH
1139 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1141 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1142 dnl ===============================================================
1143 INTEL_ARCHITECTURE=
1144 case "$OS_TEST" in
1145     x86_64|i?86)
1146       INTEL_ARCHITECTURE=1
1147 esac
1149 dnl Configure platform-specific CPU architecture compiler options.
1150 dnl ==============================================================
1151 MOZ_ARCH_OPTS
1153 dnl =================================================================
1154 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1155 dnl which is bad when cross compiling.
1156 dnl =================================================================
1157 if test "$COMPILE_ENVIRONMENT"; then
1158 configure_static_assert_macros='
1159 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1160 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1161 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1164 dnl test that the macros actually work:
1165 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1166 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1167  [AC_LANG_SAVE
1168   AC_LANG_C
1169   ac_cv_static_assertion_macros_work="yes"
1170   AC_TRY_COMPILE([$configure_static_assert_macros],
1171                  [CONFIGURE_STATIC_ASSERT(1)],
1172                  ,
1173                  ac_cv_static_assertion_macros_work="no")
1174   AC_TRY_COMPILE([$configure_static_assert_macros],
1175                  [CONFIGURE_STATIC_ASSERT(0)],
1176                  ac_cv_static_assertion_macros_work="no",
1177                  )
1178   AC_LANG_CPLUSPLUS
1179   AC_TRY_COMPILE([$configure_static_assert_macros],
1180                  [CONFIGURE_STATIC_ASSERT(1)],
1181                  ,
1182                  ac_cv_static_assertion_macros_work="no")
1183   AC_TRY_COMPILE([$configure_static_assert_macros],
1184                  [CONFIGURE_STATIC_ASSERT(0)],
1185                  ac_cv_static_assertion_macros_work="no",
1186                  )
1187   AC_LANG_RESTORE
1188  ])
1189 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1190 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1191     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1193 fi # COMPILE_ENVIRONMENT
1195 dnl ========================================================
1196 dnl Android libstdc++, placed here so it can use MOZ_ARCH
1197 dnl computed above.
1198 dnl ========================================================
1200 MOZ_ANDROID_STLPORT
1202 dnl ========================================================
1203 dnl Suppress Clang Argument Warnings
1204 dnl ========================================================
1205 if test -n "$CLANG_CC"; then
1206     _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
1207     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
1209 if test -n "$CLANG_CXX"; then
1210     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
1213 dnl ========================================================
1214 dnl = Use Address Sanitizer
1215 dnl ========================================================
1216 MOZ_ARG_ENABLE_BOOL(address-sanitizer,
1217 [  --enable-address-sanitizer       Enable Address Sanitizer (default=no)],
1218     MOZ_ASAN=1,
1219     MOZ_ASAN= )
1220 if test -n "$MOZ_ASAN"; then
1221     MOZ_LLVM_HACKS=1
1222     AC_DEFINE(MOZ_ASAN)
1224 AC_SUBST(MOZ_ASAN)
1226 dnl ========================================================
1227 dnl = Enable hacks required for LLVM instrumentations
1228 dnl ========================================================
1229 MOZ_ARG_ENABLE_BOOL(llvm-hacks,
1230 [  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)],
1231     MOZ_LLVM_HACKS=1,
1232     MOZ_LLVM_HACKS= )
1233 if test -n "$MOZ_LLVM_HACKS"; then
1234     MOZ_NO_WLZDEFS=1
1235     MOZ_CFLAGS_NSS=1
1237 AC_SUBST(MOZ_NO_WLZDEFS)
1238 AC_SUBST(MOZ_CFLAGS_NSS)
1240 dnl ========================================================
1241 dnl GNU specific defaults
1242 dnl ========================================================
1243 if test "$GNU_CC"; then
1244     # Per bug 719659 comment 2, some of the headers on ancient build machines
1245     # may require gnu89 inline semantics.  But otherwise, we use C99.
1246     CFLAGS="$CFLAGS -std=gnu99 -fgnu89-inline"
1247     # FIXME: Let us build with strict aliasing. bug 414641.
1248     CFLAGS="$CFLAGS -fno-strict-aliasing"
1249     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@'
1250     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@'
1251     DSO_LDOPTS='-shared'
1252     if test "$GCC_USE_GNU_LD"; then
1253         # Some tools like ASan use a runtime library that is only
1254         # linked against executables, so we must allow undefined
1255         # symbols for shared objects in some cases.
1256         if test -z "$MOZ_NO_WLZDEFS"; then
1257             # Don't allow undefined symbols in libraries
1258             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1259         fi
1260     fi
1261     WARNINGS_AS_ERRORS='-Werror'
1262     DSO_CFLAGS=''
1263     DSO_PIC_CFLAGS='-fPIC'
1264     ASFLAGS="$ASFLAGS -fPIC"
1265     AC_MSG_CHECKING([for --noexecstack option to as])
1266     _SAVE_CFLAGS=$CFLAGS
1267     CFLAGS="$CFLAGS -Wa,--noexecstack"
1268     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
1269                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
1270                      AC_MSG_RESULT([no]))
1271     CFLAGS=$_SAVE_CFLAGS
1272     AC_MSG_CHECKING([for -z noexecstack option to ld])
1273     _SAVE_LDFLAGS=$LDFLAGS
1274     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
1275     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
1276                   AC_MSG_RESULT([no])
1277                   LDFLAGS=$_SAVE_LDFLAGS)
1279     AC_MSG_CHECKING([for -z text option to ld])
1280     _SAVE_LDFLAGS=$LDFLAGS
1281     LDFLAGS="$LDFLAGS -Wl,-z,text"
1282     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1283                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,text"],
1284                   AC_MSG_RESULT([no])
1285                   LDFLAGS=$_SAVE_LDFLAGS)
1287     AC_MSG_CHECKING([for --build-id option to ld])
1288     _SAVE_LDFLAGS=$LDFLAGS
1289     LDFLAGS="$LDFLAGS -Wl,--build-id"
1290     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1291                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,--build-id"],
1292                   AC_MSG_RESULT([no])
1293                   LDFLAGS=$_SAVE_LDFLAGS)
1296     # Check for -mssse3 on $CC
1297     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
1298     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
1299     _SAVE_CFLAGS=$CFLAGS
1300     CFLAGS="$CFLAGS -mssse3"
1301     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
1302                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
1303                      AC_MSG_RESULT([no]))
1304     CFLAGS=$_SAVE_CFLAGS
1306     # Check for -msse4.1 on $CC
1307     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
1308     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
1309     _SAVE_CFLAGS=$CFLAGS
1310     CFLAGS="$CFLAGS -msse4.1"
1311     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
1312                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
1313                      AC_MSG_RESULT([no]))
1314     CFLAGS=$_SAVE_CFLAGS
1316     # Turn on GNU-specific warnings:
1317     # -Wall - turn on a lot of warnings
1318     # -Wpointer-arith - good to have
1319     # -Wdeclaration-after-statement - MSVC doesn't like these
1320     # -Werror=return-type - catches missing returns, zero false positives
1321     # -Wtype-limits - catches overflow bugs, few false positives
1322     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1323     # -Wsign-compare - catches comparison of signed and unsigned types
1324     #
1325     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
1326     MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
1327     MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
1328     MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
1329     MOZ_C_SUPPORTS_WARNING(-W, sign-compare, ac_c_has_sign_compare)
1331     # Turn off the following warnings that -Wall turns on:
1332     # -Wno-unused - lots of violations in third-party code
1333     #
1334     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
1336     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
1337        # Don't use -Wcast-align with ICC or clang
1338        case "$CPU_ARCH" in
1339            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1340            hppa | ia64 | sparc | arm)
1341            ;;
1342            *)
1343         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1344            ;;
1345        esac
1346     fi
1348     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1349     _USE_CPP_INCLUDE_FLAG=1
1350     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
1352 elif test "$SOLARIS_SUNPRO_CC"; then
1353     DSO_CFLAGS=''
1354     if test "$CPU_ARCH" = "sparc"; then
1355         # for Sun Studio on Solaris/SPARC
1356         DSO_PIC_CFLAGS='-xcode=pic32'
1357     else
1358         DSO_PIC_CFLAGS='-KPIC'
1359     fi
1360     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1361 else
1362     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
1363     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
1365     DSO_LDOPTS='-shared'
1366     if test "$GNU_LD"; then
1367         # Don't allow undefined symbols in libraries
1368         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1369     fi
1371     DSO_CFLAGS=''
1372     DSO_PIC_CFLAGS='-KPIC'
1373     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1376 if test "$GNU_CXX"; then
1377     # FIXME: Let us build with strict aliasing. bug 414641.
1378     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
1380     # Turn on GNU-specific warnings:
1381     # -Wall - turn on a lot of warnings
1382     # -Wpointer-arith - good to have
1383     # -Woverloaded-virtual - ???
1384     # -Werror=return-type - catches missing returns, zero false positives
1385     # -Wtype-limits - catches overflow bugs, few false positives
1386     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1387     # -Wsign-compare - catches comparison of signed and unsigned types
1388     #
1389     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
1390     MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
1391     MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
1392     MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
1393     MOZ_CXX_SUPPORTS_WARNING(-W, sign-compare, ac_cxx_has_sign_compare)
1395     # Turn off the following warnings that -Wall turns on:
1396     # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
1397     #
1398     MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
1400     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
1401        # Don't use -Wcast-align with ICC or clang
1402        case "$CPU_ARCH" in
1403            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1404            hppa | ia64 | sparc | arm)
1405            ;;
1406            *)
1407         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1408            ;;
1409        esac
1410     fi
1412     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1413     _USE_CPP_INCLUDE_FLAG=1
1415     # Recent clang and gcc support C++11 deleted functions without warnings if
1416     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
1417     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
1418     # unused.  But clang's warning can be disabled, so when compiling with clang
1419     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
1420     # deleted function syntax.
1421     if test "$CLANG_CXX"; then
1422         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
1423         MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
1424     fi
1426 else
1427     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
1430 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1431 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1432 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1433 dnl normal behavior.
1434 dnl ========================================================
1435 MKSHLIB_FORCE_ALL=
1436 MKSHLIB_UNFORCE_ALL=
1438 if test "$COMPILE_ENVIRONMENT"; then
1439 if test "$GNU_CC"; then
1440   AC_MSG_CHECKING(whether ld has archive extraction flags)
1441   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1442    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1443     ac_cv_mkshlib_force_and_unforce="no"
1444     exec 3<&0 <<LOOP_INPUT
1445         force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1446         force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1447         force="-Wl,-all";              unforce="-Wl,-none"
1448 LOOP_INPUT
1449     while read line
1450     do
1451       eval $line
1452       LDFLAGS=$force
1453       LIBS=$unforce
1454       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1455     done
1456     exec 0<&3 3<&-
1457     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1458    ])
1459   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1460     AC_MSG_RESULT(no)
1461   else
1462     AC_MSG_RESULT(yes)
1463     eval $ac_cv_mkshlib_force_and_unforce
1464     MKSHLIB_FORCE_ALL=$force
1465     MKSHLIB_UNFORCE_ALL=$unforce
1466   fi
1467 fi # GNU_CC
1468 fi # COMPILE_ENVIRONMENT
1470 dnl ========================================================
1471 dnl Checking for 64-bit OS
1472 dnl ========================================================
1473 if test "$COMPILE_ENVIRONMENT"; then
1474 AC_LANG_SAVE
1475 AC_LANG_C
1476 AC_MSG_CHECKING(for 64-bit OS)
1477 AC_TRY_COMPILE([$configure_static_assert_macros],
1478                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1479                result="yes", result="no")
1480 AC_MSG_RESULT("$result")
1481 if test "$result" = "yes"; then
1482     AC_DEFINE(HAVE_64BIT_OS)
1483     HAVE_64BIT_OS=1
1485 AC_SUBST(HAVE_64BIT_OS)
1486 AC_LANG_RESTORE
1487 fi # COMPILE_ENVIRONMENT
1489 dnl ========================================================
1490 dnl Enable high-memory support on OS/2 by default.
1491 dnl ========================================================
1492 MOZ_OS2_HIGH_MEMORY=1
1493 MOZ_ARG_DISABLE_BOOL(os2-high-mem,
1494 [  --disable-os2-high-mem  Disable high-memory support on OS/2],
1495     MOZ_OS2_HIGH_MEMORY=,
1496     MOZ_OS2_HIGH_MEMORY=1 )
1497 AC_SUBST(MOZ_OS2_HIGH_MEMORY)
1499 dnl ========================================================
1500 dnl = Use profiling compile flags
1501 dnl ========================================================
1502 MOZ_ARG_ENABLE_BOOL(profiling,
1503 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1504     MOZ_PROFILING=1,
1505     MOZ_PROFILING= )
1507 # For profiling builds keep the symbol information
1508 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
1509     case "$OS_TARGET" in
1510     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
1511         STRIP_FLAGS="--strip-debug"
1512         ;;
1513     esac
1516 dnl ========================================================
1517 dnl = Use incremental GC
1518 dnl ========================================================
1519 JSGC_INCREMENTAL=1
1520 MOZ_ARG_DISABLE_BOOL(gcincremental,
1521 [  --disable-gcincremental Disable incremental GC],
1522     JSGC_INCREMENTAL= )
1523 if test -n "$JSGC_INCREMENTAL"; then
1524     AC_DEFINE(JSGC_INCREMENTAL)
1527 dnl ========================================================
1528 dnl = Use generational GC
1529 dnl ========================================================
1530 MOZ_ARG_ENABLE_BOOL(gcgenerational,
1531 [  --enable-gcgenerational Enable generational GC],
1532     JSGC_GENERATIONAL=1,
1533     JSGC_GENERATIONAL= )
1534 if test -n "$JSGC_GENERATIONAL"; then
1535     AC_DEFINE(JSGC_GENERATIONAL)
1538 dnl ========================================================
1539 dnl = Perform moving GC stack rooting analysis
1540 dnl ========================================================
1541 MOZ_ARG_ENABLE_BOOL(root-analysis,
1542 [  --enable-root-analysis  Enable moving GC stack root analysis],
1543     JSGC_ROOT_ANALYSIS=1,
1544     JSGC_ROOT_ANALYSIS= )
1545 if test -n "$JSGC_ROOT_ANALYSIS"; then
1546     AC_DEFINE(JSGC_ROOT_ANALYSIS)
1549 dnl ========================================================
1550 dnl = Use exact stack rooting for GC
1551 dnl ========================================================
1552 MOZ_ARG_ENABLE_BOOL(exact-rooting,
1553 [  --enable-exact-rooting  Enable use of exact stack roots for GC],
1554     JSGC_USE_EXACT_ROOTING=1,
1555     JSGC_USE_EXACT_ROOTING= )
1556 if test -n "$JSGC_USE_EXACT_ROOTING"; then
1557     AC_DEFINE(JSGC_USE_EXACT_ROOTING)
1560 dnl ========================================================
1561 dnl = Use Valgrind
1562 dnl ========================================================
1563 MOZ_ARG_ENABLE_BOOL(valgrind,
1564 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
1565     MOZ_VALGRIND=1,
1566     MOZ_VALGRIND= )
1567 if test -n "$MOZ_VALGRIND"; then
1568     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1569         AC_MSG_ERROR(
1570             [--enable-valgrind specified but Valgrind is not installed]))
1571     AC_DEFINE(MOZ_VALGRIND)
1573 AC_SUBST(MOZ_VALGRIND)
1575 dnl ========================================================
1576 dnl jprof
1577 dnl ========================================================
1578 MOZ_ARG_ENABLE_BOOL(jprof,
1579 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
1580     MOZ_JPROF=1,
1581     MOZ_JPROF= )
1582 if test -n "$MOZ_JPROF"; then
1583     MOZ_PROFILING=1
1584     AC_DEFINE(MOZ_JPROF)
1587 dnl ========================================================
1588 dnl SPS Profiler
1589 dnl ========================================================
1590 MOZ_ENABLE_PROFILER_SPS=1
1592 case "${OS_TARGET}" in
1593 Android)
1594     case "${CPU_ARCH}" in
1595     x86 | arm) ;;
1596     *)
1597         MOZ_ENABLE_PROFILER_SPS=
1598     esac
1599     ;;
1600 Linux)
1601     case "${CPU_ARCH}" in
1602     x86 | x86_64) ;;
1603     *)
1604         MOZ_ENABLE_PROFILER_SPS=
1605     esac
1606     ;;
1607 WINNT|Darwin) ;;
1609     MOZ_ENABLE_PROFILER_SPS=
1610     ;;
1611 esac
1613 if test -n "$MOZ_ENABLE_PROFILER_SPS"; then
1614     AC_DEFINE(MOZ_ENABLE_PROFILER_SPS)
1617 dnl ========================================================
1618 dnl shark
1619 dnl ========================================================
1620 MOZ_ARG_ENABLE_BOOL(shark,
1621 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
1622     MOZ_SHARK=1,
1623     MOZ_SHARK= )
1624 if test -n "$MOZ_SHARK"; then
1625     MOZ_PROFILING=1
1626     AC_DEFINE(MOZ_SHARK)
1629 dnl ========================================================
1630 dnl instruments
1631 dnl ========================================================
1632 MOZ_ARG_ENABLE_BOOL(instruments,
1633 [  --enable-instruments    Enable instruments remote profiling. Implies --enable-profiling.],
1634     MOZ_INSTRUMENTS=1,
1635     MOZ_INSTRUMENTS= )
1636 if test -n "$MOZ_INSTRUMENTS"; then
1637     MOZ_PROFILING=1
1638     AC_DEFINE(MOZ_INSTRUMENTS)
1641 dnl ========================================================
1642 dnl callgrind
1643 dnl ========================================================
1644 MOZ_ARG_ENABLE_BOOL(callgrind,
1645 [  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.],
1646     MOZ_CALLGRIND=1,
1647     MOZ_CALLGRIND= )
1648 if test -n "$MOZ_CALLGRIND"; then
1649     MOZ_PROFILING=1
1650     AC_DEFINE(MOZ_CALLGRIND)
1653 dnl ========================================================
1654 dnl vtune
1655 dnl ========================================================
1656 MOZ_ARG_ENABLE_BOOL(vtune,
1657 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
1658     MOZ_VTUNE=1,
1659     MOZ_VTUNE= )
1660 if test -n "$MOZ_VTUNE"; then
1661     MOZ_PROFILING=1
1662     AC_DEFINE(MOZ_VTUNE)
1665 dnl ========================================================
1666 dnl Profiling
1667 dnl ========================================================
1668 if test -n "$MOZ_PROFILING"; then
1669     AC_DEFINE(MOZ_PROFILING)
1672 dnl ========================================================
1673 dnl System overrides of the defaults for host
1674 dnl ========================================================
1675 case "$host" in
1676 *mingw*)
1677     if test -n "$_WIN32_MSVC"; then
1678         HOST_AR=lib
1679         HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
1680         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
1681         HOST_RANLIB='echo ranlib'
1682     else
1683         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
1684     fi
1685     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
1686     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1687     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1688     HOST_BIN_SUFFIX=.exe
1689     case "$host" in
1690     *mingw*)
1691         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1692         ;;
1693     esac
1695     case "${host_cpu}" in
1696     i*86)
1697         if test -n "$_WIN32_MSVC"; then
1698             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
1699         fi
1700         ;;
1701     x86_64)
1702         if test -n "$_WIN32_MSVC"; then
1703             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
1704         fi
1705         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1706         ;;
1707     esac
1708     ;;
1710 *-darwin*)
1711     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1712     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1713     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1714     ;;
1716 *-linux*|*-kfreebsd*-gnu|*-gnu*)
1717     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1718     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1719     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1720     ;;
1722 *os2*)
1723     HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
1724     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
1725     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1726     HOST_BIN_SUFFIX=.exe
1727     MOZ_FIX_LINK_PATHS=
1728     ;;
1731     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1732     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1733     ;;
1734 esac
1736 dnl Get mozilla version from central milestone file
1737 MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
1738 MOZILLA_UAVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -uaversion`
1740 dnl Get version of various core apps from the version files.
1741 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
1743 if test -z "$FIREFOX_VERSION"; then
1744     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
1747 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
1748 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
1749 AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
1751 MOZ_DOING_LTO(lto_is_enabled)
1753 dnl ========================================================
1754 dnl System overrides of the defaults for target
1755 dnl ========================================================
1757 case "$target" in
1758 *-aix*)
1759     AC_DEFINE(AIX)
1760     if test ! "$GNU_CC"; then
1761         if test ! "$HAVE_64BIT_OS"; then
1762             # Compiling with Visual Age C++ object model compat is the
1763             # default. To compile with object model ibm, add
1764             # AIX_OBJMODEL=ibm to .mozconfig.
1765             if test "$AIX_OBJMODEL" = "ibm"; then
1766                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
1767             else
1768                 AIX_OBJMODEL=compat
1769             fi
1770         else
1771             AIX_OBJMODEL=compat
1772         fi
1773         AC_SUBST(AIX_OBJMODEL)
1774         DSO_LDOPTS='-qmkshrobj=1'
1775         DSO_CFLAGS='-qflag=w:w'
1776         DSO_PIC_CFLAGS=
1777         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
1778         MOZ_FIX_LINK_PATHS=
1779         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1780         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1781         if test "$COMPILE_ENVIRONMENT"; then
1782             AC_LANG_SAVE
1783             AC_LANG_CPLUSPLUS
1784             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
1785             AC_TRY_COMPILE([],
1786                 [#if (__IBMCPP__ < 900)
1787                  #error "Bad compiler"
1788                  #endif],
1789                 _BAD_COMPILER=,_BAD_COMPILER=1)
1790             if test -n "$_BAD_COMPILER"; then
1791                 AC_MSG_RESULT([no])
1792                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
1793             else
1794                 AC_MSG_RESULT([yes])
1795             fi
1796             AC_LANG_RESTORE
1797             TARGET_COMPILER_ABI="ibmc"
1798             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
1799             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
1800         fi
1801     fi
1802     case "${target_os}" in
1803     aix4.1*)
1804         DLL_SUFFIX='_shr.a'
1805         ;;
1806     esac
1807     if test "$COMPILE_ENVIRONMENT"; then
1808         MOZ_CHECK_HEADERS(sys/inttypes.h)
1809     fi
1810     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1811     ;;
1813 *-darwin*)
1814     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1815     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1816     MOZ_OPTIMIZE_FLAGS="-O3"
1817     # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
1818     if test "$HAVE_64BIT_OS"; then
1819         MOZ_MEMORY=1
1820     fi
1821     DLL_SUFFIX=".dylib"
1822     DSO_LDOPTS=''
1823     STRIP_FLAGS="$STRIP_FLAGS -x -S"
1824     # Check whether we're targeting OS X or iOS
1825     AC_CACHE_CHECK(for iOS target,
1826                    ac_cv_ios_target,
1827                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
1828 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
1829 #error not iOS
1830 #endif],
1831                                    [],
1832                                    ac_cv_ios_target="yes",
1833                                    ac_cv_ios_target="no")])
1834     if test "$ac_cv_ios_target" = "yes"; then
1835         AC_DEFINE(XP_IOS)
1836         AC_DEFINE(XP_DARWIN)
1837         _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
1838     else
1839         AC_DEFINE(XP_MACOSX)
1840         AC_DEFINE(XP_DARWIN)
1841         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
1842         # The ExceptionHandling framework is needed for Objective-C exception
1843         # logging code in nsObjCExceptions.h. Currently we only use that in debug
1844         # builds.
1845         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
1846     fi
1847     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1850     if test "x$lto_is_enabled" = "xyes"; then
1851         echo "Skipping -dead_strip because lto is enabled."
1852     dnl DTrace and -dead_strip don't interact well. See bug 403132.
1853     dnl ===================================================================
1854     elif test "x$enable_dtrace" = "xyes"; then
1855         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
1856     else
1857         dnl check for the presence of the -dead_strip linker flag
1858         AC_MSG_CHECKING([for -dead_strip option to ld])
1859         _SAVE_LDFLAGS=$LDFLAGS
1860         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
1861         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
1862         if test -n "$_HAVE_DEAD_STRIP" ; then
1863             AC_MSG_RESULT([yes])
1864             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
1865         else
1866             AC_MSG_RESULT([no])
1867         fi
1869         LDFLAGS=$_SAVE_LDFLAGS
1870     fi
1872     dnl With newer linkers we need to pass -allow_heap_execute because of
1873     dnl Microsoft Silverlight (5.1.10411.0 at least).
1874     AC_MSG_CHECKING([for -allow_heap_execute option to ld])
1875     _SAVE_LDFLAGS=$LDFLAGS
1876     LDFLAGS="$LDFLAGS -Wl,-allow_heap_execute"
1877     AC_TRY_LINK(,[return 0;],_HAVE_ALLOW_HEAP_EXECUTE=1,
1878                 _HAVE_ALLOW_HEAP_EXECUTE=)
1879     if test -n "$_HAVE_ALLOW_HEAP_EXECUTE" ; then
1880         AC_MSG_RESULT([yes])
1881         MOZ_ALLOW_HEAP_EXECUTE_FLAGS="-Wl,-allow_heap_execute"
1882     else
1883         AC_MSG_RESULT([no])
1884     fi
1885     LDFLAGS=$_SAVE_LDFLAGS
1887     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
1888     ;;
1890 ia64*-hpux*)
1891     DLL_SUFFIX=".so"
1892     if test ! "$GNU_CC"; then
1893        DSO_LDOPTS='-b'
1894        DSO_CFLAGS=""
1895        DSO_PIC_CFLAGS=
1896        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
1897        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
1898        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
1899     else
1900        DSO_LDOPTS='-b -E'
1901        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1902        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1903     fi
1904     MOZ_FIX_LINK_PATHS=
1905     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1906     AC_DEFINE(_LARGEFILE64_SOURCE)
1907     ;;
1909 *-hpux*)
1910     DLL_SUFFIX=".sl"
1911     if test ! "$GNU_CC"; then
1912         DSO_LDOPTS='-b -Wl,+s'
1913         DSO_CFLAGS=""
1914         DSO_PIC_CFLAGS="+Z"
1915         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
1916         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
1917         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
1918     else
1919         DSO_LDOPTS='-b -E +s'
1920         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
1921         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
1922     fi
1923     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
1924     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1925     ;;
1927 *-android*|*-linuxandroid*)
1928     AC_DEFINE(NO_PW_GECOS)
1929     no_x=yes
1930     if test -n "$gonkdir"; then
1931         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
1932         MOZ_B2G_RIL=1
1933         MOZ_B2G_FM=1
1934     else
1935         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
1936         MOZ_LINKER=1
1937     fi
1938     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1940     MOZ_GFX_OPTIMIZE_MOBILE=1
1941     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
1942     ;;
1944 *-*linux*)
1945     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
1946     # Similarly for GNU_CXX and INTEL_CXX.
1947     if test "$INTEL_CC" -o "$INTEL_CXX"; then
1948         # -Os has been broken on Intel's C/C++ compilers for quite a
1949         # while; Intel recommends against using it.
1950         MOZ_OPTIMIZE_FLAGS="-O2"
1951     elif test "$GNU_CC" -o "$GNU_CXX"; then
1952         case $GCC_VERSION in
1953         4.5.*)
1954             # -Os is broken on gcc 4.5.x we need to tweak it to get good results.
1955             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
1956         esac
1957         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
1958         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
1959     fi
1961     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1963     MOZ_MEMORY=1
1965     case "${target_cpu}" in
1966     alpha*)
1967         CFLAGS="$CFLAGS -mieee"
1968         CXXFLAGS="$CXXFLAGS -mieee"
1969     ;;
1970     i*86)
1971         USE_ELF_DYNSTR_GC=1
1972     ;;
1973     esac
1975     if test -z "$MC"; then
1976         MC=mc.exe
1977     fi
1978     ;;
1979 *-mingw*)
1980     DSO_CFLAGS=
1981     DSO_PIC_CFLAGS=
1982     DLL_SUFFIX=.dll
1983     RC=rc.exe
1984     MC=mc.exe
1985     # certain versions of cygwin's makedepend barf on the
1986     # #include <string> vs -I./dist/include/string issue so don't use it
1987     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
1988         CC="$CC -mwindows"
1989         CXX="$CXX -mwindows"
1990         CPP="$CPP -mwindows"
1991         CFLAGS="$CFLAGS -mms-bitfields"
1992         CXXFLAGS="$CXXFLAGS -mms-bitfields"
1993         DSO_LDOPTS='-shared'
1994         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1995         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1996         RC='$(WINDRES)'
1997         # Use static libgcc and libstdc++
1998         LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
1999         NSPR_LDFLAGS="$NSPR_LDFLAGS -static-libgcc"
2000         # Use temp file for windres (bug 213281)
2001         RCFLAGS='-O coff --use-temp-file'
2002         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2003         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32 -lnetapi32"
2004         MOZ_FIX_LINK_PATHS=
2005         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxul -lxpcom_core -lmozalloc'
2006         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxul -lmozalloc'
2007         DLL_PREFIX=
2008         IMPORT_LIB_SUFFIX=dll.a
2010         # We use mix of both POSIX and Win32 printf format across the tree, so format
2011         # warnings are useless on mingw.
2012         MOZ_C_SUPPORTS_WARNING(-Wno-, format, ac_c_has_wno_format)
2013         MOZ_CXX_SUPPORTS_WARNING(-Wno-, format, ac_cxx_has_wno_format)
2014     else
2015         TARGET_COMPILER_ABI=msvc
2016         HOST_CC='$(CC)'
2017         HOST_CXX='$(CXX)'
2018         HOST_LD='$(LD)'
2019         if test "$AS_BIN"; then
2020             AS="$(basename "$AS_BIN")"
2021         fi
2022         AR='lib'
2023         AR_FLAGS='-NOLOGO -OUT:"$@"'
2024         AR_EXTRACT=
2025         RANLIB='echo not_ranlib'
2026         STRIP='echo not_strip'
2027         PKG_SKIP_STRIP=1
2028         XARGS=xargs
2029         ZIP=zip
2030         UNZIP=unzip
2031         DOXYGEN=:
2032         ASM_SUFFIX=asm
2033         OBJ_SUFFIX=obj
2034         LIB_SUFFIX=lib
2035         DLL_PREFIX=
2036         LIB_PREFIX=
2037         IMPORT_LIB_SUFFIX=lib
2038         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2039         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2040         MKSHLIB_FORCE_ALL=
2041         MKSHLIB_UNFORCE_ALL=
2042         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2043         _USE_CPP_INCLUDE_FLAG=1
2044         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2045         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2046         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2047         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2048         # khuey says we can safely ignore MSVC warning C4251
2049         # MSVC warning C4244 (implicit type conversion may lose data) warns
2050         # and requires workarounds for perfectly valid code.  Also, GCC/clang
2051         # don't warn about it by default. So for consistency/sanity, we turn
2052         # it off on MSVC, too.
2053         # MSVC warning C4345 warns of newly conformant behavior as of VS2003.
2054         # MSVC warning C4351 warns of newly conformant behavior as of VS2005.
2055         # MSVC warning C4482 warns when an enum value is refered specifing the
2056         # name of the enum itself.  This behavior is allowed in C++11, and the
2057         # warning has been removed in VS2012.
2058         # MSVC warning C4800 warns when a value is implicitly cast to bool,
2059         # because this also forces narrowing to a single byte, which can be a
2060         # perf hit.  But this matters so little in practice (and often we want
2061         # that behavior) that it's better to turn it off.
2062         # MSVC warning C4819 warns some UTF-8 characters (e.g. copyright sign)
2063         # on non-Western system locales even if it is in a comment.
2064         CFLAGS="$CFLAGS -wd4244 -wd4819"
2065         CXXFLAGS="$CXXFLAGS -wd4251 -wd4244 -wd4345 -wd4351 -wd4482 -wd4800 -wd4819"
2066         # make 'foo == bar;' error out
2067         CFLAGS="$CFLAGS -we4553"
2068         CXXFLAGS="$CXXFLAGS -we4553"
2069         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib netapi32.lib"
2070         MOZ_DEBUG_FLAGS='-Zi'
2071         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2072         WARNINGS_AS_ERRORS='-WX'
2073         MOZ_OPTIMIZE_FLAGS='-O1'
2074         MOZ_FIX_LINK_PATHS=
2075         DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2076         XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2077         LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2078         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2079         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2080         if test -z "$DEVELOPER_OPTIONS"; then
2081             LDFLAGS="$LDFLAGS -RELEASE"
2082         fi
2083         dnl For profile-guided optimization
2084         PROFILE_GEN_CFLAGS="-GL"
2085         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2086         dnl XXX: PGO builds can fail with warnings treated as errors,
2087         dnl specifically "no profile data available" appears to be
2088         dnl treated as an error sometimes. This might be a consequence
2089         dnl of using WARNINGS_AS_ERRORS in some modules, combined
2090         dnl with the linker doing most of the work in the whole-program
2091         dnl optimization/PGO case. I think it's probably a compiler bug,
2092         dnl but we work around it here.
2093         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2094         dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2095         dnl Probably also a compiler bug, but what can you do?
2096         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2097         LDFLAGS="$LDFLAGS -DYNAMICBASE"
2098         dnl Minimum reqiurement of Gecko is VS2010 or later which supports
2099         dnl both SSSE3 and SSE4.1.
2100         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
2101         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
2102     fi
2103     AC_DEFINE(HAVE_SNPRINTF)
2104     AC_DEFINE(_WINDOWS)
2105     AC_DEFINE(WIN32)
2106     AC_DEFINE(XP_WIN)
2107     AC_DEFINE(XP_WIN32)
2108     AC_DEFINE(HW_THREADS)
2109     AC_DEFINE(STDC_HEADERS)
2110     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2111     TARGET_MD_ARCH=win32
2112     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2113     BIN_SUFFIX='.exe'
2114     MOZ_USER_DIR="Mozilla"
2116     dnl Hardcode to win95 for now - cls
2117     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2119     dnl set NO_X11 defines here as the general check is skipped on win32
2120     no_x=yes
2121     AC_DEFINE(NO_X11)
2123     case "$host" in
2124     *-mingw*)
2125         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2126         if test -n "$L10NBASEDIR"; then
2127             L10NBASEDIR=`cd $L10NBASEDIR && pwd -W`
2128         fi
2129         ;;
2130     esac
2132     case "$host" in
2133     *-mingw*)
2134         if test -z "$MOZ_TOOLS"; then
2135             AC_MSG_ERROR([MOZ_TOOLS is not set])
2136         fi
2137         MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2138         if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2139             AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2140         fi
2141         MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2142         if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2143             AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2144         fi
2145         ;;
2146     esac
2148     case "$host_os" in
2149     cygwin*|msvc*|mks*)
2150         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.])
2151         ;;
2152     esac
2154     case "$target" in
2155     i*86-*)
2156         if test "$HAVE_64BIT_OS"; then
2157             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2158         fi
2160         if test -n "$GNU_CC"; then
2161             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
2162             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
2163             LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup -Wl,--large-address-aware"
2164         else
2165             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
2166             LDFLAGS="$LDFLAGS -SAFESEH"
2167         fi
2169         AC_DEFINE(_X86_)
2170         ;;
2171     x86_64-*)
2172         if test -n "$_WIN32_MSVC"; then
2173             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
2174         fi
2175         AC_DEFINE(_AMD64_)
2176         ;;
2177     *)
2178         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2179         ;;
2180     esac
2181     ;;
2183 *-netbsd*)
2184     DSO_CFLAGS=''
2185     CFLAGS="$CFLAGS -Dunix"
2186     CXXFLAGS="$CXXFLAGS -Dunix"
2187     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2188         DLL_SUFFIX=".so"
2189         DSO_PIC_CFLAGS='-fPIC -DPIC'
2190         DSO_LDOPTS='-shared'
2191         BIN_FLAGS='-Wl,--export-dynamic'
2192     else
2193         DSO_PIC_CFLAGS='-fPIC -DPIC'
2194         DLL_SUFFIX=".so.1.0"
2195         DSO_LDOPTS='-shared'
2196     fi
2197     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2198     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2199     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2200     if test "$LIBRUNPATH"; then
2201         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2202     fi
2203     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@) -o $@'
2204     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@)) -o $@'
2205     ;;
2207 *-openbsd*)
2208     if test "$SO_VERSION"; then
2209         DLL_SUFFIX=".so.$SO_VERSION"
2210     else
2211         DLL_SUFFIX=".so.1.0"
2212     fi
2213     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
2214     DSO_CFLAGS=''
2215     DSO_PIC_CFLAGS='-fPIC'
2216     DSO_LDOPTS='-shared -fPIC'
2217     if test "$LIBRUNPATH"; then
2218         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2219     fi
2220     ;;
2222 *-os2*)
2223     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2224     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2225     AC_DEFINE(OS2)
2226     AC_DEFINE(XP_OS2)
2227     AC_DEFINE(OS2EMX_PLAIN_CHAR)
2228     AC_DEFINE(TCPV40HDRS)
2229     DLL_PREFIX=
2230     LIB_PREFIX=
2231     LIB_SUFFIX=lib
2232     BIN_SUFFIX=".exe"
2233     DLL_SUFFIX=".dll"
2234     IMPORT_LIB_SUFFIX=lib
2235     DSO_PIC_CFLAGS=
2236     AR=emxomfar
2237     AR_FLAGS='r $@'
2238     CFLAGS="$CFLAGS -Zomf"
2239     CXXFLAGS="$CXXFLAGS -Zomf"
2240     DSO_LDOPTS='-Zdll'
2241     BIN_FLAGS='-Zlinker /ST:0x100000'
2242     IMPLIB='emximp -o'
2243     FILTER='true'
2244     LDFLAGS='-Zmap'
2245     WARNINGS_AS_ERRORS='-Werror'
2246     MOZ_DEBUG_FLAGS="-g -fno-inline"
2247     MOZ_OPTIMIZE_FLAGS="-O2"
2248     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2249     DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2250     LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2251     TARGET_MD_ARCH=os2
2252     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
2253     RC=rc.exe
2254     MC=mc.exe
2255     RCFLAGS='-n'
2256     MOZ_USER_DIR="Mozilla"
2257     ZIP="$ZIP -X"
2258     STRIP=lxlite
2259     STRIP_FLAGS="/yua /ydd /yxd /ynl /anp /b- /cs+ /d /i- /ml1 /mr2 /mf2 /r+ /u+ /x- /zs:0 /zx /zd"
2261     if test "$MOZTOOLS"; then
2262         MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
2263     else
2264         AC_MSG_ERROR([MOZTOOLS is not set])
2265     fi
2266     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2267         DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2268         LDFLAGS="$LDFLAGS -Zhigh-mem"
2269         MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
2270         AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2271     fi
2273     # GCC for OS/2 currently predefines these, but we don't want them
2274     _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
2275     _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
2277     AC_CACHE_CHECK(for __declspec(dllexport),
2278         ac_os2_declspec,
2279         [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
2280                         [return 0;],
2281                         ac_os2_declspec="yes",
2282                         ac_os2_declspec="no")])
2283     if test "$ac_os2_declspec" != "yes"; then
2284         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
2285     fi
2286     ;;
2288 *-solaris*)
2289     AC_DEFINE(SOLARIS)
2290     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2291     MOZ_FIX_LINK_PATHS=
2292     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2293     # libraries one level up (e.g. libnspr4.so)
2294     if test "$SOLARIS_SUNPRO_CC"; then
2295        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2296        LIBS="-lCrun -lCstd -lc $LIBS"
2297        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2298        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2299        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2300        LDFLAGS="-xildoff $LDFLAGS"
2301        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2302            _SAVE_LDFLAGS=$LDFLAGS
2303            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
2304            AC_TRY_LINK([#include <stdio.h>],
2305                        [printf("Hello World\n");],
2306                        ,
2307                        [LDFLAGS=$_SAVE_LDFLAGS])
2308        fi
2309        MOZ_OPTIMIZE_FLAGS="-xO4"
2310        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
2311        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
2312        MKSHLIB_FORCE_ALL='-z allextract'
2313        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2314        DSO_LDOPTS='-G'
2315        AR_LIST="$AR t"
2316        AR_EXTRACT="$AR x"
2317        AR_DELETE="$AR d"
2318        AR='$(CXX) -xar'
2319        AR_FLAGS='-o $@'
2320        AS='/usr/ccs/bin/as'
2321        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2322        AS_DASH_C_FLAG=''
2323        TARGET_COMPILER_ABI="sunc"
2324        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2325        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2326        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2327        AC_LANG_SAVE
2328        AC_LANG_CPLUSPLUS
2329        AC_TRY_COMPILE([],
2330            [#if (__SUNPRO_CC < 0x590)
2331            #error "Denied"
2332            #endif],
2333            _BAD_COMPILER=,_BAD_COMPILER=1)
2334        if test -n "$_BAD_COMPILER"; then
2335            _res="no"
2336            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2337        else
2338            _res="yes"
2339        fi
2340        AC_TRY_COMPILE([],
2341            [#if (__SUNPRO_CC >= 0x5100)
2342            #error "Sun C++ 5.10 or above"
2343            #endif],
2344            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2345        if test "$_ABOVE_SS12U1"; then
2346            # disable xannotate
2347            CXXFLAGS="$CXXFLAGS -xannotate=no"
2348        fi
2349        AC_MSG_RESULT([$_res])
2350        AC_LANG_RESTORE
2351     else
2352        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2353        LIBS="-lc $LIBS"
2354        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2355        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2356        ASFLAGS="$ASFLAGS -fPIC"
2357        DSO_LDOPTS='-shared'
2358        WARNINGS_AS_ERRORS='-Werror'
2359        _WARNINGS_CFLAGS=''
2360        _WARNINGS_CXXFLAGS=''
2361        if test "$OS_RELEASE" = "5.3"; then
2362            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2363        fi
2364     fi
2365     if test "$OS_RELEASE" = "5.5.1"; then
2366         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2367     fi
2368     ;;
2370 *-sunos*)
2371     DSO_LDOPTS='-Bdynamic'
2372     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2373     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2374     AC_DEFINE(SUNOS4)
2375     AC_DEFINE(SPRINTF_RETURNS_STRING)
2376     case "$(target_os)" in
2377     sunos4.1*)
2378         DLL_SUFFIX='.so.1.0'
2379         ;;
2380     esac
2381     ;;
2383 *-os2*)
2384     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2385     ;;
2387 esac
2389 case "$target" in
2390 *-*linux*)
2391     # Includes linux-android
2392     AC_DEFINE(XP_LINUX)
2393     ;;
2394 esac
2396 AC_SUBST(MOZ_LINKER)
2397 if test -n "$MOZ_LINKER"; then
2398   AC_DEFINE(MOZ_LINKER)
2401 dnl Only one oddball right now (QNX), but this gives us flexibility
2402 dnl if any other platforms need to override this in the future.
2403 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2405 dnl ========================================================
2406 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2407 dnl by now will not have any way to link most binaries (tests
2408 dnl as well as viewer, apprunner, etc.), because some symbols
2409 dnl will be left out of the "composite" .so's by ld as unneeded.
2410 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2411 dnl they can link in the static libs that provide the missing
2412 dnl symbols.
2413 dnl ========================================================
2414 NO_LD_ARCHIVE_FLAGS=
2415 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2416     NO_LD_ARCHIVE_FLAGS=1
2418 case "$target" in
2419 *-os2*)
2420     NO_LD_ARCHIVE_FLAGS=
2421     ;;
2422 *-aix4.3*|*-aix5*)
2423     NO_LD_ARCHIVE_FLAGS=
2424     ;;
2425 *-mingw*)
2426     if test -z "$GNU_CC"; then
2427         NO_LD_ARCHIVE_FLAGS=
2428     fi
2429     ;;
2430 esac
2431 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2433 dnl ========================================================
2434 dnl = Flags to strip unused symbols from .so components and
2435 dnl = to export jemalloc symbols when linking a program
2436 dnl ========================================================
2437 case "$target" in
2438     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2439         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2440         ;;
2441     *-solaris*)
2442         if test -z "$GNU_CC"; then
2443          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2444         else
2445          if test -z "$GCC_USE_GNU_LD"; then
2446           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2447          else
2448           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2449          fi
2450         fi
2451         ;;
2452     *-darwin*)
2453         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2454         ;;
2455     *-mingw*)
2456         if test -n "$GNU_CC"; then
2457            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2458         fi
2459         ;;
2460 esac
2462 if test -z "$COMPILE_ENVIRONMENT"; then
2463     SKIP_COMPILER_CHECKS=1
2464     SKIP_LIBRARY_CHECKS=1
2467 dnl ========================================================
2468 dnl =
2469 dnl = Debugging Options
2470 dnl =
2471 dnl = These must come before MOZ_COMPILER_OPTS so that MOZ_COMPILER_OPTS
2472 dnl = sees any debug flags set by the user.
2473 dnl =
2474 dnl ========================================================
2475 MOZ_ARG_HEADER(Debugging)
2477 dnl ========================================================
2478 dnl = Debug info is ON by default.
2479 dnl ========================================================
2480 if test -z "$MOZ_DEBUG_FLAGS"; then
2481   MOZ_DEBUG_FLAGS="-g"
2484 MOZ_ARG_ENABLE_STRING(debug,
2485 [  --enable-debug[=DBG]    Enable building with developer debug info
2486                            (using compiler flags DBG)],
2487 [ if test "$enableval" != "no"; then
2488     MOZ_DEBUG=1
2489     if test -n "$enableval" -a "$enableval" != "yes"; then
2490         MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
2491         _MOZ_DEBUG_FLAGS_SET=1
2492     fi
2493   else
2494     MOZ_DEBUG=
2495   fi ],
2496   MOZ_DEBUG=)
2498 MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG -DTRACING"
2499 MOZ_ARG_WITH_STRING(debug-label,
2500 [  --with-debug-label=LABELS
2501                           Define DEBUG_<value> for each comma-separated
2502                           value given.],
2503 [ for option in `echo $withval | sed 's/,/ /g'`; do
2504     MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${option}"
2505 done])
2507 MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
2509 if test -n "$MOZ_DEBUG"; then
2510     AC_MSG_CHECKING([for valid debug flags])
2511     _SAVE_CFLAGS=$CFLAGS
2512     CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS"
2513     AC_TRY_COMPILE([#include <stdio.h>],
2514         [printf("Hello World\n");],
2515         _results=yes,
2516         _results=no)
2517     AC_MSG_RESULT([$_results])
2518     if test "$_results" = "no"; then
2519         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_DEBUG_FLAGS])
2520     fi
2521     CFLAGS=$_SAVE_CFLAGS
2524 dnl ========================================================
2525 dnl = Enable generation of debug symbols
2526 dnl ========================================================
2527 MOZ_ARG_ENABLE_STRING(debug-symbols,
2528 [  --enable-debug-symbols[=DBG]
2529                           Enable debugging symbols (using compiler flags DBG)],
2530 [ if test "$enableval" != "no"; then
2531       MOZ_DEBUG_SYMBOLS=1
2532       if test -n "$enableval" -a "$enableval" != "yes"; then
2533           if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
2534               MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
2535           else
2536               AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
2537           fi
2538       fi
2539   else
2540       MOZ_DEBUG_SYMBOLS=
2541   fi ],
2542   MOZ_DEBUG_SYMBOLS=1)
2544 if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
2545     AC_DEFINE(MOZ_DEBUG_SYMBOLS)
2546     export MOZ_DEBUG_SYMBOLS
2549 MOZ_COMPILER_OPTS
2550 if test -z "$SKIP_COMPILER_CHECKS"; then
2551 dnl Checks for typedefs, structures, and compiler characteristics.
2552 dnl ========================================================
2553 AC_HEADER_STDC
2554 AC_C_CONST
2555 AC_TYPE_MODE_T
2556 AC_TYPE_OFF_T
2557 AC_TYPE_PID_T
2558 AC_TYPE_SIZE_T
2559 AC_LANG_CPLUSPLUS
2560 AC_LANG_C
2561 AC_MSG_CHECKING(for ssize_t)
2562 AC_CACHE_VAL(ac_cv_type_ssize_t,
2563  [AC_TRY_COMPILE([#include <stdio.h>
2564                   #include <sys/types.h>],
2565                  [ssize_t foo = 0;],
2566                  [ac_cv_type_ssize_t=true],
2567                  [ac_cv_type_ssize_t=false])])
2568 if test "$ac_cv_type_ssize_t" = true ; then
2569   AC_DEFINE(HAVE_SSIZE_T)
2570   AC_MSG_RESULT(yes)
2571 else
2572   AC_MSG_RESULT(no)
2574 AC_STRUCT_ST_BLKSIZE
2575 AC_MSG_CHECKING(for siginfo_t)
2576 AC_CACHE_VAL(ac_cv_siginfo_t,
2577  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
2578                   #include <signal.h>],
2579                  [siginfo_t* info;],
2580                  [ac_cv_siginfo_t=true],
2581                  [ac_cv_siginfo_t=false])])
2582 if test "$ac_cv_siginfo_t" = true ; then
2583   AC_DEFINE(HAVE_SIGINFO_T)
2584   AC_MSG_RESULT(yes)
2585 else
2586   AC_MSG_RESULT(no)
2589 dnl Check for int64, uint, and uint_t.
2590 dnl ========================================================
2591 AC_MSG_CHECKING(for int64)
2592 AC_CACHE_VAL(ac_cv_int64,
2593  [AC_TRY_COMPILE([#include <stdio.h>
2594                   #include <sys/types.h>],
2595                  [int64 foo = 0;],
2596                  [ac_cv_int64=true],
2597                  [ac_cv_int64=false])])
2598 if test "$ac_cv_int64" = true ; then
2599   AC_DEFINE(HAVE_INT64)
2600   AC_MSG_RESULT(yes)
2601 else
2602   AC_MSG_RESULT(no)
2604 AC_MSG_CHECKING(for uint)
2605 AC_CACHE_VAL(ac_cv_uint,
2606  [AC_TRY_COMPILE([#include <stdio.h>
2607                   #include <sys/types.h>],
2608                  [uint foo = 0;],
2609                  [ac_cv_uint=true],
2610                  [ac_cv_uint=false])])
2611 if test "$ac_cv_uint" = true ; then
2612   AC_DEFINE(HAVE_UINT)
2613   AC_MSG_RESULT(yes)
2614 else
2615   AC_MSG_RESULT(no)
2617 AC_MSG_CHECKING(for uint_t)
2618 AC_CACHE_VAL(ac_cv_uint_t,
2619  [AC_TRY_COMPILE([#include <stdio.h>
2620                   #include <sys/types.h>],
2621                  [uint_t foo = 0;],
2622                  [ac_cv_uint_t=true],
2623                  [ac_cv_uint_t=false])])
2624 if test "$ac_cv_uint_t" = true ; then
2625   AC_DEFINE(HAVE_UINT_T)
2626   AC_MSG_RESULT(yes)
2627 else
2628   AC_MSG_RESULT(no)
2631 dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
2632 dnl are defined when compiling C++ but not C.  Since the result of this
2633 dnl test is used only in C++, do it in C++.
2634 AC_LANG_CPLUSPLUS
2636 AC_MSG_CHECKING(for uname.domainname)
2637 AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
2638     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2639         [ struct utsname *res; char *domain;
2640             (void)uname(res);  if (res != 0) { domain = res->domainname; } ],
2641         [ac_cv_have_uname_domainname_field=true],
2642         [ac_cv_have_uname_domainname_field=false])])
2644 if test "$ac_cv_have_uname_domainname_field" = "true"; then
2645     AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
2646     AC_MSG_RESULT(yes)
2647 else
2648     AC_MSG_RESULT(no)
2651 AC_MSG_CHECKING(for uname.__domainname)
2652 AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
2653     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2654         [ struct utsname *res; char *domain;
2655             (void)uname(res);  if (res != 0) { domain = res->__domainname; } ],
2656         [ac_cv_have_uname_us_domainname_field=true],
2657         [ac_cv_have_uname_us_domainname_field=false])])
2659 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
2660     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
2661     AC_MSG_RESULT(yes)
2662 else
2663     AC_MSG_RESULT(no)
2666 MOZ_CXX11
2668 AC_LANG_CPLUSPLUS
2670 dnl Check for usable char16_t (2 bytes, unsigned)
2671 dnl (we might not need the unsignedness check anymore)
2672 AC_CACHE_CHECK(for usable char16_t (2 bytes, unsigned),
2673     ac_cv_have_usable_char16_t,
2674     [AC_TRY_COMPILE([$configure_static_assert_macros],
2675                     [CONFIGURE_STATIC_ASSERT(sizeof(char16_t) == 2);
2676                      CONFIGURE_STATIC_ASSERT(char16_t(-1) > char16_t(0));
2677                      CONFIGURE_STATIC_ASSERT(sizeof((u"hello")[0]) == 2);
2678                      CONFIGURE_STATIC_ASSERT(sizeof(u'a') == 2);
2679                      CONFIGURE_STATIC_ASSERT(u'\xFFFF' > u'\x0')],
2680                     ac_cv_have_usable_char16_t="yes",
2681                     ac_cv_have_usable_char16_t="no")])
2682 if test "$ac_cv_have_usable_char16_t" = "yes"; then
2683     AC_DEFINE(HAVE_CPP_CHAR16_T)
2684     HAVE_CPP_CHAR16_T=1
2685 elif test "$GNU_CXX"; then
2686     CXXFLAGS="$_SAVE_CXXFLAGS"
2689 dnl Check for usable wchar_t (2 bytes, unsigned)
2690 dnl (we really don't need the unsignedness check anymore)
2691 dnl ========================================================
2693 AC_CACHE_CHECK(for usable wchar_t (2 bytes, unsigned),
2694     ac_cv_have_usable_wchar_v2,
2695     [AC_TRY_COMPILE([#include <stddef.h>
2696                      $configure_static_assert_macros],
2697                     [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
2698                      CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
2699                     ac_cv_have_usable_wchar_v2="yes",
2700                     ac_cv_have_usable_wchar_v2="no")])
2701 if test "$ac_cv_have_usable_wchar_v2" = "yes"; then
2702     AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
2703     HAVE_CPP_2BYTE_WCHAR_T=1
2704 elif test "$ac_cv_have_usable_char16_t" != "yes"; then
2705 dnl This is really gcc-only
2706 dnl Do this test using CXX only since some versions of gcc
2707 dnl 2.95-2.97 have a signed wchar_t in c++ only and some versions
2708 dnl only have short-wchar support for c++.
2709 dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
2711     _SAVE_CXXFLAGS=$CXXFLAGS
2712     CXXFLAGS="$CXXFLAGS -fshort-wchar"
2714     AC_CACHE_CHECK(for compiler -fshort-wchar option,
2715         ac_cv_have_usable_wchar_option_v2,
2716         [AC_TRY_LINK([#include <stddef.h>
2717                       $configure_static_assert_macros],
2718                      [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
2719                       CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
2720                      ac_cv_have_usable_wchar_option_v2="yes",
2721                      ac_cv_have_usable_wchar_option_v2="no")])
2723     if test "$ac_cv_have_usable_wchar_option_v2" = "yes"; then
2724         AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
2725         HAVE_CPP_2BYTE_WCHAR_T=1
2726         if test "$OS_TARGET" = Android; then
2727             WCHAR_CFLAGS="-fshort-wchar -Wl,--no-wchar-size-warning"
2728             CXXFLAGS="$CXXFLAGS -Wl,--no-wchar-size-warning"
2729             CFLAGS="$CFLAGS -Wl,--no-wchar-size-warning"
2730             DSO_LDOPTS="$DSO_LDOPTS -Wl,--no-wchar-size-warning"
2731         else
2732             WCHAR_CFLAGS="-fshort-wchar"
2733         fi
2734     else
2735         CXXFLAGS=$_SAVE_CXXFLAGS
2736     fi
2739 AC_LANG_C
2741 dnl Check for .hidden assembler directive and visibility attribute.
2742 dnl Borrowed from glibc configure.in
2743 dnl ===============================================================
2744 if test "$GNU_CC"; then
2745   AC_CACHE_CHECK(for visibility(hidden) attribute,
2746                  ac_cv_visibility_hidden,
2747                  [cat > conftest.c <<EOF
2748                   int foo __attribute__ ((visibility ("hidden"))) = 1;
2750                   ac_cv_visibility_hidden=no
2751                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2752                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2753                       ac_cv_visibility_hidden=yes
2754                     fi
2755                   fi
2756                   rm -f conftest.[cs]
2757                  ])
2758   if test "$ac_cv_visibility_hidden" = "yes"; then
2759     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
2761     AC_CACHE_CHECK(for visibility(default) attribute,
2762                    ac_cv_visibility_default,
2763                    [cat > conftest.c <<EOF
2764                     int foo __attribute__ ((visibility ("default"))) = 1;
2766                     ac_cv_visibility_default=no
2767                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2768                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2769                         ac_cv_visibility_default=yes
2770                       fi
2771                     fi
2772                     rm -f conftest.[cs]
2773                    ])
2774     if test "$ac_cv_visibility_default" = "yes"; then
2775       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
2777       AC_CACHE_CHECK(for visibility pragma support,
2778                      ac_cv_visibility_pragma,
2779                      [cat > conftest.c <<EOF
2780 #pragma GCC visibility push(hidden)
2781                       int foo_hidden = 1;
2782 #pragma GCC visibility push(default)
2783                       int foo_default = 1;
2785                       ac_cv_visibility_pragma=no
2786                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2787                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
2788                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
2789                             ac_cv_visibility_pragma=yes
2790                           fi
2791                         fi
2792                       fi
2793                       rm -f conftest.[cs]
2794                     ])
2795       if test "$ac_cv_visibility_pragma" = "yes"; then
2796         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
2797                        ac_cv_have_visibility_class_bug,
2798                        [cat > conftest.c <<EOF
2799 #pragma GCC visibility push(hidden)
2800 struct __attribute__ ((visibility ("default"))) TestStruct {
2801   static void Init();
2803 __attribute__ ((visibility ("default"))) void TestFunc() {
2804   TestStruct::Init();
2807                        ac_cv_have_visibility_class_bug=no
2808                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2809                          ac_cv_have_visibility_class_bug=yes
2810                        else
2811                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
2812                            ac_cv_have_visibility_class_bug=yes
2813                          fi
2814                        fi
2815                        rm -rf conftest.{c,S}
2816                        ])
2818         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
2819                        ac_cv_have_visibility_builtin_bug,
2820                        [cat > conftest.c <<EOF
2821 #pragma GCC visibility push(hidden)
2822 #pragma GCC visibility push(default)
2823 #include <string.h>
2824 #pragma GCC visibility pop
2826 __attribute__ ((visibility ("default"))) void Func() {
2827   char c[[100]];
2828   memset(c, 0, sizeof(c));
2831                        ac_cv_have_visibility_builtin_bug=no
2832                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2833                          ac_cv_have_visibility_builtin_bug=yes
2834                        else
2835                          if test `grep -c "@PLT" conftest.S` = 0; then
2836                            ac_cv_visibility_builtin_bug=yes
2837                          fi
2838                        fi
2839                        rm -f conftest.{c,S}
2840                        ])
2841         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
2842                 "$ac_cv_have_visibility_class_bug" = "no"; then
2843           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
2844           WRAP_SYSTEM_INCLUDES=1
2845           STL_FLAGS='-I$(DIST)/stl_wrappers'
2846           WRAP_STL_INCLUDES=1
2847         else
2848           VISIBILITY_FLAGS='-fvisibility=hidden'
2849         fi # have visibility pragma bug
2850       fi   # have visibility pragma
2851     fi     # have visibility(default) attribute
2852   fi       # have visibility(hidden) attribute
2853 fi         # GNU_CC
2855 # visibility hidden flag for Sun Studio on Solaris
2856 if test "$SOLARIS_SUNPRO_CC"; then
2857 VISIBILITY_FLAGS='-xldscope=hidden'
2858 fi         # Sun Studio on Solaris
2860 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2861 AC_SUBST(VISIBILITY_FLAGS)
2863 MOZ_GCC_PR49911
2864 MOZ_GCC_PR39608
2865 if test "$OS_TARGET" != WINNT; then
2866     # Only run this test with clang on non-Windows platforms, because clang
2867     # cannot do enough code gen for now to make this test work correctly.
2868     MOZ_LLVM_PR8927
2871 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
2872 dnl ========================================================
2873 if test "$GNU_CC"; then
2874   CFLAGS_save="${CFLAGS}"
2875   CFLAGS="${CFLAGS} -Werror"
2876   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
2877                  ac_cv_force_align_arg_pointer,
2878                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
2879                                  [],
2880                                  ac_cv_force_align_arg_pointer="yes",
2881                                  ac_cv_force_align_arg_pointer="no")])
2882   CFLAGS="${CFLAGS_save}"
2883   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
2884     HAVE_GCC_ALIGN_ARG_POINTER=1
2885   else
2886     HAVE_GCC_ALIGN_ARG_POINTER=
2887   fi
2889 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
2891 dnl Checks for header files.
2892 dnl ========================================================
2893 AC_HEADER_DIRENT
2894 case "$target_os" in
2895 freebsd*|openbsd*)
2896 # for stuff like -lXshm
2897     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
2898     ;;
2899 esac
2900 MOZ_CHECK_COMMON_HEADERS
2902 dnl These are all the places some variant of statfs can be hiding.
2903 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
2905 dnl Quota support
2906 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
2907 MOZ_CHECK_HEADERS([linux/quota.h],,,[#include <sys/socket.h>])
2909 dnl SCTP support - needs various network include headers
2910 MOZ_CHECK_HEADERS([linux/if_addr.h linux/rtnetlink.h],,,[#include <sys/socket.h>])
2912 MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
2914 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
2915 AC_CACHE_CHECK(for sockaddr_in.sin_len,
2916                    ac_cv_sockaddr_in_sin_len,
2917                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2918                                     #include <sys/types.h>
2919                                     #endif
2920                                     #include <netinet/in.h>
2921                                     struct sockaddr_in x;
2922                                     void *foo = (void*) &x.sin_len;],
2923                                    [],
2924                                    [ac_cv_sockaddr_in_sin_len=true],
2925                                    [ac_cv_sockaddr_in_sin_len=false])])
2926 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
2927   AC_DEFINE(HAVE_SIN_LEN)
2928 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
2929   AC_DEFINE(HAVE_SCONN_LEN)
2932 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
2933                ac_cv_sockaddr_in6_sin6_len,
2934                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2935                                 #include <sys/types.h>
2936                                 #endif
2937                                 #include <netinet/in.h>
2938                                 struct sockaddr_in6 x;
2939                                 void *foo = (void*) &x.sin6_len;],
2940                                [],
2941                                [ac_cv_sockaddr_in6_sin6_len=true],
2942                                [ac_cv_sockaddr_in6_sin6_len=false])])
2943 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
2944   AC_DEFINE(HAVE_SIN6_LEN)
2947 AC_CACHE_CHECK(for sockaddr.sa_len,
2948                ac_cv_sockaddr_sa_len,
2949                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2950                                 #include <sys/types.h>
2951                                 #endif
2952                                 #include <sys/socket.h>
2953                                 struct sockaddr x;
2954                                 void *foo = (void*) &x.sa_len;],
2955                                [],
2956                                [ac_cv_sockaddr_sa_len=true],
2957                                [ac_cv_sockaddr_sa_len=false])])
2958 if test "$ac_cv_sockaddr_sa_len" = true ; then
2959   AC_DEFINE(HAVE_SA_LEN)
2962 AC_ARG_ENABLE(dtrace,
2963               [  --enable-dtrace         build with dtrace support if available (default=no)],
2964               [enable_dtrace="yes"],)
2965 if test "x$enable_dtrace" = "xyes"; then
2966   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
2967   if test -n "$HAVE_DTRACE"; then
2968       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
2969   else
2970       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
2971   fi
2973 AC_SUBST(HAVE_DTRACE)
2975 case $target in
2976 *-aix4.3*|*-aix5*)
2977         ;;
2979         MOZ_CHECK_HEADERS(sys/cdefs.h)
2980         ;;
2981 esac
2983 MOZ_LINUX_PERF_EVENT
2985 dnl Checks for libraries.
2986 dnl ========================================================
2987 case $target in
2988 *-hpux11.*)
2989         ;;
2991         AC_CHECK_LIB(c_r, gethostbyname_r)
2992         ;;
2993 esac
2995 dnl We don't want to link with libdl even if it's present on OS X, since
2996 dnl it's not used and not part of the default installation. OS/2 has dlfcn
2997 dnl in libc.
2998 dnl We don't want to link against libm or libpthread on Darwin since
2999 dnl they both are just symlinks to libSystem and explicitly linking
3000 dnl against libSystem causes issues when debugging (see bug 299601).
3001 case $target in
3002 *-darwin*)
3003     ;;
3004 *-os2*)
3005     ;;
3007     AC_SEARCH_LIBS(dlopen, dl,
3008         MOZ_CHECK_HEADER(dlfcn.h,
3009         AC_DEFINE(HAVE_DLOPEN)))
3010     ;;
3011 esac
3013 _SAVE_CFLAGS="$CFLAGS"
3014 CFLAGS="$CFLAGS -D_GNU_SOURCE"
3015 AC_CHECK_FUNCS(dladdr memmem)
3016 CFLAGS="$_SAVE_CFLAGS"
3018 if test ! "$GNU_CXX"; then
3020     case $target in
3021     *-aix*)
3022         AC_CHECK_LIB(C_r, demangle)
3023         ;;
3024      *)
3025         AC_CHECK_LIB(C, demangle)
3026         ;;
3027      esac
3030 dnl OS/2 has socket in libc.
3031 case $target in
3032 *-os2*)
3033     ;;
3035     AC_CHECK_LIB(socket, socket)
3036 esac
3038 XLDFLAGS="$X_LIBS"
3039 XLIBS="$X_EXTRA_LIBS"
3041 dnl ========================================================
3042 dnl Checks for X libraries.
3043 dnl Ordering is important.
3044 dnl Xt is dependent upon SM as of X11R6
3045 dnl ========================================================
3046 if test "$no_x" = "yes"; then
3047     AC_DEFINE(NO_X11)
3048 else
3049     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
3050         XLIBS="-lX11 $XLIBS"
3051         _SAVE_LDFLAGS="$LDFLAGS"
3052         LDFLAGS="$XLDFLAGS $LDFLAGS"
3053         AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
3054                 [MISSING_X="$MISSING_X -lX11"], $XLIBS)
3055         AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
3056                 [MISSING_X="$MISSING_X -lXext"], $XLIBS)
3058         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
3059         unset ac_cv_lib_Xt_XtFree
3060             AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
3061             AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
3062         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
3063                     [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
3064         ])
3066     # AIX needs the motif library linked before libXt to prevent
3067     # crashes in plugins linked against Motif - Bug #98892
3068     case "${target_os}" in
3069     aix*)
3070         XT_LIBS="-lXm $XT_LIBS"
3071         ;;
3072     esac
3074     dnl ========================================================
3075     dnl = Check for XShm
3076     dnl ========================================================
3077     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
3078         $XLIBS $XEXT_LIBS)
3080     dnl ========================================================
3081     dnl = Check for Xss
3082     dnl ========================================================
3083     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
3084         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
3085             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
3086              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
3088         LDFLAGS="$_SAVE_LDFLAGS"
3089 fi # $no_x
3091 AC_SUBST(XCFLAGS)
3092 AC_SUBST(XLDFLAGS)
3093 AC_SUBST(XLIBS)
3094 AC_SUBST(XEXT_LIBS)
3095 AC_SUBST(XT_LIBS)
3096 AC_SUBST(XSS_LIBS)
3098 dnl ========================================================
3099 dnl = pthread support
3100 dnl = Start by checking whether the system support pthreads
3101 dnl ========================================================
3102 case "$target_os" in
3103 darwin*)
3104     MOZ_USE_PTHREADS=1
3105     ;;
3107     MOZ_CHECK_PTHREADS(pthreads,
3108         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
3109         MOZ_CHECK_PTHREADS(pthread,
3110             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
3111             MOZ_CHECK_PTHREADS(c_r,
3112                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
3113                 MOZ_CHECK_PTHREADS(c,
3114                     MOZ_USE_PTHREADS=1
3115                 )
3116             )
3117         )
3118     )
3119     ;;
3120 esac
3122 dnl ========================================================
3123 dnl Check the command line for --with-pthreads
3124 dnl ========================================================
3125 MOZ_ARG_WITH_BOOL(pthreads,
3126 [  --with-pthreads         Force use of system pthread library with NSPR ],
3127 [ if test "$MOZ_USE_PTHREADS"x = x; then
3128     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
3129 fi],
3130     MOZ_USE_PTHREADS=
3131     _PTHREAD_LDFLAGS=
3134 dnl ========================================================
3135 dnl Do the platform specific pthread hackery
3136 dnl ========================================================
3137 if test "$MOZ_USE_PTHREADS"x != x
3138 then
3139         dnl
3140         dnl See if -pthread is supported.
3141         dnl
3142         rm -f conftest*
3143         ac_cv_have_dash_pthread=no
3144         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
3145         echo 'int main() { return 0; }' | cat > conftest.c
3146         ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
3147         if test $? -eq 0; then
3148                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3149                         ac_cv_have_dash_pthread=yes
3150                 case "$target_os" in
3151                 freebsd*)
3152 # Freebsd doesn't use -pthread for compiles, it uses them for linking
3153                 ;;
3154                 *)
3155                             CFLAGS="$CFLAGS -pthread"
3156                             CXXFLAGS="$CXXFLAGS -pthread"
3157                 ;;
3158                 esac
3159                 fi
3160         fi
3161         rm -f conftest*
3162     AC_MSG_RESULT($ac_cv_have_dash_pthread)
3164         dnl
3165         dnl See if -pthreads is supported.
3166         dnl
3167     ac_cv_have_dash_pthreads=no
3168     if test "$ac_cv_have_dash_pthread" = "no"; then
3169             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
3170         echo 'int main() { return 0; }' | cat > conftest.c
3171             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
3172         if test $? -eq 0; then
3173                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3174                             ac_cv_have_dash_pthreads=yes
3175                             CFLAGS="$CFLAGS -pthreads"
3176                             CXXFLAGS="$CXXFLAGS -pthreads"
3177                     fi
3178             fi
3179             rm -f conftest*
3180         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
3181     fi
3183         case "$target" in
3184             *-*-freebsd*)
3185                         AC_DEFINE(_REENTRANT)
3186                         AC_DEFINE(_THREAD_SAFE)
3187                         dnl -pthread links in -lpthread, so don't specify it explicitly.
3188                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3189                                 _PTHREAD_LDFLAGS="-pthread"
3190                         fi
3191                         ;;
3193             *-*-openbsd*|*-*-bsdi*)
3194                         AC_DEFINE(_REENTRANT)
3195                         AC_DEFINE(_THREAD_SAFE)
3196                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3197                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3198                 _PTHREAD_LDFLAGS="-pthread"
3199                         fi
3200                         ;;
3202             *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3203                         AC_DEFINE(_REENTRANT)
3204                         ;;
3206             *-aix4.3*|*-aix5*)
3207                         AC_DEFINE(_REENTRANT)
3208                         ;;
3210             *-hpux11.*)
3211                         AC_DEFINE(_REENTRANT)
3212                         ;;
3214             *-*-solaris*)
3215                         AC_DEFINE(_REENTRANT)
3216                         if test "$SOLARIS_SUNPRO_CC"; then
3217                                 CFLAGS="$CFLAGS -mt"
3218                                 CXXFLAGS="$CXXFLAGS -mt"
3219                         fi
3220                         ;;
3221         esac
3222     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3223     AC_SUBST(MOZ_USE_PTHREADS)
3227 dnl Checks for library functions.
3228 dnl ========================================================
3229 AC_PROG_GCC_TRADITIONAL
3230 AC_FUNC_MEMCMP
3231 AC_CHECK_FUNCS(random strerror lchown fchmod snprintf memmove rint stat64 lstat64 truncate64 setbuf isatty)
3232 AC_CHECK_FUNCS(statvfs64 statvfs statfs64 statfs)
3233 AC_CHECK_FUNCS(flockfile getpagesize)
3234 AC_CHECK_FUNCS(localtime_r strtok_r)
3236 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
3237 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
3238                ac_cv_clock_monotonic,
3239                [for libs in "" -lrt; do
3240                     _SAVE_LIBS="$LIBS"
3241                     LIBS="$LIBS $libs"
3242                     AC_TRY_LINK([#include <time.h>],
3243                                  [ struct timespec ts;
3244                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
3245                                  ac_cv_clock_monotonic=$libs
3246                                  LIBS="$_SAVE_LIBS"
3247                                  break,
3248                                  ac_cv_clock_monotonic=no)
3249                     LIBS="$_SAVE_LIBS"
3250                 done])
3251 if test "$ac_cv_clock_monotonic" != "no"; then
3252     HAVE_CLOCK_MONOTONIC=1
3253     REALTIME_LIBS=$ac_cv_clock_monotonic
3254     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3255     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3256     AC_SUBST(REALTIME_LIBS)
3259 dnl check for wcrtomb/mbrtowc
3260 dnl =======================================================================
3261 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3262 AC_LANG_SAVE
3263 AC_LANG_CPLUSPLUS
3264 AC_CACHE_CHECK(for wcrtomb,
3265     ac_cv_have_wcrtomb,
3266     [AC_TRY_LINK([#include <wchar.h>],
3267                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3268                  ac_cv_have_wcrtomb="yes",
3269                  ac_cv_have_wcrtomb="no")])
3270 if test "$ac_cv_have_wcrtomb" = "yes"; then
3271     AC_DEFINE(HAVE_WCRTOMB)
3273 AC_CACHE_CHECK(for mbrtowc,
3274     ac_cv_have_mbrtowc,
3275     [AC_TRY_LINK([#include <wchar.h>],
3276                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3277                  ac_cv_have_mbrtowc="yes",
3278                  ac_cv_have_mbrtowc="no")])
3279 if test "$ac_cv_have_mbrtowc" = "yes"; then
3280     AC_DEFINE(HAVE_MBRTOWC)
3282 AC_LANG_RESTORE
3285 AC_CACHE_CHECK(
3286     [for res_ninit()],
3287     ac_cv_func_res_ninit,
3288     [AC_TRY_LINK([
3289         #ifdef linux
3290         #define _BSD_SOURCE 1
3291         #endif
3292         #include <resolv.h>
3293         ],
3294         [int foo = res_ninit(&_res);],
3295         [ac_cv_func_res_ninit=yes],
3296         [ac_cv_func_res_ninit=no])
3297     ])
3299 if test "$ac_cv_func_res_ninit" = "yes"; then
3300     AC_DEFINE(HAVE_RES_NINIT)
3301 dnl must add the link line we do something as foolish as this... dougt
3302 dnl else
3303 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3304 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3307 AC_LANG_CPLUSPLUS
3308 AC_CACHE_CHECK(
3309     [for gnu_get_libc_version()],
3310     ac_cv_func_gnu_get_libc_version,
3311     [AC_TRY_LINK([
3312         #ifdef HAVE_GNU_LIBC_VERSION_H
3313         #include <gnu/libc-version.h>
3314         #endif
3315         ],
3316         [const char *glibc_version = gnu_get_libc_version();],
3317         [ac_cv_func_gnu_get_libc_version=yes],
3318         [ac_cv_func_gnu_get_libc_version=no]
3319         )]
3320     )
3322 if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
3323     AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
3326 case $target_os in
3327     darwin*|mingw*|os2*)
3328         ;;
3329     *)
3331 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3332     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3333         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3334 _SAVE_LIBS=$LIBS
3335 LIBS="$LIBS $_ICONV_LIBS"
3336 AC_CACHE_CHECK(
3337     [for iconv()],
3338     ac_cv_func_iconv,
3339     [AC_TRY_LINK([
3340         #include <stdlib.h>
3341         #include <iconv.h>
3342         ],
3343         [
3344             iconv_t h = iconv_open("", "");
3345             iconv(h, NULL, NULL, NULL, NULL);
3346             iconv_close(h);
3347         ],
3348         [ac_cv_func_iconv=yes],
3349         [ac_cv_func_iconv=no]
3350         )]
3351     )
3352 if test "$ac_cv_func_iconv" = "yes"; then
3353     AC_DEFINE(HAVE_ICONV)
3354     DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
3355     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3356     LIBICONV="$_ICONV_LIBS"
3357     AC_CACHE_CHECK(
3358         [for iconv() with const input],
3359         ac_cv_func_const_iconv,
3360         [AC_TRY_COMPILE([
3361             #include <stdlib.h>
3362             #include <iconv.h>
3363             ],
3364             [
3365                 const char *input = "testing";
3366                 iconv_t h = iconv_open("", "");
3367                 iconv(h, &input, NULL, NULL, NULL);
3368                 iconv_close(h);
3369             ],
3370             [ac_cv_func_const_iconv=yes],
3371             [ac_cv_func_const_iconv=no]
3372             )]
3373         )
3374     if test "$ac_cv_func_const_iconv" = "yes"; then
3375         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3376     fi
3378 LIBS=$_SAVE_LIBS
3380     ;;
3381 esac
3383 AM_LANGINFO_CODESET
3385 AC_LANG_C
3387 dnl **********************
3388 dnl *** va_copy checks ***
3389 dnl **********************
3390 dnl we currently check for all three va_copy possibilities, so we get
3391 dnl all results in config.log for bug reports.
3392 AC_MSG_CHECKING(for an implementation of va_copy())
3393 AC_CACHE_VAL(ac_cv_va_copy,[
3394     AC_TRY_RUN([
3395         #include <stdarg.h>
3396         void f (int i, ...) {
3397             va_list args1, args2;
3398             va_start (args1, i);
3399             va_copy (args2, args1);
3400             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3401                 exit (1);
3402             va_end (args1); va_end (args2);
3403         }
3404         int main() { f (0, 42); return 0; }],
3405         ac_cv_va_copy=yes,
3406         ac_cv_va_copy=no,
3407         ac_cv_va_copy=no
3408     )
3410 AC_MSG_RESULT($ac_cv_va_copy)
3411 AC_MSG_CHECKING(for an implementation of __va_copy())
3412 AC_CACHE_VAL(ac_cv___va_copy,[
3413     AC_TRY_RUN([
3414         #include <stdarg.h>
3415         void f (int i, ...) {
3416             va_list args1, args2;
3417             va_start (args1, i);
3418             __va_copy (args2, args1);
3419             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3420                 exit (1);
3421             va_end (args1); va_end (args2);
3422         }
3423         int main() { f (0, 42); return 0; }],
3424         ac_cv___va_copy=yes,
3425         ac_cv___va_copy=no,
3426         ac_cv___va_copy=no
3427     )
3429 AC_MSG_RESULT($ac_cv___va_copy)
3430 AC_MSG_CHECKING(whether va_lists can be copied by value)
3431 AC_CACHE_VAL(ac_cv_va_val_copy,[
3432     AC_TRY_RUN([
3433         #include <stdarg.h>
3434         void f (int i, ...) {
3435             va_list args1, args2;
3436             va_start (args1, i);
3437             args2 = args1;
3438             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3439                 exit (1);
3440             va_end (args1); va_end (args2);
3441         }
3442         int main() { f (0, 42); return 0; }],
3443         ac_cv_va_val_copy=yes,
3444         ac_cv_va_val_copy=no,
3445         ac_cv_va_val_copy=yes
3446     )
3448 if test "x$ac_cv_va_copy" = "xyes"; then
3449     AC_DEFINE(VA_COPY, va_copy)
3450     AC_DEFINE(HAVE_VA_COPY)
3451 elif test "x$ac_cv___va_copy" = "xyes"; then
3452     AC_DEFINE(VA_COPY, __va_copy)
3453     AC_DEFINE(HAVE_VA_COPY)
3456 if test "x$ac_cv_va_val_copy" = "xno"; then
3457    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3459 AC_MSG_RESULT($ac_cv_va_val_copy)
3461 dnl ===================================================================
3462 dnl ========================================================
3463 dnl Put your C++ language/feature checks below
3464 dnl ========================================================
3465 AC_LANG_CPLUSPLUS
3467 ARM_ABI_PREFIX=
3468 if test "$GNU_CC"; then
3469   if test "$CPU_ARCH" = "arm" ; then
3470     AC_CACHE_CHECK(for ARM EABI,
3471         ac_cv_gcc_arm_eabi,
3472         [AC_TRY_COMPILE([],
3473                         [
3474 #if defined(__ARM_EABI__)
3475   return 0;
3476 #else
3477 #error Not ARM EABI.
3478 #endif
3479                         ],
3480                         ac_cv_gcc_arm_eabi="yes",
3481                         ac_cv_gcc_arm_eabi="no")])
3482     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
3483         HAVE_ARM_EABI=1
3484         ARM_ABI_PREFIX=eabi-
3485     else
3486         ARM_ABI_PREFIX=oabi-
3487     fi
3488   fi
3490   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
3493 dnl Check to see if we can resolve ambiguity with |using|.
3494 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
3495                ac_cv_cpp_ambiguity_resolving_using,
3496                [AC_TRY_COMPILE(class X {
3497                                  public: int go(const X&) {return 3;}
3498                                          int jo(const X&) {return 3;}
3499                                };
3500                                class Y : public X {
3501                                  public:  int go(int) {return 2;}
3502                                           int jo(int) {return 2;}
3503                                           using X::jo;
3504                                  private: using X::go;
3505                                };,
3506                                X x; Y y; y.jo(x);,
3507                                ac_cv_cpp_ambiguity_resolving_using=yes,
3508                                ac_cv_cpp_ambiguity_resolving_using=no)])
3509 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
3510    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
3513 dnl See if a dynamic_cast to void* gives the most derived object.
3514 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
3515                ac_cv_cpp_dynamic_cast_void_ptr,
3516                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
3517                             class Y { int j; public: virtual ~Y() { } };
3518                             class Z : public X, public Y { int k; };
3520                             int main() {
3521                                  Z mdo;
3522                                  X *subx = (X*)&mdo;
3523                                  Y *suby = (Y*)&mdo;
3524                                  return !((((void*)&mdo != (void*)subx) &&
3525                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
3526                                           (((void*)&mdo != (void*)suby) &&
3527                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
3528                             }],
3529                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
3530                            ac_cv_cpp_dynamic_cast_void_ptr=no,
3531                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
3532 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
3533    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
3537 dnl note that this one is reversed - if the test fails, then
3538 dnl we require implementations of unused virtual methods. Which
3539 dnl really blows because it means we'll have useless vtable
3540 dnl bloat.
3541 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
3542                ac_cv_cpp_unused_required,
3543                [AC_TRY_LINK(class X {private: virtual void never_called();};,
3544                                X x;,
3545                                ac_cv_cpp_unused_required=no,
3546                                ac_cv_cpp_unused_required=yes)])
3547 if test "$ac_cv_cpp_unused_required" = yes ; then
3548    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
3552 dnl Some compilers have trouble comparing a constant reference to a templatized
3553 dnl class to zero, and require an explicit operator==() to be defined that takes
3554 dnl an int. This test separates the strong from the weak.
3556 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
3557                ac_cv_trouble_comparing_to_zero,
3558                [AC_TRY_COMPILE([#include <algorithm>
3559                                 template <class T> class Foo {};
3560                                 class T2;
3561                                 template <class T> int operator==(const T2*, const T&) { return 0; }
3562                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
3563                                [Foo<int> f; return (0 != f);],
3564                                ac_cv_trouble_comparing_to_zero=no,
3565                                ac_cv_trouble_comparing_to_zero=yes)])
3566 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
3567   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
3570 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
3571 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
3572 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
3573 # linking XUL.
3574 _SAVE_LDFLAGS=$LDFLAGS
3575 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
3576 AC_CACHE_CHECK(for __thread keyword for TLS variables,
3577                ac_cv_thread_keyword,
3578                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
3579                             [return tlsIsMainThread;],
3580                             ac_cv_thread_keyword=yes,
3581                             ac_cv_thread_keyword=no)])
3582 LDFLAGS=$_SAVE_LDFLAGS
3583 # The custom dynamic linker doesn't support TLS variables
3584 MOZ_TLS=
3585 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
3586   # mips builds fail with TLS variables because of a binutils bug.
3587   # See bug 528687
3588   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
3589   case "${target}" in
3590     mips*-*)
3591       :
3592       ;;
3593     *-android*|*-linuxandroid*)
3594       :
3595       ;;
3596     *-openbsd*)
3597       :
3598       ;;
3599     *)
3600       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
3601       MOZ_TLS=1
3602       ;;
3603   esac
3606 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
3607 if test -n "$MOZ_LINKER"; then
3608   if test "$CPU_ARCH" = arm; then
3609     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
3610     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
3611       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3612       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3613     fi
3614   fi
3617 dnl The custom linker doesn't support text relocations, but NDK >= r6b
3618 dnl creates some (http://code.google.com/p/android/issues/detail?id=23203)
3619 dnl We however want to avoid these text relocations, and this can be done
3620 dnl by making gcc not link crtbegin and crtend. In the broken NDKs, crtend
3621 dnl doesn't contain anything at all, beside placeholders for some sections,
3622 dnl and crtbegin only contains a finalizer function that calls
3623 dnl __cxa_finalize. The custom linker actually takes care of calling
3624 dnl __cxa_finalize when the library doesn't call it itself, which makes it
3625 dnl safe not to link crtbegin. Besides, previous versions of the NDK didn't
3626 dnl link crtbegin and crtend at all.
3627 if test -n "$MOZ_LINKER" -a "$OS_TARGET" = "Android"; then
3628   AC_CACHE_CHECK([whether the CRT objects have text relocations],
3629     ac_cv_crt_has_text_relocations,
3630     [echo 'int foo() { return 0; }' > conftest.cpp
3631      if AC_TRY_COMMAND(${CXX-g++} -o conftest${DLL_SUFFIX} $CXXFLAGS $DSO_LDOPTS $LDFLAGS conftest.cpp $LIBS 1>&5) &&
3632         test -s conftest${DLL_SUFFIX}; then
3633        if ${TOOLCHAIN_PREFIX}readelf -d conftest${DLL_SUFFIX} | grep TEXTREL > /dev/null; then
3634          ac_cv_crt_has_text_relocations=yes
3635        else
3636          ac_cv_crt_has_text_relocations=no
3637        fi
3638      else
3639        AC_ERROR([couldn't compile a simple C file])
3640      fi
3641      rm -rf conftest*])
3642   if test "$ac_cv_crt_has_text_relocations" = yes; then
3643     dnl While we want libraries to skip the CRT files, we don't want
3644     dnl executables to be treated the same way. We thus set the flag
3645     dnl in DSO_LDOPTS and not LDFLAGS. However, to pass it to nspr,
3646     dnl we need to use LDFLAGS because nspr doesn't inherit DSO_LDOPTS.
3647     dnl Using LDFLAGS in nspr is safe, since we only really build
3648     dnl libraries there.
3649     DSO_LDOPTS="$DSO_LDOPTS -nostartfiles"
3650     NSPR_LDFLAGS="$NSPR_LDFLAGS -nostartfiles"
3651   fi
3654 dnl Check for the existence of various allocation headers/functions
3656 MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h"
3657 MALLOC_H=
3659 for file in $MALLOC_HEADERS; do
3660   MOZ_CHECK_HEADER($file, [MALLOC_H=$file])
3661   if test "$MALLOC_H" != ""; then
3662     AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
3663     break
3664   fi
3665 done
3667 MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
3668 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
3670 AC_CHECK_FUNCS(malloc_usable_size)
3672 dnl See if compiler supports some gcc-style attributes
3674 AC_CACHE_CHECK(for __attribute__((always_inline)),
3675                ac_cv_attribute_always_inline,
3676                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
3677                                [],
3678                                ac_cv_attribute_always_inline=yes,
3679                                ac_cv_attribute_always_inline=no)])
3681 AC_CACHE_CHECK(for __attribute__((malloc)),
3682                ac_cv_attribute_malloc,
3683                [AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
3684                                [],
3685                                ac_cv_attribute_malloc=yes,
3686                                ac_cv_attribute_malloc=no)])
3688 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
3689                ac_cv_attribute_warn_unused,
3690                [AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
3691                                [],
3692                                ac_cv_attribute_warn_unused=yes,
3693                                ac_cv_attribute_warn_unused=no)])
3695 dnl End of C++ language/feature checks
3696 AC_LANG_C
3698 dnl ========================================================
3699 dnl =  Internationalization checks
3700 dnl ========================================================
3702 dnl Internationalization and Locale support is different
3703 dnl on various UNIX platforms.  Checks for specific i18n
3704 dnl features go here.
3706 dnl check for LC_MESSAGES
3707 AC_CACHE_CHECK(for LC_MESSAGES,
3708                 ac_cv_i18n_lc_messages,
3709                 [AC_TRY_COMPILE([#include <locale.h>],
3710                                 [int category = LC_MESSAGES;],
3711                                 ac_cv_i18n_lc_messages=yes,
3712                                 ac_cv_i18n_lc_messages=no)])
3713 if test "$ac_cv_i18n_lc_messages" = yes; then
3714    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
3717 AC_HAVE_FUNCS(localeconv)
3718 fi # ! SKIP_COMPILER_CHECKS
3720 TARGET_XPCOM_ABI=
3721 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
3722     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
3725 dnl Mozilla specific options
3726 dnl ========================================================
3727 dnl The macros used for command line options
3728 dnl are defined in build/autoconf/altoptions.m4.
3730 dnl If the compiler supports these attributes, define them as
3731 dnl convenience macros.
3732 if test "$ac_cv_attribute_malloc" = yes ; then
3733   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
3734 else
3735   AC_DEFINE(NS_ATTR_MALLOC,)
3738 if test "$ac_cv_attribute_warn_unused" = yes ; then
3739   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
3740 else
3741   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
3744 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
3745 dnl features that Windows actually does support.
3747 if test -n "$SKIP_COMPILER_CHECKS"; then
3748    dnl Windows has malloc.h
3749    AC_DEFINE(MALLOC_H, [<malloc.h>])
3750    AC_DEFINE(HAVE_FORCEINLINE)
3751    AC_DEFINE(HAVE_LOCALECONV)
3752 fi # SKIP_COMPILER_CHECKS
3754 dnl ========================================================
3755 dnl =
3756 dnl = Check for external package dependencies
3757 dnl =
3758 dnl ========================================================
3759 MOZ_ARG_HEADER(External Packages)
3761 MOZ_ARG_WITH_STRING(libxul-sdk,
3762 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
3763   LIBXUL_SDK_DIR=$withval)
3765 if test "$LIBXUL_SDK_DIR" = "yes"; then
3766     AC_MSG_ERROR([--with-libxul-sdk must specify a path])
3767 elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
3768     LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
3770     if test ! -f "$LIBXUL_SDK/include/xpcom-config.h"; then
3771         AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
3772     fi
3775 AC_SUBST(LIBXUL_SDK)
3777 if test -n "$LIBXUL_SDK"; then
3778     LIBXUL_DIST="$LIBXUL_SDK"
3779 else
3780     LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
3782 AC_SUBST(LIBXUL_DIST)
3784 SYSTEM_LIBXUL=
3786 MOZ_ARG_WITH_BOOL(system-libxul,
3787 [  --with-system-libxul    Use system installed libxul SDK],
3788     SYSTEM_LIBXUL=1)
3790 dnl ========================================================
3791 dnl = If NSPR was not detected in the system,
3792 dnl = use the one in the source tree (mozilla/nsprpub)
3793 dnl ========================================================
3794 MOZ_ARG_WITH_BOOL(system-nspr,
3795 [  --with-system-nspr      Use system installed NSPR],
3796     _USE_SYSTEM_NSPR=1 )
3798 if test -n "$_USE_SYSTEM_NSPR"; then
3799     AM_PATH_NSPR(4.9.6, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])])
3802 if test -n "$MOZ_NATIVE_NSPR"; then
3803     _SAVE_CFLAGS=$CFLAGS
3804     CFLAGS="$CFLAGS $NSPR_CFLAGS"
3805     AC_TRY_COMPILE([#include "prtypes.h"],
3806                 [#ifndef PR_STATIC_ASSERT
3807                  #error PR_STATIC_ASSERT not defined or requires including prtypes.h
3808                  #endif],
3809                 [MOZ_NATIVE_NSPR=1],
3810                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
3811     AC_TRY_COMPILE([#include "prtypes.h"],
3812                 [#ifndef PR_UINT64
3813                  #error PR_UINT64 not defined or requires including prtypes.h
3814                  #endif],
3815                 [MOZ_NATIVE_NSPR=1],
3816                 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
3817     CFLAGS=$_SAVE_CFLAGS
3818 else
3819     if test -z "$LIBXUL_SDK"; then
3820         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
3821         if test -n "$GNU_CC"; then
3822             NSPR_LIBS="-L${LIBXUL_DIST}/lib -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
3823         else
3824             NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
3825         fi
3826     else
3827         NSPR_CFLAGS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --includedir="${LIBXUL_DIST}/include/nspr" --cflags`
3828         NSPR_LIBS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --libdir="${LIBXUL_DIST}"/lib --libs`
3829     fi
3832 dnl set GRE_MILESTONE
3833 dnl ========================================================
3834 if test -n "$LIBXUL_SDK"; then
3835     GRE_MILESTONE=`$PYTHON "$_topsrcdir"/config/printconfigsetting.py "$LIBXUL_DIST"/bin/platform.ini Build Milestone`
3836 else
3837     GRE_MILESTONE=`tail -n 1 "$_topsrcdir"/config/milestone.txt 2>/dev/null || tail -1 "$_topsrcdir"/config/milestone.txt`
3839 AC_SUBST(GRE_MILESTONE)
3841 # set RELEASE_BUILD and NIGHTLY_BUILD variables depending on the cycle we're in
3842 # The logic works like this:
3843 # - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
3844 # - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
3845 # - otherwise, we're building Release/Beta (define RELEASE_BUILD)
3846 case "$GRE_MILESTONE" in
3847   *a1*)
3848       NIGHTLY_BUILD=1
3849       AC_DEFINE(NIGHTLY_BUILD)
3850       ;;
3851   *a*)
3852       ;;
3853   *)
3854       RELEASE_BUILD=1
3855       AC_DEFINE(RELEASE_BUILD)
3856       ;;
3857 esac
3858 AC_SUBST(NIGHTLY_BUILD)
3859 AC_SUBST(RELEASE_BUILD)
3861 dnl system libevent Support
3862 dnl ========================================================
3863 MOZ_ARG_WITH_STRING(system-libevent,
3864 [  --with-system-libevent[=PFX]
3865                           Use system libevent [installed at prefix PFX]],
3866     LIBEVENT_DIR=$withval)
3868 _SAVE_CFLAGS=$CFLAGS
3869 _SAVE_LDFLAGS=$LDFLAGS
3870 _SAVE_LIBS=$LIBS
3871 if test "$LIBEVENT_DIR" = yes; then
3872     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
3873         MOZ_NATIVE_LIBEVENT=1,
3874         LIBEVENT_DIR=/usr)
3876 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
3877     MOZ_NATIVE_LIBEVENT=
3878 elif test -z "$MOZ_NATIVE_LIBEVENT"; then
3879     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
3880     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
3881     MOZ_CHECK_HEADER(event.h,
3882         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
3883              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
3884          fi],
3885         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
3886     AC_CHECK_LIB(event, event_init,
3887                  [MOZ_NATIVE_LIBEVENT=1
3888                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
3889                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
3890                  [MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
3892 CFLAGS=$_SAVE_CFLAGS
3893 LDFLAGS=$_SAVE_LDFLAGS
3894 LIBS=$_SAVE_LIBS
3896 AC_SUBST(MOZ_NATIVE_LIBEVENT)
3897 AC_SUBST(MOZ_LIBEVENT_CFLAGS)
3898 AC_SUBST(MOZ_LIBEVENT_LIBS)
3900 dnl ========================================================
3901 dnl = If NSS was not detected in the system,
3902 dnl = use the one in the source tree (mozilla/security/nss)
3903 dnl ========================================================
3905 MOZ_ARG_WITH_BOOL(system-nss,
3906 [  --with-system-nss       Use system installed NSS],
3907     _USE_SYSTEM_NSS=1 )
3909 if test -n "$_USE_SYSTEM_NSS"; then
3910     AM_PATH_NSS(3.15, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
3913 if test -n "$MOZ_NATIVE_NSS"; then
3914    NSS_LIBS="$NSS_LIBS -lcrmf"
3915 else
3916    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
3918    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2"; then
3919        NSS_LIBS="\
3920         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
3921         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
3922         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
3923         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
3924         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
3925    else
3926        NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
3927    fi
3930 dnl ======================
3931 dnl Detect yasm
3932 dnl ======================
3934 AC_MSG_CHECKING([for YASM assembler])
3935 AC_CHECK_PROGS(YASM, yasm, "")
3937 if test -n "$YASM"; then
3938   dnl Pull out yasm's version string
3939   YASM_VERSION=`yasm --version | $AWK '/^yasm/ { print $2 }'`
3940   _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
3941   _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
3942   _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
3943   _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
3946 if test -z "$SKIP_LIBRARY_CHECKS"; then
3947 dnl system JPEG support
3948 dnl ========================================================
3949 MOZ_ARG_WITH_STRING(system-jpeg,
3950 [  --with-system-jpeg[=PFX]
3951                           Use system libjpeg [installed at prefix PFX]],
3952     JPEG_DIR=$withval)
3954 _SAVE_CFLAGS=$CFLAGS
3955 _SAVE_LDFLAGS=$LDFLAGS
3956 _SAVE_LIBS=$LIBS
3957 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
3958     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
3959     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
3961 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
3962     MOZ_NATIVE_JPEG=
3963 else
3964     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_NATIVE_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_NATIVE_JPEG=)
3967 if test "$MOZ_NATIVE_JPEG" = 1; then
3968     AC_TRY_COMPILE([ #include <stdio.h>
3969                      #include <sys/types.h>
3970                      #include <jpeglib.h> ],
3971                    [ #if JPEG_LIB_VERSION < $MOZJPEG
3972                      #error "Insufficient JPEG library version ($MOZJPEG required)."
3973                      #endif
3974                      #ifndef JCS_EXTENSIONS
3975                      #error "libjpeg-turbo JCS_EXTENSIONS required"
3976                      #endif
3977                      ],
3978                    MOZ_NATIVE_JPEG=1,
3979                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
3981 CFLAGS=$_SAVE_CFLAGS
3982 LDFLAGS=$_SAVE_LDFLAGS
3983 LIBS=$_SAVE_LIBS
3985 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
3986     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
3987     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
3989 fi # SKIP_LIBRARY_CHECKS
3991 dnl system ZLIB support
3992 dnl ========================================================
3993 MOZ_ZLIB_CHECK([1.2.3])
3995 if test "$MOZ_NATIVE_ZLIB" != 1; then
3996     MOZ_ZLIB_CFLAGS=
3997     MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,'"$MOZ_BUILD_ROOT"'/modules/zlib/src)'
4000 if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
4001     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
4004 if test -z "$SKIP_LIBRARY_CHECKS"; then
4005 dnl system BZIP2 Support
4006 dnl ========================================================
4007 MOZ_ARG_WITH_STRING(system-bz2,
4008 [  --with-system-bz2[=PFX]
4009                           Use system libbz2 [installed at prefix PFX]],
4010     BZ2_DIR=$withval)
4012 _SAVE_CFLAGS=$CFLAGS
4013 _SAVE_LDFLAGS=$LDFLAGS
4014 _SAVE_LIBS=$LIBS
4015 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
4016     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
4017     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
4019 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
4020     MOZ_NATIVE_BZ2=
4021 else
4022     AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_NATIVE_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
4023         [MOZ_NATIVE_BZ2= MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS=])
4025 CFLAGS=$_SAVE_CFLAGS
4026 LDFLAGS=$_SAVE_LDFLAGS
4027 LIBS=$_SAVE_LIBS
4029 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_NATIVE_BZ2" = 1; then
4030     MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
4031     MOZ_BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
4034 dnl system PNG Support
4035 dnl ========================================================
4036 MOZ_ARG_WITH_STRING(system-png,
4037 [  --with-system-png[=PFX]
4038                           Use system libpng [installed at prefix PFX]],
4039     PNG_DIR=$withval)
4041 _SAVE_CFLAGS=$CFLAGS
4042 _SAVE_LDFLAGS=$LDFLAGS
4043 _SAVE_LIBS=$LIBS
4044 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
4045     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
4046     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
4048 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
4049     MOZ_NATIVE_PNG=
4050 else
4051     AC_CHECK_LIB(png, png_get_valid, [MOZ_NATIVE_PNG=1 MOZ_PNG_LIBS="-lpng"],
4052                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4053     AC_CHECK_LIB(png, png_get_acTL, ,
4054                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
4056 if test "$MOZ_NATIVE_PNG" = 1; then
4057     AC_TRY_COMPILE([ #include <stdio.h>
4058                      #include <sys/types.h>
4059                      #include <png.h> ],
4060                    [ #if PNG_LIBPNG_VER < $MOZPNG
4061                      #error "Insufficient libpng version ($MOZPNG required)."
4062                      #endif
4063                      #ifndef PNG_UINT_31_MAX
4064                      #error "Insufficient libpng version."
4065                      #endif ],
4066                    MOZ_NATIVE_PNG=1,
4067                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4069 CFLAGS=$_SAVE_CFLAGS
4070 LDFLAGS=$_SAVE_LDFLAGS
4071 LIBS=$_SAVE_LIBS
4073 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_NATIVE_PNG" = 1; then
4074     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
4075     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
4078 MOZ_PNG_ARM_NEON=
4079 if test "$MOZ_NATIVE_PNG" != 1 -a "$CPU_ARCH" = "arm" ; then
4080     MOZ_PNG_ARM_NEON=1
4082 AC_SUBST(MOZ_PNG_ARM_NEON)
4084 fi # SKIP_LIBRARY_CHECKS
4086 dnl system HunSpell Support
4087 dnl ========================================================
4088 MOZ_ARG_ENABLE_BOOL(system-hunspell,
4089 [  --enable-system-hunspell
4090                           Use system hunspell (located with pkgconfig)],
4091     MOZ_NATIVE_HUNSPELL=1 )
4093 if test -n "$MOZ_NATIVE_HUNSPELL"; then
4094     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
4097 AC_SUBST(MOZ_NATIVE_HUNSPELL)
4099 dnl ========================================================
4100 dnl system libffi Support
4101 dnl ========================================================
4102 MOZ_ARG_ENABLE_BOOL(system-ffi,
4103 [  --enable-system-ffi       Use system libffi (located with pkgconfig)],
4104     MOZ_NATIVE_FFI=1 )
4106 if test -n "$MOZ_NATIVE_FFI"; then
4107     # Vanilla libffi 3.0.9 needs a few patches from upcoming version 3.0.10
4108     # for non-GCC compilers.
4109     if test -z "$GNU_CC"; then
4110         PKG_CHECK_MODULES(MOZ_FFI, libffi > 3.0.9)
4111     else
4112         PKG_CHECK_MODULES(MOZ_FFI, libffi >= 3.0.9)
4113     fi
4114     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS"
4117 dnl ========================================================
4118 dnl Java SDK support
4119 dnl ========================================================
4121 JAVA_BIN_PATH=
4122 MOZ_ARG_WITH_STRING(java-bin-path,
4123 [  --with-java-bin-path=dir
4124                           Location of Java binaries (java, javac, jar)],
4125     JAVA_BIN_PATH=$withval)
4127 dnl ========================================================
4128 dnl =
4129 dnl = Application
4130 dnl =
4131 dnl ========================================================
4133 MOZ_ARG_HEADER(Application)
4135 ENABLE_TESTS=1
4136 ENABLE_SYSTEM_EXTENSION_DIRS=1
4137 MOZ_BRANDING_DIRECTORY=
4138 MOZ_OFFICIAL_BRANDING=
4139 MOZ_FEEDS=1
4140 MOZ_WEBAPP_RUNTIME=
4141 MOZ_JSDEBUGGER=1
4142 MOZ_AUTH_EXTENSION=1
4143 MOZ_OGG=1
4144 MOZ_RAW=
4145 MOZ_SPEEX_RESAMPLER=1
4146 MOZ_SOUNDTOUCH=1
4147 MOZ_CUBEB=
4148 MOZ_VORBIS=
4149 MOZ_TREMOR=
4150 MOZ_WAVE=1
4151 MOZ_SAMPLE_TYPE_FLOAT32=
4152 MOZ_SAMPLE_TYPE_S16=
4153 MOZ_OPUS=1
4154 MOZ_WEBM=1
4155 MOZ_DASH=
4156 MOZ_DIRECTSHOW=
4157 MOZ_WMF=
4158 MOZ_WEBRTC=1
4159 MOZ_PEERCONNECTION=
4160 MOZ_SRTP=
4161 MOZ_WEBRTC_SIGNALING=
4162 MOZ_WEBRTC_IN_LIBXUL=
4163 MOZ_WEBRTC_ASSERT_ALWAYS=1
4164 MOZ_SCTP=
4165 MOZ_MEDIA_PLUGINS=
4166 MOZ_MEDIA_NAVIGATOR=
4167 MOZ_OMX_PLUGIN=
4168 MOZ_VP8=
4169 MOZ_VP8_ERROR_CONCEALMENT=
4170 MOZ_VP8_ENCODER=
4171 MOZ_WEBSPEECH=1
4172 VPX_AS=
4173 VPX_ASFLAGS=
4174 VPX_AS_DASH_C_FLAG=
4175 VPX_AS_CONVERSION=
4176 VPX_ASM_SUFFIX=
4177 VPX_X86_ASM=
4178 VPX_ARM_ASM=
4179 LIBJPEG_TURBO_AS=
4180 LIBJPEG_TURBO_ASFLAGS=
4181 LIBJPEG_TURBO_X86_ASM=
4182 LIBJPEG_TURBO_X64_ASM=
4183 LIBJPEG_TURBO_ARM_ASM=
4184 MOZ_PANGO=1
4185 MOZ_PERMISSIONS=1
4186 MOZ_PLACES=1
4187 MOZ_SOCIAL=1
4188 MOZ_PREF_EXTENSIONS=1
4189 MOZ_PROFILELOCKING=1
4190 MOZ_REFLOW_PERF=
4191 MOZ_SAFE_BROWSING=
4192 MOZ_HELP_VIEWER=
4193 MOZ_SPELLCHECK=1
4194 MOZ_ANDROID_OMTC=
4195 MOZ_TOOLKIT_SEARCH=1
4196 MOZ_UI_LOCALE=en-US
4197 MOZ_UNIVERSALCHARDET=1
4198 MOZ_URL_CLASSIFIER=
4199 MOZ_XUL=1
4200 MOZ_ZIPWRITER=1
4201 NS_PRINTING=1
4202 MOZ_PDF_PRINTING=
4203 MOZ_DISABLE_CRYPTOLEGACY=
4204 NSS_DISABLE_DBM=
4205 NECKO_COOKIES=1
4206 NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg device"
4207 USE_ARM_KUSER=
4208 BUILD_CTYPES=1
4209 MOZ_USE_NATIVE_POPUP_WINDOWS=
4210 MOZ_ANDROID_HISTORY=
4211 MOZ_WEBSMS_BACKEND=
4212 MOZ_ANDROID_BEAM=
4213 ACCESSIBILITY=1
4214 MOZ_TIME_MANAGER=
4215 MOZ_PAY=
4216 MOZ_AUDIO_CHANNEL_MANAGER=
4217 NSS_NO_LIBPKIX=
4218 MOZ_CONTENT_SANDBOX=
4219 MOZ_CONTENT_SANDBOX_REPORTER=
4221 case "$target_os" in
4222     mingw*)
4223         NS_ENABLE_TSF=1
4224         AC_DEFINE(NS_ENABLE_TSF)
4225         ;;
4226 esac
4228 case "${target}" in
4229     *-android*|*-linuxandroid*)
4230         if test "$CPU_ARCH" = "arm" ; then
4231           USE_ARM_KUSER=1
4232         fi
4234         NSS_DISABLE_DBM=1
4235         MOZ_THEME_FASTSTRIPE=1
4236         MOZ_TREE_FREETYPE=1
4237         MOZ_MEMORY=1
4238         MOZ_RAW=1
4239         ;;
4241 esac
4243 MOZ_ARG_WITH_STRING(external-source-dir,
4244 [  --with-external-source-dir=dir
4245                           External directory containing additional build files.],
4246 [ EXTERNAL_SOURCE_DIR=$withval])
4247 AC_SUBST(EXTERNAL_SOURCE_DIR)
4249 MOZ_ARG_ENABLE_STRING(application,
4250 [  --enable-application=APP
4251                           Options include:
4252                             browser (Firefox)
4253                             xulrunner
4254                             tools/update-packaging (AUS-related packaging tools)],
4255 [ MOZ_BUILD_APP=$enableval ] )
4257 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
4258 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
4259   XULRUNNER_STUB_NAME=$withval)
4261 if test -z "$XULRUNNER_STUB_NAME"; then
4262   case "$target_os" in
4263   darwin*)
4264     XULRUNNER_STUB_NAME=xulrunner
4265     ;;
4266   *)
4267     XULRUNNER_STUB_NAME=xulrunner-stub
4268   esac
4270 AC_SUBST(XULRUNNER_STUB_NAME)
4272 AC_MSG_CHECKING([for application to build])
4273 if test -z "$MOZ_BUILD_APP"; then
4274   AC_MSG_RESULT([browser])
4275   MOZ_BUILD_APP=browser
4276 else
4277   # "mobile" no longer exists.
4278   if test "$MOZ_BUILD_APP" = "mobile" ; then
4279     AC_MSG_RESULT([none])
4280     AC_MSG_ERROR([--enable-application=mobile is no longer supported.])
4281   fi
4282   # We have a valid application only if it has a build.mk file in its top
4283   # directory.
4284   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
4285     AC_MSG_RESULT([none])
4286     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
4287   else
4288     AC_MSG_RESULT([$MOZ_BUILD_APP])
4289   fi
4292 # The app update channel is 'default' when not supplied. The value is used in
4293 # the application's confvars.sh so it must be set before confvars.sh is called.
4294 MOZ_ARG_ENABLE_STRING([update-channel],
4295 [  --enable-update-channel=CHANNEL
4296                           Select application update channel (default=default)],
4297     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
4299 if test -z "$MOZ_UPDATE_CHANNEL"; then
4300     MOZ_UPDATE_CHANNEL=default
4302 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
4303 AC_SUBST(MOZ_UPDATE_CHANNEL)
4305 # Allow to specify a Google API key file that contains the secret key to be
4306 # used for various Google API requests.
4307 MOZ_ARG_WITH_STRING(google-api-keyfile,
4308 [  --with-google-api-keyfile=file   Use the secret key contained in the given keyfile for Google API requests],
4309   MOZ_GOOGLE_API_KEY=`cat $withval`)
4310 if test -z "$MOZ_GOOGLE_API_KEY"; then
4311     MOZ_GOOGLE_API_KEY=no-google-api-key
4313 AC_SUBST(MOZ_GOOGLE_API_KEY)
4315 # Allow the application to influence configure with a confvars.sh script.
4316 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4317 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4318   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4319   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4320 else
4321   AC_MSG_RESULT([no])
4324 # Allow influencing configure with a defines.sh script.
4325 . "${srcdir}/build/defines.sh"
4327 # If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
4328 # set in defines.sh
4329 if test "$BUILDING_RELEASE"; then
4330   # Override value in defines.sh, if any
4331   EARLY_BETA_OR_EARLIER=
4332 elif test "$EARLY_BETA_OR_EARLIER"; then
4333   AC_DEFINE(EARLY_BETA_OR_EARLIER)
4335 AC_SUBST(EARLY_BETA_OR_EARLIER)
4337 # Allow the application to provide a subconfigure script
4338 if test -f "${srcdir}/${MOZ_BUILD_APP}/configure.in" ; then
4339   do_output_subdirs() {
4340     if test -n "$_subconfigure_subdirs"; then
4341       AC_MSG_ERROR([Cannot specify more than one sub-sub-configure])
4342      fi
4343     _subconfigure_subdir="$1"
4344     _subconfigure_config_args="$ac_configure_args"
4345   }
4346   tmpscript=`$PYTHON -c 'import os, tempfile; print tempfile.mktemp(prefix="subscript.").replace(os.sep, "/")'` || exit 1
4347   m4 "${srcdir}/build/autoconf/subconfigure.m4" \
4348      "${srcdir}/build/autoconf/altoptions.m4" \
4349      "${srcdir}/${MOZ_BUILD_APP}/configure.in" > $tmpscript
4350   . $tmpscript
4351   rm -f $tmpscript
4354 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
4355 MOZ_ARG_WITH_STRING(app-name,
4356 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
4357 WITH_APP_NAME=$withval,
4360 if test -n "$WITH_APP_NAME" ; then
4361     MOZ_APP_NAME="$WITH_APP_NAME"
4364 MOZ_ARG_WITH_STRING(app-basename,
4365 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
4366 WITH_APP_BASENAME=$withval,
4369 if test -n "$WITH_APP_BASENAME" ; then
4370     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
4373 # Now is a good time to test for logic errors, define mismatches, etc.
4374 case "$MOZ_BUILD_APP" in
4375 xulrunner)
4376   if test "$LIBXUL_SDK"; then
4377     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4378   fi
4379   ;;
4380 esac
4382 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4383 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4384 # MOZ_BUILD_APP.
4385 case "$MOZ_BUILD_APP" in
4386 browser)
4387   AC_DEFINE(MOZ_PHOENIX)
4388   ;;
4390 xulrunner)
4391   AC_DEFINE(MOZ_XULRUNNER)
4392   ;;
4393 b2g)
4394   AC_DEFINE(MOZ_B2G)
4395   ;;
4396 esac
4398 AC_SUBST(MOZ_BUILD_APP)
4399 AC_SUBST(MOZ_PHOENIX)
4400 AC_SUBST(MOZ_XULRUNNER)
4401 AC_SUBST(MOZ_B2G)
4403 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4405 dnl ========================================================
4406 dnl Check android sdk version depending on mobile target
4407 dnl ========================================================
4409 if test -z "$gonkdir" ; then
4410     # Minimum Android SDK API Level we require.
4411     case "$MOZ_BUILD_APP" in
4412     mobile/android)
4413         android_min_api_level=16
4414         case "$target" in
4415         *-android*|*-linuxandroid*)
4416             :
4417             ;;
4418         *)
4419             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])
4420             ;;
4421         esac
4422         ;;
4423     esac
4425     MOZ_ANDROID_SDK($android_min_api_level)
4428 dnl ========================================================
4429 dnl =
4430 dnl = Toolkit Options
4431 dnl =
4432 dnl ========================================================
4433 MOZ_ARG_HEADER(Toolkit Options)
4435     dnl ========================================================
4436     dnl = Select the default toolkit
4437     dnl ========================================================
4438         MOZ_ARG_ENABLE_STRING(default-toolkit,
4439         [  --enable-default-toolkit=TK
4440                           Select default toolkit
4441                           Platform specific defaults:
4442                             Mac OS X - cairo-cocoa
4443                             OS/2 - cairo-os2
4444                             Win32 - cairo-windows
4445                             * - cairo-gtk2
4446                             * - cairo-gtk3
4447                             * - cairo-qt],
4448     [ _DEFAULT_TOOLKIT=$enableval ],
4449     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4451     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4452         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4453         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4454         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk3" \
4455         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4456         -o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
4457         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
4458         -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
4459         -o "$_DEFAULT_TOOLKIT" = "cairo-android" \
4460         -o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
4461     then
4462         dnl nglayout only supports building with one toolkit,
4463         dnl so ignore everything after the first comma (",").
4464         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4465     else
4466         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4467     fi
4469 MOZ_ARG_WITHOUT_BOOL(x,
4470 [  --without-x              Build without X11],
4471     WITHOUT_X11=1)
4473 dnl ========================================================
4474 dnl = Enable the toolkit as needed                         =
4475 dnl ========================================================
4477 MOZ_WIDGET_GTK=
4479 case "$MOZ_WIDGET_TOOLKIT" in
4481 cairo-windows)
4482     MOZ_WIDGET_TOOLKIT=windows
4483     MOZ_WEBGL=1
4484     MOZ_PDF_PRINTING=1
4485     MOZ_INSTRUMENT_EVENT_LOOP=1
4486     if test -n "$GNU_CC"; then
4487         MOZ_FOLD_LIBS=
4488     fi
4489     ;;
4491 cairo-gtk3)
4492     MOZ_WIDGET_TOOLKIT=gtk3
4493     MOZ_ENABLE_GTK=1
4494     MOZ_ENABLE_GTK3=1
4495     MOZ_ENABLE_XREMOTE=1
4496     MOZ_WEBGL=1
4497     MOZ_GL_DEFAULT_PROVIDER=GLX
4499     AC_DEFINE(MOZ_X11)
4500     MOZ_X11=1
4501     USE_FC_FREETYPE=1
4503     TK_CFLAGS='$(MOZ_GTK3_CFLAGS)'
4504     TK_LIBS='$(MOZ_GTK3_LIBS)'
4505     MOZ_WIDGET_GTK=3
4506     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4507     MOZ_PDF_PRINTING=1
4508     MOZ_INSTRUMENT_EVENT_LOOP=1
4509     ;;
4511 cairo-gtk2|cairo-gtk2-x11)
4512     MOZ_WIDGET_TOOLKIT=gtk2
4513     MOZ_ENABLE_GTK=1
4514     MOZ_ENABLE_GTK2=1
4515     MOZ_ENABLE_XREMOTE=1
4516     MOZ_WEBGL=1
4517     MOZ_GL_DEFAULT_PROVIDER=GLX
4519     AC_DEFINE(MOZ_X11)
4520     MOZ_X11=1
4521     USE_FC_FREETYPE=1
4523     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4524     TK_LIBS='$(MOZ_GTK2_LIBS)'
4525     AC_DEFINE(MOZ_WIDGET_GTK2)
4526     MOZ_WIDGET_GTK=2
4527     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4528     MOZ_PDF_PRINTING=1
4529     MOZ_INSTRUMENT_EVENT_LOOP=1
4530     ;;
4532 cairo-qt)
4533     MOZ_WIDGET_TOOLKIT=qt
4534     MOZ_ENABLE_QT=1
4535     if test -z "$WITHOUT_X11"; then
4536       MOZ_ENABLE_XREMOTE=1
4537       MOZ_GL_DEFAULT_PROVIDER=GLX
4538       MOZ_X11=1
4539       AC_DEFINE(MOZ_X11)
4540       XT_LIBS=
4541     fi
4543     MOZ_WEBGL=1
4544     USE_ELF_DYNSTR_GC=
4545     USE_FC_FREETYPE=1
4546     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4547     TK_LIBS='$(MOZ_QT_LIBS)'
4548     AC_DEFINE(MOZ_WIDGET_QT)
4549     MOZ_PDF_PRINTING=1
4550     AC_DEFINE(QT_NO_KEYWORDS)
4551     ;;
4553 cairo-os2)
4554     MOZ_WIDGET_TOOLKIT=os2
4555     USE_FC_FREETYPE=1
4556     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4557     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4558     MOZ_PDF_PRINTING=1
4559     ;;
4561 cairo-cocoa)
4562     MOZ_WIDGET_TOOLKIT=cocoa
4563     AC_DEFINE(MOZ_WIDGET_COCOA)
4564     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
4565     TK_LIBS='-framework CoreLocation -framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
4566     TK_CFLAGS="-DNO_X11"
4567     CFLAGS="$CFLAGS $TK_CFLAGS"
4568     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4569     DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/bin/XUL -lxpcom_core -lmozalloc'
4570     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/bin/XUL -lmozalloc'
4571     MOZ_USER_DIR="Mozilla"
4572     MOZ_FS_LAYOUT=bundle
4573     MOZ_WEBGL=1
4574     MOZ_INSTRUMENT_EVENT_LOOP=1
4575     ;;
4577 cairo-uikit)
4578     MOZ_WIDGET_TOOLKIT=uikit
4579     AC_DEFINE(MOZ_WIDGET_UIKIT)
4580     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
4581     TK_CFLAGS="-DNO_X11"
4582     TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
4583     CFLAGS="$CFLAGS $TK_CFLAGS"
4584     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4585     DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/bin/XUL -lxpcom_core -lmozalloc'
4586     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/bin/XUL -lmozalloc'
4587     MOZ_USER_DIR="Mozilla"
4588     MOZ_FS_LAYOUT=bundle
4589     ;;
4591 cairo-android)
4592     AC_DEFINE(MOZ_WIDGET_ANDROID)
4593     MOZ_WIDGET_TOOLKIT=android
4594     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4595     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4596     MOZ_WEBGL=1
4597     MOZ_PDF_PRINTING=1
4598     MOZ_INSTRUMENT_EVENT_LOOP=1
4599     ;;
4601 cairo-gonk)
4602     AC_DEFINE(MOZ_WIDGET_GONK)
4603     AC_DEFINE(MOZ_TOUCH)
4604     MOZ_WIDGET_TOOLKIT=gonk
4605     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4606     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4607     MOZ_WEBGL=1
4608     MOZ_PDF_PRINTING=1
4609     MOZ_TOUCH=1
4610     ;;
4612 esac
4614 AC_SUBST(MOZ_PDF_PRINTING)
4615 if test "$MOZ_PDF_PRINTING"; then
4616    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
4617    AC_DEFINE(MOZ_PDF_PRINTING)
4620 if test "$MOZ_ENABLE_XREMOTE"; then
4621     AC_DEFINE(MOZ_ENABLE_XREMOTE)
4624 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
4625    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
4628 if test "$COMPILE_ENVIRONMENT"; then
4629   if test "$MOZ_ENABLE_GTK3"; then
4630     PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4631   fi
4632   if test "$MOZ_ENABLE_GTK2"; then
4633     if test "$MOZ_X11"; then
4634       GDK_PACKAGES=gdk-x11-2.0
4635     fi
4637     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4638   fi
4640 fi # COMPILE_ENVIRONMENT
4642 AC_SUBST(MOZ_FS_LAYOUT)
4644 dnl ========================================================
4645 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4646 dnl their usage and use them in spidermonkey.
4647 dnl ========================================================
4648 MOZ_ARG_WITH_BOOL(arm-kuser,
4649 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4650     USE_ARM_KUSER=1,)
4651 if test -n "$USE_ARM_KUSER"; then
4652    AC_DEFINE(USE_ARM_KUSER)
4655 dnl ========================================================
4656 dnl = startup-notification support module
4657 dnl ========================================================
4659 if test "$MOZ_ENABLE_GTK"
4660 then
4661     MOZ_ENABLE_STARTUP_NOTIFICATION=
4663     MOZ_ARG_ENABLE_BOOL(startup-notification,
4664     [  --enable-startup-notification
4665                           Enable startup-notification support (default: disabled) ],
4666         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
4667         MOZ_ENABLE_STARTUP_NOTIFICATION=)
4668     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
4669     then
4670         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
4671                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
4672         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
4673             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
4674             then
4675                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
4676             fi
4677             MOZ_ENABLE_STARTUP_NOTIFICATION=
4678         ])
4679     fi
4681     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
4682         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
4683     fi
4685     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
4687 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
4688 AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
4689 AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
4691 dnl ========================================================
4692 dnl = QT support
4693 dnl ========================================================
4694 if test "$MOZ_ENABLE_QT"
4695 then
4696     MOZ_ARG_WITH_STRING(qtdir,
4697     [  --with-qtdir=\$dir       Specify Qt directory ],
4698     [ QTDIR=$withval])
4700     if test -z "$QTDIR"; then
4701         AC_CHECK_PROGS(HOST_QMAKE, $HOST_QMAKE qmake, "")
4702     else
4703         HOST_QMAKE="$QTDIR/bin/qmake"
4704     fi
4705     QT_VERSION=`$HOST_QMAKE -v | grep 'Using Qt version' | egrep -o '[[0-9]]+\.[[0-9]]+\.[[0-9]]+'`
4707     if test -z "$QTDIR"; then
4708         case $QT_VERSION in
4709         5.*)
4710             AC_MSG_RESULT("Using qt5: $QT_VERSION")
4711             PKG_CHECK_MODULES(MOZ_QT, Qt5Gui Qt5Network Qt5Core Qt5OpenGL Qt5Widgets Qt5PrintSupport, ,
4712             [
4713               AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qtbase development packages, (On Ubuntu, you might try installing the packages qtbase5-dev libqt5opengl5-dev.)])
4714             ])
4715             QT5INCDIR=`pkg-config --variable=includedir Qt5Gui`
4716             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QT5INCDIR/QtGui/$QT_VERSION/QtGui"
4717             ;;
4718         4.*)
4719             AC_MSG_RESULT("Using qt4: $QT_VERSION")
4720             PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore QtOpenGL, ,
4721             [
4722               AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qt4 development package, (On Ubuntu, you might try installing the packages libqt4-dev libqt4-opengl-dev.)])
4723             ])
4724             ;;
4725         *)
4726             AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION])
4727             ;;
4728         esac
4730         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
4731         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
4732     else
4733         MOZ_QT_CFLAGS="-DQT_SHARED"
4734         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
4735         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
4736         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
4737         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
4738         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
4739         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative"
4741         case $QT_VERSION in
4742         5.*)
4743             AC_MSG_RESULT("Using qt5: $QT_VERSION")
4744             MOZ_QT_LIBS="-L$QTDIR/lib/ -lQt5Gui -lQt5Network -lQt5Core -lQt5Xml -lQt5OpenGL"
4745             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui/$QT_VERSION/QtGui"
4746             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtWidgets"
4747             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport"
4748             MOZ_QT_LIBS="$MOZ_QT_LIBS -lQt5Widgets -lQt5PrintSupport"
4749             ;;
4750         4.*)
4751             AC_MSG_RESULT("Using qt4: $QT_VERSION")
4752             MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
4753             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/Qt"
4754             ;;
4755         *)
4756             AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION])
4757             ;;
4758         esac
4760         HOST_MOC="$QTDIR/bin/moc"
4761         HOST_RCC="$QTDIR/bin/rcc"
4762     fi
4763     if test -z "$HOST_MOC"; then
4764         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
4765 incorrect])
4766     fi
4767     if test -z "$HOST_RCC"; then
4768         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is
4769 incorrect])
4770     fi
4772     MOC=$HOST_MOC
4773     RCC=$HOST_RCC
4775     MOZ_ENABLE_QMSYSTEM2=
4776     PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
4777                       MOZ_ENABLE_QMSYSTEM2=1,
4778                       MOZ_ENABLE_QMSYSTEM2=)
4780     if test "$MOZ_ENABLE_QMSYSTEM2"; then
4781       MOZ_ENABLE_QMSYSTEM2=1
4782       MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
4783       MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
4784       AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
4785     fi
4787     MOZ_ENABLE_QTNETWORK=
4788     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
4789                       MOZ_ENABLE_QTNETWORK=1,
4790                       MOZ_ENABLE_QTNETWORK=)
4792     if test "$MOZ_ENABLE_QTNETWORK"; then
4793       MOZ_ENABLE_QTNETWORK=1
4794       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
4795     fi
4797     MOZ_ENABLE_QTMOBILITY=
4798     PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
4799                       MOZ_ENABLE_QTMOBILITY=1,
4800                       MOZ_ENABLE_QTMOBILITY=)
4801     if test "$MOZ_ENABLE_QTMOBILITY"; then
4802        MOZ_ENABLE_QTMOBILITY=1
4803        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
4804        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
4805     else
4806        AC_CHECK_LIB(QtSensors, main, [
4807           MOZ_ENABLE_QTMOBILITY=1
4808           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMobility"
4809           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtSensors"
4810           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtFeedback"
4811           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtLocation"
4812           MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
4813        ])
4814     fi
4815     if test "$MOZ_ENABLE_QTMOBILITY"; then
4816        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
4817     fi
4820 AC_SUBST(GTK_CONFIG)
4821 AC_SUBST(TK_CFLAGS)
4822 AC_SUBST(TK_LIBS)
4824 AC_SUBST(MOZ_ENABLE_GTK2)
4825 AC_SUBST(MOZ_ENABLE_GTK3)
4826 AC_SUBST(MOZ_ENABLE_GTK)
4827 AC_SUBST(MOZ_ENABLE_QT)
4828 AC_SUBST(MOZ_ENABLE_QTNETWORK)
4829 AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
4830 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4831 AC_SUBST(MOZ_ENABLE_XREMOTE)
4832 AC_SUBST(MOZ_GTK2_CFLAGS)
4833 AC_SUBST(MOZ_GTK2_LIBS)
4834 AC_SUBST(MOZ_GTK3_CFLAGS)
4835 AC_SUBST(MOZ_GTK3_LIBS)
4836 AC_SUBST(MOZ_WIDGET_GTK)
4837 AC_SUBST(MOZ_QT_CFLAGS)
4838 AC_SUBST(MOZ_QT_LIBS)
4840 AC_SUBST(MOC)
4841 AC_SUBST(RCC)
4843 AC_SUBST(MOZ_X11)
4845 dnl ========================================================
4846 dnl =
4847 dnl = Components & Features
4848 dnl =
4849 dnl ========================================================
4850 MOZ_ARG_HEADER(Components and Features)
4852 dnl ========================================================
4853 dnl = Localization
4854 dnl ========================================================
4855 MOZ_ARG_ENABLE_STRING(ui-locale,
4856 [  --enable-ui-locale=ab-CD
4857                           Select the user interface locale (default: en-US)],
4858     MOZ_UI_LOCALE=$enableval )
4859 AC_SUBST(MOZ_UI_LOCALE)
4861 dnl ========================================================
4862 dnl = Trademarked Branding
4863 dnl ========================================================
4864 MOZ_ARG_ENABLE_BOOL(official-branding,
4865 [  --enable-official-branding
4866                           Enable Official mozilla.org Branding
4867                           Do not distribute builds with
4868                           --enable-official-branding unless you have
4869                           permission to use trademarks per
4870                           http://www.mozilla.org/foundation/trademarks/ .],
4872   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
4873     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
4874   else
4875     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
4876     MOZ_OFFICIAL_BRANDING=1
4877   fi
4878 ], MOZ_OFFICIAL_BRANDING=)
4880 AC_SUBST(MOZ_OFFICIAL_BRANDING)
4881 if test -n "$MOZ_OFFICIAL_BRANDING"; then
4882   AC_DEFINE(MOZ_OFFICIAL_BRANDING)
4885 MOZ_ARG_WITH_STRING(branding,
4886 [  --with-branding=dir     Use branding from the specified directory.],
4887     MOZ_BRANDING_DIRECTORY=$withval)
4889 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
4890 if test -z "$REAL_BRANDING_DIRECTORY"; then
4891   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
4894 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
4895   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
4898 AC_SUBST(MOZ_BRANDING_DIRECTORY)
4900 dnl ========================================================
4901 dnl = Distribution ID
4902 dnl ========================================================
4903 MOZ_ARG_WITH_STRING(distribution-id,
4904 [  --with-distribution-id=ID
4905                           Set distribution-specific id (default=org.mozilla)],
4906 [ val=`echo $withval`
4907     MOZ_DISTRIBUTION_ID="$val"])
4909 if test -z "$MOZ_DISTRIBUTION_ID"; then
4910    MOZ_DISTRIBUTION_ID="org.mozilla"
4913 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
4914 AC_SUBST(MOZ_DISTRIBUTION_ID)
4917 dnl ========================================================
4918 dnl complex text support off by default
4919 dnl ========================================================
4920 MOZ_ARG_DISABLE_BOOL(pango,
4921 [  --disable-pango         Disable usage of Pango ],
4922     MOZ_PANGO=,
4923     MOZ_PANGO=1)
4925 dnl ========================================================
4926 dnl = Pango
4927 dnl ========================================================
4928 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4929 then
4930     AC_SUBST(MOZ_PANGO)
4932     if test "$MOZ_PANGO"
4933     then
4934         PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
4936         PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
4937         AC_SUBST(MOZ_PANGO_CFLAGS)
4938         AC_SUBST(MOZ_PANGO_LIBS)
4939         AC_DEFINE(MOZ_PANGO)
4940     else
4941         PKG_CHECK_MODULES(FT2, freetype2 > 6.1.0)
4942         AC_SUBST(FT2_CFLAGS)
4943         AC_SUBST(FT2_LIBS)
4944     fi
4947 dnl ========================================================
4948 dnl = GnomeVFS, GIO and GConf support module
4949 dnl ========================================================
4951 if test "$MOZ_X11"
4952 then
4953     dnl build the GIO extension by default only when the
4954     dnl GTK2 toolkit is in use.
4955     if test "$MOZ_ENABLE_GTK"
4956     then
4957         MOZ_ENABLE_GIO=1
4958         MOZ_ENABLE_GCONF=1
4959     fi
4961     dnl ========================================================
4962     dnl = GnomeVFS support module
4963     dnl ========================================================
4964     MOZ_ARG_ENABLE_BOOL(gnomevfs,
4965     [  --enable-gnomevfs       Enable GnomeVFS support (default: disabled)],
4966         MOZ_ENABLE_GNOMEVFS=force,
4967         MOZ_ENABLE_GNOMEVFS=)
4969     if test "$MOZ_ENABLE_GNOMEVFS"
4970     then
4971         PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
4972             MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
4973             MOZ_ENABLE_GNOMEVFS=1
4974             AC_DEFINE(MOZ_ENABLE_GNOMEVFS)
4975         ],[
4976             if test "$MOZ_ENABLE_GNOMEVFS" = "force"
4977             then
4978                 AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
4979             fi
4980             MOZ_ENABLE_GNOMEVFS=
4981         ])
4982     fi
4984     AC_SUBST(MOZ_ENABLE_GNOMEVFS)
4985     AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
4986     AC_SUBST(MOZ_GNOMEVFS_LIBS)
4988     dnl ========================================================
4989     dnl = GIO support module
4990     dnl ========================================================
4991     MOZ_ARG_DISABLE_BOOL(gio,
4992     [  --disable-gio           Disable GIO support],
4993         MOZ_ENABLE_GIO=,
4994         MOZ_ENABLE_GIO=force)
4996     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK"
4997     then
4998         PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
4999                           [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
5000         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
5001             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
5002             MOZ_ENABLE_GIO=1
5003             AC_DEFINE(MOZ_ENABLE_GIO)
5004         ],[
5005             if test "$MOZ_ENABLE_GIO" = "force"
5006             then
5007                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
5008             fi
5009             MOZ_ENABLE_GIO=
5010         ])
5011     fi
5013     AC_SUBST(MOZ_ENABLE_GIO)
5014     AC_SUBST(MOZ_GIO_CFLAGS)
5015     AC_SUBST(MOZ_GIO_LIBS)
5017     dnl ========================================================
5018     dnl = GConf support module
5019     dnl ========================================================
5020     MOZ_ARG_DISABLE_BOOL(gconf,
5021     [  --disable-gconf      Disable Gconf support ],
5022         MOZ_ENABLE_GCONF=,
5023         MOZ_ENABLE_GCONF=force)
5025     if test "$MOZ_ENABLE_GCONF"
5026     then
5027         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
5028             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
5029             MOZ_ENABLE_GCONF=1
5030         ],[
5031             if test "$MOZ_ENABLE_GCONF" = "force"
5032             then
5033                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
5034             fi
5035             MOZ_ENABLE_GCONF=
5036         ])
5037     fi
5039     if test "$MOZ_ENABLE_GCONF"; then
5040         AC_DEFINE(MOZ_ENABLE_GCONF)
5041     fi
5043     AC_SUBST(MOZ_ENABLE_GCONF)
5044     AC_SUBST(MOZ_GCONF_CFLAGS)
5045     AC_SUBST(MOZ_GCONF_LIBS)
5048 dnl ========================================================
5049 dnl = libproxy support
5050 dnl ========================================================
5052 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
5053 then
5054     MOZ_ENABLE_LIBPROXY=
5056     MOZ_ARG_ENABLE_BOOL(libproxy,
5057     [  --enable-libproxy         Enable libproxy support ],
5058     MOZ_ENABLE_LIBPROXY=1,
5059     MOZ_ENABLE_LIBPROXY=)
5061     if test "$MOZ_ENABLE_LIBPROXY"
5062     then
5063         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
5064         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
5065     fi
5067 AC_SUBST(MOZ_ENABLE_LIBPROXY)
5068 AC_SUBST(MOZ_LIBPROXY_CFLAGS)
5069 AC_SUBST(MOZ_LIBPROXY_LIBS)
5071 dnl ========================================================
5072 dnl = GNOME component (mozgnome)
5073 dnl ========================================================
5075 if test "$MOZ_ENABLE_GTK2"
5076 then
5077     MOZ_ENABLE_GNOME_COMPONENT=1
5079 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
5081 dnl ========================================================
5082 dnl = libgnomeui support module
5083 dnl ========================================================
5085 if test "$MOZ_ENABLE_GTK"
5086 then
5087     MOZ_ARG_ENABLE_BOOL(gnomeui,
5088     [  --enable-gnomeui        Enable libgnomeui instead of GIO & GTK for icon theme support ],
5089         MOZ_ENABLE_GNOMEUI=force,
5090         MOZ_ENABLE_GNOMEUI=)
5092     if test "$MOZ_ENABLE_GNOMEUI"
5093     then
5094         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
5095         [
5096             MOZ_ENABLE_GNOMEUI=1
5097         ],[
5098             if test "$MOZ_ENABLE_GNOMEUI" = "force"
5099             then
5100                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
5101             fi
5102             MOZ_ENABLE_GNOMEUI=
5103         ])
5104     fi
5106     if test "$MOZ_ENABLE_GNOMEUI"; then
5107         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
5108     fi
5111 AC_SUBST(MOZ_ENABLE_GNOMEUI)
5112 AC_SUBST(MOZ_GNOMEUI_CFLAGS)
5114 dnl ========================================================
5115 dnl = dbus support
5116 dnl ========================================================
5118 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
5119 then
5120     MOZ_ENABLE_DBUS=1
5122     MOZ_ARG_DISABLE_BOOL(dbus,
5123     [  --disable-dbus          Disable dbus support ],
5124         MOZ_ENABLE_DBUS=,
5125         MOZ_ENABLE_DBUS=1)
5127     if test "$MOZ_ENABLE_DBUS"
5128     then
5129         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
5130         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
5131         AC_DEFINE(MOZ_ENABLE_DBUS)
5132     fi
5134 AC_SUBST(MOZ_ENABLE_DBUS)
5135 AC_SUBST(MOZ_DBUS_CFLAGS)
5136 AC_SUBST(MOZ_DBUS_LIBS)
5137 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
5138 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
5140 dnl ========================================================
5141 dnl = Enable Android History instead of Places
5142 dnl ========================================================
5143 if test -n "$MOZ_ANDROID_HISTORY"; then
5144     if test -z "$MOZ_PLACES"; then
5145         AC_DEFINE(MOZ_ANDROID_HISTORY)
5146     else
5147         AC_MSG_ERROR([Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.])
5148     fi
5151 dnl ========================================================
5152 dnl = Build with the Android compositor
5153 dnl ========================================================
5154 if test -n "$MOZ_ANDROID_OMTC"; then
5155      dnl Do this if defined in confvars.sh
5156      AC_DEFINE(MOZ_ANDROID_OMTC)
5159 dnl ========================================================
5160 dnl = Disable WebSMS backend
5161 dnl ========================================================
5162 MOZ_ARG_DISABLE_BOOL(websms-backend,
5163 [  --disable-websms-backend
5164                            Disable WebSMS backend],
5165     MOZ_WEBSMS_BACKEND=,
5166     MOZ_WEBSMS_BACKEND=1)
5168 if test -n "$MOZ_WEBSMS_BACKEND"; then
5169     AC_DEFINE(MOZ_WEBSMS_BACKEND)
5172 dnl ========================================================
5173 dnl = Enable NFC permission on Android
5174 dnl ========================================================
5175 if test -n "$MOZ_ANDROID_BEAM"; then
5176     AC_DEFINE(MOZ_ANDROID_BEAM)
5179 dnl ========================================================
5180 dnl = JS Debugger XPCOM component (js/jsd)
5181 dnl ========================================================
5182 MOZ_ARG_DISABLE_BOOL(jsd,
5183 [  --disable-jsd           Disable JavaScript debug library],
5184     MOZ_JSDEBUGGER=,
5185     MOZ_JSDEBUGGER=1)
5188 dnl ========================================================
5189 dnl = Enable IPDL's "expensive" unit tests
5190 dnl ========================================================
5191 MOZ_IPDL_TESTS=
5193 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
5194 [  --enable-ipdl-tests     Enable expensive IPDL tests],
5195     MOZ_IPDL_TESTS=1,
5196     MOZ_IPDL_TESTS=)
5198 if test -n "$MOZ_IPDL_TESTS"; then
5199     AC_DEFINE(MOZ_IPDL_TESTS)
5202 AC_SUBST(MOZ_IPDL_TESTS)
5204 dnl ========================================================
5205 dnl = Disable building dbm
5206 dnl ========================================================
5207 MOZ_ARG_DISABLE_BOOL(dbm,
5208 [  --disable-dbm           Disable building dbm],
5209     NSS_DISABLE_DBM=1,
5210     NSS_DISABLE_DBM=)
5212 dnl bi-directional support always on
5213 IBMBIDI=1
5214 AC_DEFINE(IBMBIDI)
5216 dnl ========================================================
5217 dnl accessibility support on by default on all platforms
5218 dnl ========================================================
5219 MOZ_ARG_DISABLE_BOOL(accessibility,
5220 [  --disable-accessibility Disable accessibility support],
5221     ACCESSIBILITY=,
5222     ACCESSIBILITY=1 )
5223 if test "$ACCESSIBILITY"; then
5224     case "$target" in
5225     *-mingw*)
5226         if test -z "$MIDL"; then
5227             if test "$GCC" != "yes"; then
5228                 AC_MSG_ERROR([MIDL could not be found. Building accessibility without MIDL is not supported.])
5229             else
5230                 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.])
5231             fi
5232         fi
5233     esac
5234     AC_DEFINE(ACCESSIBILITY)
5237 dnl ========================================================
5238 dnl Accessibility is required for the linuxgl widget
5239 dnl backend
5240 dnl ========================================================
5241 if test "${MOZ_WIDGET_TOOLKIT}" = "linuxgl" -a "$ACCESSIBILITY" != "1"; then
5242     AC_MSG_ERROR(["Accessibility is required for the linuxgl widget backend"])
5245 dnl ========================================================
5246 dnl Disable printing
5247 dnl ========================================================
5248 MOZ_ARG_DISABLE_BOOL(printing,
5249 [  --disable-printing      Disable printing support],
5250     NS_PRINTING=,
5251     NS_PRINTING=1)
5253 if test "$NS_PRINTING"; then
5254     AC_DEFINE(NS_PRINTING)
5255     AC_DEFINE(NS_PRINT_PREVIEW)
5258 dnl Turn off webrtc for OS's we don't handle yet, but allow 
5259 dnl --enable-webrtc to override.  Can disable for everything in
5260 dnl the master list above.
5261 if test -n "$MOZ_WEBRTC"; then
5262     case "$target" in
5263     *-linux*|*-mingw*|*-darwin*|*-android*|*-linuxandroid*)
5264         dnl Leave enabled
5265         ;;
5266     *)
5267         dnl default to disabled for all others
5268         MOZ_WEBRTC=
5269         ;;
5270     esac
5273 # target_arch is from {ia32|x64|arm|ppc}
5274 case "$CPU_ARCH" in
5275 x86_64)
5276     WEBRTC_TARGET_ARCH=x64
5277     ;;
5279 arm*)
5280     WEBRTC_TARGET_ARCH=arm
5281     ;;
5283 x86)
5284     WEBRTC_TARGET_ARCH=ia32
5285     ;;
5287 ppc*)
5288     WEBRTC_TARGET_ARCH=ppc
5289     ;;
5290 ia64)
5291     WEBRTC_TARGET_ARCH=ia64
5292     ;;
5294 # unsupported arch for webrtc
5295     WEBRTC_TARGET_ARCH=unknown
5296     MOZ_WEBRTC=
5297     ;;
5299 esac
5301 dnl ========================================================
5302 dnl = Disable WebRTC code
5303 dnl ========================================================
5304 MOZ_ARG_DISABLE_BOOL(webrtc,
5305 [  --disable-webrtc        Disable support for WebRTC],
5306     MOZ_WEBRTC=,
5307     MOZ_WEBRTC=1)
5309 if test -n "$MOZ_WEBRTC"; then
5310     AC_DEFINE(MOZ_WEBRTC)
5311     dnl MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
5312     dnl opt/production builds (via MOZ_CRASH())
5313     AC_DEFINE(MOZ_WEBRTC_ASSERT_ALWAYS)
5314     MOZ_RAW=1
5315     MOZ_VP8=1
5316     MOZ_VP8_ENCODER=1
5317     MOZ_VP8_ERROR_CONCEALMENT=1
5319 dnl enable once Signaling lands
5320     MOZ_WEBRTC_SIGNALING=1
5321     AC_DEFINE(MOZ_WEBRTC_SIGNALING)
5322     if test "${OS_TARGET}" = "WINNT"; then
5323         MOZ_WEBRTC_IN_LIBXUL=1
5324     fi
5325 dnl enable once PeerConnection lands
5326     MOZ_PEERCONNECTION=1
5327     AC_DEFINE(MOZ_PEERCONNECTION)
5328     MOZ_SCTP=1
5329     MOZ_SRTP=1
5330     AC_DEFINE(MOZ_SCTP)
5331     AC_DEFINE(MOZ_SRTP)
5334 AC_SUBST(MOZ_WEBRTC)
5335 AC_SUBST(MOZ_WEBRTC_LEAKING_TESTS)
5336 AC_SUBST(MOZ_WEBRTC_SIGNALING)
5337 AC_SUBST(MOZ_PEERCONNECTION)
5338 AC_SUBST(MOZ_WEBRTC_IN_LIBXUL)
5339 AC_SUBST(MOZ_WEBRTC_ASSERT_ALWAYS)
5340 AC_SUBST(MOZ_SCTP)
5341 AC_SUBST(MOZ_SRTP)
5343 dnl Use integers over floats for audio on B2G and Android, because audio
5344 dnl backends for those platforms don't support floats.
5345 if test "$OS_TARGET" = "Android"; then
5346     MOZ_SAMPLE_TYPE_S16=1
5347     AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
5348     AC_SUBST(MOZ_SAMPLE_TYPE_S16)
5349 else
5350     MOZ_SAMPLE_TYPE_FLOAT32=1
5351     AC_DEFINE(MOZ_SAMPLE_TYPE_FLOAT32)
5352     AC_SUBST(MOZ_SAMPLE_TYPE_FLOAT32)
5355 dnl ========================================================
5356 dnl = Disable Speech API code
5357 dnl ========================================================
5358 MOZ_ARG_DISABLE_BOOL(webspeech,
5359 [  --disable-webspeech        Disable support for HTML Speech API],
5360     MOZ_WEBSPEECH=,
5361     MOZ_WEBSPEECH=1)
5363 if test -n "$MOZ_WEBSPEECH"; then
5364     AC_DEFINE(MOZ_WEBSPEECH)
5367 AC_SUBST(MOZ_WEBSPEECH)
5369 dnl ========================================================
5370 dnl = Enable Raw Codecs
5371 dnl ========================================================
5372 MOZ_ARG_ENABLE_BOOL(raw,
5373 [  --enable-raw           Enable support for RAW media],
5374     MOZ_RAW=1,
5375     MOZ_RAW=)
5377 if test -n "$MOZ_RAW"; then
5378     AC_DEFINE(MOZ_RAW)
5381 AC_SUBST(MOZ_RAW)
5383 dnl ========================================================
5384 dnl = Disable Ogg Codecs
5385 dnl ========================================================
5386 MOZ_ARG_DISABLE_BOOL(ogg,
5387 [  --disable-ogg           Disable support for OGG media (Theora video and Vorbis audio)],
5388     MOZ_OGG=,
5389     MOZ_OGG=1)
5391 if test -n "$MOZ_OGG"; then
5392     AC_DEFINE(MOZ_OGG)
5393     MOZ_CUBEB=1
5395     dnl Checks for __attribute__(aligned()) directive
5396     AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5397         [ac_cv_c_attribute_aligned],
5398         [ac_cv_c_attribute_aligned=0
5399          CFLAGS_save="${CFLAGS}"
5400          CFLAGS="${CFLAGS} -Werror"
5401          for ac_cv_c_attr_align_try in 64 32 16 8; do
5402            echo "trying $ac_cv_c_attr_align_try"
5403            AC_TRY_COMPILE([],
5404                           [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5405                           [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5406            if test "$ac_cv_c_attribute_aligned" != 0; then
5407              break;
5408            fi
5409          done
5410            CFLAGS="${CFLAGS_save}"])
5411     if test "${ac_cv_c_attribute_aligned}" != "0"; then
5412       AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5413                          [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5414     fi
5417 dnl ========================================================
5418 dnl = Disable Opus audio codec support
5419 dnl ========================================================
5420 MOZ_ARG_DISABLE_BOOL(opus,
5421 [  --disable-opus          Disable support for Opus audio],
5422     MOZ_OPUS=,
5423     MOZ_OPUS=1)
5425 dnl ========================================================
5426 dnl = Disable VP8 decoder support
5427 dnl ========================================================
5428 MOZ_ARG_DISABLE_BOOL(webm,
5429 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
5430     MOZ_WEBM=,
5431     MOZ_WEBM=1)
5433 if test -n "$MOZ_WEBM"; then
5434     AC_DEFINE(MOZ_WEBM)
5435     MOZ_VP8=1
5438 dnl ========================================================
5439 dnl = DirectShow support
5440 dnl ========================================================
5441 if test "$OS_ARCH" = "WINNT"; then
5442     dnl Enable DirectShow support by default.
5443     MOZ_DIRECTSHOW=1
5446 MOZ_ARG_DISABLE_BOOL(directshow,
5447 [  --disable-directshow  Disable support for DirectShow],
5448     MOZ_DIRECTSHOW=,
5449     MOZ_DIRECTSHOW=1)
5451 if test -n "$MOZ_DIRECTSHOW"; then
5452     AC_DEFINE(MOZ_DIRECTSHOW)
5453     MOZ_CUBEB=1
5456 dnl ========================================================
5457 dnl = Windows Media Foundation support
5458 dnl ========================================================
5459 if test "$OS_ARCH" = "WINNT"; then
5460     dnl Enable Windows Media Foundation support by default.
5461     dnl Note our minimum SDK version is Windows 7 SDK, so we are (currently)
5462     dnl guaranteed to have a recent-enough SDK to build WMF.
5463     MOZ_WMF=1
5466 MOZ_ARG_DISABLE_BOOL(wmf,
5467 [  --disable-wmf  Disable support for Windows Media Foundation],
5468     MOZ_WMF=,
5469     MOZ_WMF=1)
5471 if test -n "$MOZ_WMF"; then
5472     AC_DEFINE(MOZ_WMF)
5473     MOZ_CUBEB=1
5476 dnl ========================================================
5477 dnl = Enable media plugin support
5478 dnl ========================================================
5479 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5480   dnl Enable support on android by default
5481   MOZ_MEDIA_PLUGINS=1
5484 MOZ_ARG_ENABLE_BOOL(media-plugins,
5485 [  --enable-media-plugins  Enable support for media plugins],
5486     MOZ_MEDIA_PLUGINS=1,
5487     MOZ_MEDIA_PLUGINS=)
5489 if test -n "$MOZ_MEDIA_PLUGINS"; then
5490   AC_DEFINE(MOZ_MEDIA_PLUGINS)
5493 dnl ========================================================
5494 dnl = Enable getUserMedia support
5495 dnl ========================================================
5496 MOZ_ARG_ENABLE_BOOL(media-navigator,
5497 [  --enable-media-navigator  Enable support for getUserMedia],
5498     MOZ_MEDIA_NAVIGATOR=1,
5499     MOZ_MEDIA_NAVIGATOR=)
5501 if test -n "$MOZ_MEDIA_NAVIGATOR"; then
5502   AC_DEFINE(MOZ_MEDIA_NAVIGATOR)
5505 dnl ========================================================
5506 dnl = Enable building OMX media plugin (B2G or Android)
5507 dnl ========================================================
5508 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5509   dnl Enable support on android by default
5510   MOZ_OMX_PLUGIN=1
5513 MOZ_ARG_ENABLE_BOOL(omx-plugin,
5514 [  --enable-omx-plugin      Enable building OMX plugin (B2G)],
5515     MOZ_OMX_PLUGIN=1,
5516     MOZ_OMX_PLUGIN=)
5518 if test -n "$MOZ_OMX_PLUGIN"; then
5519     if test "$OS_TARGET" = "Android"; then
5520         dnl Only allow building OMX plugin on Gonk (B2G) or Android
5521         AC_DEFINE(MOZ_OMX_PLUGIN)
5522     else
5523        dnl fail if we're not building on Gonk or Android
5524        AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
5525     fi
5528 dnl system libvpx Support
5529 dnl ========================================================
5530 MOZ_ARG_WITH_BOOL(system-libvpx,
5531 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
5532     MOZ_NATIVE_LIBVPX=1)
5534 MOZ_LIBVPX_CFLAGS=
5535 MOZ_LIBVPX_LIBS=
5537 if test -n "$MOZ_VP8"; then
5538     AC_DEFINE(MOZ_VP8)
5539     if test -n "$MOZ_VP8_ERROR_CONCEALMENT" ; then
5540         AC_DEFINE(MOZ_VP8_ERROR_CONCEALMENT)
5541     fi
5542     if test -n "$MOZ_VP8_ENCODER" ; then
5543         AC_DEFINE(MOZ_VP8_ENCODER)
5544     fi
5546     if test -n "$MOZ_NATIVE_LIBVPX"; then
5547         dnl ============================
5548         dnl === libvpx Version check ===
5549         dnl ============================
5550         dnl Check to see if we have a system libvpx package.
5551         PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.0.0)
5553         MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [], 
5554          [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.])])
5556         _SAVE_LIBS=$LIBS
5557         AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [], 
5558          [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
5559         LIBS=$_SAVE_LIBS
5560     fi
5563 AC_SUBST(MOZ_NATIVE_LIBVPX)
5564 AC_SUBST(MOZ_LIBVPX_CFLAGS)
5565 AC_SUBST(MOZ_LIBVPX_LIBS)
5567 if test "$MOZ_WEBM"; then
5568     MOZ_CUBEB=1
5569     if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then
5570         MOZ_VORBIS=1
5571     else
5572         MOZ_TREMOR=1
5573     fi
5576 if test -n "$MOZ_VP8" -a -z "$MOZ_NATIVE_LIBVPX"; then
5578     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
5579     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
5580     dnl We currently require gcc on all arm platforms.
5581     VPX_AS=$YASM
5582     VPX_ASM_SUFFIX=asm
5583     VPX_NEED_OBJ_INT_EXTRACT=
5585     dnl See if we have assembly on this platform.
5586     case "$OS_ARCH:$CPU_ARCH" in
5587     Darwin:x86)
5588       VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
5589       VPX_X86_ASM=1
5590     ;;
5591     Darwin:x86_64)
5592       VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
5593       VPX_X86_ASM=1
5594     ;;
5595     WINNT:x86_64)
5596       VPX_ASFLAGS="-f x64 -rnasm -pnasm"
5597       VPX_X86_ASM=1
5598     ;;
5599     WINNT:x86)
5600       dnl Check for yasm 1.1 or greater.
5601       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
5602         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.])
5603       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5604         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.])
5605       else
5606         VPX_ASFLAGS="-f win32 -rnasm -pnasm -DPIC"
5607         VPX_X86_ASM=1
5608         dnl The encoder needs obj_int_extract to get asm offsets.
5609       fi
5610     ;;
5611     *:arm*)
5612       if test -n "$GNU_AS" ; then
5613         VPX_AS=$AS
5614         dnl These flags are a lie; they're just used to enable the requisite
5615         dnl opcodes; actual arch detection is done at runtime.
5616         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
5617         VPX_DASH_C_FLAG="-c"
5618         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
5619         VPX_ASM_SUFFIX="$ASM_SUFFIX"
5620         VPX_ARM_ASM=1
5621       fi
5622     ;;
5623     *:x86)
5624       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5625         VPX_ASFLAGS="-f elf32 -rnasm -pnasm"
5626         VPX_X86_ASM=1
5627       fi
5628     ;;
5629     *:x86_64)
5630       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5631         VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5632         VPX_X86_ASM=1
5633       fi
5634     ;;
5635     esac
5637     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_X86_ASM" -a -z "$VPX_AS"; then
5638       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.])
5639     fi
5641     if test -n "$MOZ_VP8_ENCODER" -a \
5642             -z "$GNU_CC" -a -z "$INTEL_CC" -a -z "$CLANG_CC" ; then
5643       dnl We prefer to get asm offsets using inline assembler, which the above
5644       dnl compilers can do. When we're not using one of those, we have to fall
5645       dnl back to obj_int_extract, which reads them from a compiled object
5646       dnl file. Unfortunately, that only works if we're compiling on a system
5647       dnl with the header files for the appropriate object file format.
5648       VPX_NEED_OBJ_INT_EXTRACT=1
5649     fi
5651     if test -n "$VPX_X86_ASM"; then
5652       AC_DEFINE(VPX_X86_ASM)
5653     elif test -n "$VPX_ARM_ASM"; then
5654       AC_DEFINE(VPX_ARM_ASM)
5655     else
5656       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
5657     fi
5660 dnl ========================================================
5661 dnl = Disable Wave decoder support
5662 dnl ========================================================
5663 MOZ_ARG_DISABLE_BOOL(wave,
5664 [  --disable-wave          Disable Wave decoder support],
5665     MOZ_WAVE=,
5666     MOZ_WAVE=1)
5668 if test -n "$MOZ_WAVE"; then
5669     AC_DEFINE(MOZ_WAVE)
5670     MOZ_CUBEB=1
5673 dnl ========================================================
5674 dnl = Handle dependent CUBEB and MEDIA defines
5675 dnl ========================================================
5677 if test -n "$MOZ_SPEEX_RESAMPLER"; then
5678     AC_DEFINE(MOZ_SPEEX_RESAMPLER)
5681 if test -n "$MOZ_SOUNDTOUCH"; then
5682     AC_DEFINE(MOZ_SOUNDTOUCH)
5685 if test -n "$MOZ_CUBEB"; then
5686     AC_DEFINE(MOZ_CUBEB)
5689 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
5690     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/])
5693 if test -n "$MOZ_VORBIS"; then
5694     AC_DEFINE(MOZ_VORBIS)
5697 if test -n "$MOZ_TREMOR"; then
5698     AC_DEFINE(MOZ_TREMOR)
5701 if test -n "$MOZ_OPUS"; then
5702     AC_DEFINE(MOZ_OPUS)
5705 dnl ========================================================
5706 dnl = Check alsa availability on Linux if using sydneyaudio
5707 dnl ========================================================
5709 dnl If using sydneyaudio with Linux, ensure that the alsa library is available
5710 if test -n "$MOZ_CUBEB" -a "$OS_TARGET" = "Linux"; then
5711     MOZ_ALSA=1
5714 MOZ_ARG_ENABLE_BOOL(alsa,
5715 [  --enable-alsa          Enable Alsa support (default on Linux)],
5716 MOZ_ALSA=1,
5717 MOZ_ALSA=)
5719 if test -n "$MOZ_ALSA"; then
5720     AC_DEFINE(MOZ_CUBEB)
5721     PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5722          [echo "$MOZ_ALSA_PKG_ERRORS"
5723           AC_MSG_ERROR([Need alsa for Ogg, Wave or WebM decoding on Linux.  Disable with --disable-ogg --disable-wave --disable-webm.  (On Ubuntu, you might try installing the package libasound2-dev.)])])
5726 AC_SUBST(MOZ_ALSA)
5727 AC_SUBST(MOZ_ALSA_CFLAGS)
5728 AC_SUBST(MOZ_ALSA_LIBS)
5730 dnl ========================================================
5731 dnl = Enable PulseAudio
5732 dnl ========================================================
5734 MOZ_ARG_ENABLE_BOOL(pulseaudio,
5735 [  --enable-pulseaudio          Enable PulseAudio support (experimental)],
5736 MOZ_PULSEAUDIO=1,
5737 MOZ_PULSEAUDIO=)
5739 if test -n "$MOZ_PULSEAUDIO"; then
5740     AC_DEFINE(MOZ_CUBEB)
5741     if test -z "$gonkdir"; then
5742         PKG_CHECK_MODULES(MOZ_PULSEAUDIO, libpulse, ,
5743              [echo "$MOZ_PULSEAUDIO_PKG_ERRORS"
5744               AC_MSG_ERROR([pulseaudio audio backend requires libpulse development package])])
5745     else
5746         MOZ_PULSEAUDIO_CFLAGS="-I$gonkdir/external/pulseaudio/pulseaudio/src"
5747         MOZ_PULSEAUDIO_LIBS="-lpulse"
5748     fi
5751 AC_SUBST(MOZ_PULSEAUDIO)
5752 AC_SUBST(MOZ_PULSEAUDIO_CFLAGS)
5753 AC_SUBST(MOZ_PULSEAUDIO_LIBS)
5755 dnl ========================================================
5756 dnl = Enable GStreamer
5757 dnl ========================================================
5758 if test "$OS_TARGET" = "Linux"; then
5759   MOZ_GSTREAMER=1
5762 MOZ_ARG_ENABLE_BOOL(gstreamer,
5763 [  --enable-gstreamer           Enable GStreamer support],
5764 MOZ_GSTREAMER=1,
5765 MOZ_GSTREAMER=)
5767 if test "$MOZ_GSTREAMER"; then
5768     # API version, eg 0.10, 1.0 etc
5769     GST_API_VERSION=0.10
5770     # core/base release number
5771     GST_VERSION=0.10.25
5772     PKG_CHECK_MODULES(GSTREAMER,
5773                       gstreamer-$GST_API_VERSION >= $GST_VERSION
5774                       gstreamer-app-$GST_API_VERSION
5775                       gstreamer-plugins-base-$GST_API_VERSION, ,
5776                       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]))
5777     if test -n "$GSTREAMER_LIBS"; then
5778        _SAVE_LDFLAGS=$LDFLAGS
5779        LDFLAGS="$LDFLAGS $GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5780        AC_TRY_LINK(,[return 0;],_HAVE_LIBGSTVIDEO=1,_HAVE_LIBGSTVIDEO=)
5781        if test -n "$_HAVE_LIBGSTVIDEO" ; then
5782           GSTREAMER_LIBS="$GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5783        else
5784           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.])
5785        fi
5786        LDFLAGS=$_SAVE_LDFLAGS
5787     else
5788        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])
5789     fi
5791 AC_SUBST(GSTREAMER_CFLAGS)
5792 AC_SUBST(GSTREAMER_LIBS)
5793 AC_SUBST(MOZ_GSTREAMER)
5795 if test -n "$MOZ_GSTREAMER"; then
5796    AC_DEFINE(MOZ_GSTREAMER)
5800 dnl ========================================================
5801 dnl Permissions System
5802 dnl ========================================================
5803 MOZ_ARG_DISABLE_BOOL(permissions,
5804 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5805     MOZ_PERMISSIONS=,
5806     MOZ_PERMISSIONS=1
5809 dnl ========================================================
5810 dnl Child permissions, currently only used for b2g
5811 dnl ========================================================
5812 if test -n "$MOZ_B2G"; then
5813     if test -n "$MOZ_PERMISSIONS"; then
5814         MOZ_CHILD_PERMISSIONS=1
5815     else
5816         AC_MSG_ERROR([You need to enable MOZ_PERMISSIONS for MOZ_CHILD_PERMISSIONS])
5817     fi
5819 AC_SUBST(MOZ_CHILD_PERMISSIONS)
5821 dnl ========================================================
5822 dnl NegotiateAuth
5823 dnl ========================================================
5824 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5825 [  --disable-negotiateauth Disable GSS-API negotiation ],
5826     MOZ_AUTH_EXTENSION=,
5827     MOZ_AUTH_EXTENSION=1 )
5829 dnl ========================================================
5830 dnl Pref extensions (autoconfig)
5831 dnl ========================================================
5832 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5833 [  --disable-pref-extensions
5834                           Disable pref extensions such as autoconfig],
5835   MOZ_PREF_EXTENSIONS=,
5836   MOZ_PREF_EXTENSIONS=1 )
5838 dnl ========================================================
5839 dnl Searching of system directories for extensions.
5840 dnl Note: this switch is meant to be used for test builds
5841 dnl whose behavior should not depend on what happens to be
5842 dnl installed on the local machine.
5843 dnl ========================================================
5844 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
5845 [  --disable-system-extension-dirs
5846                           Disable searching system- and account-global
5847                           directories for extensions of any kind; use
5848                           only profile-specific extension directories],
5849   ENABLE_SYSTEM_EXTENSION_DIRS=,
5850   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
5851 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
5852   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
5855 dnl ========================================================
5856 dnl = Universalchardet
5857 dnl ========================================================
5858 MOZ_ARG_DISABLE_BOOL(universalchardet,
5859 [  --disable-universalchardet
5860                           Disable universal encoding detection],
5861   MOZ_UNIVERSALCHARDET=,
5862   MOZ_UNIVERSALCHARDET=1 )
5864 if test -n "${JAVA_BIN_PATH}"; then
5865   dnl Look for javac and jar in the specified path.
5866   JAVA_PATH="$JAVA_BIN_PATH"
5867 else
5868   dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5869   JAVA_PATH="$JAVA_HOME/bin:$PATH"
5872 MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5873 MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5874 MOZ_PATH_PROG(JAVAH, javah, :, [$JAVA_PATH])
5875 MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5876 MOZ_PATH_PROG(JARSIGNER, jarsigner, :, [$JAVA_PATH])
5877 MOZ_PATH_PROG(KEYTOOL, keytool, :, [$JAVA_PATH])
5879 if test -n "${JAVA_BIN_PATH}" -o \
5880   \( "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk" \); then
5881   if test -z "$JAVA" -o "$JAVA" = ":"; then
5882     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}])
5883   fi
5884   if test -z "$JAVAC" -o "$JAVAC" = ":"; then
5885     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}])
5886   fi
5887   if test -z "$JAVAH" -o "$JAVAH" = ":"; then
5888     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}])
5889   fi
5890   if test -z "$JAR" -o "$JAR" = ":"; then
5891     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}])
5892   fi
5893   if test -z "$JARSIGNER" -o "$JARSIGNER" = ":"; then
5894     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}])
5895   fi
5896   if test -z "$KEYTOOL" -o "$KEYTOOL" = ":"; then
5897     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}])
5898   fi
5901 dnl ========================================================
5902 dnl = ANGLE OpenGL->D3D translator for WebGL
5903 dnl = * only applies to win32
5904 dnl = * enabled by default (shipping build); requires explicit --disable to disable
5905 dnl ========================================================
5906 MOZ_ANGLE_RENDERER=
5907 MOZ_DIRECTX_SDK_PATH=
5908 MOZ_DIRECTX_SDK_CPU_SUFFIX=
5909 MOZ_D3DCOMPILER_CAB=
5910 MOZ_D3DCOMPILER_DLL=
5911 case "$target_os" in
5912 *mingw*)
5913     MOZ_ANGLE_RENDERER=1
5914     ;;
5915 esac
5917 # The DirectX SDK libraries are split into x86 and x64 sub-directories
5918 case "${target_cpu}" in
5919 i*86)
5920   MOZ_DIRECTX_SDK_CPU_SUFFIX=x86
5921   ;;
5922 x86_64)
5923   MOZ_DIRECTX_SDK_CPU_SUFFIX=x64
5924   ;;
5925 esac
5927 MOZ_ARG_DISABLE_BOOL(webgl,
5928 [  --disable-webgl     Disable building of the WebGL implementation],
5929     MOZ_WEBGL_DISABLED=1,
5930     MOZ_WEBGL_DISABLED=)
5932 if test -n "$MOZ_WEBGL_DISABLED"; then
5933   MOZ_WEBGL=
5934   MOZ_ANGLE_RENDERER=
5937 if test -n "$MOZ_WEBGL"; then
5938   AC_DEFINE(MOZ_WEBGL)
5941 if test -n "$MOZ_WEBGL_CONFORMANT"; then
5942   AC_DEFINE(MOZ_WEBGL_CONFORMANT)
5945 # Locate a DirectX SDK here so we can use it for both ANGLE and
5946 # Joystick support.
5947 if test "$OS_TARGET" = "WINNT" -a -z "$CROSS_COMPILE"; then
5948   # Get the SDK path from the registry.
5949   # First try to get the June 2010 SDK
5950   MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK (June 2010)' | head -n 1`
5951   if test -z "$MOZ_DIRECTX_SDK_REG_KEY" ; then
5952     # Otherwise just take whatever comes first
5953     MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK' | head -n 1`
5954   fi
5955   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'`
5958 if test -n "$MOZ_ANGLE_RENDERER" -a -z "$CROSS_COMPILE"; then
5959   if test -n "`echo $MOZ_DIRECTX_SDK_REG_KEY | grep 'February 2010'`" ; then
5960     AC_MSG_ERROR([Found the February 2010 DirectX SDK. Need the June 2010 DirectX SDK, or newer.  Upgrade your SDK or reconfigure with --disable-webgl.])
5961   fi
5963   if test -n "$MOZ_DIRECTX_SDK_PATH" &&
5964      test -f "$MOZ_DIRECTX_SDK_PATH"/include/d3dx9.h &&
5965          test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5966     AC_MSG_RESULT([Found DirectX SDK via registry, using $MOZ_DIRECTX_SDK_PATH])
5967   else
5968     AC_MSG_ERROR([Couldn't find the DirectX SDK, needed for WebGL. Either install it (June 2010 version or newer), or reconfigure with --disable-webgl.])
5969   fi
5971   # Get the SDK numeric version (e.g. 43) by looking at the dependencies of d3dx9.lib
5972   MOZ_D3DX9_VERSION=`dumpbin //headers "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/d3dx9.lib | egrep d3dx9_[[0-9]][[0-9]]\.dll | head -n1 | sed 's/.*\([[0-9]][[0-9]]\).*/\\1/g'`
5974   if test -z "$MOZ_D3DX9_VERSION" ; then
5975         AC_MSG_ERROR([Couldn't determine the D3DX9 version, needed for WebGL. Either reinstall the DirectX SDK (June 2010 version or newer), or reconfigure with --disable-webgl.])
5976   fi
5978   MOZ_D3DCOMPILER_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *D3DCompiler_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
5980   if test -z "$MOZ_D3DCOMPILER_CAB"; then
5981     AC_MSG_ERROR([Couldn't find the DirectX redistributable files. Either reinstall the DirectX SDK (making sure the "DirectX Redistributable Files" option is selected), or reconfigure with --disable-webgl.])
5982   fi
5984   MOZ_D3DCOMPILER_DLL=D3DCompiler_$MOZ_D3DX9_VERSION.dll
5987 dnl ========================================================
5988 dnl Gamepad support
5989 dnl ========================================================
5990 MOZ_GAMEPAD=
5991 MOZ_GAMEPAD_BACKEND=stub
5993 # Gamepad DOM is built on supported platforms by default.
5994 case "$OS_TARGET" in
5995      Darwin|WINNT|Linux)
5996        MOZ_GAMEPAD=1
5997        ;;
5998      *)
5999        ;;
6000 esac
6002 MOZ_ARG_DISABLE_BOOL(gamepad,
6003 [  --disable-gamepad   Disable gamepad support],
6004     MOZ_GAMEPAD=,
6005     MOZ_GAMEPAD=1)
6007 if test "$MOZ_GAMEPAD"; then
6008     case "$OS_TARGET" in
6009     Darwin)
6010         MOZ_GAMEPAD_BACKEND=cocoa
6011         ;;
6012     WINNT)
6013         if test -n "$MOZ_DIRECTX_SDK_PATH" ; then
6014             if ! test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
6015                MOZ_GAMEPAD=
6016             fi
6017         elif test "$GCC" != "yes"; then
6018             MOZ_GAMEPAD=
6019         fi
6020         if test -z "$MOZ_GAMEPAD"; then
6021            AC_MSG_ERROR([Couldn't find the DirectX SDK, needed for gamepad support. Please install it or, reconfigure with --disable-gamepad to disable gamepad support.])
6022         fi
6023         MOZ_GAMEPAD_BACKEND=windows
6024         ;;
6025     Linux)
6026         MOZ_CHECK_HEADER([linux/joystick.h])
6027         if test "$ac_cv_header_linux_joystick_h" != "yes"; then
6028           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.])
6029         fi
6030         MOZ_GAMEPAD_BACKEND=linux
6031         ;;
6032     *)
6033         ;;
6034    esac
6036   AC_DEFINE(MOZ_GAMEPAD)
6038 AC_SUBST(MOZ_GAMEPAD)
6039 AC_SUBST(MOZ_GAMEPAD_BACKEND)
6041 dnl ========================================================
6042 dnl = Breakpad crash reporting (on by default on supported platforms)
6043 dnl ========================================================
6045 case $target in
6046 i?86-*-mingw*|x86_64-*-mingw*)
6047   MOZ_CRASHREPORTER=1
6048   ;;
6049 i?86-apple-darwin*|x86_64-apple-darwin*)
6050   MOZ_CRASHREPORTER=1
6051   ;;
6052 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
6053   if test "$MOZ_ENABLE_GTK"; then
6054     MOZ_CRASHREPORTER=1
6055   fi
6056   ;;
6057 *-android*|*-linuxandroid*)
6058   MOZ_CRASHREPORTER=1
6059   ;;
6060 *solaris*)
6061   MOZ_CRASHREPORTER=1
6062   ;;
6063 esac
6065 MOZ_ARG_DISABLE_BOOL(crashreporter,
6066 [  --disable-crashreporter Disable breakpad crash reporting],
6067     [MOZ_CRASHREPORTER=],
6068     [MOZ_CRASHREPORTER=F # Force enable breakpad])
6070 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT"; then
6071   if test "$MOZ_CRASHREPORTER" = F; then
6072     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
6073   fi
6074   MOZ_CRASHREPORTER=
6077 if test -n "$MOZ_CRASHREPORTER"; then
6078    AC_DEFINE(MOZ_CRASHREPORTER)
6080   if test "$OS_TARGET" = "Linux" -o "$OS_ARCH" = "SunOS" && \
6081     test -z "$SKIP_LIBRARY_CHECKS"; then
6082     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
6083     AC_SUBST(MOZ_GTHREAD_CFLAGS)
6084     AC_SUBST(MOZ_GTHREAD_LIBS)
6085   fi
6087   if test "$OS_ARCH" = "WINNT"; then
6088     if test -z "$HAVE_64BIT_OS"; then
6089       MOZ_CRASHREPORTER_INJECTOR=1
6090       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
6091     fi
6092   fi
6095 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
6096 [  --with-crashreporter-enable-percent=NN
6097                           Enable sending crash reports by default on NN% of users. (default=100)],
6098 [ val=`echo $withval | sed 's/[^0-9]//g'`
6099     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
6101 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
6102    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
6104 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
6106 dnl ========================================================
6107 dnl = libjpeg-turbo configuration
6108 dnl ========================================================
6109 MOZ_LIBJPEG_TURBO=
6110 if test -z "$MOZ_NATIVE_JPEG"; then
6111     MOZ_LIBJPEG_TURBO=1
6114 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
6115 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
6116     MOZ_LIBJPEG_TURBO=,
6117     MOZ_LIBJPEG_TURBO=1)
6119 if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
6120     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
6123 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
6124 dnl files.
6126 if test -n "$MOZ_LIBJPEG_TURBO"; then
6128   dnl Do we support libjpeg-turbo on this platform?
6129   case "$OS_ARCH:$OS_TEST" in
6130   Darwin:i?86)
6131     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
6132     LIBJPEG_TURBO_X86_ASM=1
6133   ;;
6134   Darwin:x86_64)
6135     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
6136     LIBJPEG_TURBO_X64_ASM=1
6137   ;;
6138   WINNT:x86|WINNT:i?86)
6139     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
6140     LIBJPEG_TURBO_X86_ASM=1
6141   ;;
6142   WINNT:x86_64)
6143     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
6144     LIBJPEG_TURBO_X64_ASM=1
6145   ;;
6146   *:arm*)
6147     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
6148     LIBJPEG_TURBO_ARM_ASM=1
6149   ;;
6150   *:x86|*:i?86)
6151     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6152       LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6153       LIBJPEG_TURBO_X86_ASM=1
6154     fi
6155   ;;
6156   *:x86_64)
6157     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6158       LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6159       LIBJPEG_TURBO_X64_ASM=1
6160     fi
6161   ;;
6162   esac
6166 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
6167 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
6168 dnl it doesn't exist or we have too old of a version.
6169 if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
6170     LIBJPEG_TURBO_AS=$YASM
6172     if test -z "$LIBJPEG_TURBO_AS" ; then
6173         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.])
6174     fi
6176     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
6177     dnl on Linux and 1.1 or newer everywhere else.
6178     if test "$OS_ARCH" = "Linux" ; then
6179         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
6180             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.])
6181         fi
6182     else
6183         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
6184             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.])
6185         fi
6186     fi
6189 dnl If we're on an ARM system which supports libjpeg-turbo's asm routines and
6190 dnl --disable-libjpeg-turbo wasn't passed, use the C compiler as the assembler.
6191 if test -n "$LIBJPEG_TURBO_ARM_ASM" ; then
6192     echo "Using $AS as the assembler for ARM code."
6193     LIBJPEG_TURBO_AS=$AS
6196 if test -n "$LIBJPEG_TURBO_X86_ASM"; then
6197     AC_DEFINE(LIBJPEG_TURBO_X86_ASM)
6198 elif test -n "$LIBJPEG_TURBO_X64_ASM"; then
6199     AC_DEFINE(LIBJPEG_TURBO_X64_ASM)
6200 elif test -n "$LIBJPEG_TURBO_ARM_ASM"; then
6201     AC_DEFINE(LIBJPEG_TURBO_ARM_ASM)
6202 elif test -n "$MOZ_LIBJPEG_TURBO"; then
6203     dnl Warn if we're not building the optimized routines, even though the user
6204     dnl didn't specify --disable-libjpeg-turbo.
6205     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
6208 dnl ========================================================
6209 dnl = Enable compilation of specific extension modules
6210 dnl ========================================================
6212 MOZ_ARG_ENABLE_STRING(extensions,
6213 [  --enable-extensions     Enable extensions],
6214 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6215     if test "$option" = "yes" -o "$option" = "all"; then
6216         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
6217     elif test "$option" = "no" -o "$option" = "none"; then
6218         MOZ_EXTENSIONS=""
6219     elif test "$option" = "default"; then
6220         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
6221     elif test `echo "$option" | grep -c \^-` != 0; then
6222         option=`echo $option | sed 's/^-//'`
6223         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
6224     else
6225         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
6226     fi
6227 done],
6228     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
6230 if test -z "$MOZ_ENABLE_GNOMEVFS" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6231     # Suppress warning on non-X11 platforms
6232     if test -n "$MOZ_X11"; then
6233         AC_MSG_WARN([Removing gnomevfs from MOZ_EXTENSIONS due to no --enable-gnomevfs.])
6234     fi
6235     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6238 dnl Do not build gnomevfs with libxul based apps
6239 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6240     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6243 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6244     # Suppress warning on non-X11 platforms
6245     if test -n "$MOZ_X11"; then
6246         AC_MSG_WARN([Removing gio from MOZ_EXTENSIONS due to --disable-gio.])
6247     fi
6248     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6251 dnl Do not build gio with libxul based apps
6252 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6253     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6256 if test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6257     MOZ_GIO_COMPONENT=1
6258     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6260 AC_SUBST(MOZ_GIO_COMPONENT)
6262 if test -z "$MOZ_JSDEBUGGER" -a `echo "$MOZ_EXTENSIONS" | grep -c venkman` -ne 0; then
6263     AC_MSG_WARN([Cannot build venkman without JavaScript debug library. Removing venkman from MOZ_EXTENSIONS.])
6264     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|venkman||'`
6267 dnl Remove dupes
6268 MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
6270 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6271 dnl when trying to build a nonexistent extension.
6272 for extension in $MOZ_EXTENSIONS; do
6273     if test ! -d "${srcdir}/extensions/${extension}"; then
6274         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6275     fi
6276 done
6278 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
6279   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
6282 dnl ========================================================
6283 dnl Build Freetype in the tree
6284 dnl ========================================================
6285 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6286 [  --enable-tree-freetype  Enable Tree FreeType],
6287     MOZ_TREE_FREETYPE=1,
6288     MOZ_TREE_FREETYPE= )
6289 if test -n "$MOZ_TREE_FREETYPE"; then
6290    if test -n "$_WIN32_MSVC"; then
6291       AC_ERROR("building with in-tree freetype is not supported on MSVC")
6292    fi
6293    AC_DEFINE(MOZ_TREE_FREETYPE)
6294    AC_SUBST(MOZ_TREE_FREETYPE)
6295    MOZ_ENABLE_CAIRO_FT=1
6296    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6297    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6298    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6299    FT2_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6300    CAIRO_FT_OSLIBS=''
6301    CAIRO_FT_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6302    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6303    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6304    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6305    AC_SUBST(CAIRO_FT_CFLAGS)
6308 dnl ========================================================
6309 dnl Installer
6310 dnl ========================================================
6311 dnl Abort Windows build if the required major version and
6312 dnl minimum minor version of Unicode NSIS isn't in the path
6313 dnl (unless in case of cross compiling, for which Unicode
6314 dnl is not yet sufficient).
6315 if test "$OS_ARCH" = "WINNT"; then
6316     REQ_NSIS_MAJOR_VER=2
6317     MIN_NSIS_MINOR_VER=46
6318     MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensisu-2.46 makensis)
6319     if test -n "$MAKENSISU" -a "$MAKENSISU" != ":"; then
6320       AC_MSG_RESULT([yes])
6321       changequote(,)
6322       MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\).*\-Unicode$/\1/g'`
6323       changequote([,])
6324       if test ! "$MAKENSISU_VER" = ""; then
6325           MAKENSISU_MAJOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $1 }'`
6326           MAKENSISU_MINOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $2 }'`
6327       fi
6328       AC_MSG_CHECKING([for Unicode NSIS with major version == $REQ_NSIS_MAJOR_VER and minor version >= $MIN_NSIS_MINOR_VER])
6329       if test "$MAKENSISU_VER" = "" || \
6330          test ! "$MAKENSISU_MAJOR_VER" = "$REQ_NSIS_MAJOR_VER" -o \
6331               ! "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER; then
6332           AC_MSG_RESULT([no])
6333           if test -z "$CROSS_COMPILE"; then
6334             AC_MSG_ERROR([To build the installer you must have the latest MozillaBuild or Unicode NSIS with a major version of $REQ_NSIS_MAJOR_VER and a minimum minor version of $MIN_NSIS_MINOR_VER in your path.])
6335           else
6336             MAKENSISU=
6337           fi
6338       fi
6339     elif test -z "$CROSS_COMPILE"; then
6340       AC_MSG_ERROR([To build the installer you must have the latest MozillaBuild or Unicode NSIS with a major version of $REQ_NSIS_MAJOR_VER and a minimum minor version of $MIN_NSIS_MINOR_VER in your path.])
6341     else
6342       MAKENSISU=
6343     fi
6346 dnl ========================================================
6347 dnl Web App Runtime
6348 dnl ========================================================
6349 MOZ_ARG_DISABLE_BOOL(webapp-runtime,
6350 [  --disable-webapp-runtime  Disable Web App Runtime],
6351     MOZ_WEBAPP_RUNTIME=,
6352     MOZ_WEBAPP_RUNTIME=1)
6353 if test "$MOZ_WIDGET_TOOLKIT" != "windows" -a "$MOZ_WIDGET_TOOLKIT" != "cocoa" -a "$MOZ_WIDGET_TOOLKIT" != "gtk2"; then
6354     MOZ_WEBAPP_RUNTIME=
6356 if test "$OS_ARCH" = "WINNT" -a -z "$MAKENSISU" -a -n "$CROSS_COMPILE"; then
6357     MOZ_WEBAPP_RUNTIME=
6359 AC_SUBST(MOZ_WEBAPP_RUNTIME)
6360 if test "$MOZ_WEBAPP_RUNTIME"; then
6361     AC_DEFINE(MOZ_WEBAPP_RUNTIME)
6364 AC_MSG_CHECKING([for tar archiver])
6365 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6366 if test -z "$TAR"; then
6367     AC_MSG_ERROR([no tar archiver found in \$PATH])
6369 AC_MSG_RESULT([$TAR])
6370 AC_SUBST(TAR)
6372 AC_MSG_CHECKING([for wget])
6373 AC_CHECK_PROGS(WGET, wget, "")
6374 AC_MSG_RESULT([$WGET])
6375 AC_SUBST(WGET)
6377 dnl ========================================================
6378 dnl Signing
6379 dnl ========================================================
6381 if test -n "$MOZ_SIGN_CMD"; then
6382     AC_DEFINE(MOZ_SIGNING)
6385 dnl ========================================================
6386 dnl Maintenance Service
6387 dnl ========================================================
6389 MOZ_ARG_ENABLE_BOOL(maintenance-service,
6390 [  --enable-maintenance-service       Enable building of maintenanceservice],
6391     MOZ_MAINTENANCE_SERVICE=1,
6392     MOZ_MAINTENANCE_SERVICE= )
6394 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
6395   if test "$OS_ARCH" = "WINNT"; then
6396     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
6397   else
6398     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
6399   fi
6402 dnl ========================================================
6403 dnl Verify MAR signatures
6404 dnl ========================================================
6406 MOZ_ARG_ENABLE_BOOL(verify-mar,
6407 [  --enable-verify-mar     Enable verifying MAR signatures],
6408     MOZ_VERIFY_MAR_SIGNATURE=1,
6409     MOZ_VERIFY_MAR_SIGNATURE= )
6411 if test -n "$MOZ_VERIFY_MAR_SIGNATURE"; then
6412   if test "$OS_ARCH" = "WINNT"; then
6413     AC_DEFINE(MOZ_VERIFY_MAR_SIGNATURE)
6414   else
6415     AC_MSG_ERROR([Can only build with --enable-verify-mar with a Windows target])
6416   fi
6419 dnl ========================================================
6420 dnl Enable building the signmar program.
6421 dnl This option is much different than the --enable-verify-mar option.
6422 dnl --enable-verify-mar is for enabling the verification check on MAR
6423 dnl files in the updater.  The --enable-signmar option is for building
6424 dnl the signmar program.
6425 dnl ========================================================
6427 MOZ_ARG_ENABLE_BOOL(signmar,
6428 [  --enable-signmar     Enable building the signmar program],
6429     MOZ_ENABLE_SIGNMAR=1,
6430     MOZ_ENABLE_SIGNMAR= )
6432 if test -n "$MOZ_ENABLE_SIGNMAR"; then
6433   AC_DEFINE(MOZ_ENABLE_SIGNMAR)
6436 dnl ========================================================
6437 dnl Updater
6438 dnl ========================================================
6440 MOZ_ARG_DISABLE_BOOL(updater,
6441 [  --disable-updater       Disable building of updater],
6442     MOZ_UPDATER=,
6443     MOZ_UPDATER=1 )
6445 if test -n "$MOZ_UPDATER"; then
6446     AC_DEFINE(MOZ_UPDATER)
6449 # tools/update-packaging is not checked out by default.
6450 MOZ_ARG_ENABLE_BOOL(update-packaging,
6451 [  --enable-update-packaging
6452                           Enable tools/update-packaging],
6453     MOZ_UPDATE_PACKAGING=1,
6454     MOZ_UPDATE_PACKAGING= )
6455 AC_SUBST(MOZ_UPDATE_PACKAGING)
6457 dnl ========================================================
6458 dnl build the tests by default
6459 dnl ========================================================
6460 MOZ_ARG_DISABLE_BOOL(tests,
6461 [  --disable-tests         Do not build test libraries & programs],
6462     ENABLE_TESTS=,
6463     ENABLE_TESTS=1 )
6465 if test -n "$ENABLE_TESTS"; then
6466     MOZ_ENABLE_GTEST=1
6467     GTEST_HAS_RTTI=0
6468     AC_DEFINE(MOZ_ENABLE_GTEST)
6469     AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0)
6470     AC_SUBST(MOZ_ENABLE_GTEST)
6471     AC_SUBST(GTEST_HAS_RTTI)
6472     if test -n "$_WIN32_MSVC"; then
6473           AC_DEFINE_UNQUOTED(_VARIADIC_MAX, 10)
6474     fi
6475     if test "${OS_TARGET}" = "Android"; then
6476         AC_DEFINE(GTEST_OS_LINUX_ANDROID)
6477         AC_DEFINE(GTEST_USE_OWN_TR1_TUPLE)
6478         AC_DEFINE_UNQUOTED(GTEST_HAS_CLONE, 0)
6479         AC_SUBST(GTEST_OS_LINUX_ANDROID)
6480         AC_SUBST(GTEST_USE_OWN_TR1_TUPLE)
6481         AC_SUBST(GTEST_HAS_CLONE)
6482     fi
6485 dnl ========================================================
6486 dnl parental controls (for Windows Vista)
6487 dnl ========================================================
6488 MOZ_ARG_DISABLE_BOOL(parental-controls,
6489 [  --disable-parental-controls
6490                           Do not build parental controls],
6491    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6492    MOZ_DISABLE_PARENTAL_CONTROLS=)
6493 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6494     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6497 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6499 dnl ========================================================
6500 dnl = Disable DOMCrypto
6501 dnl ========================================================
6502 if test -n "$MOZ_DISABLE_CRYPTOLEGACY"; then
6503     AC_DEFINE(MOZ_DISABLE_CRYPTOLEGACY)
6505 AC_SUBST(MOZ_DISABLE_CRYPTOLEGACY)
6507 dnl ========================================================
6508 dnl = Disable libpkix
6509 dnl ========================================================
6510 if test -n "$NSS_NO_LIBPKIX"; then
6511     AC_DEFINE(NSS_NO_LIBPKIX)
6513 AC_SUBST(NSS_NO_LIBPKIX)
6515 dnl ========================================================
6516 dnl = Content process sandboxing
6517 dnl ========================================================
6518 if test -n "$gonkdir"; then
6519     MOZ_CONTENT_SANDBOX=1
6522 MOZ_ARG_ENABLE_BOOL(content-sandbox,
6523 [  --enable-content-sandbox        Enable sandboxing support for content-processes],
6524     MOZ_CONTENT_SANDBOX=1)
6526 if test -n "$MOZ_CONTENT_SANDBOX"; then
6527     AC_DEFINE(MOZ_CONTENT_SANDBOX)
6530 AC_SUBST(MOZ_CONTENT_SANDBOX)
6532 MOZ_ARG_ENABLE_BOOL(content-sandbox-reporter,
6533 [ --enable-content-sandbox-reporter        Enable syscall reporter to troubleshoot syscalls denied by the content-processes sandbox],
6534     MOZ_CONTENT_SANDBOX_REPORTER=1)
6536 if test -n "$MOZ_CONTENT_SANDBOX_REPORTER"; then
6537     AC_DEFINE(MOZ_CONTENT_SANDBOX_REPORTER)
6540 AC_SUBST(MOZ_CONTENT_SANDBOX_REPORTER)
6542 dnl ========================================================
6543 dnl =
6544 dnl = Module specific options
6545 dnl =
6546 dnl ========================================================
6547 MOZ_ARG_HEADER(Individual module options)
6549 dnl ========================================================
6550 dnl = Disable feed handling components
6551 dnl ========================================================
6552 MOZ_ARG_DISABLE_BOOL(feeds,
6553 [  --disable-feeds         Disable feed handling and processing components],
6554     MOZ_FEEDS=,
6555     MOZ_FEEDS=1 )
6556 if test -n "$MOZ_FEEDS"; then
6557     AC_DEFINE(MOZ_FEEDS)
6558 else
6559     if test "$MOZ_BUILD_APP" = "browser"; then
6560         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6561     fi
6564 dnl ========================================================
6565 dnl Check for sqlite
6566 dnl ========================================================
6568 MOZ_NATIVE_SQLITE=
6569 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6570 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6571 MOZ_NATIVE_SQLITE=1,
6572 MOZ_NATIVE_SQLITE= )
6574 if test -z "$MOZ_NATIVE_SQLITE"
6575 then
6576     SQLITE_CFLAGS=
6577     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
6578 else
6579     dnl ============================
6580     dnl === SQLite Version check ===
6581     dnl ============================
6582     dnl Check to see if the system SQLite package is new enough.
6583     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6585     dnl ==================================
6586     dnl === SQLITE_SECURE_DELETE check ===
6587     dnl ==================================
6588     dnl Check to see if the system SQLite package is compiled with
6589     dnl SQLITE_SECURE_DELETE enabled.
6590     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
6591     _SAVE_CFLAGS="$CFLAGS"
6592     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6593     _SAVE_LIBS="$LIBS"
6594     LIBS="$LIBS $SQLITE_LIBS"
6595     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6596         AC_TRY_RUN([
6597             #include "sqlite3.h"
6599             int main(int argc, char **argv){
6600               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
6601             }],
6602             ac_cv_sqlite_secure_delete=yes,
6603             ac_cv_sqlite_secure_delete=no,
6604             ac_cv_sqlite_secure_delete=no
6605         )
6606     ])
6607     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6608     CFLAGS="$_SAVE_CFLAGS"
6609     LIBS="$_SAVE_LIBS"
6610     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6611         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
6612     fi
6614     dnl ===============================
6615     dnl === SQLITE_THREADSAFE check ===
6616     dnl ===============================
6617     dnl Check to see if the system SQLite package is compiled with
6618     dnl SQLITE_THREADSAFE enabled.
6619     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
6620     _SAVE_CFLAGS="$CFLAGS"
6621     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6622     _SAVE_LIBS="$LIBS"
6623     LIBS="$LIBS $SQLITE_LIBS"
6624     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
6625         AC_TRY_RUN([
6626             #include "sqlite3.h"
6628             int main(int argc, char **argv){
6629               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
6630             }],
6631             ac_cv_sqlite_threadsafe=yes,
6632             ac_cv_sqlite_threadsafe=no,
6633             ac_cv_sqlite_threadsafe=no
6634         )
6635     ])
6636     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
6637     CFLAGS="$_SAVE_CFLAGS"
6638     LIBS="$_SAVE_LIBS"
6639     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
6640         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
6641     fi
6643     dnl ================================
6644     dnl === SQLITE_ENABLE_FTS3 check ===
6645     dnl ================================
6646     dnl check to see if the system SQLite package is compiled with
6647     dnl SQLITE_ENABLE_FTS3 enabled.
6648     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
6649     _SAVE_CFLAGS="$CFLAGS"
6650     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6651     _SAVE_LIBS="$LIBS"
6652     LIBS="$LIBS $SQLITE_LIBS"
6653     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
6654         AC_TRY_RUN([
6655             #include "sqlite3.h"
6657             int main(int argc, char **argv){
6658               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
6659             }],
6660             ac_cv_sqlite_enable_fts3=yes,
6661             ac_cv_sqlite_enable_fts3=no,
6662             ac_cv_sqlite_enable_fts3=no
6663         )
6664     ])
6665     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
6666     CFLAGS="$_SAVE_CFLAGS"
6667     LIBS="$_SAVE_LIBS"
6668     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
6669         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
6670     fi
6672     dnl =========================================
6673     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
6674     dnl =========================================
6675     dnl check to see if the system SQLite package is compiled with
6676     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
6677     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
6678     _SAVE_CFLAGS="$CFLAGS"
6679     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6680     _SAVE_LIBS="$LIBS"
6681     LIBS="$LIBS $SQLITE_LIBS"
6682     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
6683         AC_TRY_RUN([
6684             #include "sqlite3.h"
6686             int main(int argc, char **argv){
6687               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
6688             }],
6689             ac_cv_sqlite_enable_unlock_notify=yes,
6690             ac_cv_sqlite_enable_unlock_notify=no,
6691             ac_cv_sqlite_enable_unlock_notify=no
6692         )
6693     ])
6694     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
6695     CFLAGS="$_SAVE_CFLAGS"
6696     LIBS="$_SAVE_LIBS"
6697     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
6698         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
6699     fi
6702 if test -n "$MOZ_NATIVE_SQLITE"; then
6703     AC_DEFINE(MOZ_NATIVE_SQLITE)
6705 AC_SUBST(MOZ_NATIVE_SQLITE)
6707 dnl ========================================================
6708 dnl = Enable help viewer (off by default)
6709 dnl ========================================================
6710 if test -n "$MOZ_HELP_VIEWER"; then
6711      dnl Do this if defined in confvars.sh
6712      AC_DEFINE(MOZ_HELP_VIEWER)
6715 dnl ========================================================
6716 dnl = Enable safe browsing (anti-phishing)
6717 dnl ========================================================
6718 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6719 [  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation],
6720     MOZ_SAFE_BROWSING=1,
6721     MOZ_SAFE_BROWSING= )
6722 if test -n "$MOZ_SAFE_BROWSING"; then
6723     AC_DEFINE(MOZ_SAFE_BROWSING)
6725 AC_SUBST(MOZ_SAFE_BROWSING)
6727 dnl ========================================================
6728 dnl = Enable url-classifier
6729 dnl ========================================================
6730 dnl Implicitly enabled by default if building with safe-browsing
6731 if test -n "$MOZ_SAFE_BROWSING"; then
6732     MOZ_URL_CLASSIFIER=1
6734 MOZ_ARG_ENABLE_BOOL(url-classifier,
6735 [  --enable-url-classifier Enable url classifier module],
6736     MOZ_URL_CLASSIFIER=1,
6737     MOZ_URL_CLASSIFIER= )
6738 if test -n "$MOZ_URL_CLASSIFIER"; then
6739     AC_DEFINE(MOZ_URL_CLASSIFIER)
6741 AC_SUBST(MOZ_URL_CLASSIFIER)
6743 dnl ========================================================
6744 dnl = Disable zipwriter
6745 dnl ========================================================
6746 MOZ_ARG_DISABLE_BOOL(zipwriter,
6747 [  --disable-zipwriter     Disable zipwriter component],
6748     MOZ_ZIPWRITER=,
6749     MOZ_ZIPWRITER=1 )
6750 AC_SUBST(MOZ_ZIPWRITER)
6752 dnl ========================================================
6753 dnl = libconic
6754 dnl ========================================================
6755 dnl superseded by QtNetwork starting from 4.7
6756 MOZ_ENABLE_LIBCONIC=1
6758 if test -n "$MOZ_ENABLE_QT"; then
6759   if test "$MOZ_ENABLE_QTNETWORK"; then
6760     MOZ_ENABLE_LIBCONIC=
6761   fi
6764 MOZ_ARG_DISABLE_BOOL(libconic,
6765 [  --disable-libconic      Disable libconic],
6766     MOZ_ENABLE_LIBCONIC=,
6767     MOZ_ENABLE_LIBCONIC=1 )
6769 if test -n "$MOZ_ENABLE_LIBCONIC"; then
6770     PKG_CHECK_MODULES(LIBCONIC, conic,
6771                       MOZ_ENABLE_LIBCONIC=1,
6772                       MOZ_ENABLE_LIBCONIC=)
6774 if test "$MOZ_ENABLE_LIBCONIC"; then
6775     AC_DEFINE(MOZ_ENABLE_LIBCONIC)
6778 AC_SUBST(MOZ_ENABLE_LIBCONIC)
6779 AC_SUBST(LIBCONIC_CFLAGS)
6780 AC_SUBST(LIBCONIC_LIBS)
6782 dnl ========================================================
6783 dnl = Maemo checks
6784 dnl ========================================================
6786 MAEMO_SDK_TARGET_VER=-1
6788 MOZ_ARG_WITH_STRING(maemo-version,
6789 [  --with-maemo-version=MAEMO_SDK_TARGET_VER
6790                           Maemo SDK Version],
6791   MAEMO_SDK_TARGET_VER=$withval)
6793 case "$MAEMO_SDK_TARGET_VER" in
6795     MOZ_PLATFORM_MAEMO=5
6796     ;;
6799     MOZ_PLATFORM_MAEMO=6
6800     ;;
6803     dnl We aren't compiling for Maemo, move on.
6804     ;;
6806     AC_MSG_ERROR([Unknown Maemo Version.  Try setting --with-maemo-version to 5 or 6.])
6807     ;;
6808 esac
6810 if test $MOZ_PLATFORM_MAEMO; then
6811    AC_DEFINE_UNQUOTED([MOZ_PLATFORM_MAEMO], $MOZ_PLATFORM_MAEMO)
6813    if test -z "$MOZ_ENABLE_DBUS"; then
6814        AC_MSG_ERROR([DBus is required when building for Maemo])
6815    fi
6817    MOZ_GFX_OPTIMIZE_MOBILE=1
6818    MOZ_GL_DEFAULT_PROVIDER=EGL
6819    MOZ_MAEMO_LIBLOCATION=
6821    if test $MOZ_PLATFORM_MAEMO = 5; then
6822       dnl if we have Xcomposite we should also have Xdamage and Xfixes
6823       MOZ_CHECK_HEADERS([X11/extensions/Xdamage.h], [],
6824           [AC_MSG_ERROR([Couldn't find X11/extensions/Xdamage.h which is required for composited plugins.])])
6825       AC_CHECK_LIB(Xcomposite, XCompositeRedirectWindow, [XCOMPOSITE_LIBS="-lXcomposite -lXdamage -lXfixes"],
6826                    [MISSING_X="$MISSING_X -lXcomposite"], $XLIBS)
6828       AC_SUBST(XCOMPOSITE_LIBS)
6830       PKG_CHECK_MODULES(LIBHILDONMIME,libhildonmime, _LIB_FOUND=1, _LIB_FOUND=)
6831       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONMIME_LIBS"
6832       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONMIME_CFLAGS"
6833       if test -z "$_LIB_FOUND"; then
6834          AC_MSG_ERROR([Hildon Mime is required when building for Maemo])
6835       fi
6838       PKG_CHECK_MODULES(LIBOSSO,libosso, _LIB_FOUND=1, _LIB_FOUND=)
6839       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBOSSO_LIBS"
6840       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBOSSO_CFLAGS"
6841       if test -z "$_LIB_FOUND"; then
6842          AC_MSG_ERROR([LibOSSO is required when building for Maemo])
6843       fi
6845       PKG_CHECK_MODULES(LIBHILDONFM,hildon-fm-2, _LIB_FOUND=1, _LIB_FOUND=)
6846       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONFM_LIBS"
6847       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONFM_CFLAGS"
6848       if test -z "$_LIB_FOUND"; then
6849          AC_MSG_ERROR([Hildon FM-2 is required when building for Maemo])
6850       fi
6852    fi
6853    if test $MOZ_PLATFORM_MAEMO = 6; then
6855       PKG_CHECK_MODULES(LIBCONTENTMANAGER, ContentManager QtSparql,
6856                         _LIB_FOUND=1,
6857                         _LIB_FOUND=)
6858       if test "$_LIB_FOUND"; then
6859          MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTMANAGER_LIBS"
6860          MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTMANAGER_CFLAGS"
6861          MOZ_ENABLE_CONTENTMANAGER=1
6862          AC_DEFINE(MOZ_ENABLE_CONTENTMANAGER)
6863       else
6864          AC_MSG_WARN([Cannot find libcontentmanager and or QtSparql building for Maemo 6])
6865       fi
6866       AC_SUBST(MOZ_ENABLE_CONTENTMANAGER)
6868       dnl ========================================================
6869       dnl = Enable meego libcontentaction
6870       dnl ========================================================
6871       MOZ_ARG_ENABLE_BOOL(meegocontentaction,
6872       [  --enable-meegocontentaction           Enable meegocontentaction support],
6873          MOZ_MEEGOCONTENTACTION=1,
6874          MOZ_MEEGOCONTENTACTION=)
6876       if test -n "$MOZ_MEEGOCONTENTACTION"; then
6878          PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
6879          if test "$_LIB_FOUND"; then
6880             MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTACTION_LIBS"
6881             MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTACTION_CFLAGS"
6882             MOZ_ENABLE_CONTENTACTION=1
6883             AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
6884             AC_SUBST(MOZ_ENABLE_CONTENTACTION)
6885          fi
6886       fi
6888       MOZ_ARG_ENABLE_BOOL(meegotouch,
6889       [  --enable-meegotouch  Enable meegotouch support],
6890          MOZ_MEEGOTOUCHENABLED=1,
6891          MOZ_MEEGOTOUCHENABLED=)
6893       if test -n "$MOZ_MEEGOTOUCHENABLED"; then
6894           PKG_CHECK_MODULES(MOZ_MEEGOTOUCH, meegotouchcore, _LIB_FOUND=1, _LIB_FOUND=)
6895           if test "$_LIB_FOUND"; then
6896               MOZ_QT_CFLAGS="$MOZ_MEEGOTOUCH_CFLAGS $MOZ_QT_CFLAGS"
6897               MOZ_QT_LIBS="$MOZ_MEEGOTOUCH_LIBS $MOZ_QT_LIBS"
6898               AC_DEFINE(MOZ_ENABLE_MEEGOTOUCH)
6899           else
6900               AC_MSG_WARN([Cannot meegotouchcore-dev. Disabling Meegotouch support.])
6901           fi
6902       fi
6903    fi
6905    PKG_CHECK_MODULES(LIBLOCATION,liblocation, _LIB_FOUND=1, _LIB_FOUND=)
6906    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBLOCATION_LIBS"
6907    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBLOCATION_CFLAGS"
6908    if test "$_LIB_FOUND"; then
6909       MOZ_MAEMO_LIBLOCATION=1
6910       AC_DEFINE(MOZ_MAEMO_LIBLOCATION)
6911    else
6912       AC_MSG_WARN([Cannot liblocation-dev. Disabling Maemo geolocation.])
6913    fi
6914    AC_SUBST(MOZ_MAEMO_LIBLOCATION)
6916    PKG_CHECK_MODULES(LIBMEEGOTOUCHSHARE, ShareUiInterface-maemo-meegotouch >= 0.3.31 mdatauri, _LIB_FOUND=1, _LIB_FOUND=)
6917    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBMEEGOTOUCHSHARE_LIBS"
6918    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBMEEGOTOUCHSHARE_CFLAGS"
6919    if test "$_LIB_FOUND"; then
6920       MOZ_ENABLE_MEEGOTOUCHSHARE=1
6921       AC_DEFINE(MOZ_ENABLE_MEEGOTOUCHSHARE)
6922    else
6923       AC_MSG_WARN([Cannot find maemo-meegotouch-interfaces-dev or libmdatauri-dev. Disabling meegotouch share ui.])
6924    fi
6925    AC_SUBST(MOZ_ENABLE_MEEGOTOUCHSHARE)
6927    AC_SUBST(MOZ_PLATFORM_MAEMO_LIBS)
6928    AC_SUBST(MOZ_PLATFORM_MAEMO_CFLAGS)
6931 dnl ========================================================
6932 dnl GL provider
6933 dnl ========================================================
6934 MOZ_GL_PROVIDER=
6935 MOZ_ARG_WITH_STRING(gl-provider,
6936 [  --with-gl-provider=ID
6937                           Set GL provider backend type],
6938 [ val=`echo $withval`
6939     MOZ_GL_PROVIDER="$val"])
6941 if test -n "$MOZ_GL_PROVIDER"; then
6942 MOZ_GL_DEFAULT_PROVIDER=$MOZ_GL_PROVIDER
6943 AC_SUBST(MOZ_GL_PROVIDER)
6944 AC_DEFINE_UNQUOTED(MOZ_GL_PROVIDER, GLContextProvider$MOZ_GL_PROVIDER)
6946 AC_SUBST(MOZ_GL_DEFAULT_PROVIDER)
6947 AC_DEFINE_UNQUOTED(GL_PROVIDER_$MOZ_GL_DEFAULT_PROVIDER)
6949 dnl ========================================================
6950 dnl = faststripe theme
6951 dnl ========================================================
6952 MOZ_ARG_ENABLE_BOOL(faststripe,
6953 [  --enable-faststripe     Use faststripe theme],
6954     MOZ_THEME_FASTSTRIPE=1,
6955     MOZ_THEME_FASTSTRIPE= )
6956 AC_SUBST(MOZ_THEME_FASTSTRIPE)
6958 dnl ========================================================
6959 dnl =
6960 dnl = Feature options that require extra sources to be pulled
6961 dnl =
6962 dnl ========================================================
6963 dnl MOZ_ARG_HEADER(Features that require extra sources)
6965 dnl ========================================================
6966 dnl =
6967 dnl = Runtime debugging and Optimization Options
6968 dnl =
6969 dnl ========================================================
6970 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
6972 dnl ========================================================
6973 dnl enable mobile optimizations
6974 dnl ========================================================
6975 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
6976 [  --enable-mobile-optimize
6977                           Enable mobile optimizations],
6978     MOZ_GFX_OPTIMIZE_MOBILE=1)
6980 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
6982 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
6983     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
6986 dnl ========================================================
6987 dnl = Enable code optimization. ON by default.
6988 dnl ========================================================
6989 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
6990         MOZ_OPTIMIZE_FLAGS="-O"
6993 MOZ_ARG_ENABLE_STRING(optimize,
6994 [  --disable-optimize      Disable compiler optimization
6995   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
6996 [ if test "$enableval" != "no"; then
6997     MOZ_OPTIMIZE=1
6998     if test -n "$enableval" -a "$enableval" != "yes"; then
6999         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
7000         MOZ_OPTIMIZE=2
7001     fi
7002 else
7003     MOZ_OPTIMIZE=
7004 fi ], MOZ_OPTIMIZE=1)
7006 MOZ_SET_FRAMEPTR_FLAGS
7008 if test "$COMPILE_ENVIRONMENT"; then
7009 if test -n "$MOZ_OPTIMIZE"; then
7010     AC_MSG_CHECKING([for valid optimization flags])
7011     _SAVE_CFLAGS=$CFLAGS
7012     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
7013     AC_TRY_COMPILE([#include <stdio.h>],
7014         [printf("Hello World\n");],
7015         _results=yes,
7016         _results=no)
7017     AC_MSG_RESULT([$_results])
7018     if test "$_results" = "no"; then
7019         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
7020     fi
7021     CFLAGS=$_SAVE_CFLAGS
7023 fi # COMPILE_ENVIRONMENT
7025 AC_SUBST(MOZ_OPTIMIZE)
7026 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
7027 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
7028 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
7029 AC_SUBST(MOZ_ALLOW_HEAP_EXECUTE_FLAGS)
7030 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
7031 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
7033 dnl ========================================================
7034 dnl = Enable any treating of compile warnings as errors
7035 dnl ========================================================
7036 MOZ_ARG_ENABLE_BOOL(warnings-as-errors,
7037 [  --enable-warnings-as-errors
7038                           Enable treating of warnings as errors],
7039     MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
7040     MOZ_ENABLE_WARNINGS_AS_ERRORS=)
7041 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
7042    WARNINGS_AS_ERRORS=''
7043 elif test "$GNU_CC"; then
7044     # Prevent the following GCC warnings from being treated as errors:
7045     # -Wuninitialized - too many false positives
7046     # -Wmaybe-uninitialized - too many false positives
7047     # -Wdeprecated-declarations - we don't want our builds held hostage when a
7048     #   platform-specific API becomes deprecated.
7049     MOZ_C_SUPPORTS_WARNING(-W, no-error=uninitialized, ac_c_has_noerror_uninitialized)
7050     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=uninitialized, ac_cxx_has_noerror_uninitialized)
7051     MOZ_C_SUPPORTS_WARNING(-W, no-error=maybe-uninitialized, ac_c_has_noerror_maybe_uninitialized)
7052     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=maybe-uninitialized, ac_cxx_has_noerror_maybe_uninitialized)
7053     MOZ_C_SUPPORTS_WARNING(-W, no-error=deprecated-declarations, ac_c_has_noerror_deprecated_declarations)
7054     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=deprecated-declarations, ac_cxx_has_noerror_deprecated_declarations)
7057 dnl ========================================================
7058 dnl = Disable runtime logging checks
7059 dnl ========================================================
7060 MOZ_ARG_DISABLE_BOOL(logging,
7061 [  --disable-logging       Disable logging facilities],
7062     NS_DISABLE_LOGGING=1,
7063     NS_DISABLE_LOGGING= )
7064 if test "$NS_DISABLE_LOGGING"; then
7065     AC_DEFINE(NS_DISABLE_LOGGING)
7066 else
7067     AC_DEFINE(MOZ_LOGGING)
7070 dnl ========================================================
7071 dnl = This will enable logging of addref, release, ctor, dtor.
7072 dnl ========================================================
7073 _ENABLE_LOGREFCNT=42
7074 MOZ_ARG_ENABLE_BOOL(logrefcnt,
7075 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
7076     _ENABLE_LOGREFCNT=1,
7077     _ENABLE_LOGREFCNT= )
7078 if test "$_ENABLE_LOGREFCNT" = "1"; then
7079     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
7080 elif test -z "$_ENABLE_LOGREFCNT"; then
7081     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
7084 dnl ========================================================
7085 dnl moz_dump_painting
7086 dnl ========================================================
7087 MOZ_ARG_ENABLE_BOOL(dump-painting,
7088 [  --enable-dump-painting          Enable paint debugging.],
7089     MOZ_DUMP_PAINTING=1,
7090     MOZ_DUMP_PAINTING= )
7091 if test -n "$MOZ_DUMP_PAINTING"; then
7092     AC_DEFINE(MOZ_DUMP_PAINTING)
7093     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
7095 if test -n "$MOZ_DEBUG"; then
7096     AC_DEFINE(MOZ_DUMP_PAINTING)
7099 dnl ========================================================
7100 dnl = Enable trace malloc
7101 dnl ========================================================
7102 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
7103 MOZ_ARG_ENABLE_BOOL(trace-malloc,
7104 [  --enable-trace-malloc   Enable malloc tracing; also disables DMD and jemalloc],
7105     NS_TRACE_MALLOC=1,
7106     NS_TRACE_MALLOC= )
7107 if test "$NS_TRACE_MALLOC"; then
7108   # Please, Mr. Linker Man, don't take away our symbol names
7109   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
7110   USE_ELF_DYNSTR_GC=
7111   AC_DEFINE(NS_TRACE_MALLOC)
7113 AC_SUBST(NS_TRACE_MALLOC)
7115 dnl ========================================================
7116 dnl = Enable DMD
7117 dnl ========================================================
7119 MOZ_ARG_ENABLE_BOOL(dmd,
7120 [  --enable-dmd            Enable DMD; also enables jemalloc and replace-malloc],
7121     MOZ_DMD=1,
7122     MOZ_DMD= )
7124 if test "$NS_TRACE_MALLOC"; then        # trace-malloc disables DMD
7125     MOZ_DMD=
7127 if test "$MOZ_DMD"; then
7128     USE_ELF_DYNSTR_GC=
7129     AC_DEFINE(MOZ_DMD)
7131     if test "${CPU_ARCH}" = "arm"; then
7132         CFLAGS="$CFLAGS -funwind-tables"
7133         CXXFLAGS="$CXXFLAGS -funwind-tables"
7134     fi
7136     MOZ_MEMORY=1                        # DMD enables jemalloc
7137     MOZ_REPLACE_MALLOC=1                # DMD enables replace-malloc
7139 AC_SUBST(MOZ_DMD)
7141 dnl ========================================================
7142 dnl = Enable jemalloc
7143 dnl ========================================================
7144 MOZ_ARG_ENABLE_BOOL(jemalloc,
7145 [  --enable-jemalloc       Replace memory allocator with jemalloc],
7146     MOZ_MEMORY=1,
7147     MOZ_MEMORY=)
7149 if test "$NS_TRACE_MALLOC"; then
7150     MOZ_MEMORY=
7153 if test "${OS_TARGET}" = "Android"; then
7154   dnl On Android, we use WRAP_LDFLAGS to link everything to mozglue
7155   :
7156 elif test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "OS2"; then
7157   dnl On Windows, OSX and OS2, we want to link all our binaries against mozglue
7158   if test -z "$GNU_CC"; then
7159     MOZ_GLUE_LDFLAGS='$(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
7160   else
7161     MOZ_GLUE_LDFLAGS='-L$(LIBXUL_DIST)/lib $(call EXPAND_LIBNAME,mozglue)'
7162   fi
7163 else
7164   dnl On other Unix systems, we only want to link executables against mozglue
7165   MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
7166   dnl On other Unix systems, where mozglue is a static library, jemalloc is
7167   dnl separated for the SDK, so we need to add it here.
7168   if test "$MOZ_MEMORY" = 1 -o \( "$LIBXUL_SDK" -a -f "$LIBXUL_SDK/lib/${LIB_PREFIX}memory.${LIB_SUFFIX}" \); then
7169     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib)'
7170   fi
7171   MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(MKSHLIB_UNFORCE_ALL)'
7172   if test -n "$GNU_CC"; then
7173     dnl And we need mozglue symbols to be exported.
7174     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
7175   fi
7176   if test "$MOZ_LINKER" = 1; then
7177     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS $MOZ_ZLIB_LIBS"
7178   fi
7181 dnl ========================================================
7182 dnl = Enable dynamic replacement of malloc implementation
7183 dnl ========================================================
7184 MOZ_ARG_ENABLE_BOOL(replace-malloc,
7185 [  --enable-replace-malloc   Enable ability to dynamically replace the malloc implementation],
7186     MOZ_REPLACE_MALLOC=1,
7187     MOZ_REPLACE_MALLOC= )
7189 if test -n "$MOZ_REPLACE_MALLOC" -a -z "$MOZ_MEMORY"; then
7190     dnl We don't want to enable jemalloc unconditionally because it may be a
7191     dnl deliberate choice not to enable it (bug 702250, for instance)
7192     AC_MSG_ERROR([--enable-replace-malloc requires --enable-jemalloc])
7193 elif test -n "$MOZ_REPLACE_MALLOC"; then
7194     MOZ_NATIVE_JEMALLOC=
7196     dnl Replace-malloc Mac linkage quirks
7197     if test -n "$MACOSX_DEPLOYMENT_TARGET"; then
7198         AC_CACHE_CHECK([how to do weak dynamic linking],
7199             ac_cv_weak_dynamic_linking,
7200             [echo 'extern void foo() __attribute__((weak_import));int bar() { if (foo) foo(); return 0; }' > conftest.c
7201              if AC_TRY_COMMAND([${CC-cc} -o conftest${DLL_SUFFIX} $CFLAGS -dynamiclib $LDFLAGS -Wl,-U,_foo conftest.c $LIBS 1>&5]) &&
7202                 test -s conftest${DLL_SUFFIX}; then
7203                  dnl There are several ways the linker can put link edit rules in a binary:
7204                  dnl - classic info only (for OSX < 10.6)
7205                  dnl - dyld info only
7206                  dnl - both
7207                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO_ONLY" > /dev/null; then
7208                      _CLASSIC_INFO=
7209                  else
7210                      _CLASSIC_INFO=1
7211                  fi
7212                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO" > /dev/null; then
7213                      _DYLD_INFO=1
7214                  else
7215                      _DYLD_INFO=
7216                  fi
7217                  dnl With classic info, we need to build with -flat_namespace.
7218                  dnl With dyld info, Xcode 4.5 does the right thing without additional flags,
7219                  dnl but Xcode < 4.5 requires a dummy library and -flat_namespace because it
7220                  dnl forgets to set the weak flag in the dyld info.
7221                  dnl See http://glandium.org/blog/?p=2764 for more details.
7222                  dnl
7223                  dnl Values for ac_cv_weak_dynamic_linking, and subsequently
7224                  dnl MOZ_REPLACE_MALLOC_LINKAGE are thus:
7225                  dnl - "flat namespace" when -flat_namespace alone is needed
7226                  dnl - "dummy library" when a dummy library and -flat_namespace are needed
7227                  dnl - "compiler support" when nothing is needed
7228                  if test -n "$_DYLD_INFO" && dyldinfo -bind conftest${DLL_SUFFIX} 2> /dev/null | grep "_foo (weak import)" > /dev/null; then
7229                      if test -n "$_CLASSIC_INFO"; then
7230                          ac_cv_weak_dynamic_linking="flat namespace"
7231                      else
7232                          ac_cv_weak_dynamic_linking="compiler support"
7233                      fi
7234                  else
7235                      if test -n "$_DYLD_INFO"; then
7236                          ac_cv_weak_dynamic_linking="dummy library"
7237                      else
7238                          ac_cv_weak_dynamic_linking="flat namespace"
7239                      fi
7240                  fi
7241              else
7242                  AC_ERROR([couldn't compile a simple C file])
7243              fi
7244              rm -rf conftest*])
7245         MOZ_REPLACE_MALLOC_LINKAGE="$ac_cv_weak_dynamic_linking"
7246     fi
7248 AC_SUBST(MOZ_REPLACE_MALLOC)
7249 AC_SUBST(MOZ_REPLACE_MALLOC_LINKAGE)
7251 dnl ========================================================
7252 dnl = Jemalloc build setup
7253 dnl ========================================================
7254 if test -z "$MOZ_MEMORY"; then
7255   if test -n "$MOZ_JEMALLOC3" -a -z "$MOZ_REPLACE_MALLOC"; then
7256     MOZ_NATIVE_JEMALLOC=1
7257     AC_CHECK_FUNCS(mallctl nallocm,,
7258       [MOZ_NATIVE_JEMALLOC=
7259        break])
7260     if test -n "$MOZ_NATIVE_JEMALLOC"; then
7261       MOZ_MEMORY=1
7262       AC_DEFINE(MOZ_MEMORY)
7263       AC_DEFINE(MOZ_JEMALLOC3)
7264       AC_DEFINE(MOZ_NATIVE_JEMALLOC)
7265     fi
7266   fi
7267   case "${target}" in
7268     *-mingw*)
7269       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
7270         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.])
7271       fi
7272       ;;
7273   esac
7274 else
7275   dnl Don't try to run compiler tests on Windows
7276   if test "$OS_ARCH" = "WINNT"; then
7277     if test -z "$HAVE_64BIT_OS"; then
7278       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7279     else
7280       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7281     fi
7282   else
7283     AC_CHECK_SIZEOF([int *], [4])
7284     case "${ac_cv_sizeof_int_p}" in
7285     4)
7286       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7287       ;;
7288     8)
7289       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7290       ;;
7291     *)
7292       AC_MSG_ERROR([Unexpected pointer size])
7293       ;;
7294     esac
7295   fi
7297   AC_DEFINE(MOZ_MEMORY)
7298   if test -n "$MOZ_JEMALLOC3"; then
7299     AC_DEFINE(MOZ_JEMALLOC3)
7300   fi
7301   if test "x$MOZ_DEBUG" = "x1"; then
7302     AC_DEFINE(MOZ_MEMORY_DEBUG)
7303   fi
7304   dnl The generic feature tests that determine how to compute ncpus are long and
7305   dnl complicated.  Therefore, simply define special cpp variables for the
7306   dnl platforms we have special knowledge of.
7307   case "${target}" in
7308   *-darwin*)
7309     AC_DEFINE(MOZ_MEMORY_DARWIN)
7310     ;;
7311   *-*freebsd*)
7312     AC_DEFINE(MOZ_MEMORY_BSD)
7313     ;;
7314   *-android*|*-linuxandroid*)
7315     AC_DEFINE(MOZ_MEMORY_LINUX)
7316     AC_DEFINE(MOZ_MEMORY_ANDROID)
7317     if test -z "$gonkdir"; then
7318       _WRAP_MALLOC=1
7319     else
7320       AC_DEFINE(MOZ_MEMORY_GONK)
7321     fi
7322     MOZ_GLUE_LDFLAGS=
7323     ;;
7324   *-*linux*)
7325     AC_DEFINE(MOZ_MEMORY_LINUX)
7326     ;;
7327   *-netbsd*)
7328     AC_DEFINE(MOZ_MEMORY_BSD)
7329     ;;
7330   *-solaris*)
7331     AC_DEFINE(MOZ_MEMORY_SOLARIS)
7332     ;;
7333   *-mingw*)
7334     AC_DEFINE(MOZ_MEMORY_WINDOWS)
7335     if test -z "$MOZ_DEBUG"; then
7336       WIN32_CRT_LIBS="msvcrt.lib msvcprt.lib"
7337     else
7338       WIN32_CRT_LIBS="msvcrtd.lib msvcprtd.lib"
7339     fi
7340     dnl Look for a broken crtdll.obj
7341     WIN32_CRTDLL_FULLPATH=`lib -nologo -list $WIN32_CRT_LIBS | grep crtdll\\.obj`
7342     lib -NOLOGO -OUT:crtdll.obj $WIN32_CRT_LIBS -EXTRACT:$WIN32_CRTDLL_FULLPATH
7343     if grep -q '__imp__\{0,1\}free' crtdll.obj; then
7344       MOZ_GLUE_LDFLAGS='-LIBPATH:$(DIST)/lib -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcrtd -NODEFAULTLIB:msvcprt -NODEFAULTLIB:msvcprtd -DEFAULTLIB:mozcrt'
7345       dnl Also pass this to NSPR/NSS
7346       DLLFLAGS="$DLLFLAGS $MOZ_GLUE_LDFLAGS"
7347     else
7348       DLLFLAGS="$DLLFLAGS -LIBPATH:\$(DIST)/lib -DEFAULTLIB:mozglue"
7349     fi
7350     rm crtdll.obj
7352     export DLLFLAGS
7353     ;;
7354   *)
7355     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
7356     ;;
7357   esac
7358 fi # MOZ_MEMORY
7359 AC_SUBST(MOZ_MEMORY)
7360 AC_SUBST(MOZ_JEMALLOC3)
7361 AC_SUBST(MOZ_NATIVE_JEMALLOC)
7362 AC_SUBST(MOZ_GLUE_LDFLAGS)
7363 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
7364 AC_SUBST(WIN32_CRT_LIBS)
7365 dnl Need to set this for make because NSS doesn't have configure
7366 AC_SUBST(DLLFLAGS)
7368 dnl We need to wrap dlopen and related functions on Android because we use
7369 dnl our own linker.
7370 if test "$OS_TARGET" = Android; then
7371     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
7372     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
7373     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_GetEnv,--wrap=PR_SetEnv"
7374     if test -z "$gonkdir"; then
7375         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork,--wrap=raise"
7376         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=memccpy,--wrap=memchr,--wrap=memrchr,--wrap=memcmp,--wrap=memcpy,--wrap=memmove,--wrap=memset,--wrap=memmem,--wrap=memswap,--wrap=index,--wrap=strchr,--wrap=strrchr,--wrap=strlen,--wrap=strcmp,--wrap=strcpy,--wrap=strcat,--wrap=strcasecmp,--wrap=strncasecmp,--wrap=strstr,--wrap=strcasestr,--wrap=strtok,--wrap=strtok_r,--wrap=strerror,--wrap=strerror_r,--wrap=strnlen,--wrap=strncat,--wrap=strncmp,--wrap=strncpy,--wrap=strlcat,--wrap=strlcpy,--wrap=strcspn,--wrap=strpbrk,--wrap=strsep,--wrap=strspn,--wrap=strcoll,--wrap=strxfrm"
7377     fi
7380 dnl ========================================================
7381 dnl = Use malloc wrapper lib
7382 dnl ========================================================
7383 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
7384 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
7385     _WRAP_MALLOC=1,
7386     _WRAP_MALLOC= )
7388 if test -n "$_WRAP_MALLOC"; then
7389     if test -n "$GNU_CC"; then
7390         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
7391         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
7392         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
7393         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
7394         dnl Wrap operator new and operator delete on Android.
7395         if test "$OS_TARGET" = "Android"; then
7396             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_Znwj,--wrap=_Znaj,--wrap=_ZdlPv,--wrap=_ZdaPv"
7397             dnl Wrap the nothrow variants too.
7398             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_ZnwjRKSt9nothrow_t,--wrap=_ZnajRKSt9nothrow_t,--wrap=_ZdlPvRKSt9nothrow_t,--wrap=_ZdaPvRKSt9nothrow_t"
7399         fi
7400     else
7401         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
7402     fi
7405 dnl ========================================================
7406 dnl = Location of malloc wrapper lib
7407 dnl ========================================================
7408 MOZ_ARG_WITH_STRING(wrap-malloc,
7409 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
7410     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
7412 dnl ========================================================
7413 dnl = Use JS Call tracing
7414 dnl ========================================================
7415 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
7416 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
7417     MOZ_TRACE_JSCALLS=1,
7418     MOZ_TRACE_JSCALLS= )
7419 if test -n "$MOZ_TRACE_JSCALLS"; then
7420     AC_DEFINE(MOZ_TRACE_JSCALLS)
7423 dnl ========================================================
7424 dnl = Use incremental GC
7425 dnl ========================================================
7426 JSGC_INCREMENTAL=1
7427 MOZ_ARG_DISABLE_BOOL(gcincremental,
7428 [  --disable-gcincremental Disable incremental GC],
7429     JSGC_INCREMENTAL= )
7430 if test -n "$JSGC_INCREMENTAL"; then
7431     AC_DEFINE(JSGC_INCREMENTAL)
7434 dnl ========================================================
7435 dnl Zealous JavaScript GC
7436 dnl ========================================================
7437 MOZ_ARG_ENABLE_BOOL(gczeal,
7438 [  --enable-gczeal         Enable zealous JavaScript GCing],
7439     JS_GC_ZEAL=1,
7440     JS_GC_ZEAL= )
7441 if test -n "$JS_GC_ZEAL"; then
7442     AC_DEFINE(JS_GC_ZEAL)
7445 dnl ========================================================
7446 dnl JS opt-mode assertions and minidump instrumentation
7447 dnl ========================================================
7448 MOZ_ARG_ENABLE_BOOL(js-diagnostics,
7449 [  --enable-js-diagnostics
7450                           Enable JS diagnostic assertions and breakpad data],
7451     JS_CRASH_DIAGNOSTICS=1,
7452     JS_CRASH_DIAGNOSTICS= )
7453 if test -n "$JS_CRASH_DIAGNOSTICS"; then
7454     AC_DEFINE(JS_CRASH_DIAGNOSTICS)
7457 MOZ_CHECK_CCACHE
7458 MOZ_CHECK_COMPILER_WRAPPER
7460 dnl ========================================================
7461 dnl = Enable static checking using gcc-dehydra
7462 dnl ========================================================
7464 MOZ_ARG_WITH_STRING(static-checking,
7465 [  --with-static-checking=path/to/gcc_dehydra.so
7466                           Enable static checking of code using GCC-dehydra],
7467     DEHYDRA_PATH=$withval,
7468     DEHYDRA_PATH= )
7470 if test -n "$DEHYDRA_PATH"; then
7471     if test ! -f "$DEHYDRA_PATH"; then
7472         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7473     fi
7474     AC_DEFINE(NS_STATIC_CHECKING)
7476 AC_SUBST(DEHYDRA_PATH)
7478 dnl ========================================================
7479 dnl = Enable using the clang plugin to build
7480 dnl ========================================================
7482 MOZ_ARG_ENABLE_BOOL(clang-plugin,
7483 [  --enable-clang-plugin   Enable building with the mozilla clang plugin ],
7484    ENABLE_CLANG_PLUGIN=1,
7485    ENABLE_CLANG_PLUGIN= )
7486 if test -n "$ENABLE_CLANG_PLUGIN"; then
7487     if test -z "$CLANG_CC"; then
7488         AC_MSG_ERROR([Can't use clang plugin without clang.])
7489     fi
7490     AC_DEFINE(MOZ_CLANG_PLUGIN)
7493 AC_SUBST(ENABLE_CLANG_PLUGIN)
7495 dnl ========================================================
7496 dnl = Enable stripping of libs & executables
7497 dnl ========================================================
7498 MOZ_ARG_ENABLE_BOOL(strip,
7499 [  --enable-strip          Enable stripping of libs & executables ],
7500     ENABLE_STRIP=1,
7501     ENABLE_STRIP= )
7503 dnl ========================================================
7504 dnl = Enable stripping of libs & executables when packaging
7505 dnl ========================================================
7506 MOZ_ARG_ENABLE_BOOL(install-strip,
7507 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7508     PKG_SKIP_STRIP= ,
7509     PKG_SKIP_STRIP=1)
7511 dnl ========================================================
7512 dnl = --enable-elf-dynstr-gc
7513 dnl ========================================================
7514 MOZ_ARG_ENABLE_BOOL(elf-dynstr-gc,
7515 [  --enable-elf-dynstr-gc  Enable elf dynstr garbage collector (opt builds only)],
7516     USE_ELF_DYNSTR_GC=1,
7517     USE_ELF_DYNSTR_GC= )
7519 dnl ========================================================
7520 dnl = --disable-elf-hack
7521 dnl ========================================================
7523 USE_ELF_HACK=1
7524 MOZ_ARG_DISABLE_BOOL(elf-hack,
7525 [  --disable-elf-hack      Disable elf hacks],
7526     [USE_ELF_HACK=],
7527     [USE_ELF_HACK=F # Force enable elf-hack])
7529 # Disable elf hack for profiling because the built in profiler
7530 # doesn't read the segments properly with elf hack. This is
7531 # temporary and should be fixed soon in the profiler.
7532 if test "$MOZ_PROFILING" = 1; then
7533   if test "$USE_ELF_HACK" = F; then
7534     AC_ERROR([--enable-elf-hack is not compatible with --enable-profiling])
7535   fi
7536   USE_ELF_HACK=
7539 # Only enable elfhack where supported
7540 if test "$USE_ELF_HACK" = 1; then
7541     case "${HOST_OS_ARCH},${OS_ARCH}" in
7542     Linux,Linux)
7543         case "${CPU_ARCH}" in
7544         arm | x86 | x86_64)
7545             USE_ELF_HACK=1
7546             ;;
7547         *)
7548             USE_ELF_HACK=
7549             ;;
7550         esac
7551         ;;
7552     *)
7553         USE_ELF_HACK=
7554         ;;
7555     esac
7558 if test -n "$USE_ELF_HACK"; then
7559     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
7560     dnl memory addresses it maps to. The result is that by the time elfhack
7561     dnl kicks in, it is not possible to apply relocations because of that,
7562     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
7563     dnl segment. It makes elfhack mostly useless, so considering the problems
7564     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
7565     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
7566     dnl the linker creates PT_GNU_RELRO segments. However, when we do want
7567     dnl elfhack enabled, disable PT_GNU_RELRO instead.
7568     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
7569         LINK_WITH_PT_GNU_RELRO,
7570         [echo "int main() {return 0;}" > conftest.${ac_ext}
7571          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
7572             test -s conftest${ac_exeext}; then
7573             if ${TOOLCHAIN_PREFIX}readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
7574                 LINK_WITH_PT_GNU_RELRO=yes
7575             else
7576                 LINK_WITH_PT_GNU_RELRO=no
7577             fi
7578          else
7579              dnl We really don't expect to get here, but just in case
7580              AC_ERROR([couldn't compile a simple C file])
7581          fi
7582          rm -rf conftest*])
7583     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
7584         if test "$USE_ELF_HACK" = F; then
7585             AC_MSG_CHECKING([for -z norelro option to ld])
7586             _SAVE_LDFLAGS=$LDFLAGS
7587             LDFLAGS="$LDFLAGS -Wl,-z,norelro"
7588             AC_TRY_LINK(,,AC_MSG_RESULT([yes])
7589                         [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,norelro"],
7590                         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.]))
7591             USE_ELF_HACK=1
7592         else
7593             AC_MSG_WARN([Disabling elfhack])
7594             USE_ELF_HACK=
7595         fi
7596     fi
7599 dnl ========================================================
7600 dnl = libstdc++ compatibility hacks
7601 dnl ========================================================
7603 STDCXX_COMPAT=
7604 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
7605 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
7606     STDCXX_COMPAT=1)
7608 if test -n "$STDCXX_COMPAT"; then
7609    eval $(CXX="$CXX" HOST_CXX="$HOST_CXX" $PYTHON $_topsrcdir/build/autoconf/libstdcxx.py)
7610    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
7611    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
7614 dnl ========================================================
7615 dnl =
7616 dnl = Profiling and Instrumenting
7617 dnl =
7618 dnl ========================================================
7619 MOZ_ARG_HEADER(Profiling and Instrumenting)
7621 dnl ========================================================
7622 dnl = Enable runtime visual profiling logger
7623 dnl ========================================================
7624 MOZ_ARG_ENABLE_BOOL(visual-event-tracer,
7625 [  --enable-visual-event-tracer   Enable visual event tracer instrumentation],
7626     MOZ_VISUAL_EVENT_TRACER=1,
7627     MOZ_VISUAL_EVENT_TRACER=)
7628 if test -n "$MOZ_VISUAL_EVENT_TRACER"; then
7629     AC_DEFINE(MOZ_VISUAL_EVENT_TRACER)
7632 dnl ========================================================
7633 dnl Turn on reflow counting
7634 dnl ========================================================
7635 MOZ_ARG_ENABLE_BOOL(reflow-perf,
7636 [  --enable-reflow-perf    Enable reflow performance tracing],
7637     MOZ_REFLOW_PERF=1,
7638     MOZ_REFLOW_PERF= )
7639 if test -n "$MOZ_REFLOW_PERF"; then
7640     AC_DEFINE(MOZ_REFLOW_PERF)
7643 dnl ========================================================
7644 dnl = Enable Radio Interface for B2G (Gonk usually)
7645 dnl ========================================================
7646 MOZ_ARG_ENABLE_BOOL(b2g-ril,
7647 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
7648     MOZ_B2G_RIL=1,
7649     MOZ_B2G_RIL= )
7650 if test -n "$MOZ_B2G_RIL"; then
7651     AC_DEFINE(MOZ_B2G_RIL)
7653 AC_SUBST(MOZ_B2G_RIL)
7655 dnl ========================================================
7656 dnl = Enable Radio FM for B2G (Gonk usually)
7657 dnl ========================================================
7658 if test -n "$MOZ_B2G_FM"; then
7659     AC_DEFINE(MOZ_B2G_FM)
7661 AC_SUBST(MOZ_B2G_FM)
7663 dnl ========================================================
7664 dnl = Enable Bluetooth Interface for B2G (Gonk usually)
7665 dnl ========================================================
7666 MOZ_ARG_ENABLE_BOOL(b2g-bt,
7667 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
7668     MOZ_B2G_BT=1,
7669     MOZ_B2G_BT= )
7670 if test -n "$MOZ_B2G_BT"; then
7671     AC_DEFINE(MOZ_B2G_BT)
7673 AC_SUBST(MOZ_B2G_BT)
7675 dnl ========================================================
7676 dnl = Enable Support for Time Manager API
7677 dnl ========================================================
7678 if test -n "$MOZ_TIME_MANAGER"; then
7679     AC_DEFINE(MOZ_TIME_MANAGER)
7681 AC_SUBST(MOZ_TIME_MANAGER)
7683 dnl ========================================================
7684 dnl = Enable Camera Interface for B2G (Gonk usually)
7685 dnl ========================================================
7686 MOZ_ARG_ENABLE_BOOL(b2g-camera,
7687 [  --enable-b2g-camera      Set compile flags necessary for compiling camera API for B2G ],
7688     MOZ_B2G_CAMERA=1,
7689     MOZ_B2G_CAMERA= )
7690 if test -n "$MOZ_B2G_CAMERA"; then
7691    AC_DEFINE(MOZ_B2G_CAMERA)
7693 AC_SUBST(MOZ_B2G_CAMERA)
7695 dnl ========================================================
7696 dnl = Enable Support B2G-specific changes to the NSS
7697 dnl = certificate trust database.
7698 dnl ========================================================
7699 if test -n "$MOZ_B2G_CERTDATA"; then
7700     AC_DEFINE(MOZ_B2G_CERTDATA)
7702 AC_SUBST(MOZ_B2G_CERTDATA)
7704 dnl ========================================================
7705 dnl = Enable Support for Payment API
7706 dnl ========================================================
7707 if test -n "$MOZ_PAY"; then
7708     AC_DEFINE(MOZ_PAY)
7710 AC_SUBST(MOZ_PAY)
7712 dnl ========================================================
7713 dnl = Enable Support for AudioChannelManager API
7714 dnl ========================================================
7715 if test -n "$MOZ_AUDIO_CHANNEL_MANAGER"; then
7716     AC_DEFINE(MOZ_AUDIO_CHANNEL_MANAGER)
7718 AC_SUBST(MOZ_AUDIO_CHANNEL_MANAGER)
7720 dnl ========================================================
7721 dnl = Support for demangling undefined symbols
7722 dnl ========================================================
7723 if test -z "$SKIP_LIBRARY_CHECKS"; then
7724     AC_LANG_SAVE
7725     AC_LANG_CPLUSPLUS
7726     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7727     AC_LANG_RESTORE
7730 # Demangle only for debug or trace-malloc or DMD builds
7731 MOZ_DEMANGLE_SYMBOLS=
7732 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
7733     MOZ_DEMANGLE_SYMBOLS=1
7734     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7736 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7738 dnl ========================================================
7739 dnl = Support for gcc stack unwinding (from gcc 3.3)
7740 dnl ========================================================
7741 if test -z "$SKIP_LIBRARY_CHECKS"; then
7742     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7745 dnl ========================================================
7746 dnl JIT observers
7747 dnl ========================================================
7749 MOZ_ARG_WITH_STRING(jitreport-granularity,
7750 [  --jitreport-granularity=N
7751                            Default granularity at which to report JIT code
7752                            to external tools
7753                              0 - no info
7754                              1 - code ranges for whole functions only
7755                              2 - per-line information
7756                              3 - per-op information],
7757   JITREPORT_GRANULARITY=$withval,
7758   JITREPORT_GRANULARITY=3)
7760 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
7762 dnl ========================================================
7763 dnl =
7764 dnl = Misc. Options
7765 dnl =
7766 dnl ========================================================
7767 MOZ_ARG_HEADER(Misc. Options)
7769 dnl ========================================================
7770 dnl update xterm title
7771 dnl ========================================================
7772 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7773 [  --enable-xterm-updates  Update XTERM titles with current command.],
7774     MOZ_UPDATE_XTERM=1,
7775     MOZ_UPDATE_XTERM= )
7777 dnl =========================================================
7778 dnl = Chrome format
7779 dnl =========================================================
7780 MOZ_ARG_ENABLE_STRING([chrome-format],
7781 [  --enable-chrome-format=jar|flat|omni
7782                           Select FORMAT of chrome files during packaging],
7783     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7785 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7786     MOZ_CHROME_FILE_FORMAT=jar
7789 if test "$MOZ_CHROME_FILE_FORMAT" = "symlink"; then
7790     AC_MSG_ERROR([--enable-chrome-format=symlink has been deprecated. It is now used by default in $DIST/bin on platforms that support it])
7793 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
7794     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7795     test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
7796     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, or omni])
7799 dnl =========================================================
7800 dnl Omnijar packaging (bug 552121)
7801 dnl =========================================================
7802 dnl Omnijar packaging is compatible with flat packaging.
7803 dnl In unpackaged builds, omnijar looks for files as if
7804 dnl things were flat packaged. After packaging, all files
7805 dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
7806 dnl is set to flat since putting files into jars is only
7807 dnl done during packaging with omnijar.
7808 if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
7809     MOZ_OMNIJAR=1
7810     AC_DEFINE(MOZ_OMNIJAR)
7812 MOZ_PACKAGER_FORMAT="$MOZ_CHROME_FILE_FORMAT"
7813 if test "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2" -o "$MOZ_WIDGET_TOOLKIT" = "android"; then
7814     MOZ_CHROME_FILE_FORMAT=flat
7815 else
7816     MOZ_CHROME_FILE_FORMAT=symlink
7819 if test "$MOZ_WIDGET_TOOLKIT" = "android"; then
7820     dnl Fennec's static resources live in the assets/ folder of the
7821     dnl APK.  Adding a path to the name here works because we only
7822     dnl have one omnijar file in the final package (which is not the
7823     dnl case on desktop), and necessitates some contortions during
7824     dnl packaging so that the resources in the omnijar are considered
7825     dnl as rooted at / and not as rooted at assets/ (which again is
7826     dnl not the case on desktop: there are omnijars rooted at webrtc/,
7827     dnl etc). packager.mk handles changing the rooting of the single
7828     dnl omnijar.
7829     OMNIJAR_NAME=assets/omni.ja
7830 else
7831     OMNIJAR_NAME=omni.ja
7834 AC_SUBST(OMNIJAR_NAME)
7835 AC_SUBST(MOZ_OMNIJAR)
7836 AC_SUBST(MOZ_PACKAGER_FORMAT)
7838 dnl ========================================================
7839 dnl = Define default location for MOZILLA_FIVE_HOME
7840 dnl ========================================================
7841 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7842 [  --with-default-mozilla-five-home
7843                           Set the default value for MOZILLA_FIVE_HOME],
7844 [ val=`echo $withval`
7845   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7847 dnl ========================================================
7848 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7849 dnl ========================================================
7850 MOZ_ARG_WITH_STRING(user-appdir,
7851 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7852 [ val=`echo $withval`
7853 if echo "$val" | grep "\/" >/dev/null; then
7854     AC_MSG_ERROR("Homedir must be single relative path.")
7855 else
7856     MOZ_USER_DIR="$val"
7857 fi])
7859 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7861 dnl ========================================================
7862 dnl = Doxygen configuration
7863 dnl ========================================================
7864 dnl Use commas to specify multiple dirs to this arg
7865 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7866 MOZ_ARG_WITH_STRING(doc-input-dirs,
7867 [  --with-doc-input-dirs=DIRS
7868                           Header/idl dirs to create docs from],
7869 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7870 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7872 dnl Use commas to specify multiple dirs to this arg
7873 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7874 MOZ_ARG_WITH_STRING(doc-include-dirs,
7875 [  --with-doc-include-dirs=DIRS
7876                           Include dirs to preprocess doc headers],
7877 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7878 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7880 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7881 MOZ_ARG_WITH_STRING(doc-output-dir,
7882 [  --with-doc-output-dir=DIR
7883                           Dir to generate docs into],
7884 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7885 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7887 if test -z "$SKIP_COMPILER_CHECKS"; then
7888 dnl ========================================================
7889 dnl =
7890 dnl = Compiler Options
7891 dnl =
7892 dnl ========================================================
7893 MOZ_ARG_HEADER(Compiler Options)
7895 dnl ========================================================
7896 dnl Check for gcc -pipe support
7897 dnl ========================================================
7898 AC_MSG_CHECKING([for -pipe support])
7899 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
7900     dnl Any gcc that supports firefox supports -pipe.
7901     CFLAGS="$CFLAGS -pipe"
7902     CXXFLAGS="$CXXFLAGS -pipe"
7903     AC_MSG_RESULT([yes])
7904 else
7905     AC_MSG_RESULT([no])
7908 dnl ========================================================
7909 dnl Profile guided optimization (gcc checks)
7910 dnl ========================================================
7911 dnl Test for profiling options
7912 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7914 _SAVE_CFLAGS="$CFLAGS"
7915 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
7917 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7918 AC_TRY_COMPILE([], [return 0;],
7919                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7920                  result="yes" ], result="no")
7921 AC_MSG_RESULT([$result])
7923 if test $result = "yes"; then
7924   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7925   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
7926   PROFILE_USE_LDFLAGS="-fprofile-use"
7929 CFLAGS="$_SAVE_CFLAGS"
7931 if test -n "$INTEL_CC"; then
7932   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
7933   PROFILE_GEN_LDFLAGS=
7934   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
7935   PROFILE_USE_LDFLAGS=
7938 dnl Sun Studio on Solaris
7939 if test "$SOLARIS_SUNPRO_CC"; then
7940   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
7941   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
7942   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
7943   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
7946 AC_SUBST(PROFILE_GEN_CFLAGS)
7947 AC_SUBST(PROFILE_GEN_LDFLAGS)
7948 AC_SUBST(PROFILE_USE_CFLAGS)
7949 AC_SUBST(PROFILE_USE_LDFLAGS)
7951 AC_LANG_CPLUSPLUS
7953 dnl ========================================================
7954 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
7955 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
7956 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
7957 dnl ========================================================
7958 _SAVE_CXXFLAGS=$CXXFLAGS
7959 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
7960 AC_CACHE_CHECK(for correct overload resolution with const and templates,
7961     ac_nscap_nonconst_opeq_bug,
7962     [AC_TRY_COMPILE([
7963                       template <class T>
7964                       class Pointer
7965                         {
7966                         public:
7967                           T* myPtr;
7968                         };
7970                       template <class T, class U>
7971                       int operator==(const Pointer<T>& rhs, U* lhs)
7972                         {
7973                           return rhs.myPtr == lhs;
7974                         }
7976                       template <class T, class U>
7977                       int operator==(const Pointer<T>& rhs, const U* lhs)
7978                         {
7979                           return rhs.myPtr == lhs;
7980                         }
7981                     ],
7982                     [
7983                       Pointer<int> foo;
7984                       const int* bar;
7985                       return foo == bar;
7986                     ],
7987                     ac_nscap_nonconst_opeq_bug="no",
7988                     ac_nscap_nonconst_opeq_bug="yes")])
7989 CXXFLAGS="$_SAVE_CXXFLAGS"
7991 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
7992     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
7994 fi # ! SKIP_COMPILER_CHECKS
7996 AC_DEFINE(CPP_THROW_NEW, [throw()])
7997 AC_LANG_C
7999 if test "$COMPILE_ENVIRONMENT"; then
8000 MOZ_EXPAND_LIBS
8001 fi # COMPILE_ENVIRONMENT
8003 dnl ========================================================
8004 dnl =
8005 dnl = Build depencency options
8006 dnl =
8007 dnl ========================================================
8008 MOZ_ARG_HEADER(Build dependencies)
8010 if test "$GNU_CC" -a "$GNU_CXX"; then
8011   _DEPEND_CFLAGS='-MD -MP -MF $(MDDEPDIR)/$(@F).pp'
8012 dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
8013 elif test "$SOLARIS_SUNPRO_CC"; then
8014   _DEPEND_CFLAGS=
8015 else
8016   dnl Don't override this for MSVC
8017   if test -z "$_WIN32_MSVC"; then
8018     _USE_CPP_INCLUDE_FLAG=
8019     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
8020     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
8021   else
8022     echo '#include <stdio.h>' > dummy-hello.c
8023     changequote(,)
8024     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
8025     changequote([,])
8026     if test -z "$CL_INCLUDES_PREFIX"; then
8027         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
8028     fi
8029     AC_SUBST(CL_INCLUDES_PREFIX)
8030     rm -f dummy-hello.c
8031   fi
8034 dnl ========================================================
8035 dnl =
8036 dnl = Static Build Options
8037 dnl =
8038 dnl ========================================================
8039 MOZ_ARG_HEADER(Static build options)
8041 # split JS out by default to avoid VS2005 PGO crash (bug 591836).
8042 if test "$OS_ARCH" = "WINNT"; then
8043   ENABLE_SHARED_JS=1
8046 MOZ_ARG_ENABLE_BOOL(shared-js,
8047 [  --enable-shared-js
8048                           Create a shared JavaScript library.],
8049     ENABLE_SHARED_JS=1,
8050     ENABLE_SHARED_JS=)
8052 if test -n "$ENABLE_SHARED_JS"; then
8053   JS_SHARED_LIBRARY=1
8054   MOZ_JS_LIBS="$MOZ_JS_SHARED_LIBS"
8055 else
8056   MOZ_JS_LIBS="$MOZ_JS_STATIC_LIBS"
8057   AC_DEFINE(MOZ_STATIC_JS)
8059 AC_SUBST(JS_SHARED_LIBRARY)
8061 AC_SUBST(LIBXUL_LIBS)
8062 XPCOM_LIBS="$LIBXUL_LIBS"
8064 dnl ========================================================
8065 dnl =
8066 dnl = Standalone module options
8067 dnl =
8068 dnl ========================================================
8069 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
8071 dnl Check for GLib.
8072 dnl ========================================================
8074 if test -z "$SKIP_PATH_CHECKS"; then
8075 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
8076     if test "$MOZ_ENABLE_GTK2" -o "$USE_ELF_DYNSTR_GC" ; then
8077         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
8078     fi
8082 if test -z "${GLIB_GMODULE_LIBS}" \
8083    -a -n "${GLIB_CONFIG}"\
8084     -a "${GLIB_CONFIG}" != no\
8085 ; then
8086     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
8089 AC_SUBST(GLIB_CFLAGS)
8090 AC_SUBST(GLIB_LIBS)
8091 AC_SUBST(GLIB_GMODULE_LIBS)
8093 dnl ========================================================
8094 dnl Graphics checks.
8095 dnl ========================================================
8097 if test "${OS_TARGET}" = "WINNT"; then
8098   if $PERL -e "exit($MOZ_WINSDK_MAXVER < 0x06020000)"; then
8099     MOZ_ENABLE_DIRECT2D1_1=1
8100     AC_SUBST(MOZ_ENABLE_DIRECT2D1_1)
8101   fi
8104 if test "${OS_TARGET}" = "WINNT" -o \
8105         "${OS_ARCH}" = "Darwin" -o \
8106         "${MOZ_WIDGET_TOOLKIT}" = "android" -o \
8107         "${MOZ_WIDGET_TOOLKIT}" = "gonk" -o \
8108         "${MOZ_WIDGET_TOOLKIT}" = "gtk2"; then
8109     case "${target_cpu}" in
8110     i*86*|x86_64|arm)
8111         MOZ_ENABLE_SKIA=1
8112         ;;
8113     *)
8114         MOZ_ENABLE_SKIA=
8115         ;;
8116     esac
8117 else
8118 MOZ_ENABLE_SKIA=
8121 MOZ_ARG_ENABLE_BOOL(skia,
8122 [  --enable-skia   Enable use of Skia],
8123 MOZ_ENABLE_SKIA=1,
8124 MOZ_ENABLE_SKIA=)
8126 if test "$USE_FC_FREETYPE"; then
8127     if test "$COMPILE_ENVIRONMENT"; then
8128         dnl ========================================================
8129         dnl = Check for freetype2 and its functionality
8130         dnl ========================================================
8131         PKG_CHECK_MODULES(FT2, freetype2 >= 6.1.0, _HAVE_FREETYPE2=1, _HAVE_FREETYPE2=)
8133         if test "$_HAVE_FREETYPE2"; then
8134             _SAVE_LIBS="$LIBS"
8135             _SAVE_CFLAGS="$CFLAGS"
8136             LIBS="$LIBS $FT2_LIBS"
8137             CFLAGS="$CFLAGS $FT2_CFLAGS"
8139             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
8140                 ac_cv_member_FT_Bitmap_Size_y_ppem,
8141                 [AC_TRY_COMPILE([#include <ft2build.h>
8142                                  #include FT_FREETYPE_H],
8143                                 [FT_Bitmap_Size s;
8144                                  if (sizeof s.y_ppem) return 0;
8145                                  return 1],
8146                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
8147                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
8148             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
8149                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
8150             else
8151                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
8152             fi
8153             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
8154                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
8155                                [FT_Bitmap_Size structure includes y_ppem field])
8157             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table FT_Select_Size)
8159             LIBS="$_SAVE_LIBS"
8160             CFLAGS="$_SAVE_CFLAGS"
8161         fi
8163         _SAVE_CPPFLAGS="$CPPFLAGS"
8164         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
8165         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
8166             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
8167         CPPFLAGS="$_SAVE_CPPFLAGS"
8168     else
8169         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
8170     fi
8172     PKG_CHECK_MODULES(_FONTCONFIG, fontconfig,
8173     [
8174         if test "$MOZ_PANGO"; then
8175             MOZ_PANGO_CFLAGS="$MOZ_PANGO_CFLAGS $_FONTCONFIG_CFLAGS"
8176             MOZ_PANGO_LIBS="$MOZ_PANGO_LIBS $_FONTCONFIG_LIBS"
8177         else
8178             FT2_CFLAGS="$FT2_CFLAGS $_FONTCONFIG_CFLAGS"
8179             FT2_LIBS="$FT2_LIBS $_FONTCONFIG_LIBS"
8180         fi
8181     ])
8184 dnl ========================================================
8185 dnl Check for pixman and cairo
8186 dnl ========================================================
8188 MOZ_TREE_CAIRO=1
8189 MOZ_ARG_ENABLE_BOOL(system-cairo,
8190 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
8191 MOZ_TREE_CAIRO=,
8192 MOZ_TREE_CAIRO=1 )
8194 MOZ_TREE_PIXMAN=1
8195 MOZ_ARG_ENABLE_BOOL(system-pixman,
8196 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
8197 MOZ_TREE_PIXMAN=,
8198 MOZ_TREE_PIXMAN=force,
8199 MOZ_TREE_PIXMAN=1 )
8201 # System cairo depends on system pixman
8202 if test "$MOZ_TREE_PIXMAN" = "force"; then
8203     if test -z "$MOZ_TREE_CAIRO"; then
8204         AC_MSG_ERROR([--disable-system-pixman is incompatible with --enable-system-cairo.])
8205     else
8206         MOZ_TREE_PIXMAN=1
8207     fi
8208 elif test -z "$MOZ_TREE_CAIRO"; then
8209     MOZ_TREE_PIXMAN=
8212 if test "$MOZ_TREE_PIXMAN"; then
8213     AC_DEFINE(MOZ_TREE_PIXMAN)
8214     MOZ_PIXMAN_CFLAGS=""
8215     MOZ_PIXMAN_LIBS='$(call EXPAND_LIBNAME_PATH,mozlibpixman,$(DEPTH)/gfx/cairo/libpixman/src)'
8216 else
8217     PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.19.2)
8218     MOZ_PIXMAN_CFLAGS="$PIXMAN_CFLAGS"
8219     MOZ_PIXMAN_LIBS="$PIXMAN_LIBS"
8221 AC_SUBST(MOZ_PIXMAN_CFLAGS)
8222 AC_SUBST(MOZ_PIXMAN_LIBS)
8224 # Check for headers defining standard int types.
8225 MOZ_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
8227 if test "$MOZ_TREE_CAIRO"; then
8228     MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
8229     AC_DEFINE(MOZ_TREE_CAIRO)
8231     # For now we assume that we will have a uint64_t available through
8232     # one of the above headers or mozstdint.h.
8233     AC_DEFINE(HAVE_UINT64_T)
8235     # Define macros for cairo-features.h
8236     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
8237     if test "$MOZ_X11"; then
8238         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
8239         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
8240         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
8241         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8242         MOZ_ENABLE_CAIRO_FT=1
8243         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
8244     fi
8245     case "$MOZ_WIDGET_TOOLKIT" in
8246       qt)
8247         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
8248         ;;
8249       cocoa | uikit)
8250         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
8251         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
8252         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
8253         ;;
8254       windows)
8255         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
8256         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
8257         if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
8258             WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
8259             WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
8260             MOZ_ENABLE_D2D_SURFACE=1
8261             MOZ_ENABLE_DWRITE_FONT=1
8262         else
8263             WIN32_DWRITE_FONT_FEATURE=
8264             WIN32_D2D_SURFACE_FEATURE=
8265         fi
8267         MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
8269         dnl D3D10 Layers depend on D2D Surfaces.
8270         if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
8271           MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
8272         fi
8273         ;;
8274       os2)
8275         OS2_SURFACE_FEATURE="#define CAIRO_HAS_OS2_SURFACE 1"
8276         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8277         MOZ_ENABLE_CAIRO_FT=1
8278         CAIRO_FT_CFLAGS="-I${MZFTCFGFT2}/include"
8279         CAIRO_FT_OSLIBS="-L${MZFTCFGFT2}/lib -lmozft -lmzfntcfg"
8280         CAIRO_FT_LIBS=""
8281         ;;
8282     esac
8283     if test "$USE_FC_FREETYPE"; then
8284         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
8285     fi
8286     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
8287     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
8288     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
8289     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
8290     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
8291     AC_SUBST(CAIRO_FT_CFLAGS)
8293     AC_SUBST(PS_SURFACE_FEATURE)
8294     AC_SUBST(PDF_SURFACE_FEATURE)
8295     AC_SUBST(SVG_SURFACE_FEATURE)
8296     AC_SUBST(XLIB_SURFACE_FEATURE)
8297     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
8298     AC_SUBST(QUARTZ_SURFACE_FEATURE)
8299     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
8300     AC_SUBST(WIN32_SURFACE_FEATURE)
8301     AC_SUBST(OS2_SURFACE_FEATURE)
8302     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
8303     AC_SUBST(FT_FONT_FEATURE)
8304     AC_SUBST(FC_FONT_FEATURE)
8305     AC_SUBST(WIN32_FONT_FEATURE)
8306     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
8307     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
8308     AC_SUBST(QUARTZ_FONT_FEATURE)
8309     AC_SUBST(PNG_FUNCTIONS_FEATURE)
8310     AC_SUBST(QT_SURFACE_FEATURE)
8311     AC_SUBST(TEE_SURFACE_FEATURE)
8313     MOZ_CAIRO_LIBS='$(call EXPAND_LIBNAME_PATH,mozcairo,$(DEPTH)/gfx/cairo/cairo/src)'" $CAIRO_FT_LIBS"
8314     MOZ_CAIRO_OSLIBS='${CAIRO_FT_OSLIBS}'
8316     if test "$MOZ_X11"; then
8317         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
8318     fi
8320     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
8321 else
8322     PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION)
8323     MOZ_CAIRO_CFLAGS="$CAIRO_CFLAGS"
8324     MOZ_CAIRO_LIBS="$CAIRO_LIBS"
8325     PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
8326     if test "$MOZ_X11"; then
8327         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
8328         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
8329         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_LIBS"
8330         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
8331     fi
8334 AC_SUBST(MOZ_TREE_CAIRO)
8335 AC_SUBST(MOZ_CAIRO_CFLAGS)
8336 AC_SUBST(MOZ_CAIRO_LIBS)
8337 AC_SUBST(MOZ_CAIRO_OSLIBS)
8338 AC_SUBST(MOZ_TREE_PIXMAN)
8340 dnl ========================================================
8341 dnl qcms
8342 dnl ========================================================
8344 QCMS_LIBS='$(DEPTH)/gfx/qcms/$(LIB_PREFIX)mozqcms.$(LIB_SUFFIX)'
8345 AC_SUBST(QCMS_LIBS)
8347 dnl ========================================================
8348 dnl HarfBuzz
8349 dnl ========================================================
8350 MOZ_HARFBUZZ_LIBS='$(DEPTH)/gfx/harfbuzz/src/$(LIB_PREFIX)mozharfbuzz.$(LIB_SUFFIX)'
8351 AC_SUBST(MOZ_HARFBUZZ_LIBS)
8353 dnl ========================================================
8354 dnl SIL Graphite
8355 dnl ========================================================
8356 MOZ_GRAPHITE_LIBS='$(DEPTH)/gfx/graphite2/src/$(LIB_PREFIX)mozgraphite2.$(LIB_SUFFIX)'
8357 AC_SUBST(MOZ_GRAPHITE_LIBS)
8359 dnl ========================================================
8360 dnl OTS
8361 dnl ========================================================
8362 MOZ_OTS_LIBS='$(DEPTH)/gfx/ots/src/$(LIB_PREFIX)mozots.$(LIB_SUFFIX)'
8363 AC_SUBST(MOZ_OTS_LIBS)
8365 dnl ========================================================
8366 dnl Skia 
8367 dnl ========================================================
8368 if test "$MOZ_ENABLE_SKIA"; then
8369   MOZ_SKIA_LIBS='$(DEPTH)/gfx/skia/$(LIB_PREFIX)skia.$(LIB_SUFFIX)'
8370   AC_DEFINE(MOZ_ENABLE_SKIA)
8371   AC_DEFINE(USE_SKIA)
8372   if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
8373     AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
8374   elif test "$OS_ARCH" = "WINNT"; then
8375     AC_DEFINE(SKIA_DLL)
8376     AC_DEFINE(GR_DLL)
8377   fi
8379   if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64"; then
8380     MOZ_ENABLE_SKIA_GPU=1
8381     AC_DEFINE(USE_SKIA_GPU)
8382     AC_SUBST(MOZ_ENABLE_SKIA_GPU)
8383   fi
8384 else
8385   MOZ_SKIA_LIBS=
8387 AC_SUBST(MOZ_ENABLE_SKIA)
8388 AC_SUBST(MOZ_SKIA_LIBS)
8390 dnl ========================================================
8391 dnl disable xul
8392 dnl ========================================================
8393 MOZ_ARG_DISABLE_BOOL(xul,
8394 [  --disable-xul           Disable XUL],
8395     MOZ_XUL= )
8396 if test "$MOZ_XUL"; then
8397   AC_DEFINE(MOZ_XUL)
8398 else
8399   dnl remove extensions that require XUL
8400   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/venkman//' -e 's/irc//' -e 's/tasks//'`
8403 AC_SUBST(MOZ_XUL)
8405 dnl ========================================================
8406 dnl disable profile locking
8407 dnl   do no use this in applications that can have more than
8408 dnl   one process accessing the profile directory.
8409 dnl ========================================================
8410 MOZ_ARG_DISABLE_BOOL(profilelocking,
8411 [  --disable-profilelocking
8412                           Disable profile locking],
8413     MOZ_PROFILELOCKING=,
8414     MOZ_PROFILELOCKING=1 )
8415 if test "$MOZ_PROFILELOCKING"; then
8416   AC_DEFINE(MOZ_PROFILELOCKING)
8419 dnl ========================================================
8420 dnl necko configuration options
8421 dnl ========================================================
8424 dnl option to disable various necko protocols
8426 MOZ_ARG_ENABLE_STRING(necko-protocols,
8427 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8428                           Enable/disable specific protocol handlers],
8429 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8430     if test "$option" = "yes" -o "$option" = "all"; then
8431         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8432     elif test "$option" = "no" -o "$option" = "none"; then
8433         NECKO_PROTOCOLS=""
8434     elif test "$option" = "default"; then
8435         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8436     elif test `echo "$option" | grep -c \^-` != 0; then
8437         option=`echo $option | sed 's/^-//'`
8438         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8439     else
8440         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8441     fi
8442 done],
8443     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8444 dnl Remove dupes
8445 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
8446 AC_SUBST(NECKO_PROTOCOLS)
8447 for p in $NECKO_PROTOCOLS; do
8448     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8449     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_PROTOCOL_$p"
8450 done
8453 dnl option to disable necko's wifi scanner
8456 case "$OS_TARGET" in
8457   Android)
8458     if test -n "$gonkdir"; then
8459       NECKO_WIFI=1
8460     fi
8461     ;;
8462   Darwin|SunOS|WINNT)
8463     NECKO_WIFI=1
8464     ;;
8465   Linux)
8466     NECKO_WIFI=1
8467     NECKO_WIFI_DBUS=1
8468     ;;
8469 esac
8471 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8472 [  --disable-necko-wifi    Disable necko wifi scanner],
8473     NECKO_WIFI=,
8474     NECKO_WIFI=1)
8476 if test "$NECKO_WIFI"; then
8477   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
8478     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
8479   fi
8480   AC_DEFINE(NECKO_WIFI)
8481   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
8483 AC_SUBST(NECKO_WIFI)
8484 AC_SUBST(NECKO_WIFI_DBUS)
8487 dnl option to disable cookies
8489 MOZ_ARG_DISABLE_BOOL(cookies,
8490 [  --disable-cookies       Disable cookie support],
8491     NECKO_COOKIES=,
8492     NECKO_COOKIES=1)
8493 AC_SUBST(NECKO_COOKIES)
8494 if test "$NECKO_COOKIES"; then
8495     AC_DEFINE(NECKO_COOKIES)
8496     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
8500 dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
8502 MOZ_ARG_DISABLE_BOOL(ctypes,
8503 [  --disable-ctypes        Disable js-ctypes],
8504     BUILD_CTYPES=,
8505     BUILD_CTYPES=1)
8506 AC_SUBST(BUILD_CTYPES)
8507 if test "$BUILD_CTYPES"; then
8508     AC_DEFINE(BUILD_CTYPES)
8511 dnl Build Places if required
8512 if test "$MOZ_PLACES"; then
8513   AC_DEFINE(MOZ_PLACES)
8516 dnl Build SocialAPI if required
8517 if test "$MOZ_SOCIAL"; then
8518   AC_DEFINE(MOZ_SOCIAL)
8521 dnl Build Common JS modules provided by services.
8522 AC_SUBST(MOZ_SERVICES_COMMON)
8523 if test -n "$MOZ_SERVICES_COMMON"; then
8524   AC_DEFINE(MOZ_SERVICES_COMMON)
8527 dnl Build Services crypto component (used by Sync)
8528 AC_SUBST(MOZ_SERVICES_CRYPTO)
8529 if test -n "$MOZ_SERVICES_CRYPTO"; then
8530   AC_DEFINE(MOZ_SERVICES_CRYPTO)
8533 dnl Build Firefox Health Reporter Service
8534 AC_SUBST(MOZ_SERVICES_HEALTHREPORT)
8535 if test -n "$MOZ_SERVICES_HEALTHREPORT"; then
8536   AC_DEFINE(MOZ_SERVICES_HEALTHREPORT)
8539 dnl Build Services metrics component
8540 AC_SUBST(MOZ_SERVICES_METRICS)
8541 if test -n "$MOZ_SERVICES_METRICS"; then
8542   AC_DEFINE(MOZ_SERVICES_METRICS)
8545 dnl Build Notifications if required
8546 AC_SUBST(MOZ_SERVICES_NOTIFICATIONS)
8547 if test -n "$MOZ_SERVICES_NOTIFICATIONS"; then
8548   AC_DEFINE(MOZ_SERVICES_NOTIFICATIONS)
8551 dnl Build Sync Services if required
8552 AC_SUBST(MOZ_SERVICES_SYNC)
8553 if test -n "$MOZ_SERVICES_SYNC"; then
8554   AC_DEFINE(MOZ_SERVICES_SYNC)
8557 dnl Build Captive Portal Detector if required
8558 AC_SUBST(MOZ_CAPTIVEDETECT)
8559 if test -n "$MOZ_CAPTIVEDETECT"; then
8560   AC_DEFINE(MOZ_CAPTIVEDETECT)
8563 dnl ========================================================
8564 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
8565     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8568 if test "$MOZ_APP_COMPONENT_INCLUDE"; then
8569   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
8572 if test "$MOZ_APP_COMPONENT_MODULES"; then
8573   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_MODULES, $MOZ_APP_COMPONENT_MODULES)
8576 dnl ========================================================
8577 dnl =
8578 dnl = Maintainer debug option (no --enable equivalent)
8579 dnl =
8580 dnl ========================================================
8582 AC_SUBST(AR)
8583 AC_SUBST(AR_FLAGS)
8584 AC_SUBST(AR_LIST)
8585 AC_SUBST(AR_EXTRACT)
8586 AC_SUBST(AR_DELETE)
8587 AC_SUBST(AS)
8588 AC_SUBST(ASFLAGS)
8589 AC_SUBST(AS_DASH_C_FLAG)
8590 AC_SUBST(LD)
8591 AC_SUBST(RC)
8592 AC_SUBST(RCFLAGS)
8593 AC_SUBST(MC)
8594 AC_SUBST(WINDRES)
8595 AC_SUBST(IMPLIB)
8596 AC_SUBST(FILTER)
8597 AC_SUBST(BIN_FLAGS)
8598 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8599 AC_SUBST(MOZ_UPDATE_XTERM)
8600 AC_SUBST(MOZ_PLATFORM_MAEMO)
8601 AC_SUBST(MOZ_AUTH_EXTENSION)
8602 AC_SUBST(MOZ_PERMISSIONS)
8603 AC_SUBST(MOZ_PREF_EXTENSIONS)
8604 AC_SUBST(MOZ_JS_LIBS)
8605 AC_SUBST(MOZ_DEBUG)
8606 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8607 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8608 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8609 AC_SUBST(MOZ_DEBUG_FLAGS)
8610 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8611 AC_SUBST(WARNINGS_AS_ERRORS)
8612 AC_SUBST(MOZ_EXTENSIONS)
8613 AC_SUBST(MOZ_JSDEBUGGER)
8614 AC_SUBST(MOZ_ENABLE_PROFILER_SPS)
8615 AC_SUBST(MOZ_JPROF)
8616 AC_SUBST(MOZ_SHARK)
8617 AC_SUBST(MOZ_INSTRUMENTS)
8618 AC_SUBST(MOZ_CALLGRIND)
8619 AC_SUBST(MOZ_VTUNE)
8620 AC_SUBST(MOZ_PROFILING)
8621 AC_SUBST(LIBICONV)
8622 AC_SUBST(MOZ_PLACES)
8623 AC_SUBST(MOZ_SOCIAL)
8624 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8625 AC_SUBST(MOZ_FEEDS)
8626 AC_SUBST(NS_PRINTING)
8627 AC_SUBST(MOZ_WEBGL)
8628 AC_SUBST(MOZ_HELP_VIEWER)
8629 AC_SUBST(TOOLCHAIN_PREFIX)
8631 AC_SUBST(JAVA)
8632 AC_SUBST(JAVAC)
8633 AC_SUBST(JAVAH)
8634 AC_SUBST(JAR)
8635 AC_SUBST(JARSIGNER)
8636 AC_SUBST(KEYTOOL)
8638 AC_SUBST(MOZ_PROFILELOCKING)
8640 AC_SUBST(ENABLE_TESTS)
8641 AC_SUBST(ENABLE_MARIONETTE)
8642 AC_SUBST(IBMBIDI)
8643 AC_SUBST(MOZ_UNIVERSALCHARDET)
8644 AC_SUBST(ACCESSIBILITY)
8645 AC_SUBST(MOZ_SPELLCHECK)
8646 AC_SUBST(MOZ_ANDROID_OMTC)
8647 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
8648 AC_SUBST(MOZ_CRASHREPORTER)
8649 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
8650 AC_SUBST(MOZ_CRASHREPORTER_UPLOAD_FULL_SYMBOLS)
8651 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
8652 AC_SUBST(MOZ_STUB_INSTALLER)
8653 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
8654 AC_SUBST(MOZ_ENABLE_SIGNMAR)
8655 AC_SUBST(MOZ_UPDATER)
8656 AC_SUBST(MOZ_ANGLE_RENDERER)
8657 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
8658 AC_SUBST(MOZ_DIRECTX_SDK_CPU_SUFFIX)
8659 AC_SUBST(MOZ_D3DX9_VERSION)
8660 AC_SUBST(MOZ_D3DCOMPILER_CAB)
8661 AC_SUBST(MOZ_D3DCOMPILER_DLL)
8662 AC_SUBST(MOZ_METRO)
8664 AC_SUBST(MOZ_ANDROID_HISTORY)
8665 AC_SUBST(MOZ_WEBSMS_BACKEND)
8666 AC_SUBST(MOZ_ANDROID_BEAM)
8667 AC_SUBST(ENABLE_STRIP)
8668 AC_SUBST(PKG_SKIP_STRIP)
8669 AC_SUBST(STRIP_FLAGS)
8670 AC_SUBST(USE_ELF_DYNSTR_GC)
8671 AC_SUBST(USE_ELF_HACK)
8672 AC_SUBST(INCREMENTAL_LINKER)
8673 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8674 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8676 AC_SUBST(MOZ_FIX_LINK_PATHS)
8677 AC_SUBST(XPCOM_LIBS)
8678 AC_SUBST(XPCOM_FROZEN_LDOPTS)
8679 AC_SUBST(XPCOM_GLUE_LDOPTS)
8680 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
8681 AC_SUBST(XPCOM_STATICRUNTIME_GLUE_LDOPTS)
8682 AC_SUBST(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS)
8684 AC_SUBST(USE_DEPENDENT_LIBS)
8686 AC_SUBST(MOZ_BUILD_ROOT)
8687 AC_SUBST(MOZ_OS2_TOOLS)
8689 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8690 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8691 AC_SUBST(MOZ_LINKER_EXTRACT)
8693 dnl ========================================================
8694 dnl = Mac bundle name prefix
8695 dnl ========================================================
8696 MOZ_ARG_WITH_STRING(macbundlename-prefix,
8697 [  --with-macbundlename-prefix=prefix
8698                           Prefix for MOZ_MACBUNDLE_NAME],
8699 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
8701 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
8702 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
8703   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
8706 if test "$MOZ_DEBUG"; then
8707   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
8708 else
8709   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
8711 AC_SUBST(MOZ_MACBUNDLE_NAME)
8713 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
8714 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr '[A-Z]' '[a-z]'`
8715 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
8716 if test "$MOZ_DEBUG"; then
8717   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
8720 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
8721 AC_SUBST(MOZ_MACBUNDLE_ID)
8723 dnl ========================================================
8724 dnl = Child Process Name for IPC
8725 dnl ========================================================
8726 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
8727   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
8728 else
8729   # We want to let Android unpack the file at install time, but it only does
8730   # so if the file is named libsomething.so. The lib/ path is also required
8731   # because the unpacked file will be under the lib/ subdirectory and will
8732   # need to be executed from that path.
8733   MOZ_CHILD_PROCESS_NAME="lib/libplugin-container.so"
8735 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
8737 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
8738 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
8740 # The following variables are available to branding and application
8741 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
8742 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
8743 # impacts profile location and user-visible fields.
8744 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
8745 # versions of a given application (e.g. Aurora and Firefox both use
8746 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
8747 # for application.ini's "Name" field, which controls profile location in
8748 # the absence of a "Profile" field (see below), and various system
8749 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
8750 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
8751 # Mac Bundle name, Updater, Installer), it is typically used for nightly
8752 # builds (e.g. Aurora for Firefox).
8753 # - MOZ_APP_VERSION: Defines the application version number.
8754 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
8755 # defaults to a lowercase form of MOZ_APP_BASENAME.
8756 # - MOZ_APP_PROFILE: When set, used for application.ini's
8757 # "Profile" field, which controls profile location.
8758 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
8759 # crash reporter server url.
8760 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
8761 # - MOZ_EXTENSION_MANAGER: When set, enabled extension manager.
8763 if test -z "$MOZ_APP_NAME"; then
8764    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
8767 # For extensions and langpacks, we require a max version that is compatible
8768 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
8769 # 10.0a1 and 10.0a2 aren't affected
8770 # 10.0 becomes 10.0.*
8771 # 10.0.1 becomes 10.0.*
8772 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
8773 if test -z "$IS_ALPHA"; then
8774   changequote(,)
8775   MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*.[0-9]*\).*|\1|"`.*
8776   changequote([,])
8777 else
8778   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
8781 MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"}
8782 AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION")
8783 AC_DEFINE_UNQUOTED(MOZ_B2G_OS_NAME,"$MOZ_B2G_OS_NAME")
8785 AC_SUBST(MOZ_APP_NAME)
8786 AC_SUBST(MOZ_APP_DISPLAYNAME)
8787 AC_SUBST(MOZ_APP_BASENAME)
8788 AC_SUBST(MOZ_APP_VENDOR)
8789 AC_SUBST(MOZ_APP_PROFILE)
8790 AC_SUBST(MOZ_APP_ID)
8791 AC_SUBST(MAR_CHANNEL_ID)
8792 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
8793 AC_SUBST(MOZ_PROFILE_MIGRATOR)
8794 AC_SUBST(MOZ_EXTENSION_MANAGER)
8795 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
8796 AC_SUBST(MOZ_APP_UA_NAME)
8797 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
8798 AC_SUBST(MOZ_APP_VERSION)
8799 AC_SUBST(MOZ_APP_MAXVERSION)
8800 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
8801 AC_SUBST(FIREFOX_VERSION)
8802 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
8803 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
8804   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
8807 AC_SUBST(MOZ_APP_STATIC_INI)
8809 AC_SUBST(MOZ_PKG_SPECIAL)
8811 AC_SUBST(MOZILLA_OFFICIAL)
8813 AC_DEFINE_UNQUOTED(MOZ_TELEMETRY_DISPLAY_REV, 2)
8814 AC_SUBST(MOZ_TELEMETRY_DISPLAY_REV)
8816 if test "$MOZ_TELEMETRY_REPORTING"; then
8817     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
8819     # Enable Telemetry by default for nightly and aurora channels
8820     if test -z "$RELEASE_BUILD"; then
8821       AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
8822     fi
8825 dnl If we have any service that uploads data (and requires data submission
8826 dnl policy alert), set MOZ_DATA_REPORTING.
8827 dnl We need SUBST for build system and DEFINE for xul preprocessor.
8828 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"; then
8829   MOZ_DATA_REPORTING=1
8830   AC_DEFINE(MOZ_DATA_REPORTING)
8831   AC_SUBST(MOZ_DATA_REPORTING)
8834 dnl win32 options
8835 AC_SUBST(MOZ_BROWSE_INFO)
8836 AC_SUBST(MOZ_TOOLS_DIR)
8837 AC_SUBST(WIN32_REDIST_DIR)
8838 AC_SUBST(MAKENSISU)
8840 dnl Echo the CFLAGS to remove extra whitespace.
8841 CFLAGS=`echo \
8842         $_WARNINGS_CFLAGS \
8843         $CFLAGS`
8845 CXXFLAGS=`echo \
8846         $_WARNINGS_CXXFLAGS \
8847         $CXXFLAGS`
8849 COMPILE_CFLAGS=`echo \
8850     $_DEFINES_CFLAGS \
8851         $_DEPEND_CFLAGS \
8852     $COMPILE_CFLAGS`
8854 COMPILE_CXXFLAGS=`echo \
8855     $_DEFINES_CXXFLAGS \
8856         $_DEPEND_CFLAGS \
8857     $COMPILE_CXXFLAGS`
8859 AC_SUBST(SYSTEM_LIBXUL)
8860 AC_SUBST(MOZ_NATIVE_JPEG)
8861 AC_SUBST(MOZ_NATIVE_PNG)
8862 AC_SUBST(MOZ_NATIVE_BZ2)
8864 AC_SUBST(MOZ_JPEG_CFLAGS)
8865 AC_SUBST(MOZ_JPEG_LIBS)
8866 AC_SUBST(MOZ_BZ2_CFLAGS)
8867 AC_SUBST(MOZ_BZ2_LIBS)
8868 AC_SUBST(MOZ_PNG_CFLAGS)
8869 AC_SUBST(MOZ_PNG_LIBS)
8871 AC_SUBST(NSPR_CFLAGS)
8872 AC_SUBST(NSPR_LIBS)
8873 AC_SUBST(MOZ_NATIVE_NSPR)
8875 AC_SUBST(NSS_CFLAGS)
8876 AC_SUBST(NSS_LIBS)
8877 AC_SUBST(MOZ_NATIVE_NSS)
8878 AC_SUBST(NSS_DISABLE_DBM)
8880 OS_CFLAGS="$CFLAGS"
8881 OS_CXXFLAGS="$CXXFLAGS"
8882 OS_CPPFLAGS="$CPPFLAGS"
8883 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
8884 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
8885 OS_LDFLAGS="$LDFLAGS"
8886 OS_LIBS="$LIBS"
8887 AC_SUBST(OS_CFLAGS)
8888 AC_SUBST(OS_CXXFLAGS)
8889 AC_SUBST(OS_CPPFLAGS)
8890 AC_SUBST(OS_COMPILE_CFLAGS)
8891 AC_SUBST(OS_COMPILE_CXXFLAGS)
8892 AC_SUBST(OS_LDFLAGS)
8893 AC_SUBST(OS_LIBS)
8894 AC_SUBST(CROSS_COMPILE)
8895 AC_SUBST(WCHAR_CFLAGS)
8897 AC_SUBST(HOST_CC)
8898 AC_SUBST(HOST_CXX)
8899 AC_SUBST(HOST_CFLAGS)
8900 AC_SUBST(HOST_CXXFLAGS)
8901 AC_SUBST(HOST_LDFLAGS)
8902 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8903 AC_SUBST(HOST_AR)
8904 AC_SUBST(HOST_AR_FLAGS)
8905 AC_SUBST(HOST_LD)
8906 AC_SUBST(HOST_RANLIB)
8907 AC_SUBST(HOST_NSPR_MDCPUCFG)
8908 AC_SUBST(HOST_BIN_SUFFIX)
8909 AC_SUBST(HOST_OS_ARCH)
8911 AC_SUBST(TARGET_CPU)
8912 AC_SUBST(TARGET_VENDOR)
8913 AC_SUBST(TARGET_OS)
8914 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8915 AC_SUBST(TARGET_MD_ARCH)
8916 AC_SUBST(TARGET_XPCOM_ABI)
8917 AC_SUBST(OS_TARGET)
8918 AC_SUBST(OS_ARCH)
8919 AC_SUBST(OS_RELEASE)
8920 AC_SUBST(OS_TEST)
8921 AC_SUBST(CPU_ARCH)
8922 AC_SUBST(INTEL_ARCHITECTURE)
8923 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
8924 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
8926 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
8928 AC_SUBST(WRAP_LDFLAGS)
8929 AC_SUBST(MKSHLIB)
8930 AC_SUBST(MKCSHLIB)
8931 AC_SUBST(MKSHLIB_FORCE_ALL)
8932 AC_SUBST(MKSHLIB_UNFORCE_ALL)
8933 AC_SUBST(DSO_CFLAGS)
8934 AC_SUBST(DSO_PIC_CFLAGS)
8935 AC_SUBST(DSO_LDOPTS)
8936 AC_SUBST(LIB_PREFIX)
8937 AC_SUBST(DLL_PREFIX)
8938 AC_SUBST(DLL_SUFFIX)
8939 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
8940 AC_SUBST(LIB_SUFFIX)
8941 AC_SUBST(OBJ_SUFFIX)
8942 AC_SUBST(BIN_SUFFIX)
8943 AC_SUBST(ASM_SUFFIX)
8944 AC_SUBST(IMPORT_LIB_SUFFIX)
8945 AC_SUBST(USE_N32)
8946 AC_SUBST(CC_VERSION)
8947 AC_SUBST(CXX_VERSION)
8948 AC_SUBST(MSMANIFEST_TOOL)
8949 AC_SUBST(NS_ENABLE_TSF)
8950 AC_SUBST(MOZ_NSS_PATCH)
8951 AC_SUBST(MOZ_APP_COMPONENT_LIBS)
8952 AC_SUBST(MOZ_APP_EXTRA_LIBS)
8954 AC_SUBST(MOZ_SPEEX_RESAMPLER)
8955 AC_SUBST(MOZ_SOUNDTOUCH)
8956 AC_SUBST(MOZ_CUBEB)
8957 AC_SUBST(MOZ_WAVE)
8958 AC_SUBST(MOZ_VORBIS)
8959 AC_SUBST(MOZ_TREMOR)
8960 AC_SUBST(MOZ_OPUS)
8961 AC_SUBST(MOZ_WEBM)
8962 AC_SUBST(MOZ_DASH)
8963 AC_SUBST(MOZ_WMF)
8964 AC_SUBST(MOZ_DIRECTSHOW)
8965 AC_SUBST(MOZ_MEDIA_PLUGINS)
8966 AC_SUBST(MOZ_OMX_PLUGIN)
8967 AC_SUBST(MOZ_VP8_ERROR_CONCEALMENT)
8968 AC_SUBST(MOZ_VP8_ENCODER)
8969 AC_SUBST(MOZ_VP8)
8970 AC_SUBST(MOZ_OGG)
8971 AC_SUBST(VPX_AS)
8972 AC_SUBST(VPX_ASFLAGS)
8973 AC_SUBST(VPX_DASH_C_FLAG)
8974 AC_SUBST(VPX_AS_CONVERSION)
8975 AC_SUBST(VPX_ASM_SUFFIX)
8976 AC_SUBST(VPX_X86_ASM)
8977 AC_SUBST(VPX_ARM_ASM)
8978 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
8979 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
8980 AC_SUBST(LIBJPEG_TURBO_AS)
8981 AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
8982 AC_SUBST(LIBJPEG_TURBO_X86_ASM)
8983 AC_SUBST(LIBJPEG_TURBO_X64_ASM)
8984 AC_SUBST(LIBJPEG_TURBO_ARM_ASM)
8986 AC_SUBST(MOZ_PACKAGE_JSSHELL)
8987 AC_SUBST(MOZ_FOLD_LIBS)
8989 AC_SUBST(MOZ_ENABLE_SZIP)
8990 AC_SUBST(MOZ_SZIP_FLAGS)
8992 AC_MSG_CHECKING([for posix_fallocate])
8993 AC_TRY_LINK([#define _XOPEN_SOURCE 600
8994   #include <fcntl.h>],
8995                  [posix_fallocate(0, 0, 0);],
8996                  [ac_cv___posix_fallocate=true],
8997                  [ac_cv___posix_fallocate=false])
8999 if test "$ac_cv___posix_fallocate" = true ; then
9000   AC_DEFINE(HAVE_POSIX_FALLOCATE)
9001   AC_MSG_RESULT(yes)
9002 else
9003   AC_MSG_RESULT(no)
9006 dnl Check for missing components
9007 if test "$COMPILE_ENVIRONMENT"; then
9008 if test "$MOZ_X11"; then
9009     if test "$WITHOUT_X11"; then
9010         AC_MSG_ERROR([--without-x specified and MOZ_X11 still defined])
9011     fi
9012     dnl ====================================================
9013     dnl = Check if X headers exist
9014     dnl ====================================================
9015     _SAVE_CFLAGS=$CFLAGS
9016     CFLAGS="$CFLAGS $XCFLAGS"
9017     AC_TRY_COMPILE([
9018         #include <stdio.h>
9019         #include <stdlib.h>
9020         #include <X11/Xlib.h>
9021         #include <X11/Intrinsic.h>
9022         #include <X11/extensions/XShm.h>
9023     ],
9024     [
9025         Display *dpy = 0;
9026         if ((dpy = XOpenDisplay(NULL)) == NULL) {
9027             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
9028             exit(1);
9029         }
9030     ], [],
9031     [ AC_MSG_ERROR([Could not compile basic X program.]) ])
9032     CFLAGS="$_SAVE_CFLAGS"
9034     if test -n "$MISSING_X"; then
9035         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
9036     fi
9038 fi # MOZ_X11
9040 dnl Check for headers, etc. needed by WebGL.
9041 if test "$MOZ_GL_DEFAULT_PROVIDER" = "GLX"; then
9042     MOZ_CHECK_HEADER(GL/glx.h)
9043     if test "$ac_cv_header_GL_glx_h" != "yes"; then
9044         AC_MSG_ERROR([Can't find header GL/glx.h for WebGL (install mesa-common-dev (Ubuntu), mesa-libGL-devel (Fedora), or Mesa-devel (openSUSE))])
9045     fi
9046 fi # MOZ_GL_DEFAULT_PROVIDER=GLX
9047 fi # COMPILE_ENVIRONMENT
9049 dnl Set various defines and substitutions
9050 dnl ========================================================
9052 if test "$OS_ARCH" = "Darwin"; then
9053   AC_DEFINE(XP_UNIX)
9054 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2"; then
9055   AC_DEFINE(XP_UNIX)
9058 if test "$MOZ_DEBUG"; then
9059     AC_DEFINE(MOZ_REFLOW_PERF)
9060     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
9063 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
9064     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
9065     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
9066     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
9067     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
9068     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
9069     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
9070     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
9071     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
9074 AC_SUBST(MOZILLA_VERSION)
9076 AC_SUBST(ac_configure_args)
9078 dnl Spit out some output
9079 dnl ========================================================
9081 dnl The following defines are used by xpcom
9082 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
9083 CPP_THROW_NEW
9084 HAVE_CPP_2BYTE_WCHAR_T
9085 HAVE_CPP_AMBIGUITY_RESOLVING_USING
9086 HAVE_CPP_CHAR16_T
9087 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
9088 HAVE_CPP_PARTIAL_SPECIALIZATION
9089 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
9090 NEED_CPP_UNUSED_IMPLEMENTATIONS
9091 HAVE_GETPAGESIZE
9092 HAVE_ICONV
9093 HAVE_ICONV_WITH_CONST_INPUT
9094 HAVE_MBRTOWC
9095 HAVE_WCRTOMB
9096 HAVE_STATVFS64
9097 HAVE_STATVFS
9098 HAVE_STATFS64
9099 HAVE_STATFS
9100 HAVE_SYS_STATVFS_H
9101 HAVE_SYS_STATFS_H
9102 HAVE_SYS_VFS_H
9103 HAVE_SYS_MOUNT_H
9106 # FUTURE? Consider moving all these to moz.build files.
9107 AC_CONFIG_HEADER(
9108 netwerk/necko-config.h
9109 xpcom/xpcom-config.h
9110 xpcom/xpcom-private.h
9113 AC_SUBST(STLPORT_LIBS)
9115 export WRITE_MOZINFO=1
9116 AC_OUTPUT([mozilla-config.h])
9117 unset WRITE_MOZINFO
9119 # Hack around an Apple bug that affects the egrep that comes with OS X 10.7.
9120 # "env ARCHPREFERENCE=i386,x86_64 arch egrep" first tries to use the 32-bit
9121 # Intel part of the egrep fat binary, even on 64-bit systems, and falls back on
9122 # the 64-bit part if it's not a fat binary, as can happen with MacPorts. We
9123 # (apparently) only need this hack when egrep's "pattern" is particularly long
9124 # (as in the following code) and the first egrep on our $PATH is Apple's.  See
9125 # bug 655339.
9126 case "$host" in
9127 *-apple-darwin11*)
9128     FIXED_EGREP="env ARCHPREFERENCE=i386,x86_64 arch egrep"
9129     ;;
9131     FIXED_EGREP="egrep"
9132     ;;
9133 esac
9135 # Generate Makefiles for WebRTC directly from .gyp files
9136 if test "${OS_TARGET}" = "WINNT"; then
9137    if test "$HAVE_64BIT_OS"; then
9138       OS_BITS=64
9139    else
9140       OS_BITS=32
9141    fi
9142    EXTRA_GYP_DEFINES="-D MSVS_VERSION=${_MSVS_VERSION} -D MSVS_OS_BITS=${OS_BITS}"
9144 elif test "${OS_TARGET}" = "Android"; then
9145    if test "${MOZ_WIDGET_TOOLKIT}" = "gonk"; then
9146       EXTRA_GYP_DEFINES="-G os=linux "
9147    else
9148       EXTRA_GYP_DEFINES="-D gtest_target_type=executable -D android_toolchain=${android_toolchain} -G os=android "
9149    fi
9152 if test -n "$ARM_ARCH"; then
9153     if test "$ARM_ARCH" -lt 7; then
9154         EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D armv7=0 "
9155     else
9156         if test "${OS_TARGET}" = "Android"; then
9157             EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D armv7=1 "
9158         else
9159             dnl CPU detection for ARM works on Android only.  armv7 always uses CPU detection, so
9160             dnl we have to set armv7=0 for non-Android target
9161             EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D armv7=0 "
9162         fi
9163     fi
9166 # Keep libcubeb and audio_device backends in sync
9167 if test -n "$MOZ_ALSA"; then
9168    EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D include_alsa_audio=1"
9169 else
9170    EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D include_alsa_audio=0"
9172 if test -n "$MOZ_PULSEAUDIO"; then
9173    EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D include_pulse_audio=1"
9174 else
9175    EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D include_pulse_audio=0"
9178 # Don't try to compile ssse3/sse4.1 code if toolchain doesn't support
9179 if test -n "$INTEL_ARCHITECTURE"; then
9180   if test -z "$HAVE_TOOLCHAIN_SUPPORT_MSSSE3" -o -z "$HAVE_TOOLCHAIN_SUPPORT_MSSE4_1"; then
9181     EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D yuv_disable_asm=1"
9182   fi
9185 if test -n "$MOZ_WEBRTC"; then
9186    AC_MSG_RESULT("generating WebRTC Makefiles...")
9188    if test "${MOZ_WIDGET_TOOLKIT}" = "gonk"; then
9189       EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D build_with_gonk=1"
9190    fi
9192 dnl Any --include files must also appear in -D FORCED_INCLUDE_FILE= entries
9193 dnl so that regeneration via dependencies works correctly
9194    WEBRTC_CONFIG="-D build_with_mozilla=1 -D build_with_chromium=0 --include ${srcdir}/media/webrtc/webrtc_config.gypi -D FORCED_INCLUDE_FILE=${srcdir}/media/webrtc/webrtc_config.gypi"
9196    if test -n HAVE_CLOCK_MONOTONIC; then
9197       WEBRTC_CONFIG="${WEBRTC_CONFIG} -D have_clock_monotonic=1"
9198    else
9199       WEBRTC_CONFIG="${WEBRTC_CONFIG} -D have_clock_monotonic=0"
9200    fi
9202    GYP_WEBRTC_OPTIONS="--format=mozmake ${WEBRTC_CONFIG} -D target_arch=${WEBRTC_TARGET_ARCH} ${EXTRA_GYP_DEFINES} --depth=${srcdir}/media/webrtc/trunk --toplevel-dir=${srcdir} -G OBJDIR=${_objdir}"
9204    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9205      $GYP_WEBRTC_OPTIONS \
9206      --generator-output=${_objdir}/media/webrtc/trunk \
9207      ${srcdir}/media/webrtc/trunk/peerconnection.gyp
9208    if test "$?" != 0; then
9209       AC_MSG_ERROR([failed to generate WebRTC Makefiles])
9210    fi
9212    # XXX disable until we land the tranche with signaling
9213    if test -n "$MOZ_WEBRTC_SIGNALING"; then
9214      AC_MSG_RESULT("generating WebRTC/Signaling Makefiles...")
9215      $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9216        $GYP_WEBRTC_OPTIONS \
9217        -D build_for_test=0 \
9218        --generator-output=${_objdir}/media/webrtc/signaling \
9219        ${srcdir}/media/webrtc/signaling/signaling.gyp
9220      if test "$?" != 0; then
9221         AC_MSG_ERROR([failed to generate WebRTC/Signaling Makefiles])
9222      fi
9224      AC_MSG_RESULT("generating WebRTC/SignalingTest Makefiles...")
9225      $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9226        $GYP_WEBRTC_OPTIONS \
9227        -D build_for_test=1 \
9228        --generator-output=${_objdir}/media/webrtc/signalingtest \
9229        ${srcdir}/media/webrtc/signaling/signaling.gyp
9230      if test "$?" != 0; then
9231        AC_MSG_ERROR([failed to generate WebRTC/SignalingTest Makefiles])
9232      fi
9233    fi
9235    AC_MSG_RESULT("generating gtest Makefiles...")
9236    # Ok to pass some extra -D's that are ignored here
9237    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9238      $GYP_WEBRTC_OPTIONS \
9239      --generator-output=${_objdir}/media/webrtc/trunk/testing/ \
9240      ${srcdir}/media/webrtc/trunk/testing/gtest.gyp
9241    if test "$?" != 0; then
9242       AC_MSG_ERROR([failed to generate gtest Makefiles])
9243    fi
9245    AC_MSG_RESULT("generating nrappkit Makefiles...")
9246    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9247      $GYP_WEBRTC_OPTIONS \
9248      --generator-output=${_objdir}/media/mtransport/third_party/nrappkit \
9249      ${srcdir}/media/mtransport/third_party/nrappkit/nrappkit.gyp
9250    if test "$?" != 0; then
9251       AC_MSG_ERROR([failed to generate nrappkit Makefiles])
9252    fi
9254    AC_MSG_RESULT("generating nICEr Makefiles...")
9255    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9256      $GYP_WEBRTC_OPTIONS \
9257      --generator-output=${_objdir}/media/mtransport/third_party/nICEr \
9258      ${srcdir}/media/mtransport/third_party/nICEr/nicer.gyp
9259    if test "$?" != 0; then
9260       AC_MSG_ERROR([failed to generate nICEr Makefiles])
9261    fi
9264 # Run jemalloc configure script
9266 if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC3" -o -n "$MOZ_REPLACE_MALLOC"; then
9267   ac_configure_args="$_SUBDIR_CONFIG_ARGS --build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
9268   if test -n "$MOZ_REPLACE_MALLOC"; then
9269     # When using replace_malloc, we always want memalign and valloc exported from jemalloc.
9270     ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
9271     ac_configure_args="$ac_configure_args ac_cv_func_valloc=yes"
9272   fi
9273   if test -n "$MOZ_JEMALLOC3"; then
9274     case "${OS_ARCH}" in
9275       WINNT|Darwin)
9276         # We want jemalloc functions to be kept hidden on both Mac and Windows
9277         # See memory/build/mozmemory_wrap.h for details.
9278         ac_configure_args="$ac_configure_args --without-export"
9279         ;;
9280     esac
9281   elif test "${OS_ARCH}" = Darwin; then
9282     # When building as a replace-malloc lib, disabling the zone allocator
9283     # forces to use pthread_atfork.
9284     ac_configure_args="$ac_configure_args --disable-zone-allocator"
9285   fi
9286   _MANGLE="malloc posix_memalign aligned_alloc calloc realloc free memalign valloc malloc_usable_size"
9287   JEMALLOC_WRAPPER=
9288   if test -z "$MOZ_REPLACE_MALLOC"; then
9289     case "$OS_ARCH" in
9290       Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
9291         MANGLE=$_MANGLE
9292         ;;
9293     esac
9294   elif test -z "$MOZ_JEMALLOC3"; then
9295     MANGLE=$_MANGLE
9296     JEMALLOC_WRAPPER=replace_
9297   fi
9298   if test -n "$MANGLE"; then
9299     MANGLED=
9300     if test -n "$_WRAP_MALLOC" -a -z "$JEMALLOC_WRAPPER"; then
9301       JEMALLOC_WRAPPER=__wrap_
9302     fi
9303     for mangle in ${MANGLE}; do
9304       if test -n "$MANGLED"; then
9305         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle,$MANGLED"
9306       else
9307         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle"
9308       fi
9309     done
9310     ac_configure_args="$ac_configure_args --with-mangling=$MANGLED"
9311   fi
9312   unset CONFIG_FILES
9313   if test -z "$MOZ_TLS"; then
9314     ac_configure_args="$ac_configure_args --disable-tls"
9315   fi
9316   EXTRA_CFLAGS="$CFLAGS"
9317   for var in AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS EXTRA_CFLAGS LDFLAGS; do
9318     ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
9319   done
9320   if test "$CROSS_COMPILE"; then
9321     ac_configure_args="$ac_configure_args je_cv_static_page_shift=12"
9322   fi
9323   _save_cache_file="$cache_file"
9324   cache_file=$_objdir/memory/jemalloc/src/config.cache
9326   if ! test -e memory/jemalloc; then
9327     mkdir -p memory/jemalloc
9328   fi
9330   AC_OUTPUT_SUBDIRS(memory/jemalloc/src)
9331   cache_file="$_save_cache_file"
9332   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9335 # Run freetype configure script
9337 if test "$MOZ_TREE_FREETYPE"; then
9338    export CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS -std=c99"
9339    export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS"
9340    export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS"
9341    export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS"
9342    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
9343    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes --without-png"
9345    if ! test -e modules; then
9346      mkdir modules
9347    fi
9349    AC_OUTPUT_SUBDIRS(modules/freetype2)
9352 if test -z "$direct_nspr_config"; then
9353     dnl ========================================================
9354     dnl = Setup a nice relatively clean build environment for
9355     dnl = sub-configures.
9356     dnl ========================================================
9357     CC="$_SUBDIR_CC"
9358     CXX="$_SUBDIR_CXX"
9359     CFLAGS="$_SUBDIR_CFLAGS"
9360     CPPFLAGS="$_SUBDIR_CPPFLAGS"
9361     CXXFLAGS="$_SUBDIR_CXXFLAGS"
9362     LDFLAGS="$_SUBDIR_LDFLAGS"
9363     HOST_CC="$_SUBDIR_HOST_CC"
9364     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9365     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9366     RC=
9369 unset MAKEFILES
9370 unset CONFIG_FILES
9372 # Run all configure scripts specified by a subconfigure
9373 if test -n "$_subconfigure_subdir"; then
9374   _save_ac_configure_args="$ac_configure_args"
9375   ac_configure_args="$_subconfigure_config_args"
9376   AC_OUTPUT_SUBDIRS("$_subconfigure_subdir")
9377   ac_configure_args="$_save_ac_configure_args"
9380 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9381 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9383 export WRAP_LDFLAGS
9385 if test -n "$_WRAP_MALLOC"; then
9386     # Avoid doubling wrap malloc arguments
9387     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
9390 if test -z "$MOZ_NATIVE_NSPR"; then
9391     ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
9392     if test -z "$MOZ_DEBUG"; then
9393         ac_configure_args="$ac_configure_args --disable-debug"
9394     else
9395         ac_configure_args="$ac_configure_args --enable-debug"
9396     fi
9397     if test "$MOZ_OPTIMIZE" = "1"; then
9398         ac_configure_args="$ac_configure_args --enable-optimize"
9399     elif test -z "$MOZ_OPTIMIZE"; then
9400         ac_configure_args="$ac_configure_args --disable-optimize"
9401     fi
9402     if test -n "$HAVE_64BIT_OS"; then
9403         ac_configure_args="$ac_configure_args --enable-64bit"
9404     fi
9405     if test -n "$USE_ARM_KUSER"; then
9406         ac_configure_args="$ac_configure_args --with-arm-kuser"
9407     fi
9408     ac_configure_args="$ac_configure_args $NSPR_CONFIGURE_ARGS"
9410     # Save these, so we can mess with them for the subconfigure ..
9411     _SAVE_CFLAGS="$CFLAGS"
9412     _SAVE_CPPFLAGS="$CPPFLAGS"
9413     _SAVE_LDFLAGS="$LDFLAGS"
9415     if test -n "$MOZ_LINKER" -a "$ac_cv_func_dladdr" = no ; then
9416       # dladdr is supported by the new linker, even when the system linker doesn't
9417       # support it. Trick nspr into using dladdr when it's not supported.
9418       export CPPFLAGS="-include $_topsrcdir/mozglue/linker/dladdr.h $CPPFLAGS"
9419     fi
9420     export LDFLAGS="$LDFLAGS $NSPR_LDFLAGS"
9421     export CFLAGS="$CFLAGS $MOZ_FRAMEPTR_FLAGS"
9423     AC_OUTPUT_SUBDIRS(nsprpub)
9425     # .. and restore them
9426     unset CFLAGS
9427     unset CPPFLAGS
9428     unset LDFLAGS
9429     CFLAGS="$_SAVE_CFLAGS"
9430     CPPFLAGS="$_SAVE_CPPFLAGS"
9431     LDFLAGS="$_SAVE_LDFLAGS"
9433     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9436 dnl ========================================================
9437 dnl = Setup a nice relatively clean build environment for
9438 dnl = sub-configures.
9439 dnl ========================================================
9440 CC="$_SUBDIR_CC"
9441 CXX="$_SUBDIR_CXX"
9442 CFLAGS="$_SUBDIR_CFLAGS"
9443 CPPFLAGS="$_SUBDIR_CPPFLAGS"
9444 CXXFLAGS="$_SUBDIR_CXXFLAGS"
9445 LDFLAGS="$_SUBDIR_LDFLAGS"
9446 HOST_CC="$_SUBDIR_HOST_CC"
9447 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9448 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9451 if test -n "$ENABLE_CLANG_PLUGIN"; then
9452     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9453     AC_OUTPUT_SUBDIRS(build/clang-plugin)
9457 # Run the SpiderMonkey 'configure' script.
9458 dist=$MOZ_BUILD_ROOT/dist
9459 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9460 ac_configure_args="$ac_configure_args --enable-threadsafe"
9461 if test "$NIGHTLY_BUILD" = "1" -a "$MOZ_BUILD_APP" = "browser"; then
9462     # In desktop nightlies the Internationalization API is disabled, but all
9463     # code for it is still built.  Bug 853301 will remove this so that it's
9464     # built and the API is enabled.
9465     ac_configure_args="$ac_configure_args --with-intl-api=build"
9466 else
9467     # Internationalization isn't built or exposed by default in non-desktop and
9468     # non-nightly builds.  Bugs to enable:
9469     #
9470     #   Android:  bug 864843
9471     #   B2G:      bug 866301
9472     ac_configure_args="$ac_configure_args --without-intl-api"
9474 if test "$BUILD_CTYPES"; then
9475     # Build js-ctypes on the platforms we can.
9476     ac_configure_args="$ac_configure_args --enable-ctypes"
9478 if test -z "$JS_SHARED_LIBRARY" ; then
9479     ac_configure_args="$ac_configure_args --disable-shared-js"
9481 if test -z "$MOZ_NATIVE_NSPR"; then
9482     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
9483     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
9485 ac_configure_args="$ac_configure_args --with-dist-dir=../../dist"
9486 ac_configure_args="$ac_configure_args --prefix=$dist"
9487 if test "$MOZ_MEMORY"; then
9488    ac_configure_args="$ac_configure_args --enable-jemalloc"
9490 if test -n "$MOZ_GLUE_LDFLAGS"; then
9491    export MOZ_GLUE_LDFLAGS
9493 if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
9494    export MOZ_GLUE_PROGRAM_LDFLAGS
9496 if test "$MOZ_NATIVE_ZLIB" != 1 -a "$OS_ARCH" = "WINNT"; then
9497    MOZ_ZLIB_LIBS=
9499 export MOZ_NATIVE_ZLIB
9500 export MOZ_ZLIB_CFLAGS
9501 export MOZ_ZLIB_LIBS
9502 export MOZ_APP_NAME
9503 export DONT_POPULATE_VIRTUALENV=1
9504 export PYTHON
9505 export MOZILLA_CENTRAL_PATH=$_topsrcdir
9506 export STLPORT_CPPFLAGS
9507 export STLPORT_LDFLAGS
9508 export STLPORT_LIBS
9509 export JS_STANDALONE=no
9511 if ! test -e js; then
9512     mkdir js
9515 AC_OUTPUT_SUBDIRS(js/src)
9516 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9518 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR