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