Bug 777574 - Skip quickCheckAPI-B2.html on Linux. r=bjacob, a=test-only
[gecko.git] / configure.in
blob432ca8359e9e3cb35e6bfdae42a59867184ebf29
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=10607
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.8.1
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 objdir == srcdir builds.
90 dnl ==============================================================
91 _topsrcdir=`cd \`dirname $0\`; pwd`
92 _objdir=`pwd`
96 dnl TODO Don't exempt L10N builds once bug 842760 is resolved.
97 if test "$_topsrcdir" = "$_objdir" -a "${with_l10n_base+set}" != set; then
98   echo "  ***"
99   echo "  * Building directly in the main source directory is not allowed."
100   echo "  *"
101   echo "  * To build, you must run configure from a separate directory"
102   echo "  * (referred to as an object directory)."
103   echo "  *"
104   echo "  * If you are building with a mozconfig, you will need to change your"
105   echo "  * mozconfig to point to a different object directory."
106   echo "  ***"
107   exit 1
110 # Check for a couple representative files in the source tree
111 _conflict_files=
112 for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
113   if test -f $file; then
114     _conflict_files="$_conflict_files $file"
115   fi
116 done
117 if test "$_conflict_files"; then
118   echo "***"
119   echo "*   Your source tree contains these files:"
120   for file in $_conflict_files; do
121     echo "*         $file"
122   done
123   cat 1>&2 <<-EOF
124         *   This indicates that you previously built in the source tree.
125         *   A source tree build can confuse the separate objdir build.
126         *
127         *   To clean up the source tree:
128         *     1. cd $_topsrcdir
129         *     2. gmake distclean
130         ***
131         EOF
132   exit 1
133   break
135 MOZ_BUILD_ROOT=`pwd`
137 MOZ_PYTHON
139 MOZ_DEFAULT_COMPILER
141 COMPILE_ENVIRONMENT=1
142 MOZ_ARG_DISABLE_BOOL(compile-environment,
143 [  --disable-compile-environment
144                           Disable compiler/library checks.],
145     COMPILE_ENVIRONMENT= )
146 AC_SUBST(COMPILE_ENVIRONMENT)
148 MOZ_ARG_WITH_STRING(l10n-base,
149 [  --with-l10n-base=DIR    path to l10n repositories],
150     L10NBASEDIR=$withval)
151 if test -n "$L10NBASEDIR"; then
152     if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
153         AC_MSG_ERROR([--with-l10n-base must specify a path])
154     elif test -d "$L10NBASEDIR"; then
155         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd`
156     else
157         AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
158     fi
160 AC_SUBST(L10NBASEDIR)
162 dnl Check for Perl first -- needed for win32 SDK checks
163 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
164 if test -z "$PERL" -o "$PERL" = ":"; then
165     AC_MSG_ERROR([perl not found in \$PATH])
168 AC_SUBST(GAIADIR)
169 if test -n "$GAIADIR" ; then
170     AC_DEFINE(PACKAGE_GAIA)
173 MOZ_ARG_WITH_STRING(gonk,
174 [  --with-gonk=DIR
175                location of gonk dir],
176     gonkdir=$withval)
178 MOZ_ARG_WITH_STRING(gonk-toolchain-prefix,
179 [  --with-gonk-toolchain-prefix=DIR
180                           prefix to gonk toolchain commands],
181     gonk_toolchain_prefix=$withval)
183 if test -n "$gonkdir" ; then
184     kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
185     android_source="$gonkdir"
186     ANDROID_SOURCE="$android_source"
187     ANDROID_NDK="${ANDROID_SOURCE}/ndk"
188     dnl Default to ICS
189     ANDROID_VERSION=15
190     if test -n "${PLATFORM_SDK_VERSION}"; then
191         ANDROID_VERSION="${PLATFORM_SDK_VERSION}"
192     fi
194     dnl set up compilers
195     TOOLCHAIN_PREFIX="$gonk_toolchain_prefix"
196     AS="$gonk_toolchain_prefix"as
197     CC="$gonk_toolchain_prefix"gcc
198     CXX="$gonk_toolchain_prefix"g++
199     CPP="$gonk_toolchain_prefix"cpp
200     LD="$gonk_toolchain_prefix"ld
201     AR="$gonk_toolchain_prefix"ar
202     RANLIB="$gonk_toolchain_prefix"ranlib
203     STRIP="$gonk_toolchain_prefix"strip
204     OBJCOPY="$gonk_toolchain_prefix"objcopy
206     if ! test -e "$gonkdir/ndk/sources/cxx-stl/stlport/src/iostream.cpp"; then
207         AC_MSG_ERROR([Couldn't find path to stlport sources in the gonk tree])
208     fi
209     STLPORT_CPPFLAGS="-I$_topsrcdir/build/stlport/stlport -I$gonkdir/ndk/sources/cxx-stl/system/include"
210     STLPORT_LIBS="$_objdir/build/stlport/libstlport_static.a"
212     case "$target_cpu" in
213     arm)
214         ARCH_DIR=arch-arm
215         ;;
216     i?86)
217         ARCH_DIR=arch-x86
218         ;;
219     esac
221     case "$ANDROID_VERSION" in
222     15)
223         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"
224         MOZ_B2G_BT=1
225         MOZ_B2G_BT_BLUEZ=1
226         MOZ_NFC=1
227         MOZ_B2G_CAMERA=1
228         MOZ_OMX_DECODER=1
229         AC_SUBST(MOZ_OMX_DECODER)
230         MOZ_RTSP=1
231         ;;
232     17|18)
233         GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include"
234         if test -d "$gonkdir/external/bluetooth/bluez"; then
235           GONK_INCLUDES="$GONK_INCLUDES -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib"
236             MOZ_B2G_BT=1
237             MOZ_B2G_BT_BLUEZ=1
238         elif test -d "$gonkdir/external/bluetooth/bluedroid"; then
239             MOZ_B2G_BT=1
240             MOZ_B2G_BT_BLUEDROID=1
241         fi
243         MOZ_RTSP=1
244         MOZ_NFC=1
245         MOZ_B2G_CAMERA=1
246         MOZ_OMX_DECODER=1
247         AC_SUBST(MOZ_OMX_DECODER)
248         ;;
249     *)
250         AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION])
251         ;;
252     esac
253     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"
254     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
255     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS $STLPORT_CPPFLAGS"
256     dnl Add -llog by default, since we use it all over the place.
257     LIBS="$LIBS -llog"
259     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"
261     dnl prevent cross compile section from using these flags as host flags
262     if test -z "$HOST_CPPFLAGS" ; then
263         HOST_CPPFLAGS=" "
264     fi
265     if test -z "$HOST_CFLAGS" ; then
266         HOST_CFLAGS=" "
267     fi
268     if test -z "$HOST_CXXFLAGS" ; then
269         HOST_CXXFLAGS=" "
270     fi
271     if test -z "$HOST_LDFLAGS" ; then
272         HOST_LDFLAGS=" "
273     fi
275     AC_DEFINE(ANDROID)
276     AC_DEFINE_UNQUOTED(ANDROID_VERSION, $ANDROID_VERSION)
277     AC_SUBST(ANDROID_VERSION)
278     AC_DEFINE(HAVE_SYS_UIO_H)
279     AC_DEFINE(HAVE_PTHREADS)
280     CROSS_COMPILE=1
281     MOZ_CHROME_FILE_FORMAT=omni
282     direct_nspr_config=1
283 else
284     MOZ_ANDROID_NDK
286     case "$target" in
287     *-android*|*-linuxandroid*)
288         if test -z "$ANDROID_PACKAGE_NAME" ; then
289             ANDROID_PACKAGE_NAME='org.mozilla.$(MOZ_APP_NAME)'
290         fi
291         MOZ_CHROME_FILE_FORMAT=omni
292         ZLIB_DIR=yes
293         ;;
294     *-linux*)
295         AC_PATH_PROG(OBJCOPY,objcopy)
296         ;;
297     esac
300 AC_SUBST(ANDROID_SOURCE)
301 AC_SUBST(ANDROID_PACKAGE_NAME)
302 AC_SUBST(OBJCOPY)
304 dnl ========================================================
305 dnl Checks for compilers.
306 dnl ========================================================
307 dnl Set CROSS_COMPILE in the environment when running configure
308 dnl to use the cross-compile setup for now
309 dnl ========================================================
311 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
312 AR_FLAGS='crs $@'
314 if test "$COMPILE_ENVIRONMENT"; then
316 if test -n "$CROSS_COMPILE" -a "$target" != "$host"; then
317     MOZ_CROSS_COMPILER
318 else
319     AC_PROG_CC
320     case "$target" in
321     *-mingw*)
322       # Work around the conftest.exe access problem on Windows
323       sleep 2
324     esac
325     AC_PROG_CXX
326     AC_PROG_RANLIB
327     MOZ_PATH_PROGS(AS, $AS as, $CC)
328     AC_CHECK_PROGS(AR, ar, :)
329     AC_CHECK_PROGS(LD, ld, :)
330     AC_CHECK_PROGS(STRIP, strip, :)
331     AC_CHECK_PROGS(WINDRES, windres, :)
332     if test -z "$HOST_CC"; then
333         HOST_CC="$CC"
334     fi
335     if test -z "$HOST_CFLAGS"; then
336         HOST_CFLAGS="$CFLAGS"
337     fi
338     if test -z "$HOST_CXX"; then
339         HOST_CXX="$CXX"
340     fi
341     if test -z "$HOST_CXXFLAGS"; then
342         HOST_CXXFLAGS="$CXXFLAGS"
343     fi
344     if test -z "$HOST_LDFLAGS"; then
345         HOST_LDFLAGS="$LDFLAGS"
346     fi
347     if test -z "$HOST_RANLIB"; then
348         HOST_RANLIB="$RANLIB"
349     fi
350     if test -z "$HOST_AR"; then
351         HOST_AR="$AR"
352     fi
353     if test -z "$HOST_AR_FLAGS"; then
354         HOST_AR_FLAGS="$AR_FLAGS"
355     fi
358 if test -n "$MOZ_WINCONSOLE"; then
359     AC_DEFINE(MOZ_WINCONSOLE)
362 MOZ_TOOL_VARIABLES
364 if test -n "$GNU_CC" -a -z "$CLANG_CC" ; then
365     if test "$GCC_MAJOR_VERSION" -eq 4 -a "$GCC_MINOR_VERSION" -lt 4 ||
366        test "$GCC_MAJOR_VERSION" -lt 4; then
367         AC_MSG_ERROR([Only GCC 4.4 or newer supported])
368     fi
371 dnl ========================================================
372 dnl Special win32 checks
373 dnl ========================================================
375 MOZ_ARG_ENABLE_BOOL(metro,
376 [  --enable-metro           Enable Windows Metro build targets],
377     MOZ_METRO=1,
378     MOZ_METRO=)
379 if test -n "$MOZ_METRO"; then
380     AC_DEFINE(MOZ_METRO)
381     # Target the Windows 8 Kit
382     WINSDK_TARGETVER=602
383     WINVER=502
384     # toolkit/library/makefile.in needs these, see nsDllMain.
385     CRTDLLVERSION=110
386     CRTEXPDLLVERSION=1-1-0
387 else
388     # Target the Windows 7 SDK by default
389     WINSDK_TARGETVER=601
390     WINVER=502
393 AC_SUBST(CRTDLLVERSION)
394 AC_SUBST(CRTEXPDLLVERSION)
396 MOZ_ARG_WITH_STRING(windows-version,
397 [  --with-windows-version=WINSDK_TARGETVER
398                           Windows SDK version to target. Lowest version
399                           currently allowed is 601 (Win7), highest is 602 (Win8)],
400   WINSDK_TARGETVER=$withval)
402 # Currently only two sdk versions allowed, 601 and 602
403 case "$WINSDK_TARGETVER" in
404 601|602)
405     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
406     ;;
409     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER)]);
410     ;;
411 esac
413 case "$target" in
414 *-mingw*)
415     if test "$GCC" != "yes" -a -z "$CLANG_CC"; then
416         # Check to see if we are really running in a msvc environemnt
417         _WIN32_MSVC=1
418         AC_CHECK_PROGS(MIDL, midl)
420         # Make sure compilers are valid
421         CFLAGS="$CFLAGS -TC -nologo"
422         CXXFLAGS="$CXXFLAGS -TP -nologo"
423         AC_LANG_SAVE
424         AC_LANG_C
425         AC_TRY_COMPILE([#include <stdio.h>],
426             [ printf("Hello World\n"); ],,
427             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
429         AC_LANG_CPLUSPLUS
430         AC_TRY_COMPILE([#include <new.h>],
431             [ unsigned *test = new unsigned(42); ],,
432             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
433         AC_LANG_RESTORE
435         changequote(,)
436         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
437         changequote([,])
439         # Determine compiler version
440         CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
441         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
442         _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
443         _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
444         _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
445         _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
447         CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
448         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
450         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
451             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
452         fi
454         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
455         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
457         if test "$_CC_MAJOR_VERSION" = "16"; then
458             _CC_SUITE=10
459             _MSVS_VERSION=2010
460         elif test "$_CC_MAJOR_VERSION" = "17"; then
461             _CC_SUITE=11
462             _MSVS_VERSION=2012
463         elif test "$_CC_MAJOR_VERSION" = "18"; then
464             _CC_SUITE=12
465             _MSVS_VERSION=2013
466         else
467             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
468         fi
470         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
472         if test -n "$WIN32_REDIST_DIR"; then
473           if test ! -d "$WIN32_REDIST_DIR"; then
474             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
475           fi
476           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
477         fi
479         dnl Confirm we have the pri tools on win8 builds
480         if test -n "$MOZ_METRO"; then
481           AC_MSG_CHECKING([for makepri])
482           AC_CHECK_PROGS(MAKEPRI, makepri, "")
483           if test -z "MAKEPRI" ; then
484               AC_MSG_ERROR([makepri.exe is required for generating metro browser install components. It should be in the Win8 SDK.])
485           fi
486           AC_SUBST(MAKEPRI)
487         fi
489         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
490         dnl not something else like "magnetic tape manipulation utility".
491         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
492         if test -z "$MSMT_TOOL"; then
493           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
494         fi
496         changequote(,)
497         _MSMT_VER_FILTER='s|.*[^!-~]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
498         changequote([,])
499         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
500         if test -z "$MSMANIFEST_TOOL_VERSION"; then
501           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
502         fi
504         MSMANIFEST_TOOL=1
505         unset MSMT_TOOL
507         # Check linker version
508         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
509         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
510         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
511             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
512         fi
514         INCREMENTAL_LINKER=1
516         # Set midl environment
517         case "$target" in
518         i*86-*)
519             MIDL_FLAGS="${MIDL_FLAGS} -env win32"
520             ;;
521         x86_64-*)
522             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
523             ;;
524         esac
526         unset _MSVC_VER_FILTER
528         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
529             [
530                 AC_LANG_SAVE
531                 AC_LANG_CPLUSPLUS
532                 _SAVE_CXXFLAGS="$CXXFLAGS"
533                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
534                 AC_TRY_COMPILE([#include <exception>],
535                             [std::_Throw(std::exception()); return 0;],
536                             ac_cv_have_std__Throw="yes",
537                             ac_cv_have_std__Throw="no")
538                 CXXFLAGS="$_SAVE_CXXFLAGS"
539                 AC_LANG_RESTORE
540             ])
542         if test "$ac_cv_have_std__Throw" = "yes"; then
543             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
544                            ac_cv_have_dllimport_exception_bug,
545                 [
546                     AC_LANG_SAVE
547                     AC_LANG_CPLUSPLUS
548                     _SAVE_CXXFLAGS="$CXXFLAGS"
549                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
550                     AC_TRY_LINK([#include <vector>],
551                                 [std::vector<int> v; return v.at(1);],
552                                 ac_cv_have_dllimport_exception_bug="no",
553                                 ac_cv_have_dllimport_exception_bug="yes")
554                     CXXFLAGS="$_SAVE_CXXFLAGS"
555                     AC_LANG_RESTORE
556                 ])
557             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
558                 WRAP_STL_INCLUDES=1
559                 MOZ_MSVC_STL_WRAP__Throw=1
560                 AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
561             fi
562         else
563             AC_CACHE_CHECK(for overridable _RAISE,
564                            ac_cv_have__RAISE,
565                 [
566                     AC_LANG_SAVE
567                     AC_LANG_CPLUSPLUS
568                     _SAVE_CXXFLAGS="$CXXFLAGS"
569                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
570                     AC_TRY_COMPILE([#include <xstddef>
571                                     #undef _RAISE
572                                     #define _RAISE(x) externallyDefinedFunction((x).what())
573                                     #include <vector>
574                                    ],
575                                    [std::vector<int> v; return v.at(1);],
576                                    ac_cv_have__RAISE="no",
577                                    ac_cv_have__RAISE="yes")
578                     CXXFLAGS="$_SAVE_CXXFLAGS"
579                     AC_LANG_RESTORE
580                 ])
581             if test "$ac_cv_have__RAISE" = "yes"; then
582                 WRAP_STL_INCLUDES=1
583                 MOZ_MSVC_STL_WRAP__RAISE=1
584                 AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
585             else
586                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
587             fi
588         fi
590         if test "$WRAP_STL_INCLUDES" = "1"; then
591             STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
592         fi
593     elif test -z "$CLANG_CC"; then
594         # Check w32api version
595         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
596         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
597         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
598         AC_TRY_COMPILE([#include <w32api.h>],
599             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
600                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
601                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
602                 #error "test failed."
603             #endif
604             , [ res=yes ], [ res=no ])
605         AC_MSG_RESULT([$res])
606         if test "$res" != "yes"; then
607             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
608         fi
609         # Check windres version
610         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
611         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
612         AC_MSG_RESULT([$_WINDRES_VERSION])
613         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
614         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
615         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
616         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
617         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
618         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
619         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
620                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
621                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
622                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
623                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
624                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
625         then
626             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
627         fi
629         AC_CHECK_PROGS(MIDL, $target-widl widl)
630         if test -n "$MIDL"; then
631             case "$target" in
632             i*86-*)
633                 MIDL_FLAGS="$MIDL_FLAGS --win32 -m32"
634                 ;;
635             x86_64-*)
636                 MIDL_FLAGS="$MIDL_FLAGS --win64 -m64"
637                 ;;
638             esac
639         fi
641         MOZ_WINSDK_MAXVER=0x06020000
642     fi # !GNU_CC
644     # If MSVC or clang
645     if test "$GCC" != "yes" -o -n "$CLANG_CC" ; then
646         MOZ_FIND_WINSDK_VERSION
647     fi
649     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
650     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
651     # Require OS features provided by IE 6.0 SP2 (XP SP2)
652     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
654     # If the maximum version supported by this SDK is lower than the target
655     # version, error out
656     AC_MSG_CHECKING([for Windows SDK being recent enough])
657     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
658         AC_MSG_RESULT("yes")
659     else
660         AC_MSG_RESULT("no")
661         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.])
662     fi
663     
664     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
665     # Definitions matching sdkddkver.h
666     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
667     AC_DEFINE_UNQUOTED(MOZ_WINSDK_MAXVER,$MOZ_WINSDK_MAXVER)
668     AC_SUBST(MOZ_WINSDK_MAXVER)
669     ;;
670 esac
672 AC_PROG_CPP
673 AC_PROG_CXXCPP
675 if test -n "$_WIN32_MSVC"; then
676     SKIP_PATH_CHECKS=1
677     SKIP_COMPILER_CHECKS=1
678     SKIP_LIBRARY_CHECKS=1
680     # Since we're skipping compiler and library checks, hard-code
681     # some facts here.
682     AC_DEFINE(HAVE_IO_H)
683     AC_DEFINE(HAVE_SETBUF)
684     AC_DEFINE(HAVE_ISATTY)
687 fi # COMPILE_ENVIRONMENT
689 AC_SUBST(MIDL_FLAGS)
690 AC_SUBST(_MSC_VER)
692 AC_SUBST(GNU_AS)
693 AC_SUBST(GNU_LD)
694 AC_SUBST(GNU_CC)
695 AC_SUBST(GNU_CXX)
696 AC_SUBST(INTEL_CC)
697 AC_SUBST(INTEL_CXX)
699 AC_SUBST(STL_FLAGS)
700 AC_SUBST(WRAP_STL_INCLUDES)
701 AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
702 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
704 dnl ========================================================
705 dnl Checks for programs.
706 dnl ========================================================
707 AC_PROG_INSTALL
708 AC_PROG_LN_S
710 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
711 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
712 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
713 _perl_res=$?
714 AC_MSG_RESULT([$_perl_version])
716 if test "$_perl_res" != 0; then
717     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
721 AC_MSG_CHECKING([for full perl installation])
722 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
723 _perl_res=$?
724 if test "$_perl_res" != 0; then
725     AC_MSG_RESULT([no])
726     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
727 else
728     AC_MSG_RESULT([yes])
731 if test -z "$COMPILE_ENVIRONMENT"; then
732     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
734 AC_SUBST(NSINSTALL_BIN)
736 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
737 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
738 MOZ_PATH_PROGS(UNZIP, unzip)
739 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
740     AC_MSG_ERROR([unzip not found in \$PATH])
742 MOZ_PATH_PROGS(ZIP, zip)
743 if test -z "$ZIP" -o "$ZIP" = ":"; then
744     AC_MSG_ERROR([zip not found in \$PATH])
746 MOZ_PATH_PROG(XARGS, xargs)
747 if test -z "$XARGS" -o "$XARGS" = ":"; then
748     AC_MSG_ERROR([xargs not found in \$PATH .])
751 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
752 AC_SUBST(RPMBUILD)
754 if test "$COMPILE_ENVIRONMENT"; then
756 dnl ========================================================
757 dnl = Mac OS X toolchain support
758 dnl ========================================================
760 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
761 dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
762 dnl when we can run target binaries.
763 AC_SUBST(UNIVERSAL_BINARY)
764 AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
766 MOZ_ARG_WITH_STRING(unify-dist,
767 [  --with-unify-dist=dir   Location of the dist directory to unify with at packaging time (Mac OS X universal build only)],
768     UNIFY_DIST=$withval)
769 if test -n "$UNIVERSAL_BINARY"; then
770     if test -z "$UNIFY_DIST"; then
771         AC_MSG_ERROR([You need to provide the --with-unify-dist=dir argument when performing a universal build])
772     fi
773     case "$UNIFY_DIST" in
774     /*)
775         ;;
776     *)
777         UNIFY_DIST="${MOZ_BUILD_ROOT}/${UNIFY_DIST}"
778         ;;
779     esac
781 AC_SUBST(UNIFY_DIST)
783 dnl ========================================================
784 dnl Check for MacOS deployment target version
785 dnl ========================================================
787 MOZ_ARG_ENABLE_STRING(macos-target,
788                       [  --enable-macos-target=VER (default=10.6)
789                           Set the minimum MacOS version needed at runtime],
790                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
792 case "$target" in
793 *-darwin*)
794     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
795         dnl Use the specified value
796         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
797     else
798         dnl No value specified on the command line or in the environment,
799         dnl use architecture minimum.
800         export MACOSX_DEPLOYMENT_TARGET=10.6
801     fi
802     ;;
803 esac
805 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
807 dnl ========================================================
808 dnl = Mac OS X SDK support
809 dnl ========================================================
810 MACOS_SDK_DIR=
811 MOZ_ARG_WITH_STRING(macos-sdk,
812 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
813     MACOS_SDK_DIR=$withval)
815 MACOS_PRIVATE_FRAMEWORKS_DIR_DEFAULTED=
816 MOZ_ARG_WITH_STRING(macos-private-frameworks,
817 [  --with-macos-private-frameworks=dir    Location of private frameworks to use (Mac OS X only)],
818     MACOS_PRIVATE_FRAMEWORKS_DIR=$withval,
819     MACOS_PRIVATE_FRAMEWORKS_DIR=/System/Library/PrivateFrameworks
820     MACOS_PRIVATE_FRAMEWORKS_DEFAULTED=1)
822 if test -z "${MACOS_PRIVATE_FRAMEWORKS_DEFAULTED}"; then
823   if test -z "$CROSS_COMPILE"; then
824     AC_MSG_WARN([You should only be using --with-macos-private-frameworks when cross-compiling.])
825   fi
826   if test ! -d "$MACOS_PRIVATE_FRAMEWORKS_DIR"; then
827     AC_MSG_ERROR([PrivateFrameworks directory not found.])
828   fi
831 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
832 AC_SUBST(MACOS_SDK_DIR)
833 AC_SUBST(MACOS_PRIVATE_FRAMEWORKS_DIR)
835 if test "$MACOS_SDK_DIR"; then
836   dnl Sync this section with the ones in NSPR and NSS.
837   dnl Changes to the cross environment here need to be accounted for in
838   dnl the libIDL checks (below) and xpidl build.
840   if test ! -d "$MACOS_SDK_DIR"; then
841     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
842 specify a valid SDK.  SDKs are installed when the optional cross-development
843 tools are selected during the Xcode/Developer Tools installation.])
844   fi
846   CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
847   CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
849   dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
850   CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
851   CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
853   AC_LANG_SAVE
854   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
855   AC_LANG_CPLUSPLUS
856   AC_TRY_COMPILE([#include <new>],[],
857    result=yes,
858    result=no)
859   AC_LANG_RESTORE
860   AC_MSG_RESULT($result)
862   if test "$result" = "no" ; then
863     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
864   fi
867 fi # COMPILE_ENVIRONMENT
869 AC_MSG_CHECKING([compiler version])
870 # Just print it so it shows up in the logs.
871 cc_version=$($CC --version)
872 AC_MSG_RESULT([$cc_version])
874 if test -n "$MAKE"; then
875   if test `echo $MAKE | grep -c make.py` != 1; then
876      NOT_PYMAKE=$MAKE
877   fi
880 case "$host_os" in
881 mingw*)
882     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
883     ;;
885     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
886     ;;
887 esac
888 if test "$GMAKE" = ":"; then
889    AC_MSG_ERROR([GNU make not found])
891 AC_SUBST(GMAKE)
893 if test -z "$MAKE"; then
894   MAKE=$GMAKE
897 if test "$COMPILE_ENVIRONMENT"; then
899 AC_PATH_XTRA
901 XCFLAGS="$X_CFLAGS"
903 fi # COMPILE_ENVIRONMENT
905 dnl ========================================================
906 dnl set the defaults first
907 dnl ========================================================
908 AS_BIN=$AS
909 AR_LIST='$(AR) t'
910 AR_EXTRACT='$(AR) x'
911 AR_DELETE='$(AR) d'
912 AS='$(CC)'
913 AS_DASH_C_FLAG='-c'
914 DLL_PREFIX=lib
915 LIB_PREFIX=lib
916 DLL_SUFFIX=.so
917 OBJ_SUFFIX=o
918 LIB_SUFFIX=a
919 ASM_SUFFIX=s
920 IMPORT_LIB_SUFFIX=
921 TARGET_MD_ARCH=unix
922 DIRENT_INO=d_ino
923 MOZ_USER_DIR=".mozilla"
925 MOZ_JPEG_CFLAGS=
926 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)'
927 MOZ_BZ2_CFLAGS=
928 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
929 MOZ_PNG_CFLAGS=
930 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
932 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
933 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
934 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
935 XPCOM_FROZEN_LDOPTS='$(call EXPAND_LIBNAME_PATH,xul mozalloc,$(LIBXUL_DIST)/bin)'
936 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS)'
937 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
938 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
940 # These are specially defined on Windows only
941 case "$target" in
942 *-mingw*)
943   XPCOM_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
944   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime.$(LIB_SUFFIX)'
945   ;;
947   XPCOM_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_GLUE_LDOPTS
948   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_STANDALONE_GLUE_LDOPTS
949   ;;
950 esac
952 MOZ_FS_LAYOUT=unix
954 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
956 USE_DEPENDENT_LIBS=1
958 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
960 if test -n "$CROSS_COMPILE"; then
961     OS_TARGET="${target_os}"
962     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
963     OS_RELEASE=
964     case "${target_os}" in
965         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
966         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
967         gnu*)         OS_ARCH=GNU ;;
968         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
969         mingw*)       OS_ARCH=WINNT OS_TARGET=WINNT ;;
970         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
971     esac
972     case "${target}" in
973         *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
974     esac
975 else
976     OS_TARGET=`uname -s`
977     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
978     OS_RELEASE=`uname -r`
981 # Before this used `uname -m` when not cross compiling
982 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
983 OS_TEST="${target_cpu}"
985 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
987 #######################################################################
988 # Master "Core Components" macros for getting the OS target           #
989 #######################################################################
992 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
993 # cross-compilation.
997 # Define and override various archtecture-specific variables, including
998 # HOST_OS_ARCH
999 # OS_ARCH
1000 # OS_TEST
1001 # OS_TARGET
1002 # OS_RELEASE
1003 # OS_MINOR_RELEASE
1006 case "$HOST_OS_ARCH" in
1007 mingw*)
1008     HOST_OS_ARCH=WINNT
1009     ;;
1010 darwin*)
1011     HOST_OS_ARCH=Darwin
1012     ;;
1013 linux*)
1014     HOST_OS_ARCH=Linux
1015     ;;
1016 solaris*)
1017     HOST_OS_ARCH=SunOS
1018     SOLARIS_SUNPRO_CC=
1019     SOLARIS_SUNPRO_CXX=
1020     if test -z "$GNU_CC"; then
1021         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1022             SOLARIS_SUNPRO_CC=1
1023        fi
1024     fi
1026     if test -z "$GNU_CXX"; then
1027        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1028            SOLARIS_SUNPRO_CXX=1
1029        fi
1030     fi
1031     AC_SUBST(SOLARIS_SUNPRO_CC)
1032     AC_SUBST(SOLARIS_SUNPRO_CXX)
1033     ;;
1034 OS_2)
1035     HOST_OS_ARCH=OS2
1036     ;;
1037 esac
1039 case "$OS_ARCH" in
1040 WINNT)
1041     if test -z "$CROSS_COMPILE" ; then
1042         OS_TEST=`uname -p`
1043     fi
1044     ;;
1045 Windows_NT)
1047 # If uname -s returns "Windows_NT", we assume that we are using
1048 # the uname.exe in MKS toolkit.
1050 # The -r option of MKS uname only returns the major version number.
1051 # So we need to use its -v option to get the minor version number.
1052 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1054     OS_ARCH=WINNT
1055     OS_TARGET=WINNT
1056     OS_MINOR_RELEASE=`uname -v`
1057     if test "$OS_MINOR_RELEASE" = "00"; then
1058         OS_MINOR_RELEASE=0
1059     fi
1060     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1061     ;;
1062 MINGW*_NT*)
1064 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1065 # the uname.exe in the MSYS tools.
1067     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1068     OS_ARCH=WINNT
1069     OS_TARGET=WINNT
1070     ;;
1071 AIX)
1072     OS_RELEASE=`uname -v`.`uname -r`
1073     OS_TEST=${target_cpu}
1074     ;;
1075 OS_2)
1076     OS_ARCH=OS2
1077     OS_TARGET=OS2
1078     OS_RELEASE=`uname -v`
1079     ;;
1080 Darwin)
1081     case "${target_cpu}" in
1082     powerpc*)
1083         OS_TEST=ppc
1084         ;;
1085     i*86*)
1086         OS_TEST=i386
1087         ;;
1088     x86_64)
1089         OS_TEST=x86_64
1090         ;;
1091     *)
1092         if test -z "$CROSS_COMPILE" ; then
1093             OS_TEST=`uname -p`
1094         fi
1095         ;;
1096     esac
1097     ;;
1098 esac
1100 # Only set CPU_ARCH if we recognize the value of OS_TEST
1102 case "$OS_TEST" in
1103 *86 | i86pc)
1104     CPU_ARCH=x86
1105     ;;
1107 powerpc64 | ppc64)
1108     CPU_ARCH=ppc64
1109     ;;
1111 powerpc | ppc | rs6000)
1112     CPU_ARCH=ppc
1113     ;;
1115 Alpha | alpha | ALPHA)
1116     CPU_ARCH=Alpha
1117     ;;
1119 s390)
1120     CPU_ARCH=s390
1121     ;;
1123 s390x)
1124     CPU_ARCH=s390x
1125     ;;
1127 hppa* | parisc)
1128     CPU_ARCH=hppa
1129     ;;
1131 sun4u | sparc*)
1132     CPU_ARCH=sparc
1133     ;;
1135 x86_64 | ia64)
1136     CPU_ARCH="$OS_TEST"
1137     ;;
1139 arm*)
1140     CPU_ARCH=arm
1141     ;;
1143 mips|mipsel)
1144     CPU_ARCH="mips"
1145     ;;
1146 esac
1148 if test -z "$OS_TARGET"; then
1149     OS_TARGET=$OS_ARCH
1151 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1153 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1154 dnl ===============================================================
1155 INTEL_ARCHITECTURE=
1156 case "$OS_TEST" in
1157     x86_64|i?86)
1158       INTEL_ARCHITECTURE=1
1159 esac
1161 dnl Configure platform-specific CPU architecture compiler options.
1162 dnl ==============================================================
1163 MOZ_ARCH_OPTS
1165 dnl =================================================================
1166 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1167 dnl which is bad when cross compiling.
1168 dnl =================================================================
1169 if test "$COMPILE_ENVIRONMENT"; then
1170 configure_static_assert_macros='
1171 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1172 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1173 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1176 dnl test that the macros actually work:
1177 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1178 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1179  [AC_LANG_SAVE
1180   AC_LANG_C
1181   ac_cv_static_assertion_macros_work="yes"
1182   AC_TRY_COMPILE([$configure_static_assert_macros],
1183                  [CONFIGURE_STATIC_ASSERT(1)],
1184                  ,
1185                  ac_cv_static_assertion_macros_work="no")
1186   AC_TRY_COMPILE([$configure_static_assert_macros],
1187                  [CONFIGURE_STATIC_ASSERT(0)],
1188                  ac_cv_static_assertion_macros_work="no",
1189                  )
1190   AC_LANG_CPLUSPLUS
1191   AC_TRY_COMPILE([$configure_static_assert_macros],
1192                  [CONFIGURE_STATIC_ASSERT(1)],
1193                  ,
1194                  ac_cv_static_assertion_macros_work="no")
1195   AC_TRY_COMPILE([$configure_static_assert_macros],
1196                  [CONFIGURE_STATIC_ASSERT(0)],
1197                  ac_cv_static_assertion_macros_work="no",
1198                  )
1199   AC_LANG_RESTORE
1200  ])
1201 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1202 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1203     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1205 fi # COMPILE_ENVIRONMENT
1207 dnl ========================================================
1208 dnl Android libstdc++, placed here so it can use MOZ_ARCH
1209 dnl computed above.
1210 dnl ========================================================
1212 MOZ_ANDROID_STLPORT
1214 dnl ========================================================
1215 dnl Suppress Clang Argument Warnings
1216 dnl ========================================================
1217 if test -n "$CLANG_CC"; then
1218     _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
1219     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
1221 if test -n "$CLANG_CXX"; then
1222     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
1225 dnl ========================================================
1226 dnl = Use Address Sanitizer
1227 dnl ========================================================
1228 MOZ_ARG_ENABLE_BOOL(address-sanitizer,
1229 [  --enable-address-sanitizer       Enable Address Sanitizer (default=no)],
1230     MOZ_ASAN=1,
1231     MOZ_ASAN= )
1232 if test -n "$MOZ_ASAN"; then
1233     MOZ_LLVM_HACKS=1
1234     AC_DEFINE(MOZ_ASAN)
1235     MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
1237 AC_SUBST(MOZ_ASAN)
1238 AC_SUBST(LLVM_SYMBOLIZER)
1240 dnl ========================================================
1241 dnl = Enable hacks required for LLVM instrumentations
1242 dnl ========================================================
1243 MOZ_ARG_ENABLE_BOOL(llvm-hacks,
1244 [  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)],
1245     MOZ_LLVM_HACKS=1,
1246     MOZ_LLVM_HACKS= )
1247 if test -n "$MOZ_LLVM_HACKS"; then
1248     MOZ_NO_WLZDEFS=1
1249     MOZ_CFLAGS_NSS=1
1251 AC_SUBST(MOZ_NO_WLZDEFS)
1252 AC_SUBST(MOZ_CFLAGS_NSS)
1254 dnl ========================================================
1255 dnl GNU specific defaults
1256 dnl ========================================================
1257 if test "$GNU_CC"; then
1258     # Per bug 719659 comment 2, some of the headers on ancient build machines
1259     # may require gnu89 inline semantics.  But otherwise, we use C99.
1260     # But on OS X we just use C99 plus GNU extensions, in order to fix
1261     # bug 917526.
1262     CFLAGS="$CFLAGS -std=gnu99"
1263     if test "${OS_ARCH}" != Darwin; then
1264         CFLAGS="$CFLAGS -fgnu89-inline"
1265     fi
1266     # FIXME: Let us build with strict aliasing. bug 414641.
1267     CFLAGS="$CFLAGS -fno-strict-aliasing"
1268     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@'
1269     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@'
1270     DSO_LDOPTS='-shared'
1271     if test "$GCC_USE_GNU_LD"; then
1272         # Some tools like ASan use a runtime library that is only
1273         # linked against executables, so we must allow undefined
1274         # symbols for shared objects in some cases.
1275         if test -z "$MOZ_NO_WLZDEFS"; then
1276             # Don't allow undefined symbols in libraries
1277             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1278         fi
1279     fi
1280     WARNINGS_AS_ERRORS='-Werror'
1281     DSO_CFLAGS=''
1282     DSO_PIC_CFLAGS='-fPIC'
1283     ASFLAGS="$ASFLAGS -fPIC"
1284     AC_MSG_CHECKING([for --noexecstack option to as])
1285     _SAVE_CFLAGS=$CFLAGS
1286     CFLAGS="$CFLAGS -Wa,--noexecstack"
1287     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
1288                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
1289                      AC_MSG_RESULT([no]))
1290     CFLAGS=$_SAVE_CFLAGS
1291     AC_MSG_CHECKING([for -z noexecstack option to ld])
1292     _SAVE_LDFLAGS=$LDFLAGS
1293     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
1294     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
1295                   AC_MSG_RESULT([no])
1296                   LDFLAGS=$_SAVE_LDFLAGS)
1298     AC_MSG_CHECKING([for -z text option to ld])
1299     _SAVE_LDFLAGS=$LDFLAGS
1300     LDFLAGS="$LDFLAGS -Wl,-z,text"
1301     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1302                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,text"],
1303                   AC_MSG_RESULT([no])
1304                   LDFLAGS=$_SAVE_LDFLAGS)
1306     AC_MSG_CHECKING([for --build-id option to ld])
1307     _SAVE_LDFLAGS=$LDFLAGS
1308     LDFLAGS="$LDFLAGS -Wl,--build-id"
1309     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1310                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,--build-id"],
1311                   AC_MSG_RESULT([no])
1312                   LDFLAGS=$_SAVE_LDFLAGS)
1315     # Check for -mssse3 on $CC
1316     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
1317     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
1318     _SAVE_CFLAGS=$CFLAGS
1319     CFLAGS="$CFLAGS -mssse3"
1320     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
1321                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
1322                      AC_MSG_RESULT([no]))
1323     CFLAGS=$_SAVE_CFLAGS
1325     # Check for -msse4.1 on $CC
1326     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
1327     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
1328     _SAVE_CFLAGS=$CFLAGS
1329     CFLAGS="$CFLAGS -msse4.1"
1330     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
1331                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
1332                      AC_MSG_RESULT([no]))
1333     CFLAGS=$_SAVE_CFLAGS
1335     # Turn on GNU-specific warnings:
1336     # -Wall - turn on a lot of warnings
1337     # -Wpointer-arith - good to have
1338     # -Wdeclaration-after-statement - MSVC doesn't like these
1339     # -Werror=return-type - catches missing returns, zero false positives
1340     # -Wtype-limits - catches overflow bugs, few false positives
1341     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1342     # -Wsign-compare - catches comparison of signed and unsigned types
1343     #
1344     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
1345     MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
1346     MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
1347     MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
1348     MOZ_C_SUPPORTS_WARNING(-W, sign-compare, ac_c_has_sign_compare)
1350     # Turn off the following warnings that -Wall turns on:
1351     # -Wno-unused - lots of violations in third-party code
1352     #
1353     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
1355     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
1356        # Don't use -Wcast-align with ICC or clang
1357        case "$CPU_ARCH" in
1358            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1359            hppa | ia64 | sparc | arm)
1360            ;;
1361            *)
1362         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1363            ;;
1364        esac
1365     fi
1367     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1368     _USE_CPP_INCLUDE_FLAG=1
1369     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
1371 elif test "$SOLARIS_SUNPRO_CC"; then
1372     DSO_CFLAGS=''
1373     if test "$CPU_ARCH" = "sparc"; then
1374         # for Sun Studio on Solaris/SPARC
1375         DSO_PIC_CFLAGS='-xcode=pic32'
1376     else
1377         DSO_PIC_CFLAGS='-KPIC'
1378     fi
1379     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1380 else
1381     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
1382     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
1384     DSO_LDOPTS='-shared'
1385     if test "$GNU_LD"; then
1386         # Don't allow undefined symbols in libraries
1387         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1388     fi
1390     DSO_CFLAGS=''
1391     DSO_PIC_CFLAGS='-KPIC'
1392     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1395 if test "$GNU_CXX"; then
1396     # FIXME: Let us build with strict aliasing. bug 414641.
1397     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
1399     # Turn on GNU-specific warnings:
1400     # -Wall - turn on a lot of warnings
1401     # -Wpointer-arith - good to have
1402     # -Woverloaded-virtual - ???
1403     # -Werror=return-type - catches missing returns, zero false positives
1404     # -Wtype-limits - catches overflow bugs, few false positives
1405     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1406     # -Wsign-compare - catches comparison of signed and unsigned types
1407     #
1408     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
1409     MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
1410     MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
1411     MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
1412     MOZ_CXX_SUPPORTS_WARNING(-W, sign-compare, ac_cxx_has_sign_compare)
1414     # Turn off the following warnings that -Wall turns on:
1415     # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
1416     #
1417     MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
1419     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
1420        # Don't use -Wcast-align with ICC or clang
1421        case "$CPU_ARCH" in
1422            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1423            hppa | ia64 | sparc | arm)
1424            ;;
1425            *)
1426         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1427            ;;
1428        esac
1429     fi
1431     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1432     _USE_CPP_INCLUDE_FLAG=1
1434     # Recent clang and gcc support C++11 deleted functions without warnings if
1435     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
1436     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
1437     # unused.  But clang's warning can be disabled, so when compiling with clang
1438     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
1439     # deleted function syntax.
1440     if test "$CLANG_CXX"; then
1441         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
1442         MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
1443     fi
1445 else
1446     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
1449 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1450 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1451 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1452 dnl normal behavior.
1453 dnl ========================================================
1454 MKSHLIB_FORCE_ALL=
1455 MKSHLIB_UNFORCE_ALL=
1457 if test "$COMPILE_ENVIRONMENT"; then
1458 if test "$GNU_CC"; then
1459   AC_MSG_CHECKING(whether ld has archive extraction flags)
1460   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1461    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1462     ac_cv_mkshlib_force_and_unforce="no"
1463     exec 3<&0 <<LOOP_INPUT
1464         force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1465         force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1466         force="-Wl,-all";              unforce="-Wl,-none"
1467 LOOP_INPUT
1468     while read line
1469     do
1470       eval $line
1471       LDFLAGS=$force
1472       LIBS=$unforce
1473       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1474     done
1475     exec 0<&3 3<&-
1476     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1477    ])
1478   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1479     AC_MSG_RESULT(no)
1480   else
1481     AC_MSG_RESULT(yes)
1482     eval $ac_cv_mkshlib_force_and_unforce
1483     MKSHLIB_FORCE_ALL=$force
1484     MKSHLIB_UNFORCE_ALL=$unforce
1485   fi
1486 fi # GNU_CC
1487 fi # COMPILE_ENVIRONMENT
1489 dnl ========================================================
1490 dnl Checking for 64-bit OS
1491 dnl ========================================================
1492 if test "$COMPILE_ENVIRONMENT"; then
1493 AC_LANG_SAVE
1494 AC_LANG_C
1495 AC_MSG_CHECKING(for 64-bit OS)
1496 AC_TRY_COMPILE([$configure_static_assert_macros],
1497                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1498                result="yes", result="no")
1499 AC_MSG_RESULT("$result")
1500 if test "$result" = "yes"; then
1501     AC_DEFINE(HAVE_64BIT_OS)
1502     HAVE_64BIT_OS=1
1504 AC_SUBST(HAVE_64BIT_OS)
1505 AC_LANG_RESTORE
1506 fi # COMPILE_ENVIRONMENT
1508 dnl ========================================================
1509 dnl Enable high-memory support on OS/2 by default.
1510 dnl ========================================================
1511 MOZ_OS2_HIGH_MEMORY=1
1512 MOZ_ARG_DISABLE_BOOL(os2-high-mem,
1513 [  --disable-os2-high-mem  Disable high-memory support on OS/2],
1514     MOZ_OS2_HIGH_MEMORY=,
1515     MOZ_OS2_HIGH_MEMORY=1 )
1516 AC_SUBST(MOZ_OS2_HIGH_MEMORY)
1518 dnl ========================================================
1519 dnl = Use profiling compile flags
1520 dnl ========================================================
1521 MOZ_ARG_ENABLE_BOOL(profiling,
1522 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1523     MOZ_PROFILING=1,
1524     MOZ_PROFILING= )
1526 # For profiling builds keep the symbol information
1527 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
1528     case "$OS_TARGET" in
1529     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
1530         STRIP_FLAGS="--strip-debug"
1531         ;;
1532     esac
1535 dnl ========================================================
1536 dnl = Use incremental GC
1537 dnl ========================================================
1538 JSGC_INCREMENTAL=1
1539 MOZ_ARG_DISABLE_BOOL(gcincremental,
1540 [  --disable-gcincremental Disable incremental GC],
1541     JSGC_INCREMENTAL= )
1542 if test -n "$JSGC_INCREMENTAL"; then
1543     AC_DEFINE(JSGC_INCREMENTAL)
1546 dnl ========================================================
1547 dnl = Use generational GC
1548 dnl ========================================================
1549 MOZ_ARG_ENABLE_BOOL(gcgenerational,
1550 [  --enable-gcgenerational Enable generational GC],
1551     JSGC_GENERATIONAL=1,
1552     JSGC_GENERATIONAL= )
1553 if test -n "$JSGC_GENERATIONAL"; then
1554     AC_DEFINE(JSGC_GENERATIONAL)
1557 dnl ========================================================
1558 dnl = Perform moving GC stack rooting analysis
1559 dnl ========================================================
1560 MOZ_ARG_ENABLE_BOOL(root-analysis,
1561 [  --enable-root-analysis  Enable moving GC stack root analysis],
1562     JSGC_ROOT_ANALYSIS=1,
1563     JSGC_ROOT_ANALYSIS= )
1564 if test -n "$JSGC_ROOT_ANALYSIS"; then
1565     AC_DEFINE(JSGC_ROOT_ANALYSIS)
1568 dnl ========================================================
1569 dnl = Use exact stack rooting for GC
1570 dnl ========================================================
1571 MOZ_ARG_ENABLE_BOOL(exact-rooting,
1572 [  --enable-exact-rooting  Enable use of exact stack roots for GC],
1573     JSGC_USE_EXACT_ROOTING=1,
1574     JSGC_USE_EXACT_ROOTING= )
1575 if test -n "$JSGC_USE_EXACT_ROOTING"; then
1576     AC_DEFINE(JSGC_USE_EXACT_ROOTING)
1579 dnl ========================================================
1580 dnl = Use Valgrind
1581 dnl ========================================================
1582 MOZ_ARG_ENABLE_BOOL(valgrind,
1583 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
1584     MOZ_VALGRIND=1,
1585     MOZ_VALGRIND= )
1586 if test -n "$MOZ_VALGRIND"; then
1587     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1588         AC_MSG_ERROR(
1589             [--enable-valgrind specified but Valgrind is not installed]))
1590     AC_DEFINE(MOZ_VALGRIND)
1592 AC_SUBST(MOZ_VALGRIND)
1594 dnl ========================================================
1595 dnl jprof
1596 dnl ========================================================
1597 MOZ_ARG_ENABLE_BOOL(jprof,
1598 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
1599     MOZ_JPROF=1,
1600     MOZ_JPROF= )
1601 if test -n "$MOZ_JPROF"; then
1602     MOZ_PROFILING=1
1603     AC_DEFINE(MOZ_JPROF)
1606 dnl ========================================================
1607 dnl SPS Profiler
1608 dnl ========================================================
1609 MOZ_ENABLE_PROFILER_SPS=1
1611 case "${OS_TARGET}" in
1612 Android)
1613     case "${CPU_ARCH}" in
1614     x86 | arm) ;;
1615     *)
1616         MOZ_ENABLE_PROFILER_SPS=
1617     esac
1618     ;;
1619 Linux)
1620     case "${CPU_ARCH}" in
1621     x86 | x86_64) ;;
1622     *)
1623         MOZ_ENABLE_PROFILER_SPS=
1624     esac
1625     ;;
1626 WINNT|Darwin) ;;
1628     MOZ_ENABLE_PROFILER_SPS=
1629     ;;
1630 esac
1632 if test -n "$MOZ_ENABLE_PROFILER_SPS"; then
1633     AC_DEFINE(MOZ_ENABLE_PROFILER_SPS)
1636 dnl ========================================================
1637 dnl shark
1638 dnl ========================================================
1639 MOZ_ARG_ENABLE_BOOL(shark,
1640 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
1641     MOZ_SHARK=1,
1642     MOZ_SHARK= )
1643 if test -n "$MOZ_SHARK"; then
1644     MOZ_PROFILING=1
1645     AC_DEFINE(MOZ_SHARK)
1648 dnl ========================================================
1649 dnl instruments
1650 dnl ========================================================
1651 MOZ_ARG_ENABLE_BOOL(instruments,
1652 [  --enable-instruments    Enable instruments remote profiling. Implies --enable-profiling.],
1653     MOZ_INSTRUMENTS=1,
1654     MOZ_INSTRUMENTS= )
1655 if test -n "$MOZ_INSTRUMENTS"; then
1656     MOZ_PROFILING=1
1657     AC_DEFINE(MOZ_INSTRUMENTS)
1660 dnl ========================================================
1661 dnl callgrind
1662 dnl ========================================================
1663 MOZ_ARG_ENABLE_BOOL(callgrind,
1664 [  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.],
1665     MOZ_CALLGRIND=1,
1666     MOZ_CALLGRIND= )
1667 if test -n "$MOZ_CALLGRIND"; then
1668     MOZ_PROFILING=1
1669     AC_DEFINE(MOZ_CALLGRIND)
1672 dnl ========================================================
1673 dnl vtune
1674 dnl ========================================================
1675 MOZ_ARG_ENABLE_BOOL(vtune,
1676 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
1677     MOZ_VTUNE=1,
1678     MOZ_VTUNE= )
1679 if test -n "$MOZ_VTUNE"; then
1680     MOZ_PROFILING=1
1681     AC_DEFINE(MOZ_VTUNE)
1684 dnl ========================================================
1685 dnl Profiling
1686 dnl ========================================================
1687 if test -n "$MOZ_PROFILING"; then
1688     AC_DEFINE(MOZ_PROFILING)
1691 dnl ========================================================
1692 dnl System overrides of the defaults for host
1693 dnl ========================================================
1694 case "$host" in
1695 *mingw*)
1696     if test -n "$_WIN32_MSVC"; then
1697         HOST_AR=lib
1698         HOST_AR_FLAGS='-NOLOGO -OUT:$@'
1699         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
1700         HOST_RANLIB='echo ranlib'
1701     else
1702         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
1703     fi
1704     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
1705     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1706     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1707     HOST_BIN_SUFFIX=.exe
1708     case "$host" in
1709     *mingw*)
1710         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1711         ;;
1712     esac
1714     case "${host_cpu}" in
1715     i*86)
1716         if test -n "$_WIN32_MSVC"; then
1717             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
1718         fi
1719         ;;
1720     x86_64)
1721         if test -n "$_WIN32_MSVC"; then
1722             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
1723         fi
1724         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1725         ;;
1726     esac
1727     ;;
1729 *-darwin*)
1730     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1731     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1732     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1733     ;;
1735 *-linux*|*-kfreebsd*-gnu|*-gnu*)
1736     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1737     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1738     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1739     ;;
1741 *os2*)
1742     HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
1743     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
1744     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1745     HOST_BIN_SUFFIX=.exe
1746     MOZ_FIX_LINK_PATHS=
1747     ;;
1750     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1751     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1752     ;;
1753 esac
1755 dnl Check for using a custom <inttypes.h> implementation
1756 dnl ========================================================
1757 AC_MSG_CHECKING(for custom <inttypes.h> implementation)
1758 if test "$MOZ_CUSTOM_INTTYPES_H"; then
1759   AC_DEFINE_UNQUOTED(MOZ_CUSTOM_INTTYPES_H, "$MOZ_CUSTOM_INTTYPES_H")
1760   AC_MSG_RESULT(using $MOZ_CUSTOM_INTTYPES_H)
1761 else
1762   AC_MSG_RESULT(none specified)
1765 dnl Get mozilla version from central milestone file
1766 MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
1767 MOZILLA_UAVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -uaversion`
1768 MOZILLA_SYMBOLVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -symbolversion`
1770 dnl Get version of various core apps from the version files.
1771 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
1773 if test -z "$FIREFOX_VERSION"; then
1774     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
1777 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
1778 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
1779 AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
1780 AC_SUBST(MOZILLA_SYMBOLVERSION)
1782 MOZ_DOING_LTO(lto_is_enabled)
1784 dnl ========================================================
1785 dnl System overrides of the defaults for target
1786 dnl ========================================================
1788 case "$target" in
1789 *-aix*)
1790     AC_DEFINE(AIX)
1791     if test ! "$GNU_CC"; then
1792         if test ! "$HAVE_64BIT_OS"; then
1793             # Compiling with Visual Age C++ object model compat is the
1794             # default. To compile with object model ibm, add
1795             # AIX_OBJMODEL=ibm to .mozconfig.
1796             if test "$AIX_OBJMODEL" = "ibm"; then
1797                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
1798             else
1799                 AIX_OBJMODEL=compat
1800             fi
1801         else
1802             AIX_OBJMODEL=compat
1803         fi
1804         AC_SUBST(AIX_OBJMODEL)
1805         DSO_LDOPTS='-qmkshrobj=1'
1806         DSO_CFLAGS='-qflag=w:w'
1807         DSO_PIC_CFLAGS=
1808         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
1809         MOZ_FIX_LINK_PATHS=
1810         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1811         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1812         if test "$COMPILE_ENVIRONMENT"; then
1813             AC_LANG_SAVE
1814             AC_LANG_CPLUSPLUS
1815             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
1816             AC_TRY_COMPILE([],
1817                 [#if (__IBMCPP__ < 900)
1818                  #error "Bad compiler"
1819                  #endif],
1820                 _BAD_COMPILER=,_BAD_COMPILER=1)
1821             if test -n "$_BAD_COMPILER"; then
1822                 AC_MSG_RESULT([no])
1823                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
1824             else
1825                 AC_MSG_RESULT([yes])
1826             fi
1827             AC_LANG_RESTORE
1828             TARGET_COMPILER_ABI="ibmc"
1829             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
1830             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
1831         fi
1832     fi
1833     case "${target_os}" in
1834     aix4.1*)
1835         DLL_SUFFIX='_shr.a'
1836         ;;
1837     esac
1838     if test "$COMPILE_ENVIRONMENT"; then
1839         MOZ_CHECK_HEADERS(sys/inttypes.h)
1840     fi
1841     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1842     ;;
1844 *-darwin*)
1845     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1846     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1847     MOZ_OPTIMIZE_FLAGS="-O3"
1848     # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
1849     if test "$HAVE_64BIT_OS"; then
1850         MOZ_MEMORY=1
1851     fi
1852     DLL_SUFFIX=".dylib"
1853     DSO_LDOPTS=''
1854     STRIP_FLAGS="$STRIP_FLAGS -x -S"
1855     # Check whether we're targeting OS X or iOS
1856     AC_CACHE_CHECK(for iOS target,
1857                    ac_cv_ios_target,
1858                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
1859 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
1860 #error not iOS
1861 #endif],
1862                                    [],
1863                                    ac_cv_ios_target="yes",
1864                                    ac_cv_ios_target="no")])
1865     if test "$ac_cv_ios_target" = "yes"; then
1866         AC_DEFINE(XP_IOS)
1867         AC_DEFINE(XP_DARWIN)
1868         _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
1869     else
1870         AC_DEFINE(XP_MACOSX)
1871         AC_DEFINE(XP_DARWIN)
1872         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
1873         # The ExceptionHandling framework is needed for Objective-C exception
1874         # logging code in nsObjCExceptions.h. Currently we only use that in debug
1875         # builds.
1876         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
1877     fi
1878     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1881     if test "x$lto_is_enabled" = "xyes"; then
1882         echo "Skipping -dead_strip because lto is enabled."
1883     dnl DTrace and -dead_strip don't interact well. See bug 403132.
1884     dnl ===================================================================
1885     elif test "x$enable_dtrace" = "xyes"; then
1886         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
1887     else
1888         dnl check for the presence of the -dead_strip linker flag
1889         AC_MSG_CHECKING([for -dead_strip option to ld])
1890         _SAVE_LDFLAGS=$LDFLAGS
1891         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
1892         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
1893         if test -n "$_HAVE_DEAD_STRIP" ; then
1894             AC_MSG_RESULT([yes])
1895             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
1896         else
1897             AC_MSG_RESULT([no])
1898         fi
1900         LDFLAGS=$_SAVE_LDFLAGS
1901     fi
1903     dnl With newer linkers we need to pass -allow_heap_execute because of
1904     dnl Microsoft Silverlight (5.1.10411.0 at least).
1905     AC_MSG_CHECKING([for -allow_heap_execute option to ld])
1906     _SAVE_LDFLAGS=$LDFLAGS
1907     LDFLAGS="$LDFLAGS -Wl,-allow_heap_execute"
1908     AC_TRY_LINK(,[return 0;],_HAVE_ALLOW_HEAP_EXECUTE=1,
1909                 _HAVE_ALLOW_HEAP_EXECUTE=)
1910     if test -n "$_HAVE_ALLOW_HEAP_EXECUTE" ; then
1911         AC_MSG_RESULT([yes])
1912         MOZ_ALLOW_HEAP_EXECUTE_FLAGS="-Wl,-allow_heap_execute"
1913     else
1914         AC_MSG_RESULT([no])
1915     fi
1916     LDFLAGS=$_SAVE_LDFLAGS
1918     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
1919     ;;
1921 ia64*-hpux*)
1922     DLL_SUFFIX=".so"
1923     if test ! "$GNU_CC"; then
1924        DSO_LDOPTS='-b'
1925        DSO_CFLAGS=""
1926        DSO_PIC_CFLAGS=
1927        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
1928        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
1929        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
1930     else
1931        DSO_LDOPTS='-b -E'
1932        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1933        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1934     fi
1935     MOZ_FIX_LINK_PATHS=
1936     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1937     AC_DEFINE(_LARGEFILE64_SOURCE)
1938     ;;
1940 *-hpux*)
1941     DLL_SUFFIX=".sl"
1942     if test ! "$GNU_CC"; then
1943         DSO_LDOPTS='-b -Wl,+s'
1944         DSO_CFLAGS=""
1945         DSO_PIC_CFLAGS="+Z"
1946         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
1947         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
1948         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
1949     else
1950         DSO_LDOPTS='-b -E +s'
1951         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
1952         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
1953     fi
1954     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
1955     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1956     ;;
1958 *-android*|*-linuxandroid*)
1959     AC_DEFINE(NO_PW_GECOS)
1960     no_x=yes
1961     if test -n "$gonkdir"; then
1962         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
1963         _PLATFORM_HAVE_RIL=1
1964         MOZ_B2G_FM=1
1965         MOZ_SYNTH_PICO=1
1966     else
1967         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
1968         MOZ_LINKER=1
1969     fi
1970     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1972     MOZ_GFX_OPTIMIZE_MOBILE=1
1973     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
1974     ;;
1976 *-*linux*)
1977     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
1978     # Similarly for GNU_CXX and INTEL_CXX.
1979     if test "$INTEL_CC" -o "$INTEL_CXX"; then
1980         # -Os has been broken on Intel's C/C++ compilers for quite a
1981         # while; Intel recommends against using it.
1982         MOZ_OPTIMIZE_FLAGS="-O2"
1983     elif test "$GNU_CC" -o "$GNU_CXX"; then
1984         case $GCC_VERSION in
1985         4.5.*)
1986             # -Os is broken on gcc 4.5.x we need to tweak it to get good results.
1987             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
1988         esac
1989         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
1990         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
1991     fi
1993     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1995     MOZ_MEMORY=1
1997     case "${target_cpu}" in
1998     alpha*)
1999         CFLAGS="$CFLAGS -mieee"
2000         CXXFLAGS="$CXXFLAGS -mieee"
2001     ;;
2002     esac
2004     if test -z "$MC"; then
2005         MC=mc.exe
2006     fi
2007     ;;
2008 *-mingw*)
2009     DSO_CFLAGS=
2010     DSO_PIC_CFLAGS=
2011     DLL_SUFFIX=.dll
2012     RC=rc.exe
2013     MC=mc.exe
2014     # certain versions of cygwin's makedepend barf on the
2015     # #include <string> vs -I./dist/include/string issue so don't use it
2016     XPCOM_FROZEN_LDOPTS='$(call EXPAND_LIBNAME_PATH,xul mozalloc,$(LIBXUL_DIST)/lib)'
2017     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
2018         CC="$CC -mwindows"
2019         CXX="$CXX -mwindows"
2020         CPP="$CPP -mwindows"
2021         CFLAGS="$CFLAGS -mms-bitfields"
2022         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2023         DSO_LDOPTS='-shared'
2024         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2025         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2026         RC='$(WINDRES)'
2027         # Use static libgcc and libstdc++
2028         LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
2029         NSPR_LDFLAGS="$NSPR_LDFLAGS -static-libgcc"
2030         # Use temp file for windres (bug 213281)
2031         RCFLAGS='-O coff --use-temp-file'
2032         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2033         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32 -lnetapi32"
2034         MOZ_FIX_LINK_PATHS=
2035         DLL_PREFIX=
2036         IMPORT_LIB_SUFFIX=dll.a
2038         # We use mix of both POSIX and Win32 printf format across the tree, so format
2039         # warnings are useless on mingw.
2040         MOZ_C_SUPPORTS_WARNING(-Wno-, format, ac_c_has_wno_format)
2041         MOZ_CXX_SUPPORTS_WARNING(-Wno-, format, ac_cxx_has_wno_format)
2042     else
2043         TARGET_COMPILER_ABI=msvc
2044         HOST_CC='$(CC)'
2045         HOST_CXX='$(CXX)'
2046         HOST_LD='$(LD)'
2047         if test "$AS_BIN"; then
2048             AS="$(basename "$AS_BIN")"
2049         fi
2050         AR='lib'
2051         AR_FLAGS='-NOLOGO -OUT:$@'
2052         AR_EXTRACT=
2053         RANLIB='echo not_ranlib'
2054         STRIP='echo not_strip'
2055         PKG_SKIP_STRIP=1
2056         XARGS=xargs
2057         ZIP=zip
2058         UNZIP=unzip
2059         DOXYGEN=:
2060         ASM_SUFFIX=asm
2061         OBJ_SUFFIX=obj
2062         LIB_SUFFIX=lib
2063         DLL_PREFIX=
2064         LIB_PREFIX=
2065         IMPORT_LIB_SUFFIX=lib
2066         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2067         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2068         MKSHLIB_FORCE_ALL=
2069         MKSHLIB_UNFORCE_ALL=
2070         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2071         _USE_CPP_INCLUDE_FLAG=1
2072         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2073         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2074         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2075         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2076         if test "$_CC_SUITE" -ge "12"; then
2077             dnl VS2013+ requires -FS when parallel building by make -jN.
2078             dnl If nothing, compiler sometimes causes C1041 error.
2079             dnl
2080             dnl Visual Studio 2013 supports -Gw flags
2081             dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
2082             CFLAGS="$CFLAGS -FS -Gw"
2083             CXXFLAGS="$CXXFLAGS -FS -Gw"
2084         fi
2085         # khuey says we can safely ignore MSVC warning C4251
2086         # MSVC warning C4244 (implicit type conversion may lose data) warns
2087         # and requires workarounds for perfectly valid code.  Also, GCC/clang
2088         # don't warn about it by default. So for consistency/sanity, we turn
2089         # it off on MSVC, too.
2090         # MSVC warning C4345 warns of newly conformant behavior as of VS2003.
2091         # MSVC warning C4351 warns of newly conformant behavior as of VS2005.
2092         # MSVC warning C4482 warns when an enum value is refered specifing the
2093         # name of the enum itself.  This behavior is allowed in C++11, and the
2094         # warning has been removed in VS2012.
2095         # MSVC warning C4800 warns when a value is implicitly cast to bool,
2096         # because this also forces narrowing to a single byte, which can be a
2097         # perf hit.  But this matters so little in practice (and often we want
2098         # that behavior) that it's better to turn it off.
2099         # MSVC warning C4819 warns some UTF-8 characters (e.g. copyright sign)
2100         # on non-Western system locales even if it is in a comment.
2101         CFLAGS="$CFLAGS -wd4244 -wd4819"
2102         CXXFLAGS="$CXXFLAGS -wd4251 -wd4244 -wd4345 -wd4351 -wd4482 -wd4800 -wd4819"
2103         # make 'foo == bar;' error out
2104         CFLAGS="$CFLAGS -we4553"
2105         CXXFLAGS="$CXXFLAGS -we4553"
2106         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib netapi32.lib"
2107         MOZ_DEBUG_FLAGS='-Zi'
2108         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2109         WARNINGS_AS_ERRORS='-WX'
2110         MOZ_OPTIMIZE_FLAGS='-O1'
2111         MOZ_FIX_LINK_PATHS=
2112         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2113         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2114         if test -z "$DEVELOPER_OPTIONS"; then
2115             LDFLAGS="$LDFLAGS -RELEASE"
2116         fi
2117         dnl For profile-guided optimization
2118         PROFILE_GEN_CFLAGS="-GL"
2119         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2120         dnl XXX: PGO builds can fail with warnings treated as errors,
2121         dnl specifically "no profile data available" appears to be
2122         dnl treated as an error sometimes. This might be a consequence
2123         dnl of using WARNINGS_AS_ERRORS in some modules, combined
2124         dnl with the linker doing most of the work in the whole-program
2125         dnl optimization/PGO case. I think it's probably a compiler bug,
2126         dnl but we work around it here.
2127         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2128         dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2129         dnl Probably also a compiler bug, but what can you do?
2130         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2131         LDFLAGS="$LDFLAGS -DYNAMICBASE"
2132         dnl Minimum reqiurement of Gecko is VS2010 or later which supports
2133         dnl both SSSE3 and SSE4.1.
2134         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
2135         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
2136     fi
2137     AC_DEFINE(HAVE_SNPRINTF)
2138     AC_DEFINE(_WINDOWS)
2139     AC_DEFINE(WIN32)
2140     AC_DEFINE(XP_WIN)
2141     AC_DEFINE(XP_WIN32)
2142     AC_DEFINE(HW_THREADS)
2143     AC_DEFINE(STDC_HEADERS)
2144     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2145     TARGET_MD_ARCH=win32
2146     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2147     BIN_SUFFIX='.exe'
2148     MOZ_USER_DIR="Mozilla"
2150     dnl Hardcode to win95 for now - cls
2151     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2153     dnl set NO_X11 defines here as the general check is skipped on win32
2154     no_x=yes
2155     AC_DEFINE(NO_X11)
2157     case "$host" in
2158     *-mingw*)
2159         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2160         if test -n "$L10NBASEDIR"; then
2161             L10NBASEDIR=`cd $L10NBASEDIR && pwd -W`
2162         fi
2163         ;;
2164     esac
2166     case "$host" in
2167     *-mingw*)
2168         if test -z "$MOZ_TOOLS"; then
2169             AC_MSG_ERROR([MOZ_TOOLS is not set])
2170         fi
2171         MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2172         if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2173             AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2174         fi
2175         MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2176         if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2177             AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2178         fi
2179         ;;
2180     esac
2182     case "$host_os" in
2183     cygwin*|msvc*|mks*)
2184         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.])
2185         ;;
2186     esac
2188     case "$target" in
2189     i*86-*)
2190         if test "$HAVE_64BIT_OS"; then
2191             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2192         fi
2194         if test -n "$GNU_CC"; then
2195             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
2196             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
2197             LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup -Wl,--large-address-aware"
2198         else
2199             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
2200             LDFLAGS="$LDFLAGS -SAFESEH"
2201         fi
2203         AC_DEFINE(_X86_)
2204         ;;
2205     x86_64-*)
2206         if test -n "$_WIN32_MSVC"; then
2207             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
2208         fi
2209         AC_DEFINE(_AMD64_)
2210         ;;
2211     *)
2212         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2213         ;;
2214     esac
2215     ;;
2217 *-netbsd*)
2218     DSO_CFLAGS=''
2219     CFLAGS="$CFLAGS -Dunix"
2220     CXXFLAGS="$CXXFLAGS -Dunix"
2221     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2222         DLL_SUFFIX=".so"
2223         DSO_PIC_CFLAGS='-fPIC -DPIC'
2224         DSO_LDOPTS='-shared'
2225         BIN_FLAGS='-Wl,--export-dynamic'
2226     else
2227         DSO_PIC_CFLAGS='-fPIC -DPIC'
2228         DLL_SUFFIX=".so.1.0"
2229         DSO_LDOPTS='-shared'
2230     fi
2231     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2232     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2233     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2234     if test "$LIBRUNPATH"; then
2235         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2236     fi
2237     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@) -o $@'
2238     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@)) -o $@'
2239     ;;
2241 *-openbsd*)
2242     if test "$SO_VERSION"; then
2243         DLL_SUFFIX=".so.$SO_VERSION"
2244     else
2245         DLL_SUFFIX=".so.1.0"
2246     fi
2247     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
2248     DSO_CFLAGS=''
2249     DSO_PIC_CFLAGS='-fPIC'
2250     DSO_LDOPTS='-shared -fPIC'
2251     if test "$LIBRUNPATH"; then
2252         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2253     fi
2254     ;;
2256 *-os2*)
2257     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2258     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2259     AC_DEFINE(OS2)
2260     AC_DEFINE(XP_OS2)
2261     AC_DEFINE(OS2EMX_PLAIN_CHAR)
2262     AC_DEFINE(TCPV40HDRS)
2263     DLL_PREFIX=
2264     LIB_PREFIX=
2265     LIB_SUFFIX=lib
2266     BIN_SUFFIX=".exe"
2267     DLL_SUFFIX=".dll"
2268     IMPORT_LIB_SUFFIX=lib
2269     DSO_PIC_CFLAGS=
2270     AR=emxomfar
2271     AR_FLAGS='r $@'
2272     CFLAGS="$CFLAGS -Zomf"
2273     CXXFLAGS="$CXXFLAGS -Zomf"
2274     DSO_LDOPTS='-Zdll'
2275     BIN_FLAGS='-Zlinker /ST:0x100000'
2276     IMPLIB='emximp -o'
2277     FILTER='true'
2278     LDFLAGS='-Zmap'
2279     WARNINGS_AS_ERRORS='-Werror'
2280     MOZ_DEBUG_FLAGS="-g -fno-inline"
2281     MOZ_OPTIMIZE_FLAGS="-O2"
2282     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2283     LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2284     TARGET_MD_ARCH=os2
2285     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
2286     RC=rc.exe
2287     MC=mc.exe
2288     RCFLAGS='-n'
2289     MOZ_USER_DIR="Mozilla"
2290     ZIP="$ZIP -X"
2291     STRIP=lxlite
2292     STRIP_FLAGS="/yua /ydd /yxd /ynl /anp /b- /cs+ /d /i- /ml1 /mr2 /mf2 /r+ /u+ /x- /zs:0 /zx /zd"
2294     if test "$MOZTOOLS"; then
2295         MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
2296     else
2297         AC_MSG_ERROR([MOZTOOLS is not set])
2298     fi
2299     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2300         DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2301         LDFLAGS="$LDFLAGS -Zhigh-mem"
2302         MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
2303         AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2304     fi
2306     # GCC for OS/2 currently predefines these, but we don't want them
2307     _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
2308     _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
2310     AC_CACHE_CHECK(for __declspec(dllexport),
2311         ac_os2_declspec,
2312         [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
2313                         [return 0;],
2314                         ac_os2_declspec="yes",
2315                         ac_os2_declspec="no")])
2316     if test "$ac_os2_declspec" != "yes"; then
2317         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
2318     fi
2319     ;;
2321 *-solaris*)
2322     AC_DEFINE(SOLARIS)
2323     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2324     MOZ_FIX_LINK_PATHS=
2325     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2326     # libraries one level up (e.g. libnspr4.so)
2327     if test "$SOLARIS_SUNPRO_CC"; then
2328        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2329        LIBS="-lCrun -lCstd -lc $LIBS"
2330        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2331        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2332        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2333        LDFLAGS="-xildoff $LDFLAGS"
2334        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2335            _SAVE_LDFLAGS=$LDFLAGS
2336            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
2337            AC_TRY_LINK([#include <stdio.h>],
2338                        [printf("Hello World\n");],
2339                        ,
2340                        [LDFLAGS=$_SAVE_LDFLAGS])
2341        fi
2342        MOZ_OPTIMIZE_FLAGS="-xO4"
2343        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
2344        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
2345        MKSHLIB_FORCE_ALL='-z allextract'
2346        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2347        DSO_LDOPTS='-G'
2348        AR_LIST="$AR t"
2349        AR_EXTRACT="$AR x"
2350        AR_DELETE="$AR d"
2351        AR='$(CXX) -xar'
2352        AR_FLAGS='-o $@'
2353        AS='/usr/ccs/bin/as'
2354        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2355        AS_DASH_C_FLAG=''
2356        TARGET_COMPILER_ABI="sunc"
2357        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2358        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2359        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2360        AC_LANG_SAVE
2361        AC_LANG_CPLUSPLUS
2362        AC_TRY_COMPILE([],
2363            [#if (__SUNPRO_CC < 0x590)
2364            #error "Denied"
2365            #endif],
2366            _BAD_COMPILER=,_BAD_COMPILER=1)
2367        if test -n "$_BAD_COMPILER"; then
2368            _res="no"
2369            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2370        else
2371            _res="yes"
2372        fi
2373        AC_TRY_COMPILE([],
2374            [#if (__SUNPRO_CC >= 0x5100)
2375            #error "Sun C++ 5.10 or above"
2376            #endif],
2377            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2378        if test "$_ABOVE_SS12U1"; then
2379            # disable xannotate
2380            CXXFLAGS="$CXXFLAGS -xannotate=no"
2381        fi
2382        AC_MSG_RESULT([$_res])
2383        AC_LANG_RESTORE
2384     else
2385        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2386        LIBS="-lc $LIBS"
2387        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2388        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2389        ASFLAGS="$ASFLAGS -fPIC"
2390        DSO_LDOPTS='-shared'
2391        WARNINGS_AS_ERRORS='-Werror'
2392        _WARNINGS_CFLAGS=''
2393        _WARNINGS_CXXFLAGS=''
2394        if test "$OS_RELEASE" = "5.3"; then
2395            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2396        fi
2397     fi
2398     if test "$OS_RELEASE" = "5.5.1"; then
2399         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2400     fi
2401     ;;
2403 *-sunos*)
2404     DSO_LDOPTS='-Bdynamic'
2405     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2406     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2407     AC_DEFINE(SUNOS4)
2408     AC_DEFINE(SPRINTF_RETURNS_STRING)
2409     case "$(target_os)" in
2410     sunos4.1*)
2411         DLL_SUFFIX='.so.1.0'
2412         ;;
2413     esac
2414     ;;
2416 *-os2*)
2417     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2418     ;;
2420 esac
2422 case "$target" in
2423 *-*linux*)
2424     # Includes linux-android
2425     AC_DEFINE(XP_LINUX)
2426     ;;
2427 esac
2429 AC_SUBST(MOZ_LINKER)
2430 if test -n "$MOZ_LINKER"; then
2431   AC_DEFINE(MOZ_LINKER)
2434 dnl Only one oddball right now (QNX), but this gives us flexibility
2435 dnl if any other platforms need to override this in the future.
2436 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2438 dnl ========================================================
2439 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2440 dnl by now will not have any way to link most binaries (tests
2441 dnl as well as viewer, apprunner, etc.), because some symbols
2442 dnl will be left out of the "composite" .so's by ld as unneeded.
2443 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2444 dnl they can link in the static libs that provide the missing
2445 dnl symbols.
2446 dnl ========================================================
2447 NO_LD_ARCHIVE_FLAGS=
2448 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2449     NO_LD_ARCHIVE_FLAGS=1
2451 case "$target" in
2452 *-os2*)
2453     NO_LD_ARCHIVE_FLAGS=
2454     ;;
2455 *-aix4.3*|*-aix5*)
2456     NO_LD_ARCHIVE_FLAGS=
2457     ;;
2458 *-mingw*)
2459     if test -z "$GNU_CC"; then
2460         NO_LD_ARCHIVE_FLAGS=
2461     fi
2462     ;;
2463 esac
2464 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2466 dnl ========================================================
2467 dnl = Flags to strip unused symbols from .so components and
2468 dnl = to export jemalloc symbols when linking a program
2469 dnl ========================================================
2470 case "$target" in
2471     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2472         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2473         ;;
2474     *-solaris*)
2475         if test -z "$GNU_CC"; then
2476          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2477         else
2478          if test -z "$GCC_USE_GNU_LD"; then
2479           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2480          else
2481           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2482          fi
2483         fi
2484         ;;
2485     *-darwin*)
2486         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2487         ;;
2488     *-mingw*)
2489         if test -n "$GNU_CC"; then
2490            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2491         fi
2492         ;;
2493 esac
2495 if test -z "$COMPILE_ENVIRONMENT"; then
2496     SKIP_COMPILER_CHECKS=1
2497     SKIP_LIBRARY_CHECKS=1
2498 else
2499     MOZ_COMPILER_OPTS
2502 if test -z "$SKIP_COMPILER_CHECKS"; then
2503 dnl Checks for typedefs, structures, and compiler characteristics.
2504 dnl ========================================================
2505 AC_HEADER_STDC
2506 AC_C_CONST
2507 AC_TYPE_MODE_T
2508 AC_TYPE_OFF_T
2509 AC_TYPE_PID_T
2510 AC_TYPE_SIZE_T
2511 AC_LANG_CPLUSPLUS
2512 AC_LANG_C
2513 AC_MSG_CHECKING(for ssize_t)
2514 AC_CACHE_VAL(ac_cv_type_ssize_t,
2515  [AC_TRY_COMPILE([#include <stdio.h>
2516                   #include <sys/types.h>],
2517                  [ssize_t foo = 0;],
2518                  [ac_cv_type_ssize_t=true],
2519                  [ac_cv_type_ssize_t=false])])
2520 if test "$ac_cv_type_ssize_t" = true ; then
2521   AC_DEFINE(HAVE_SSIZE_T)
2522   AC_MSG_RESULT(yes)
2523 else
2524   AC_MSG_RESULT(no)
2526 AC_STRUCT_ST_BLKSIZE
2527 AC_MSG_CHECKING(for siginfo_t)
2528 AC_CACHE_VAL(ac_cv_siginfo_t,
2529  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
2530                   #include <signal.h>],
2531                  [siginfo_t* info;],
2532                  [ac_cv_siginfo_t=true],
2533                  [ac_cv_siginfo_t=false])])
2534 if test "$ac_cv_siginfo_t" = true ; then
2535   AC_DEFINE(HAVE_SIGINFO_T)
2536   AC_MSG_RESULT(yes)
2537 else
2538   AC_MSG_RESULT(no)
2541 AC_LANG_CPLUSPLUS
2543 MOZ_CXX11
2545 AC_LANG_C
2547 dnl Check for .hidden assembler directive and visibility attribute.
2548 dnl Borrowed from glibc configure.in
2549 dnl ===============================================================
2550 if test "$GNU_CC"; then
2551   AC_CACHE_CHECK(for visibility(hidden) attribute,
2552                  ac_cv_visibility_hidden,
2553                  [cat > conftest.c <<EOF
2554                   int foo __attribute__ ((visibility ("hidden"))) = 1;
2556                   ac_cv_visibility_hidden=no
2557                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2558                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2559                       ac_cv_visibility_hidden=yes
2560                     fi
2561                   fi
2562                   rm -f conftest.[cs]
2563                  ])
2564   if test "$ac_cv_visibility_hidden" = "yes"; then
2565     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
2567     AC_CACHE_CHECK(for visibility(default) attribute,
2568                    ac_cv_visibility_default,
2569                    [cat > conftest.c <<EOF
2570                     int foo __attribute__ ((visibility ("default"))) = 1;
2572                     ac_cv_visibility_default=no
2573                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2574                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2575                         ac_cv_visibility_default=yes
2576                       fi
2577                     fi
2578                     rm -f conftest.[cs]
2579                    ])
2580     if test "$ac_cv_visibility_default" = "yes"; then
2581       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
2583       AC_CACHE_CHECK(for visibility pragma support,
2584                      ac_cv_visibility_pragma,
2585                      [cat > conftest.c <<EOF
2586 #pragma GCC visibility push(hidden)
2587                       int foo_hidden = 1;
2588 #pragma GCC visibility push(default)
2589                       int foo_default = 1;
2591                       ac_cv_visibility_pragma=no
2592                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2593                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
2594                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
2595                             ac_cv_visibility_pragma=yes
2596                           fi
2597                         fi
2598                       fi
2599                       rm -f conftest.[cs]
2600                     ])
2601       if test "$ac_cv_visibility_pragma" = "yes"; then
2602         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
2603                        ac_cv_have_visibility_class_bug,
2604                        [cat > conftest.c <<EOF
2605 #pragma GCC visibility push(hidden)
2606 struct __attribute__ ((visibility ("default"))) TestStruct {
2607   static void Init();
2609 __attribute__ ((visibility ("default"))) void TestFunc() {
2610   TestStruct::Init();
2613                        ac_cv_have_visibility_class_bug=no
2614                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2615                          ac_cv_have_visibility_class_bug=yes
2616                        else
2617                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
2618                            ac_cv_have_visibility_class_bug=yes
2619                          fi
2620                        fi
2621                        rm -rf conftest.{c,S}
2622                        ])
2624         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
2625                        ac_cv_have_visibility_builtin_bug,
2626                        [cat > conftest.c <<EOF
2627 #pragma GCC visibility push(hidden)
2628 #pragma GCC visibility push(default)
2629 #include <string.h>
2630 #pragma GCC visibility pop
2632 __attribute__ ((visibility ("default"))) void Func() {
2633   char c[[100]];
2634   memset(c, 0, sizeof(c));
2637                        ac_cv_have_visibility_builtin_bug=no
2638                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2639                          ac_cv_have_visibility_builtin_bug=yes
2640                        else
2641                          if test `grep -c "@PLT" conftest.S` = 0; then
2642                            ac_cv_visibility_builtin_bug=yes
2643                          fi
2644                        fi
2645                        rm -f conftest.{c,S}
2646                        ])
2647         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
2648                 "$ac_cv_have_visibility_class_bug" = "no"; then
2649           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
2650           WRAP_SYSTEM_INCLUDES=1
2651           STL_FLAGS='-I$(DIST)/stl_wrappers'
2652           WRAP_STL_INCLUDES=1
2653         else
2654           VISIBILITY_FLAGS='-fvisibility=hidden'
2655         fi # have visibility pragma bug
2656       fi   # have visibility pragma
2657     fi     # have visibility(default) attribute
2658   fi       # have visibility(hidden) attribute
2659 fi         # GNU_CC
2661 # visibility hidden flag for Sun Studio on Solaris
2662 if test "$SOLARIS_SUNPRO_CC"; then
2663 VISIBILITY_FLAGS='-xldscope=hidden'
2664 fi         # Sun Studio on Solaris
2666 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2667 AC_SUBST(VISIBILITY_FLAGS)
2669 MOZ_GCC_PR49911
2670 MOZ_GCC_PR39608
2671 if test "$OS_TARGET" != WINNT; then
2672     # Only run this test with clang on non-Windows platforms, because clang
2673     # cannot do enough code gen for now to make this test work correctly.
2674     MOZ_LLVM_PR8927
2677 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
2678 dnl ========================================================
2679 if test "$GNU_CC"; then
2680   CFLAGS_save="${CFLAGS}"
2681   CFLAGS="${CFLAGS} -Werror"
2682   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
2683                  ac_cv_force_align_arg_pointer,
2684                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
2685                                  [],
2686                                  ac_cv_force_align_arg_pointer="yes",
2687                                  ac_cv_force_align_arg_pointer="no")])
2688   CFLAGS="${CFLAGS_save}"
2689   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
2690     HAVE_GCC_ALIGN_ARG_POINTER=1
2691   else
2692     HAVE_GCC_ALIGN_ARG_POINTER=
2693   fi
2695 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
2697 dnl Checks for header files.
2698 dnl ========================================================
2699 AC_HEADER_DIRENT
2700 case "$target_os" in
2701 freebsd*|openbsd*)
2702 # for stuff like -lXshm
2703     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
2704     ;;
2705 esac
2706 MOZ_CHECK_COMMON_HEADERS
2708 dnl These are all the places some variant of statfs can be hiding.
2709 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
2711 dnl Quota support
2712 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
2713 MOZ_CHECK_HEADERS([linux/quota.h],,,[#include <sys/socket.h>])
2715 dnl SCTP support - needs various network include headers
2716 MOZ_CHECK_HEADERS([linux/if_addr.h linux/rtnetlink.h],,,[#include <sys/socket.h>])
2718 MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
2720 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
2721 AC_CACHE_CHECK(for sockaddr_in.sin_len,
2722                    ac_cv_sockaddr_in_sin_len,
2723                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2724                                     #include <sys/types.h>
2725                                     #endif
2726                                     #include <netinet/in.h>
2727                                     struct sockaddr_in x;
2728                                     void *foo = (void*) &x.sin_len;],
2729                                    [],
2730                                    [ac_cv_sockaddr_in_sin_len=true],
2731                                    [ac_cv_sockaddr_in_sin_len=false])])
2732 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
2733   AC_DEFINE(HAVE_SIN_LEN)
2734 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
2735   AC_DEFINE(HAVE_SCONN_LEN)
2738 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
2739                ac_cv_sockaddr_in6_sin6_len,
2740                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2741                                 #include <sys/types.h>
2742                                 #endif
2743                                 #include <netinet/in.h>
2744                                 struct sockaddr_in6 x;
2745                                 void *foo = (void*) &x.sin6_len;],
2746                                [],
2747                                [ac_cv_sockaddr_in6_sin6_len=true],
2748                                [ac_cv_sockaddr_in6_sin6_len=false])])
2749 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
2750   AC_DEFINE(HAVE_SIN6_LEN)
2753 AC_CACHE_CHECK(for sockaddr.sa_len,
2754                ac_cv_sockaddr_sa_len,
2755                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2756                                 #include <sys/types.h>
2757                                 #endif
2758                                 #include <sys/socket.h>
2759                                 struct sockaddr x;
2760                                 void *foo = (void*) &x.sa_len;],
2761                                [],
2762                                [ac_cv_sockaddr_sa_len=true],
2763                                [ac_cv_sockaddr_sa_len=false])])
2764 if test "$ac_cv_sockaddr_sa_len" = true ; then
2765   AC_DEFINE(HAVE_SA_LEN)
2768 AC_ARG_ENABLE(dtrace,
2769               [  --enable-dtrace         build with dtrace support if available (default=no)],
2770               [enable_dtrace="yes"],)
2771 if test "x$enable_dtrace" = "xyes"; then
2772   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
2773   if test -n "$HAVE_DTRACE"; then
2774       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
2775   else
2776       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
2777   fi
2779 AC_SUBST(HAVE_DTRACE)
2781 case $target in
2782 *-aix4.3*|*-aix5*)
2783         ;;
2785         MOZ_CHECK_HEADERS(sys/cdefs.h)
2786         ;;
2787 esac
2789 MOZ_LINUX_PERF_EVENT
2791 dnl Checks for libraries.
2792 dnl ========================================================
2793 case $target in
2794 *-hpux11.*)
2795         ;;
2797         AC_CHECK_LIB(c_r, gethostbyname_r)
2798         ;;
2799 esac
2801 dnl We don't want to link with libdl even if it's present on OS X, since
2802 dnl it's not used and not part of the default installation. OS/2 has dlfcn
2803 dnl in libc.
2804 dnl We don't want to link against libm or libpthread on Darwin since
2805 dnl they both are just symlinks to libSystem and explicitly linking
2806 dnl against libSystem causes issues when debugging (see bug 299601).
2807 case $target in
2808 *-darwin*)
2809     ;;
2810 *-os2*)
2811     ;;
2813     AC_SEARCH_LIBS(dlopen, dl,
2814         MOZ_CHECK_HEADER(dlfcn.h,
2815         AC_DEFINE(HAVE_DLOPEN)))
2816     ;;
2817 esac
2819 _SAVE_CFLAGS="$CFLAGS"
2820 CFLAGS="$CFLAGS -D_GNU_SOURCE"
2821 AC_CHECK_FUNCS(dladdr memmem)
2822 CFLAGS="$_SAVE_CFLAGS"
2824 if test ! "$GNU_CXX"; then
2826     case $target in
2827     *-aix*)
2828         AC_CHECK_LIB(C_r, demangle)
2829         ;;
2830      *)
2831         AC_CHECK_LIB(C, demangle)
2832         ;;
2833      esac
2836 dnl OS/2 has socket in libc.
2837 case $target in
2838 *-os2*)
2839     ;;
2841     AC_CHECK_LIB(socket, socket)
2842 esac
2844 XLDFLAGS="$X_LIBS"
2845 XLIBS="$X_EXTRA_LIBS"
2847 dnl ========================================================
2848 dnl Checks for X libraries.
2849 dnl Ordering is important.
2850 dnl Xt is dependent upon SM as of X11R6
2851 dnl ========================================================
2852 if test "$no_x" = "yes"; then
2853     AC_DEFINE(NO_X11)
2854 else
2855     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
2856         XLIBS="-lX11 $XLIBS"
2857         _SAVE_LDFLAGS="$LDFLAGS"
2858         LDFLAGS="$XLDFLAGS $LDFLAGS"
2859         AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
2860                 [MISSING_X="$MISSING_X -lX11"], $XLIBS)
2861         AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
2862                 [MISSING_X="$MISSING_X -lXext"], $XLIBS)
2864         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
2865         unset ac_cv_lib_Xt_XtFree
2866             AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
2867             AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
2868         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
2869                     [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
2870         ])
2872     # AIX needs the motif library linked before libXt to prevent
2873     # crashes in plugins linked against Motif - Bug #98892
2874     case "${target_os}" in
2875     aix*)
2876         XT_LIBS="-lXm $XT_LIBS"
2877         ;;
2878     esac
2880     dnl ========================================================
2881     dnl = Check for XShm
2882     dnl ========================================================
2883     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
2884         $XLIBS $XEXT_LIBS)
2886     dnl ========================================================
2887     dnl = Check for Xss
2888     dnl ========================================================
2889     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
2890         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
2891             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
2892              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
2894         LDFLAGS="$_SAVE_LDFLAGS"
2895 fi # $no_x
2897 AC_SUBST(XCFLAGS)
2898 AC_SUBST(XLDFLAGS)
2899 AC_SUBST(XLIBS)
2900 AC_SUBST(XEXT_LIBS)
2901 AC_SUBST(XT_LIBS)
2902 AC_SUBST(XSS_LIBS)
2904 dnl ========================================================
2905 dnl = pthread support
2906 dnl = Start by checking whether the system support pthreads
2907 dnl ========================================================
2908 case "$target_os" in
2909 darwin*)
2910     MOZ_USE_PTHREADS=1
2911     ;;
2913     MOZ_CHECK_PTHREADS(pthreads,
2914         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2915         MOZ_CHECK_PTHREADS(pthread,
2916             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2917             MOZ_CHECK_PTHREADS(c_r,
2918                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2919                 MOZ_CHECK_PTHREADS(c,
2920                     MOZ_USE_PTHREADS=1
2921                 )
2922             )
2923         )
2924     )
2925     ;;
2926 esac
2928 dnl ========================================================
2929 dnl Check the command line for --with-pthreads
2930 dnl ========================================================
2931 MOZ_ARG_WITH_BOOL(pthreads,
2932 [  --with-pthreads         Force use of system pthread library with NSPR ],
2933 [ if test "$MOZ_USE_PTHREADS"x = x; then
2934     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2935 fi],
2936     MOZ_USE_PTHREADS=
2937     _PTHREAD_LDFLAGS=
2940 dnl ========================================================
2941 dnl Do the platform specific pthread hackery
2942 dnl ========================================================
2943 if test "$MOZ_USE_PTHREADS"x != x
2944 then
2945         dnl
2946         dnl See if -pthread is supported.
2947         dnl
2948         rm -f conftest*
2949         ac_cv_have_dash_pthread=no
2950         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2951         echo 'int main() { return 0; }' | cat > conftest.c
2952         ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2953         if test $? -eq 0; then
2954                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2955                         ac_cv_have_dash_pthread=yes
2956                 case "$target_os" in
2957                 freebsd*)
2958 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2959                 ;;
2960                 *)
2961                             CFLAGS="$CFLAGS -pthread"
2962                             CXXFLAGS="$CXXFLAGS -pthread"
2963                 ;;
2964                 esac
2965                 fi
2966         fi
2967         rm -f conftest*
2968     AC_MSG_RESULT($ac_cv_have_dash_pthread)
2970         dnl
2971         dnl See if -pthreads is supported.
2972         dnl
2973     ac_cv_have_dash_pthreads=no
2974     if test "$ac_cv_have_dash_pthread" = "no"; then
2975             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
2976         echo 'int main() { return 0; }' | cat > conftest.c
2977             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
2978         if test $? -eq 0; then
2979                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2980                             ac_cv_have_dash_pthreads=yes
2981                             CFLAGS="$CFLAGS -pthreads"
2982                             CXXFLAGS="$CXXFLAGS -pthreads"
2983                     fi
2984             fi
2985             rm -f conftest*
2986         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
2987     fi
2989         case "$target" in
2990             *-*-freebsd*)
2991                         AC_DEFINE(_REENTRANT)
2992                         AC_DEFINE(_THREAD_SAFE)
2993                         dnl -pthread links in -lpthread, so don't specify it explicitly.
2994                         if test "$ac_cv_have_dash_pthread" = "yes"; then
2995                                 _PTHREAD_LDFLAGS="-pthread"
2996                         fi
2997                         ;;
2999             *-*-openbsd*|*-*-bsdi*)
3000                         AC_DEFINE(_REENTRANT)
3001                         AC_DEFINE(_THREAD_SAFE)
3002                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3003                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3004                 _PTHREAD_LDFLAGS="-pthread"
3005                         fi
3006                         ;;
3008             *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3009                         AC_DEFINE(_REENTRANT)
3010                         ;;
3012             *-aix4.3*|*-aix5*)
3013                         AC_DEFINE(_REENTRANT)
3014                         ;;
3016             *-hpux11.*)
3017                         AC_DEFINE(_REENTRANT)
3018                         ;;
3020             *-*-solaris*)
3021                         AC_DEFINE(_REENTRANT)
3022                         if test "$SOLARIS_SUNPRO_CC"; then
3023                                 CFLAGS="$CFLAGS -mt"
3024                                 CXXFLAGS="$CXXFLAGS -mt"
3025                         fi
3026                         ;;
3027         esac
3028     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3029     AC_SUBST(MOZ_USE_PTHREADS)
3033 dnl Checks for library functions.
3034 dnl ========================================================
3035 AC_PROG_GCC_TRADITIONAL
3036 AC_FUNC_MEMCMP
3037 AC_CHECK_FUNCS(random strerror lchown fchmod snprintf memmove stat64 lstat64 truncate64 setbuf isatty)
3038 AC_CHECK_FUNCS(statvfs64 statvfs statfs64 statfs)
3039 AC_CHECK_FUNCS(flockfile getpagesize)
3040 AC_CHECK_FUNCS(localtime_r strtok_r)
3042 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
3043 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
3044                ac_cv_clock_monotonic,
3045                [for libs in "" -lrt; do
3046                     _SAVE_LIBS="$LIBS"
3047                     LIBS="$LIBS $libs"
3048                     AC_TRY_LINK([#include <time.h>],
3049                                  [ struct timespec ts;
3050                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
3051                                  ac_cv_clock_monotonic=$libs
3052                                  LIBS="$_SAVE_LIBS"
3053                                  break,
3054                                  ac_cv_clock_monotonic=no)
3055                     LIBS="$_SAVE_LIBS"
3056                 done])
3057 if test "$ac_cv_clock_monotonic" != "no"; then
3058     HAVE_CLOCK_MONOTONIC=1
3059     REALTIME_LIBS=$ac_cv_clock_monotonic
3060     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3061     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3062     AC_SUBST(REALTIME_LIBS)
3065 dnl check for wcrtomb/mbrtowc
3066 dnl =======================================================================
3067 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3068 AC_LANG_SAVE
3069 AC_LANG_CPLUSPLUS
3070 AC_CACHE_CHECK(for wcrtomb,
3071     ac_cv_have_wcrtomb,
3072     [AC_TRY_LINK([#include <wchar.h>],
3073                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3074                  ac_cv_have_wcrtomb="yes",
3075                  ac_cv_have_wcrtomb="no")])
3076 if test "$ac_cv_have_wcrtomb" = "yes"; then
3077     AC_DEFINE(HAVE_WCRTOMB)
3079 AC_CACHE_CHECK(for mbrtowc,
3080     ac_cv_have_mbrtowc,
3081     [AC_TRY_LINK([#include <wchar.h>],
3082                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3083                  ac_cv_have_mbrtowc="yes",
3084                  ac_cv_have_mbrtowc="no")])
3085 if test "$ac_cv_have_mbrtowc" = "yes"; then
3086     AC_DEFINE(HAVE_MBRTOWC)
3088 AC_LANG_RESTORE
3091 AC_CACHE_CHECK(
3092     [for res_ninit()],
3093     ac_cv_func_res_ninit,
3094     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
3095         dnl no need for res_ninit() on NetBSD and OpenBSD
3096         ac_cv_func_res_ninit=no
3097      else
3098         AC_TRY_LINK([
3099             #ifdef linux
3100             #define _BSD_SOURCE 1
3101             #endif
3102             #include <sys/types.h>
3103             #include <netinet/in.h>
3104             #include <arpa/nameser.h>
3105             #include <resolv.h>
3106             ],
3107             [int foo = res_ninit(&_res);],
3108             [ac_cv_func_res_ninit=yes],
3109             [ac_cv_func_res_ninit=no])
3110      fi
3111     ])
3113 if test "$ac_cv_func_res_ninit" = "yes"; then
3114     AC_DEFINE(HAVE_RES_NINIT)
3115 dnl must add the link line we do something as foolish as this... dougt
3116 dnl else
3117 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3118 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3121 AC_LANG_CPLUSPLUS
3123 case $target_os in
3124     darwin*|mingw*|os2*)
3125         ;;
3126     *)
3128 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3129     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3130         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3131 _SAVE_LIBS=$LIBS
3132 LIBS="$LIBS $_ICONV_LIBS"
3133 AC_CACHE_CHECK(
3134     [for iconv()],
3135     ac_cv_func_iconv,
3136     [AC_TRY_LINK([
3137         #include <stdlib.h>
3138         #include <iconv.h>
3139         ],
3140         [
3141             iconv_t h = iconv_open("", "");
3142             iconv(h, NULL, NULL, NULL, NULL);
3143             iconv_close(h);
3144         ],
3145         [ac_cv_func_iconv=yes],
3146         [ac_cv_func_iconv=no]
3147         )]
3148     )
3149 if test "$ac_cv_func_iconv" = "yes"; then
3150     AC_DEFINE(HAVE_ICONV)
3151     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3152     LIBICONV="$_ICONV_LIBS"
3153     AC_CACHE_CHECK(
3154         [for iconv() with const input],
3155         ac_cv_func_const_iconv,
3156         [AC_TRY_COMPILE([
3157             #include <stdlib.h>
3158             #include <iconv.h>
3159             ],
3160             [
3161                 const char *input = "testing";
3162                 iconv_t h = iconv_open("", "");
3163                 iconv(h, &input, NULL, NULL, NULL);
3164                 iconv_close(h);
3165             ],
3166             [ac_cv_func_const_iconv=yes],
3167             [ac_cv_func_const_iconv=no]
3168             )]
3169         )
3170     if test "$ac_cv_func_const_iconv" = "yes"; then
3171         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3172     fi
3174 LIBS=$_SAVE_LIBS
3176     ;;
3177 esac
3179 AM_LANGINFO_CODESET
3181 AC_LANG_C
3183 dnl **********************
3184 dnl *** va_copy checks ***
3185 AC_CACHE_CHECK([for an implementation of va_copy()],
3186                ac_cv_va_copy,
3187     [AC_TRY_COMPILE([#include <stdarg.h>
3188                      #include <stdlib.h>
3189         void f (int i, ...) {
3190             va_list args1, args2;
3191             va_start (args1, i);
3192             va_copy (args2, args1);
3193             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3194                 exit (1);
3195             va_end (args1); va_end (args2);
3196         }],
3197         [f(0, 42); return 0],
3198         [ac_cv_va_copy=yes],
3199         [ac_cv_va_copy=no]
3200     )]
3202 AC_CACHE_CHECK([whether va_list can be copied by value],
3203                ac_cv_va_val_copy,
3204     [AC_TRY_COMPILE([#include <stdarg.h>
3205                      #include <stdlib.h>
3206         void f (int i, ...) {
3207             va_list args1, args2;
3208             va_start (args1, i);
3209             args2 = args1;
3210             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3211                 exit (1);
3212             va_end (args1); va_end (args2);
3213         }],
3214         [f(0, 42); return 0],
3215         [ac_cv_va_val_copy=yes],
3216         [ac_cv_va_val_copy=no],
3217     )]
3219 if test "x$ac_cv_va_copy" = "xyes"; then
3220     AC_DEFINE(VA_COPY, va_copy)
3221     AC_DEFINE(HAVE_VA_COPY)
3224 if test "x$ac_cv_va_val_copy" = "xno"; then
3225    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3228 dnl ===================================================================
3229 dnl ========================================================
3230 dnl Put your C++ language/feature checks below
3231 dnl ========================================================
3232 AC_LANG_CPLUSPLUS
3234 ARM_ABI_PREFIX=
3235 if test "$GNU_CC"; then
3236   if test "$CPU_ARCH" = "arm" ; then
3237     AC_CACHE_CHECK(for ARM EABI,
3238         ac_cv_gcc_arm_eabi,
3239         [AC_TRY_COMPILE([],
3240                         [
3241 #if defined(__ARM_EABI__)
3242   return 0;
3243 #else
3244 #error Not ARM EABI.
3245 #endif
3246                         ],
3247                         ac_cv_gcc_arm_eabi="yes",
3248                         ac_cv_gcc_arm_eabi="no")])
3249     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
3250         HAVE_ARM_EABI=1
3251         ARM_ABI_PREFIX=eabi-
3252     else
3253         ARM_ABI_PREFIX=oabi-
3254     fi
3255   fi
3257   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
3260 dnl Check to see if we can resolve ambiguity with |using|.
3261 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
3262                ac_cv_cpp_ambiguity_resolving_using,
3263                [AC_TRY_COMPILE(class X {
3264                                  public: int go(const X&) {return 3;}
3265                                          int jo(const X&) {return 3;}
3266                                };
3267                                class Y : public X {
3268                                  public:  int go(int) {return 2;}
3269                                           int jo(int) {return 2;}
3270                                           using X::jo;
3271                                  private: using X::go;
3272                                };,
3273                                X x; Y y; y.jo(x);,
3274                                ac_cv_cpp_ambiguity_resolving_using=yes,
3275                                ac_cv_cpp_ambiguity_resolving_using=no)])
3276 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
3277    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
3280 dnl See if a dynamic_cast to void* gives the most derived object.
3281 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
3282                ac_cv_cpp_dynamic_cast_void_ptr,
3283                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
3284                             class Y { int j; public: virtual ~Y() { } };
3285                             class Z : public X, public Y { int k; };
3287                             int main() {
3288                                  Z mdo;
3289                                  X *subx = (X*)&mdo;
3290                                  Y *suby = (Y*)&mdo;
3291                                  return !((((void*)&mdo != (void*)subx) &&
3292                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
3293                                           (((void*)&mdo != (void*)suby) &&
3294                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
3295                             }],
3296                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
3297                            ac_cv_cpp_dynamic_cast_void_ptr=no,
3298                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
3299 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
3300    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
3304 dnl note that this one is reversed - if the test fails, then
3305 dnl we require implementations of unused virtual methods. Which
3306 dnl really blows because it means we'll have useless vtable
3307 dnl bloat.
3308 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
3309                ac_cv_cpp_unused_required,
3310                [AC_TRY_LINK(class X {private: virtual void never_called();};,
3311                                X x;,
3312                                ac_cv_cpp_unused_required=no,
3313                                ac_cv_cpp_unused_required=yes)])
3314 if test "$ac_cv_cpp_unused_required" = yes ; then
3315    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
3319 dnl Some compilers have trouble comparing a constant reference to a templatized
3320 dnl class to zero, and require an explicit operator==() to be defined that takes
3321 dnl an int. This test separates the strong from the weak.
3323 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
3324                ac_cv_trouble_comparing_to_zero,
3325                [AC_TRY_COMPILE([#include <algorithm>
3326                                 template <class T> class Foo {};
3327                                 class T2;
3328                                 template <class T> int operator==(const T2*, const T&) { return 0; }
3329                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
3330                                [Foo<int> f; return (0 != f);],
3331                                ac_cv_trouble_comparing_to_zero=no,
3332                                ac_cv_trouble_comparing_to_zero=yes)])
3333 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
3334   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
3337 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
3338 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
3339 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
3340 # linking XUL.
3341 _SAVE_LDFLAGS=$LDFLAGS
3342 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
3343 AC_CACHE_CHECK(for __thread keyword for TLS variables,
3344                ac_cv_thread_keyword,
3345                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
3346                             [return tlsIsMainThread;],
3347                             ac_cv_thread_keyword=yes,
3348                             ac_cv_thread_keyword=no)])
3349 LDFLAGS=$_SAVE_LDFLAGS
3350 # The custom dynamic linker doesn't support TLS variables
3351 MOZ_TLS=
3352 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
3353   # mips builds fail with TLS variables because of a binutils bug.
3354   # See bug 528687
3355   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
3356   case "${target}" in
3357     mips*-*)
3358       :
3359       ;;
3360     *-android*|*-linuxandroid*)
3361       :
3362       ;;
3363     *-openbsd*)
3364       :
3365       ;;
3366     *)
3367       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
3368       MOZ_TLS=1
3369       ;;
3370   esac
3373 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
3374 if test -n "$MOZ_LINKER"; then
3375   if test "$CPU_ARCH" = arm; then
3376     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
3377     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
3378       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3379       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3380     fi
3381   fi
3384 dnl The custom linker doesn't support text relocations, but NDK >= r6b
3385 dnl creates some (http://code.google.com/p/android/issues/detail?id=23203)
3386 dnl We however want to avoid these text relocations, and this can be done
3387 dnl by making gcc not link crtbegin and crtend. In the broken NDKs, crtend
3388 dnl doesn't contain anything at all, beside placeholders for some sections,
3389 dnl and crtbegin only contains a finalizer function that calls
3390 dnl __cxa_finalize. The custom linker actually takes care of calling
3391 dnl __cxa_finalize when the library doesn't call it itself, which makes it
3392 dnl safe not to link crtbegin. Besides, previous versions of the NDK didn't
3393 dnl link crtbegin and crtend at all.
3394 if test -n "$MOZ_LINKER" -a "$OS_TARGET" = "Android"; then
3395   AC_CACHE_CHECK([whether the CRT objects have text relocations],
3396     ac_cv_crt_has_text_relocations,
3397     [echo 'int foo() { return 0; }' > conftest.cpp
3398      if AC_TRY_COMMAND(${CXX-g++} -o conftest${DLL_SUFFIX} $CXXFLAGS $DSO_LDOPTS $LDFLAGS conftest.cpp $LIBS 1>&5) &&
3399         test -s conftest${DLL_SUFFIX}; then
3400        if ${TOOLCHAIN_PREFIX}readelf -d conftest${DLL_SUFFIX} | grep TEXTREL > /dev/null; then
3401          ac_cv_crt_has_text_relocations=yes
3402        else
3403          ac_cv_crt_has_text_relocations=no
3404        fi
3405      else
3406        AC_ERROR([couldn't compile a simple C file])
3407      fi
3408      rm -rf conftest*])
3409   if test "$ac_cv_crt_has_text_relocations" = yes; then
3410     dnl While we want libraries to skip the CRT files, we don't want
3411     dnl executables to be treated the same way. We thus set the flag
3412     dnl in DSO_LDOPTS and not LDFLAGS. However, to pass it to nspr,
3413     dnl we need to use LDFLAGS because nspr doesn't inherit DSO_LDOPTS.
3414     dnl Using LDFLAGS in nspr is safe, since we only really build
3415     dnl libraries there.
3416     DSO_LDOPTS="$DSO_LDOPTS -nostartfiles"
3417     NSPR_LDFLAGS="$NSPR_LDFLAGS -nostartfiles"
3418   fi
3421 dnl Check for the existence of various allocation headers/functions
3423 MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h"
3424 MALLOC_H=
3426 for file in $MALLOC_HEADERS; do
3427   MOZ_CHECK_HEADER($file, [MALLOC_H=$file])
3428   if test "$MALLOC_H" != ""; then
3429     AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
3430     break
3431   fi
3432 done
3434 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
3436 AC_CHECK_FUNCS(malloc_usable_size)
3438 dnl See if compiler supports some gcc-style attributes
3440 AC_CACHE_CHECK(for __attribute__((always_inline)),
3441                ac_cv_attribute_always_inline,
3442                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
3443                                [],
3444                                ac_cv_attribute_always_inline=yes,
3445                                ac_cv_attribute_always_inline=no)])
3447 AC_CACHE_CHECK(for __attribute__((malloc)),
3448                ac_cv_attribute_malloc,
3449                [AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
3450                                [],
3451                                ac_cv_attribute_malloc=yes,
3452                                ac_cv_attribute_malloc=no)])
3454 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
3455                ac_cv_attribute_warn_unused,
3456                [AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
3457                                [],
3458                                ac_cv_attribute_warn_unused=yes,
3459                                ac_cv_attribute_warn_unused=no)])
3461 dnl End of C++ language/feature checks
3462 AC_LANG_C
3464 dnl ========================================================
3465 dnl =  Internationalization checks
3466 dnl ========================================================
3468 dnl Internationalization and Locale support is different
3469 dnl on various UNIX platforms.  Checks for specific i18n
3470 dnl features go here.
3472 dnl check for LC_MESSAGES
3473 AC_CACHE_CHECK(for LC_MESSAGES,
3474                 ac_cv_i18n_lc_messages,
3475                 [AC_TRY_COMPILE([#include <locale.h>],
3476                                 [int category = LC_MESSAGES;],
3477                                 ac_cv_i18n_lc_messages=yes,
3478                                 ac_cv_i18n_lc_messages=no)])
3479 if test "$ac_cv_i18n_lc_messages" = yes; then
3480    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
3483 AC_HAVE_FUNCS(localeconv)
3484 fi # ! SKIP_COMPILER_CHECKS
3486 TARGET_XPCOM_ABI=
3487 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
3488     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
3491 dnl Mozilla specific options
3492 dnl ========================================================
3493 dnl The macros used for command line options
3494 dnl are defined in build/autoconf/altoptions.m4.
3496 dnl If the compiler supports these attributes, define them as
3497 dnl convenience macros.
3498 if test "$ac_cv_attribute_malloc" = yes ; then
3499   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
3500 else
3501   AC_DEFINE(NS_ATTR_MALLOC,)
3504 if test "$ac_cv_attribute_warn_unused" = yes ; then
3505   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
3506 else
3507   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
3510 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
3511 dnl features that Windows actually does support.
3513 if test -n "$SKIP_COMPILER_CHECKS"; then
3514    dnl Windows has malloc.h
3515    AC_DEFINE(MALLOC_H, [<malloc.h>])
3516    AC_DEFINE(HAVE_FORCEINLINE)
3517    AC_DEFINE(HAVE_LOCALECONV)
3518 fi # SKIP_COMPILER_CHECKS
3520 dnl ========================================================
3521 dnl =
3522 dnl = Check for external package dependencies
3523 dnl =
3524 dnl ========================================================
3525 MOZ_ARG_HEADER(External Packages)
3527 MOZ_ARG_WITH_STRING(libxul-sdk,
3528 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
3529   LIBXUL_SDK_DIR=$withval)
3531 if test "$LIBXUL_SDK_DIR" = "yes"; then
3532     AC_MSG_ERROR([--with-libxul-sdk must specify a path])
3533 elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
3534     LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
3536     if test ! -f "$LIBXUL_SDK/include/xpcom-config.h"; then
3537         AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
3538     fi
3541 AC_SUBST(LIBXUL_SDK)
3543 if test -n "$LIBXUL_SDK"; then
3544     LIBXUL_DIST="$LIBXUL_SDK"
3545 else
3546     LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
3548 AC_SUBST(LIBXUL_DIST)
3550 SYSTEM_LIBXUL=
3552 MOZ_ARG_WITH_BOOL(system-libxul,
3553 [  --with-system-libxul    Use system installed libxul SDK],
3554     SYSTEM_LIBXUL=1)
3556 dnl ========================================================
3557 dnl = If NSPR was not detected in the system,
3558 dnl = use the one in the source tree (mozilla/nsprpub)
3559 dnl ========================================================
3560 MOZ_ARG_WITH_BOOL(system-nspr,
3561 [  --with-system-nspr      Use system installed NSPR],
3562     _USE_SYSTEM_NSPR=1 )
3564 if test -n "$_USE_SYSTEM_NSPR"; then
3565     AM_PATH_NSPR(4.10.2, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])])
3568 if test -n "$MOZ_NATIVE_NSPR"; then
3569     _SAVE_CFLAGS=$CFLAGS
3570     CFLAGS="$CFLAGS $NSPR_CFLAGS"
3571     AC_TRY_COMPILE([#include "prtypes.h"],
3572                 [#ifndef PR_STATIC_ASSERT
3573                  #error PR_STATIC_ASSERT not defined or requires including prtypes.h
3574                  #endif],
3575                 [MOZ_NATIVE_NSPR=1],
3576                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
3577     AC_TRY_COMPILE([#include "prtypes.h"],
3578                 [#ifndef PR_UINT64
3579                  #error PR_UINT64 not defined or requires including prtypes.h
3580                  #endif],
3581                 [MOZ_NATIVE_NSPR=1],
3582                 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
3583     CFLAGS=$_SAVE_CFLAGS
3584 else
3585     if test -z "$LIBXUL_SDK"; then
3586         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
3587         if test -n "$GNU_CC"; then
3588             NSPR_LIBS="-L${LIBXUL_DIST}/lib -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
3589         else
3590             NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
3591         fi
3592     else
3593         NSPR_CFLAGS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --includedir="${LIBXUL_DIST}/include/nspr" --cflags`
3594         NSPR_LIBS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --libdir="${LIBXUL_DIST}"/lib --libs`
3595     fi
3598 dnl set GRE_MILESTONE
3599 dnl ========================================================
3600 if test -n "$LIBXUL_SDK"; then
3601     GRE_MILESTONE=`$PYTHON "$_topsrcdir"/config/printconfigsetting.py "$LIBXUL_DIST"/bin/platform.ini Build Milestone`
3602 else
3603     GRE_MILESTONE=`tail -n 1 "$_topsrcdir"/config/milestone.txt 2>/dev/null || tail -1 "$_topsrcdir"/config/milestone.txt`
3605 AC_SUBST(GRE_MILESTONE)
3607 # set RELEASE_BUILD and NIGHTLY_BUILD variables depending on the cycle we're in
3608 # The logic works like this:
3609 # - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
3610 # - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
3611 # - otherwise, we're building Release/Beta (define RELEASE_BUILD)
3612 case "$GRE_MILESTONE" in
3613   *a1*)
3614       NIGHTLY_BUILD=1
3615       AC_DEFINE(NIGHTLY_BUILD)
3616       ;;
3617   *a*)
3618       ;;
3619   *)
3620       RELEASE_BUILD=1
3621       AC_DEFINE(RELEASE_BUILD)
3622       ;;
3623 esac
3624 AC_SUBST(NIGHTLY_BUILD)
3625 AC_SUBST(RELEASE_BUILD)
3627 dnl ========================================================
3628 dnl Disable compiling sources in unified mode.
3629 dnl ========================================================
3631 if test -z "$NIGHTLY_BUILD"; then
3632     MOZ_DISABLE_UNIFIED_COMPILATION=1
3635 MOZ_ARG_DISABLE_BOOL(unified-compilation,
3636 [  --disable-unified-compilation
3637                           Disable unified compilation of some C/C++ sources],
3638     MOZ_DISABLE_UNIFIED_COMPILATION=1,
3639     MOZ_DISABLE_UNIFIED_COMPILATION=)
3640 AC_SUBST(MOZ_DISABLE_UNIFIED_COMPILATION)
3642 dnl system libevent Support
3643 dnl ========================================================
3644 MOZ_ARG_WITH_STRING(system-libevent,
3645 [  --with-system-libevent[=PFX]
3646                           Use system libevent [installed at prefix PFX]],
3647     LIBEVENT_DIR=$withval)
3649 _SAVE_CFLAGS=$CFLAGS
3650 _SAVE_LDFLAGS=$LDFLAGS
3651 _SAVE_LIBS=$LIBS
3652 if test "$LIBEVENT_DIR" = yes; then
3653     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
3654         MOZ_NATIVE_LIBEVENT=1,
3655         LIBEVENT_DIR=/usr)
3657 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
3658     MOZ_NATIVE_LIBEVENT=
3659 elif test -z "$MOZ_NATIVE_LIBEVENT"; then
3660     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
3661     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
3662     MOZ_CHECK_HEADER(event.h,
3663         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
3664              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
3665          fi],
3666         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
3667     AC_CHECK_LIB(event, event_init,
3668                  [MOZ_NATIVE_LIBEVENT=1
3669                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
3670                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
3671                  [MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
3673 CFLAGS=$_SAVE_CFLAGS
3674 LDFLAGS=$_SAVE_LDFLAGS
3675 LIBS=$_SAVE_LIBS
3677 AC_SUBST(MOZ_NATIVE_LIBEVENT)
3678 AC_SUBST(MOZ_LIBEVENT_CFLAGS)
3679 AC_SUBST(MOZ_LIBEVENT_LIBS)
3681 dnl ========================================================
3682 dnl = If NSS was not detected in the system,
3683 dnl = use the one in the source tree (mozilla/security/nss)
3684 dnl ========================================================
3686 MOZ_ARG_WITH_BOOL(system-nss,
3687 [  --with-system-nss       Use system installed NSS],
3688     _USE_SYSTEM_NSS=1 )
3690 if test -n "$_USE_SYSTEM_NSS"; then
3691     AM_PATH_NSS(3.15.4, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
3694 if test -n "$MOZ_NATIVE_NSS"; then
3695    NSS_LIBS="$NSS_LIBS -lcrmf"
3696 else
3697    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
3699    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2"; then
3700        NSS_LIBS="\
3701         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
3702         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
3703         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
3704         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
3705         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
3706    else
3707        NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
3708    fi
3711 dnl ======================
3712 dnl Detect yasm
3713 dnl ======================
3715 AC_MSG_CHECKING([for YASM assembler])
3716 AC_CHECK_PROGS(YASM, yasm, "")
3718 if test -n "$YASM"; then
3719   dnl Pull out yasm's version string
3720   YASM_VERSION=`yasm --version | $AWK '/^yasm/ { print $2 }'`
3721   _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
3722   _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
3723   _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
3724   _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
3727 if test -z "$SKIP_LIBRARY_CHECKS"; then
3728 dnl system JPEG support
3729 dnl ========================================================
3730 MOZ_ARG_WITH_STRING(system-jpeg,
3731 [  --with-system-jpeg[=PFX]
3732                           Use system libjpeg [installed at prefix PFX]],
3733     JPEG_DIR=$withval)
3735 _SAVE_CFLAGS=$CFLAGS
3736 _SAVE_LDFLAGS=$LDFLAGS
3737 _SAVE_LIBS=$LIBS
3738 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
3739     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
3740     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
3742 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
3743     MOZ_NATIVE_JPEG=
3744 else
3745     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_NATIVE_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_NATIVE_JPEG=)
3748 if test "$MOZ_NATIVE_JPEG" = 1; then
3749     AC_TRY_COMPILE([ #include <stdio.h>
3750                      #include <sys/types.h>
3751                      #include <jpeglib.h> ],
3752                    [ #if JPEG_LIB_VERSION < $MOZJPEG
3753                      #error "Insufficient JPEG library version ($MOZJPEG required)."
3754                      #endif
3755                      #ifndef JCS_EXTENSIONS
3756                      #error "libjpeg-turbo JCS_EXTENSIONS required"
3757                      #endif
3758                      ],
3759                    MOZ_NATIVE_JPEG=1,
3760                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
3762 CFLAGS=$_SAVE_CFLAGS
3763 LDFLAGS=$_SAVE_LDFLAGS
3764 LIBS=$_SAVE_LIBS
3766 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
3767     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
3768     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
3770 fi # SKIP_LIBRARY_CHECKS
3772 dnl system ZLIB support
3773 dnl ========================================================
3774 MOZ_ZLIB_CHECK([1.2.3])
3776 if test "$MOZ_NATIVE_ZLIB" != 1; then
3777     MOZ_ZLIB_CFLAGS=
3778     MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,'"$MOZ_BUILD_ROOT"'/modules/zlib/src)'
3781 if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
3782     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
3785 MOZ_PNG_ARM_NEON=
3787 if test -z "$SKIP_LIBRARY_CHECKS"; then
3788 dnl system BZIP2 Support
3789 dnl ========================================================
3790 MOZ_ARG_WITH_STRING(system-bz2,
3791 [  --with-system-bz2[=PFX]
3792                           Use system libbz2 [installed at prefix PFX]],
3793     BZ2_DIR=$withval)
3795 _SAVE_CFLAGS=$CFLAGS
3796 _SAVE_LDFLAGS=$LDFLAGS
3797 _SAVE_LIBS=$LIBS
3798 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
3799     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
3800     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
3802 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
3803     MOZ_NATIVE_BZ2=
3804 else
3805     AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_NATIVE_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
3806         [MOZ_NATIVE_BZ2= MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS=])
3808 CFLAGS=$_SAVE_CFLAGS
3809 LDFLAGS=$_SAVE_LDFLAGS
3810 LIBS=$_SAVE_LIBS
3812 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_NATIVE_BZ2" = 1; then
3813     MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
3814     MOZ_BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
3817 dnl system PNG Support
3818 dnl ========================================================
3819 MOZ_ARG_WITH_STRING(system-png,
3820 [  --with-system-png[=PFX]
3821                           Use system libpng [installed at prefix PFX]],
3822     PNG_DIR=$withval)
3824 _SAVE_CFLAGS=$CFLAGS
3825 _SAVE_LDFLAGS=$LDFLAGS
3826 _SAVE_LIBS=$LIBS
3827 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
3828     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
3829     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
3831 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
3832     MOZ_NATIVE_PNG=
3833 else
3834     AC_CHECK_LIB(png, png_get_valid, [MOZ_NATIVE_PNG=1 MOZ_PNG_LIBS="-lpng"],
3835                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
3836     AC_CHECK_LIB(png, png_get_acTL, ,
3837                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
3839 if test "$MOZ_NATIVE_PNG" = 1; then
3840     AC_TRY_COMPILE([ #include <stdio.h>
3841                      #include <sys/types.h>
3842                      #include <png.h> ],
3843                    [ #if PNG_LIBPNG_VER < $MOZPNG
3844                      #error "Insufficient libpng version ($MOZPNG required)."
3845                      #endif
3846                      #ifndef PNG_UINT_31_MAX
3847                      #error "Insufficient libpng version."
3848                      #endif ],
3849                    MOZ_NATIVE_PNG=1,
3850                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
3852 CFLAGS=$_SAVE_CFLAGS
3853 LDFLAGS=$_SAVE_LDFLAGS
3854 LIBS=$_SAVE_LIBS
3856 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_NATIVE_PNG" = 1; then
3857     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
3858     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
3861 fi # SKIP_LIBRARY_CHECKS
3863 AC_SUBST(MOZ_PNG_ARM_NEON)
3865 dnl system HunSpell Support
3866 dnl ========================================================
3867 MOZ_ARG_ENABLE_BOOL(system-hunspell,
3868 [  --enable-system-hunspell
3869                           Use system hunspell (located with pkgconfig)],
3870     MOZ_NATIVE_HUNSPELL=1 )
3872 if test -n "$MOZ_NATIVE_HUNSPELL"; then
3873     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
3876 AC_SUBST(MOZ_NATIVE_HUNSPELL)
3878 dnl ========================================================
3879 dnl system libffi Support
3880 dnl ========================================================
3881 MOZ_ARG_ENABLE_BOOL(system-ffi,
3882 [  --enable-system-ffi       Use system libffi (located with pkgconfig)],
3883     MOZ_NATIVE_FFI=1 )
3885 if test -n "$MOZ_NATIVE_FFI"; then
3886     # Vanilla libffi 3.0.9 needs a few patches from upcoming version 3.0.10
3887     # for non-GCC compilers.
3888     if test -z "$GNU_CC"; then
3889         PKG_CHECK_MODULES(MOZ_FFI, libffi > 3.0.9)
3890     else
3891         PKG_CHECK_MODULES(MOZ_FFI, libffi >= 3.0.9)
3892     fi
3893     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS"
3896 # split JS out by default to avoid VS2005 PGO crash (bug 591836).
3897 if test "$OS_ARCH" = "WINNT"; then
3898   JS_SHARED_LIBRARY=1
3901 MOZ_ARG_ENABLE_BOOL(shared-js,
3902 [  --enable-shared-js
3903                           Create a shared JavaScript library.],
3904     JS_SHARED_LIBRARY=1,
3905     JS_SHARED_LIBRARY=)
3907 dnl ========================================================
3908 dnl System ICU Support
3909 dnl ========================================================
3910 MOZ_NATIVE_ICU=
3911 MOZ_ARG_WITH_BOOL(system-icu,
3912 [  --with-system-icu
3913                           Use system ICU (located with pkgconfig)],
3914     MOZ_NATIVE_ICU=1)
3916 if test -n "$MOZ_NATIVE_ICU"; then
3917     PKG_CHECK_MODULES(MOZ_ICU, icu-i18n >= 50.1)
3918     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_ICU_LIBS"
3921 AC_SUBST(MOZ_NATIVE_ICU)
3923 dnl ========================================================
3924 dnl Java SDK support
3925 dnl ========================================================
3927 JAVA_BIN_PATH=
3928 MOZ_ARG_WITH_STRING(java-bin-path,
3929 [  --with-java-bin-path=dir
3930                           Location of Java binaries (java, javac, jar)],
3931     JAVA_BIN_PATH=$withval)
3933 dnl ========================================================
3934 dnl =
3935 dnl = Application
3936 dnl =
3937 dnl ========================================================
3939 MOZ_ARG_HEADER(Application)
3941 ENABLE_TESTS=1
3942 ENABLE_SYSTEM_EXTENSION_DIRS=1
3943 MOZ_BRANDING_DIRECTORY=
3944 MOZ_OFFICIAL_BRANDING=
3945 MOZ_FEEDS=1
3946 MOZ_WEBAPP_RUNTIME=
3947 MOZ_JSDEBUGGER=1
3948 MOZ_AUTH_EXTENSION=1
3949 MOZ_OGG=1
3950 MOZ_RAW=
3951 MOZ_VORBIS=
3952 MOZ_TREMOR=
3953 MOZ_WAVE=1
3954 MOZ_SAMPLE_TYPE_FLOAT32=
3955 MOZ_SAMPLE_TYPE_S16=
3956 MOZ_OPUS=1
3957 MOZ_WEBM=1
3958 MOZ_DIRECTSHOW=
3959 MOZ_WMF=
3960 MOZ_FMP4=
3961 MOZ_WEBRTC=1
3962 MOZ_PEERCONNECTION=
3963 MOZ_SRTP=
3964 MOZ_WEBRTC_SIGNALING=
3965 MOZ_WEBRTC_ASSERT_ALWAYS=1
3966 MOZ_SCTP=
3967 MOZ_MEDIA_PLUGINS=
3968 MOZ_MEDIA_NAVIGATOR=
3969 MOZ_OMX_PLUGIN=
3970 MOZ_VP8=
3971 MOZ_VP8_ERROR_CONCEALMENT=
3972 MOZ_VP8_ENCODER=1
3973 MOZ_WEBSPEECH=1
3974 VPX_AS=
3975 VPX_ASFLAGS=
3976 VPX_AS_DASH_C_FLAG=
3977 VPX_AS_CONVERSION=
3978 VPX_ASM_SUFFIX=
3979 VPX_X86_ASM=
3980 VPX_ARM_ASM=
3981 LIBJPEG_TURBO_AS=
3982 LIBJPEG_TURBO_ASFLAGS=
3983 LIBJPEG_TURBO_X86_ASM=
3984 LIBJPEG_TURBO_X64_ASM=
3985 LIBJPEG_TURBO_ARM_ASM=
3986 MOZ_PANGO=1
3987 MOZ_PERMISSIONS=1
3988 MOZ_PLACES=1
3989 MOZ_SOCIAL=1
3990 MOZ_PREF_EXTENSIONS=1
3991 MOZ_PROFILELOCKING=1
3992 MOZ_REFLOW_PERF=
3993 MOZ_SAFE_BROWSING=
3994 MOZ_HELP_VIEWER=
3995 MOZ_SPELLCHECK=1
3996 MOZ_ANDROID_OMTC=
3997 MOZ_TOOLKIT_SEARCH=1
3998 MOZ_UI_LOCALE=en-US
3999 MOZ_UNIVERSALCHARDET=1
4000 MOZ_URL_CLASSIFIER=
4001 MOZ_XUL=1
4002 MOZ_ZIPWRITER=1
4003 NS_PRINTING=1
4004 MOZ_PDF_PRINTING=
4005 MOZ_DISABLE_CRYPTOLEGACY=
4006 NSS_DISABLE_DBM=
4007 NECKO_COOKIES=1
4008 NECKO_PROTOCOLS_DEFAULT="about app data file ftp http res viewsource websocket wyciwyg device"
4009 if test -n "$MOZ_RTSP"; then
4010   NECKO_PROTOCOLS_DEFAULT="$NECKO_PROTOCOLS_DEFAULT rtsp"
4012 USE_ARM_KUSER=
4013 BUILD_CTYPES=1
4014 MOZ_USE_NATIVE_POPUP_WINDOWS=
4015 MOZ_ANDROID_HISTORY=
4016 MOZ_WEBSMS_BACKEND=
4017 MOZ_ANDROID_BEAM=
4018 ACCESSIBILITY=1
4019 MOZ_TIME_MANAGER=
4020 MOZ_PAY=
4021 MOZ_AUDIO_CHANNEL_MANAGER=
4022 NSS_NO_LIBPKIX=
4023 MOZ_CONTENT_SANDBOX=
4024 MOZ_CONTENT_SANDBOX_REPORTER=
4026 case "$target_os" in
4027     mingw*)
4028         NS_ENABLE_TSF=1
4029         AC_DEFINE(NS_ENABLE_TSF)
4030         ;;
4031 esac
4033 case "${target}" in
4034     *-android*|*-linuxandroid*)
4035         if test "$CPU_ARCH" = "arm" ; then
4036           USE_ARM_KUSER=1
4037         fi
4039         NSS_DISABLE_DBM=1
4040         MOZ_THEME_FASTSTRIPE=1
4041         MOZ_TREE_FREETYPE=1
4042         MOZ_MEMORY=1
4043         MOZ_RAW=1
4044         ;;
4046 esac
4048 MOZ_ARG_WITH_STRING(external-source-dir,
4049 [  --with-external-source-dir=dir
4050                           External directory containing additional build files.],
4051 [ EXTERNAL_SOURCE_DIR=$withval])
4052 AC_SUBST(EXTERNAL_SOURCE_DIR)
4054 MOZ_ARG_ENABLE_STRING(application,
4055 [  --enable-application=APP
4056                           Options include:
4057                             browser (Firefox)
4058                             xulrunner
4059                             tools/update-packaging (AUS-related packaging tools)],
4060 [ MOZ_BUILD_APP=$enableval ] )
4062 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
4063 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
4064   XULRUNNER_STUB_NAME=$withval)
4066 if test -z "$XULRUNNER_STUB_NAME"; then
4067   case "$target_os" in
4068   darwin*)
4069     XULRUNNER_STUB_NAME=xulrunner
4070     ;;
4071   *)
4072     XULRUNNER_STUB_NAME=xulrunner-stub
4073   esac
4075 AC_SUBST(XULRUNNER_STUB_NAME)
4077 AC_MSG_CHECKING([for application to build])
4078 if test -z "$MOZ_BUILD_APP"; then
4079   AC_MSG_RESULT([browser])
4080   MOZ_BUILD_APP=browser
4081 else
4082   # "mobile" no longer exists.
4083   if test "$MOZ_BUILD_APP" = "mobile" ; then
4084     AC_MSG_RESULT([none])
4085     AC_MSG_ERROR([--enable-application=mobile is no longer supported.])
4086   fi
4087   # We have a valid application only if it has a build.mk file in its top
4088   # directory.
4089   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
4090     AC_MSG_RESULT([none])
4091     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
4092   else
4093     AC_MSG_RESULT([$MOZ_BUILD_APP])
4094   fi
4097 # The app update channel is 'default' when not supplied. The value is used in
4098 # the application's confvars.sh so it must be set before confvars.sh is called.
4099 MOZ_ARG_ENABLE_STRING([update-channel],
4100 [  --enable-update-channel=CHANNEL
4101                           Select application update channel (default=default)],
4102     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
4104 if test -z "$MOZ_UPDATE_CHANNEL"; then
4105     MOZ_UPDATE_CHANNEL=default
4107 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
4108 AC_SUBST(MOZ_UPDATE_CHANNEL)
4110 # Allow to specify a Google API key file that contains the secret key to be
4111 # used for various Google API requests.
4112 MOZ_ARG_WITH_STRING(google-api-keyfile,
4113 [  --with-google-api-keyfile=file   Use the secret key contained in the given keyfile for Google API requests],
4114   MOZ_GOOGLE_API_KEY=`cat $withval`)
4115 if test -z "$MOZ_GOOGLE_API_KEY"; then
4116     MOZ_GOOGLE_API_KEY=no-google-api-key
4118 AC_SUBST(MOZ_GOOGLE_API_KEY)
4120 # Allow the application to influence configure with a confvars.sh script.
4121 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4122 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4123   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4124   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4125 else
4126   AC_MSG_RESULT([no])
4129 # Allow influencing configure with a defines.sh script.
4130 . "${srcdir}/build/defines.sh"
4132 # If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
4133 # set in defines.sh
4134 if test "$BUILDING_RELEASE"; then
4135   # Override value in defines.sh, if any
4136   EARLY_BETA_OR_EARLIER=
4137 elif test "$EARLY_BETA_OR_EARLIER"; then
4138   AC_DEFINE(EARLY_BETA_OR_EARLIER)
4140 AC_SUBST(EARLY_BETA_OR_EARLIER)
4142 # Allow the application to provide a subconfigure script
4143 if test -f "${srcdir}/${MOZ_BUILD_APP}/configure.in" ; then
4144   do_output_subdirs() {
4145     if test -n "$_subconfigure_subdirs"; then
4146       AC_MSG_ERROR([Cannot specify more than one sub-sub-configure])
4147      fi
4148     _subconfigure_subdir="$1"
4149     _subconfigure_config_args="$ac_configure_args"
4150   }
4151   tmpscript=`$PYTHON -c 'import os, tempfile; print tempfile.mktemp(prefix="subscript.").replace(os.sep, "/")'` || exit 1
4152   m4 "${srcdir}/build/autoconf/subconfigure.m4" \
4153      "${srcdir}/build/autoconf/altoptions.m4" \
4154      "${srcdir}/${MOZ_BUILD_APP}/configure.in" > $tmpscript
4155   . $tmpscript
4156   rm -f $tmpscript
4159 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
4160 MOZ_ARG_WITH_STRING(app-name,
4161 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
4162 WITH_APP_NAME=$withval,
4165 if test -n "$WITH_APP_NAME" ; then
4166     MOZ_APP_NAME="$WITH_APP_NAME"
4169 MOZ_ARG_WITH_STRING(app-basename,
4170 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
4171 WITH_APP_BASENAME=$withval,
4174 if test -n "$WITH_APP_BASENAME" ; then
4175     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
4178 # Now is a good time to test for logic errors, define mismatches, etc.
4179 case "$MOZ_BUILD_APP" in
4180 xulrunner)
4181   if test "$LIBXUL_SDK"; then
4182     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4183   fi
4184   ;;
4185 esac
4187 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4188 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4189 # MOZ_BUILD_APP.
4190 case "$MOZ_BUILD_APP" in
4191 browser)
4192   AC_DEFINE(MOZ_PHOENIX)
4193   ;;
4195 xulrunner)
4196   AC_DEFINE(MOZ_XULRUNNER)
4197   ;;
4198 b2g)
4199   AC_DEFINE(MOZ_B2G)
4200   ;;
4201 esac
4203 AC_SUBST(MOZ_BUILD_APP)
4204 AC_SUBST(MOZ_PHOENIX)
4205 AC_SUBST(MOZ_XULRUNNER)
4206 AC_SUBST(MOZ_B2G)
4208 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4210 dnl ========================================================
4211 dnl Check android sdk version depending on mobile target
4212 dnl ========================================================
4214 if test -z "$gonkdir" ; then
4215     # Minimum Android SDK API Level we require.
4216     case "$MOZ_BUILD_APP" in
4217     mobile/android)
4218         android_min_api_level=16
4219         case "$target" in
4220         *-android*|*-linuxandroid*)
4221             :
4222             ;;
4223         *)
4224             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])
4225             ;;
4226         esac
4227         ;;
4228     esac
4230     MOZ_ANDROID_SDK($android_min_api_level)
4233 dnl ========================================================
4234 dnl =
4235 dnl = Toolkit Options
4236 dnl =
4237 dnl ========================================================
4238 MOZ_ARG_HEADER(Toolkit Options)
4240     dnl ========================================================
4241     dnl = Select the default toolkit
4242     dnl ========================================================
4243         MOZ_ARG_ENABLE_STRING(default-toolkit,
4244         [  --enable-default-toolkit=TK
4245                           Select default toolkit
4246                           Platform specific defaults:
4247                             Mac OS X - cairo-cocoa
4248                             OS/2 - cairo-os2
4249                             Win32 - cairo-windows
4250                             * - cairo-gtk2
4251                             * - cairo-gtk3
4252                             * - cairo-qt],
4253     [ _DEFAULT_TOOLKIT=$enableval ],
4254     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4256     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4257         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4258         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4259         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk3" \
4260         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4261         -o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
4262         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
4263         -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
4264         -o "$_DEFAULT_TOOLKIT" = "cairo-android" \
4265         -o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
4266     then
4267         dnl nglayout only supports building with one toolkit,
4268         dnl so ignore everything after the first comma (",").
4269         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4270     else
4271         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4272     fi
4274 MOZ_ARG_WITHOUT_BOOL(x,
4275 [  --without-x              Build without X11],
4276     WITHOUT_X11=1)
4278 dnl ========================================================
4279 dnl = Enable the toolkit as needed                         =
4280 dnl ========================================================
4282 MOZ_WIDGET_GTK=
4284 case "$MOZ_WIDGET_TOOLKIT" in
4286 cairo-windows)
4287     MOZ_WIDGET_TOOLKIT=windows
4288     MOZ_WEBGL=1
4289     MOZ_PDF_PRINTING=1
4290     MOZ_INSTRUMENT_EVENT_LOOP=1
4291     if test -n "$GNU_CC"; then
4292         MOZ_FOLD_LIBS=
4293     fi
4294     ;;
4296 cairo-gtk3)
4297     MOZ_WIDGET_TOOLKIT=gtk3
4298     MOZ_ENABLE_GTK=1
4299     MOZ_ENABLE_GTK3=1
4300     MOZ_ENABLE_XREMOTE=1
4301     MOZ_WEBGL=1
4302     MOZ_GL_DEFAULT_PROVIDER=GLX
4304     AC_DEFINE(MOZ_X11)
4305     MOZ_X11=1
4306     USE_FC_FREETYPE=1
4308     TK_CFLAGS='$(MOZ_GTK3_CFLAGS)'
4309     TK_LIBS='$(MOZ_GTK3_LIBS)'
4310     MOZ_WIDGET_GTK=3
4311     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4312     MOZ_PDF_PRINTING=1
4313     MOZ_INSTRUMENT_EVENT_LOOP=1
4314     ;;
4316 cairo-gtk2|cairo-gtk2-x11)
4317     MOZ_WIDGET_TOOLKIT=gtk2
4318     MOZ_ENABLE_GTK=1
4319     MOZ_ENABLE_GTK2=1
4320     MOZ_ENABLE_XREMOTE=1
4321     MOZ_WEBGL=1
4322     MOZ_GL_DEFAULT_PROVIDER=GLX
4324     AC_DEFINE(MOZ_X11)
4325     MOZ_X11=1
4326     USE_FC_FREETYPE=1
4328     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4329     TK_LIBS='$(MOZ_GTK2_LIBS)'
4330     AC_DEFINE(MOZ_WIDGET_GTK2)
4331     MOZ_WIDGET_GTK=2
4332     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4333     MOZ_PDF_PRINTING=1
4334     MOZ_INSTRUMENT_EVENT_LOOP=1
4335     ;;
4337 cairo-qt)
4338     MOZ_WIDGET_TOOLKIT=qt
4339     MOZ_ENABLE_QT=1
4340     if test -z "$WITHOUT_X11"; then
4341       MOZ_ENABLE_XREMOTE=1
4342       MOZ_GL_DEFAULT_PROVIDER=GLX
4343       MOZ_X11=1
4344       AC_DEFINE(MOZ_X11)
4345       XT_LIBS=
4346     fi
4348     MOZ_WEBGL=1
4349     USE_FC_FREETYPE=1
4350     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4351     TK_LIBS='$(MOZ_QT_LIBS)'
4352     AC_DEFINE(MOZ_WIDGET_QT)
4353     MOZ_PDF_PRINTING=1
4354     AC_DEFINE(QT_NO_KEYWORDS)
4355     ;;
4357 cairo-os2)
4358     MOZ_WIDGET_TOOLKIT=os2
4359     USE_FC_FREETYPE=1
4360     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4361     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4362     MOZ_PDF_PRINTING=1
4363     ;;
4365 cairo-cocoa)
4366     MOZ_WIDGET_TOOLKIT=cocoa
4367     AC_DEFINE(MOZ_WIDGET_COCOA)
4368     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
4369     TK_LIBS='-framework CoreLocation -framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
4370     TK_CFLAGS="-DNO_X11"
4371     CFLAGS="$CFLAGS $TK_CFLAGS"
4372     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4373     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/bin/XUL $(call EXPAND_LIBNAME_PATH,mozalloc,$(LIBXUL_DIST)/bin)'
4374     MOZ_USER_DIR="Mozilla"
4375     MOZ_FS_LAYOUT=bundle
4376     MOZ_WEBGL=1
4377     MOZ_INSTRUMENT_EVENT_LOOP=1
4378     ;;
4380 cairo-uikit)
4381     MOZ_WIDGET_TOOLKIT=uikit
4382     AC_DEFINE(MOZ_WIDGET_UIKIT)
4383     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
4384     TK_CFLAGS="-DNO_X11"
4385     TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
4386     CFLAGS="$CFLAGS $TK_CFLAGS"
4387     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4388     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/bin/XUL $(call EXPAND_LIBNAME_PATH,mozalloc,$(LIBXUL_DIST)/bin)'
4389     MOZ_USER_DIR="Mozilla"
4390     MOZ_FS_LAYOUT=bundle
4391     ;;
4393 cairo-android)
4394     AC_DEFINE(MOZ_WIDGET_ANDROID)
4395     MOZ_WIDGET_TOOLKIT=android
4396     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4397     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4398     MOZ_WEBGL=1
4399     MOZ_PDF_PRINTING=1
4400     MOZ_INSTRUMENT_EVENT_LOOP=1
4401     ;;
4403 cairo-gonk)
4404     XPCOM_FROZEN_LDOPTS='$(call EXPAND_LIBNAME_PATH,xul mozalloc,$(LIBXUL_DIST)/lib)'
4405     AC_DEFINE(MOZ_WIDGET_GONK)
4406     AC_DEFINE(MOZ_TOUCH)
4407     MOZ_WIDGET_TOOLKIT=gonk
4408     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4409     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4410     MOZ_WEBGL=1
4411     MOZ_PDF_PRINTING=1
4412     MOZ_TOUCH=1
4413     ;;
4415 esac
4417 AC_SUBST(MOZ_PDF_PRINTING)
4418 if test "$MOZ_PDF_PRINTING"; then
4419    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
4420    AC_DEFINE(MOZ_PDF_PRINTING)
4423 if test "$MOZ_ENABLE_XREMOTE"; then
4424     AC_DEFINE(MOZ_ENABLE_XREMOTE)
4427 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
4428    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
4431 if test "$COMPILE_ENVIRONMENT"; then
4432   if test "$MOZ_ENABLE_GTK3"; then
4433     PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4434   fi
4435   if test "$MOZ_ENABLE_GTK2"; then
4436     if test "$MOZ_X11"; then
4437       GDK_PACKAGES=gdk-x11-2.0
4438     fi
4440     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4441   fi
4443 fi # COMPILE_ENVIRONMENT
4445 AC_SUBST(MOZ_FS_LAYOUT)
4447 dnl ========================================================
4448 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4449 dnl their usage and use them in spidermonkey.
4450 dnl ========================================================
4451 MOZ_ARG_WITH_BOOL(arm-kuser,
4452 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4453     USE_ARM_KUSER=1,)
4454 if test -n "$USE_ARM_KUSER"; then
4455    AC_DEFINE(USE_ARM_KUSER)
4458 dnl ========================================================
4459 dnl = startup-notification support module
4460 dnl ========================================================
4462 if test "$MOZ_ENABLE_GTK"
4463 then
4464     MOZ_ENABLE_STARTUP_NOTIFICATION=
4466     MOZ_ARG_ENABLE_BOOL(startup-notification,
4467     [  --enable-startup-notification
4468                           Enable startup-notification support (default: disabled) ],
4469         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
4470         MOZ_ENABLE_STARTUP_NOTIFICATION=)
4471     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
4472     then
4473         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
4474                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
4475         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
4476             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
4477             then
4478                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
4479             fi
4480             MOZ_ENABLE_STARTUP_NOTIFICATION=
4481         ])
4482     fi
4484     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
4485         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
4486     fi
4488     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
4490 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
4491 AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
4492 AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
4494 dnl ========================================================
4495 dnl = QT support
4496 dnl ========================================================
4497 if test "$MOZ_ENABLE_QT"
4498 then
4499     MOZ_ARG_WITH_STRING(qtdir,
4500     [  --with-qtdir=\$dir       Specify Qt directory ],
4501     [ QTDIR=$withval])
4503     if test -z "$QTDIR"; then
4504         AC_CHECK_PROGS(HOST_QMAKE, $HOST_QMAKE qmake, "")
4505     else
4506         HOST_QMAKE="$QTDIR/bin/qmake"
4507     fi
4508     QT_VERSION=`$HOST_QMAKE -v | grep 'Using Qt version' | egrep -o '[[0-9]]+\.[[0-9]]+\.[[0-9]]+'`
4510     if test -z "$QTDIR"; then
4511         case $QT_VERSION in
4512         5.*)
4513             AC_MSG_RESULT("Using qt5: $QT_VERSION")
4514             PKG_CHECK_MODULES(MOZ_QT, Qt5Gui Qt5Network Qt5Core Qt5OpenGL Qt5Widgets Qt5PrintSupport, ,
4515             [
4516               AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qtbase development packages, (On Ubuntu, you might try installing the packages qtbase5-dev libqt5opengl5-dev.)])
4517             ])
4518             QT5INCDIR=`pkg-config --variable=includedir Qt5Gui`
4519             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QT5INCDIR/QtGui/$QT_VERSION/QtGui"
4520             ;;
4521         4.*)
4522             AC_MSG_RESULT("Using qt4: $QT_VERSION")
4523             PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore QtOpenGL, ,
4524             [
4525               AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qt4 development package, (On Ubuntu, you might try installing the packages libqt4-dev libqt4-opengl-dev.)])
4526             ])
4527             ;;
4528         *)
4529             AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION])
4530             ;;
4531         esac
4533         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
4534         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
4535     else
4536         MOZ_QT_CFLAGS="-DQT_SHARED"
4537         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
4538         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
4539         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
4540         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
4541         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
4542         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative"
4544         case $QT_VERSION in
4545         5.*)
4546             AC_MSG_RESULT("Using qt5: $QT_VERSION")
4547             MOZ_QT_LIBS="-L$QTDIR/lib/ -lQt5Gui -lQt5Network -lQt5Core -lQt5Xml -lQt5OpenGL"
4548             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui/$QT_VERSION/QtGui"
4549             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtWidgets"
4550             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport"
4551             MOZ_QT_LIBS="$MOZ_QT_LIBS -lQt5Widgets -lQt5PrintSupport"
4552             ;;
4553         4.*)
4554             AC_MSG_RESULT("Using qt4: $QT_VERSION")
4555             MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
4556             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/Qt"
4557             ;;
4558         *)
4559             AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION])
4560             ;;
4561         esac
4563         HOST_MOC="$QTDIR/bin/moc"
4564         HOST_RCC="$QTDIR/bin/rcc"
4565     fi
4566     if test -z "$HOST_MOC"; then
4567         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
4568 incorrect])
4569     fi
4570     if test -z "$HOST_RCC"; then
4571         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is
4572 incorrect])
4573     fi
4575     MOC=$HOST_MOC
4576     RCC=$HOST_RCC
4578     MOZ_ENABLE_QMSYSTEM2=
4579     PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
4580                       MOZ_ENABLE_QMSYSTEM2=1,
4581                       MOZ_ENABLE_QMSYSTEM2=)
4583     if test "$MOZ_ENABLE_QMSYSTEM2"; then
4584       MOZ_ENABLE_QMSYSTEM2=1
4585       MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
4586       MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
4587       AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
4588     fi
4590     MOZ_ENABLE_QTNETWORK=
4591     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
4592                       MOZ_ENABLE_QTNETWORK=1,
4593                       MOZ_ENABLE_QTNETWORK=)
4595     if test "$MOZ_ENABLE_QTNETWORK"; then
4596       MOZ_ENABLE_QTNETWORK=1
4597       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
4598     fi
4600     MOZ_ENABLE_QTMOBILITY=
4601     PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
4602                       MOZ_ENABLE_QTMOBILITY=1,
4603                       MOZ_ENABLE_QTMOBILITY=)
4604     if test "$MOZ_ENABLE_QTMOBILITY"; then
4605        MOZ_ENABLE_QTMOBILITY=1
4606        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
4607        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
4608        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
4609        AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4610     else
4611        AC_CHECK_LIB(QtSensors, main, [
4612           MOZ_ENABLE_QTMOBILITY=1
4613           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMobility"
4614           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtSensors"
4615           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtFeedback"
4616           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtLocation"
4617           MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
4618        ])
4619     fi
4621     if test "$MOZ_ENABLE_CONTENTACTION"; then
4622       MOZ_ENABLE_CONTENTACTION=1
4623       AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
4624     fi
4626     MOZ_ENABLE_CONTENTACTION=
4627     PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
4628     if test "$MOZ_ENABLE_CONTENTACTION"; then
4629        MOZ_ENABLE_CONTENTACTION=1
4630        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_CONTENTACTION_CFLAGS"
4631        MOZ_QT_LIBS="$MOZ_QT_LIBS $_CONTENTACTION_LIBS"
4632        AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
4633        AC_SUBST(MOZ_ENABLE_CONTENTACTION)
4634     fi
4637 AC_SUBST(GTK_CONFIG)
4638 AC_SUBST(TK_CFLAGS)
4639 AC_SUBST(TK_LIBS)
4641 AC_SUBST(MOZ_ENABLE_GTK2)
4642 AC_SUBST(MOZ_ENABLE_GTK3)
4643 AC_SUBST(MOZ_ENABLE_GTK)
4644 AC_SUBST(MOZ_ENABLE_QT)
4645 AC_SUBST(MOZ_ENABLE_QTNETWORK)
4646 AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
4647 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4648 AC_SUBST(MOZ_ENABLE_XREMOTE)
4649 AC_SUBST(MOZ_GTK2_CFLAGS)
4650 AC_SUBST(MOZ_GTK2_LIBS)
4651 AC_SUBST(MOZ_GTK3_CFLAGS)
4652 AC_SUBST(MOZ_GTK3_LIBS)
4653 AC_SUBST(MOZ_WIDGET_GTK)
4654 AC_SUBST(MOZ_QT_CFLAGS)
4655 AC_SUBST(MOZ_QT_LIBS)
4657 AC_SUBST(MOC)
4658 AC_SUBST(RCC)
4660 AC_SUBST(MOZ_X11)
4662 dnl ========================================================
4663 dnl =
4664 dnl = Components & Features
4665 dnl =
4666 dnl ========================================================
4667 MOZ_ARG_HEADER(Components and Features)
4669 dnl ========================================================
4670 dnl = Localization
4671 dnl ========================================================
4672 MOZ_ARG_ENABLE_STRING(ui-locale,
4673 [  --enable-ui-locale=ab-CD
4674                           Select the user interface locale (default: en-US)],
4675     MOZ_UI_LOCALE=$enableval )
4676 AC_SUBST(MOZ_UI_LOCALE)
4678 dnl ========================================================
4679 dnl = Trademarked Branding
4680 dnl ========================================================
4681 MOZ_ARG_ENABLE_BOOL(official-branding,
4682 [  --enable-official-branding
4683                           Enable Official mozilla.org Branding
4684                           Do not distribute builds with
4685                           --enable-official-branding unless you have
4686                           permission to use trademarks per
4687                           http://www.mozilla.org/foundation/trademarks/ .],
4689   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
4690     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
4691   else
4692     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
4693     MOZ_OFFICIAL_BRANDING=1
4694   fi
4695 ], MOZ_OFFICIAL_BRANDING=)
4697 AC_SUBST(MOZ_OFFICIAL_BRANDING)
4698 if test -n "$MOZ_OFFICIAL_BRANDING"; then
4699   AC_DEFINE(MOZ_OFFICIAL_BRANDING)
4702 MOZ_ARG_WITH_STRING(branding,
4703 [  --with-branding=dir     Use branding from the specified directory.],
4704     MOZ_BRANDING_DIRECTORY=$withval)
4706 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
4707 if test -z "$REAL_BRANDING_DIRECTORY"; then
4708   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
4711 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
4712   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
4715 AC_SUBST(MOZ_BRANDING_DIRECTORY)
4717 dnl ========================================================
4718 dnl = Distribution ID
4719 dnl ========================================================
4720 MOZ_ARG_WITH_STRING(distribution-id,
4721 [  --with-distribution-id=ID
4722                           Set distribution-specific id (default=org.mozilla)],
4723 [ val=`echo $withval`
4724     MOZ_DISTRIBUTION_ID="$val"])
4726 if test -z "$MOZ_DISTRIBUTION_ID"; then
4727    MOZ_DISTRIBUTION_ID="org.mozilla"
4730 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
4731 AC_SUBST(MOZ_DISTRIBUTION_ID)
4734 dnl ========================================================
4735 dnl complex text support off by default
4736 dnl ========================================================
4737 MOZ_ARG_DISABLE_BOOL(pango,
4738 [  --disable-pango         Disable usage of Pango ],
4739     MOZ_PANGO=,
4740     MOZ_PANGO=1)
4742 dnl ========================================================
4743 dnl = Pango
4744 dnl ========================================================
4745 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4746 then
4747     AC_SUBST(MOZ_PANGO)
4749     if test "$MOZ_PANGO"
4750     then
4751         PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
4753         PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
4754         AC_SUBST(MOZ_PANGO_CFLAGS)
4755         AC_SUBST(MOZ_PANGO_LIBS)
4756         AC_DEFINE(MOZ_PANGO)
4757     else
4758         PKG_CHECK_MODULES(FT2, freetype2 > 6.1.0)
4759         AC_SUBST(FT2_CFLAGS)
4760         AC_SUBST(FT2_LIBS)
4761     fi
4764 dnl ========================================================
4765 dnl = GnomeVFS, GIO and GConf support module
4766 dnl ========================================================
4768 if test "$MOZ_X11"
4769 then
4770     dnl build the GIO extension by default only when the
4771     dnl GTK2 toolkit is in use.
4772     if test "$MOZ_ENABLE_GTK"
4773     then
4774         MOZ_ENABLE_GIO=1
4775         MOZ_ENABLE_GCONF=1
4776     fi
4778     dnl ========================================================
4779     dnl = GnomeVFS support module
4780     dnl ========================================================
4781     MOZ_ARG_ENABLE_BOOL(gnomevfs,
4782     [  --enable-gnomevfs       Enable GnomeVFS support (default: disabled)],
4783         MOZ_ENABLE_GNOMEVFS=force,
4784         MOZ_ENABLE_GNOMEVFS=)
4786     if test "$MOZ_ENABLE_GNOMEVFS"
4787     then
4788         PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
4789             MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
4790             MOZ_ENABLE_GNOMEVFS=1
4791             AC_DEFINE(MOZ_ENABLE_GNOMEVFS)
4792         ],[
4793             if test "$MOZ_ENABLE_GNOMEVFS" = "force"
4794             then
4795                 AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
4796             fi
4797             MOZ_ENABLE_GNOMEVFS=
4798         ])
4799     fi
4801     AC_SUBST(MOZ_ENABLE_GNOMEVFS)
4802     AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
4803     AC_SUBST(MOZ_GNOMEVFS_LIBS)
4805     dnl ========================================================
4806     dnl = GIO support module
4807     dnl ========================================================
4808     MOZ_ARG_DISABLE_BOOL(gio,
4809     [  --disable-gio           Disable GIO support],
4810         MOZ_ENABLE_GIO=,
4811         MOZ_ENABLE_GIO=force)
4813     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK"
4814     then
4815         PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
4816                           [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
4817         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
4818             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
4819             MOZ_ENABLE_GIO=1
4820             AC_DEFINE(MOZ_ENABLE_GIO)
4821         ],[
4822             if test "$MOZ_ENABLE_GIO" = "force"
4823             then
4824                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
4825             fi
4826             MOZ_ENABLE_GIO=
4827         ])
4828     fi
4830     AC_SUBST(MOZ_ENABLE_GIO)
4831     AC_SUBST(MOZ_GIO_CFLAGS)
4832     AC_SUBST(MOZ_GIO_LIBS)
4834     dnl ========================================================
4835     dnl = GConf support module
4836     dnl ========================================================
4837     MOZ_ARG_DISABLE_BOOL(gconf,
4838     [  --disable-gconf      Disable Gconf support ],
4839         MOZ_ENABLE_GCONF=,
4840         MOZ_ENABLE_GCONF=force)
4842     if test "$MOZ_ENABLE_GCONF"
4843     then
4844         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
4845             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
4846             MOZ_ENABLE_GCONF=1
4847         ],[
4848             if test "$MOZ_ENABLE_GCONF" = "force"
4849             then
4850                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
4851             fi
4852             MOZ_ENABLE_GCONF=
4853         ])
4854     fi
4856     if test "$MOZ_ENABLE_GCONF"; then
4857         AC_DEFINE(MOZ_ENABLE_GCONF)
4858     fi
4860     AC_SUBST(MOZ_ENABLE_GCONF)
4861     AC_SUBST(MOZ_GCONF_CFLAGS)
4862     AC_SUBST(MOZ_GCONF_LIBS)
4865 dnl ========================================================
4866 dnl = libproxy support
4867 dnl ========================================================
4869 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4870 then
4871     MOZ_ENABLE_LIBPROXY=
4873     MOZ_ARG_ENABLE_BOOL(libproxy,
4874     [  --enable-libproxy         Enable libproxy support ],
4875     MOZ_ENABLE_LIBPROXY=1,
4876     MOZ_ENABLE_LIBPROXY=)
4878     if test "$MOZ_ENABLE_LIBPROXY"
4879     then
4880         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
4881         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
4882     fi
4884 AC_SUBST(MOZ_ENABLE_LIBPROXY)
4885 AC_SUBST(MOZ_LIBPROXY_CFLAGS)
4886 AC_SUBST(MOZ_LIBPROXY_LIBS)
4888 dnl ========================================================
4889 dnl = GNOME component (mozgnome)
4890 dnl ========================================================
4892 if test "$MOZ_ENABLE_GTK2"
4893 then
4894     MOZ_ENABLE_GNOME_COMPONENT=1
4896 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
4898 dnl ========================================================
4899 dnl = libgnomeui support module
4900 dnl ========================================================
4902 if test "$MOZ_ENABLE_GTK"
4903 then
4904     MOZ_ARG_ENABLE_BOOL(gnomeui,
4905     [  --enable-gnomeui        Enable libgnomeui instead of GIO & GTK for icon theme support ],
4906         MOZ_ENABLE_GNOMEUI=force,
4907         MOZ_ENABLE_GNOMEUI=)
4909     if test "$MOZ_ENABLE_GNOMEUI"
4910     then
4911         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
4912         [
4913             MOZ_ENABLE_GNOMEUI=1
4914         ],[
4915             if test "$MOZ_ENABLE_GNOMEUI" = "force"
4916             then
4917                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
4918             fi
4919             MOZ_ENABLE_GNOMEUI=
4920         ])
4921     fi
4923     if test "$MOZ_ENABLE_GNOMEUI"; then
4924         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
4925     fi
4928 AC_SUBST(MOZ_ENABLE_GNOMEUI)
4929 AC_SUBST(MOZ_GNOMEUI_CFLAGS)
4931 dnl ========================================================
4932 dnl = dbus support
4933 dnl ========================================================
4935 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4936 then
4937     MOZ_ENABLE_DBUS=1
4939     MOZ_ARG_DISABLE_BOOL(dbus,
4940     [  --disable-dbus          Disable dbus support ],
4941         MOZ_ENABLE_DBUS=,
4942         MOZ_ENABLE_DBUS=1)
4944     if test "$MOZ_ENABLE_DBUS"
4945     then
4946         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
4947         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
4948         AC_DEFINE(MOZ_ENABLE_DBUS)
4949     fi
4951 AC_SUBST(MOZ_ENABLE_DBUS)
4952 AC_SUBST(MOZ_DBUS_CFLAGS)
4953 AC_SUBST(MOZ_DBUS_LIBS)
4954 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
4955 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
4957 dnl ========================================================
4958 dnl = Enable Android History instead of Places
4959 dnl ========================================================
4960 if test -n "$MOZ_ANDROID_HISTORY"; then
4961     if test -z "$MOZ_PLACES"; then
4962         AC_DEFINE(MOZ_ANDROID_HISTORY)
4963     else
4964         AC_MSG_ERROR([Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.])
4965     fi
4968 dnl ========================================================
4969 dnl = Build with the Android compositor
4970 dnl ========================================================
4971 if test -n "$MOZ_ANDROID_OMTC"; then
4972      dnl Do this if defined in confvars.sh
4973      AC_DEFINE(MOZ_ANDROID_OMTC)
4976 dnl ========================================================
4977 dnl = Disable WebSMS backend
4978 dnl ========================================================
4979 MOZ_ARG_DISABLE_BOOL(websms-backend,
4980 [  --disable-websms-backend
4981                            Disable WebSMS backend],
4982     MOZ_WEBSMS_BACKEND=,
4983     MOZ_WEBSMS_BACKEND=1)
4985 if test -n "$MOZ_WEBSMS_BACKEND"; then
4986     AC_DEFINE(MOZ_WEBSMS_BACKEND)
4989 dnl ========================================================
4990 dnl = Enable NFC permission on Android
4991 dnl ========================================================
4992 if test -n "$MOZ_ANDROID_BEAM"; then
4993     AC_DEFINE(MOZ_ANDROID_BEAM)
4996 dnl ========================================================
4997 dnl = JS Debugger XPCOM component (js/jsd)
4998 dnl ========================================================
4999 MOZ_ARG_DISABLE_BOOL(jsd,
5000 [  --disable-jsd           Disable JavaScript debug library],
5001     MOZ_JSDEBUGGER=,
5002     MOZ_JSDEBUGGER=1)
5005 dnl ========================================================
5006 dnl = Enable IPDL's "expensive" unit tests
5007 dnl ========================================================
5008 MOZ_IPDL_TESTS=
5010 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
5011 [  --enable-ipdl-tests     Enable expensive IPDL tests],
5012     MOZ_IPDL_TESTS=1,
5013     MOZ_IPDL_TESTS=)
5015 if test -n "$MOZ_IPDL_TESTS"; then
5016     AC_DEFINE(MOZ_IPDL_TESTS)
5019 AC_SUBST(MOZ_IPDL_TESTS)
5021 dnl ========================================================
5022 dnl = Disable building dbm
5023 dnl ========================================================
5024 MOZ_ARG_DISABLE_BOOL(dbm,
5025 [  --disable-dbm           Disable building dbm],
5026     NSS_DISABLE_DBM=1,
5027     NSS_DISABLE_DBM=)
5029 dnl bi-directional support always on
5030 IBMBIDI=1
5031 AC_DEFINE(IBMBIDI)
5033 dnl ========================================================
5034 dnl accessibility support on by default on all platforms
5035 dnl ========================================================
5036 MOZ_ARG_DISABLE_BOOL(accessibility,
5037 [  --disable-accessibility Disable accessibility support],
5038     ACCESSIBILITY=,
5039     ACCESSIBILITY=1 )
5040 if test "$ACCESSIBILITY"; then
5041     case "$target" in
5042     *-mingw*)
5043         if test -z "$MIDL"; then
5044             if test "$GCC" != "yes"; then
5045                 AC_MSG_ERROR([MIDL could not be found. Building accessibility without MIDL is not supported.])
5046             else
5047                 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.])
5048             fi
5049         fi
5050     esac
5051     AC_DEFINE(ACCESSIBILITY)
5054 dnl ========================================================
5055 dnl Accessibility is required for the linuxgl widget
5056 dnl backend
5057 dnl ========================================================
5058 if test "${MOZ_WIDGET_TOOLKIT}" = "linuxgl" -a "$ACCESSIBILITY" != "1"; then
5059     AC_MSG_ERROR(["Accessibility is required for the linuxgl widget backend"])
5062 dnl ========================================================
5063 dnl Disable printing
5064 dnl ========================================================
5065 MOZ_ARG_DISABLE_BOOL(printing,
5066 [  --disable-printing      Disable printing support],
5067     NS_PRINTING=,
5068     NS_PRINTING=1)
5070 if test "$NS_PRINTING"; then
5071     AC_DEFINE(NS_PRINTING)
5072     AC_DEFINE(NS_PRINT_PREVIEW)
5075 dnl Turn off webrtc for OS's we don't handle yet, but allow 
5076 dnl --enable-webrtc to override.  Can disable for everything in
5077 dnl the master list above.
5078 if test -n "$MOZ_WEBRTC"; then
5079     case "$target" in
5080     *-linux*|*-mingw*|*-darwin*|*-android*|*-linuxandroid*|*-dragonfly*|*-freebsd*|*-netbsd*|*-openbsd*)
5081         dnl Leave enabled
5082         ;;
5083     *)
5084         dnl default to disabled for all others
5085         MOZ_WEBRTC=
5086         ;;
5087     esac
5090 AC_TRY_COMPILE([#include <linux/ethtool.h>],
5091                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
5092                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
5094 # target_arch is from {ia32|x64|arm|ppc}
5095 case "$CPU_ARCH" in
5096 x86_64)
5097     WEBRTC_TARGET_ARCH=x64
5098     ;;
5100 arm*)
5101     WEBRTC_TARGET_ARCH=arm
5102     ;;
5104 x86)
5105     WEBRTC_TARGET_ARCH=ia32
5106     ;;
5108 ppc*)
5109     WEBRTC_TARGET_ARCH=ppc
5110     ;;
5111 ia64)
5112     WEBRTC_TARGET_ARCH=ia64
5113     ;;
5115 # unsupported arch for webrtc
5116     WEBRTC_TARGET_ARCH=unknown
5117     MOZ_WEBRTC=
5118     ;;
5120 esac
5122 dnl ========================================================
5123 dnl = Disable WebRTC code
5124 dnl ========================================================
5125 MOZ_ARG_DISABLE_BOOL(webrtc,
5126 [  --disable-webrtc        Disable support for WebRTC],
5127     MOZ_WEBRTC=,
5128     MOZ_WEBRTC=1)
5130 if test -n "$MOZ_WEBRTC"; then
5131     AC_DEFINE(MOZ_WEBRTC)
5132     dnl MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
5133     dnl opt/production builds (via MOZ_CRASH())
5134     AC_DEFINE(MOZ_WEBRTC_ASSERT_ALWAYS)
5135     MOZ_RAW=1
5136     MOZ_VP8=1
5137     MOZ_VP8_ERROR_CONCEALMENT=1
5139 dnl enable once Signaling lands
5140     MOZ_WEBRTC_SIGNALING=1
5141     AC_DEFINE(MOZ_WEBRTC_SIGNALING)
5142 dnl enable once PeerConnection lands
5143     MOZ_PEERCONNECTION=1
5144     AC_DEFINE(MOZ_PEERCONNECTION)
5145     MOZ_SCTP=1
5146     MOZ_SRTP=1
5147     AC_DEFINE(MOZ_SCTP)
5148     AC_DEFINE(MOZ_SRTP)
5151 AC_SUBST(MOZ_WEBRTC)
5152 AC_SUBST(MOZ_WEBRTC_LEAKING_TESTS)
5153 AC_SUBST(MOZ_WEBRTC_SIGNALING)
5154 AC_SUBST(MOZ_PEERCONNECTION)
5155 AC_SUBST(MOZ_WEBRTC_ASSERT_ALWAYS)
5156 AC_SUBST(MOZ_SCTP)
5157 AC_SUBST(MOZ_SRTP)
5159 dnl Use integers over floats for audio on B2G and Android, because audio
5160 dnl backends for those platforms don't support floats.
5161 if test "$OS_TARGET" = "Android"; then
5162     MOZ_SAMPLE_TYPE_S16=1
5163     AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
5164     AC_SUBST(MOZ_SAMPLE_TYPE_S16)
5165 else
5166     MOZ_SAMPLE_TYPE_FLOAT32=1
5167     AC_DEFINE(MOZ_SAMPLE_TYPE_FLOAT32)
5168     AC_SUBST(MOZ_SAMPLE_TYPE_FLOAT32)
5171 dnl ========================================================
5172 dnl = Disable Speech API code
5173 dnl ========================================================
5174 MOZ_ARG_DISABLE_BOOL(webspeech,
5175 [  --disable-webspeech        Disable support for HTML Speech API],
5176     MOZ_WEBSPEECH=,
5177     MOZ_WEBSPEECH=1)
5179 if test -n "$MOZ_WEBSPEECH"; then
5180     AC_DEFINE(MOZ_WEBSPEECH)
5183 AC_SUBST(MOZ_WEBSPEECH)
5185 dnl ========================================================
5186 dnl = Enable Raw Codecs
5187 dnl ========================================================
5188 MOZ_ARG_ENABLE_BOOL(raw,
5189 [  --enable-raw           Enable support for RAW media],
5190     MOZ_RAW=1,
5191     MOZ_RAW=)
5193 if test -n "$MOZ_RAW"; then
5194     AC_DEFINE(MOZ_RAW)
5197 AC_SUBST(MOZ_RAW)
5199 dnl ========================================================
5200 dnl = Disable Ogg Codecs
5201 dnl ========================================================
5202 MOZ_ARG_DISABLE_BOOL(ogg,
5203 [  --disable-ogg           Disable support for OGG media (Theora video and Vorbis audio)],
5204     MOZ_OGG=,
5205     MOZ_OGG=1)
5207 if test -n "$MOZ_OGG"; then
5208     AC_DEFINE(MOZ_OGG)
5210     dnl Checks for __attribute__(aligned()) directive
5211     AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5212         [ac_cv_c_attribute_aligned],
5213         [ac_cv_c_attribute_aligned=0
5214          CFLAGS_save="${CFLAGS}"
5215          CFLAGS="${CFLAGS} -Werror"
5216          for ac_cv_c_attr_align_try in 64 32 16 8; do
5217            echo "trying $ac_cv_c_attr_align_try"
5218            AC_TRY_COMPILE([],
5219                           [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5220                           [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5221            if test "$ac_cv_c_attribute_aligned" != 0; then
5222              break;
5223            fi
5224          done
5225            CFLAGS="${CFLAGS_save}"])
5226     if test "${ac_cv_c_attribute_aligned}" != "0"; then
5227       AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5228                          [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5229     fi
5232 dnl ========================================================
5233 dnl = Disable Opus audio codec support
5234 dnl ========================================================
5235 MOZ_ARG_DISABLE_BOOL(opus,
5236 [  --disable-opus          Disable support for Opus audio],
5237     MOZ_OPUS=,
5238     MOZ_OPUS=1)
5240 dnl ========================================================
5241 dnl = Disable VP8 decoder support
5242 dnl ========================================================
5243 MOZ_ARG_DISABLE_BOOL(webm,
5244 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
5245     MOZ_WEBM=,
5246     MOZ_WEBM=1)
5248 if test -n "$MOZ_WEBM"; then
5249     AC_DEFINE(MOZ_WEBM)
5250     MOZ_VP8=1
5253 dnl ========================================================
5254 dnl = DirectShow support
5255 dnl ========================================================
5256 if test "$OS_ARCH" = "WINNT"; then
5257     dnl Enable DirectShow support by default.
5258     MOZ_DIRECTSHOW=1
5261 MOZ_ARG_DISABLE_BOOL(directshow,
5262 [  --disable-directshow  Disable support for DirectShow],
5263     MOZ_DIRECTSHOW=,
5264     MOZ_DIRECTSHOW=1)
5266 if test -n "$MOZ_DIRECTSHOW"; then
5267     AC_DEFINE(MOZ_DIRECTSHOW)
5270 dnl ========================================================
5271 dnl = Windows Media Foundation support
5272 dnl ========================================================
5273 if test "$OS_ARCH" = "WINNT"; then
5274     dnl Enable Windows Media Foundation support by default.
5275     dnl Note our minimum SDK version is Windows 7 SDK, so we are (currently)
5276     dnl guaranteed to have a recent-enough SDK to build WMF.
5277     MOZ_WMF=1
5280 MOZ_ARG_DISABLE_BOOL(wmf,
5281 [  --disable-wmf  Disable support for Windows Media Foundation],
5282     MOZ_WMF=,
5283     MOZ_WMF=1)
5285 if test -n "$MOZ_WMF"; then
5286     AC_DEFINE(MOZ_WMF)
5289 dnl ========================================================
5290 dnl = Built-in fragmented MP4 support.
5291 dnl ========================================================
5292 if test -n "$MOZ_WMF"; then
5293     dnl Enable fragmented MP4 parser on Windows by default.
5294     dnl We will also need to enable it on other platforms as we implement
5295     dnl platform decoder support there too.
5296     MOZ_FMP4=1
5299 MOZ_ARG_DISABLE_BOOL(fmp4,
5300 [  --disable-fmp4  Disable support for in built Fragmented MP4 parsing],
5301     MOZ_FMP4=,
5302     MOZ_FMP4=1)
5304 if test -n "$MOZ_FMP4"; then
5305     AC_DEFINE(MOZ_FMP4)
5309 dnl ========================================================
5310 dnl = Enable media plugin support
5311 dnl ========================================================
5312 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5313   dnl Enable support on android by default
5314   MOZ_MEDIA_PLUGINS=1
5317 MOZ_ARG_ENABLE_BOOL(media-plugins,
5318 [  --enable-media-plugins  Enable support for media plugins],
5319     MOZ_MEDIA_PLUGINS=1,
5320     MOZ_MEDIA_PLUGINS=)
5322 if test -n "$MOZ_MEDIA_PLUGINS"; then
5323   AC_DEFINE(MOZ_MEDIA_PLUGINS)
5326 dnl ========================================================
5327 dnl = Disable platform MP3 decoder on OSX
5328 dnl ========================================================
5329 if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
5330   MOZ_APPLEMEDIA=1
5333 MOZ_ARG_DISABLE_BOOL(apple-media,
5334 [  --disable-apple-media  Disable support for Apple AudioToolbox/VideoToolbox],
5335     MOZ_APPLEMEDIA=,
5336     MOZ_APPLEMEDIA=1)
5338 if test -n "$MOZ_APPLEMEDIA"; then
5339   AC_DEFINE(MOZ_APPLEMEDIA)
5342 dnl ========================================================
5343 dnl = Enable getUserMedia support
5344 dnl ========================================================
5345 MOZ_ARG_ENABLE_BOOL(media-navigator,
5346 [  --enable-media-navigator  Enable support for getUserMedia],
5347     MOZ_MEDIA_NAVIGATOR=1,
5348     MOZ_MEDIA_NAVIGATOR=)
5350 if test -n "$MOZ_MEDIA_NAVIGATOR"; then
5351   AC_DEFINE(MOZ_MEDIA_NAVIGATOR)
5354 dnl ========================================================
5355 dnl = Enable building OMX media plugin (B2G or Android)
5356 dnl ========================================================
5357 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5358   dnl Enable support on android by default
5359   MOZ_OMX_PLUGIN=1
5362 MOZ_ARG_ENABLE_BOOL(omx-plugin,
5363 [  --enable-omx-plugin      Enable building OMX plugin (B2G)],
5364     MOZ_OMX_PLUGIN=1,
5365     MOZ_OMX_PLUGIN=)
5367 if test -n "$MOZ_OMX_PLUGIN"; then
5368     if test "$OS_TARGET" = "Android"; then
5369         dnl Only allow building OMX plugin on Gonk (B2G) or Android
5370         AC_DEFINE(MOZ_OMX_PLUGIN)
5371     else
5372        dnl fail if we're not building on Gonk or Android
5373        AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
5374     fi
5377 dnl system libvpx Support
5378 dnl ========================================================
5379 MOZ_ARG_WITH_BOOL(system-libvpx,
5380 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
5381     MOZ_NATIVE_LIBVPX=1)
5383 MOZ_LIBVPX_CFLAGS=
5384 MOZ_LIBVPX_LIBS=
5386 if test -n "$MOZ_VP8"; then
5387     AC_DEFINE(MOZ_VP8)
5388     if test -n "$MOZ_VP8_ERROR_CONCEALMENT" ; then
5389         AC_DEFINE(MOZ_VP8_ERROR_CONCEALMENT)
5390     fi
5391     if test -n "$MOZ_VP8_ENCODER" ; then
5392         AC_DEFINE(MOZ_VP8_ENCODER)
5393     fi
5395     if test -n "$MOZ_NATIVE_LIBVPX"; then
5396         dnl ============================
5397         dnl === libvpx Version check ===
5398         dnl ============================
5399         dnl Check to see if we have a system libvpx package.
5400         PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.3.0)
5402         MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [], 
5403          [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.])])
5405         _SAVE_LIBS=$LIBS
5406         AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [], 
5407          [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
5408         LIBS=$_SAVE_LIBS
5409     fi
5412 AC_SUBST(MOZ_NATIVE_LIBVPX)
5413 AC_SUBST(MOZ_LIBVPX_CFLAGS)
5414 AC_SUBST(MOZ_LIBVPX_LIBS)
5416 if test "$MOZ_WEBM" -o "$MOZ_OGG"; then
5417     if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then
5418         MOZ_VORBIS=1
5419     else
5420         MOZ_TREMOR=1
5421     fi
5424 if test -n "$MOZ_VP8" -a -z "$MOZ_NATIVE_LIBVPX"; then
5426     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
5427     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
5428     dnl We currently require gcc on all arm platforms.
5429     VPX_AS=$YASM
5430     VPX_ASM_SUFFIX=asm
5431     VPX_NEED_OBJ_INT_EXTRACT=
5433     dnl See if we have assembly on this platform.
5434     case "$OS_ARCH:$CPU_ARCH" in
5435     Darwin:x86)
5436       VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
5437       VPX_X86_ASM=1
5438     ;;
5439     Darwin:x86_64)
5440       VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
5441       VPX_X86_ASM=1
5442     ;;
5443     WINNT:x86_64)
5444       VPX_ASFLAGS="-f x64 -rnasm -pnasm"
5445       VPX_X86_ASM=1
5446     ;;
5447     WINNT:x86)
5448       dnl Check for yasm 1.1 or greater.
5449       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
5450         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.])
5451       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5452         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.])
5453       else
5454         VPX_ASFLAGS="-f win32 -rnasm -pnasm -DPIC"
5455         VPX_X86_ASM=1
5456         dnl The encoder needs obj_int_extract to get asm offsets.
5457       fi
5458     ;;
5459     *:arm*)
5460       if test -n "$GNU_AS" ; then
5461         VPX_AS=$AS
5462         dnl These flags are a lie; they're just used to enable the requisite
5463         dnl opcodes; actual arch detection is done at runtime.
5464         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
5465         VPX_DASH_C_FLAG="-c"
5466         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
5467         VPX_ASM_SUFFIX="$ASM_SUFFIX"
5468         VPX_ARM_ASM=1
5469       fi
5470     ;;
5471     *:x86)
5472       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5473         VPX_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC"
5474         VPX_X86_ASM=1
5475       fi
5476     ;;
5477     *:x86_64)
5478       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5479         VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5480         VPX_X86_ASM=1
5481       fi
5482     ;;
5483     esac
5485     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_X86_ASM" -a -z "$VPX_AS"; then
5486       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.])
5487     fi
5489     if test -n "$MOZ_VP8_ENCODER" -a \
5490             -z "$GNU_CC" -a -z "$INTEL_CC" -a -z "$CLANG_CC" ; then
5491       dnl We prefer to get asm offsets using inline assembler, which the above
5492       dnl compilers can do. When we're not using one of those, we have to fall
5493       dnl back to obj_int_extract, which reads them from a compiled object
5494       dnl file. Unfortunately, that only works if we're compiling on a system
5495       dnl with the header files for the appropriate object file format.
5496       VPX_NEED_OBJ_INT_EXTRACT=1
5497     fi
5499     if test -n "$VPX_X86_ASM"; then
5500       AC_DEFINE(VPX_X86_ASM)
5501     elif test -n "$VPX_ARM_ASM"; then
5502       AC_DEFINE(VPX_ARM_ASM)
5503     else
5504       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
5505     fi
5508 dnl ========================================================
5509 dnl = Disable Wave decoder support
5510 dnl ========================================================
5511 MOZ_ARG_DISABLE_BOOL(wave,
5512 [  --disable-wave          Disable Wave decoder support],
5513     MOZ_WAVE=,
5514     MOZ_WAVE=1)
5516 if test -n "$MOZ_WAVE"; then
5517     AC_DEFINE(MOZ_WAVE)
5520 dnl ========================================================
5521 dnl = Handle dependent MEDIA defines
5522 dnl ========================================================
5524 if test -n "$MOZ_OPUS" -a -z "$MOZ_OGG"; then
5525     AC_MSG_ERROR([MOZ_OPUS requires MOZ_OGG which is disabled.])
5528 if test -n "$MOZ_VORBIS" -a -z "$MOZ_OGG"; then
5529     AC_MSG_ERROR([MOZ_VORBIS requires MOZ_OGG which is disabled.
5530 Note that you need vorbis support for WebM playback.])
5533 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
5534     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/])
5537 if test -n "$MOZ_WEBRTC" -a -z "$MOZ_OPUS"; then
5538     AC_MSG_ERROR([MOZ_WEBRTC requires MOZ_OPUS which is disabled.])
5541 if test -n "$MOZ_VORBIS"; then
5542     AC_DEFINE(MOZ_VORBIS)
5545 if test -n "$MOZ_TREMOR"; then
5546     AC_DEFINE(MOZ_TREMOR)
5549 if test -n "$MOZ_OPUS"; then
5550     AC_DEFINE(MOZ_OPUS)
5553 dnl ==================================
5554 dnl = Check alsa availability on Linux
5555 dnl ==================================
5557 dnl If using Linux, ensure that the alsa library is available
5558 if test "$OS_TARGET" = "Linux"; then
5559     MOZ_ALSA=1
5562 MOZ_ARG_ENABLE_BOOL(alsa,
5563 [  --enable-alsa          Enable Alsa support (default on Linux)],
5564    MOZ_ALSA=1,
5565    MOZ_ALSA=)
5567 if test -n "$MOZ_ALSA"; then
5568     PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5569          [echo "$MOZ_ALSA_PKG_ERRORS"
5570           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.)])])
5573 AC_SUBST(MOZ_ALSA)
5574 AC_SUBST(MOZ_ALSA_CFLAGS)
5575 AC_SUBST(MOZ_ALSA_LIBS)
5577 dnl ========================================================
5578 dnl = Disable PulseAudio
5579 dnl ========================================================
5581 dnl If using Linux, ensure that the PA library is available
5582 if test "$OS_TARGET" = "Linux" -a -z "$MOZ_B2G"; then
5583     MOZ_PULSEAUDIO=1
5586 MOZ_ARG_DISABLE_BOOL(pulseaudio,
5587 [  --disable-pulseaudio          Disable PulseAudio support],
5588    MOZ_PULSEAUDIO=,
5589    MOZ_PULSEAUDIO=1)
5591 if test -n "$MOZ_PULSEAUDIO"; then
5592     if test -z "$gonkdir"; then
5593         PKG_CHECK_MODULES(MOZ_PULSEAUDIO, libpulse, ,
5594              [echo "$MOZ_PULSEAUDIO_PKG_ERRORS"
5595               AC_MSG_ERROR([pulseaudio audio backend requires libpulse development package])])
5596     else
5597         MOZ_PULSEAUDIO_CFLAGS="-I$gonkdir/external/pulseaudio/pulseaudio/src"
5598     fi
5601 AC_SUBST(MOZ_PULSEAUDIO)
5602 AC_SUBST(MOZ_PULSEAUDIO_CFLAGS)
5604 dnl ========================================================
5605 dnl = Enable GStreamer
5606 dnl ========================================================
5607 if test "$OS_TARGET" = "Linux"; then
5608   MOZ_GSTREAMER=1
5611 MOZ_ARG_ENABLE_BOOL(gstreamer,
5612 [  --enable-gstreamer           Enable GStreamer support],
5613 MOZ_GSTREAMER=1,
5614 MOZ_GSTREAMER=)
5616 if test "$MOZ_GSTREAMER"; then
5617     # API version, eg 0.10, 1.0 etc
5618     GST_API_VERSION=0.10
5619     # core/base release number
5620     GST_VERSION=0.10.25
5621     PKG_CHECK_MODULES(GSTREAMER,
5622                       gstreamer-$GST_API_VERSION >= $GST_VERSION
5623                       gstreamer-app-$GST_API_VERSION
5624                       gstreamer-plugins-base-$GST_API_VERSION, ,
5625                       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]))
5626     if test -n "$GSTREAMER_LIBS"; then
5627        _SAVE_LDFLAGS=$LDFLAGS
5628        LDFLAGS="$LDFLAGS $GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5629        AC_TRY_LINK(,[return 0;],_HAVE_LIBGSTVIDEO=1,_HAVE_LIBGSTVIDEO=)
5630        if test -n "$_HAVE_LIBGSTVIDEO" ; then
5631           GSTREAMER_LIBS="$GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5632        else
5633           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.])
5634        fi
5635        LDFLAGS=$_SAVE_LDFLAGS
5636     else
5637        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])
5638     fi
5640 AC_SUBST(GSTREAMER_CFLAGS)
5641 AC_SUBST(GSTREAMER_LIBS)
5642 AC_SUBST(MOZ_GSTREAMER)
5644 if test -n "$MOZ_GSTREAMER"; then
5645    AC_DEFINE(MOZ_GSTREAMER)
5649 dnl ========================================================
5650 dnl Permissions System
5651 dnl ========================================================
5652 MOZ_ARG_DISABLE_BOOL(permissions,
5653 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5654     MOZ_PERMISSIONS=,
5655     MOZ_PERMISSIONS=1
5658 dnl ========================================================
5659 dnl Child permissions, currently only used for b2g
5660 dnl ========================================================
5661 if test -n "$MOZ_B2G"; then
5662     if test -n "$MOZ_PERMISSIONS"; then
5663         MOZ_CHILD_PERMISSIONS=1
5664     else
5665         AC_MSG_ERROR([You need to enable MOZ_PERMISSIONS for MOZ_CHILD_PERMISSIONS])
5666     fi
5668 AC_SUBST(MOZ_CHILD_PERMISSIONS)
5670 dnl ========================================================
5671 dnl NegotiateAuth
5672 dnl ========================================================
5673 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5674 [  --disable-negotiateauth Disable GSS-API negotiation ],
5675     MOZ_AUTH_EXTENSION=,
5676     MOZ_AUTH_EXTENSION=1 )
5678 dnl ========================================================
5679 dnl Pref extensions (autoconfig)
5680 dnl ========================================================
5681 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5682 [  --disable-pref-extensions
5683                           Disable pref extensions such as autoconfig],
5684   MOZ_PREF_EXTENSIONS=,
5685   MOZ_PREF_EXTENSIONS=1 )
5687 dnl ========================================================
5688 dnl Searching of system directories for extensions.
5689 dnl Note: this switch is meant to be used for test builds
5690 dnl whose behavior should not depend on what happens to be
5691 dnl installed on the local machine.
5692 dnl ========================================================
5693 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
5694 [  --disable-system-extension-dirs
5695                           Disable searching system- and account-global
5696                           directories for extensions of any kind; use
5697                           only profile-specific extension directories],
5698   ENABLE_SYSTEM_EXTENSION_DIRS=,
5699   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
5700 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
5701   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
5704 dnl ========================================================
5705 dnl = Universalchardet
5706 dnl ========================================================
5707 MOZ_ARG_DISABLE_BOOL(universalchardet,
5708 [  --disable-universalchardet
5709                           Disable universal encoding detection],
5710   MOZ_UNIVERSALCHARDET=,
5711   MOZ_UNIVERSALCHARDET=1 )
5713 if test -n "${JAVA_BIN_PATH}"; then
5714   dnl Look for javac and jar in the specified path.
5715   JAVA_PATH="$JAVA_BIN_PATH"
5716 else
5717   dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5718   JAVA_PATH="$JAVA_HOME/bin:$PATH"
5721 MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5722 MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5723 MOZ_PATH_PROG(JAVAH, javah, :, [$JAVA_PATH])
5724 MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5725 MOZ_PATH_PROG(JARSIGNER, jarsigner, :, [$JAVA_PATH])
5726 MOZ_PATH_PROG(KEYTOOL, keytool, :, [$JAVA_PATH])
5728 if test -n "${JAVA_BIN_PATH}" -o \
5729   \( "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk" \); then
5730   if test -z "$JAVA" -o "$JAVA" = ":"; then
5731     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}])
5732   fi
5733   if test -z "$JAVAC" -o "$JAVAC" = ":"; then
5734     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}])
5735   fi
5736   if test -z "$JAVAH" -o "$JAVAH" = ":"; then
5737     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}])
5738   fi
5739   if test -z "$JAR" -o "$JAR" = ":"; then
5740     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}])
5741   fi
5742   if test -z "$JARSIGNER" -o "$JARSIGNER" = ":"; then
5743     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}])
5744   fi
5745   if test -z "$KEYTOOL" -o "$KEYTOOL" = ":"; then
5746     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}])
5747   fi
5750 dnl ========================================================
5751 dnl = ANGLE OpenGL->D3D translator for WebGL
5752 dnl = * only applies to win32
5753 dnl = * enabled by default (shipping build); requires explicit --disable to disable
5754 dnl ========================================================
5755 MOZ_ANGLE_RENDERER=
5756 MOZ_DIRECTX_SDK_PATH=
5757 MOZ_DIRECTX_SDK_CPU_SUFFIX=
5758 MOZ_D3DCOMPILER_CAB=
5759 MOZ_D3DCOMPILER_DLL=
5760 case "$target_os" in
5761 *mingw*)
5762     MOZ_ANGLE_RENDERER=1
5763     ;;
5764 esac
5766 # The DirectX SDK libraries are split into x86 and x64 sub-directories
5767 case "${target_cpu}" in
5768 i*86)
5769   MOZ_DIRECTX_SDK_CPU_SUFFIX=x86
5770   ;;
5771 x86_64)
5772   MOZ_DIRECTX_SDK_CPU_SUFFIX=x64
5773   ;;
5774 esac
5776 MOZ_ARG_DISABLE_BOOL(webgl,
5777 [  --disable-webgl     Disable building of the WebGL implementation],
5778     MOZ_WEBGL_DISABLED=1,
5779     MOZ_WEBGL_DISABLED=)
5781 if test -n "$MOZ_WEBGL_DISABLED"; then
5782   MOZ_WEBGL=
5783   MOZ_ANGLE_RENDERER=
5786 if test -n "$MOZ_WEBGL"; then
5787   AC_DEFINE(MOZ_WEBGL)
5790 if test -n "$MOZ_WEBGL_CONFORMANT"; then
5791   AC_DEFINE(MOZ_WEBGL_CONFORMANT)
5794 # Locate a DirectX SDK here so we can use it for both ANGLE and
5795 # Joystick support.
5796 if test "$OS_TARGET" = "WINNT" -a -z "$CROSS_COMPILE"; then
5797   # Get the SDK path from the registry.
5798   # First try to get the June 2010 SDK
5799   MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK (June 2010)' | head -n 1`
5800   if test -z "$MOZ_DIRECTX_SDK_REG_KEY" ; then
5801     # Otherwise just take whatever comes first
5802     MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK' | head -n 1`
5803   fi
5804   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'`
5807 if test -n "$MOZ_ANGLE_RENDERER" -a -z "$CROSS_COMPILE"; then
5808   if test -n "`echo $MOZ_DIRECTX_SDK_REG_KEY | grep 'February 2010'`" ; then
5809     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.])
5810   fi
5812   if test -n "$MOZ_DIRECTX_SDK_PATH" &&
5813      test -f "$MOZ_DIRECTX_SDK_PATH"/include/d3dx9.h &&
5814          test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5815     AC_MSG_RESULT([Found DirectX SDK via registry, using $MOZ_DIRECTX_SDK_PATH])
5816   else
5817     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.])
5818   fi
5820   # Get the SDK numeric version (e.g. 43) by looking at the dependencies of d3dx9.lib
5821   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'`
5823   if test -z "$MOZ_D3DX9_VERSION" ; then
5824         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.])
5825   fi
5827   MOZ_D3DCOMPILER_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *D3DCompiler_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
5829   if test -z "$MOZ_D3DCOMPILER_CAB"; then
5830     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.])
5831   fi
5833   MOZ_D3DCOMPILER_DLL=D3DCompiler_$MOZ_D3DX9_VERSION.dll
5836 dnl ========================================================
5837 dnl Gamepad support
5838 dnl ========================================================
5839 MOZ_GAMEPAD=
5840 MOZ_GAMEPAD_BACKEND=stub
5842 # Gamepad DOM is built on supported platforms by default.
5843 case "$OS_TARGET" in
5844      Darwin|WINNT|Linux)
5845        MOZ_GAMEPAD=1
5846        ;;
5847      *)
5848        ;;
5849 esac
5851 MOZ_ARG_DISABLE_BOOL(gamepad,
5852 [  --disable-gamepad   Disable gamepad support],
5853     MOZ_GAMEPAD=,
5854     MOZ_GAMEPAD=1)
5856 if test "$MOZ_GAMEPAD"; then
5857     case "$OS_TARGET" in
5858     Darwin)
5859         MOZ_GAMEPAD_BACKEND=cocoa
5860         ;;
5861     WINNT)
5862         if test -n "$MOZ_DIRECTX_SDK_PATH" ; then
5863             if ! test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5864                MOZ_GAMEPAD=
5865             fi
5866         elif test "$GCC" != "yes"; then
5867             MOZ_GAMEPAD=
5868         fi
5869         if test -z "$MOZ_GAMEPAD"; then
5870            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.])
5871         fi
5872         MOZ_GAMEPAD_BACKEND=windows
5873         ;;
5874     Linux)
5875         MOZ_CHECK_HEADER([linux/joystick.h])
5876         if test "$ac_cv_header_linux_joystick_h" != "yes"; then
5877           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.])
5878         fi
5879         MOZ_GAMEPAD_BACKEND=linux
5880         ;;
5881     *)
5882         ;;
5883    esac
5885   AC_DEFINE(MOZ_GAMEPAD)
5887 AC_SUBST(MOZ_GAMEPAD)
5888 AC_SUBST(MOZ_GAMEPAD_BACKEND)
5890 dnl ========================================================
5891 dnl = Breakpad crash reporting (on by default on supported platforms)
5892 dnl ========================================================
5894 case $target in
5895 i?86-*-mingw*|x86_64-*-mingw*)
5896   MOZ_CRASHREPORTER=1
5897   ;;
5898 i?86-apple-darwin*|x86_64-apple-darwin*)
5899   MOZ_CRASHREPORTER=1
5900   ;;
5901 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
5902   if test "$MOZ_ENABLE_GTK"; then
5903     MOZ_CRASHREPORTER=1
5904   fi
5905   ;;
5906 *-android*|*-linuxandroid*)
5907   MOZ_CRASHREPORTER=1
5908   ;;
5909 *solaris*)
5910   MOZ_CRASHREPORTER=1
5911   ;;
5912 esac
5914 MOZ_ARG_DISABLE_BOOL(crashreporter,
5915 [  --disable-crashreporter Disable breakpad crash reporting],
5916     [MOZ_CRASHREPORTER=],
5917     [MOZ_CRASHREPORTER=F # Force enable breakpad])
5919 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT"; then
5920   if test "$MOZ_CRASHREPORTER" = F; then
5921     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
5922   fi
5923   MOZ_CRASHREPORTER=
5926 if test -n "$MOZ_CRASHREPORTER"; then
5927    AC_DEFINE(MOZ_CRASHREPORTER)
5929   if test "$OS_TARGET" = "Linux" -o "$OS_ARCH" = "SunOS" && \
5930     test -z "$SKIP_LIBRARY_CHECKS"; then
5931     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
5932     AC_SUBST(MOZ_GTHREAD_CFLAGS)
5933     AC_SUBST(MOZ_GTHREAD_LIBS)
5934   fi
5936   if test "$OS_ARCH" = "WINNT"; then
5937     if test -z "$HAVE_64BIT_OS"; then
5938       MOZ_CRASHREPORTER_INJECTOR=1
5939       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
5940     fi
5941   fi
5944 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
5945 [  --with-crashreporter-enable-percent=NN
5946                           Enable sending crash reports by default on NN% of users. (default=100)],
5947 [ val=`echo $withval | sed 's/[^0-9]//g'`
5948     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
5950 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
5951    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
5953 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
5955 dnl ========================================================
5956 dnl = libjpeg-turbo configuration
5957 dnl ========================================================
5958 MOZ_LIBJPEG_TURBO=
5959 if test -z "$MOZ_NATIVE_JPEG"; then
5960     MOZ_LIBJPEG_TURBO=1
5963 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
5964 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
5965     MOZ_LIBJPEG_TURBO=,
5966     MOZ_LIBJPEG_TURBO=1)
5968 if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
5969     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
5972 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
5973 dnl files.
5975 if test -n "$MOZ_LIBJPEG_TURBO"; then
5977   dnl Do we support libjpeg-turbo on this platform?
5978   case "$OS_ARCH:$OS_TEST" in
5979   Darwin:i?86)
5980     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
5981     LIBJPEG_TURBO_X86_ASM=1
5982   ;;
5983   Darwin:x86_64)
5984     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
5985     LIBJPEG_TURBO_X64_ASM=1
5986   ;;
5987   WINNT:x86|WINNT:i?86)
5988     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
5989     LIBJPEG_TURBO_X86_ASM=1
5990   ;;
5991   WINNT:x86_64)
5992     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
5993     LIBJPEG_TURBO_X64_ASM=1
5994   ;;
5995   *:arm*)
5996     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
5997     LIBJPEG_TURBO_ARM_ASM=1
5998   ;;
5999   *:x86|*:i?86)
6000     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6001       LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6002       LIBJPEG_TURBO_X86_ASM=1
6003     fi
6004   ;;
6005   *:x86_64)
6006     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6007       LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6008       LIBJPEG_TURBO_X64_ASM=1
6009     fi
6010   ;;
6011   esac
6015 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
6016 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
6017 dnl it doesn't exist or we have too old of a version.
6018 if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
6019     LIBJPEG_TURBO_AS=$YASM
6021     if test -z "$LIBJPEG_TURBO_AS" ; then
6022         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.])
6023     fi
6025     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
6026     dnl on Linux and 1.1 or newer everywhere else.
6027     if test "$OS_ARCH" = "Linux" ; then
6028         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
6029             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.])
6030         fi
6031     else
6032         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
6033             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.])
6034         fi
6035     fi
6038 dnl If we're on an ARM system which supports libjpeg-turbo's asm routines and
6039 dnl --disable-libjpeg-turbo wasn't passed, use the C compiler as the assembler.
6040 if test -n "$LIBJPEG_TURBO_ARM_ASM" ; then
6041     echo "Using $AS as the assembler for ARM code."
6042     LIBJPEG_TURBO_AS=$AS
6045 if test -n "$LIBJPEG_TURBO_X86_ASM"; then
6046     AC_DEFINE(LIBJPEG_TURBO_X86_ASM)
6047 elif test -n "$LIBJPEG_TURBO_X64_ASM"; then
6048     AC_DEFINE(LIBJPEG_TURBO_X64_ASM)
6049 elif test -n "$LIBJPEG_TURBO_ARM_ASM"; then
6050     AC_DEFINE(LIBJPEG_TURBO_ARM_ASM)
6051 elif test -n "$MOZ_LIBJPEG_TURBO"; then
6052     dnl Warn if we're not building the optimized routines, even though the user
6053     dnl didn't specify --disable-libjpeg-turbo.
6054     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
6057 dnl ========================================================
6058 dnl = Enable compilation of specific extension modules
6059 dnl ========================================================
6061 MOZ_ARG_ENABLE_STRING(extensions,
6062 [  --enable-extensions     Enable extensions],
6063 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6064     if test "$option" = "yes" -o "$option" = "all"; then
6065         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
6066     elif test "$option" = "no" -o "$option" = "none"; then
6067         MOZ_EXTENSIONS=""
6068     elif test "$option" = "default"; then
6069         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
6070     elif test `echo "$option" | grep -c \^-` != 0; then
6071         option=`echo $option | sed 's/^-//'`
6072         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
6073     else
6074         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
6075     fi
6076 done],
6077     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
6079 if test -z "$MOZ_ENABLE_GNOMEVFS" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6080     # Suppress warning on non-X11 platforms
6081     if test -n "$MOZ_X11"; then
6082         AC_MSG_WARN([Removing gnomevfs from MOZ_EXTENSIONS due to no --enable-gnomevfs.])
6083     fi
6084     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6087 dnl Do not build gnomevfs with libxul based apps
6088 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6089     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6092 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6093     # Suppress warning on non-X11 platforms
6094     if test -n "$MOZ_X11"; then
6095         AC_MSG_WARN([Removing gio from MOZ_EXTENSIONS due to --disable-gio.])
6096     fi
6097     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6100 dnl Do not build gio with libxul based apps
6101 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6102     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6105 if test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6106     MOZ_GIO_COMPONENT=1
6107     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6109 AC_SUBST(MOZ_GIO_COMPONENT)
6111 if test -z "$MOZ_JSDEBUGGER" -a `echo "$MOZ_EXTENSIONS" | grep -c venkman` -ne 0; then
6112     AC_MSG_WARN([Cannot build venkman without JavaScript debug library. Removing venkman from MOZ_EXTENSIONS.])
6113     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|venkman||'`
6116 dnl Remove dupes
6117 MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
6119 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6120 dnl when trying to build a nonexistent extension.
6121 for extension in $MOZ_EXTENSIONS; do
6122     if test ! -d "${srcdir}/extensions/${extension}"; then
6123         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6124     fi
6125 done
6127 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
6128   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
6131 dnl ========================================================
6132 dnl Build Freetype in the tree
6133 dnl ========================================================
6134 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6135 [  --enable-tree-freetype  Enable Tree FreeType],
6136     MOZ_TREE_FREETYPE=1,
6137     MOZ_TREE_FREETYPE= )
6138 if test -n "$MOZ_TREE_FREETYPE"; then
6139    if test -n "$_WIN32_MSVC"; then
6140       AC_ERROR("building with in-tree freetype is not supported on MSVC")
6141    fi
6142    AC_DEFINE(MOZ_TREE_FREETYPE)
6143    AC_SUBST(MOZ_TREE_FREETYPE)
6144    MOZ_ENABLE_CAIRO_FT=1
6145    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6146    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6147    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6148    FT2_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6149    CAIRO_FT_OSLIBS=''
6150    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6151    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6152    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6153    AC_SUBST(CAIRO_FT_CFLAGS)
6156 dnl ========================================================
6157 dnl Installer
6158 dnl ========================================================
6159 dnl Abort Windows build if the required major version and
6160 dnl minimum minor version of Unicode NSIS isn't in the path
6161 dnl (unless in case of cross compiling, for which Unicode
6162 dnl is not yet sufficient).
6163 if test "$OS_ARCH" = "WINNT"; then
6164     REQ_NSIS_MAJOR_VER=2
6165     MIN_NSIS_MINOR_VER=46
6166     MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensisu-2.46 makensis)
6167     if test -n "$MAKENSISU" -a "$MAKENSISU" != ":"; then
6168       AC_MSG_RESULT([yes])
6169       changequote(,)
6170       MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\).*\-Unicode$/\1/g'`
6171       changequote([,])
6172       if test ! "$MAKENSISU_VER" = ""; then
6173           MAKENSISU_MAJOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $1 }'`
6174           MAKENSISU_MINOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $2 }'`
6175       fi
6176       AC_MSG_CHECKING([for Unicode NSIS with major version == $REQ_NSIS_MAJOR_VER and minor version >= $MIN_NSIS_MINOR_VER])
6177       if test "$MAKENSISU_VER" = "" || \
6178          test ! "$MAKENSISU_MAJOR_VER" = "$REQ_NSIS_MAJOR_VER" -o \
6179               ! "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER; then
6180           AC_MSG_RESULT([no])
6181           if test -z "$CROSS_COMPILE"; then
6182             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.])
6183           else
6184             MAKENSISU=
6185           fi
6186       fi
6187     elif test -z "$CROSS_COMPILE"; then
6188       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.])
6189     else
6190       MAKENSISU=
6191     fi
6194 dnl ========================================================
6195 dnl Web App Runtime
6196 dnl ========================================================
6197 MOZ_ARG_DISABLE_BOOL(webapp-runtime,
6198 [  --disable-webapp-runtime  Disable Web App Runtime],
6199     MOZ_WEBAPP_RUNTIME=,
6200     MOZ_WEBAPP_RUNTIME=1)
6201 if test "$MOZ_WIDGET_TOOLKIT" != "windows" -a "$MOZ_WIDGET_TOOLKIT" != "cocoa" -a "$MOZ_WIDGET_TOOLKIT" != "gtk2"; then
6202     MOZ_WEBAPP_RUNTIME=
6204 if test "$OS_ARCH" = "WINNT" -a -z "$MAKENSISU" -a -n "$CROSS_COMPILE"; then
6205     MOZ_WEBAPP_RUNTIME=
6207 AC_SUBST(MOZ_WEBAPP_RUNTIME)
6208 if test "$MOZ_WEBAPP_RUNTIME"; then
6209     AC_DEFINE(MOZ_WEBAPP_RUNTIME)
6212 AC_MSG_CHECKING([for tar archiver])
6213 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6214 if test -z "$TAR"; then
6215     AC_MSG_ERROR([no tar archiver found in \$PATH])
6217 AC_MSG_RESULT([$TAR])
6218 AC_SUBST(TAR)
6220 AC_MSG_CHECKING([for wget])
6221 AC_CHECK_PROGS(WGET, wget, "")
6222 AC_MSG_RESULT([$WGET])
6223 AC_SUBST(WGET)
6225 dnl ========================================================
6226 dnl Signing
6227 dnl ========================================================
6229 if test -n "$MOZ_SIGN_CMD"; then
6230     AC_DEFINE(MOZ_SIGNING)
6233 dnl ========================================================
6234 dnl Maintenance Service
6235 dnl ========================================================
6237 MOZ_ARG_ENABLE_BOOL(maintenance-service,
6238 [  --enable-maintenance-service       Enable building of maintenanceservice],
6239     MOZ_MAINTENANCE_SERVICE=1,
6240     MOZ_MAINTENANCE_SERVICE= )
6242 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
6243   if test "$OS_ARCH" = "WINNT"; then
6244     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
6245   else
6246     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
6247   fi
6250 dnl ========================================================
6251 dnl Verify MAR signatures
6252 dnl ========================================================
6254 MOZ_ARG_ENABLE_BOOL(verify-mar,
6255 [  --enable-verify-mar     Enable verifying MAR signatures],
6256     MOZ_VERIFY_MAR_SIGNATURE=1,
6257     MOZ_VERIFY_MAR_SIGNATURE= )
6259 if test -n "$MOZ_VERIFY_MAR_SIGNATURE"; then
6260   if test "$OS_ARCH" = "WINNT"; then
6261     AC_DEFINE(MOZ_VERIFY_MAR_SIGNATURE)
6262   else
6263     AC_MSG_ERROR([Can only build with --enable-verify-mar with a Windows target])
6264   fi
6267 dnl ========================================================
6268 dnl Enable building the signmar program.
6269 dnl This option is much different than the --enable-verify-mar option.
6270 dnl --enable-verify-mar is for enabling the verification check on MAR
6271 dnl files in the updater.  The --enable-signmar option is for building
6272 dnl the signmar program.
6273 dnl ========================================================
6275 MOZ_ARG_ENABLE_BOOL(signmar,
6276 [  --enable-signmar     Enable building the signmar program],
6277     MOZ_ENABLE_SIGNMAR=1,
6278     MOZ_ENABLE_SIGNMAR= )
6280 if test -n "$MOZ_ENABLE_SIGNMAR"; then
6281   AC_DEFINE(MOZ_ENABLE_SIGNMAR)
6284 dnl ========================================================
6285 dnl Updater
6286 dnl ========================================================
6288 MOZ_ARG_DISABLE_BOOL(updater,
6289 [  --disable-updater       Disable building of updater],
6290     MOZ_UPDATER=,
6291     MOZ_UPDATER=1 )
6293 if test -n "$MOZ_UPDATER"; then
6294     AC_DEFINE(MOZ_UPDATER)
6297 # tools/update-packaging is not checked out by default.
6298 MOZ_ARG_ENABLE_BOOL(update-packaging,
6299 [  --enable-update-packaging
6300                           Enable tools/update-packaging],
6301     MOZ_UPDATE_PACKAGING=1,
6302     MOZ_UPDATE_PACKAGING= )
6303 AC_SUBST(MOZ_UPDATE_PACKAGING)
6305 dnl ========================================================
6306 dnl build the tests by default
6307 dnl ========================================================
6308 MOZ_ARG_DISABLE_BOOL(tests,
6309 [  --disable-tests         Do not build test libraries & programs],
6310     ENABLE_TESTS=,
6311     ENABLE_TESTS=1 )
6313 if test -n "$ENABLE_TESTS"; then
6314     GTEST_HAS_RTTI=0
6315     AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0)
6316     AC_SUBST(GTEST_HAS_RTTI)
6317     if test -n "$_WIN32_MSVC"; then
6318           AC_DEFINE_UNQUOTED(_VARIADIC_MAX, 10)
6319     fi
6320     if test "${OS_TARGET}" = "Android"; then
6321         AC_DEFINE(GTEST_OS_LINUX_ANDROID)
6322         AC_DEFINE(GTEST_USE_OWN_TR1_TUPLE)
6323         AC_DEFINE_UNQUOTED(GTEST_HAS_CLONE, 0)
6324         AC_SUBST(GTEST_OS_LINUX_ANDROID)
6325         AC_SUBST(GTEST_USE_OWN_TR1_TUPLE)
6326         AC_SUBST(GTEST_HAS_CLONE)
6327     fi
6330 dnl ========================================================
6331 dnl parental controls (for Windows Vista)
6332 dnl ========================================================
6333 MOZ_ARG_DISABLE_BOOL(parental-controls,
6334 [  --disable-parental-controls
6335                           Do not build parental controls],
6336    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6337    MOZ_DISABLE_PARENTAL_CONTROLS=)
6338 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6339     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6342 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6344 dnl ========================================================
6345 dnl = Disable DOMCrypto
6346 dnl ========================================================
6347 if test -n "$MOZ_DISABLE_CRYPTOLEGACY"; then
6348     AC_DEFINE(MOZ_DISABLE_CRYPTOLEGACY)
6350 AC_SUBST(MOZ_DISABLE_CRYPTOLEGACY)
6352 dnl ========================================================
6353 dnl = Disable libpkix
6354 dnl ========================================================
6355 if test -n "$NSS_NO_LIBPKIX"; then
6356     AC_DEFINE(NSS_NO_LIBPKIX)
6358 AC_SUBST(NSS_NO_LIBPKIX)
6360 dnl ========================================================
6361 dnl = Content process sandboxing
6362 dnl ========================================================
6363 if test -n "$gonkdir"; then
6364     MOZ_CONTENT_SANDBOX=1
6367 MOZ_ARG_ENABLE_BOOL(content-sandbox,
6368 [  --enable-content-sandbox        Enable sandboxing support for content-processes],
6369     MOZ_CONTENT_SANDBOX=1,
6370     MOZ_CONTENT_SANDBOX=)
6372 if test -n "$MOZ_CONTENT_SANDBOX"; then
6373     AC_DEFINE(MOZ_CONTENT_SANDBOX)
6376 AC_SUBST(MOZ_CONTENT_SANDBOX)
6378 MOZ_ARG_ENABLE_BOOL(content-sandbox-reporter,
6379 [ --enable-content-sandbox-reporter        Enable syscall reporter to troubleshoot syscalls denied by the content-processes sandbox],
6380     MOZ_CONTENT_SANDBOX_REPORTER=1,
6381     MOZ_CONTENT_SANDBOX_REPORTER=)
6383 if test -n "$MOZ_CONTENT_SANDBOX_REPORTER"; then
6384     AC_DEFINE(MOZ_CONTENT_SANDBOX_REPORTER)
6387 AC_SUBST(MOZ_CONTENT_SANDBOX_REPORTER)
6389 dnl ========================================================
6390 dnl =
6391 dnl = Module specific options
6392 dnl =
6393 dnl ========================================================
6394 MOZ_ARG_HEADER(Individual module options)
6396 dnl ========================================================
6397 dnl = Disable feed handling components
6398 dnl ========================================================
6399 MOZ_ARG_DISABLE_BOOL(feeds,
6400 [  --disable-feeds         Disable feed handling and processing components],
6401     MOZ_FEEDS=,
6402     MOZ_FEEDS=1 )
6403 if test -n "$MOZ_FEEDS"; then
6404     AC_DEFINE(MOZ_FEEDS)
6405 else
6406     if test "$MOZ_BUILD_APP" = "browser"; then
6407         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6408     fi
6411 dnl ========================================================
6412 dnl Check for sqlite
6413 dnl ========================================================
6415 MOZ_NATIVE_SQLITE=
6416 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6417 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6418 MOZ_NATIVE_SQLITE=1,
6419 MOZ_NATIVE_SQLITE= )
6421 if test -z "$MOZ_NATIVE_SQLITE"
6422 then
6423     SQLITE_CFLAGS=
6424     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
6425 else
6426     dnl ============================
6427     dnl === SQLite Version check ===
6428     dnl ============================
6429     dnl Check to see if the system SQLite package is new enough.
6430     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6432     dnl ==================================
6433     dnl === SQLITE_SECURE_DELETE check ===
6434     dnl ==================================
6435     dnl Check to see if the system SQLite package is compiled with
6436     dnl SQLITE_SECURE_DELETE enabled.
6437     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
6438     _SAVE_CFLAGS="$CFLAGS"
6439     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6440     _SAVE_LIBS="$LIBS"
6441     LIBS="$LIBS $SQLITE_LIBS"
6442     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6443         AC_TRY_RUN([
6444             #include "sqlite3.h"
6446             int main(int argc, char **argv){
6447               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
6448             }],
6449             ac_cv_sqlite_secure_delete=yes,
6450             ac_cv_sqlite_secure_delete=no,
6451             ac_cv_sqlite_secure_delete=no
6452         )
6453     ])
6454     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6455     CFLAGS="$_SAVE_CFLAGS"
6456     LIBS="$_SAVE_LIBS"
6457     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6458         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
6459     fi
6461     dnl ===============================
6462     dnl === SQLITE_THREADSAFE check ===
6463     dnl ===============================
6464     dnl Check to see if the system SQLite package is compiled with
6465     dnl SQLITE_THREADSAFE enabled.
6466     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
6467     _SAVE_CFLAGS="$CFLAGS"
6468     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6469     _SAVE_LIBS="$LIBS"
6470     LIBS="$LIBS $SQLITE_LIBS"
6471     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
6472         AC_TRY_RUN([
6473             #include "sqlite3.h"
6475             int main(int argc, char **argv){
6476               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
6477             }],
6478             ac_cv_sqlite_threadsafe=yes,
6479             ac_cv_sqlite_threadsafe=no,
6480             ac_cv_sqlite_threadsafe=no
6481         )
6482     ])
6483     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
6484     CFLAGS="$_SAVE_CFLAGS"
6485     LIBS="$_SAVE_LIBS"
6486     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
6487         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
6488     fi
6490     dnl ================================
6491     dnl === SQLITE_ENABLE_FTS3 check ===
6492     dnl ================================
6493     dnl check to see if the system SQLite package is compiled with
6494     dnl SQLITE_ENABLE_FTS3 enabled.
6495     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
6496     _SAVE_CFLAGS="$CFLAGS"
6497     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6498     _SAVE_LIBS="$LIBS"
6499     LIBS="$LIBS $SQLITE_LIBS"
6500     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
6501         AC_TRY_RUN([
6502             #include "sqlite3.h"
6504             int main(int argc, char **argv){
6505               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
6506             }],
6507             ac_cv_sqlite_enable_fts3=yes,
6508             ac_cv_sqlite_enable_fts3=no,
6509             ac_cv_sqlite_enable_fts3=no
6510         )
6511     ])
6512     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
6513     CFLAGS="$_SAVE_CFLAGS"
6514     LIBS="$_SAVE_LIBS"
6515     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
6516         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
6517     fi
6519     dnl =========================================
6520     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
6521     dnl =========================================
6522     dnl check to see if the system SQLite package is compiled with
6523     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
6524     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
6525     _SAVE_CFLAGS="$CFLAGS"
6526     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6527     _SAVE_LIBS="$LIBS"
6528     LIBS="$LIBS $SQLITE_LIBS"
6529     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
6530         AC_TRY_RUN([
6531             #include "sqlite3.h"
6533             int main(int argc, char **argv){
6534               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
6535             }],
6536             ac_cv_sqlite_enable_unlock_notify=yes,
6537             ac_cv_sqlite_enable_unlock_notify=no,
6538             ac_cv_sqlite_enable_unlock_notify=no
6539         )
6540     ])
6541     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
6542     CFLAGS="$_SAVE_CFLAGS"
6543     LIBS="$_SAVE_LIBS"
6544     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
6545         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
6546     fi
6549 if test -n "$MOZ_NATIVE_SQLITE"; then
6550     AC_DEFINE(MOZ_NATIVE_SQLITE)
6552 AC_SUBST(MOZ_NATIVE_SQLITE)
6554 dnl ========================================================
6555 dnl = Enable help viewer (off by default)
6556 dnl ========================================================
6557 if test -n "$MOZ_HELP_VIEWER"; then
6558      dnl Do this if defined in confvars.sh
6559      AC_DEFINE(MOZ_HELP_VIEWER)
6562 dnl ========================================================
6563 dnl = Enable safe browsing (anti-phishing)
6564 dnl ========================================================
6565 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6566 [  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation],
6567     MOZ_SAFE_BROWSING=1,
6568     MOZ_SAFE_BROWSING= )
6569 if test -n "$MOZ_SAFE_BROWSING"; then
6570     AC_DEFINE(MOZ_SAFE_BROWSING)
6572 AC_SUBST(MOZ_SAFE_BROWSING)
6574 dnl ========================================================
6575 dnl = Enable url-classifier
6576 dnl ========================================================
6577 dnl Implicitly enabled by default if building with safe-browsing
6578 if test -n "$MOZ_SAFE_BROWSING"; then
6579     MOZ_URL_CLASSIFIER=1
6581 MOZ_ARG_ENABLE_BOOL(url-classifier,
6582 [  --enable-url-classifier Enable url classifier module],
6583     MOZ_URL_CLASSIFIER=1,
6584     MOZ_URL_CLASSIFIER= )
6585 if test -n "$MOZ_URL_CLASSIFIER"; then
6586     AC_DEFINE(MOZ_URL_CLASSIFIER)
6588 AC_SUBST(MOZ_URL_CLASSIFIER)
6590 dnl ========================================================
6591 dnl = Disable zipwriter
6592 dnl ========================================================
6593 MOZ_ARG_DISABLE_BOOL(zipwriter,
6594 [  --disable-zipwriter     Disable zipwriter component],
6595     MOZ_ZIPWRITER=,
6596     MOZ_ZIPWRITER=1 )
6597 AC_SUBST(MOZ_ZIPWRITER)
6599 dnl ========================================================
6600 dnl GL provider
6601 dnl ========================================================
6602 MOZ_GL_PROVIDER=
6603 MOZ_ARG_WITH_STRING(gl-provider,
6604 [  --with-gl-provider=ID
6605                           Set GL provider backend type],
6606 [ val=`echo $withval`
6607     MOZ_GL_PROVIDER="$val"])
6609 if test -n "$MOZ_GL_PROVIDER"; then
6610 MOZ_GL_DEFAULT_PROVIDER=$MOZ_GL_PROVIDER
6611 AC_SUBST(MOZ_GL_PROVIDER)
6612 AC_DEFINE_UNQUOTED(MOZ_GL_PROVIDER, GLContextProvider$MOZ_GL_PROVIDER)
6614 AC_SUBST(MOZ_GL_DEFAULT_PROVIDER)
6615 AC_DEFINE_UNQUOTED(GL_PROVIDER_$MOZ_GL_DEFAULT_PROVIDER)
6617 dnl ========================================================
6618 dnl = faststripe theme
6619 dnl ========================================================
6620 MOZ_ARG_ENABLE_BOOL(faststripe,
6621 [  --enable-faststripe     Use faststripe theme],
6622     MOZ_THEME_FASTSTRIPE=1,
6623     MOZ_THEME_FASTSTRIPE= )
6624 AC_SUBST(MOZ_THEME_FASTSTRIPE)
6626 dnl ========================================================
6627 dnl =
6628 dnl = Feature options that require extra sources to be pulled
6629 dnl =
6630 dnl ========================================================
6631 dnl MOZ_ARG_HEADER(Features that require extra sources)
6633 dnl ========================================================
6634 dnl =
6635 dnl = Runtime debugging and Optimization Options
6636 dnl =
6637 dnl ========================================================
6638 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
6640 dnl ========================================================
6641 dnl enable mobile optimizations
6642 dnl ========================================================
6643 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
6644 [  --enable-mobile-optimize
6645                           Enable mobile optimizations],
6646     MOZ_GFX_OPTIMIZE_MOBILE=1)
6648 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
6650 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
6651     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
6654 dnl ========================================================
6655 dnl = Enable code optimization. ON by default.
6656 dnl ========================================================
6657 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
6658         MOZ_OPTIMIZE_FLAGS="-O"
6661 MOZ_ARG_ENABLE_STRING(optimize,
6662 [  --disable-optimize      Disable compiler optimization
6663   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
6664 [ if test "$enableval" != "no"; then
6665     MOZ_OPTIMIZE=1
6666     if test -n "$enableval" -a "$enableval" != "yes"; then
6667         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
6668         MOZ_OPTIMIZE=2
6669     fi
6670 else
6671     MOZ_OPTIMIZE=
6672 fi ], MOZ_OPTIMIZE=1)
6674 MOZ_SET_FRAMEPTR_FLAGS
6676 if test "$COMPILE_ENVIRONMENT"; then
6677 if test -n "$MOZ_OPTIMIZE"; then
6678     AC_MSG_CHECKING([for valid optimization flags])
6679     _SAVE_CFLAGS=$CFLAGS
6680     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
6681     AC_TRY_COMPILE([#include <stdio.h>],
6682         [printf("Hello World\n");],
6683         _results=yes,
6684         _results=no)
6685     AC_MSG_RESULT([$_results])
6686     if test "$_results" = "no"; then
6687         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
6688     fi
6689     CFLAGS=$_SAVE_CFLAGS
6691 fi # COMPILE_ENVIRONMENT
6693 AC_SUBST(MOZ_OPTIMIZE)
6694 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
6695 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
6696 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
6697 AC_SUBST(MOZ_ALLOW_HEAP_EXECUTE_FLAGS)
6698 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
6699 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
6701 dnl ========================================================
6702 dnl = Enable any treating of compile warnings as errors
6703 dnl ========================================================
6704 MOZ_ARG_ENABLE_BOOL(warnings-as-errors,
6705 [  --enable-warnings-as-errors
6706                           Enable treating of warnings as errors],
6707     MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
6708     MOZ_ENABLE_WARNINGS_AS_ERRORS=)
6709 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
6710    WARNINGS_AS_ERRORS=''
6711 elif test "$GNU_CC"; then
6712     # Prevent the following GCC warnings from being treated as errors:
6713     # -Wuninitialized - too many false positives
6714     # -Wmaybe-uninitialized - too many false positives
6715     # -Wdeprecated-declarations - we don't want our builds held hostage when a
6716     #   platform-specific API becomes deprecated.
6717     MOZ_C_SUPPORTS_WARNING(-W, no-error=uninitialized, ac_c_has_noerror_uninitialized)
6718     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=uninitialized, ac_cxx_has_noerror_uninitialized)
6719     MOZ_C_SUPPORTS_WARNING(-W, no-error=maybe-uninitialized, ac_c_has_noerror_maybe_uninitialized)
6720     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=maybe-uninitialized, ac_cxx_has_noerror_maybe_uninitialized)
6721     MOZ_C_SUPPORTS_WARNING(-W, no-error=deprecated-declarations, ac_c_has_noerror_deprecated_declarations)
6722     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=deprecated-declarations, ac_cxx_has_noerror_deprecated_declarations)
6725 dnl ========================================================
6726 dnl = Disable runtime logging checks
6727 dnl ========================================================
6728 MOZ_ARG_DISABLE_BOOL(logging,
6729 [  --disable-logging       Disable logging facilities],
6730     NS_DISABLE_LOGGING=1,
6731     NS_DISABLE_LOGGING= )
6732 if test "$NS_DISABLE_LOGGING"; then
6733     AC_DEFINE(NS_DISABLE_LOGGING)
6734 else
6735     AC_DEFINE(MOZ_LOGGING)
6738 dnl ========================================================
6739 dnl = This will enable logging of addref, release, ctor, dtor.
6740 dnl ========================================================
6741 _ENABLE_LOGREFCNT=42
6742 MOZ_ARG_ENABLE_BOOL(logrefcnt,
6743 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
6744     _ENABLE_LOGREFCNT=1,
6745     _ENABLE_LOGREFCNT= )
6746 if test "$_ENABLE_LOGREFCNT" = "1"; then
6747     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
6748 elif test -z "$_ENABLE_LOGREFCNT"; then
6749     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
6752 dnl ========================================================
6753 dnl moz_dump_painting
6754 dnl ========================================================
6755 MOZ_ARG_ENABLE_BOOL(dump-painting,
6756 [  --enable-dump-painting          Enable paint debugging.],
6757     MOZ_DUMP_PAINTING=1,
6758     MOZ_DUMP_PAINTING= )
6759 if test -n "$MOZ_DUMP_PAINTING"; then
6760     AC_DEFINE(MOZ_DUMP_PAINTING)
6761     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
6763 if test -n "$MOZ_DEBUG"; then
6764     AC_DEFINE(MOZ_DUMP_PAINTING)
6767 dnl ========================================================
6768 dnl = Enable trace malloc
6769 dnl ========================================================
6770 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
6771 MOZ_ARG_ENABLE_BOOL(trace-malloc,
6772 [  --enable-trace-malloc   Enable malloc tracing; also disables DMD and jemalloc],
6773     NS_TRACE_MALLOC=1,
6774     NS_TRACE_MALLOC= )
6775 if test "$NS_TRACE_MALLOC"; then
6776   # Please, Mr. Linker Man, don't take away our symbol names
6777   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
6778   AC_DEFINE(NS_TRACE_MALLOC)
6780 AC_SUBST(NS_TRACE_MALLOC)
6782 dnl ========================================================
6783 dnl = Enable DMD
6784 dnl ========================================================
6786 MOZ_ARG_ENABLE_BOOL(dmd,
6787 [  --enable-dmd            Enable DMD; also enables jemalloc and replace-malloc],
6788     MOZ_DMD=1,
6789     MOZ_DMD= )
6791 dnl The two options are conflicting. Fails the configure to alert the user.
6792 if test "$NS_TRACE_MALLOC" -a "$MOZ_DMD"; then
6793     AC_MSG_ERROR([--enable-trace-malloc and --enable-dmd are conflicting options])
6796 if test "$MOZ_DMD"; then
6797     AC_DEFINE(MOZ_DMD)
6799     if test "${CPU_ARCH}" = "arm"; then
6800         CFLAGS="$CFLAGS -funwind-tables"
6801         CXXFLAGS="$CXXFLAGS -funwind-tables"
6802     fi
6804     MOZ_MEMORY=1                        # DMD enables jemalloc
6805     MOZ_REPLACE_MALLOC=1                # DMD enables replace-malloc
6807 AC_SUBST(MOZ_DMD)
6809 dnl ========================================================
6810 dnl = Enable jemalloc
6811 dnl ========================================================
6812 MOZ_ARG_ENABLE_BOOL(jemalloc,
6813 [  --enable-jemalloc       Replace memory allocator with jemalloc],
6814     MOZ_MEMORY=1,
6815     MOZ_MEMORY=)
6817 if test "$NS_TRACE_MALLOC"; then
6818     MOZ_MEMORY=
6821 if test "${OS_TARGET}" = "Android"; then
6822   dnl On Android, we use WRAP_LDFLAGS to link everything to mozglue
6823   :
6824 elif test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "OS2"; then
6825   dnl On Windows, OSX and OS2, we want to link all our binaries against mozglue
6826   if test -z "$GNU_CC"; then
6827     MOZ_GLUE_LDFLAGS='$(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
6828   else
6829     MOZ_GLUE_LDFLAGS='-L$(LIBXUL_DIST)/lib $(call EXPAND_LIBNAME,mozglue)'
6830   fi
6831 else
6832   dnl On other Unix systems, we only want to link executables against mozglue
6833   MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
6834   dnl On other Unix systems, where mozglue is a static library, jemalloc is
6835   dnl separated for the SDK, so we need to add it here.
6836   if test "$MOZ_MEMORY" = 1 -o \( "$LIBXUL_SDK" -a -f "$LIBXUL_SDK/lib/${LIB_PREFIX}memory.${LIB_SUFFIX}" \); then
6837     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib)'
6838   fi
6839   MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(MKSHLIB_UNFORCE_ALL)'
6840   if test -n "$GNU_CC"; then
6841     dnl And we need mozglue symbols to be exported.
6842     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
6843   fi
6844   if test "$MOZ_LINKER" = 1; then
6845     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS $MOZ_ZLIB_LIBS"
6846   fi
6849 dnl ========================================================
6850 dnl = Enable dynamic replacement of malloc implementation
6851 dnl ========================================================
6852 MOZ_ARG_ENABLE_BOOL(replace-malloc,
6853 [  --enable-replace-malloc   Enable ability to dynamically replace the malloc implementation],
6854     MOZ_REPLACE_MALLOC=1,
6855     MOZ_REPLACE_MALLOC= )
6857 dnl The two options are conflicting. Fails the configure to alert the user.
6858 if test "$NS_TRACE_MALLOC" -a "$MOZ_REPLACE_MALLOC"; then
6859     AC_MSG_ERROR([--enable-trace-malloc and --enable-replace-malloc are conflicting options])
6862 if test -n "$MOZ_REPLACE_MALLOC" -a -z "$MOZ_MEMORY"; then
6863     dnl We don't want to enable jemalloc unconditionally because it may be a
6864     dnl deliberate choice not to enable it (bug 702250, for instance)
6865     AC_MSG_ERROR([--enable-replace-malloc requires --enable-jemalloc])
6866 elif test -n "$MOZ_REPLACE_MALLOC"; then
6867     MOZ_NATIVE_JEMALLOC=
6869     dnl Replace-malloc Mac linkage quirks
6870     if test -n "$MACOSX_DEPLOYMENT_TARGET"; then
6871         AC_CACHE_CHECK([how to do weak dynamic linking],
6872             ac_cv_weak_dynamic_linking,
6873             [echo 'extern void foo() __attribute__((weak_import));int bar() { if (foo) foo(); return 0; }' > conftest.c
6874              if AC_TRY_COMMAND([${CC-cc} -o conftest${DLL_SUFFIX} $CFLAGS -dynamiclib $LDFLAGS -Wl,-U,_foo conftest.c $LIBS 1>&5]) &&
6875                 test -s conftest${DLL_SUFFIX}; then
6876                  dnl There are several ways the linker can put link edit rules in a binary:
6877                  dnl - classic info only (for OSX < 10.6)
6878                  dnl - dyld info only
6879                  dnl - both
6880                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO_ONLY" > /dev/null; then
6881                      _CLASSIC_INFO=
6882                  else
6883                      _CLASSIC_INFO=1
6884                  fi
6885                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO" > /dev/null; then
6886                      _DYLD_INFO=1
6887                  else
6888                      _DYLD_INFO=
6889                  fi
6890                  dnl With classic info, we need to build with -flat_namespace.
6891                  dnl With dyld info, Xcode 4.5 does the right thing without additional flags,
6892                  dnl but Xcode < 4.5 requires a dummy library and -flat_namespace because it
6893                  dnl forgets to set the weak flag in the dyld info.
6894                  dnl See http://glandium.org/blog/?p=2764 for more details.
6895                  dnl
6896                  dnl Values for ac_cv_weak_dynamic_linking, and subsequently
6897                  dnl MOZ_REPLACE_MALLOC_LINKAGE are thus:
6898                  dnl - "flat namespace" when -flat_namespace alone is needed
6899                  dnl - "dummy library" when a dummy library and -flat_namespace are needed
6900                  dnl - "compiler support" when nothing is needed
6901                  if test -n "$_DYLD_INFO" && dyldinfo -bind conftest${DLL_SUFFIX} 2> /dev/null | grep "_foo (weak import)" > /dev/null; then
6902                      if test -n "$_CLASSIC_INFO"; then
6903                          ac_cv_weak_dynamic_linking="flat namespace"
6904                      else
6905                          ac_cv_weak_dynamic_linking="compiler support"
6906                      fi
6907                  else
6908                      if test -n "$_DYLD_INFO"; then
6909                          ac_cv_weak_dynamic_linking="dummy library"
6910                      else
6911                          ac_cv_weak_dynamic_linking="flat namespace"
6912                      fi
6913                  fi
6914              else
6915                  AC_ERROR([couldn't compile a simple C file])
6916              fi
6917              rm -rf conftest*])
6918         MOZ_REPLACE_MALLOC_LINKAGE="$ac_cv_weak_dynamic_linking"
6919     fi
6921 AC_SUBST(MOZ_REPLACE_MALLOC)
6922 AC_SUBST(MOZ_REPLACE_MALLOC_LINKAGE)
6924 dnl ========================================================
6925 dnl = Jemalloc build setup
6926 dnl ========================================================
6927 if test -z "$MOZ_MEMORY"; then
6928   if test -n "$MOZ_JEMALLOC3" -a -z "$MOZ_REPLACE_MALLOC"; then
6929     MOZ_NATIVE_JEMALLOC=1
6930     AC_CHECK_FUNCS(mallctl nallocm,,
6931       [MOZ_NATIVE_JEMALLOC=
6932        break])
6933     if test -n "$MOZ_NATIVE_JEMALLOC"; then
6934       MOZ_MEMORY=1
6935       AC_DEFINE(MOZ_MEMORY)
6936       AC_DEFINE(MOZ_JEMALLOC3)
6937       AC_DEFINE(MOZ_NATIVE_JEMALLOC)
6938     fi
6939   fi
6940   case "${target}" in
6941     *-mingw*)
6942       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
6943         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.])
6944       fi
6945       ;;
6946   esac
6947 else
6948   AC_DEFINE(MOZ_MEMORY)
6949   if test -n "$MOZ_JEMALLOC3"; then
6950     AC_DEFINE(MOZ_JEMALLOC3)
6951   fi
6952   if test "x$MOZ_DEBUG" = "x1"; then
6953     AC_DEFINE(MOZ_MEMORY_DEBUG)
6954   fi
6955   dnl The generic feature tests that determine how to compute ncpus are long and
6956   dnl complicated.  Therefore, simply define special cpp variables for the
6957   dnl platforms we have special knowledge of.
6958   case "${target}" in
6959   *-darwin*)
6960     AC_DEFINE(MOZ_MEMORY_DARWIN)
6961     ;;
6962   *-*freebsd*)
6963     AC_DEFINE(MOZ_MEMORY_BSD)
6964     ;;
6965   *-android*|*-linuxandroid*)
6966     AC_DEFINE(MOZ_MEMORY_LINUX)
6967     AC_DEFINE(MOZ_MEMORY_ANDROID)
6968     if test -z "$gonkdir"; then
6969       _WRAP_MALLOC=1
6970     else
6971       AC_DEFINE(MOZ_MEMORY_GONK)
6972     fi
6973     MOZ_GLUE_LDFLAGS=
6974     ;;
6975   *-*linux*)
6976     AC_DEFINE(MOZ_MEMORY_LINUX)
6977     ;;
6978   *-netbsd*)
6979     AC_DEFINE(MOZ_MEMORY_BSD)
6980     ;;
6981   *-solaris*)
6982     AC_DEFINE(MOZ_MEMORY_SOLARIS)
6983     ;;
6984   *-mingw*)
6985     AC_DEFINE(MOZ_MEMORY_WINDOWS)
6986     if test -z "$MOZ_DEBUG"; then
6987       WIN32_CRT_LIBS="msvcrt.lib msvcprt.lib"
6988     else
6989       WIN32_CRT_LIBS="msvcrtd.lib msvcprtd.lib"
6990     fi
6991     dnl Look for a broken crtdll.obj
6992     WIN32_CRTDLL_FULLPATH=`lib -nologo -list $WIN32_CRT_LIBS | grep crtdll\\.obj`
6993     lib -NOLOGO -OUT:crtdll.obj $WIN32_CRT_LIBS -EXTRACT:$WIN32_CRTDLL_FULLPATH
6994     if grep -q '__imp__\{0,1\}free' crtdll.obj; then
6995       MOZ_GLUE_LDFLAGS='-LIBPATH:$(DIST)/lib -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcrtd -NODEFAULTLIB:msvcprt -NODEFAULTLIB:msvcprtd -DEFAULTLIB:mozcrt'
6996       dnl Also pass this to NSPR/NSS
6997       DLLFLAGS="$DLLFLAGS $MOZ_GLUE_LDFLAGS"
6998     else
6999       DLLFLAGS="$DLLFLAGS -LIBPATH:\$(DIST)/lib -DEFAULTLIB:mozglue"
7000     fi
7001     rm crtdll.obj
7003     export DLLFLAGS
7004     ;;
7005   *)
7006     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
7007     ;;
7008   esac
7009 fi # MOZ_MEMORY
7010 AC_SUBST(MOZ_MEMORY)
7011 AC_SUBST(MOZ_JEMALLOC3)
7012 AC_SUBST(MOZ_NATIVE_JEMALLOC)
7013 AC_SUBST(MOZ_GLUE_LDFLAGS)
7014 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
7015 AC_SUBST(WIN32_CRT_LIBS)
7016 dnl Need to set this for make because NSS doesn't have configure
7017 AC_SUBST(DLLFLAGS)
7019 dnl We need to wrap dlopen and related functions on Android because we use
7020 dnl our own linker.
7021 if test "$OS_TARGET" = Android; then
7022     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
7023     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
7024     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_GetEnv,--wrap=PR_SetEnv"
7025     if test -z "$gonkdir"; then
7026         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork,--wrap=raise"
7027         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"
7028     fi
7029     if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_NUWA_PROCESS"; then
7030         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=pthread_create,--wrap=epoll_wait,--wrap=poll,--wrap=pthread_cond_timedwait,--wrap=__pthread_cond_timedwait,--wrap=pthread_cond_wait,--wrap=epoll_create,--wrap=epoll_ctl,--wrap=close,--wrap=pthread_key_create,--wrap=pthread_key_delete,--wrap=socketpair,--wrap=pthread_self,--wrap=pthread_mutex_lock,--wrap=pthread_join,--wrap=pipe,--wrap=pipe2"
7031     fi
7034 dnl ========================================================
7035 dnl = Use malloc wrapper lib
7036 dnl ========================================================
7037 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
7038 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
7039     _WRAP_MALLOC=1,
7040     _WRAP_MALLOC= )
7042 if test -n "$_WRAP_MALLOC"; then
7043     if test -n "$GNU_CC"; then
7044         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
7045         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
7046         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
7047         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
7048         dnl Wrap operator new and operator delete on Android.
7049         if test "$OS_TARGET" = "Android"; then
7050             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_Znwj,--wrap=_Znaj,--wrap=_ZdlPv,--wrap=_ZdaPv"
7051             dnl Wrap the nothrow variants too.
7052             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_ZnwjRKSt9nothrow_t,--wrap=_ZnajRKSt9nothrow_t,--wrap=_ZdlPvRKSt9nothrow_t,--wrap=_ZdaPvRKSt9nothrow_t"
7053         fi
7054     else
7055         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
7056     fi
7059 dnl ========================================================
7060 dnl = Location of malloc wrapper lib
7061 dnl ========================================================
7062 MOZ_ARG_WITH_STRING(wrap-malloc,
7063 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
7064     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
7066 dnl ========================================================
7067 dnl = Use JS Call tracing
7068 dnl ========================================================
7069 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
7070 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
7071     MOZ_TRACE_JSCALLS=1,
7072     MOZ_TRACE_JSCALLS= )
7073 if test -n "$MOZ_TRACE_JSCALLS"; then
7074     AC_DEFINE(MOZ_TRACE_JSCALLS)
7077 dnl ========================================================
7078 dnl = Use incremental GC
7079 dnl ========================================================
7080 JSGC_INCREMENTAL=1
7081 MOZ_ARG_DISABLE_BOOL(gcincremental,
7082 [  --disable-gcincremental Disable incremental GC],
7083     JSGC_INCREMENTAL= )
7084 if test -n "$JSGC_INCREMENTAL"; then
7085     AC_DEFINE(JSGC_INCREMENTAL)
7088 dnl ========================================================
7089 dnl Zealous JavaScript GC
7090 dnl ========================================================
7091 MOZ_ARG_ENABLE_BOOL(gczeal,
7092 [  --enable-gczeal         Enable zealous JavaScript GCing],
7093     JS_GC_ZEAL=1,
7094     JS_GC_ZEAL= )
7095 if test -n "$JS_GC_ZEAL" -o -n "$MOZ_DEBUG"; then
7096     AC_DEFINE(JS_GC_ZEAL)
7099 dnl ========================================================
7100 dnl JS opt-mode assertions and minidump instrumentation
7101 dnl ========================================================
7102 MOZ_ARG_ENABLE_BOOL(js-diagnostics,
7103 [  --enable-js-diagnostics
7104                           Enable JS diagnostic assertions and breakpad data],
7105     JS_CRASH_DIAGNOSTICS=1,
7106     JS_CRASH_DIAGNOSTICS= )
7107 if test -n "$JS_CRASH_DIAGNOSTICS"; then
7108     AC_DEFINE(JS_CRASH_DIAGNOSTICS)
7111 MOZ_CHECK_CCACHE
7112 MOZ_CHECK_COMPILER_WRAPPER
7114 dnl ========================================================
7115 dnl = Enable static checking using gcc-dehydra
7116 dnl ========================================================
7118 MOZ_ARG_WITH_STRING(static-checking,
7119 [  --with-static-checking=path/to/gcc_dehydra.so
7120                           Enable static checking of code using GCC-dehydra],
7121     DEHYDRA_PATH=$withval,
7122     DEHYDRA_PATH= )
7124 if test -n "$DEHYDRA_PATH"; then
7125     if test ! -f "$DEHYDRA_PATH"; then
7126         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7127     fi
7128     AC_DEFINE(NS_STATIC_CHECKING)
7130 AC_SUBST(DEHYDRA_PATH)
7132 dnl ========================================================
7133 dnl = Enable using the clang plugin to build
7134 dnl ========================================================
7136 MOZ_ARG_ENABLE_BOOL(clang-plugin,
7137 [  --enable-clang-plugin   Enable building with the mozilla clang plugin ],
7138    ENABLE_CLANG_PLUGIN=1,
7139    ENABLE_CLANG_PLUGIN= )
7140 if test -n "$ENABLE_CLANG_PLUGIN"; then
7141     if test -z "$CLANG_CC"; then
7142         AC_MSG_ERROR([Can't use clang plugin without clang.])
7143     fi
7144     AC_DEFINE(MOZ_CLANG_PLUGIN)
7147 AC_SUBST(ENABLE_CLANG_PLUGIN)
7149 dnl ========================================================
7150 dnl = Enable stripping of libs & executables
7151 dnl ========================================================
7152 MOZ_ARG_ENABLE_BOOL(strip,
7153 [  --enable-strip          Enable stripping of libs & executables ],
7154     ENABLE_STRIP=1,
7155     ENABLE_STRIP= )
7157 dnl ========================================================
7158 dnl = Enable stripping of libs & executables when packaging
7159 dnl ========================================================
7160 MOZ_ARG_ENABLE_BOOL(install-strip,
7161 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7162     PKG_SKIP_STRIP= ,
7163     PKG_SKIP_STRIP=1)
7165 dnl ========================================================
7166 dnl = --disable-elf-hack
7167 dnl ========================================================
7169 USE_ELF_HACK=1
7170 MOZ_ARG_DISABLE_BOOL(elf-hack,
7171 [  --disable-elf-hack      Disable elf hacks],
7172     [USE_ELF_HACK=],
7173     [USE_ELF_HACK=F # Force enable elf-hack])
7175 # Disable elf hack for profiling because the built in profiler
7176 # doesn't read the segments properly with elf hack. This is
7177 # temporary and should be fixed soon in the profiler.
7178 if test "$MOZ_PROFILING" = 1; then
7179   if test "$USE_ELF_HACK" = F; then
7180     AC_ERROR([--enable-elf-hack is not compatible with --enable-profiling])
7181   fi
7182   USE_ELF_HACK=
7185 # Only enable elfhack where supported
7186 if test "$USE_ELF_HACK" = 1; then
7187     case "${HOST_OS_ARCH},${OS_ARCH}" in
7188     Linux,Linux)
7189         case "${CPU_ARCH}" in
7190         arm | x86 | x86_64)
7191             USE_ELF_HACK=1
7192             ;;
7193         *)
7194             USE_ELF_HACK=
7195             ;;
7196         esac
7197         ;;
7198     *)
7199         USE_ELF_HACK=
7200         ;;
7201     esac
7204 if test -n "$COMPILE_ENVIRONMENT" -a -n "$USE_ELF_HACK"; then
7205     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
7206     dnl memory addresses it maps to. The result is that by the time elfhack
7207     dnl kicks in, it is not possible to apply relocations because of that,
7208     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
7209     dnl segment. It makes elfhack mostly useless, so considering the problems
7210     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
7211     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
7212     dnl the linker creates PT_GNU_RELRO segments. However, when we do want
7213     dnl elfhack enabled, disable PT_GNU_RELRO instead.
7214     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
7215         LINK_WITH_PT_GNU_RELRO,
7216         [echo "int main() {return 0;}" > conftest.${ac_ext}
7217          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
7218             test -s conftest${ac_exeext}; then
7219             if ${TOOLCHAIN_PREFIX}readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
7220                 LINK_WITH_PT_GNU_RELRO=yes
7221             else
7222                 LINK_WITH_PT_GNU_RELRO=no
7223             fi
7224          else
7225              dnl We really don't expect to get here, but just in case
7226              AC_ERROR([couldn't compile a simple C file])
7227          fi
7228          rm -rf conftest*])
7229     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
7230         if test "$USE_ELF_HACK" = F; then
7231             AC_MSG_CHECKING([for -z norelro option to ld])
7232             _SAVE_LDFLAGS=$LDFLAGS
7233             LDFLAGS="$LDFLAGS -Wl,-z,norelro"
7234             AC_TRY_LINK(,,AC_MSG_RESULT([yes])
7235                         [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,norelro"],
7236                         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.]))
7237             USE_ELF_HACK=1
7238         else
7239             AC_MSG_WARN([Disabling elfhack])
7240             USE_ELF_HACK=
7241         fi
7242     fi
7245 dnl ========================================================
7246 dnl = libstdc++ compatibility hacks
7247 dnl ========================================================
7249 STDCXX_COMPAT=
7250 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
7251 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
7252     STDCXX_COMPAT=1)
7254 if test -n "$STDCXX_COMPAT"; then
7255    eval $(CXX="$CXX" HOST_CXX="$HOST_CXX" $PYTHON $_topsrcdir/build/autoconf/libstdcxx.py)
7256    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
7257    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
7260 dnl ========================================================
7261 dnl =
7262 dnl = Profiling and Instrumenting
7263 dnl =
7264 dnl ========================================================
7265 MOZ_ARG_HEADER(Profiling and Instrumenting)
7267 dnl ========================================================
7268 dnl = Enable runtime visual profiling logger
7269 dnl ========================================================
7270 MOZ_ARG_ENABLE_BOOL(visual-event-tracer,
7271 [  --enable-visual-event-tracer   Enable visual event tracer instrumentation],
7272     MOZ_VISUAL_EVENT_TRACER=1,
7273     MOZ_VISUAL_EVENT_TRACER=)
7274 if test -n "$MOZ_VISUAL_EVENT_TRACER"; then
7275     AC_DEFINE(MOZ_VISUAL_EVENT_TRACER)
7278 dnl ========================================================
7279 dnl Turn on reflow counting
7280 dnl ========================================================
7281 MOZ_ARG_ENABLE_BOOL(reflow-perf,
7282 [  --enable-reflow-perf    Enable reflow performance tracing],
7283     MOZ_REFLOW_PERF=1,
7284     MOZ_REFLOW_PERF= )
7285 if test -n "$MOZ_REFLOW_PERF"; then
7286     AC_DEFINE(MOZ_REFLOW_PERF)
7289 dnl ========================================================
7290 dnl = Enable Radio Interface for B2G (Gonk usually)
7291 dnl ========================================================
7292 MOZ_ARG_ENABLE_BOOL(b2g-ril,
7293 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
7294     MOZ_B2G_RIL=1,
7295     MOZ_B2G_RIL=,
7296     MOZ_B2G_RIL=$_PLATFORM_HAVE_RIL )
7297 if test -n "$MOZ_B2G_RIL"; then
7298     if test -n "$_PLATFORM_HAVE_RIL"; then
7299         AC_DEFINE(MOZ_B2G_RIL)
7300     else
7301         AC_MSG_ERROR([b2g-ril cannot be enabled because target platform doesn't support it.])
7302     fi
7304 AC_SUBST(MOZ_B2G_RIL)
7306 dnl ========================================================
7307 dnl = Enable Radio FM for B2G (Gonk usually)
7308 dnl ========================================================
7309 if test -n "$MOZ_B2G_FM"; then
7310     AC_DEFINE(MOZ_B2G_FM)
7312 AC_SUBST(MOZ_B2G_FM)
7314 dnl ========================================================
7315 dnl = Enable Bluetooth Interface for B2G (Gonk usually)
7316 dnl ========================================================
7317 MOZ_ARG_ENABLE_BOOL(b2g-bt,
7318 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
7319     MOZ_B2G_BT=1,
7320     MOZ_B2G_BT= )
7321 if test -n "$MOZ_B2G_BT"; then
7322     AC_DEFINE(MOZ_B2G_BT)
7324 AC_SUBST(MOZ_B2G_BT)
7325 AC_SUBST(MOZ_B2G_BT_BLUEZ)
7326 AC_SUBST(MOZ_B2G_BT_BLUEDROID)
7328 dnl ========================================================
7329 dnl = Enable NFC Interface for B2G (Gonk usually)
7330 dnl ========================================================
7331 MOZ_ARG_ENABLE_BOOL(nfc,
7332 [  --enable-nfc         Set compile flags necessary for compiling NFC API ],
7333     MOZ_NFC=1,
7334     MOZ_NFC= )
7335 if test -n "$MOZ_NFC"; then
7336    AC_DEFINE(MOZ_NFC)
7338 AC_SUBST(MOZ_NFC)
7340 dnl ========================================================
7341 dnl = Enable Pico Speech Synthesis (Gonk usually)
7342 dnl ========================================================
7343 MOZ_ARG_ENABLE_BOOL(synth-pico,
7344 [  --enable-synth-pico  Set compile flags necessary for compiling Pico Web Speech API ],
7345     MOZ_SYNTH_PICO=1,
7346     MOZ_SYNTH_PICO= )
7347 if test -n "$MOZ_SYNTH_PICO"; then
7348     AC_DEFINE(MOZ_SYNTH_PICO)
7350 AC_SUBST(MOZ_SYNTH_PICO)
7352 dnl ========================================================
7353 dnl = Enable Support for Time Manager API
7354 dnl ========================================================
7355 if test -n "$MOZ_TIME_MANAGER"; then
7356     AC_DEFINE(MOZ_TIME_MANAGER)
7358 AC_SUBST(MOZ_TIME_MANAGER)
7360 dnl ========================================================
7361 dnl = Enable Camera Interface for B2G (Gonk usually)
7362 dnl ========================================================
7363 MOZ_ARG_ENABLE_BOOL(b2g-camera,
7364 [  --enable-b2g-camera      Set compile flags necessary for compiling camera API for B2G ],
7365     MOZ_B2G_CAMERA=1,
7366     MOZ_B2G_CAMERA= )
7367 if test -n "$MOZ_B2G_CAMERA"; then
7368    AC_DEFINE(MOZ_B2G_CAMERA)
7370 AC_SUBST(MOZ_B2G_CAMERA)
7372 dnl ========================================================
7373 dnl = Enable Support B2G-specific changes to the NSS
7374 dnl = certificate trust database.
7375 dnl ========================================================
7376 if test -n "$MOZ_B2G_CERTDATA"; then
7377     AC_DEFINE(MOZ_B2G_CERTDATA)
7379 AC_SUBST(MOZ_B2G_CERTDATA)
7381 dnl ========================================================
7382 dnl = Enable Support for Payment API
7383 dnl ========================================================
7384 if test -n "$MOZ_PAY"; then
7385     AC_DEFINE(MOZ_PAY)
7387 AC_SUBST(MOZ_PAY)
7389 dnl ========================================================
7390 dnl = Enable Browser Support for Activities
7391 dnl ========================================================
7392 if test -n "$MOZ_ACTIVITIES"; then
7393     AC_DEFINE(MOZ_ACTIVITIES)
7395 AC_SUBST(MOZ_ACTIVITIES)
7397 dnl ========================================================
7398 dnl = Enable Support for AudioChannelManager API
7399 dnl ========================================================
7400 if test -n "$MOZ_AUDIO_CHANNEL_MANAGER"; then
7401     AC_DEFINE(MOZ_AUDIO_CHANNEL_MANAGER)
7403 AC_SUBST(MOZ_AUDIO_CHANNEL_MANAGER)
7405 dnl ========================================================
7406 dnl = Support for demangling undefined symbols
7407 dnl ========================================================
7408 if test -z "$SKIP_LIBRARY_CHECKS"; then
7409     AC_LANG_SAVE
7410     AC_LANG_CPLUSPLUS
7411     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7412     AC_LANG_RESTORE
7415 # Demangle only for debug or trace-malloc or DMD builds
7416 MOZ_DEMANGLE_SYMBOLS=
7417 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
7418     MOZ_DEMANGLE_SYMBOLS=1
7419     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7421 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7423 dnl ========================================================
7424 dnl = Support for gcc stack unwinding (from gcc 3.3)
7425 dnl ========================================================
7426 if test -z "$SKIP_LIBRARY_CHECKS"; then
7427     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7430 dnl ========================================================
7431 dnl JIT observers
7432 dnl ========================================================
7434 MOZ_ARG_WITH_STRING(jitreport-granularity,
7435 [  --jitreport-granularity=N
7436                            Default granularity at which to report JIT code
7437                            to external tools
7438                              0 - no info
7439                              1 - code ranges for whole functions only
7440                              2 - per-line information
7441                              3 - per-op information],
7442   JITREPORT_GRANULARITY=$withval,
7443   JITREPORT_GRANULARITY=3)
7445 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
7447 dnl ========================================================
7448 dnl =
7449 dnl = Misc. Options
7450 dnl =
7451 dnl ========================================================
7452 MOZ_ARG_HEADER(Misc. Options)
7454 dnl ========================================================
7455 dnl update xterm title
7456 dnl ========================================================
7457 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7458 [  --enable-xterm-updates  Update XTERM titles with current command.],
7459     MOZ_UPDATE_XTERM=1,
7460     MOZ_UPDATE_XTERM= )
7462 dnl =========================================================
7463 dnl = Chrome format
7464 dnl =========================================================
7465 MOZ_ARG_ENABLE_STRING([chrome-format],
7466 [  --enable-chrome-format=jar|flat|omni
7467                           Select FORMAT of chrome files during packaging],
7468     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7470 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7471     MOZ_CHROME_FILE_FORMAT=jar
7474 if test "$MOZ_CHROME_FILE_FORMAT" = "symlink"; then
7475     AC_MSG_ERROR([--enable-chrome-format=symlink has been deprecated. It is now used by default in $DIST/bin on platforms that support it])
7478 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
7479     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7480     test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
7481     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, or omni])
7484 dnl =========================================================
7485 dnl Omnijar packaging (bug 552121)
7486 dnl =========================================================
7487 dnl Omnijar packaging is compatible with flat packaging.
7488 dnl In unpackaged builds, omnijar looks for files as if
7489 dnl things were flat packaged. After packaging, all files
7490 dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
7491 dnl is set to flat since putting files into jars is only
7492 dnl done during packaging with omnijar.
7493 if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
7494     MOZ_OMNIJAR=1
7495     AC_DEFINE(MOZ_OMNIJAR)
7497 MOZ_PACKAGER_FORMAT="$MOZ_CHROME_FILE_FORMAT"
7498 if test "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2" -o "$MOZ_WIDGET_TOOLKIT" = "android"; then
7499     MOZ_CHROME_FILE_FORMAT=flat
7500 else
7501     MOZ_CHROME_FILE_FORMAT=symlink
7504 if test "$MOZ_WIDGET_TOOLKIT" = "android"; then
7505     dnl Fennec's static resources live in the assets/ folder of the
7506     dnl APK.  Adding a path to the name here works because we only
7507     dnl have one omnijar file in the final package (which is not the
7508     dnl case on desktop), and necessitates some contortions during
7509     dnl packaging so that the resources in the omnijar are considered
7510     dnl as rooted at / and not as rooted at assets/ (which again is
7511     dnl not the case on desktop: there are omnijars rooted at webrtc/,
7512     dnl etc). packager.mk handles changing the rooting of the single
7513     dnl omnijar.
7514     OMNIJAR_NAME=assets/omni.ja
7515 else
7516     OMNIJAR_NAME=omni.ja
7519 AC_SUBST(OMNIJAR_NAME)
7520 AC_SUBST(MOZ_OMNIJAR)
7521 AC_SUBST(MOZ_PACKAGER_FORMAT)
7523 dnl ========================================================
7524 dnl = Define default location for MOZILLA_FIVE_HOME
7525 dnl ========================================================
7526 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7527 [  --with-default-mozilla-five-home
7528                           Set the default value for MOZILLA_FIVE_HOME],
7529 [ val=`echo $withval`
7530   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7532 dnl ========================================================
7533 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7534 dnl ========================================================
7535 MOZ_ARG_WITH_STRING(user-appdir,
7536 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7537 [ val=`echo $withval`
7538 if echo "$val" | grep "\/" >/dev/null; then
7539     AC_MSG_ERROR("Homedir must be single relative path.")
7540 else
7541     MOZ_USER_DIR="$val"
7542 fi])
7544 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7546 dnl ========================================================
7547 dnl = Doxygen configuration
7548 dnl ========================================================
7549 dnl Use commas to specify multiple dirs to this arg
7550 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7551 MOZ_ARG_WITH_STRING(doc-input-dirs,
7552 [  --with-doc-input-dirs=DIRS
7553                           Header/idl dirs to create docs from],
7554 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7555 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7557 dnl Use commas to specify multiple dirs to this arg
7558 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7559 MOZ_ARG_WITH_STRING(doc-include-dirs,
7560 [  --with-doc-include-dirs=DIRS
7561                           Include dirs to preprocess doc headers],
7562 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7563 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7565 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7566 MOZ_ARG_WITH_STRING(doc-output-dir,
7567 [  --with-doc-output-dir=DIR
7568                           Dir to generate docs into],
7569 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7570 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7572 if test -z "$SKIP_COMPILER_CHECKS"; then
7573 dnl ========================================================
7574 dnl =
7575 dnl = Compiler Options
7576 dnl =
7577 dnl ========================================================
7578 MOZ_ARG_HEADER(Compiler Options)
7580 dnl ========================================================
7581 dnl Check for gcc -pipe support
7582 dnl ========================================================
7583 AC_MSG_CHECKING([for -pipe support])
7584 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
7585     dnl Any gcc that supports firefox supports -pipe.
7586     CFLAGS="$CFLAGS -pipe"
7587     CXXFLAGS="$CXXFLAGS -pipe"
7588     AC_MSG_RESULT([yes])
7589 else
7590     AC_MSG_RESULT([no])
7593 dnl ========================================================
7594 dnl Profile guided optimization (gcc checks)
7595 dnl ========================================================
7596 dnl Test for profiling options
7597 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7599 _SAVE_CFLAGS="$CFLAGS"
7600 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
7602 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7603 AC_TRY_COMPILE([], [return 0;],
7604                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7605                  result="yes" ], result="no")
7606 AC_MSG_RESULT([$result])
7608 if test $result = "yes"; then
7609   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7610   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
7611   PROFILE_USE_LDFLAGS="-fprofile-use"
7614 CFLAGS="$_SAVE_CFLAGS"
7616 if test -n "$INTEL_CC"; then
7617   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
7618   PROFILE_GEN_LDFLAGS=
7619   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
7620   PROFILE_USE_LDFLAGS=
7623 dnl Sun Studio on Solaris
7624 if test "$SOLARIS_SUNPRO_CC"; then
7625   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
7626   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
7627   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
7628   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
7631 AC_SUBST(PROFILE_GEN_CFLAGS)
7632 AC_SUBST(PROFILE_GEN_LDFLAGS)
7633 AC_SUBST(PROFILE_USE_CFLAGS)
7634 AC_SUBST(PROFILE_USE_LDFLAGS)
7636 AC_LANG_CPLUSPLUS
7638 dnl ========================================================
7639 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
7640 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
7641 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
7642 dnl ========================================================
7643 _SAVE_CXXFLAGS=$CXXFLAGS
7644 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
7645 AC_CACHE_CHECK(for correct overload resolution with const and templates,
7646     ac_nscap_nonconst_opeq_bug,
7647     [AC_TRY_COMPILE([
7648                       template <class T>
7649                       class Pointer
7650                         {
7651                         public:
7652                           T* myPtr;
7653                         };
7655                       template <class T, class U>
7656                       int operator==(const Pointer<T>& rhs, U* lhs)
7657                         {
7658                           return rhs.myPtr == lhs;
7659                         }
7661                       template <class T, class U>
7662                       int operator==(const Pointer<T>& rhs, const U* lhs)
7663                         {
7664                           return rhs.myPtr == lhs;
7665                         }
7666                     ],
7667                     [
7668                       Pointer<int> foo;
7669                       const int* bar;
7670                       return foo == bar;
7671                     ],
7672                     ac_nscap_nonconst_opeq_bug="no",
7673                     ac_nscap_nonconst_opeq_bug="yes")])
7674 CXXFLAGS="$_SAVE_CXXFLAGS"
7676 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
7677     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
7679 fi # ! SKIP_COMPILER_CHECKS
7681 AC_DEFINE(CPP_THROW_NEW, [throw()])
7682 AC_LANG_C
7684 if test "$COMPILE_ENVIRONMENT"; then
7685 MOZ_EXPAND_LIBS
7686 fi # COMPILE_ENVIRONMENT
7688 dnl ========================================================
7689 dnl =
7690 dnl = Build depencency options
7691 dnl =
7692 dnl ========================================================
7693 MOZ_ARG_HEADER(Build dependencies)
7695 if test "$GNU_CC" -a "$GNU_CXX"; then
7696   _DEPEND_CFLAGS='-MD -MP -MF $(MDDEPDIR)/$(@F).pp'
7697 dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
7698 elif test "$SOLARIS_SUNPRO_CC"; then
7699   _DEPEND_CFLAGS=
7700 else
7701   dnl Don't override this for MSVC
7702   if test -z "$_WIN32_MSVC"; then
7703     _USE_CPP_INCLUDE_FLAG=
7704     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7705     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7706   else
7707     echo '#include <stdio.h>' > dummy-hello.c
7708     changequote(,)
7709     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
7710     changequote([,])
7711     if test -z "$CL_INCLUDES_PREFIX"; then
7712         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
7713     fi
7714     AC_SUBST(CL_INCLUDES_PREFIX)
7715     rm -f dummy-hello.c
7716   fi
7719 dnl ========================================================
7720 dnl =
7721 dnl = Static Build Options
7722 dnl =
7723 dnl ========================================================
7724 MOZ_ARG_HEADER(Static build options)
7726 if test -n "$JS_SHARED_LIBRARY"; then
7727   MOZ_JS_LIBS="$MOZ_JS_SHARED_LIBS"
7728 else
7729   MOZ_JS_LIBS="$MOZ_JS_STATIC_LIBS"
7730   AC_DEFINE(MOZ_STATIC_JS)
7732 AC_SUBST(JS_SHARED_LIBRARY)
7734 AC_SUBST(LIBXUL_LIBS)
7735 XPCOM_LIBS="$LIBXUL_LIBS"
7737 if test "$OS_ARCH" = "WINNT"; then
7738   GKMEDIAS_SHARED_LIBRARY=1
7740 AC_SUBST(GKMEDIAS_SHARED_LIBRARY)
7742 if test -z "$MOZ_NATIVE_ZLIB"; then
7743 if test -n "$JS_SHARED_LIBRARY" -o "$GKMEDIAS_SHARED_LIBRARY"; then
7744   ZLIB_IN_MOZGLUE=1
7745   AC_DEFINE(ZLIB_IN_MOZGLUE)
7749 AC_SUBST(ZLIB_IN_MOZGLUE)
7751 dnl ========================================================
7752 dnl =
7753 dnl = Standalone module options
7754 dnl =
7755 dnl ========================================================
7756 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
7758 dnl Check for GLib.
7759 dnl ========================================================
7761 if test -z "$SKIP_PATH_CHECKS"; then
7762 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
7763     if test "$MOZ_ENABLE_GTK2" ; then
7764         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
7765     fi
7769 if test -z "${GLIB_GMODULE_LIBS}" \
7770    -a -n "${GLIB_CONFIG}"\
7771     -a "${GLIB_CONFIG}" != no\
7772 ; then
7773     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
7776 AC_SUBST(GLIB_CFLAGS)
7777 AC_SUBST(GLIB_LIBS)
7778 AC_SUBST(GLIB_GMODULE_LIBS)
7780 dnl ========================================================
7781 dnl Graphics checks.
7782 dnl ========================================================
7784 if test "${OS_TARGET}" = "WINNT"; then
7785   if $PERL -e "exit($MOZ_WINSDK_MAXVER < 0x06020000)"; then
7786     MOZ_ENABLE_DIRECT2D1_1=1
7787     AC_SUBST(MOZ_ENABLE_DIRECT2D1_1)
7788   fi
7791 if test "${OS_TARGET}" = "WINNT" -o \
7792         "${OS_ARCH}" = "Darwin" -o \
7793         "${MOZ_WIDGET_TOOLKIT}" = "android" -o \
7794         "${MOZ_WIDGET_TOOLKIT}" = "gonk" -o \
7795         "${MOZ_WIDGET_TOOLKIT}" = "gtk2" -o \
7796         "${MOZ_WIDGET_TOOLKIT}" = "gtk3"; then
7797     case "${target_cpu}" in
7798     i*86*|x86_64|arm)
7799         MOZ_ENABLE_SKIA=1
7800         ;;
7801     *)
7802         MOZ_ENABLE_SKIA=
7803         ;;
7804     esac
7805 else
7806 MOZ_ENABLE_SKIA=
7809 MOZ_ARG_ENABLE_BOOL(skia,
7810 [  --enable-skia   Enable use of Skia],
7811 MOZ_ENABLE_SKIA=1,
7812 MOZ_ENABLE_SKIA=)
7814 if test "$USE_FC_FREETYPE"; then
7815     if test "$COMPILE_ENVIRONMENT"; then
7816         dnl ========================================================
7817         dnl = Check for freetype2 and its functionality
7818         dnl ========================================================
7819         PKG_CHECK_MODULES(FT2, freetype2 >= 6.1.0, _HAVE_FREETYPE2=1, _HAVE_FREETYPE2=)
7821         if test "$_HAVE_FREETYPE2"; then
7822             _SAVE_LIBS="$LIBS"
7823             _SAVE_CFLAGS="$CFLAGS"
7824             LIBS="$LIBS $FT2_LIBS"
7825             CFLAGS="$CFLAGS $FT2_CFLAGS"
7827             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
7828                 ac_cv_member_FT_Bitmap_Size_y_ppem,
7829                 [AC_TRY_COMPILE([#include <ft2build.h>
7830                                  #include FT_FREETYPE_H],
7831                                 [FT_Bitmap_Size s;
7832                                  if (sizeof s.y_ppem) return 0;
7833                                  return 1],
7834                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
7835                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
7836             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
7837                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
7838             else
7839                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
7840             fi
7841             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
7842                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
7843                                [FT_Bitmap_Size structure includes y_ppem field])
7845             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table FT_Select_Size)
7847             LIBS="$_SAVE_LIBS"
7848             CFLAGS="$_SAVE_CFLAGS"
7849         fi
7851         _SAVE_CPPFLAGS="$CPPFLAGS"
7852         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
7853         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
7854             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
7855         CPPFLAGS="$_SAVE_CPPFLAGS"
7856     else
7857         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
7858     fi
7860     PKG_CHECK_MODULES(_FONTCONFIG, fontconfig,
7861     [
7862         if test "$MOZ_PANGO"; then
7863             MOZ_PANGO_CFLAGS="$MOZ_PANGO_CFLAGS $_FONTCONFIG_CFLAGS"
7864             MOZ_PANGO_LIBS="$MOZ_PANGO_LIBS $_FONTCONFIG_LIBS"
7865         else
7866             FT2_CFLAGS="$FT2_CFLAGS $_FONTCONFIG_CFLAGS"
7867             FT2_LIBS="$FT2_LIBS $_FONTCONFIG_LIBS"
7868         fi
7869     ])
7872 dnl ========================================================
7873 dnl Check for pixman and cairo
7874 dnl ========================================================
7876 MOZ_TREE_CAIRO=1
7877 MOZ_ARG_ENABLE_BOOL(system-cairo,
7878 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
7879 MOZ_TREE_CAIRO=,
7880 MOZ_TREE_CAIRO=1 )
7882 MOZ_TREE_PIXMAN=1
7883 MOZ_ARG_ENABLE_BOOL(system-pixman,
7884 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
7885 MOZ_TREE_PIXMAN=,
7886 MOZ_TREE_PIXMAN=force,
7887 MOZ_TREE_PIXMAN=1 )
7889 # System cairo depends on system pixman
7890 if test "$MOZ_TREE_PIXMAN" = "force"; then
7891     if test -z "$MOZ_TREE_CAIRO"; then
7892         AC_MSG_ERROR([--disable-system-pixman is incompatible with --enable-system-cairo.])
7893     else
7894         MOZ_TREE_PIXMAN=1
7895     fi
7896 elif test -z "$MOZ_TREE_CAIRO"; then
7897     MOZ_TREE_PIXMAN=
7900 if test "$MOZ_TREE_PIXMAN"; then
7901     AC_DEFINE(MOZ_TREE_PIXMAN)
7902     MOZ_PIXMAN_CFLAGS=""
7903     MOZ_PIXMAN_LIBS='$(call EXPAND_LIBNAME_PATH,mozlibpixman,$(DEPTH)/gfx/cairo/libpixman/src)'
7904 else
7905     PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.19.2)
7906     MOZ_PIXMAN_CFLAGS="$PIXMAN_CFLAGS"
7907     MOZ_PIXMAN_LIBS="$PIXMAN_LIBS"
7909 AC_SUBST(MOZ_PIXMAN_CFLAGS)
7910 AC_SUBST(MOZ_PIXMAN_LIBS)
7912 # Check for headers defining standard int types.
7913 if test -n "$COMPILE_ENVIRONMENT"; then
7914     MOZ_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
7917 if test "$MOZ_TREE_CAIRO"; then
7918     MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
7919     AC_DEFINE(MOZ_TREE_CAIRO)
7921     # For now we assume that we will have a uint64_t available through
7922     # one of the above headers or mozstdint.h.
7923     AC_DEFINE(HAVE_UINT64_T)
7925     # Define macros for cairo-features.h
7926     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
7927     if test "$MOZ_X11"; then
7928         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
7929         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
7930         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
7931         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
7932         MOZ_ENABLE_CAIRO_FT=1
7933         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
7934     fi
7935     case "$MOZ_WIDGET_TOOLKIT" in
7936       qt)
7937         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
7938         ;;
7939       cocoa | uikit)
7940         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
7941         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
7942         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
7943         ;;
7944       windows)
7945         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
7946         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
7947         if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
7948             WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
7949             WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
7950             MOZ_ENABLE_D2D_SURFACE=1
7951             MOZ_ENABLE_DWRITE_FONT=1
7952         else
7953             WIN32_DWRITE_FONT_FEATURE=
7954             WIN32_D2D_SURFACE_FEATURE=
7955         fi
7957         MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
7959         dnl D3D10 Layers depend on D2D Surfaces.
7960         if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
7961           MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
7962         fi
7963         ;;
7964       os2)
7965         OS2_SURFACE_FEATURE="#define CAIRO_HAS_OS2_SURFACE 1"
7966         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
7967         MOZ_ENABLE_CAIRO_FT=1
7968         CAIRO_FT_CFLAGS="-I${MZFTCFGFT2}/include"
7969         CAIRO_FT_OSLIBS="-L${MZFTCFGFT2}/lib -lmozft -lmzfntcfg"
7970         ;;
7971     esac
7972     if test "$USE_FC_FREETYPE"; then
7973         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
7974     fi
7975     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
7976     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
7977     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
7978     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
7979     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
7980     AC_SUBST(CAIRO_FT_CFLAGS)
7982     AC_SUBST(PS_SURFACE_FEATURE)
7983     AC_SUBST(PDF_SURFACE_FEATURE)
7984     AC_SUBST(SVG_SURFACE_FEATURE)
7985     AC_SUBST(XLIB_SURFACE_FEATURE)
7986     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
7987     AC_SUBST(QUARTZ_SURFACE_FEATURE)
7988     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
7989     AC_SUBST(WIN32_SURFACE_FEATURE)
7990     AC_SUBST(OS2_SURFACE_FEATURE)
7991     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
7992     AC_SUBST(FT_FONT_FEATURE)
7993     AC_SUBST(FC_FONT_FEATURE)
7994     AC_SUBST(WIN32_FONT_FEATURE)
7995     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
7996     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
7997     AC_SUBST(QUARTZ_FONT_FEATURE)
7998     AC_SUBST(PNG_FUNCTIONS_FEATURE)
7999     AC_SUBST(QT_SURFACE_FEATURE)
8000     AC_SUBST(TEE_SURFACE_FEATURE)
8002     MOZ_CAIRO_OSLIBS='${CAIRO_FT_OSLIBS}'
8004     if test "$MOZ_X11"; then
8005         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
8006     fi
8008     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
8009 else
8010     PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION)
8011     MOZ_CAIRO_CFLAGS="$CAIRO_CFLAGS"
8012     MOZ_CAIRO_LIBS="$CAIRO_LIBS"
8013     PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
8014     if test "$MOZ_X11"; then
8015         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
8016         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
8017         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_LIBS"
8018         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
8019     fi
8022 AC_SUBST(MOZ_TREE_CAIRO)
8023 AC_SUBST(MOZ_CAIRO_CFLAGS)
8024 AC_SUBST(MOZ_CAIRO_LIBS)
8025 AC_SUBST(MOZ_CAIRO_OSLIBS)
8026 AC_SUBST(MOZ_TREE_PIXMAN)
8028 dnl ========================================================
8029 dnl Skia 
8030 dnl ========================================================
8031 if test "$MOZ_ENABLE_SKIA"; then
8032   AC_DEFINE(MOZ_ENABLE_SKIA)
8033   AC_DEFINE(USE_SKIA)
8034   if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
8035     AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
8036   elif test "$OS_ARCH" = "WINNT"; then
8037     AC_DEFINE(SKIA_DLL)
8038     AC_DEFINE(GR_DLL)
8039   fi
8041   if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64"; then
8042     MOZ_ENABLE_SKIA_GPU=1
8043     AC_DEFINE(USE_SKIA_GPU)
8044     AC_SUBST(MOZ_ENABLE_SKIA_GPU)
8045   fi
8047 AC_SUBST(MOZ_ENABLE_SKIA)
8049 dnl ========================================================
8050 dnl disable xul
8051 dnl ========================================================
8052 MOZ_ARG_DISABLE_BOOL(xul,
8053 [  --disable-xul           Disable XUL],
8054     MOZ_XUL= )
8055 if test "$MOZ_XUL"; then
8056   AC_DEFINE(MOZ_XUL)
8057 else
8058   dnl remove extensions that require XUL
8059   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/venkman//' -e 's/irc//' -e 's/tasks//'`
8062 AC_SUBST(MOZ_XUL)
8064 dnl ========================================================
8065 dnl disable profile locking
8066 dnl   do no use this in applications that can have more than
8067 dnl   one process accessing the profile directory.
8068 dnl ========================================================
8069 MOZ_ARG_DISABLE_BOOL(profilelocking,
8070 [  --disable-profilelocking
8071                           Disable profile locking],
8072     MOZ_PROFILELOCKING=,
8073     MOZ_PROFILELOCKING=1 )
8074 if test "$MOZ_PROFILELOCKING"; then
8075   AC_DEFINE(MOZ_PROFILELOCKING)
8078 dnl ========================================================
8079 dnl necko configuration options
8080 dnl ========================================================
8083 dnl option to disable various necko protocols
8085 MOZ_ARG_ENABLE_STRING(necko-protocols,
8086 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8087                           Enable/disable specific protocol handlers],
8088 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8089     if test "$option" = "yes" -o "$option" = "all"; then
8090         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8091     elif test "$option" = "no" -o "$option" = "none"; then
8092         NECKO_PROTOCOLS=""
8093     elif test "$option" = "default"; then
8094         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8095     elif test `echo "$option" | grep -c \^-` != 0; then
8096         option=`echo $option | sed 's/^-//'`
8097         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8098     else
8099         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8100     fi
8101 done],
8102     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8103 dnl Remove dupes
8104 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
8105 AC_SUBST_SET(NECKO_PROTOCOLS)
8106 for p in $NECKO_PROTOCOLS; do
8107     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8108     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_PROTOCOL_$p"
8109 done
8112 dnl option to disable necko's wifi scanner
8115 case "$OS_TARGET" in
8116   Android)
8117     if test -n "$gonkdir"; then
8118       NECKO_WIFI=1
8119     fi
8120     ;;
8121   Darwin|SunOS|WINNT)
8122     NECKO_WIFI=1
8123     ;;
8124   Linux)
8125     NECKO_WIFI=1
8126     NECKO_WIFI_DBUS=1
8127     ;;
8128 esac
8130 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8131 [  --disable-necko-wifi    Disable necko wifi scanner],
8132     NECKO_WIFI=,
8133     NECKO_WIFI=1)
8135 if test "$NECKO_WIFI"; then
8136   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
8137     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
8138   fi
8139   AC_DEFINE(NECKO_WIFI)
8140   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
8142 AC_SUBST(NECKO_WIFI)
8143 AC_SUBST(NECKO_WIFI_DBUS)
8146 dnl option to disable cookies
8148 MOZ_ARG_DISABLE_BOOL(cookies,
8149 [  --disable-cookies       Disable cookie support],
8150     NECKO_COOKIES=,
8151     NECKO_COOKIES=1)
8152 AC_SUBST(NECKO_COOKIES)
8153 if test "$NECKO_COOKIES"; then
8154     AC_DEFINE(NECKO_COOKIES)
8155     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
8159 dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
8161 MOZ_ARG_DISABLE_BOOL(ctypes,
8162 [  --disable-ctypes        Disable js-ctypes],
8163     BUILD_CTYPES=,
8164     BUILD_CTYPES=1)
8165 AC_SUBST(BUILD_CTYPES)
8166 if test "$BUILD_CTYPES"; then
8167     AC_DEFINE(BUILD_CTYPES)
8170 dnl Build Places if required
8171 if test "$MOZ_PLACES"; then
8172   AC_DEFINE(MOZ_PLACES)
8175 dnl Build SocialAPI if required
8176 if test "$MOZ_SOCIAL"; then
8177   AC_DEFINE(MOZ_SOCIAL)
8180 dnl Build Common JS modules provided by services.
8181 AC_SUBST(MOZ_SERVICES_COMMON)
8182 if test -n "$MOZ_SERVICES_COMMON"; then
8183   AC_DEFINE(MOZ_SERVICES_COMMON)
8186 dnl Build Services crypto component (used by Sync)
8187 AC_SUBST(MOZ_SERVICES_CRYPTO)
8188 if test -n "$MOZ_SERVICES_CRYPTO"; then
8189   AC_DEFINE(MOZ_SERVICES_CRYPTO)
8192 dnl Build Firefox Health Reporter Service
8193 AC_SUBST(MOZ_SERVICES_HEALTHREPORT)
8194 if test -n "$MOZ_SERVICES_HEALTHREPORT"; then
8195   AC_DEFINE(MOZ_SERVICES_HEALTHREPORT)
8198 dnl Build Services metrics component
8199 AC_SUBST(MOZ_SERVICES_METRICS)
8200 if test -n "$MOZ_SERVICES_METRICS"; then
8201   AC_DEFINE(MOZ_SERVICES_METRICS)
8204 dnl Build Notifications if required
8205 AC_SUBST(MOZ_SERVICES_NOTIFICATIONS)
8206 if test -n "$MOZ_SERVICES_NOTIFICATIONS"; then
8207   AC_DEFINE(MOZ_SERVICES_NOTIFICATIONS)
8210 dnl Build Sync Services if required
8211 AC_SUBST(MOZ_SERVICES_SYNC)
8212 if test -n "$MOZ_SERVICES_SYNC"; then
8213   AC_DEFINE(MOZ_SERVICES_SYNC)
8216 dnl Build Captive Portal Detector if required
8217 AC_SUBST(MOZ_CAPTIVEDETECT)
8218 if test -n "$MOZ_CAPTIVEDETECT"; then
8219   AC_DEFINE(MOZ_CAPTIVEDETECT)
8222 dnl ========================================================
8223 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
8224     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8227 if test "$MOZ_APP_COMPONENT_INCLUDE"; then
8228   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
8231 if test "$MOZ_APP_COMPONENT_MODULES"; then
8232   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_MODULES, $MOZ_APP_COMPONENT_MODULES)
8235 dnl ========================================================
8236 dnl =
8237 dnl = Maintainer debug option (no --enable equivalent)
8238 dnl =
8239 dnl ========================================================
8241 AC_SUBST(AR)
8242 AC_SUBST(AR_FLAGS)
8243 AC_SUBST(AR_LIST)
8244 AC_SUBST(AR_EXTRACT)
8245 AC_SUBST(AR_DELETE)
8246 AC_SUBST(AS)
8247 AC_SUBST(ASFLAGS)
8248 AC_SUBST(AS_DASH_C_FLAG)
8249 AC_SUBST(LD)
8250 AC_SUBST(RC)
8251 AC_SUBST(RCFLAGS)
8252 AC_SUBST(MC)
8253 AC_SUBST(WINDRES)
8254 AC_SUBST(IMPLIB)
8255 AC_SUBST(FILTER)
8256 AC_SUBST(BIN_FLAGS)
8257 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8258 AC_SUBST(MOZ_UPDATE_XTERM)
8259 AC_SUBST(MOZ_AUTH_EXTENSION)
8260 AC_SUBST(MOZ_PERMISSIONS)
8261 AC_SUBST(MOZ_PREF_EXTENSIONS)
8262 AC_SUBST(MOZ_JS_LIBS)
8263 AC_SUBST(MOZ_DEBUG)
8264 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8265 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8266 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8267 AC_SUBST(MOZ_DEBUG_FLAGS)
8268 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8269 AC_SUBST(WARNINGS_AS_ERRORS)
8270 AC_SUBST(MOZ_EXTENSIONS)
8271 AC_SUBST(MOZ_JSDEBUGGER)
8272 AC_SUBST(MOZ_ENABLE_PROFILER_SPS)
8273 AC_SUBST(MOZ_JPROF)
8274 AC_SUBST(MOZ_SHARK)
8275 AC_SUBST(MOZ_INSTRUMENTS)
8276 AC_SUBST(MOZ_CALLGRIND)
8277 AC_SUBST(MOZ_VTUNE)
8278 AC_SUBST(MOZ_PROFILING)
8279 AC_SUBST(LIBICONV)
8280 AC_SUBST(MOZ_PLACES)
8281 AC_SUBST(MOZ_SOCIAL)
8282 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8283 AC_SUBST(MOZ_FEEDS)
8284 AC_SUBST(NS_PRINTING)
8285 AC_SUBST(MOZ_WEBGL)
8286 AC_SUBST(MOZ_HELP_VIEWER)
8287 AC_SUBST(TOOLCHAIN_PREFIX)
8289 AC_SUBST(JAVA)
8290 AC_SUBST(JAVAC)
8291 AC_SUBST(JAVAH)
8292 AC_SUBST(JAR)
8293 AC_SUBST(JARSIGNER)
8294 AC_SUBST(KEYTOOL)
8296 AC_SUBST(MOZ_PROFILELOCKING)
8298 AC_SUBST(ENABLE_TESTS)
8299 AC_SUBST(ENABLE_MARIONETTE)
8300 AC_SUBST(IBMBIDI)
8301 AC_SUBST(MOZ_UNIVERSALCHARDET)
8302 AC_SUBST(ACCESSIBILITY)
8303 AC_SUBST(MOZ_SPELLCHECK)
8304 AC_SUBST(MOZ_ANDROID_OMTC)
8305 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
8306 AC_SUBST(MOZ_CRASHREPORTER)
8307 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
8308 AC_SUBST(MOZ_CRASHREPORTER_UPLOAD_FULL_SYMBOLS)
8309 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
8310 AC_SUBST(MOZ_STUB_INSTALLER)
8311 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
8312 AC_SUBST(MOZ_ENABLE_SIGNMAR)
8313 AC_SUBST(MOZ_UPDATER)
8314 AC_SUBST(MOZ_ANGLE_RENDERER)
8315 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
8316 AC_SUBST(MOZ_DIRECTX_SDK_CPU_SUFFIX)
8317 AC_SUBST(MOZ_D3DX9_VERSION)
8318 AC_SUBST(MOZ_D3DCOMPILER_CAB)
8319 AC_SUBST(MOZ_D3DCOMPILER_DLL)
8320 AC_SUBST(MOZ_METRO)
8322 AC_SUBST(MOZ_ANDROID_HISTORY)
8323 AC_SUBST(MOZ_WEBSMS_BACKEND)
8324 AC_SUBST(MOZ_ANDROID_BEAM)
8325 AC_SUBST(MOZ_DISABLE_GECKOVIEW)
8326 AC_SUBST(ENABLE_STRIP)
8327 AC_SUBST(PKG_SKIP_STRIP)
8328 AC_SUBST(STRIP_FLAGS)
8329 AC_SUBST(USE_ELF_HACK)
8330 AC_SUBST(INCREMENTAL_LINKER)
8331 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8332 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8334 AC_SUBST(MOZ_FIX_LINK_PATHS)
8335 AC_SUBST(XPCOM_LIBS)
8336 AC_SUBST(XPCOM_FROZEN_LDOPTS)
8337 AC_SUBST(XPCOM_GLUE_LDOPTS)
8338 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
8339 AC_SUBST(XPCOM_STATICRUNTIME_GLUE_LDOPTS)
8340 AC_SUBST(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS)
8342 AC_SUBST(USE_DEPENDENT_LIBS)
8344 AC_SUBST(MOZ_BUILD_ROOT)
8345 AC_SUBST(MOZ_OS2_TOOLS)
8347 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8348 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8349 AC_SUBST(MOZ_LINKER_EXTRACT)
8351 AC_SUBST(MOZ_JSDOWNLOADS)
8352 if test -n "$MOZ_JSDOWNLOADS"; then
8353   AC_DEFINE(MOZ_JSDOWNLOADS)
8356 dnl ========================================================
8357 dnl = Mac bundle name prefix
8358 dnl ========================================================
8359 MOZ_ARG_WITH_STRING(macbundlename-prefix,
8360 [  --with-macbundlename-prefix=prefix
8361                           Prefix for MOZ_MACBUNDLE_NAME],
8362 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
8364 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
8365 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
8366   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
8369 if test "$MOZ_DEBUG"; then
8370   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
8371 else
8372   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
8374 AC_SUBST(MOZ_MACBUNDLE_NAME)
8376 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
8377 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr '[A-Z]' '[a-z]'`
8378 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
8379 if test "$MOZ_DEBUG"; then
8380   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
8383 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
8384 AC_SUBST(MOZ_MACBUNDLE_ID)
8386 dnl ========================================================
8387 dnl = Child Process Name for IPC
8388 dnl ========================================================
8389 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
8390   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
8391 else
8392   # We want to let Android unpack the file at install time, but it only does
8393   # so if the file is named libsomething.so. The lib/ path is also required
8394   # because the unpacked file will be under the lib/ subdirectory and will
8395   # need to be executed from that path.
8396   MOZ_CHILD_PROCESS_NAME="lib/libplugin-container.so"
8398 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
8400 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
8401 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
8403 # The following variables are available to branding and application
8404 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
8405 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
8406 # impacts profile location and user-visible fields.
8407 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
8408 # versions of a given application (e.g. Aurora and Firefox both use
8409 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
8410 # for application.ini's "Name" field, which controls profile location in
8411 # the absence of a "Profile" field (see below), and various system
8412 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
8413 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
8414 # Mac Bundle name, Updater, Installer), it is typically used for nightly
8415 # builds (e.g. Aurora for Firefox).
8416 # - MOZ_APP_VERSION: Defines the application version number.
8417 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
8418 # defaults to a lowercase form of MOZ_APP_BASENAME.
8419 # - MOZ_APP_PROFILE: When set, used for application.ini's
8420 # "Profile" field, which controls profile location.
8421 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
8422 # crash reporter server url.
8423 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
8424 # - MOZ_EXTENSION_MANAGER: When set, enabled extension manager.
8426 if test -z "$MOZ_APP_NAME"; then
8427    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
8430 # For extensions and langpacks, we require a max version that is compatible
8431 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
8432 # 10.0a1 and 10.0a2 aren't affected
8433 # 10.0 becomes 10.0.*
8434 # 10.0.1 becomes 10.0.*
8435 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
8436 if test -z "$IS_ALPHA"; then
8437   changequote(,)
8438   MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*.[0-9]*\).*|\1|"`.*
8439   changequote([,])
8440 else
8441   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
8444 MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"}
8445 AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION")
8446 AC_DEFINE_UNQUOTED(MOZ_B2G_OS_NAME,"$MOZ_B2G_OS_NAME")
8448 AC_SUBST(MOZ_APP_NAME)
8449 AC_SUBST(MOZ_APP_DISPLAYNAME)
8450 AC_SUBST(MOZ_APP_BASENAME)
8451 AC_SUBST(MOZ_APP_VENDOR)
8452 AC_SUBST(MOZ_APP_PROFILE)
8453 AC_SUBST(MOZ_APP_ID)
8454 AC_SUBST(MAR_CHANNEL_ID)
8455 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
8456 AC_SUBST(MOZ_PROFILE_MIGRATOR)
8457 AC_SUBST(MOZ_EXTENSION_MANAGER)
8458 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
8459 AC_SUBST(MOZ_APP_UA_NAME)
8460 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
8461 AC_SUBST(MOZ_APP_VERSION)
8462 AC_SUBST(MOZ_APP_MAXVERSION)
8463 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
8464 AC_SUBST(FIREFOX_VERSION)
8465 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
8466 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
8467   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
8470 AC_SUBST(MOZ_APP_STATIC_INI)
8472 AC_SUBST(MOZ_PKG_SPECIAL)
8474 AC_SUBST(MOZILLA_OFFICIAL)
8476 AC_DEFINE_UNQUOTED(MOZ_TELEMETRY_DISPLAY_REV, 2)
8477 AC_SUBST(MOZ_TELEMETRY_DISPLAY_REV)
8479 if test "$MOZ_TELEMETRY_REPORTING"; then
8480     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
8482     # Enable Telemetry by default for nightly and aurora channels
8483     if test -z "$RELEASE_BUILD"; then
8484       AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
8485     fi
8488 dnl If we have any service that uploads data (and requires data submission
8489 dnl policy alert), set MOZ_DATA_REPORTING.
8490 dnl We need SUBST for build system and DEFINE for xul preprocessor.
8491 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"; then
8492   MOZ_DATA_REPORTING=1
8493   AC_DEFINE(MOZ_DATA_REPORTING)
8494   AC_SUBST(MOZ_DATA_REPORTING)
8497 dnl win32 options
8498 AC_SUBST(MOZ_BROWSE_INFO)
8499 AC_SUBST(MOZ_TOOLS_DIR)
8500 AC_SUBST(WIN32_REDIST_DIR)
8501 AC_SUBST(MAKENSISU)
8503 dnl Echo the CFLAGS to remove extra whitespace.
8504 CFLAGS=`echo \
8505         $_WARNINGS_CFLAGS \
8506         $CFLAGS`
8508 CXXFLAGS=`echo \
8509         $_WARNINGS_CXXFLAGS \
8510         $CXXFLAGS`
8512 COMPILE_CFLAGS=`echo \
8513     $_DEFINES_CFLAGS \
8514         $_DEPEND_CFLAGS \
8515     $COMPILE_CFLAGS`
8517 COMPILE_CXXFLAGS=`echo \
8518     $_DEFINES_CXXFLAGS \
8519         $_DEPEND_CFLAGS \
8520     $COMPILE_CXXFLAGS`
8522 HOST_CFLAGS=`echo \
8523     $HOST_CFLAGS \
8524     $_DEPEND_CFLAGS`
8526 HOST_CXXFLAGS=`echo \
8527     $HOST_CXXFLAGS \
8528     $_DEPEND_CFLAGS`
8530 AC_SUBST(SYSTEM_LIBXUL)
8531 AC_SUBST(MOZ_NATIVE_JPEG)
8532 AC_SUBST(MOZ_NATIVE_PNG)
8533 AC_SUBST(MOZ_NATIVE_BZ2)
8535 AC_SUBST(MOZ_JPEG_CFLAGS)
8536 AC_SUBST(MOZ_JPEG_LIBS)
8537 AC_SUBST(MOZ_BZ2_CFLAGS)
8538 AC_SUBST(MOZ_BZ2_LIBS)
8539 AC_SUBST(MOZ_PNG_CFLAGS)
8540 AC_SUBST(MOZ_PNG_LIBS)
8542 if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_NUWA_PROCESS"; then
8543     export MOZ_NUWA_PROCESS
8544     AC_DEFINE(MOZ_NUWA_PROCESS)
8546 AC_SUBST(MOZ_NUWA_PROCESS)
8548 AC_SUBST(NSPR_CFLAGS)
8549 AC_SUBST(NSPR_LIBS)
8550 AC_SUBST(MOZ_NATIVE_NSPR)
8552 AC_SUBST(NSS_CFLAGS)
8553 AC_SUBST(NSS_LIBS)
8554 AC_SUBST(MOZ_NATIVE_NSS)
8555 AC_SUBST(NSS_DISABLE_DBM)
8557 OS_CFLAGS="$CFLAGS"
8558 OS_CXXFLAGS="$CXXFLAGS"
8559 OS_CPPFLAGS="$CPPFLAGS"
8560 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
8561 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
8562 OS_LDFLAGS="$LDFLAGS"
8563 OS_LIBS="$LIBS"
8564 AC_SUBST(OS_CFLAGS)
8565 AC_SUBST(OS_CXXFLAGS)
8566 AC_SUBST(OS_CPPFLAGS)
8567 AC_SUBST(OS_COMPILE_CFLAGS)
8568 AC_SUBST(OS_COMPILE_CXXFLAGS)
8569 AC_SUBST(OS_LDFLAGS)
8570 AC_SUBST(OS_LIBS)
8571 AC_SUBST(CROSS_COMPILE)
8572 AC_SUBST(WCHAR_CFLAGS)
8574 AC_SUBST(HOST_CC)
8575 AC_SUBST(HOST_CXX)
8576 AC_SUBST(HOST_CFLAGS)
8577 AC_SUBST(HOST_CXXFLAGS)
8578 AC_SUBST(HOST_LDFLAGS)
8579 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8580 AC_SUBST(HOST_AR)
8581 AC_SUBST(HOST_AR_FLAGS)
8582 AC_SUBST(HOST_LD)
8583 AC_SUBST(HOST_RANLIB)
8584 AC_SUBST(HOST_NSPR_MDCPUCFG)
8585 AC_SUBST(HOST_BIN_SUFFIX)
8586 AC_SUBST(HOST_OS_ARCH)
8588 AC_SUBST(TARGET_CPU)
8589 AC_SUBST(TARGET_VENDOR)
8590 AC_SUBST(TARGET_OS)
8591 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8592 AC_SUBST(TARGET_MD_ARCH)
8593 AC_SUBST(TARGET_XPCOM_ABI)
8594 AC_SUBST(OS_TARGET)
8595 AC_SUBST(OS_ARCH)
8596 AC_SUBST(OS_RELEASE)
8597 AC_SUBST(OS_TEST)
8598 AC_SUBST(CPU_ARCH)
8599 AC_SUBST(INTEL_ARCHITECTURE)
8600 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
8601 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
8603 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
8605 AC_SUBST(WRAP_LDFLAGS)
8606 AC_SUBST(MKSHLIB)
8607 AC_SUBST(MKCSHLIB)
8608 AC_SUBST(MKSHLIB_FORCE_ALL)
8609 AC_SUBST(MKSHLIB_UNFORCE_ALL)
8610 AC_SUBST(DSO_CFLAGS)
8611 AC_SUBST(DSO_PIC_CFLAGS)
8612 AC_SUBST(DSO_LDOPTS)
8613 AC_SUBST(LIB_PREFIX)
8614 AC_SUBST(DLL_PREFIX)
8615 AC_SUBST(DLL_SUFFIX)
8616 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
8617 AC_SUBST(LIB_SUFFIX)
8618 AC_SUBST(OBJ_SUFFIX)
8619 AC_SUBST(BIN_SUFFIX)
8620 AC_SUBST(ASM_SUFFIX)
8621 AC_SUBST(IMPORT_LIB_SUFFIX)
8622 AC_SUBST(USE_N32)
8623 AC_SUBST(CC_VERSION)
8624 AC_SUBST(CXX_VERSION)
8625 AC_SUBST(MSMANIFEST_TOOL)
8626 AC_SUBST(NS_ENABLE_TSF)
8627 AC_SUBST(MOZ_NSS_PATCH)
8628 AC_SUBST(MOZ_APP_COMPONENT_LIBS)
8629 AC_SUBST(MOZ_APP_EXTRA_LIBS)
8631 AC_SUBST(MOZ_WAVE)
8632 AC_SUBST(MOZ_VORBIS)
8633 AC_SUBST(MOZ_TREMOR)
8634 AC_SUBST(MOZ_OPUS)
8635 AC_SUBST(MOZ_WEBM)
8636 AC_SUBST(MOZ_WMF)
8637 AC_SUBST(MOZ_FMP4)
8638 AC_SUBST(MOZ_DIRECTSHOW)
8639 AC_SUBST(MOZ_MEDIA_PLUGINS)
8640 AC_SUBST(MOZ_APPLEMEDIA)
8641 AC_SUBST(MOZ_OMX_PLUGIN)
8642 AC_SUBST(MOZ_VP8_ERROR_CONCEALMENT)
8643 AC_SUBST(MOZ_VP8_ENCODER)
8644 AC_SUBST(MOZ_VP8)
8645 AC_SUBST(MOZ_OGG)
8646 AC_SUBST(VPX_AS)
8647 AC_SUBST(VPX_ASFLAGS)
8648 AC_SUBST(VPX_DASH_C_FLAG)
8649 AC_SUBST(VPX_AS_CONVERSION)
8650 AC_SUBST(VPX_ASM_SUFFIX)
8651 AC_SUBST(VPX_X86_ASM)
8652 AC_SUBST(VPX_ARM_ASM)
8653 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
8654 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
8655 AC_SUBST(LIBJPEG_TURBO_AS)
8656 AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
8657 AC_SUBST(LIBJPEG_TURBO_X86_ASM)
8658 AC_SUBST(LIBJPEG_TURBO_X64_ASM)
8659 AC_SUBST(LIBJPEG_TURBO_ARM_ASM)
8661 AC_SUBST(MOZ_PACKAGE_JSSHELL)
8662 AC_SUBST(MOZ_FOLD_LIBS)
8664 AC_SUBST(MOZ_ENABLE_SZIP)
8665 AC_SUBST(MOZ_SZIP_FLAGS)
8667 if test -n "$COMPILE_ENVIRONMENT"; then
8668 AC_MSG_CHECKING([for posix_fallocate])
8669 AC_TRY_LINK([#define _XOPEN_SOURCE 600
8670   #include <fcntl.h>],
8671                  [posix_fallocate(0, 0, 0);],
8672                  [ac_cv___posix_fallocate=true],
8673                  [ac_cv___posix_fallocate=false])
8675 if test "$ac_cv___posix_fallocate" = true ; then
8676   AC_DEFINE(HAVE_POSIX_FALLOCATE)
8677   AC_MSG_RESULT(yes)
8678 else
8679   AC_MSG_RESULT(no)
8682 dnl Check for missing components
8683 if test "$MOZ_X11"; then
8684     if test "$WITHOUT_X11"; then
8685         AC_MSG_ERROR([--without-x specified and MOZ_X11 still defined])
8686     fi
8687     dnl ====================================================
8688     dnl = Check if X headers exist
8689     dnl ====================================================
8690     _SAVE_CFLAGS=$CFLAGS
8691     CFLAGS="$CFLAGS $XCFLAGS"
8692     AC_TRY_COMPILE([
8693         #include <stdio.h>
8694         #include <stdlib.h>
8695         #include <X11/Xlib.h>
8696         #include <X11/Intrinsic.h>
8697         #include <X11/extensions/XShm.h>
8698     ],
8699     [
8700         Display *dpy = 0;
8701         if ((dpy = XOpenDisplay(NULL)) == NULL) {
8702             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
8703             exit(1);
8704         }
8705     ], [],
8706     [ AC_MSG_ERROR([Could not compile basic X program.]) ])
8707     CFLAGS="$_SAVE_CFLAGS"
8709     if test -n "$MISSING_X"; then
8710         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
8711     fi
8713 fi # MOZ_X11
8715 fi # COMPILE_ENVIRONMENT
8717 dnl Set various defines and substitutions
8718 dnl ========================================================
8720 if test "$OS_ARCH" = "Darwin"; then
8721   AC_DEFINE(XP_UNIX)
8722 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2"; then
8723   AC_DEFINE(XP_UNIX)
8726 if test "$MOZ_DEBUG"; then
8727     AC_DEFINE(MOZ_REFLOW_PERF)
8728     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
8731 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
8732     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
8733     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
8734     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
8735     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
8736     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
8737     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
8738     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
8739     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
8742 AC_SUBST(MOZILLA_VERSION)
8744 AC_SUBST(ac_configure_args)
8746 dnl Spit out some output
8747 dnl ========================================================
8749 dnl The following defines are used by xpcom
8750 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
8751 CPP_THROW_NEW
8752 HAVE_CPP_AMBIGUITY_RESOLVING_USING
8753 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
8754 HAVE_CPP_PARTIAL_SPECIALIZATION
8755 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
8756 NEED_CPP_UNUSED_IMPLEMENTATIONS
8757 HAVE_GETPAGESIZE
8758 HAVE_ICONV
8759 HAVE_ICONV_WITH_CONST_INPUT
8760 HAVE_MBRTOWC
8761 HAVE_WCRTOMB
8762 HAVE_STATVFS64
8763 HAVE_STATVFS
8764 HAVE_STATFS64
8765 HAVE_STATFS
8766 HAVE_SYS_STATVFS_H
8767 HAVE_SYS_STATFS_H
8768 HAVE_SYS_VFS_H
8769 HAVE_SYS_MOUNT_H
8772 AC_SUBST(STLPORT_LIBS)
8774 MOZ_ARG_WITH_STRING(intl-api,
8775 [  --with-intl-api, --with-intl-api=build, --without-intl-api
8776     Determine the status of the ECMAScript Internationalization API.  The first
8777     (or lack of any of these) builds and exposes the API.  The second builds it
8778     but doesn't use ICU or expose the API to script.  The third doesn't build
8779     ICU at all.],
8780     _INTL_API=$withval,
8781     _INTL_API=yes)
8783 WITH_INTL="--with-intl-api=$_INTL_API"
8784 ENABLE_INTL_API=
8785 case "$_INTL_API" in
8787     ;;
8788 build)
8789     ENABLE_INTL_API=1
8790     ;;
8791 yes)
8792     ENABLE_INTL_API=1
8793     ;;
8795     AC_MSG_ERROR([Invalid value passed to --with-intl-api: $_INTL_API])
8796     ;;
8797 esac
8799 if test -n "$ENABLE_INTL_API"; then
8800 if test "$MOZ_BUILD_APP" = "browser" -a -z "$RELEASE_BUILD"; then
8801     # Build and expose internationalization in non-release desktop builds.
8802     WITH_INTL="--with-intl-api"
8803 else
8804     # Internationalization isn't built or exposed by default in non-desktop
8805     # builds, or in release desktop builds.  Bugs to enable:
8806     #
8807     #   Android:  bug 864843
8808     #   B2G:      bug 866301
8809     #   Desktop release: bug 924839 (update to latest ICU)
8810     WITH_INTL="--without-intl-api"
8811     ENABLE_INTL_API=
8815 dnl Settings for the implementation of the ECMAScript Internationalization API
8816 if test -n "$ENABLE_INTL_API"; then
8817     AC_DEFINE(ENABLE_INTL_API)
8819     MOZ_CONFIG_ICU()
8821     dnl Build ICU as a shared library for shared js builds.
8822     if test -z "$MOZ_NATIVE_ICU" -a -n "$JS_SHARED_LIBRARY"; then
8823         case "$OS_TARGET" in
8824             WINNT)
8825                 ICU_LIB_NAMES="icuin icuuc icudt"
8826                 DBG_SUFFIX=
8827                 if test -n "$MOZ_DEBUG"; then
8828                     DBG_SUFFIX=d
8829                 fi
8830                 MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/js/src/intl/icu/target/lib/$(LIB_PREFIX)$(lib)$(DBG_SUFFIX).$(LIB_SUFFIX))'
8831                 ;;
8832             Darwin)
8833                 ICU_LIB_NAMES="icui18n icuuc icudata"
8834                 MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/js/src/intl/icu/target/lib/$(DLL_PREFIX)$(lib).$(MOZ_ICU_VERSION)$(DLL_SUFFIX))'
8835                 ;;
8836             Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
8837                 ICU_LIB_NAMES="icui18n icuuc icudata"
8838                 MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/js/src/intl/icu/target/lib/$(DLL_PREFIX)$(lib)$(DLL_SUFFIX).$(MOZ_ICU_VERSION))'
8839                 ;;
8840             *)
8841                 AC_MSG_ERROR([ECMAScript Internationalization API is not yet supported on this platform])
8842         esac
8843     fi
8846 AC_SUBST(DBG_SUFFIX)
8847 AC_SUBST(ENABLE_INTL_API)
8848 AC_SUBST(ICU_LIB_NAMES)
8849 AC_SUBST(MOZ_ICU_LIBS)
8851 export WRITE_MOZINFO=1
8852 AC_OUTPUT()
8853 unset WRITE_MOZINFO
8855 # Hack around an Apple bug that affects the egrep that comes with OS X 10.7.
8856 # "env ARCHPREFERENCE=i386,x86_64 arch egrep" first tries to use the 32-bit
8857 # Intel part of the egrep fat binary, even on 64-bit systems, and falls back on
8858 # the 64-bit part if it's not a fat binary, as can happen with MacPorts. We
8859 # (apparently) only need this hack when egrep's "pattern" is particularly long
8860 # (as in the following code) and the first egrep on our $PATH is Apple's.  See
8861 # bug 655339.
8862 case "$host" in
8863 *-apple-darwin11*)
8864     FIXED_EGREP="env ARCHPREFERENCE=i386,x86_64 arch egrep"
8865     ;;
8867     FIXED_EGREP="egrep"
8868     ;;
8869 esac
8871 # Generate Makefiles for WebRTC directly from .gyp files
8872 if test "${OS_TARGET}" = "WINNT"; then
8873    if test "$HAVE_64BIT_OS"; then
8874       OS_BITS=64
8875    else
8876       OS_BITS=32
8877    fi
8878    EXTRA_GYP_DEFINES="-D MSVS_VERSION=${_MSVS_VERSION} -D MSVS_OS_BITS=${OS_BITS}"
8880 elif test "${OS_TARGET}" = "Android"; then
8881    if test "${MOZ_WIDGET_TOOLKIT}" = "gonk"; then
8882       EXTRA_GYP_DEFINES="-G os=linux "
8883    else
8884       EXTRA_GYP_DEFINES="-D gtest_target_type=executable -D android_toolchain=${android_toolchain} -G os=android "
8885    fi
8888 if test -n "$ARM_ARCH"; then
8889     if test "$ARM_ARCH" -lt 7; then
8890         EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D armv7=0 "
8891     else
8892         if test "${OS_TARGET}" = "Android"; then
8893             EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D armv7=1 "
8894         else
8895             dnl CPU detection for ARM works on Android only.  armv7 always uses CPU detection, so
8896             dnl we have to set armv7=0 for non-Android target
8897             EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D armv7=0 "
8898         fi
8899     fi
8902 # Keep libcubeb and audio_device backends in sync
8903 if test -n "$MOZ_ALSA"; then
8904    EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D include_alsa_audio=1"
8905 else
8906    EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D include_alsa_audio=0"
8908 if test -n "$MOZ_PULSEAUDIO"; then
8909    EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D include_pulse_audio=1"
8910 else
8911    EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D include_pulse_audio=0"
8914 # Don't try to compile ssse3/sse4.1 code if toolchain doesn't support
8915 if test -n "$INTEL_ARCHITECTURE"; then
8916   if test -z "$HAVE_TOOLCHAIN_SUPPORT_MSSSE3" -o -z "$HAVE_TOOLCHAIN_SUPPORT_MSSE4_1"; then
8917     EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D yuv_disable_asm=1"
8918   fi
8921 if test -n "$MOZ_WEBRTC"; then
8922    AC_MSG_RESULT("generating WebRTC Makefiles...")
8924    if test "${MOZ_WIDGET_TOOLKIT}" = "gonk"; then
8925       EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D build_with_gonk=1"
8926    fi
8928 dnl Any --include files must also appear in -D FORCED_INCLUDE_FILE= entries
8929 dnl so that regeneration via dependencies works correctly
8930    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"
8932    if test -n HAVE_CLOCK_MONOTONIC; then
8933       WEBRTC_CONFIG="${WEBRTC_CONFIG} -D have_clock_monotonic=1"
8934    else
8935       WEBRTC_CONFIG="${WEBRTC_CONFIG} -D have_clock_monotonic=0"
8936    fi
8938    if test -n "$MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI"; then
8939       WEBRTC_CONFIG="${WEBRTC_CONFIG} -D have_ethtool_cmd_speed_hi=1"
8940    else
8941       WEBRTC_CONFIG="${WEBRTC_CONFIG} -D have_ethtool_cmd_speed_hi=0"
8942    fi
8944    if test -n "$CROSS_COMPILE"; then
8945       case "$target" in
8946       *-mingw*)
8947         GYP_MOZMAKE_OPTIONS="-G os=win"
8948         ;;
8949       *-darwin*)
8950         GYP_MOZMAKE_OPTIONS="-G os=mac"
8951         if test "$MACOS_SDK_DIR"; then
8952            GYP_MOZMAKE_OPTIONS="${GYP_MOZMAKE_OPTIONS} -D mac_sdk_path=$MACOS_SDK_DIR"
8953         fi
8954         ;;
8955       *-*linux*)
8956         GYP_MOZMAKE_OPTIONS="-G os=linux"
8957         ;;
8958       *)
8959         AC_MSG_ERROR([Don't know what options to give to WebRTC for cross-compilation])
8960         ;;
8961       esac
8962    fi
8964    GYP_WEBRTC_OPTIONS="--format=mozmake ${GYP_MOZMAKE_OPTIONS} ${WEBRTC_CONFIG} -D target_arch=${WEBRTC_TARGET_ARCH} ${EXTRA_GYP_DEFINES} --depth=${srcdir}/media/webrtc/trunk --toplevel-dir=${srcdir} -G OBJDIR=${_objdir}"
8966    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
8967      $GYP_WEBRTC_OPTIONS \
8968      --generator-output=${_objdir}/media/webrtc/trunk \
8969      ${srcdir}/media/webrtc/trunk/peerconnection.gyp
8970    if test "$?" != 0; then
8971       AC_MSG_ERROR([failed to generate WebRTC Makefiles])
8972    fi
8974    # XXX disable until we land the tranche with signaling
8975    if test -n "$MOZ_WEBRTC_SIGNALING"; then
8976      AC_MSG_RESULT("generating WebRTC/Signaling Makefiles...")
8977      $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
8978        $GYP_WEBRTC_OPTIONS \
8979        -D build_for_test=0 \
8980        --generator-output=${_objdir}/media/webrtc/signaling \
8981        ${srcdir}/media/webrtc/signaling/signaling.gyp
8982      if test "$?" != 0; then
8983         AC_MSG_ERROR([failed to generate WebRTC/Signaling Makefiles])
8984      fi
8986      AC_MSG_RESULT("generating WebRTC/SignalingTest Makefiles...")
8987      $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
8988        $GYP_WEBRTC_OPTIONS \
8989        -D build_for_test=1 \
8990        --generator-output=${_objdir}/media/webrtc/signalingtest \
8991        ${srcdir}/media/webrtc/signaling/signaling.gyp
8992      if test "$?" != 0; then
8993        AC_MSG_ERROR([failed to generate WebRTC/SignalingTest Makefiles])
8994      fi
8995    fi
8997    AC_MSG_RESULT("generating gtest Makefiles...")
8998    # Ok to pass some extra -D's that are ignored here
8999    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9000      $GYP_WEBRTC_OPTIONS \
9001      --generator-output=${_objdir}/media/webrtc/trunk/testing/ \
9002      ${srcdir}/media/webrtc/trunk/testing/gtest.gyp
9003    if test "$?" != 0; then
9004       AC_MSG_ERROR([failed to generate gtest Makefiles])
9005    fi
9007    AC_MSG_RESULT("generating nrappkit Makefiles...")
9008    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9009      $GYP_WEBRTC_OPTIONS \
9010      --generator-output=${_objdir}/media/mtransport/third_party/nrappkit \
9011      ${srcdir}/media/mtransport/third_party/nrappkit/nrappkit.gyp
9012    if test "$?" != 0; then
9013       AC_MSG_ERROR([failed to generate nrappkit Makefiles])
9014    fi
9016    AC_MSG_RESULT("generating nICEr Makefiles...")
9017    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9018      $GYP_WEBRTC_OPTIONS \
9019      --generator-output=${_objdir}/media/mtransport/third_party/nICEr \
9020      ${srcdir}/media/mtransport/third_party/nICEr/nicer.gyp
9021    if test "$?" != 0; then
9022       AC_MSG_ERROR([failed to generate nICEr Makefiles])
9023    fi
9026 # Run jemalloc configure script
9028 if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC3" -o -n "$MOZ_REPLACE_MALLOC"; then
9029   ac_configure_args="--build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
9030   if test -n "$MOZ_REPLACE_MALLOC"; then
9031     # When using replace_malloc, we always want memalign and valloc exported from jemalloc.
9032     ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
9033     ac_configure_args="$ac_configure_args ac_cv_func_valloc=yes"
9034   fi
9035   if test -n "$MOZ_JEMALLOC3"; then
9036     case "${OS_ARCH}" in
9037       WINNT|Darwin)
9038         # We want jemalloc functions to be kept hidden on both Mac and Windows
9039         # See memory/build/mozmemory_wrap.h for details.
9040         ac_configure_args="$ac_configure_args --without-export"
9041         ;;
9042     esac
9043   elif test "${OS_ARCH}" = Darwin; then
9044     # When building as a replace-malloc lib, disabling the zone allocator
9045     # forces to use pthread_atfork.
9046     ac_configure_args="$ac_configure_args --disable-zone-allocator"
9047   fi
9048   _MANGLE="malloc posix_memalign aligned_alloc calloc realloc free memalign valloc malloc_usable_size"
9049   JEMALLOC_WRAPPER=
9050   if test -z "$MOZ_REPLACE_MALLOC"; then
9051     case "$OS_ARCH" in
9052       Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
9053         MANGLE=$_MANGLE
9054         ;;
9055     esac
9056   elif test -z "$MOZ_JEMALLOC3"; then
9057     MANGLE=$_MANGLE
9058     JEMALLOC_WRAPPER=replace_
9059   fi
9060   if test -n "$MANGLE"; then
9061     MANGLED=
9062     if test -n "$_WRAP_MALLOC" -a -z "$JEMALLOC_WRAPPER"; then
9063       JEMALLOC_WRAPPER=__wrap_
9064     fi
9065     for mangle in ${MANGLE}; do
9066       if test -n "$MANGLED"; then
9067         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle,$MANGLED"
9068       else
9069         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle"
9070       fi
9071     done
9072     ac_configure_args="$ac_configure_args --with-mangling=$MANGLED"
9073   fi
9074   unset CONFIG_FILES
9075   if test -z "$MOZ_TLS"; then
9076     ac_configure_args="$ac_configure_args --disable-tls"
9077   fi
9078   EXTRA_CFLAGS="$CFLAGS"
9079   for var in AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS EXTRA_CFLAGS LDFLAGS; do
9080     ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
9081   done
9082   if test "$CROSS_COMPILE"; then
9083     ac_configure_args="$ac_configure_args je_cv_static_page_shift=12"
9084   fi
9085   _save_cache_file="$cache_file"
9086   cache_file=$_objdir/memory/jemalloc/src/config.cache
9088   if ! test -e memory/jemalloc; then
9089     mkdir -p memory/jemalloc
9090   fi
9092   AC_OUTPUT_SUBDIRS(memory/jemalloc/src)
9093   cache_file="$_save_cache_file"
9094   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9097 # Run freetype configure script
9099 if test "$MOZ_TREE_FREETYPE"; then
9100    export CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS -std=c99"
9101    export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS"
9102    export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS"
9103    export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS"
9104    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
9105    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes --without-png"
9107    if ! test -e modules; then
9108      mkdir modules
9109    fi
9111    AC_OUTPUT_SUBDIRS(modules/freetype2)
9114 if test -z "$direct_nspr_config"; then
9115     dnl ========================================================
9116     dnl = Setup a nice relatively clean build environment for
9117     dnl = sub-configures.
9118     dnl ========================================================
9119     CC="$_SUBDIR_CC"
9120     CXX="$_SUBDIR_CXX"
9121     CFLAGS="$_SUBDIR_CFLAGS"
9122     CPPFLAGS="$_SUBDIR_CPPFLAGS"
9123     CXXFLAGS="$_SUBDIR_CXXFLAGS"
9124     LDFLAGS="$_SUBDIR_LDFLAGS"
9125     HOST_CC="$_SUBDIR_HOST_CC"
9126     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9127     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9128     RC=
9131 unset MAKEFILES
9132 unset CONFIG_FILES
9134 # Run all configure scripts specified by a subconfigure
9135 if test -n "$_subconfigure_subdir"; then
9136   _save_ac_configure_args="$ac_configure_args"
9137   ac_configure_args="$_subconfigure_config_args"
9138   AC_OUTPUT_SUBDIRS("$_subconfigure_subdir")
9139   ac_configure_args="$_save_ac_configure_args"
9142 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9143 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9145 export WRAP_LDFLAGS
9147 if test -n "$_WRAP_MALLOC"; then
9148     # Avoid doubling wrap malloc arguments
9149     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
9152 if test -z "$MOZ_NATIVE_NSPR"; then
9153     ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
9154     if test -z "$MOZ_DEBUG"; then
9155         ac_configure_args="$ac_configure_args --disable-debug"
9156     else
9157         ac_configure_args="$ac_configure_args --enable-debug"
9158     fi
9159     if test "$MOZ_OPTIMIZE" = "1"; then
9160         ac_configure_args="$ac_configure_args --enable-optimize"
9161     elif test -z "$MOZ_OPTIMIZE"; then
9162         ac_configure_args="$ac_configure_args --disable-optimize"
9163     fi
9164     if test -n "$HAVE_64BIT_OS"; then
9165         ac_configure_args="$ac_configure_args --enable-64bit"
9166     fi
9167     if test -n "$USE_ARM_KUSER"; then
9168         ac_configure_args="$ac_configure_args --with-arm-kuser"
9169     fi
9170     ac_configure_args="$ac_configure_args $NSPR_CONFIGURE_ARGS"
9172     # Save these, so we can mess with them for the subconfigure ..
9173     _SAVE_CFLAGS="$CFLAGS"
9174     _SAVE_CPPFLAGS="$CPPFLAGS"
9175     _SAVE_LDFLAGS="$LDFLAGS"
9177     if test -n "$MOZ_LINKER" -a "$ac_cv_func_dladdr" = no ; then
9178       # dladdr is supported by the new linker, even when the system linker doesn't
9179       # support it. Trick nspr into using dladdr when it's not supported.
9180       export CPPFLAGS="-include $_topsrcdir/mozglue/linker/dladdr.h $CPPFLAGS"
9181     fi
9182     export LDFLAGS="$LDFLAGS $NSPR_LDFLAGS"
9183     export CFLAGS="$CFLAGS $MOZ_FRAMEPTR_FLAGS"
9185     AC_OUTPUT_SUBDIRS(nsprpub)
9187     # .. and restore them
9188     unset CFLAGS
9189     unset CPPFLAGS
9190     unset LDFLAGS
9191     CFLAGS="$_SAVE_CFLAGS"
9192     CPPFLAGS="$_SAVE_CPPFLAGS"
9193     LDFLAGS="$_SAVE_LDFLAGS"
9195     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9198 dnl ========================================================
9199 dnl = Setup a nice relatively clean build environment for
9200 dnl = sub-configures.
9201 dnl ========================================================
9202 CC="$_SUBDIR_CC"
9203 CXX="$_SUBDIR_CXX"
9204 CFLAGS="$_SUBDIR_CFLAGS"
9205 CPPFLAGS="$_SUBDIR_CPPFLAGS"
9206 CXXFLAGS="$_SUBDIR_CXXFLAGS"
9207 LDFLAGS="$_SUBDIR_LDFLAGS"
9208 HOST_CC="$_SUBDIR_HOST_CC"
9209 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9210 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9213 if test -n "$ENABLE_CLANG_PLUGIN"; then
9214     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9215     AC_OUTPUT_SUBDIRS(build/clang-plugin)
9219 # Run the SpiderMonkey 'configure' script.
9220 dist=$MOZ_BUILD_ROOT/dist
9221 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9222 ac_configure_args="$ac_configure_args --enable-threadsafe"
9224 ac_configure_args="$ac_configure_args $WITH_INTL"
9226 if test "$BUILD_CTYPES"; then
9227     # Build js-ctypes on the platforms we can.
9228     ac_configure_args="$ac_configure_args --enable-ctypes"
9230 if test -z "$JS_SHARED_LIBRARY" ; then
9231     ac_configure_args="$ac_configure_args --disable-shared-js"
9232     if test -n "$MOZ_DISABLE_EXPORT_JS"; then
9233         ac_configure_args="$ac_configure_args --disable-export-js"
9234     fi
9236 if test -z "$MOZ_NATIVE_NSPR"; then
9237     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
9238     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
9240 ac_configure_args="$ac_configure_args --with-dist-dir=../../dist"
9241 ac_configure_args="$ac_configure_args --prefix=$dist"
9242 if test "$MOZ_MEMORY"; then
9243    ac_configure_args="$ac_configure_args --enable-jemalloc"
9245 if test -n "$MOZ_GLUE_LDFLAGS"; then
9246    export MOZ_GLUE_LDFLAGS
9248 if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
9249    export MOZ_GLUE_PROGRAM_LDFLAGS
9251 if test -n "$ZLIB_IN_MOZGLUE"; then
9252    MOZ_ZLIB_LIBS=
9254 export MOZ_NATIVE_ZLIB
9255 export MOZ_ZLIB_CFLAGS
9256 export MOZ_ZLIB_LIBS
9257 export MOZ_APP_NAME
9258 export DONT_POPULATE_VIRTUALENV=1
9259 export PYTHON
9260 export MOZILLA_CENTRAL_PATH=$_topsrcdir
9261 export STLPORT_CPPFLAGS
9262 export STLPORT_LDFLAGS
9263 export STLPORT_LIBS
9264 export JS_STANDALONE=no
9265 export MOZ_LINKER
9266 export ZLIB_IN_MOZGLUE
9268 if ! test -e js; then
9269     mkdir js
9272 AC_OUTPUT_SUBDIRS(js/src)
9273 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9275 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR