Bug 867104 - Add a crashtest. r=ehsan
[gecko.git] / configure.in
blob3f5c79e4083022f00bbd109c0b1d745600f1c832
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=10513
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 WINDRES_VERSION=2.14.90
66 W32API_VERSION=3.14
67 GNOMEVFS_VERSION=2.0
68 GNOMEUI_VERSION=2.2.0
69 GCONF_VERSION=1.2.1
70 GIO_VERSION=2.20
71 STARTUP_NOTIFICATION_VERSION=0.8
72 DBUS_VERSION=0.60
73 SQLITE_VERSION=3.7.16.1
75 MSMANIFEST_TOOL=
77 dnl Set various checks
78 dnl ========================================================
79 MISSING_X=
80 AC_PROG_AWK
82 dnl Initialize the Pthread test variables early so they can be
83 dnl  overridden by each platform.
84 dnl ========================================================
85 USE_PTHREADS=
86 _PTHREAD_LDFLAGS=""
88 dnl Do not allow a separate objdir build if a srcdir build exists.
89 dnl ==============================================================
90 _topsrcdir=`cd \`dirname $0\`; pwd`
91 _objdir=`pwd`
93 if test "$_topsrcdir" != "$_objdir"
94 then
95   # Check for a couple representative files in the source tree
96   _conflict_files=
97   for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
98     if test -f $file; then
99       _conflict_files="$_conflict_files $file"
100     fi
101   done
102   if test "$_conflict_files"; then
103     echo "***"
104     echo "*   Your source tree contains these files:"
105     for file in $_conflict_files; do
106       echo "*         $file"
107     done
108     cat 1>&2 <<-EOF
109         *   This indicates that you previously built in the source tree.
110         *   A source tree build can confuse the separate objdir build.
111         *
112         *   To clean up the source tree:
113         *     1. cd $_topsrcdir
114         *     2. gmake distclean
115         ***
116         EOF
117     exit 1
118     break
119   fi
121 MOZ_BUILD_ROOT=`pwd`
123 MOZ_PYTHON
125 MOZ_DEFAULT_COMPILER
127 COMPILE_ENVIRONMENT=1
128 MOZ_ARG_DISABLE_BOOL(compile-environment,
129 [  --disable-compile-environment
130                           Disable compiler/library checks.],
131     COMPILE_ENVIRONMENT= )
132 AC_SUBST(COMPILE_ENVIRONMENT)
134 MOZ_ARG_WITH_STRING(l10n-base,
135 [  --with-l10n-base=DIR    path to l10n repositories],
136     L10NBASEDIR=$withval)
137 if test -n "$L10NBASEDIR"; then
138     if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
139         AC_MSG_ERROR([--with-l10n-base must specify a path])
140     elif test -d "$L10NBASEDIR"; then
141         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd`
142     else
143         AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
144     fi
146 AC_SUBST(L10NBASEDIR)
148 dnl Check for Perl first -- needed for win32 SDK checks
149 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
150 if test -z "$PERL" -o "$PERL" = ":"; then
151     AC_MSG_ERROR([perl not found in \$PATH])
154 AC_SUBST(GAIADIR)
155 if test -n "$GAIADIR" ; then
156     AC_DEFINE(PACKAGE_GAIA)
159 MOZ_ARG_WITH_STRING(gonk,
160 [  --with-gonk=DIR
161                location of gonk dir],
162     gonkdir=$withval)
164 MOZ_ARG_WITH_STRING(gonk-toolchain-prefix,
165 [  --with-gonk-toolchain-prefix=DIR
166                           prefix to gonk toolchain commands],
167     gonk_toolchain_prefix=$withval)
169 if test -n "$gonkdir" ; then
170     kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
171     android_source="$gonkdir"
172     ANDROID_SOURCE="$android_source"
173     ANDROID_NDK="${ANDROID_SOURCE}/ndk"
174     dnl Default to ICS
175     ANDROID_VERSION=15
176     if test -n "${PLATFORM_SDK_VERSION}"; then
177         ANDROID_VERSION="${PLATFORM_SDK_VERSION}"
178     fi
180     dnl set up compilers
181     TOOLCHAIN_PREFIX="$gonk_toolchain_prefix"
182     AS="$gonk_toolchain_prefix"as
183     CC="$gonk_toolchain_prefix"gcc
184     CXX="$gonk_toolchain_prefix"g++
185     CPP="$gonk_toolchain_prefix"cpp
186     LD="$gonk_toolchain_prefix"ld
187     AR="$gonk_toolchain_prefix"ar
188     RANLIB="$gonk_toolchain_prefix"ranlib
189     STRIP="$gonk_toolchain_prefix"strip
190     OBJCOPY="$gonk_toolchain_prefix"objcopy
192     STLPORT_CPPFLAGS="-I$gonkdir/ndk/sources/cxx-stl/stlport/stlport/ -I$gonkdir/external/stlport/stlport/"
193     STLPORT_LIBS="-lstlport"
195     case "$target_cpu" in
196     arm)
197         ARCH_DIR=arch-arm
198         ;;
199     i?86)
200         ARCH_DIR=arch-x86
201         ;;
202     esac
204     case "$ANDROID_VERSION" in
205     15)
206         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"
207         MOZ_B2G_BT=1
208         MOZ_B2G_CAMERA=1
209         MOZ_OMX_DECODER=1
210         AC_DEFINE(MOZ_OMX_DECODER)
211         AC_SUBST(MOZ_OMX_DECODER)
212         ;;
213     17)
214         GONK_INCLUDES="-I$gonkdir/frameworks/native/include"
215         ;;
216     *)
217         AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION])
218         ;;
219     esac
220     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 $GONK_INCLUDES $CPPFLAGS"
221     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
222     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS $STLPORT_CPPFLAGS"
223     dnl Add -llog by default, since we use it all over the place.
224     LIBS="$LIBS -llog $STLPORT_LIBS"
226     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"
228     dnl prevent cross compile section from using these flags as host flags
229     if test -z "$HOST_CPPFLAGS" ; then
230         HOST_CPPFLAGS=" "
231     fi
232     if test -z "$HOST_CFLAGS" ; then
233         HOST_CFLAGS=" "
234     fi
235     if test -z "$HOST_CXXFLAGS" ; then
236         HOST_CXXFLAGS=" "
237     fi
238     if test -z "$HOST_LDFLAGS" ; then
239         HOST_LDFLAGS=" "
240     fi
242     AC_DEFINE(ANDROID)
243     AC_DEFINE_UNQUOTED(ANDROID_VERSION, $ANDROID_VERSION)
244     AC_SUBST(ANDROID_VERSION)
245     AC_DEFINE(HAVE_SYS_UIO_H)
246     AC_DEFINE(HAVE_PTHREADS)
247     CROSS_COMPILE=1
248     MOZ_CHROME_FILE_FORMAT=omni
249     direct_nspr_config=1
250 else
251     MOZ_ANDROID_NDK
253     case "$target" in
254     *-android*|*-linuxandroid*)
255         if test -z "$ANDROID_PACKAGE_NAME" ; then
256             ANDROID_PACKAGE_NAME='org.mozilla.$(MOZ_APP_NAME)'
257         fi
258         MOZ_CHROME_FILE_FORMAT=omni
259         ZLIB_DIR=yes
260         ;;
261     *-linux*)
262         AC_PATH_PROG(OBJCOPY,objcopy)
263         ;;
264     esac
267 AC_SUBST(ANDROID_SOURCE)
268 AC_SUBST(ANDROID_PACKAGE_NAME)
269 AC_SUBST(OBJCOPY)
271 dnl ========================================================
272 dnl Checks for compilers.
273 dnl ========================================================
274 dnl Set CROSS_COMPILE in the environment when running configure
275 dnl to use the cross-compile setup for now
276 dnl ========================================================
278 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
279 AR_FLAGS='cr $@'
281 if test "$COMPILE_ENVIRONMENT"; then
283 if test -n "$CROSS_COMPILE" -a "$target" != "$host"; then
284     echo "cross compiling from $host to $target"
285     cross_compiling=yes
287     _SAVE_CC="$CC"
288     _SAVE_CFLAGS="$CFLAGS"
289     _SAVE_LDFLAGS="$LDFLAGS"
291     AC_MSG_CHECKING([for host c compiler])
292     AC_CHECK_PROGS(HOST_CC, $HOST_CC cc gcc /usr/ucb/cc cl icc, "")
293     if test -z "$HOST_CC"; then
294         AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
295     fi
296     AC_MSG_RESULT([$HOST_CC])
297     AC_MSG_CHECKING([for host c++ compiler])
298     AC_CHECK_PROGS(HOST_CXX, $HOST_CXX $CCC c++ g++ gcc CC cxx cc++ cl icc, "")
299     if test -z "$HOST_CXX"; then
300         AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
301     fi
302     AC_MSG_RESULT([$HOST_CXX])
304     if test -z "$HOST_CFLAGS"; then
305         HOST_CFLAGS="$CFLAGS"
306     fi
307     if test -z "$HOST_CXXFLAGS"; then
308         HOST_CXXFLAGS="$CXXFLAGS"
309     fi
310     if test -z "$HOST_LDFLAGS"; then
311         HOST_LDFLAGS="$LDFLAGS"
312     fi
313     if test -z "$HOST_AR_FLAGS"; then
314         HOST_AR_FLAGS="$AR_FLAGS"
315     fi
316     AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
317     AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
318     CC="$HOST_CC"
319     CFLAGS="$HOST_CFLAGS"
320     LDFLAGS="$HOST_LDFLAGS"
322     AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
323     AC_TRY_COMPILE([], [return(0);],
324         [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
325         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
327     CC="$HOST_CXX"
328     CFLAGS="$HOST_CXXFLAGS"
330     AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
331     AC_TRY_COMPILE([], [return(0);],
332         [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
333         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
335     CC=$_SAVE_CC
336     CFLAGS=$_SAVE_CFLAGS
337     LDFLAGS=$_SAVE_LDFLAGS
339     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :)
340     unset ac_cv_prog_CC
341     AC_PROG_CC
342     AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :)
343     unset ac_cv_prog_CXX
344     AC_PROG_CXX
346     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", :)
347     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", :)
348     MOZ_PATH_PROGS(AS, $AS "${target_alias}-as" "${target}-as", :)
349     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", :)
350     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :)
351     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :)
352     AC_DEFINE(CROSS_COMPILE)
353 else
354     AC_PROG_CC
355     case "$target" in
356     *-mingw*)
357       # Work around the conftest.exe access problem on Windows
358       sleep 2
359     esac
360     AC_PROG_CXX
361     AC_PROG_RANLIB
362     MOZ_PATH_PROGS(AS, $AS as, $CC)
363     AC_CHECK_PROGS(AR, ar, :)
364     AC_CHECK_PROGS(LD, ld, :)
365     AC_CHECK_PROGS(STRIP, strip, :)
366     AC_CHECK_PROGS(WINDRES, windres, :)
367     if test -z "$HOST_CC"; then
368         HOST_CC="$CC"
369     fi
370     if test -z "$HOST_CFLAGS"; then
371         HOST_CFLAGS="$CFLAGS"
372     fi
373     if test -z "$HOST_CXX"; then
374         HOST_CXX="$CXX"
375     fi
376     if test -z "$HOST_CXXFLAGS"; then
377         HOST_CXXFLAGS="$CXXFLAGS"
378     fi
379     if test -z "$HOST_LDFLAGS"; then
380         HOST_LDFLAGS="$LDFLAGS"
381     fi
382     if test -z "$HOST_RANLIB"; then
383         HOST_RANLIB="$RANLIB"
384     fi
385     if test -z "$HOST_AR"; then
386         HOST_AR="$AR"
387     fi
388     if test -z "$HOST_AR_FLAGS"; then
389         HOST_AR_FLAGS="$AR_FLAGS"
390     fi
393 if test -n "$MOZ_WINCONSOLE"; then
394     AC_DEFINE(MOZ_WINCONSOLE)
397 MOZ_TOOL_VARIABLES
399 if test -n "$GNU_CC" -a -z "$CLANG_CC" ; then
400     if test "$GCC_MAJOR_VERSION" -eq 4 -a "$GCC_MINOR_VERSION" -lt 4 ||
401        test "$GCC_MAJOR_VERSION" -lt 4; then
402         AC_MSG_ERROR([Only GCC 4.4 or newer supported])
403     fi
406 dnl ========================================================
407 dnl Special win32 checks
408 dnl ========================================================
410 MOZ_ARG_ENABLE_BOOL(metro,
411 [  --enable-metro           Enable Windows Metro build targets],
412     MOZ_METRO=1,
413     MOZ_METRO=)
414 if test -n "$MOZ_METRO"; then
415     AC_DEFINE(MOZ_METRO)
416     # Target the Windows 8 Kit
417     WINSDK_TARGETVER=602
418     WINVER=502
419     # toolkit/library/makefile.in needs these, see nsDllMain.
420     CRTDLLVERSION=110
421     CRTEXPDLLVERSION=1-1-0
422 else
423     # Target the Windows 7 SDK by default
424     WINSDK_TARGETVER=601
425     WINVER=502
428 AC_SUBST(CRTDLLVERSION)
429 AC_SUBST(CRTEXPDLLVERSION)
431 MOZ_ARG_WITH_STRING(windows-version,
432 [  --with-windows-version=WINSDK_TARGETVER
433                           Windows SDK version to target. Lowest version
434                           currently allowed is 601 (Win7), highest is 602 (Win8)],
435   WINSDK_TARGETVER=$withval)
437 # Currently only two sdk versions allowed, 601 and 602
438 case "$WINSDK_TARGETVER" in
439 601|602)
440     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
441     ;;
444     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER)]);
445     ;;
446 esac
448 case "$target" in
449 *-mingw*)
450     if test "$GCC" != "yes"; then
451         # Check to see if we are really running in a msvc environemnt
452         _WIN32_MSVC=1
453         AC_CHECK_PROGS(MIDL, midl)
455         # Make sure compilers are valid
456         CFLAGS="$CFLAGS -TC -nologo"
457         CXXFLAGS="$CXXFLAGS -TP -nologo"
458         AC_LANG_SAVE
459         AC_LANG_C
460         AC_TRY_COMPILE([#include <stdio.h>],
461             [ printf("Hello World\n"); ],,
462             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
464         AC_LANG_CPLUSPLUS
465         AC_TRY_COMPILE([#include <new.h>],
466             [ unsigned *test = new unsigned(42); ],,
467             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
468         AC_LANG_RESTORE
470         changequote(,)
471         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
472         changequote([,])
474         # Determine compiler version
475         CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
476         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
477         _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
478         _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
479         _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
480         _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
482         CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
483         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
485         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
486             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
487         fi
489         if test "$_CC_MAJOR_VERSION" = "14"; then
490             dnl Require VC8SP1 or newer.
491             dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762.
492             if test "$_CC_RELEASE" -lt 50727 -o \
493                     \( "$_CC_RELEASE" -eq 50727 -a "$_CC_BUILD" -lt 762 \); then
494               AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. You probably need to install Service Pack 1 of Visual Studio 2005. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
495             fi
497             _CC_SUITE=8
498             _MSVS_VERSION=2005
499             AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
500             AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
501         elif test "$_CC_MAJOR_VERSION" = "15"; then
502             _CC_SUITE=9
503             _MSVS_VERSION=2008
504             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
505             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
506         elif test "$_CC_MAJOR_VERSION" = "16"; then
507             _CC_SUITE=10
508             _MSVS_VERSION=2010
509             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
510             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
511         elif test "$_CC_MAJOR_VERSION" = "17"; then
512             _CC_SUITE=11
513             _MSVS_VERSION=2012
514             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
515             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
516         else
517             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
518         fi
520         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
522         if test -n "$WIN32_REDIST_DIR"; then
523           if test ! -d "$WIN32_REDIST_DIR"; then
524             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
525           fi
526           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
527         fi
529         dnl Confirm we have the pri tools on win8 builds
530         if test -n "$MOZ_METRO"; then
531           AC_MSG_CHECKING([for makepri])
532           AC_CHECK_PROGS(MAKEPRI, makepri, "")
533           if test -z "MAKEPRI" ; then
534               AC_MSG_ERROR([makepri.exe is required for generating metro browser install components. It should be in the Win8 SDK.])
535           fi
536           AC_SUBST(MAKEPRI)
537         fi
539         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
540         dnl not something else like "magnetic tape manipulation utility".
541         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
542         if test -z "$MSMT_TOOL"; then
543           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
544         fi
546         changequote(,)
547         _MSMT_VER_FILTER='s|.*[^!-~]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
548         changequote([,])
549         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
550         if test -z "$MSMANIFEST_TOOL_VERSION"; then
551           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
552         fi
554         MSMANIFEST_TOOL=1
555         unset MSMT_TOOL
557         # Check linker version
558         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
559         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
560         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
561             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
562         fi
564         INCREMENTAL_LINKER=1
566         # Check midl version
567         _MIDL_FULL_VERSION=`"${MIDL}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
568         _MIDL_MAJOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
569         _MIDL_MINOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
570         _MIDL_REV_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
571         # Add flags if necessary
572         AC_MSG_CHECKING([for midl flags])
573         case "$target" in
574         i*86-*)
575             if test \( "$_MIDL_MAJOR_VERSION" = "7" -a "$_MIDL_MINOR_VERSION" = "00" -a "$_MIDL_REV_VERSION" = "0499" \); then
576                 # MIDL version 7.00.0499 defaults /env win64 on x64 platforms.
577                 # MIDL version 7.00.0500 or later has no problem.
578                 MIDL_FLAGS="${MIDL_FLAGS} -env win32"
579                 AC_MSG_RESULT([need -env win32])
580             else
581                 AC_MSG_RESULT([none needed])
582             fi
583             ;;
584         x86_64-*)
585             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
586             ;;
587         *)
588             AC_MSG_RESULT([none needed])
589             ;;
590         esac
592         # Identify which version of the SDK we're building with
593         # Windows Server 2008 and newer SDKs have WinSDKVer.h, get the version
594         # from there
595         MOZ_CHECK_HEADERS([winsdkver.h])
596         if test "$ac_cv_header_winsdkver_h" = "yes"; then
597             # Get the highest _WIN32_WINNT and NTDDI versions supported
598             # Take the higher of the two
599             # This is done because the Windows 7 beta SDK reports its
600             # NTDDI_MAXVER to be 0x06000100 instead of 0x06010000, as it should
601             AC_CACHE_CHECK(for highest Windows version supported by this SDK,
602                            ac_cv_winsdk_maxver,
603                            [cat > conftest.h <<EOF
604 #include <winsdkver.h>
605 #include <sdkddkver.h>
607 #if (NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER) > NTDDI_MAXVER)
608 #define WINSDK_MAXVER NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER)
609 #else
610 #define WINSDK_MAXVER NTDDI_MAXVER
611 #endif
613 WINSDK_MAXVER
615                             ac_cv_winsdk_maxver=`$CPP conftest.h 2>/dev/null | tail -n1`
616                             rm -f conftest.h
617                            ])
618             MOZ_WINSDK_MAXVER=${ac_cv_winsdk_maxver}
619         else
620             # Any SDK which doesn't have WinSDKVer.h is too old.
621             AC_MSG_ERROR([Your SDK does not have WinSDKVer.h. It is probably too old. Please upgrade to a newer SDK or 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.])
622         fi
624         unset _MSVC_VER_FILTER
626         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
627             [
628                 AC_LANG_SAVE
629                 AC_LANG_CPLUSPLUS
630                 _SAVE_CXXFLAGS="$CXXFLAGS"
631                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
632                 AC_TRY_COMPILE([#include <exception>],
633                             [std::_Throw(std::exception()); return 0;],
634                             ac_cv_have_std__Throw="yes",
635                             ac_cv_have_std__Throw="no")
636                 CXXFLAGS="$_SAVE_CXXFLAGS"
637                 AC_LANG_RESTORE
638             ])
640         if test "$ac_cv_have_std__Throw" = "yes"; then
641             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
642                            ac_cv_have_dllimport_exception_bug,
643                 [
644                     AC_LANG_SAVE
645                     AC_LANG_CPLUSPLUS
646                     _SAVE_CXXFLAGS="$CXXFLAGS"
647                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
648                     AC_TRY_LINK([#include <vector>],
649                                 [std::vector<int> v; return v.at(1);],
650                                 ac_cv_have_dllimport_exception_bug="no",
651                                 ac_cv_have_dllimport_exception_bug="yes")
652                     CXXFLAGS="$_SAVE_CXXFLAGS"
653                     AC_LANG_RESTORE
654                 ])
655             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
656                 WRAP_STL_INCLUDES=1
657                 MOZ_MSVC_STL_WRAP__Throw=1
658                 AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
659             fi
660         else
661             AC_CACHE_CHECK(for overridable _RAISE,
662                            ac_cv_have__RAISE,
663                 [
664                     AC_LANG_SAVE
665                     AC_LANG_CPLUSPLUS
666                     _SAVE_CXXFLAGS="$CXXFLAGS"
667                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
668                     AC_TRY_COMPILE([#include <xstddef>
669                                     #undef _RAISE
670                                     #define _RAISE(x) externallyDefinedFunction((x).what())
671                                     #include <vector>
672                                    ],
673                                    [std::vector<int> v; return v.at(1);],
674                                    ac_cv_have__RAISE="no",
675                                    ac_cv_have__RAISE="yes")
676                     CXXFLAGS="$_SAVE_CXXFLAGS"
677                     AC_LANG_RESTORE
678                 ])
679             if test "$ac_cv_have__RAISE" = "yes"; then
680                 WRAP_STL_INCLUDES=1
681                 MOZ_MSVC_STL_WRAP__RAISE=1
682                 AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
683             else
684                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
685             fi
686         fi
688         if test "$WRAP_STL_INCLUDES" = "1"; then
689             STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
690         fi
691     else
692         # Check w32api version
693         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
694         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
695         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
696         AC_TRY_COMPILE([#include <w32api.h>],
697             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
698                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
699                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
700                 #error "test failed."
701             #endif
702             , [ res=yes ], [ res=no ])
703         AC_MSG_RESULT([$res])
704         if test "$res" != "yes"; then
705             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
706         fi
707         # Check windres version
708         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
709         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
710         AC_MSG_RESULT([$_WINDRES_VERSION])
711         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
712         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
713         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
714         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
715         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
716         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
717         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
718                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
719                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
720                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
721                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
722                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
723         then
724             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
725         fi
727         AC_CHECK_PROGS(MIDL, $target-widl widl)
728         if test -n "$MIDL"; then
729             case "$target" in
730             i*86-*)
731                 MIDL_FLAGS="$MIDL_FLAGS --win32 -m32"
732                 ;;
733             x86_64-*)
734                 MIDL_FLAGS="$MIDL_FLAGS --win64 -m64"
735                 ;;
736             esac
737         fi
739         MOZ_WINSDK_MAXVER=0x06020000
740     fi # !GNU_CC
742     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
743     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
744     # Require OS features provided by IE 6.0 SP2 (XP SP2)
745     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
747     # If the maximum version supported by this SDK is lower than the target
748     # version, error out
749     AC_MSG_CHECKING([for Windows SDK being recent enough])
750     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
751         AC_MSG_RESULT("yes")
752     else
753         AC_MSG_RESULT("no")
754         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.])
755     fi
756     
757     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
758     # Definitions matching sdkddkver.h
759     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
760     ;;
761 esac
763 AC_PROG_CPP
764 AC_PROG_CXXCPP
766 if test -n "$_WIN32_MSVC"; then
767     SKIP_PATH_CHECKS=1
768     SKIP_COMPILER_CHECKS=1
769     SKIP_LIBRARY_CHECKS=1
771     # Since we're skipping compiler and library checks, hard-code
772     # some facts here.
773     AC_DEFINE(HAVE_IO_H)
774     AC_DEFINE(HAVE_SETBUF)
775     AC_DEFINE(HAVE_ISATTY)
778 fi # COMPILE_ENVIRONMENT
780 AC_SUBST(MIDL_FLAGS)
781 AC_SUBST(_MSC_VER)
783 AC_SUBST(GNU_AS)
784 AC_SUBST(GNU_LD)
785 AC_SUBST(GNU_CC)
786 AC_SUBST(GNU_CXX)
787 AC_SUBST(INTEL_CC)
788 AC_SUBST(INTEL_CXX)
790 AC_SUBST(STL_FLAGS)
791 AC_SUBST(WRAP_STL_INCLUDES)
792 AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
793 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
795 dnl ========================================================
796 dnl Checks for programs.
797 dnl ========================================================
798 AC_PROG_INSTALL
799 AC_PROG_LN_S
801 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
802 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
803 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
804 _perl_res=$?
805 AC_MSG_RESULT([$_perl_version])
807 if test "$_perl_res" != 0; then
808     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
812 AC_MSG_CHECKING([for full perl installation])
813 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
814 _perl_res=$?
815 if test "$_perl_res" != 0; then
816     AC_MSG_RESULT([no])
817     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
818 else
819     AC_MSG_RESULT([yes])
822 MOZ_ARG_WITH_BOOL(system-ply,
823 [  --with-system-ply       Use system installed python ply library],
824     [if $PYTHON -c 'import ply' 2>&5; then
825          MOZ_SYSTEM_PLY=1
826      else
827          AC_MSG_ERROR([python ply library is not found but --with-system-ply was requested])
828      fi])
830 AC_SUBST(MOZ_SYSTEM_PLY)
832 if test -z "$COMPILE_ENVIRONMENT"; then
833     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
835 AC_SUBST(NSINSTALL_BIN)
837 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
838 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
839 MOZ_PATH_PROGS(UNZIP, unzip)
840 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
841     AC_MSG_ERROR([unzip not found in \$PATH])
843 MOZ_PATH_PROGS(ZIP, zip)
844 if test -z "$ZIP" -o "$ZIP" = ":"; then
845     AC_MSG_ERROR([zip not found in \$PATH])
847 MOZ_PATH_PROG(XARGS, xargs)
848 if test -z "$XARGS" -o "$XARGS" = ":"; then
849     AC_MSG_ERROR([xargs not found in \$PATH .])
852 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
853 AC_SUBST(RPMBUILD)
855 if test "$COMPILE_ENVIRONMENT"; then
857 dnl ========================================================
858 dnl = Mac OS X toolchain support
859 dnl ========================================================
861 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
862 dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
863 dnl when we can run target binaries.
864 AC_SUBST(UNIVERSAL_BINARY)
865 AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
867 MOZ_ARG_WITH_STRING(unify-dist,
868 [  --with-unify-dist=dir   Location of the dist directory to unify with at packaging time (Mac OS X universal build only)],
869     UNIFY_DIST=$withval)
870 if test -n "$UNIVERSAL_BINARY"; then
871     if test -z "$UNIFY_DIST"; then
872         AC_MSG_ERROR([You need to provide the --with-unify-dist=dir argument when performing a universal build])
873     fi
874     case "$UNIFY_DIST" in
875     /*)
876         ;;
877     *)
878         UNIFY_DIST="${MOZ_BUILD_ROOT}/${UNIFY_DIST}"
879         ;;
880     esac
882 AC_SUBST(UNIFY_DIST)
884 dnl ========================================================
885 dnl Check for MacOS deployment target version
886 dnl ========================================================
888 MOZ_ARG_ENABLE_STRING(macos-target,
889                       [  --enable-macos-target=VER (default=10.6)
890                           Set the minimum MacOS version needed at runtime],
891                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
893 case "$target" in
894 *-darwin*)
895     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
896         dnl Use the specified value
897         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
898     else
899         dnl No value specified on the command line or in the environment,
900         dnl use architecture minimum.
901         export MACOSX_DEPLOYMENT_TARGET=10.6
902     fi
903     ;;
904 esac
906 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
908 dnl ========================================================
909 dnl = Mac OS X SDK support
910 dnl ========================================================
911 MACOS_SDK_DIR=
912 NEXT_ROOT=
913 MOZ_ARG_WITH_STRING(macos-sdk,
914 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
915     MACOS_SDK_DIR=$withval)
917 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
918 dnl NEXT_ROOT will be set and exported only if it's needed.
919 AC_SUBST(MACOS_SDK_DIR)
920 AC_SUBST(NEXT_ROOT)
922 if test "$MACOS_SDK_DIR"; then
923   dnl Sync this section with the ones in NSPR and NSS.
924   dnl Changes to the cross environment here need to be accounted for in
925   dnl the libIDL checks (below) and xpidl build.
927   if test ! -d "$MACOS_SDK_DIR"; then
928     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
929 specify a valid SDK.  SDKs are installed when the optional cross-development
930 tools are selected during the Xcode/Developer Tools installation.])
931   fi
933   CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
934   CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
936   dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
937   CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
938   CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
940   AC_LANG_SAVE
941   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
942   AC_LANG_CPLUSPLUS
943   AC_TRY_COMPILE([#include <new>],[],
944    result=yes,
945    result=no)
946   AC_LANG_RESTORE
947   AC_MSG_RESULT($result)
949   if test "$result" = "no" ; then
950     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
951   fi
954 fi # COMPILE_ENVIRONMENT
956 AC_MSG_CHECKING([compiler version])
957 # Just print it so it shows up in the logs.
958 cc_version=$($CC --version)
959 AC_MSG_RESULT([$cc_version])
961 if test -n "$MAKE"; then
962   if test `echo $MAKE | grep -c make.py` != 1; then
963      NOT_PYMAKE=$MAKE
964   fi
967 case "$host_os" in
968 mingw*)
969     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
970     ;;
972     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
973     ;;
974 esac
975 if test "$GMAKE" = ":"; then
976    AC_MSG_ERROR([GNU make not found])
978 AC_SUBST(GMAKE)
980 if test -z "$MAKE"; then
981   MAKE=$GMAKE
984 if test "$COMPILE_ENVIRONMENT"; then
986 AC_PATH_XTRA
988 XCFLAGS="$X_CFLAGS"
990 fi # COMPILE_ENVIRONMENT
992 dnl ========================================================
993 dnl set the defaults first
994 dnl ========================================================
995 AS_BIN=$AS
996 AR_LIST='$(AR) t'
997 AR_EXTRACT='$(AR) x'
998 AR_DELETE='$(AR) d'
999 AS='$(CC)'
1000 AS_DASH_C_FLAG='-c'
1001 DLL_PREFIX=lib
1002 LIB_PREFIX=lib
1003 DLL_SUFFIX=.so
1004 OBJ_SUFFIX=o
1005 LIB_SUFFIX=a
1006 ASM_SUFFIX=s
1007 IMPORT_LIB_SUFFIX=
1008 TARGET_MD_ARCH=unix
1009 DIRENT_INO=d_ino
1010 MOZ_USER_DIR=".mozilla"
1012 MOZ_JPEG_CFLAGS=
1013 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)'
1014 MOZ_BZ2_CFLAGS=
1015 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
1016 MOZ_PNG_CFLAGS=
1017 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
1019 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
1020 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
1021 DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxul -lxpcom_core -lmozalloc'
1022 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
1023 XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxul -lmozalloc'
1024 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS)'
1025 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
1026 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
1028 # These are specially defined on Windows only
1029 case "$target" in
1030 *-mingw*)
1031   XPCOM_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
1032   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime.$(LIB_SUFFIX)'
1033   ;;
1035   XPCOM_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_GLUE_LDOPTS
1036   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_STANDALONE_GLUE_LDOPTS
1037   ;;
1038 esac
1040 MOZ_FS_LAYOUT=unix
1042 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
1044 USE_DEPENDENT_LIBS=1
1046 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
1048 if test -n "$CROSS_COMPILE"; then
1049     OS_TARGET="${target_os}"
1050     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
1051     OS_RELEASE=
1052     case "${target_os}" in
1053         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
1054         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
1055         gnu*)         OS_ARCH=GNU ;;
1056         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
1057         mingw*)       OS_ARCH=WINNT OS_TARGET=WINNT ;;
1058         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
1059     esac
1060     case "${target}" in
1061         *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
1062     esac
1063 else
1064     OS_TARGET=`uname -s`
1065     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
1066     OS_RELEASE=`uname -r`
1069 # Before this used `uname -m` when not cross compiling
1070 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
1071 OS_TEST="${target_cpu}"
1073 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
1075 #######################################################################
1076 # Master "Core Components" macros for getting the OS target           #
1077 #######################################################################
1080 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
1081 # cross-compilation.
1085 # Define and override various archtecture-specific variables, including
1086 # HOST_OS_ARCH
1087 # OS_ARCH
1088 # OS_TEST
1089 # OS_TARGET
1090 # OS_RELEASE
1091 # OS_MINOR_RELEASE
1094 case "$HOST_OS_ARCH" in
1095 mingw*)
1096     HOST_OS_ARCH=WINNT
1097     ;;
1098 darwin*)
1099     HOST_OS_ARCH=Darwin
1100     ;;
1101 linux*)
1102     HOST_OS_ARCH=Linux
1103     ;;
1104 solaris*)
1105     HOST_OS_ARCH=SunOS
1106     SOLARIS_SUNPRO_CC=
1107     SOLARIS_SUNPRO_CXX=
1108     if test -z "$GNU_CC"; then
1109         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1110             SOLARIS_SUNPRO_CC=1
1111        fi
1112     fi
1114     if test -z "$GNU_CXX"; then
1115        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1116            SOLARIS_SUNPRO_CXX=1
1117        fi
1118     fi
1119     AC_SUBST(SOLARIS_SUNPRO_CC)
1120     AC_SUBST(SOLARIS_SUNPRO_CXX)
1121     ;;
1122 OS_2)
1123     HOST_OS_ARCH=OS2
1124     ;;
1125 esac
1127 case "$OS_ARCH" in
1128 WINNT)
1129     if test -z "$CROSS_COMPILE" ; then
1130         OS_TEST=`uname -p`
1131     fi
1132     ;;
1133 Windows_NT)
1135 # If uname -s returns "Windows_NT", we assume that we are using
1136 # the uname.exe in MKS toolkit.
1138 # The -r option of MKS uname only returns the major version number.
1139 # So we need to use its -v option to get the minor version number.
1140 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1142     OS_ARCH=WINNT
1143     OS_TARGET=WINNT
1144     OS_MINOR_RELEASE=`uname -v`
1145     if test "$OS_MINOR_RELEASE" = "00"; then
1146         OS_MINOR_RELEASE=0
1147     fi
1148     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1149     ;;
1150 MINGW*_NT*)
1152 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1153 # the uname.exe in the MSYS tools.
1155     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1156     OS_ARCH=WINNT
1157     OS_TARGET=WINNT
1158     ;;
1159 AIX)
1160     OS_RELEASE=`uname -v`.`uname -r`
1161     OS_TEST=${target_cpu}
1162     ;;
1163 OS_2)
1164     OS_ARCH=OS2
1165     OS_TARGET=OS2
1166     OS_RELEASE=`uname -v`
1167     ;;
1168 Darwin)
1169     case "${target_cpu}" in
1170     powerpc*)
1171         OS_TEST=ppc
1172         ;;
1173     i*86*)
1174         OS_TEST=i386
1175         ;;
1176     x86_64)
1177         OS_TEST=x86_64
1178         ;;
1179     *)
1180         if test -z "$CROSS_COMPILE" ; then
1181             OS_TEST=`uname -p`
1182         fi
1183         ;;
1184     esac
1185     ;;
1186 esac
1188 # Only set CPU_ARCH if we recognize the value of OS_TEST
1190 case "$OS_TEST" in
1191 *86 | i86pc)
1192     CPU_ARCH=x86
1193     ;;
1195 powerpc64 | ppc64)
1196     CPU_ARCH=ppc64
1197     ;;
1199 powerpc | ppc | rs6000)
1200     CPU_ARCH=ppc
1201     ;;
1203 Alpha | alpha | ALPHA)
1204     CPU_ARCH=Alpha
1205     ;;
1207 s390)
1208     CPU_ARCH=s390
1209     ;;
1211 s390x)
1212     CPU_ARCH=s390x
1213     ;;
1215 hppa* | parisc)
1216     CPU_ARCH=hppa
1217     ;;
1219 sun4u | sparc*)
1220     CPU_ARCH=sparc
1221     ;;
1223 x86_64 | ia64)
1224     CPU_ARCH="$OS_TEST"
1225     ;;
1227 arm*)
1228     CPU_ARCH=arm
1229     ;;
1231 mips|mipsel)
1232     CPU_ARCH="mips"
1233     ;;
1234 esac
1236 if test -z "$OS_TARGET"; then
1237     OS_TARGET=$OS_ARCH
1239 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1241 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1242 dnl ===============================================================
1243 INTEL_ARCHITECTURE=
1244 case "$OS_TEST" in
1245     x86_64|i?86)
1246       INTEL_ARCHITECTURE=1
1247 esac
1249 dnl Configure platform-specific CPU architecture compiler options.
1250 dnl ==============================================================
1251 MOZ_ARCH_OPTS
1253 dnl =================================================================
1254 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1255 dnl which is bad when cross compiling.
1256 dnl =================================================================
1257 if test "$COMPILE_ENVIRONMENT"; then
1258 configure_static_assert_macros='
1259 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1260 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1261 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1264 dnl test that the macros actually work:
1265 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1266 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1267  [AC_LANG_SAVE
1268   AC_LANG_C
1269   ac_cv_static_assertion_macros_work="yes"
1270   AC_TRY_COMPILE([$configure_static_assert_macros],
1271                  [CONFIGURE_STATIC_ASSERT(1)],
1272                  ,
1273                  ac_cv_static_assertion_macros_work="no")
1274   AC_TRY_COMPILE([$configure_static_assert_macros],
1275                  [CONFIGURE_STATIC_ASSERT(0)],
1276                  ac_cv_static_assertion_macros_work="no",
1277                  )
1278   AC_LANG_CPLUSPLUS
1279   AC_TRY_COMPILE([$configure_static_assert_macros],
1280                  [CONFIGURE_STATIC_ASSERT(1)],
1281                  ,
1282                  ac_cv_static_assertion_macros_work="no")
1283   AC_TRY_COMPILE([$configure_static_assert_macros],
1284                  [CONFIGURE_STATIC_ASSERT(0)],
1285                  ac_cv_static_assertion_macros_work="no",
1286                  )
1287   AC_LANG_RESTORE
1288  ])
1289 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1290 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1291     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1293 fi # COMPILE_ENVIRONMENT
1295 dnl ========================================================
1296 dnl Android libstdc++, placed here so it can use MOZ_ARCH
1297 dnl computed above.
1298 dnl ========================================================
1300 MOZ_ANDROID_STLPORT
1302 dnl ========================================================
1303 dnl Suppress Clang Argument Warnings
1304 dnl ========================================================
1305 if test -n "$CLANG_CC"; then
1306     _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
1307     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
1309 if test -n "$CLANG_CXX"; then
1310     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
1313 dnl ========================================================
1314 dnl = Use Address Sanitizer
1315 dnl ========================================================
1316 MOZ_ARG_ENABLE_BOOL(address-sanitizer,
1317 [  --enable-address-sanitizer       Enable Address Sanitizer (default=no)],
1318     MOZ_ASAN=1,
1319     MOZ_ASAN= )
1320 if test -n "$MOZ_ASAN"; then
1321     MOZ_LLVM_HACKS=1
1322     AC_DEFINE(MOZ_ASAN)
1324 AC_SUBST(MOZ_ASAN)
1326 dnl ========================================================
1327 dnl = Enable hacks required for LLVM instrumentations
1328 dnl ========================================================
1329 MOZ_ARG_ENABLE_BOOL(llvm-hacks,
1330 [  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)],
1331     MOZ_LLVM_HACKS=1,
1332     MOZ_LLVM_HACKS= )
1333 if test -n "$MOZ_LLVM_HACKS"; then
1334     MOZ_NO_WLZDEFS=1
1335     MOZ_CFLAGS_NSS=1
1337 AC_SUBST(MOZ_NO_WLZDEFS)
1338 AC_SUBST(MOZ_CFLAGS_NSS)
1340 dnl ========================================================
1341 dnl GNU specific defaults
1342 dnl ========================================================
1343 if test "$GNU_CC"; then
1344     # Per bug 719659 comment 2, some of the headers on ancient build machines
1345     # may require gnu89 inline semantics.  But otherwise, we use C99.
1346     CFLAGS="$CFLAGS -std=gnu99 -fgnu89-inline"
1347     # FIXME: Let us build with strict aliasing. bug 414641.
1348     CFLAGS="$CFLAGS -fno-strict-aliasing"
1349     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1350     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1351     DSO_LDOPTS='-shared'
1352     if test "$GCC_USE_GNU_LD"; then
1353         # Some tools like ASan use a runtime library that is only
1354         # linked against executables, so we must allow undefined
1355         # symbols for shared objects in some cases.
1356         if test -z "$MOZ_NO_WLZDEFS"; then
1357             # Don't allow undefined symbols in libraries
1358             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1359         fi
1360     fi
1361     WARNINGS_AS_ERRORS='-Werror'
1362     # Don't treat -Wuninitialized as error b/c it has lots of false positives.
1363     WARNINGS_AS_ERRORS="$WARNINGS_AS_ERRORS -Wno-error=uninitialized"
1364     # Don't treat -Wdeprecated-declarations as error b/c we don't want our
1365     # builds held hostage when a platform-specific API is suddenly deprecated.
1366     WARNINGS_AS_ERRORS="$WARNINGS_AS_ERRORS -Wno-error=deprecated-declarations"
1367     DSO_CFLAGS=''
1368     DSO_PIC_CFLAGS='-fPIC'
1369     ASFLAGS="$ASFLAGS -fPIC"
1370     AC_MSG_CHECKING([for --noexecstack option to as])
1371     _SAVE_CFLAGS=$CFLAGS
1372     CFLAGS="$CFLAGS -Wa,--noexecstack"
1373     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
1374                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
1375                      AC_MSG_RESULT([no]))
1376     CFLAGS=$_SAVE_CFLAGS
1377     AC_MSG_CHECKING([for -z noexecstack option to ld])
1378     _SAVE_LDFLAGS=$LDFLAGS
1379     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
1380     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
1381                   AC_MSG_RESULT([no])
1382                   LDFLAGS=$_SAVE_LDFLAGS)
1383     AC_MSG_CHECKING([for --build-id option to ld])
1384     _SAVE_LDFLAGS=$LDFLAGS
1385     LDFLAGS="$LDFLAGS -Wl,--build-id"
1386     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1387                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,--build-id"],
1388                   AC_MSG_RESULT([no])
1389                   LDFLAGS=$_SAVE_LDFLAGS)
1392     # Check for -mssse3 on $CC
1393     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
1394     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
1395     _SAVE_CFLAGS=$CFLAGS
1396     CFLAGS="$CFLAGS -mssse3"
1397     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
1398                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
1399                      AC_MSG_RESULT([no]))
1400     CFLAGS=$_SAVE_CFLAGS
1401     AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
1403     # Check for -msse4.1 on $CC
1404     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
1405     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
1406     _SAVE_CFLAGS=$CFLAGS
1407     CFLAGS="$CFLAGS -msse4.1"
1408     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
1409                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
1410                      AC_MSG_RESULT([no]))
1411     CFLAGS=$_SAVE_CFLAGS
1412     AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
1414     # Turn on GNU-specific warnings:
1415     # -Wall - turn on a lot of warnings
1416     # -Wpointer-arith - good to have
1417     # -Wdeclaration-after-statement - MSVC doesn't like these
1418     # -Werror=return-type - catches missing returns, zero false positives
1419     # -Wtype-limits - catches overflow bugs, few false positives
1420     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1421     # -Wsign-compare - catches comparison of signed and unsigned types
1422     #
1423     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
1424     MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
1425     MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
1426     MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
1427     MOZ_C_SUPPORTS_WARNING(-W, sign-compare, ac_c_has_sign_compare)
1429     # Turn off the following warnings that -Wall turns on:
1430     # -Wno-unused - lots of violations in third-party code
1431     #
1432     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
1434     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
1435        # Don't use -Wcast-align with ICC or clang
1436        case "$CPU_ARCH" in
1437            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1438            hppa | ia64 | sparc | arm)
1439            ;;
1440            *)
1441         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1442            ;;
1443        esac
1444     fi
1446     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1447     _USE_CPP_INCLUDE_FLAG=1
1448     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
1450 elif test "$SOLARIS_SUNPRO_CC"; then
1451     DSO_CFLAGS=''
1452     if test "$CPU_ARCH" = "sparc"; then
1453         # for Sun Studio on Solaris/SPARC
1454         DSO_PIC_CFLAGS='-xcode=pic32'
1455     else
1456         DSO_PIC_CFLAGS='-KPIC'
1457     fi
1458     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1459 else
1460     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1461     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1463     DSO_LDOPTS='-shared'
1464     if test "$GNU_LD"; then
1465         # Don't allow undefined symbols in libraries
1466         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1467     fi
1469     DSO_CFLAGS=''
1470     DSO_PIC_CFLAGS='-KPIC'
1471     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1474 if test "$GNU_CXX"; then
1475     # FIXME: Let us build with strict aliasing. bug 414641.
1476     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
1478     # Turn on GNU-specific warnings:
1479     # -Wall - turn on a lot of warnings
1480     # -Wpointer-arith - good to have
1481     # -Woverloaded-virtual - ???
1482     # -Werror=return-type - catches missing returns, zero false positives
1483     # -Wtype-limits - catches overflow bugs, few false positives
1484     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1485     # -Wsign-compare - catches comparison of signed and unsigned types
1486     #
1487     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
1488     MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
1489     MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
1490     MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
1491     MOZ_CXX_SUPPORTS_WARNING(-W, sign-compare, ac_cxx_has_sign_compare)
1493     # Turn off the following warnings that -Wall turns on:
1494     # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
1495     #
1496     MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
1498     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
1499        # Don't use -Wcast-align with ICC or clang
1500        case "$CPU_ARCH" in
1501            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1502            hppa | ia64 | sparc | arm)
1503            ;;
1504            *)
1505         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1506            ;;
1507        esac
1508     fi
1510     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1511     _USE_CPP_INCLUDE_FLAG=1
1513     # Recent clang and gcc support C++11 deleted functions without warnings if
1514     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
1515     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
1516     # unused.  But clang's warning can be disabled, so when compiling with clang
1517     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
1518     # deleted function syntax.
1519     if test "$CLANG_CXX"; then
1520         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
1521         MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
1522     fi
1524 else
1525     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
1528 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1529 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1530 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1531 dnl normal behavior.
1532 dnl ========================================================
1533 MKSHLIB_FORCE_ALL=
1534 MKSHLIB_UNFORCE_ALL=
1536 if test "$COMPILE_ENVIRONMENT"; then
1537 if test "$GNU_CC"; then
1538   AC_MSG_CHECKING(whether ld has archive extraction flags)
1539   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1540    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1541     ac_cv_mkshlib_force_and_unforce="no"
1542     exec 3<&0 <<LOOP_INPUT
1543         force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1544         force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1545         force="-Wl,-all";              unforce="-Wl,-none"
1546 LOOP_INPUT
1547     while read line
1548     do
1549       eval $line
1550       LDFLAGS=$force
1551       LIBS=$unforce
1552       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1553     done
1554     exec 0<&3 3<&-
1555     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1556    ])
1557   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1558     AC_MSG_RESULT(no)
1559   else
1560     AC_MSG_RESULT(yes)
1561     eval $ac_cv_mkshlib_force_and_unforce
1562     MKSHLIB_FORCE_ALL=$force
1563     MKSHLIB_UNFORCE_ALL=$unforce
1564   fi
1565 fi # GNU_CC
1566 fi # COMPILE_ENVIRONMENT
1568 dnl ========================================================
1569 dnl Checking for 64-bit OS
1570 dnl ========================================================
1571 if test "$COMPILE_ENVIRONMENT"; then
1572 AC_LANG_SAVE
1573 AC_LANG_C
1574 AC_MSG_CHECKING(for 64-bit OS)
1575 AC_TRY_COMPILE([$configure_static_assert_macros],
1576                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1577                result="yes", result="no")
1578 AC_MSG_RESULT("$result")
1579 if test "$result" = "yes"; then
1580     AC_DEFINE(HAVE_64BIT_OS)
1581     HAVE_64BIT_OS=1
1583 AC_SUBST(HAVE_64BIT_OS)
1584 AC_LANG_RESTORE
1585 fi # COMPILE_ENVIRONMENT
1587 dnl ========================================================
1588 dnl Enable high-memory support on OS/2 by default.
1589 dnl ========================================================
1590 MOZ_OS2_HIGH_MEMORY=1
1591 MOZ_ARG_DISABLE_BOOL(os2-high-mem,
1592 [  --disable-os2-high-mem  Disable high-memory support on OS/2],
1593     MOZ_OS2_HIGH_MEMORY=,
1594     MOZ_OS2_HIGH_MEMORY=1 )
1595 AC_SUBST(MOZ_OS2_HIGH_MEMORY)
1597 dnl ========================================================
1598 dnl = Use profiling compile flags
1599 dnl ========================================================
1600 MOZ_ARG_ENABLE_BOOL(profiling,
1601 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1602     MOZ_PROFILING=1,
1603     MOZ_PROFILING= )
1605 # For profiling builds keep the symbol information
1606 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
1607     case "$OS_TARGET" in
1608     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
1609         STRIP_FLAGS="--strip-debug"
1610         ;;
1611     esac
1614 dnl ========================================================
1615 dnl = Use incremental GC
1616 dnl ========================================================
1617 JSGC_INCREMENTAL=1
1618 MOZ_ARG_DISABLE_BOOL(gcincremental,
1619 [  --disable-gcincremental Disable incremental GC],
1620     JSGC_INCREMENTAL= )
1621 if test -n "$JSGC_INCREMENTAL"; then
1622     AC_DEFINE(JSGC_INCREMENTAL)
1625 dnl ========================================================
1626 dnl = Use generational GC
1627 dnl ========================================================
1628 MOZ_ARG_ENABLE_BOOL(gcgenerational,
1629 [  --enable-gcgenerational Enable generational GC],
1630     JSGC_GENERATIONAL=1,
1631     JSGC_GENERATIONAL= )
1632 if test -n "$JSGC_GENERATIONAL"; then
1633     AC_DEFINE(JSGC_GENERATIONAL)
1636 dnl ========================================================
1637 dnl = Perform moving GC stack rooting analysis
1638 dnl ========================================================
1639 MOZ_ARG_ENABLE_BOOL(root-analysis,
1640 [  --enable-root-analysis  Enable moving GC stack root analysis],
1641     JSGC_ROOT_ANALYSIS=1,
1642     JSGC_ROOT_ANALYSIS= )
1643 if test -n "$JSGC_ROOT_ANALYSIS"; then
1644     AC_DEFINE(JSGC_ROOT_ANALYSIS)
1647 dnl ========================================================
1648 dnl = Use exact stack rooting for GC
1649 dnl ========================================================
1650 MOZ_ARG_ENABLE_BOOL(exact-rooting,
1651 [  --enable-exact-rooting  Enable use of exact stack roots for GC],
1652     JSGC_USE_EXACT_ROOTING=1,
1653     JSGC_USE_EXACT_ROOTING= )
1654 if test -n "$JSGC_USE_EXACT_ROOTING"; then
1655     AC_DEFINE(JSGC_USE_EXACT_ROOTING)
1658 dnl ========================================================
1659 dnl = Use Valgrind
1660 dnl ========================================================
1661 MOZ_ARG_ENABLE_BOOL(valgrind,
1662 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
1663     MOZ_VALGRIND=1,
1664     MOZ_VALGRIND= )
1665 if test -n "$MOZ_VALGRIND"; then
1666     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1667         AC_MSG_ERROR(
1668             [--enable-valgrind specified but Valgrind is not installed]))
1669     AC_DEFINE(MOZ_VALGRIND)
1671 AC_SUBST(MOZ_VALGRIND)
1673 dnl ========================================================
1674 dnl jprof
1675 dnl ========================================================
1676 MOZ_ARG_ENABLE_BOOL(jprof,
1677 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
1678     MOZ_JPROF=1,
1679     MOZ_JPROF= )
1680 if test -n "$MOZ_JPROF"; then
1681     MOZ_PROFILING=1
1682     AC_DEFINE(MOZ_JPROF)
1685 dnl ========================================================
1686 dnl SPS Profiler
1687 dnl ========================================================
1688 MOZ_ENABLE_PROFILER_SPS=1
1690 case "${OS_TARGET}" in
1691 Android)
1692     case "${CPU_ARCH}" in
1693     x86 | arm) ;;
1694     *)
1695         MOZ_ENABLE_PROFILER_SPS=
1696     esac
1697     ;;
1698 Linux)
1699     case "${CPU_ARCH}" in
1700     x86 | x86_64) ;;
1701     *)
1702         MOZ_ENABLE_PROFILER_SPS=
1703     esac
1704     ;;
1705 WINNT|Darwin) ;;
1707     MOZ_ENABLE_PROFILER_SPS=
1708     ;;
1709 esac
1711 if test -n "$MOZ_ENABLE_PROFILER_SPS"; then
1712     AC_DEFINE(MOZ_ENABLE_PROFILER_SPS)
1715 dnl ========================================================
1716 dnl shark
1717 dnl ========================================================
1718 MOZ_ARG_ENABLE_BOOL(shark,
1719 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
1720     MOZ_SHARK=1,
1721     MOZ_SHARK= )
1722 if test -n "$MOZ_SHARK"; then
1723     MOZ_PROFILING=1
1724     AC_DEFINE(MOZ_SHARK)
1727 dnl ========================================================
1728 dnl instruments
1729 dnl ========================================================
1730 MOZ_ARG_ENABLE_BOOL(instruments,
1731 [  --enable-instruments    Enable instruments remote profiling. Implies --enable-profiling.],
1732     MOZ_INSTRUMENTS=1,
1733     MOZ_INSTRUMENTS= )
1734 if test -n "$MOZ_INSTRUMENTS"; then
1735     MOZ_PROFILING=1
1736     AC_DEFINE(MOZ_INSTRUMENTS)
1739 dnl ========================================================
1740 dnl callgrind
1741 dnl ========================================================
1742 MOZ_ARG_ENABLE_BOOL(callgrind,
1743 [  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.],
1744     MOZ_CALLGRIND=1,
1745     MOZ_CALLGRIND= )
1746 if test -n "$MOZ_CALLGRIND"; then
1747     MOZ_PROFILING=1
1748     AC_DEFINE(MOZ_CALLGRIND)
1751 dnl ========================================================
1752 dnl vtune
1753 dnl ========================================================
1754 MOZ_ARG_ENABLE_BOOL(vtune,
1755 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
1756     MOZ_VTUNE=1,
1757     MOZ_VTUNE= )
1758 if test -n "$MOZ_VTUNE"; then
1759     MOZ_PROFILING=1
1760     AC_DEFINE(MOZ_VTUNE)
1763 dnl ========================================================
1764 dnl Profiling
1765 dnl ========================================================
1766 if test -n "$MOZ_PROFILING"; then
1767     AC_DEFINE(MOZ_PROFILING)
1770 dnl ========================================================
1771 dnl System overrides of the defaults for host
1772 dnl ========================================================
1773 case "$host" in
1774 *mingw*)
1775     if test -n "$_WIN32_MSVC"; then
1776         HOST_AR=lib
1777         HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
1778         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
1779         HOST_RANLIB='echo ranlib'
1780     else
1781         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
1782     fi
1783     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
1784     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1785     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1786     HOST_BIN_SUFFIX=.exe
1787     case "$host" in
1788     *mingw*)
1789         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1790         ;;
1791     esac
1793     case "${host_cpu}" in
1794     i*86)
1795         if test -n "$_WIN32_MSVC"; then
1796             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
1797         fi
1798         ;;
1799     x86_64)
1800         if test -n "$_WIN32_MSVC"; then
1801             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
1802         fi
1803         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1804         ;;
1805     esac
1806     ;;
1808 *-darwin*)
1809     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1810     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1811     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1812     ;;
1814 *-linux*|*-kfreebsd*-gnu|*-gnu*)
1815     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1816     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1817     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1818     ;;
1820 *os2*)
1821     HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
1822     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
1823     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1824     HOST_BIN_SUFFIX=.exe
1825     MOZ_FIX_LINK_PATHS=
1826     ;;
1829     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1830     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1831     ;;
1832 esac
1834 dnl Check for using a custom <stdint.h> implementation
1835 dnl ========================================================
1836 AC_MSG_CHECKING(for custom <stdint.h> implementation)
1837 if test "$MOZ_CUSTOM_STDINT_H"; then
1838   AC_DEFINE_UNQUOTED(MOZ_CUSTOM_STDINT_H, "$MOZ_CUSTOM_STDINT_H")
1839   AC_MSG_RESULT(using $MOZ_CUSTOM_STDINT_H)
1840 else
1841   AC_MSG_RESULT(none specified)
1844 dnl Get mozilla version from central milestone file
1845 MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
1846 MOZILLA_UAVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -uaversion`
1848 dnl Get version of various core apps from the version files.
1849 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
1851 if test -z "$FIREFOX_VERSION"; then
1852     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
1855 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
1856 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
1857 AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
1859 MOZ_DOING_LTO(lto_is_enabled)
1861 dnl ========================================================
1862 dnl System overrides of the defaults for target
1863 dnl ========================================================
1865 case "$target" in
1866 *-aix*)
1867     AC_DEFINE(AIX)
1868     if test ! "$GNU_CC"; then
1869         if test ! "$HAVE_64BIT_OS"; then
1870             # Compiling with Visual Age C++ object model compat is the
1871             # default. To compile with object model ibm, add
1872             # AIX_OBJMODEL=ibm to .mozconfig.
1873             if test "$AIX_OBJMODEL" = "ibm"; then
1874                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
1875             else
1876                 AIX_OBJMODEL=compat
1877             fi
1878         else
1879             AIX_OBJMODEL=compat
1880         fi
1881         AC_SUBST(AIX_OBJMODEL)
1882         DSO_LDOPTS='-qmkshrobj=1'
1883         DSO_CFLAGS='-qflag=w:w'
1884         DSO_PIC_CFLAGS=
1885         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
1886         MOZ_FIX_LINK_PATHS=
1887         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1888         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1889         if test "$COMPILE_ENVIRONMENT"; then
1890             AC_LANG_SAVE
1891             AC_LANG_CPLUSPLUS
1892             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
1893             AC_TRY_COMPILE([],
1894                 [#if (__IBMCPP__ < 900)
1895                  #error "Bad compiler"
1896                  #endif],
1897                 _BAD_COMPILER=,_BAD_COMPILER=1)
1898             if test -n "$_BAD_COMPILER"; then
1899                 AC_MSG_RESULT([no])
1900                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
1901             else
1902                 AC_MSG_RESULT([yes])
1903             fi
1904             AC_LANG_RESTORE
1905             TARGET_COMPILER_ABI="ibmc"
1906             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
1907             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
1908         fi
1909     fi
1910     case "${target_os}" in
1911     aix4.1*)
1912         DLL_SUFFIX='_shr.a'
1913         ;;
1914     esac
1915     if test "$COMPILE_ENVIRONMENT"; then
1916         MOZ_CHECK_HEADERS(sys/inttypes.h)
1917     fi
1918     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1919     ;;
1921 *-darwin*)
1922     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1923     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1924     MOZ_OPTIMIZE_FLAGS="-O3"
1925     # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
1926     if test "$HAVE_64BIT_OS"; then
1927         MOZ_MEMORY=1
1928     fi
1929     DLL_SUFFIX=".dylib"
1930     DSO_LDOPTS=''
1931     STRIP_FLAGS="$STRIP_FLAGS -x -S"
1932     # Check whether we're targeting OS X or iOS
1933     AC_CACHE_CHECK(for iOS target,
1934                    ac_cv_ios_target,
1935                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
1936 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
1937 #error not iOS
1938 #endif],
1939                                    [],
1940                                    ac_cv_ios_target="yes",
1941                                    ac_cv_ios_target="no")])
1942     if test "$ac_cv_ios_target" = "yes"; then
1943         AC_DEFINE(XP_IOS)
1944         AC_DEFINE(XP_DARWIN)
1945         _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
1946     else
1947         AC_DEFINE(XP_MACOSX)
1948         AC_DEFINE(XP_DARWIN)
1949         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
1950         # The ExceptionHandling framework is needed for Objective-C exception
1951         # logging code in nsObjCExceptions.h. Currently we only use that in debug
1952         # builds.
1953         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
1954     fi
1955     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1958     if test "x$lto_is_enabled" = "xyes"; then
1959         echo "Skipping -dead_strip because lto is enabled."
1960     dnl DTrace and -dead_strip don't interact well. See bug 403132.
1961     dnl ===================================================================
1962     elif test "x$enable_dtrace" = "xyes"; then
1963         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
1964     else
1965         dnl check for the presence of the -dead_strip linker flag
1966         AC_MSG_CHECKING([for -dead_strip option to ld])
1967         _SAVE_LDFLAGS=$LDFLAGS
1968         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
1969         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
1970         if test -n "$_HAVE_DEAD_STRIP" ; then
1971             AC_MSG_RESULT([yes])
1972             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
1973         else
1974             AC_MSG_RESULT([no])
1975         fi
1977         LDFLAGS=$_SAVE_LDFLAGS
1978     fi
1980     dnl With newer linkers we need to pass -allow_heap_execute because of
1981     dnl Microsoft Silverlight (5.1.10411.0 at least).
1982     AC_MSG_CHECKING([for -allow_heap_execute option to ld])
1983     _SAVE_LDFLAGS=$LDFLAGS
1984     LDFLAGS="$LDFLAGS -Wl,-allow_heap_execute"
1985     AC_TRY_LINK(,[return 0;],_HAVE_ALLOW_HEAP_EXECUTE=1,
1986                 _HAVE_ALLOW_HEAP_EXECUTE=)
1987     if test -n "$_HAVE_ALLOW_HEAP_EXECUTE" ; then
1988         AC_MSG_RESULT([yes])
1989         MOZ_ALLOW_HEAP_EXECUTE_FLAGS="-Wl,-allow_heap_execute"
1990     else
1991         AC_MSG_RESULT([no])
1992     fi
1993     LDFLAGS=$_SAVE_LDFLAGS
1995     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
1996     ;;
1998 ia64*-hpux*)
1999     DLL_SUFFIX=".so"
2000     if test ! "$GNU_CC"; then
2001        DSO_LDOPTS='-b'
2002        DSO_CFLAGS=""
2003        DSO_PIC_CFLAGS=
2004        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
2005        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
2006        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2007     else
2008        DSO_LDOPTS='-b -E'
2009        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2010        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2011     fi
2012     MOZ_FIX_LINK_PATHS=
2013     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2014     AC_DEFINE(_LARGEFILE64_SOURCE)
2015     ;;
2017 *-hpux*)
2018     DLL_SUFFIX=".sl"
2019     if test ! "$GNU_CC"; then
2020         DSO_LDOPTS='-b -Wl,+s'
2021         DSO_CFLAGS=""
2022         DSO_PIC_CFLAGS="+Z"
2023         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
2024         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
2025         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2026     else
2027         DSO_LDOPTS='-b -E +s'
2028         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2029         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2030     fi
2031     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
2032     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2033     ;;
2035 *-android*|*-linuxandroid*)
2036     AC_DEFINE(NO_PW_GECOS)
2037     no_x=yes
2038     if test -n "$gonkdir"; then
2039         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
2040         MOZ_B2G_RIL=1
2041         MOZ_B2G_FM=1
2042     else
2043         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
2044         MOZ_LINKER=1
2045     fi
2046     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2048     MOZ_GFX_OPTIMIZE_MOBILE=1
2049     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
2050     ;;
2052 *-*linux*)
2053     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2054     # Similarly for GNU_CXX and INTEL_CXX.
2055     if test "$INTEL_CC" -o "$INTEL_CXX"; then
2056         # -Os has been broken on Intel's C/C++ compilers for quite a
2057         # while; Intel recommends against using it.
2058         MOZ_OPTIMIZE_FLAGS="-O2"
2059         MOZ_DEBUG_FLAGS="-g"
2060     elif test "$GNU_CC" -o "$GNU_CXX"; then
2061         case $GCC_VERSION in
2062         4.5.*)
2063             # -Os is broken on gcc 4.5.x we need to tweak it to get good results.
2064             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
2065         esac
2066         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
2067         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
2068         MOZ_DEBUG_FLAGS="-g"
2069     fi
2071     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2073     MOZ_MEMORY=1
2075     case "${target_cpu}" in
2076     alpha*)
2077         CFLAGS="$CFLAGS -mieee"
2078         CXXFLAGS="$CXXFLAGS -mieee"
2079     ;;
2080     i*86)
2081         USE_ELF_DYNSTR_GC=1
2082     ;;
2083     mips*)
2084         MOZ_DEBUG_FLAGS="-g" # We want inlining
2085     ;;
2086     esac
2088     if test -z "$MC"; then
2089         MC=mc.exe
2090     fi
2091     ;;
2092 *-mingw*)
2093     DSO_CFLAGS=
2094     DSO_PIC_CFLAGS=
2095     DLL_SUFFIX=.dll
2096     RC=rc.exe
2097     MC=mc.exe
2098     # certain versions of cygwin's makedepend barf on the
2099     # #include <string> vs -I./dist/include/string issue so don't use it
2100     if test -n "$GNU_CC"; then
2101         CC="$CC -mwindows"
2102         CXX="$CXX -mwindows"
2103         CPP="$CPP -mwindows"
2104         CFLAGS="$CFLAGS -mms-bitfields"
2105         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2106         DSO_LDOPTS='-shared'
2107         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2108         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2109         RC='$(WINDRES)'
2110         # Use static libgcc and libstdc++
2111         LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
2112         # Use temp file for windres (bug 213281)
2113         RCFLAGS='-O coff --use-temp-file'
2114         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2115         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32 -lnetapi32"
2116         MOZ_FIX_LINK_PATHS=
2117         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxul -lxpcom_core -lmozalloc'
2118         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxul -lmozalloc'
2119         DLL_PREFIX=
2120         IMPORT_LIB_SUFFIX=dll.a
2122         # We use mix of both POSIX and Win32 printf format across the tree, so format
2123         # warnings are useless on mingw.
2124         MOZ_C_SUPPORTS_WARNING(-Wno-, format, ac_c_has_wno_format)
2125         MOZ_CXX_SUPPORTS_WARNING(-Wno-, format, ac_cxx_has_wno_format)
2126     else
2127         TARGET_COMPILER_ABI=msvc
2128         HOST_CC='$(CC)'
2129         HOST_CXX='$(CXX)'
2130         HOST_LD='$(LD)'
2131         if test "$AS_BIN"; then
2132             AS="$(basename "$AS_BIN")"
2133         fi
2134         AR='lib'
2135         AR_FLAGS='-NOLOGO -OUT:"$@"'
2136         AR_EXTRACT=
2137         RANLIB='echo not_ranlib'
2138         STRIP='echo not_strip'
2139         PKG_SKIP_STRIP=1
2140         XARGS=xargs
2141         ZIP=zip
2142         UNZIP=unzip
2143         DOXYGEN=:
2144         ASM_SUFFIX=asm
2145         OBJ_SUFFIX=obj
2146         LIB_SUFFIX=lib
2147         DLL_PREFIX=
2148         LIB_PREFIX=
2149         IMPORT_LIB_SUFFIX=lib
2150         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2151         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2152         MKSHLIB_FORCE_ALL=
2153         MKSHLIB_UNFORCE_ALL=
2154         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2155         _USE_CPP_INCLUDE_FLAG=1
2156         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2157         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2158         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2159         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2160         # khuey says we can safely ignore MSVC warning C4251
2161         # MSVC warning C4244 (implicit type conversion may lose data) warns
2162         # and requires workarounds for perfectly valid code.  Also, GCC/clang
2163         # don't warn about it by default. So for consistency/sanity, we turn
2164         # it off on MSVC, too.
2165         # MSVC warning C4345 warns of newly conformant behavior as of VS2003.
2166         # MSVC warning C4351 warns of newly conformant behavior as of VS2005.
2167         # MSVC warning C4482 warns when an enum value is refered specifing the
2168         # name of the enum itself.  This behavior is allowed in C++11, and the
2169         # warning has been removed in VS2012.
2170         # MSVC warning C4800 warns when a value is implicitly cast to bool,
2171         # because this also forces narrowing to a single byte, which can be a
2172         # perf hit.  But this matters so little in practice (and often we want
2173         # that behavior) that it's better to turn it off.
2174         # MSVC warning C4819 warns some UTF-8 characters (e.g. copyright sign)
2175         # on non-Western system locales even if it is in a comment.
2176         CFLAGS="$CFLAGS -wd4244 -wd4819"
2177         CXXFLAGS="$CXXFLAGS -wd4251 -wd4244 -wd4345 -wd4351 -wd4482 -wd4800 -wd4819"
2178         # make 'foo == bar;' error out
2179         CFLAGS="$CFLAGS -we4553"
2180         CXXFLAGS="$CXXFLAGS -we4553"
2181         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib netapi32.lib"
2182         MOZ_DEBUG_FLAGS='-Zi'
2183         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2184         WARNINGS_AS_ERRORS='-WX'
2185         MOZ_OPTIMIZE_FLAGS='-O1'
2186         MOZ_FIX_LINK_PATHS=
2187         DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2188         XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2189         LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2190         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2191         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT -RELEASE"
2192         dnl For profile-guided optimization
2193         PROFILE_GEN_CFLAGS="-GL"
2194         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2195         dnl XXX: PGO builds can fail with warnings treated as errors,
2196         dnl specifically "no profile data available" appears to be
2197         dnl treated as an error sometimes. This might be a consequence
2198         dnl of using WARNINGS_AS_ERRORS in some modules, combined
2199         dnl with the linker doing most of the work in the whole-program
2200         dnl optimization/PGO case. I think it's probably a compiler bug,
2201         dnl but we work around it here.
2202         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2203         dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2204         dnl Probably also a compiler bug, but what can you do?
2205         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2206         LDFLAGS="$LDFLAGS -DYNAMICBASE"
2207         if test "$_MSC_VER" -ge 1500; then
2208             dnl VS2008 or later supports SSSE3
2209             HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
2210             AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
2211         fi
2212     fi
2213     AC_DEFINE(HAVE_SNPRINTF)
2214     AC_DEFINE(_WINDOWS)
2215     AC_DEFINE(WIN32)
2216     AC_DEFINE(XP_WIN)
2217     AC_DEFINE(XP_WIN32)
2218     AC_DEFINE(HW_THREADS)
2219     AC_DEFINE(STDC_HEADERS)
2220     AC_DEFINE(NEW_H, <new>)
2221     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2222     TARGET_MD_ARCH=win32
2223     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2224     BIN_SUFFIX='.exe'
2225     MOZ_USER_DIR="Mozilla"
2227     dnl Hardcode to win95 for now - cls
2228     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2230     dnl set NO_X11 defines here as the general check is skipped on win32
2231     no_x=yes
2232     AC_DEFINE(NO_X11)
2234     case "$host" in
2235     *-mingw*)
2236         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2237         if test -n "$L10NBASEDIR"; then
2238             L10NBASEDIR=`cd $L10NBASEDIR && pwd -W`
2239         fi
2240         ;;
2241     esac
2243     case "$host" in
2244     *-mingw*)
2245         if test -z "$MOZ_TOOLS"; then
2246             AC_MSG_ERROR([MOZ_TOOLS is not set])
2247         fi
2248         MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2249         if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2250             AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2251         fi
2252         MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2253         if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2254             AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2255         fi
2256         ;;
2257     esac
2259     case "$host_os" in
2260     cygwin*|msvc*|mks*)
2261         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.])
2262         ;;
2263     esac
2265     case "$target" in
2266     i*86-*)
2267         if test "$HAVE_64BIT_OS"; then
2268             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2269         fi
2271         if test -n "$GNU_CC"; then
2272             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
2273             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
2274             LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup -Wl,--large-address-aware"
2275         else
2276             AC_DEFINE(HAVE_STDCALL)
2277             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
2278             LDFLAGS="$LDFLAGS -SAFESEH"
2279         fi
2281         AC_DEFINE(_X86_)
2282         ;;
2283     x86_64-*)
2284         if test -n "$_WIN32_MSVC"; then
2285             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
2286         fi
2287         AC_DEFINE(_AMD64_)
2288         ;;
2289     *)
2290         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2291         ;;
2292     esac
2294     if test "$HAVE_64BIT_OS"; then
2295         AC_DEFINE(_WIN64)
2296     fi
2297     ;;
2299 *-netbsd*)
2300     DSO_CFLAGS=''
2301     CFLAGS="$CFLAGS -Dunix"
2302     CXXFLAGS="$CXXFLAGS -Dunix"
2303     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2304         DLL_SUFFIX=".so"
2305         DSO_PIC_CFLAGS='-fPIC -DPIC'
2306         DSO_LDOPTS='-shared'
2307         BIN_FLAGS='-Wl,--export-dynamic'
2308     else
2309         DSO_PIC_CFLAGS='-fPIC -DPIC'
2310         DLL_SUFFIX=".so.1.0"
2311         DSO_LDOPTS='-shared'
2312     fi
2313     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2314     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2315     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2316     if test "$LIBRUNPATH"; then
2317         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2318     fi
2319     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2320     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2321     ;;
2323 *-openbsd*)
2324     if test "$SO_VERSION"; then
2325         DLL_SUFFIX=".so.$SO_VERSION"
2326     else
2327         DLL_SUFFIX=".so.1.0"
2328     fi
2329     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
2330     DSO_CFLAGS=''
2331     DSO_PIC_CFLAGS='-fPIC'
2332     DSO_LDOPTS='-shared -fPIC'
2333     if test "$LIBRUNPATH"; then
2334         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2335     fi
2336     ;;
2338 *-os2*)
2339     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2340     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2341     AC_DEFINE(OS2)
2342     AC_DEFINE(XP_OS2)
2343     AC_DEFINE(OS2EMX_PLAIN_CHAR)
2344     AC_DEFINE(TCPV40HDRS)
2345     DLL_PREFIX=
2346     LIB_PREFIX=
2347     LIB_SUFFIX=lib
2348     BIN_SUFFIX=".exe"
2349     DLL_SUFFIX=".dll"
2350     IMPORT_LIB_SUFFIX=lib
2351     DSO_PIC_CFLAGS=
2352     AR=emxomfar
2353     AR_FLAGS='r $@'
2354     CFLAGS="$CFLAGS -Zomf"
2355     CXXFLAGS="$CXXFLAGS -Zomf"
2356     DSO_LDOPTS='-Zdll'
2357     BIN_FLAGS='-Zlinker /ST:0x100000'
2358     IMPLIB='emximp -o'
2359     FILTER='true'
2360     LDFLAGS='-Zmap'
2361     WARNINGS_AS_ERRORS='-Werror'
2362     MOZ_DEBUG_FLAGS="-g -fno-inline"
2363     MOZ_OPTIMIZE_FLAGS="-O2"
2364     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2365     DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2366     LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2367     TARGET_MD_ARCH=os2
2368     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
2369     RC=rc.exe
2370     MC=mc.exe
2371     RCFLAGS='-n'
2372     MOZ_USER_DIR="Mozilla"
2373     ZIP="$ZIP -X"
2374     STRIP=lxlite
2375     STRIP_FLAGS="/yua /ydd /yxd /ynl /anp /b- /cs+ /d /i- /ml1 /mr2 /mf2 /r+ /u+ /x- /zs:0 /zx /zd"
2377     if test "$MOZTOOLS"; then
2378         MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
2379     else
2380         AC_MSG_ERROR([MOZTOOLS is not set])
2381     fi
2382     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2383         DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2384         LDFLAGS="$LDFLAGS -Zhigh-mem"
2385         MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
2386         AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2387     fi
2389     # GCC for OS/2 currently predefines these, but we don't want them
2390     _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
2391     _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
2393     AC_CACHE_CHECK(for __declspec(dllexport),
2394         ac_os2_declspec,
2395         [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
2396                         [return 0;],
2397                         ac_os2_declspec="yes",
2398                         ac_os2_declspec="no")])
2399     if test "$ac_os2_declspec" != "yes"; then
2400         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
2401     fi
2402     ;;
2404 *-solaris*)
2405     AC_DEFINE(SOLARIS)
2406     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2407     MOZ_FIX_LINK_PATHS=
2408     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2409     # libraries one level up (e.g. libnspr4.so)
2410     if test "$SOLARIS_SUNPRO_CC"; then
2411        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2412        LIBS="-lCrun -lCstd -lc $LIBS"
2413        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2414        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2415        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2416        LDFLAGS="-xildoff $LDFLAGS"
2417        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2418            _SAVE_LDFLAGS=$LDFLAGS
2419            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
2420            AC_TRY_LINK([#include <stdio.h>],
2421                        [printf("Hello World\n");],
2422                        ,
2423                        [LDFLAGS=$_SAVE_LDFLAGS])
2424        fi
2425        MOZ_OPTIMIZE_FLAGS="-xO4"
2426        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2427        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2428        MKSHLIB_FORCE_ALL='-z allextract'
2429        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2430        DSO_LDOPTS='-G'
2431        AR_LIST="$AR t"
2432        AR_EXTRACT="$AR x"
2433        AR_DELETE="$AR d"
2434        AR='$(CXX) -xar'
2435        AR_FLAGS='-o $@'
2436        AS='/usr/ccs/bin/as'
2437        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2438        AS_DASH_C_FLAG=''
2439        TARGET_COMPILER_ABI="sunc"
2440        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2441        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2442        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2443        AC_LANG_SAVE
2444        AC_LANG_CPLUSPLUS
2445        AC_TRY_COMPILE([],
2446            [#if (__SUNPRO_CC < 0x590)
2447            #error "Denied"
2448            #endif],
2449            _BAD_COMPILER=,_BAD_COMPILER=1)
2450        if test -n "$_BAD_COMPILER"; then
2451            _res="no"
2452            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2453        else
2454            _res="yes"
2455        fi
2456        AC_TRY_COMPILE([],
2457            [#if (__SUNPRO_CC >= 0x5100)
2458            #error "Sun C++ 5.10 or above"
2459            #endif],
2460            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2461        if test "$_ABOVE_SS12U1"; then
2462            # disable xannotate
2463            CXXFLAGS="$CXXFLAGS -xannotate=no"
2464        fi
2465        AC_MSG_RESULT([$_res])
2466        AC_LANG_RESTORE
2467     else
2468        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2469        LIBS="-lc $LIBS"
2470        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2471        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2472        ASFLAGS="$ASFLAGS -fPIC"
2473        DSO_LDOPTS='-shared'
2474        WARNINGS_AS_ERRORS='-Werror'
2475        _WARNINGS_CFLAGS=''
2476        _WARNINGS_CXXFLAGS=''
2477        if test "$OS_RELEASE" = "5.3"; then
2478            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2479        fi
2480     fi
2481     if test "$OS_RELEASE" = "5.5.1"; then
2482         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2483     fi
2484     ;;
2486 *-sunos*)
2487     DSO_LDOPTS='-Bdynamic'
2488     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2489     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2490     AC_DEFINE(SUNOS4)
2491     AC_DEFINE(SPRINTF_RETURNS_STRING)
2492     case "$(target_os)" in
2493     sunos4.1*)
2494         DLL_SUFFIX='.so.1.0'
2495         ;;
2496     esac
2497     ;;
2499 *-os2*)
2500     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2501     ;;
2503 esac
2505 AC_SUBST(MOZ_LINKER)
2506 if test -n "$MOZ_LINKER"; then
2507   AC_DEFINE(MOZ_LINKER)
2510 dnl Only one oddball right now (QNX), but this gives us flexibility
2511 dnl if any other platforms need to override this in the future.
2512 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2514 dnl ========================================================
2515 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2516 dnl by now will not have any way to link most binaries (tests
2517 dnl as well as viewer, apprunner, etc.), because some symbols
2518 dnl will be left out of the "composite" .so's by ld as unneeded.
2519 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2520 dnl they can link in the static libs that provide the missing
2521 dnl symbols.
2522 dnl ========================================================
2523 NO_LD_ARCHIVE_FLAGS=
2524 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2525     NO_LD_ARCHIVE_FLAGS=1
2527 case "$target" in
2528 *-os2*)
2529     NO_LD_ARCHIVE_FLAGS=
2530     ;;
2531 *-aix4.3*|*-aix5*)
2532     NO_LD_ARCHIVE_FLAGS=
2533     ;;
2534 *-mingw*)
2535     if test -z "$GNU_CC"; then
2536         NO_LD_ARCHIVE_FLAGS=
2537     fi
2538     ;;
2539 esac
2540 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2542 dnl ========================================================
2543 dnl = Flags to strip unused symbols from .so components and
2544 dnl = to export jemalloc symbols when linking a program
2545 dnl ========================================================
2546 case "$target" in
2547     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2548         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2549         ;;
2550     *-solaris*)
2551         if test -z "$GNU_CC"; then
2552          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2553         else
2554          if test -z "$GCC_USE_GNU_LD"; then
2555           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2556          else
2557           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2558          fi
2559         fi
2560         ;;
2561     *-darwin*)
2562         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2563         ;;
2564     *-mingw*)
2565         if test -n "$GNU_CC"; then
2566            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2567         fi
2568         ;;
2569 esac
2571 if test -z "$COMPILE_ENVIRONMENT"; then
2572     SKIP_COMPILER_CHECKS=1
2573     SKIP_LIBRARY_CHECKS=1
2576 MOZ_COMPILER_OPTS
2577 if test -z "$SKIP_COMPILER_CHECKS"; then
2578 dnl Checks for typedefs, structures, and compiler characteristics.
2579 dnl ========================================================
2580 AC_HEADER_STDC
2581 AC_C_CONST
2582 AC_TYPE_MODE_T
2583 AC_TYPE_OFF_T
2584 AC_TYPE_PID_T
2585 AC_TYPE_SIZE_T
2586 AC_LANG_CPLUSPLUS
2587 AC_MSG_CHECKING(for __stdcall)
2588 AC_CACHE_VAL(ac_cv___stdcall,
2589  [AC_TRY_COMPILE([template <typename Method> struct foo;
2590                   template <> struct foo<void (*)()> {};
2591                   template <> struct foo<void (__stdcall*)()> {};],
2592                  [],
2593                  [ac_cv___stdcall=true],
2594                  [ac_cv___stdcall=false])])
2595 if test "$ac_cv___stdcall" = true ; then
2596   AC_DEFINE(HAVE_STDCALL)
2597   AC_MSG_RESULT(yes)
2598 else
2599   AC_MSG_RESULT(no)
2601 AC_LANG_C
2602 AC_MSG_CHECKING(for ssize_t)
2603 AC_CACHE_VAL(ac_cv_type_ssize_t,
2604  [AC_TRY_COMPILE([#include <stdio.h>
2605                   #include <sys/types.h>],
2606                  [ssize_t foo = 0;],
2607                  [ac_cv_type_ssize_t=true],
2608                  [ac_cv_type_ssize_t=false])])
2609 if test "$ac_cv_type_ssize_t" = true ; then
2610   AC_DEFINE(HAVE_SSIZE_T)
2611   AC_MSG_RESULT(yes)
2612 else
2613   AC_MSG_RESULT(no)
2615 AC_STRUCT_ST_BLKSIZE
2616 AC_MSG_CHECKING(for siginfo_t)
2617 AC_CACHE_VAL(ac_cv_siginfo_t,
2618  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
2619                   #include <signal.h>],
2620                  [siginfo_t* info;],
2621                  [ac_cv_siginfo_t=true],
2622                  [ac_cv_siginfo_t=false])])
2623 if test "$ac_cv_siginfo_t" = true ; then
2624   AC_DEFINE(HAVE_SIGINFO_T)
2625   AC_MSG_RESULT(yes)
2626 else
2627   AC_MSG_RESULT(no)
2630 dnl Check for int64, uint, and uint_t.
2631 dnl ========================================================
2632 AC_MSG_CHECKING(for int64)
2633 AC_CACHE_VAL(ac_cv_int64,
2634  [AC_TRY_COMPILE([#include <stdio.h>
2635                   #include <sys/types.h>],
2636                  [int64 foo = 0;],
2637                  [ac_cv_int64=true],
2638                  [ac_cv_int64=false])])
2639 if test "$ac_cv_int64" = true ; then
2640   AC_DEFINE(HAVE_INT64)
2641   AC_MSG_RESULT(yes)
2642 else
2643   AC_MSG_RESULT(no)
2645 AC_MSG_CHECKING(for uint)
2646 AC_CACHE_VAL(ac_cv_uint,
2647  [AC_TRY_COMPILE([#include <stdio.h>
2648                   #include <sys/types.h>],
2649                  [uint foo = 0;],
2650                  [ac_cv_uint=true],
2651                  [ac_cv_uint=false])])
2652 if test "$ac_cv_uint" = true ; then
2653   AC_DEFINE(HAVE_UINT)
2654   AC_MSG_RESULT(yes)
2655 else
2656   AC_MSG_RESULT(no)
2658 AC_MSG_CHECKING(for uint_t)
2659 AC_CACHE_VAL(ac_cv_uint_t,
2660  [AC_TRY_COMPILE([#include <stdio.h>
2661                   #include <sys/types.h>],
2662                  [uint_t foo = 0;],
2663                  [ac_cv_uint_t=true],
2664                  [ac_cv_uint_t=false])])
2665 if test "$ac_cv_uint_t" = true ; then
2666   AC_DEFINE(HAVE_UINT_T)
2667   AC_MSG_RESULT(yes)
2668 else
2669   AC_MSG_RESULT(no)
2672 dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
2673 dnl are defined when compiling C++ but not C.  Since the result of this
2674 dnl test is used only in C++, do it in C++.
2675 AC_LANG_CPLUSPLUS
2677 AC_MSG_CHECKING(for uname.domainname)
2678 AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
2679     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2680         [ struct utsname *res; char *domain;
2681             (void)uname(res);  if (res != 0) { domain = res->domainname; } ],
2682         [ac_cv_have_uname_domainname_field=true],
2683         [ac_cv_have_uname_domainname_field=false])])
2685 if test "$ac_cv_have_uname_domainname_field" = "true"; then
2686     AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
2687     AC_MSG_RESULT(yes)
2688 else
2689     AC_MSG_RESULT(no)
2692 AC_MSG_CHECKING(for uname.__domainname)
2693 AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
2694     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2695         [ struct utsname *res; char *domain;
2696             (void)uname(res);  if (res != 0) { domain = res->__domainname; } ],
2697         [ac_cv_have_uname_us_domainname_field=true],
2698         [ac_cv_have_uname_us_domainname_field=false])])
2700 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
2701     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
2702     AC_MSG_RESULT(yes)
2703 else
2704     AC_MSG_RESULT(no)
2707 dnl Check whether we can use gcc's c++0x mode
2708 AC_LANG_CPLUSPLUS
2710 if test "$GNU_CXX"; then
2711     _SAVE_CXXFLAGS=$CXXFLAGS
2712     CXXFLAGS="$CXXFLAGS -std=gnu++0x"
2714     AC_CACHE_CHECK(for gcc c++0x headers bug without rtti,
2715         ac_cv_cxx0x_headers_bug,
2716         [AC_TRY_COMPILE([#include <memory>], [],
2717                         ac_cv_cxx0x_headers_bug="no",
2718                         ac_cv_cxx0x_headers_bug="yes")])
2720     if test "$CLANG_CXX" -a "$ac_cv_cxx0x_headers_bug" = "yes"; then
2721         CXXFLAGS="$CXXFLAGS -I$_topsrcdir/build/unix/headers"
2722         AC_CACHE_CHECK(whether workaround for gcc c++0x headers conflict with clang works,
2723             ac_cv_cxx0x_clang_workaround,
2724             [AC_TRY_COMPILE([#include <memory>], [],
2725                             ac_cv_cxx0x_clang_workaround="yes",
2726                             ac_cv_cxx0x_clang_workaround="no")])
2728         if test "ac_cv_cxx0x_clang_workaround" = "no"; then
2729             CXXFLAGS="$_SAVE_CXXFLAGS"
2730         fi
2731     elif test "$ac_cv_cxx0x_headers_bug" = "yes"; then
2732         CXXFLAGS="$_SAVE_CXXFLAGS"
2733     fi
2736 dnl Check for usable char16_t (2 bytes, unsigned)
2737 dnl (we might not need the unsignedness check anymore)
2738 AC_CACHE_CHECK(for usable char16_t (2 bytes, unsigned),
2739     ac_cv_have_usable_char16_t,
2740     [AC_TRY_COMPILE([$configure_static_assert_macros],
2741                     [CONFIGURE_STATIC_ASSERT(sizeof(char16_t) == 2);
2742                      CONFIGURE_STATIC_ASSERT(char16_t(-1) > char16_t(0));
2743                      CONFIGURE_STATIC_ASSERT(sizeof((u"hello")[0]) == 2);
2744                      CONFIGURE_STATIC_ASSERT(sizeof(u'a') == 2);
2745                      CONFIGURE_STATIC_ASSERT(u'\xFFFF' > u'\x0')],
2746                     ac_cv_have_usable_char16_t="yes",
2747                     ac_cv_have_usable_char16_t="no")])
2748 if test "$ac_cv_have_usable_char16_t" = "yes"; then
2749     AC_DEFINE(HAVE_CPP_CHAR16_T)
2750     HAVE_CPP_CHAR16_T=1
2751 elif test "$GNU_CXX"; then
2752     CXXFLAGS="$_SAVE_CXXFLAGS"
2755 dnl Check for usable wchar_t (2 bytes, unsigned)
2756 dnl (we really don't need the unsignedness check anymore)
2757 dnl ========================================================
2759 AC_CACHE_CHECK(for usable wchar_t (2 bytes, unsigned),
2760     ac_cv_have_usable_wchar_v2,
2761     [AC_TRY_COMPILE([#include <stddef.h>
2762                      $configure_static_assert_macros],
2763                     [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
2764                      CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
2765                     ac_cv_have_usable_wchar_v2="yes",
2766                     ac_cv_have_usable_wchar_v2="no")])
2767 if test "$ac_cv_have_usable_wchar_v2" = "yes"; then
2768     AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
2769     HAVE_CPP_2BYTE_WCHAR_T=1
2770 elif test "$ac_cv_have_usable_char16_t" != "yes"; then
2771 dnl This is really gcc-only
2772 dnl Do this test using CXX only since some versions of gcc
2773 dnl 2.95-2.97 have a signed wchar_t in c++ only and some versions
2774 dnl only have short-wchar support for c++.
2775 dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
2777     _SAVE_CXXFLAGS=$CXXFLAGS
2778     CXXFLAGS="$CXXFLAGS -fshort-wchar"
2780     AC_CACHE_CHECK(for compiler -fshort-wchar option,
2781         ac_cv_have_usable_wchar_option_v2,
2782         [AC_TRY_LINK([#include <stddef.h>
2783                       $configure_static_assert_macros],
2784                      [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
2785                       CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
2786                      ac_cv_have_usable_wchar_option_v2="yes",
2787                      ac_cv_have_usable_wchar_option_v2="no")])
2789     if test "$ac_cv_have_usable_wchar_option_v2" = "yes"; then
2790         AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
2791         HAVE_CPP_2BYTE_WCHAR_T=1
2792         if test "$OS_TARGET" = Android; then
2793             WCHAR_CFLAGS="-fshort-wchar -Wl,--no-wchar-size-warning"
2794             CXXFLAGS="$CXXFLAGS -Wl,--no-wchar-size-warning"
2795             CFLAGS="$CFLAGS -Wl,--no-wchar-size-warning"
2796             DSO_LDOPTS="$DSO_LDOPTS -Wl,--no-wchar-size-warning"
2797         else
2798             WCHAR_CFLAGS="-fshort-wchar"
2799         fi
2800     else
2801         CXXFLAGS=$_SAVE_CXXFLAGS
2802     fi
2805 AC_LANG_C
2807 dnl Check for .hidden assembler directive and visibility attribute.
2808 dnl Borrowed from glibc configure.in
2809 dnl ===============================================================
2810 if test "$GNU_CC"; then
2811   AC_CACHE_CHECK(for visibility(hidden) attribute,
2812                  ac_cv_visibility_hidden,
2813                  [cat > conftest.c <<EOF
2814                   int foo __attribute__ ((visibility ("hidden"))) = 1;
2816                   ac_cv_visibility_hidden=no
2817                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2818                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2819                       ac_cv_visibility_hidden=yes
2820                     fi
2821                   fi
2822                   rm -f conftest.[cs]
2823                  ])
2824   if test "$ac_cv_visibility_hidden" = "yes"; then
2825     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
2827     AC_CACHE_CHECK(for visibility(default) attribute,
2828                    ac_cv_visibility_default,
2829                    [cat > conftest.c <<EOF
2830                     int foo __attribute__ ((visibility ("default"))) = 1;
2832                     ac_cv_visibility_default=no
2833                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2834                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2835                         ac_cv_visibility_default=yes
2836                       fi
2837                     fi
2838                     rm -f conftest.[cs]
2839                    ])
2840     if test "$ac_cv_visibility_default" = "yes"; then
2841       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
2843       AC_CACHE_CHECK(for visibility pragma support,
2844                      ac_cv_visibility_pragma,
2845                      [cat > conftest.c <<EOF
2846 #pragma GCC visibility push(hidden)
2847                       int foo_hidden = 1;
2848 #pragma GCC visibility push(default)
2849                       int foo_default = 1;
2851                       ac_cv_visibility_pragma=no
2852                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2853                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
2854                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
2855                             ac_cv_visibility_pragma=yes
2856                           fi
2857                         fi
2858                       fi
2859                       rm -f conftest.[cs]
2860                     ])
2861       if test "$ac_cv_visibility_pragma" = "yes"; then
2862         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
2863                        ac_cv_have_visibility_class_bug,
2864                        [cat > conftest.c <<EOF
2865 #pragma GCC visibility push(hidden)
2866 struct __attribute__ ((visibility ("default"))) TestStruct {
2867   static void Init();
2869 __attribute__ ((visibility ("default"))) void TestFunc() {
2870   TestStruct::Init();
2873                        ac_cv_have_visibility_class_bug=no
2874                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2875                          ac_cv_have_visibility_class_bug=yes
2876                        else
2877                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
2878                            ac_cv_have_visibility_class_bug=yes
2879                          fi
2880                        fi
2881                        rm -rf conftest.{c,S}
2882                        ])
2884         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
2885                        ac_cv_have_visibility_builtin_bug,
2886                        [cat > conftest.c <<EOF
2887 #pragma GCC visibility push(hidden)
2888 #pragma GCC visibility push(default)
2889 #include <string.h>
2890 #pragma GCC visibility pop
2892 __attribute__ ((visibility ("default"))) void Func() {
2893   char c[[100]];
2894   memset(c, 0, sizeof(c));
2897                        ac_cv_have_visibility_builtin_bug=no
2898                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2899                          ac_cv_have_visibility_builtin_bug=yes
2900                        else
2901                          if test `grep -c "@PLT" conftest.S` = 0; then
2902                            ac_cv_visibility_builtin_bug=yes
2903                          fi
2904                        fi
2905                        rm -f conftest.{c,S}
2906                        ])
2907         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
2908                 "$ac_cv_have_visibility_class_bug" = "no"; then
2909           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
2910           WRAP_SYSTEM_INCLUDES=1
2911           STL_FLAGS='-I$(DIST)/stl_wrappers'
2912           WRAP_STL_INCLUDES=1
2913         else
2914           VISIBILITY_FLAGS='-fvisibility=hidden'
2915         fi # have visibility pragma bug
2916       fi   # have visibility pragma
2917     fi     # have visibility(default) attribute
2918   fi       # have visibility(hidden) attribute
2919 fi         # GNU_CC
2921 # visibility hidden flag for Sun Studio on Solaris
2922 if test "$SOLARIS_SUNPRO_CC"; then
2923 VISIBILITY_FLAGS='-xldscope=hidden'
2924 fi         # Sun Studio on Solaris
2926 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2927 AC_SUBST(VISIBILITY_FLAGS)
2929 MOZ_GCC_PR49911
2930 MOZ_GCC_PR39608
2931 MOZ_LLVM_PR8927
2933 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
2934 dnl ========================================================
2935 if test "$GNU_CC"; then
2936   CFLAGS_save="${CFLAGS}"
2937   CFLAGS="${CFLAGS} -Werror"
2938   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
2939                  ac_cv_force_align_arg_pointer,
2940                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
2941                                  [],
2942                                  ac_cv_force_align_arg_pointer="yes",
2943                                  ac_cv_force_align_arg_pointer="no")])
2944   CFLAGS="${CFLAGS_save}"
2945   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
2946     HAVE_GCC_ALIGN_ARG_POINTER=1
2947   else
2948     HAVE_GCC_ALIGN_ARG_POINTER=
2949   fi
2951 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
2953 dnl Checks for header files.
2954 dnl ========================================================
2955 AC_HEADER_DIRENT
2956 case "$target_os" in
2957 freebsd*|openbsd*)
2958 # for stuff like -lXshm
2959     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
2960     ;;
2961 esac
2962 MOZ_CHECK_COMMON_HEADERS
2964 dnl These are all the places some variant of statfs can be hiding.
2965 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
2967 dnl Quota support
2968 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
2969 MOZ_CHECK_HEADERS([linux/quota.h],,,[#include <sys/socket.h>])
2971 dnl SCTP support - needs various network include headers
2972 MOZ_CHECK_HEADERS([linux/if_addr.h linux/rtnetlink.h],,,[#include <sys/socket.h>])
2974 MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
2976 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
2977 AC_CACHE_CHECK(for sockaddr_in.sin_len,
2978                    ac_cv_sockaddr_in_sin_len,
2979                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2980                                     #include <sys/types.h>
2981                                     #endif
2982                                     #include <netinet/in.h>
2983                                     struct sockaddr_in x;
2984                                     void *foo = (void*) &x.sin_len;],
2985                                    [],
2986                                    [ac_cv_sockaddr_in_sin_len=true],
2987                                    [ac_cv_sockaddr_in_sin_len=false])])
2988 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
2989   AC_DEFINE(HAVE_SIN_LEN)
2990 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
2991   AC_DEFINE(HAVE_SCONN_LEN)
2994 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
2995                ac_cv_sockaddr_in6_sin6_len,
2996                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2997                                 #include <sys/types.h>
2998                                 #endif
2999                                 #include <netinet/in.h>
3000                                 struct sockaddr_in6 x;
3001                                 void *foo = (void*) &x.sin6_len;],
3002                                [],
3003                                [ac_cv_sockaddr_in6_sin6_len=true],
3004                                [ac_cv_sockaddr_in6_sin6_len=false])])
3005 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
3006   AC_DEFINE(HAVE_SIN6_LEN)
3009 AC_CACHE_CHECK(for sockaddr.sa_len,
3010                ac_cv_sockaddr_sa_len,
3011                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
3012                                 #include <sys/types.h>
3013                                 #endif
3014                                 #include <sys/socket.h>
3015                                 struct sockaddr x;
3016                                 void *foo = (void*) &x.sa_len;],
3017                                [],
3018                                [ac_cv_sockaddr_sa_len=true],
3019                                [ac_cv_sockaddr_sa_len=false])])
3020 if test "$ac_cv_sockaddr_sa_len" = true ; then
3021   AC_DEFINE(HAVE_SA_LEN)
3024 dnl Check whether the compiler supports the new-style C++ standard
3025 dnl library headers (i.e. <new>) or needs the old "new.h"
3026 AC_LANG_CPLUSPLUS
3027 NEW_H=new.h
3028 MOZ_CHECK_HEADER(new, [NEW_H=new])
3029 AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
3030 AC_LANG_C
3032 AC_ARG_ENABLE(dtrace,
3033               [  --enable-dtrace         build with dtrace support if available (default=no)],
3034               [enable_dtrace="yes"],)
3035 if test "x$enable_dtrace" = "xyes"; then
3036   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
3037   if test -n "$HAVE_DTRACE"; then
3038       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
3039   else
3040       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
3041   fi
3043 AC_SUBST(HAVE_DTRACE)
3045 case $target in
3046 *-aix4.3*|*-aix5*)
3047         ;;
3049         MOZ_CHECK_HEADERS(sys/cdefs.h)
3050         ;;
3051 esac
3053 MOZ_LINUX_PERF_EVENT
3055 dnl Checks for libraries.
3056 dnl ========================================================
3057 case $target in
3058 *-hpux11.*)
3059         ;;
3061         AC_CHECK_LIB(c_r, gethostbyname_r)
3062         ;;
3063 esac
3065 dnl We don't want to link with libdl even if it's present on OS X, since
3066 dnl it's not used and not part of the default installation. OS/2 has dlfcn
3067 dnl in libc.
3068 dnl We don't want to link against libm or libpthread on Darwin since
3069 dnl they both are just symlinks to libSystem and explicitly linking
3070 dnl against libSystem causes issues when debugging (see bug 299601).
3071 case $target in
3072 *-darwin*)
3073     ;;
3074 *-os2*)
3075     ;;
3077     AC_SEARCH_LIBS(dlopen, dl,
3078         MOZ_CHECK_HEADER(dlfcn.h,
3079         AC_DEFINE(HAVE_DLOPEN)))
3080     ;;
3081 esac
3083 _SAVE_CFLAGS="$CFLAGS"
3084 CFLAGS="$CFLAGS -D_GNU_SOURCE"
3085 AC_CHECK_FUNCS(dladdr memmem)
3086 CFLAGS="$_SAVE_CFLAGS"
3088 if test ! "$GNU_CXX"; then
3090     case $target in
3091     *-aix*)
3092         AC_CHECK_LIB(C_r, demangle)
3093         ;;
3094      *)
3095         AC_CHECK_LIB(C, demangle)
3096         ;;
3097      esac
3100 dnl OS/2 has socket in libc.
3101 case $target in
3102 *-os2*)
3103     ;;
3105     AC_CHECK_LIB(socket, socket)
3106 esac
3108 XLDFLAGS="$X_LIBS"
3109 XLIBS="$X_EXTRA_LIBS"
3111 dnl ========================================================
3112 dnl Checks for X libraries.
3113 dnl Ordering is important.
3114 dnl Xt is dependent upon SM as of X11R6
3115 dnl ========================================================
3116 if test "$no_x" = "yes"; then
3117     AC_DEFINE(NO_X11)
3118 else
3119     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
3120         XLIBS="-lX11 $XLIBS"
3121         _SAVE_LDFLAGS="$LDFLAGS"
3122         LDFLAGS="$XLDFLAGS $LDFLAGS"
3123         AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
3124                 [MISSING_X="$MISSING_X -lX11"], $XLIBS)
3125         AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
3126                 [MISSING_X="$MISSING_X -lXext"], $XLIBS)
3128         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
3129         unset ac_cv_lib_Xt_XtFree
3130             AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
3131             AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
3132         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
3133                     [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
3134         ])
3136     # AIX needs the motif library linked before libXt to prevent
3137     # crashes in plugins linked against Motif - Bug #98892
3138     case "${target_os}" in
3139     aix*)
3140         XT_LIBS="-lXm $XT_LIBS"
3141         ;;
3142     esac
3144     dnl ========================================================
3145     dnl = Check for XShm
3146     dnl ========================================================
3147     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
3148         $XLIBS $XEXT_LIBS)
3150     dnl ========================================================
3151     dnl = Check for Xss
3152     dnl ========================================================
3153     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
3154         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
3155             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
3156              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
3158         LDFLAGS="$_SAVE_LDFLAGS"
3159 fi # $no_x
3161 AC_SUBST(XCFLAGS)
3162 AC_SUBST(XLDFLAGS)
3163 AC_SUBST(XLIBS)
3164 AC_SUBST(XEXT_LIBS)
3165 AC_SUBST(XT_LIBS)
3166 AC_SUBST(XSS_LIBS)
3168 dnl ========================================================
3169 dnl = pthread support
3170 dnl = Start by checking whether the system support pthreads
3171 dnl ========================================================
3172 case "$target_os" in
3173 darwin*)
3174     USE_PTHREADS=1
3175     ;;
3177     MOZ_CHECK_PTHREADS(pthreads,
3178         USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
3179         MOZ_CHECK_PTHREADS(pthread,
3180             USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
3181             MOZ_CHECK_PTHREADS(c_r,
3182                 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
3183                 MOZ_CHECK_PTHREADS(c,
3184                     USE_PTHREADS=1
3185                 )
3186             )
3187         )
3188     )
3189     ;;
3190 esac
3192 dnl ========================================================
3193 dnl Check the command line for --with-pthreads
3194 dnl ========================================================
3195 MOZ_ARG_WITH_BOOL(pthreads,
3196 [  --with-pthreads         Force use of system pthread library with NSPR ],
3197 [ if test "$USE_PTHREADS"x = x; then
3198     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
3199 fi],
3200     USE_PTHREADS=
3201     _PTHREAD_LDFLAGS=
3204 dnl ========================================================
3205 dnl Do the platform specific pthread hackery
3206 dnl ========================================================
3207 if test "$USE_PTHREADS"x != x
3208 then
3209         dnl
3210         dnl See if -pthread is supported.
3211         dnl
3212         rm -f conftest*
3213         ac_cv_have_dash_pthread=no
3214         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
3215         echo 'int main() { return 0; }' | cat > conftest.c
3216         ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
3217         if test $? -eq 0; then
3218                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3219                         ac_cv_have_dash_pthread=yes
3220                 case "$target_os" in
3221                 freebsd*)
3222 # Freebsd doesn't use -pthread for compiles, it uses them for linking
3223                 ;;
3224                 *)
3225                             CFLAGS="$CFLAGS -pthread"
3226                             CXXFLAGS="$CXXFLAGS -pthread"
3227                 ;;
3228                 esac
3229                 fi
3230         fi
3231         rm -f conftest*
3232     AC_MSG_RESULT($ac_cv_have_dash_pthread)
3234         dnl
3235         dnl See if -pthreads is supported.
3236         dnl
3237     ac_cv_have_dash_pthreads=no
3238     if test "$ac_cv_have_dash_pthread" = "no"; then
3239             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
3240         echo 'int main() { return 0; }' | cat > conftest.c
3241             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
3242         if test $? -eq 0; then
3243                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3244                             ac_cv_have_dash_pthreads=yes
3245                             CFLAGS="$CFLAGS -pthreads"
3246                             CXXFLAGS="$CXXFLAGS -pthreads"
3247                     fi
3248             fi
3249             rm -f conftest*
3250         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
3251     fi
3253         case "$target" in
3254             *-*-freebsd*)
3255                         AC_DEFINE(_REENTRANT)
3256                         AC_DEFINE(_THREAD_SAFE)
3257                         dnl -pthread links in -lpthread, so don't specify it explicitly.
3258                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3259                                 _PTHREAD_LDFLAGS="-pthread"
3260                         fi
3261                         ;;
3263             *-*-openbsd*|*-*-bsdi*)
3264                         AC_DEFINE(_REENTRANT)
3265                         AC_DEFINE(_THREAD_SAFE)
3266                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3267                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3268                 _PTHREAD_LDFLAGS="-pthread"
3269                         fi
3270                         ;;
3272             *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3273                         AC_DEFINE(_REENTRANT)
3274                         ;;
3276             *-aix4.3*|*-aix5*)
3277                         AC_DEFINE(_REENTRANT)
3278                         ;;
3280             *-hpux11.*)
3281                         AC_DEFINE(_REENTRANT)
3282                         ;;
3284             *-*-solaris*)
3285                         AC_DEFINE(_REENTRANT)
3286                         if test "$SOLARIS_SUNPRO_CC"; then
3287                                 CFLAGS="$CFLAGS -mt"
3288                                 CXXFLAGS="$CXXFLAGS -mt"
3289                         fi
3290                         ;;
3291         esac
3292     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3296 dnl Checks for library functions.
3297 dnl ========================================================
3298 AC_PROG_GCC_TRADITIONAL
3299 AC_FUNC_MEMCMP
3300 AC_CHECK_FUNCS(random strerror lchown fchmod snprintf memmove rint stat64 lstat64 truncate64 setbuf isatty)
3301 AC_CHECK_FUNCS(statvfs64 statvfs statfs64 statfs)
3302 AC_CHECK_FUNCS(flockfile getpagesize)
3303 AC_CHECK_FUNCS(localtime_r strtok_r)
3305 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
3306 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
3307                ac_cv_clock_monotonic,
3308                [for libs in "" -lrt; do
3309                     _SAVE_LIBS="$LIBS"
3310                     LIBS="$LIBS $libs"
3311                     AC_TRY_LINK([#include <time.h>],
3312                                  [ struct timespec ts;
3313                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
3314                                  ac_cv_clock_monotonic=$libs
3315                                  LIBS="$_SAVE_LIBS"
3316                                  break,
3317                                  ac_cv_clock_monotonic=no)
3318                     LIBS="$_SAVE_LIBS"
3319                 done])
3320 if test "$ac_cv_clock_monotonic" != "no"; then
3321     HAVE_CLOCK_MONOTONIC=1
3322     REALTIME_LIBS=$ac_cv_clock_monotonic
3323     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3324     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3325     AC_SUBST(REALTIME_LIBS)
3328 dnl check for wcrtomb/mbrtowc
3329 dnl =======================================================================
3330 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3331 AC_LANG_SAVE
3332 AC_LANG_CPLUSPLUS
3333 AC_CACHE_CHECK(for wcrtomb,
3334     ac_cv_have_wcrtomb,
3335     [AC_TRY_LINK([#include <wchar.h>],
3336                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3337                  ac_cv_have_wcrtomb="yes",
3338                  ac_cv_have_wcrtomb="no")])
3339 if test "$ac_cv_have_wcrtomb" = "yes"; then
3340     AC_DEFINE(HAVE_WCRTOMB)
3342 AC_CACHE_CHECK(for mbrtowc,
3343     ac_cv_have_mbrtowc,
3344     [AC_TRY_LINK([#include <wchar.h>],
3345                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3346                  ac_cv_have_mbrtowc="yes",
3347                  ac_cv_have_mbrtowc="no")])
3348 if test "$ac_cv_have_mbrtowc" = "yes"; then
3349     AC_DEFINE(HAVE_MBRTOWC)
3351 AC_LANG_RESTORE
3354 AC_CACHE_CHECK(
3355     [for res_ninit()],
3356     ac_cv_func_res_ninit,
3357     [AC_TRY_LINK([
3358         #ifdef linux
3359         #define _BSD_SOURCE 1
3360         #endif
3361         #include <resolv.h>
3362         ],
3363         [int foo = res_ninit(&_res);],
3364         [ac_cv_func_res_ninit=yes],
3365         [ac_cv_func_res_ninit=no])
3366     ])
3368 if test "$ac_cv_func_res_ninit" = "yes"; then
3369     AC_DEFINE(HAVE_RES_NINIT)
3370 dnl must add the link line we do something as foolish as this... dougt
3371 dnl else
3372 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3373 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3376 AC_LANG_CPLUSPLUS
3377 AC_CACHE_CHECK(
3378     [for gnu_get_libc_version()],
3379     ac_cv_func_gnu_get_libc_version,
3380     [AC_TRY_LINK([
3381         #ifdef HAVE_GNU_LIBC_VERSION_H
3382         #include <gnu/libc-version.h>
3383         #endif
3384         ],
3385         [const char *glibc_version = gnu_get_libc_version();],
3386         [ac_cv_func_gnu_get_libc_version=yes],
3387         [ac_cv_func_gnu_get_libc_version=no]
3388         )]
3389     )
3391 if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
3392     AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
3395 case $target_os in
3396     darwin*|mingw*|os2*)
3397         ;;
3398     *)
3400 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3401     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3402         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3403 _SAVE_LIBS=$LIBS
3404 LIBS="$LIBS $_ICONV_LIBS"
3405 AC_CACHE_CHECK(
3406     [for iconv()],
3407     ac_cv_func_iconv,
3408     [AC_TRY_LINK([
3409         #include <stdlib.h>
3410         #include <iconv.h>
3411         ],
3412         [
3413             iconv_t h = iconv_open("", "");
3414             iconv(h, NULL, NULL, NULL, NULL);
3415             iconv_close(h);
3416         ],
3417         [ac_cv_func_iconv=yes],
3418         [ac_cv_func_iconv=no]
3419         )]
3420     )
3421 if test "$ac_cv_func_iconv" = "yes"; then
3422     AC_DEFINE(HAVE_ICONV)
3423     DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
3424     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3425     LIBICONV="$_ICONV_LIBS"
3426     AC_CACHE_CHECK(
3427         [for iconv() with const input],
3428         ac_cv_func_const_iconv,
3429         [AC_TRY_COMPILE([
3430             #include <stdlib.h>
3431             #include <iconv.h>
3432             ],
3433             [
3434                 const char *input = "testing";
3435                 iconv_t h = iconv_open("", "");
3436                 iconv(h, &input, NULL, NULL, NULL);
3437                 iconv_close(h);
3438             ],
3439             [ac_cv_func_const_iconv=yes],
3440             [ac_cv_func_const_iconv=no]
3441             )]
3442         )
3443     if test "$ac_cv_func_const_iconv" = "yes"; then
3444         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3445     fi
3447 LIBS=$_SAVE_LIBS
3449     ;;
3450 esac
3452 AM_LANGINFO_CODESET
3454 AC_LANG_C
3456 dnl **********************
3457 dnl *** va_copy checks ***
3458 dnl **********************
3459 dnl we currently check for all three va_copy possibilities, so we get
3460 dnl all results in config.log for bug reports.
3461 AC_MSG_CHECKING(for an implementation of va_copy())
3462 AC_CACHE_VAL(ac_cv_va_copy,[
3463     AC_TRY_RUN([
3464         #include <stdarg.h>
3465         void f (int i, ...) {
3466             va_list args1, args2;
3467             va_start (args1, i);
3468             va_copy (args2, args1);
3469             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3470                 exit (1);
3471             va_end (args1); va_end (args2);
3472         }
3473         int main() { f (0, 42); return 0; }],
3474         ac_cv_va_copy=yes,
3475         ac_cv_va_copy=no,
3476         ac_cv_va_copy=no
3477     )
3479 AC_MSG_RESULT($ac_cv_va_copy)
3480 AC_MSG_CHECKING(for an implementation of __va_copy())
3481 AC_CACHE_VAL(ac_cv___va_copy,[
3482     AC_TRY_RUN([
3483         #include <stdarg.h>
3484         void f (int i, ...) {
3485             va_list args1, args2;
3486             va_start (args1, i);
3487             __va_copy (args2, args1);
3488             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3489                 exit (1);
3490             va_end (args1); va_end (args2);
3491         }
3492         int main() { f (0, 42); return 0; }],
3493         ac_cv___va_copy=yes,
3494         ac_cv___va_copy=no,
3495         ac_cv___va_copy=no
3496     )
3498 AC_MSG_RESULT($ac_cv___va_copy)
3499 AC_MSG_CHECKING(whether va_lists can be copied by value)
3500 AC_CACHE_VAL(ac_cv_va_val_copy,[
3501     AC_TRY_RUN([
3502         #include <stdarg.h>
3503         void f (int i, ...) {
3504             va_list args1, args2;
3505             va_start (args1, i);
3506             args2 = args1;
3507             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3508                 exit (1);
3509             va_end (args1); va_end (args2);
3510         }
3511         int main() { f (0, 42); return 0; }],
3512         ac_cv_va_val_copy=yes,
3513         ac_cv_va_val_copy=no,
3514         ac_cv_va_val_copy=yes
3515     )
3517 if test "x$ac_cv_va_copy" = "xyes"; then
3518     AC_DEFINE(VA_COPY, va_copy)
3519     AC_DEFINE(HAVE_VA_COPY)
3520 elif test "x$ac_cv___va_copy" = "xyes"; then
3521     AC_DEFINE(VA_COPY, __va_copy)
3522     AC_DEFINE(HAVE_VA_COPY)
3525 if test "x$ac_cv_va_val_copy" = "xno"; then
3526    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3528 AC_MSG_RESULT($ac_cv_va_val_copy)
3530 dnl ===================================================================
3531 dnl ========================================================
3532 dnl Put your C++ language/feature checks below
3533 dnl ========================================================
3534 AC_LANG_CPLUSPLUS
3536 ARM_ABI_PREFIX=
3537 if test "$GNU_CC"; then
3538   if test "$CPU_ARCH" = "arm" ; then
3539     AC_CACHE_CHECK(for ARM EABI,
3540         ac_cv_gcc_arm_eabi,
3541         [AC_TRY_COMPILE([],
3542                         [
3543 #if defined(__ARM_EABI__)
3544   return 0;
3545 #else
3546 #error Not ARM EABI.
3547 #endif
3548                         ],
3549                         ac_cv_gcc_arm_eabi="yes",
3550                         ac_cv_gcc_arm_eabi="no")])
3551     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
3552         HAVE_ARM_EABI=1
3553         ARM_ABI_PREFIX=eabi-
3554     else
3555         ARM_ABI_PREFIX=oabi-
3556     fi
3557   fi
3559   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
3562 dnl Check to see if we can resolve ambiguity with |using|.
3563 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
3564                ac_cv_cpp_ambiguity_resolving_using,
3565                [AC_TRY_COMPILE(class X {
3566                                  public: int go(const X&) {return 3;}
3567                                          int jo(const X&) {return 3;}
3568                                };
3569                                class Y : public X {
3570                                  public:  int go(int) {return 2;}
3571                                           int jo(int) {return 2;}
3572                                           using X::jo;
3573                                  private: using X::go;
3574                                };,
3575                                X x; Y y; y.jo(x);,
3576                                ac_cv_cpp_ambiguity_resolving_using=yes,
3577                                ac_cv_cpp_ambiguity_resolving_using=no)])
3578 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
3579    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
3582 dnl See if a dynamic_cast to void* gives the most derived object.
3583 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
3584                ac_cv_cpp_dynamic_cast_void_ptr,
3585                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
3586                             class Y { int j; public: virtual ~Y() { } };
3587                             class Z : public X, public Y { int k; };
3589                             int main() {
3590                                  Z mdo;
3591                                  X *subx = (X*)&mdo;
3592                                  Y *suby = (Y*)&mdo;
3593                                  return !((((void*)&mdo != (void*)subx) &&
3594                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
3595                                           (((void*)&mdo != (void*)suby) &&
3596                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
3597                             }],
3598                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
3599                            ac_cv_cpp_dynamic_cast_void_ptr=no,
3600                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
3601 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
3602    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
3606 dnl note that this one is reversed - if the test fails, then
3607 dnl we require implementations of unused virtual methods. Which
3608 dnl really blows because it means we'll have useless vtable
3609 dnl bloat.
3610 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
3611                ac_cv_cpp_unused_required,
3612                [AC_TRY_LINK(class X {private: virtual void never_called();};,
3613                                X x;,
3614                                ac_cv_cpp_unused_required=no,
3615                                ac_cv_cpp_unused_required=yes)])
3616 if test "$ac_cv_cpp_unused_required" = yes ; then
3617    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
3621 dnl Some compilers have trouble comparing a constant reference to a templatized
3622 dnl class to zero, and require an explicit operator==() to be defined that takes
3623 dnl an int. This test separates the strong from the weak.
3625 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
3626                ac_cv_trouble_comparing_to_zero,
3627                [AC_TRY_COMPILE([#include <algorithm>
3628                                 template <class T> class Foo {};
3629                                 class T2;
3630                                 template <class T> int operator==(const T2*, const T&) { return 0; }
3631                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
3632                                [Foo<int> f; return (0 != f);],
3633                                ac_cv_trouble_comparing_to_zero=no,
3634                                ac_cv_trouble_comparing_to_zero=yes)])
3635 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
3636   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
3639 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
3640 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
3641 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
3642 # linking XUL.
3643 _SAVE_LDFLAGS=$LDFLAGS
3644 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
3645 AC_CACHE_CHECK(for __thread keyword for TLS variables,
3646                ac_cv_thread_keyword,
3647                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
3648                             [return tlsIsMainThread;],
3649                             ac_cv_thread_keyword=yes,
3650                             ac_cv_thread_keyword=no)])
3651 LDFLAGS=$_SAVE_LDFLAGS
3652 # The custom dynamic linker doesn't support TLS variables
3653 MOZ_TLS=
3654 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
3655   # mips builds fail with TLS variables because of a binutils bug.
3656   # See bug 528687
3657   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
3658   case "${target}" in
3659     mips*-*)
3660       :
3661       ;;
3662     *-android*|*-linuxandroid*)
3663       :
3664       ;;
3665     *-openbsd*)
3666       :
3667       ;;
3668     *)
3669       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
3670       MOZ_TLS=1
3671       ;;
3672   esac
3675 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
3676 if test -n "$MOZ_LINKER"; then
3677   if test "$CPU_ARCH" = arm; then
3678     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
3679     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
3680       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3681       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3682     fi
3683   fi
3686 dnl The custom linker doesn't support text relocations, but NDK >= r6b
3687 dnl creates some (http://code.google.com/p/android/issues/detail?id=23203)
3688 dnl We however want to avoid these text relocations, and this can be done
3689 dnl by making gcc not link crtbegin and crtend. In the broken NDKs, crtend
3690 dnl doesn't contain anything at all, beside placeholders for some sections,
3691 dnl and crtbegin only contains a finalizer function that calls
3692 dnl __cxa_finalize. The custom linker actually takes care of calling
3693 dnl __cxa_finalize when the library doesn't call it itself, which makes it
3694 dnl safe not to link crtbegin. Besides, previous versions of the NDK didn't
3695 dnl link crtbegin and crtend at all.
3696 if test -n "$MOZ_LINKER" -a "$OS_TARGET" = "Android"; then
3697   AC_CACHE_CHECK([whether the CRT objects have text relocations],
3698     ac_cv_crt_has_text_relocations,
3699     [echo 'int foo() { return 0; }' > conftest.cpp
3700      if AC_TRY_COMMAND(${CXX-g++} -o conftest${DLL_SUFFIX} $CXXFLAGS $DSO_LDOPTS $LDFLAGS conftest.cpp $LIBS 1>&5) &&
3701         test -s conftest${DLL_SUFFIX}; then
3702        if ${TOOLCHAIN_PREFIX}readelf -d conftest${DLL_SUFFIX} | grep TEXTREL > /dev/null; then
3703          ac_cv_crt_has_text_relocations=yes
3704        else
3705          ac_cv_crt_has_text_relocations=no
3706        fi
3707      else
3708        AC_ERROR([couldn't compile a simple C file])
3709      fi
3710      rm -rf conftest*])
3711   if test "$ac_cv_crt_has_text_relocations" = yes; then
3712     dnl While we want libraries to skip the CRT files, we don't want
3713     dnl executables to be treated the same way. We thus set the flag
3714     dnl in DSO_LDOPTS and not LDFLAGS. However, to pass it to nspr,
3715     dnl we need to use LDFLAGS because nspr doesn't inherit DSO_LDOPTS.
3716     dnl Using LDFLAGS in nspr is safe, since we only really build
3717     dnl libraries there.
3718     DSO_LDOPTS="$DSO_LDOPTS -nostartfiles"
3719     NSPR_LDFLAGS="$NSPR_LDFLAGS -nostartfiles"
3720   fi
3723 dnl Check for the existence of various allocation headers/functions
3725 MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h"
3726 MALLOC_H=
3728 for file in $MALLOC_HEADERS; do
3729   MOZ_CHECK_HEADER($file, [MALLOC_H=$file])
3730   if test "$MALLOC_H" != ""; then
3731     AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
3732     break
3733   fi
3734 done
3736 MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
3737 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
3739 AC_CHECK_FUNCS(malloc_usable_size)
3741 dnl See if compiler supports some gcc-style attributes
3743 AC_CACHE_CHECK(for __attribute__((always_inline)),
3744                ac_cv_attribute_always_inline,
3745                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
3746                                [],
3747                                ac_cv_attribute_always_inline=yes,
3748                                ac_cv_attribute_always_inline=no)])
3750 AC_CACHE_CHECK(for __attribute__((malloc)),
3751                ac_cv_attribute_malloc,
3752                [AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
3753                                [],
3754                                ac_cv_attribute_malloc=yes,
3755                                ac_cv_attribute_malloc=no)])
3757 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
3758                ac_cv_attribute_warn_unused,
3759                [AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
3760                                [],
3761                                ac_cv_attribute_warn_unused=yes,
3762                                ac_cv_attribute_warn_unused=no)])
3764 dnl End of C++ language/feature checks
3765 AC_LANG_C
3767 dnl ========================================================
3768 dnl =  Internationalization checks
3769 dnl ========================================================
3771 dnl Internationalization and Locale support is different
3772 dnl on various UNIX platforms.  Checks for specific i18n
3773 dnl features go here.
3775 dnl check for LC_MESSAGES
3776 AC_CACHE_CHECK(for LC_MESSAGES,
3777                 ac_cv_i18n_lc_messages,
3778                 [AC_TRY_COMPILE([#include <locale.h>],
3779                                 [int category = LC_MESSAGES;],
3780                                 ac_cv_i18n_lc_messages=yes,
3781                                 ac_cv_i18n_lc_messages=no)])
3782 if test "$ac_cv_i18n_lc_messages" = yes; then
3783    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
3786 AC_HAVE_FUNCS(localeconv)
3787 fi # ! SKIP_COMPILER_CHECKS
3789 TARGET_XPCOM_ABI=
3790 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
3791     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
3794 dnl Mozilla specific options
3795 dnl ========================================================
3796 dnl The macros used for command line options
3797 dnl are defined in build/autoconf/altoptions.m4.
3799 dnl If the compiler supports these attributes, define them as
3800 dnl convenience macros.
3801 if test "$ac_cv_attribute_malloc" = yes ; then
3802   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
3803 else
3804   AC_DEFINE(NS_ATTR_MALLOC,)
3807 if test "$ac_cv_attribute_warn_unused" = yes ; then
3808   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
3809 else
3810   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
3813 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
3814 dnl features that Windows actually does support.
3816 if test -n "$SKIP_COMPILER_CHECKS"; then
3817    dnl Windows has malloc.h
3818    AC_DEFINE(MALLOC_H, [<malloc.h>])
3819    AC_DEFINE(HAVE_FORCEINLINE)
3820    AC_DEFINE(HAVE_LOCALECONV)
3821 fi # SKIP_COMPILER_CHECKS
3823 dnl ========================================================
3824 dnl =
3825 dnl = Check for external package dependencies
3826 dnl =
3827 dnl ========================================================
3828 MOZ_ARG_HEADER(External Packages)
3830 MOZ_ARG_WITH_STRING(libxul-sdk,
3831 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
3832   LIBXUL_SDK_DIR=$withval)
3834 if test "$LIBXUL_SDK_DIR" = "yes"; then
3835     AC_MSG_ERROR([--with-libxul-sdk must specify a path])
3836 elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
3837     LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
3839     if test ! -f "$LIBXUL_SDK/include/xpcom-config.h"; then
3840         AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
3841     fi
3844 AC_SUBST(LIBXUL_SDK)
3846 if test -n "$LIBXUL_SDK"; then
3847     LIBXUL_DIST="$LIBXUL_SDK"
3848 else
3849     LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
3851 AC_SUBST(LIBXUL_DIST)
3853 SYSTEM_LIBXUL=
3855 MOZ_ARG_WITH_BOOL(system-libxul,
3856 [  --with-system-libxul    Use system installed libxul SDK],
3857     SYSTEM_LIBXUL=1)
3859 dnl ========================================================
3860 dnl = If NSPR was not detected in the system,
3861 dnl = use the one in the source tree (mozilla/nsprpub)
3862 dnl ========================================================
3863 MOZ_ARG_WITH_BOOL(system-nspr,
3864 [  --with-system-nspr      Use system installed NSPR],
3865     _USE_SYSTEM_NSPR=1 )
3867 if test -n "$_USE_SYSTEM_NSPR"; then
3868     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])])
3871 if test -n "$MOZ_NATIVE_NSPR"; then
3872     _SAVE_CFLAGS=$CFLAGS
3873     CFLAGS="$CFLAGS $NSPR_CFLAGS"
3874     AC_TRY_COMPILE([#include "prtypes.h"],
3875                 [#ifndef PR_STATIC_ASSERT
3876                  #error PR_STATIC_ASSERT not defined or requires including prtypes.h
3877                  #endif],
3878                 [MOZ_NATIVE_NSPR=1],
3879                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
3880     AC_TRY_COMPILE([#include "prtypes.h"],
3881                 [#ifndef PR_UINT64
3882                  #error PR_UINT64 not defined or requires including prtypes.h
3883                  #endif],
3884                 [MOZ_NATIVE_NSPR=1],
3885                 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
3886     CFLAGS=$_SAVE_CFLAGS
3887 else
3888     if test -z "$LIBXUL_SDK"; then
3889         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
3890         if test -n "$GNU_CC"; then
3891             NSPR_LIBS="-L${LIBXUL_DIST}/lib -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
3892         else
3893             NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
3894         fi
3895     else
3896         NSPR_CFLAGS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --includedir="${LIBXUL_DIST}/include/nspr" --cflags`
3897         NSPR_LIBS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --libdir="${LIBXUL_DIST}"/lib --libs`
3898     fi
3901 dnl set GRE_MILESTONE
3902 dnl ========================================================
3903 if test -n "$LIBXUL_SDK"; then
3904     GRE_MILESTONE=`$PYTHON "$_topsrcdir"/config/printconfigsetting.py "$LIBXUL_DIST"/bin/platform.ini Build Milestone`
3905 else
3906     GRE_MILESTONE=`tail -n 1 "$_topsrcdir"/config/milestone.txt 2>/dev/null || tail -1 "$_topsrcdir"/config/milestone.txt`
3908 AC_SUBST(GRE_MILESTONE)
3910 # set RELEASE_BUILD and NIGHTLY_BUILD variables depending on the cycle we're in
3911 # The logic works like this:
3912 # - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
3913 # - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
3914 # - otherwise, we're building Release/Beta (define RELEASE_BUILD)
3915 case "$GRE_MILESTONE" in
3916   *a1*)
3917       NIGHTLY_BUILD=1
3918       AC_DEFINE(NIGHTLY_BUILD)
3919       ;;
3920   *a*)
3921       ;;
3922   *)
3923       RELEASE_BUILD=1
3924       AC_DEFINE(RELEASE_BUILD)
3925       ;;
3926 esac
3927 AC_SUBST(NIGHTLY_BUILD)
3928 AC_SUBST(RELEASE_BUILD)
3930 dnl system libevent Support
3931 dnl ========================================================
3932 MOZ_ARG_WITH_STRING(system-libevent,
3933 [  --with-system-libevent[=PFX]
3934                           Use system libevent [installed at prefix PFX]],
3935     LIBEVENT_DIR=$withval)
3937 _SAVE_CFLAGS=$CFLAGS
3938 _SAVE_LDFLAGS=$LDFLAGS
3939 _SAVE_LIBS=$LIBS
3940 if test "$LIBEVENT_DIR" = yes; then
3941     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
3942         MOZ_NATIVE_LIBEVENT=1,
3943         LIBEVENT_DIR=/usr)
3945 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
3946     MOZ_NATIVE_LIBEVENT=
3947 elif test -z "$MOZ_NATIVE_LIBEVENT"; then
3948     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
3949     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
3950     MOZ_CHECK_HEADER(event.h,
3951         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
3952              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
3953          fi],
3954         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
3955     AC_CHECK_LIB(event, event_init,
3956                  [MOZ_NATIVE_LIBEVENT=1
3957                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
3958                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
3959                  [MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
3961 CFLAGS=$_SAVE_CFLAGS
3962 LDFLAGS=$_SAVE_LDFLAGS
3963 LIBS=$_SAVE_LIBS
3965 AC_SUBST(MOZ_NATIVE_LIBEVENT)
3966 AC_SUBST(MOZ_LIBEVENT_CFLAGS)
3967 AC_SUBST(MOZ_LIBEVENT_LIBS)
3969 dnl ========================================================
3970 dnl = If NSS was not detected in the system,
3971 dnl = use the one in the source tree (mozilla/security/nss)
3972 dnl ========================================================
3974 MOZ_ARG_WITH_BOOL(system-nss,
3975 [  --with-system-nss       Use system installed NSS],
3976     _USE_SYSTEM_NSS=1 )
3978 if test -n "$_USE_SYSTEM_NSS"; then
3979     AM_PATH_NSS(3.15, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
3982 if test -n "$MOZ_NATIVE_NSS"; then
3983    NSS_LIBS="$NSS_LIBS -lcrmf"
3984 else
3985    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
3987    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2"; then
3988        NSS_LIBS="\
3989         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
3990         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
3991         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
3992         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
3993         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
3994    else
3995        NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
3996    fi
3999 dnl ======================
4000 dnl Detect yasm
4001 dnl ======================
4003 AC_MSG_CHECKING([for YASM assembler])
4004 AC_CHECK_PROGS(YASM, yasm, "")
4006 if test -n "$YASM"; then
4007   dnl Pull out yasm's version string
4008   YASM_VERSION=`yasm --version | $AWK '/^yasm/ { print $2 }'`
4009   _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
4010   _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
4011   _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
4012   _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
4015 if test -z "$SKIP_LIBRARY_CHECKS"; then
4016 dnl system JPEG support
4017 dnl ========================================================
4018 MOZ_ARG_WITH_STRING(system-jpeg,
4019 [  --with-system-jpeg[=PFX]
4020                           Use system libjpeg [installed at prefix PFX]],
4021     JPEG_DIR=$withval)
4023 _SAVE_CFLAGS=$CFLAGS
4024 _SAVE_LDFLAGS=$LDFLAGS
4025 _SAVE_LIBS=$LIBS
4026 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
4027     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
4028     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
4030 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
4031     MOZ_NATIVE_JPEG=
4032 else
4033     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_NATIVE_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_NATIVE_JPEG=)
4036 if test "$MOZ_NATIVE_JPEG" = 1; then
4037     AC_TRY_COMPILE([ #include <stdio.h>
4038                      #include <sys/types.h>
4039                      #include <jpeglib.h> ],
4040                    [ #if JPEG_LIB_VERSION < $MOZJPEG
4041                      #error "Insufficient JPEG library version ($MOZJPEG required)."
4042                      #endif
4043                      #ifndef JCS_EXTENSIONS
4044                      #error "libjpeg-turbo JCS_EXTENSIONS required"
4045                      #endif
4046                      ],
4047                    MOZ_NATIVE_JPEG=1,
4048                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
4050 CFLAGS=$_SAVE_CFLAGS
4051 LDFLAGS=$_SAVE_LDFLAGS
4052 LIBS=$_SAVE_LIBS
4054 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
4055     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
4056     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
4058 fi # SKIP_LIBRARY_CHECKS
4060 dnl system ZLIB support
4061 dnl ========================================================
4062 MOZ_ZLIB_CHECK([1.2.3])
4064 if test "$MOZ_NATIVE_ZLIB" != 1; then
4065     MOZ_ZLIB_CFLAGS=
4066     MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,'"$MOZ_BUILD_ROOT"'/modules/zlib/src)'
4069 if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
4070     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
4073 if test -z "$SKIP_LIBRARY_CHECKS"; then
4074 dnl system BZIP2 Support
4075 dnl ========================================================
4076 MOZ_ARG_WITH_STRING(system-bz2,
4077 [  --with-system-bz2[=PFX]
4078                           Use system libbz2 [installed at prefix PFX]],
4079     BZ2_DIR=$withval)
4081 _SAVE_CFLAGS=$CFLAGS
4082 _SAVE_LDFLAGS=$LDFLAGS
4083 _SAVE_LIBS=$LIBS
4084 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
4085     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
4086     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
4088 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
4089     MOZ_NATIVE_BZ2=
4090 else
4091     AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_NATIVE_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
4092         [MOZ_NATIVE_BZ2= MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS=])
4094 CFLAGS=$_SAVE_CFLAGS
4095 LDFLAGS=$_SAVE_LDFLAGS
4096 LIBS=$_SAVE_LIBS
4098 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_NATIVE_BZ2" = 1; then
4099     MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
4100     MOZ_BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
4103 dnl system PNG Support
4104 dnl ========================================================
4105 MOZ_ARG_WITH_STRING(system-png,
4106 [  --with-system-png[=PFX]
4107                           Use system libpng [installed at prefix PFX]],
4108     PNG_DIR=$withval)
4110 _SAVE_CFLAGS=$CFLAGS
4111 _SAVE_LDFLAGS=$LDFLAGS
4112 _SAVE_LIBS=$LIBS
4113 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
4114     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
4115     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
4117 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
4118     MOZ_NATIVE_PNG=
4119 else
4120     AC_CHECK_LIB(png, png_get_valid, [MOZ_NATIVE_PNG=1 MOZ_PNG_LIBS="-lpng"],
4121                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4122     AC_CHECK_LIB(png, png_get_acTL, ,
4123                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
4125 if test "$MOZ_NATIVE_PNG" = 1; then
4126     AC_TRY_COMPILE([ #include <stdio.h>
4127                      #include <sys/types.h>
4128                      #include <png.h> ],
4129                    [ #if PNG_LIBPNG_VER < $MOZPNG
4130                      #error "Insufficient libpng version ($MOZPNG required)."
4131                      #endif
4132                      #ifndef PNG_UINT_31_MAX
4133                      #error "Insufficient libpng version."
4134                      #endif ],
4135                    MOZ_NATIVE_PNG=1,
4136                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4138 CFLAGS=$_SAVE_CFLAGS
4139 LDFLAGS=$_SAVE_LDFLAGS
4140 LIBS=$_SAVE_LIBS
4142 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_NATIVE_PNG" = 1; then
4143     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
4144     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
4147 fi # SKIP_LIBRARY_CHECKS
4149 dnl system HunSpell Support
4150 dnl ========================================================
4151 MOZ_ARG_ENABLE_BOOL(system-hunspell,
4152 [  --enable-system-hunspell
4153                           Use system hunspell (located with pkgconfig)],
4154     MOZ_NATIVE_HUNSPELL=1 )
4156 if test -n "$MOZ_NATIVE_HUNSPELL"; then
4157     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
4160 AC_SUBST(MOZ_NATIVE_HUNSPELL)
4162 dnl ========================================================
4163 dnl system libffi Support
4164 dnl ========================================================
4165 MOZ_ARG_ENABLE_BOOL(system-ffi,
4166 [  --enable-system-ffi       Use system libffi (located with pkgconfig)],
4167     MOZ_NATIVE_FFI=1 )
4169 if test -n "$MOZ_NATIVE_FFI"; then
4170     # Vanilla libffi 3.0.9 needs a few patches from upcoming version 3.0.10
4171     # for non-GCC compilers.
4172     if test -z "$GNU_CC"; then
4173         PKG_CHECK_MODULES(MOZ_FFI, libffi > 3.0.9)
4174     else
4175         PKG_CHECK_MODULES(MOZ_FFI, libffi >= 3.0.9)
4176     fi
4177     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS"
4180 dnl ========================================================
4181 dnl Java SDK support
4182 dnl ========================================================
4184 JAVA_BIN_PATH=
4185 MOZ_ARG_WITH_STRING(java-bin-path,
4186 [  --with-java-bin-path=dir
4187                           Location of Java binaries (java, javac, jar)],
4188     JAVA_BIN_PATH=$withval)
4190 dnl ========================================================
4191 dnl =
4192 dnl = Application
4193 dnl =
4194 dnl ========================================================
4196 MOZ_ARG_HEADER(Application)
4198 ENABLE_TESTS=1
4199 ENABLE_SYSTEM_EXTENSION_DIRS=1
4200 MOZ_BRANDING_DIRECTORY=
4201 MOZ_OFFICIAL_BRANDING=
4202 MOZ_FEEDS=1
4203 MOZ_FLEXBOX=1
4204 MOZ_WEBAPP_RUNTIME=
4205 MOZ_JSDEBUGGER=1
4206 MOZ_AUTH_EXTENSION=1
4207 MOZ_OGG=1
4208 MOZ_RAW=
4209 MOZ_SPEEX_RESAMPLER=1
4210 MOZ_SOUNDTOUCH=1
4211 MOZ_CUBEB=
4212 MOZ_VORBIS=
4213 MOZ_TREMOR=
4214 MOZ_WAVE=1
4215 MOZ_SAMPLE_TYPE_FLOAT32=
4216 MOZ_SAMPLE_TYPE_S16=
4217 MOZ_OPUS=1
4218 MOZ_WEBM=1
4219 MOZ_DASH=
4220 MOZ_WMF=
4221 MOZ_WEBRTC=1
4222 MOZ_PEERCONNECTION=
4223 MOZ_SRTP=
4224 MOZ_WEBRTC_SIGNALING=
4225 MOZ_WEBRTC_IN_LIBXUL=
4226 MOZ_WEBRTC_ASSERT_ALWAYS=1
4227 MOZ_SCTP=
4228 MOZ_MEDIA_PLUGINS=
4229 MOZ_MEDIA_NAVIGATOR=
4230 MOZ_OMX_PLUGIN=
4231 MOZ_VP8=
4232 MOZ_VP8_ERROR_CONCEALMENT=
4233 MOZ_VP8_ENCODER=
4234 MOZ_WEBSPEECH=1
4235 VPX_AS=
4236 VPX_ASFLAGS=
4237 VPX_AS_DASH_C_FLAG=
4238 VPX_AS_CONVERSION=
4239 VPX_ASM_SUFFIX=
4240 VPX_X86_ASM=
4241 VPX_ARM_ASM=
4242 LIBJPEG_TURBO_AS=
4243 LIBJPEG_TURBO_ASFLAGS=
4244 LIBJPEG_TURBO_X86_ASM=
4245 LIBJPEG_TURBO_X64_ASM=
4246 LIBJPEG_TURBO_ARM_ASM=
4247 MOZ_PANGO=1
4248 MOZ_PERMISSIONS=1
4249 MOZ_PLACES=1
4250 MOZ_SOCIAL=1
4251 MOZ_PREF_EXTENSIONS=1
4252 MOZ_PROFILELOCKING=1
4253 MOZ_PSM=1
4254 MOZ_REFLOW_PERF=
4255 MOZ_SAFE_BROWSING=
4256 MOZ_HELP_VIEWER=
4257 MOZ_SPELLCHECK=1
4258 MOZ_ANDROID_OMTC=
4259 MOZ_ONLY_TOUCH_EVENTS=
4260 MOZ_TOOLKIT_SEARCH=1
4261 MOZ_UI_LOCALE=en-US
4262 MOZ_UNIVERSALCHARDET=1
4263 MOZ_URL_CLASSIFIER=
4264 MOZ_XUL=1
4265 MOZ_ZIPWRITER=1
4266 NS_PRINTING=1
4267 MOZ_PDF_PRINTING=
4268 MOZ_DISABLE_CRYPTOLEGACY=
4269 NSS_DISABLE_DBM=
4270 NECKO_WIFI=1
4271 NECKO_COOKIES=1
4272 NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg device"
4273 USE_ARM_KUSER=
4274 BUILD_CTYPES=1
4275 MOZ_USE_NATIVE_POPUP_WINDOWS=
4276 MOZ_ANDROID_HISTORY=
4277 MOZ_WEBSMS_BACKEND=
4278 MOZ_ANDROID_WALLPAPER=
4279 MOZ_ANDROID_BEAM=
4280 ACCESSIBILITY=1
4281 MOZ_TIME_MANAGER=
4282 MOZ_PAY=
4283 MOZ_AUDIO_CHANNEL_MANAGER=
4284 NSS_NO_LIBPKIX=
4286 case "$target_os" in
4287     mingw*)
4288         NS_ENABLE_TSF=1
4289         AC_DEFINE(NS_ENABLE_TSF)
4290         ;;
4291 esac
4293 case "${target}" in
4294     *-android*|*-linuxandroid*)
4295         if test "$CPU_ARCH" = "arm" ; then
4296           USE_ARM_KUSER=1
4297         fi
4299         NSS_DISABLE_DBM=1
4300         if test -z "$gonkdir"; then
4301           NECKO_WIFI=
4302         else
4303           NECKO_WIFI=1
4304         fi
4305         MOZ_THEME_FASTSTRIPE=1
4306         MOZ_TREE_FREETYPE=1
4307         MOZ_MEMORY=1
4308         MOZ_RAW=1
4309         ;;
4311 esac
4313 MOZ_ARG_WITH_STRING(external-source-dir,
4314 [  --with-external-source-dir=dir
4315                           External directory containing additional build files.],
4316 [ EXTERNAL_SOURCE_DIR=$withval])
4317 AC_SUBST(EXTERNAL_SOURCE_DIR)
4319 MOZ_ARG_ENABLE_STRING(application,
4320 [  --enable-application=APP
4321                           Options include:
4322                             browser (Firefox)
4323                             xulrunner
4324                             tools/update-packaging (AUS-related packaging tools)],
4325 [ MOZ_BUILD_APP=$enableval ] )
4327 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
4328 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
4329   XULRUNNER_STUB_NAME=$withval)
4331 if test -z "$XULRUNNER_STUB_NAME"; then
4332   case "$target_os" in
4333   darwin*)
4334     XULRUNNER_STUB_NAME=xulrunner
4335     ;;
4336   *)
4337     XULRUNNER_STUB_NAME=xulrunner-stub
4338   esac
4340 AC_SUBST(XULRUNNER_STUB_NAME)
4342 AC_MSG_CHECKING([for application to build])
4343 if test -z "$MOZ_BUILD_APP"; then
4344   AC_MSG_RESULT([browser])
4345   MOZ_BUILD_APP=browser
4346 else
4347   # "mobile" no longer exists.
4348   if test "$MOZ_BUILD_APP" = "mobile" ; then
4349     AC_MSG_RESULT([none])
4350     AC_MSG_ERROR([--enable-application=mobile is no longer supported.])
4351   fi
4352   # We have a valid application only if it has a build.mk file in its top
4353   # directory.
4354   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
4355     AC_MSG_RESULT([none])
4356     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
4357   else
4358     AC_MSG_RESULT([$MOZ_BUILD_APP])
4359   fi
4362 # The app update channel is 'default' when not supplied. The value is used in
4363 # the application's confvars.sh so it must be set before confvars.sh is called.
4364 MOZ_ARG_ENABLE_STRING([update-channel],
4365 [  --enable-update-channel=CHANNEL
4366                           Select application update channel (default=default)],
4367     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
4369 if test -z "$MOZ_UPDATE_CHANNEL"; then
4370     MOZ_UPDATE_CHANNEL=default
4372 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
4373 AC_SUBST(MOZ_UPDATE_CHANNEL)
4375 # Allow the application to influence configure with a confvars.sh script.
4376 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4377 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4378   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4379   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4380 else
4381   AC_MSG_RESULT([no])
4384 # Allow influencing configure with a defines.sh script.
4385 . "${srcdir}/build/defines.sh"
4387 # If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
4388 # set in defines.sh
4389 if test "$BUILDING_RELEASE"; then
4390   # Override value in defines.sh, if any
4391   EARLY_BETA_OR_EARLIER=
4392 elif test "$EARLY_BETA_OR_EARLIER"; then
4393   AC_DEFINE(EARLY_BETA_OR_EARLIER)
4395 AC_SUBST(EARLY_BETA_OR_EARLIER)
4397 # Allow the application to provide a subconfigure script
4398 if test -f "${srcdir}/${MOZ_BUILD_APP}/configure.in" ; then
4399   do_output_subdirs() {
4400     if test -n "$_subconfigure_subdirs"; then
4401       AC_MSG_ERROR([Cannot specify more than one sub-sub-configure])
4402      fi
4403     _subconfigure_subdir="$1"
4404     _subconfigure_config_args="$ac_configure_args"
4405   }
4406   tmpscript=`$PYTHON -c 'import os, tempfile; print tempfile.mktemp(prefix="subscript.").replace(os.sep, "/")'` || exit 1
4407   m4 "${srcdir}/build/autoconf/subconfigure.m4" \
4408      "${srcdir}/build/autoconf/altoptions.m4" \
4409      "${srcdir}/${MOZ_BUILD_APP}/configure.in" > $tmpscript
4410   . $tmpscript
4411   rm -f $tmpscript
4414 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
4415 MOZ_ARG_WITH_STRING(app-name,
4416 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
4417 WITH_APP_NAME=$withval,
4420 if test -n "$WITH_APP_NAME" ; then
4421     MOZ_APP_NAME="$WITH_APP_NAME"
4424 MOZ_ARG_WITH_STRING(app-basename,
4425 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
4426 WITH_APP_BASENAME=$withval,
4429 if test -n "$WITH_APP_BASENAME" ; then
4430     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
4433 # Now is a good time to test for logic errors, define mismatches, etc.
4434 case "$MOZ_BUILD_APP" in
4435 xulrunner)
4436   if test "$LIBXUL_SDK"; then
4437     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4438   fi
4439   ;;
4440 esac
4442 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4443 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4444 # MOZ_BUILD_APP.
4445 case "$MOZ_BUILD_APP" in
4446 browser)
4447   AC_DEFINE(MOZ_PHOENIX)
4448   ;;
4450 xulrunner)
4451   AC_DEFINE(MOZ_XULRUNNER)
4452   ;;
4453 b2g)
4454   AC_DEFINE(MOZ_B2G)
4455   ;;
4456 esac
4458 AC_SUBST(MOZ_BUILD_APP)
4459 AC_SUBST(MOZ_PHOENIX)
4460 AC_SUBST(MOZ_XULRUNNER)
4461 AC_SUBST(MOZ_B2G)
4463 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4465 dnl ========================================================
4466 dnl Check android sdk version depending on mobile target
4467 dnl ========================================================
4469 if test -z "$gonkdir" ; then
4470     # Minimum Android SDK API Level we require.
4471     case "$MOZ_BUILD_APP" in
4472     mobile/android)
4473         android_min_api_level=16
4474         ;;
4475     esac
4477     MOZ_ANDROID_SDK($android_min_api_level)
4480 dnl ========================================================
4481 dnl =
4482 dnl = Toolkit Options
4483 dnl =
4484 dnl ========================================================
4485 MOZ_ARG_HEADER(Toolkit Options)
4487     dnl ========================================================
4488     dnl = Select the default toolkit
4489     dnl ========================================================
4490         MOZ_ARG_ENABLE_STRING(default-toolkit,
4491         [  --enable-default-toolkit=TK
4492                           Select default toolkit
4493                           Platform specific defaults:
4494                             Mac OS X - cairo-cocoa
4495                             OS/2 - cairo-os2
4496                             Win32 - cairo-windows
4497                             * - cairo-gtk2
4498                             * - cairo-qt],
4499     [ _DEFAULT_TOOLKIT=$enableval ],
4500     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4502     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4503         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4504         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4505         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4506         -o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
4507         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
4508         -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
4509         -o "$_DEFAULT_TOOLKIT" = "cairo-android" \
4510         -o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
4511     then
4512         dnl nglayout only supports building with one toolkit,
4513         dnl so ignore everything after the first comma (",").
4514         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4515     else
4516         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4517     fi
4519 MOZ_ARG_WITHOUT_BOOL(x,
4520 [  --without-x              Build without X11],
4521     WITHOUT_X11=1)
4523 dnl ========================================================
4524 dnl = Enable the toolkit as needed                         =
4525 dnl ========================================================
4527 MOZ_WIDGET_GTK=
4529 case "$MOZ_WIDGET_TOOLKIT" in
4531 cairo-windows)
4532     MOZ_WIDGET_TOOLKIT=windows
4533     MOZ_WEBGL=1
4534     MOZ_PDF_PRINTING=1
4535     MOZ_INSTRUMENT_EVENT_LOOP=1
4536     if test -n "$GNU_CC"; then
4537         MOZ_FOLD_LIBS=
4538     fi
4539     ;;
4541 cairo-gtk2|cairo-gtk2-x11)
4542     MOZ_WIDGET_TOOLKIT=gtk2
4543     MOZ_ENABLE_GTK2=1
4544     MOZ_ENABLE_XREMOTE=1
4545     MOZ_WEBGL=1
4546     MOZ_GL_DEFAULT_PROVIDER=GLX
4548     AC_DEFINE(MOZ_X11)
4549     MOZ_X11=1
4550     USE_FC_FREETYPE=1
4552     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4553     TK_LIBS='$(MOZ_GTK2_LIBS)'
4554     AC_DEFINE(MOZ_WIDGET_GTK2)
4555     MOZ_WIDGET_GTK=2
4556     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4557     MOZ_PDF_PRINTING=1
4558     MOZ_INSTRUMENT_EVENT_LOOP=1
4559     ;;
4561 cairo-qt)
4562     MOZ_WIDGET_TOOLKIT=qt
4563     MOZ_ENABLE_QT=1
4564     if test -z "$WITHOUT_X11"; then
4565       MOZ_ENABLE_XREMOTE=1
4566       MOZ_GL_DEFAULT_PROVIDER=GLX
4567       MOZ_X11=1
4568       AC_DEFINE(MOZ_X11)
4569       XT_LIBS=
4570     fi
4572     MOZ_WEBGL=1
4573     USE_ELF_DYNSTR_GC=
4574     USE_FC_FREETYPE=1
4575     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4576     TK_LIBS='$(MOZ_QT_LIBS)'
4577     AC_DEFINE(MOZ_WIDGET_QT)
4578     MOZ_PDF_PRINTING=1
4579     AC_DEFINE(QT_NO_KEYWORDS)
4580     ;;
4582 cairo-os2)
4583     MOZ_WIDGET_TOOLKIT=os2
4584     USE_FC_FREETYPE=1
4585     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4586     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4587     MOZ_PDF_PRINTING=1
4588     ;;
4590 cairo-cocoa)
4591     MOZ_WIDGET_TOOLKIT=cocoa
4592     AC_DEFINE(MOZ_WIDGET_COCOA)
4593     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
4594     TK_LIBS='-framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
4595     TK_CFLAGS="-DNO_X11"
4596     CFLAGS="$CFLAGS $TK_CFLAGS"
4597     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4598     DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/bin/XUL -lxpcom_core -lmozalloc'
4599     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/bin/XUL -lmozalloc'
4600     MOZ_USER_DIR="Mozilla"
4601     MOZ_FS_LAYOUT=bundle
4602     MOZ_WEBGL=1
4603     MOZ_INSTRUMENT_EVENT_LOOP=1
4604     ;;
4606 cairo-uikit)
4607     MOZ_WIDGET_TOOLKIT=uikit
4608     AC_DEFINE(MOZ_WIDGET_UIKIT)
4609     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
4610     TK_CFLAGS="-DNO_X11"
4611     TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
4612     CFLAGS="$CFLAGS $TK_CFLAGS"
4613     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4614     DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/bin/XUL -lxpcom_core -lmozalloc'
4615     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/bin/XUL -lmozalloc'
4616     MOZ_USER_DIR="Mozilla"
4617     MOZ_FS_LAYOUT=bundle
4618     ;;
4620 cairo-android)
4621     AC_DEFINE(MOZ_WIDGET_ANDROID)
4622     MOZ_WIDGET_TOOLKIT=android
4623     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4624     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4625     MOZ_WEBGL=1
4626     MOZ_PDF_PRINTING=1
4627     MOZ_INSTRUMENT_EVENT_LOOP=1
4628     ;;
4630 cairo-gonk)
4631     AC_DEFINE(MOZ_WIDGET_GONK)
4632     AC_DEFINE(MOZ_TOUCH)
4633     MOZ_WIDGET_TOOLKIT=gonk
4634     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4635     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4636     MOZ_WEBGL=1
4637     MOZ_PDF_PRINTING=1
4638     MOZ_TOUCH=1
4639     ;;
4641 esac
4643 AC_SUBST(MOZ_PDF_PRINTING)
4644 if test "$MOZ_PDF_PRINTING"; then
4645    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
4646    AC_DEFINE(MOZ_PDF_PRINTING)
4649 if test "$MOZ_ENABLE_XREMOTE"; then
4650     AC_DEFINE(MOZ_ENABLE_XREMOTE)
4653 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
4654    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
4657 if test "$COMPILE_ENVIRONMENT"; then
4658   if test "$MOZ_ENABLE_GTK2"; then
4659     if test "$MOZ_X11"; then
4660       GDK_PACKAGES=gdk-x11-2.0
4661     fi
4663     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4664   fi
4666 fi # COMPILE_ENVIRONMENT
4668 AC_SUBST(MOZ_FS_LAYOUT)
4670 dnl ========================================================
4671 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4672 dnl their usage and use them in spidermonkey.
4673 dnl ========================================================
4674 MOZ_ARG_WITH_BOOL(arm-kuser,
4675 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4676     USE_ARM_KUSER=1,)
4677 if test -n "$USE_ARM_KUSER"; then
4678    AC_DEFINE(USE_ARM_KUSER)
4681 dnl ========================================================
4682 dnl = startup-notification support module
4683 dnl ========================================================
4685 if test "$MOZ_ENABLE_GTK2"
4686 then
4687     MOZ_ENABLE_STARTUP_NOTIFICATION=
4689     MOZ_ARG_ENABLE_BOOL(startup-notification,
4690     [  --enable-startup-notification
4691                           Enable startup-notification support (default: disabled) ],
4692         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
4693         MOZ_ENABLE_STARTUP_NOTIFICATION=)
4694     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
4695     then
4696         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
4697                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
4698         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
4699             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
4700             then
4701                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
4702             fi
4703             MOZ_ENABLE_STARTUP_NOTIFICATION=
4704         ])
4705     fi
4707     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
4708         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
4709     fi
4711     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
4713 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
4714 AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
4715 AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
4717 dnl ========================================================
4718 dnl = QT support
4719 dnl ========================================================
4720 if test "$MOZ_ENABLE_QT"
4721 then
4722     MOZ_ARG_WITH_STRING(qtdir,
4723     [  --with-qtdir=\$dir       Specify Qt directory ],
4724     [ QTDIR=$withval])
4726     if test -z "$QTDIR"; then
4727         PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore QtOpenGL)
4728         PKG_CHECK_MODULES(MOZ_QT5, Qt5Widgets Qt5Multimedia Qt5PrintSupport,
4729                       MOZ_ENABLE_QT5=1,
4730                       MOZ_ENABLE_QT5=)
4731         if test "$MOZ_ENABLE_QT5"; then
4732             echo "Using qt5"
4733             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $MOZ_QT5_CFLAGS"
4734             MOZ_QT_LIBS="$MOZ_QT_LIBS $MOZ_QT5_LIBS"
4735         fi
4737         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
4738         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
4739     else
4740         MOZ_QT_CFLAGS="-DQT_SHARED"
4741         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
4742         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
4743         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
4744         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
4745         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
4746         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative"
4748         # QtWidgets was introduced only in Qt5
4749         if test -d $QTDIR/include/QtWidgets; then
4750             echo "Using qt5"
4751             MOZ_QT_LIBS="-L$QTDIR/lib/ -lQt5Gui -lQt5Network -lQt5Core -lQt5Xml -lQt5OpenGL"
4752             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui/5.0.1/QtGui"
4753             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtWidgets"
4754             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport"
4755             MOZ_QT_LIBS="$MOZ_QT_LIBS -lQt5Widgets -lQt5PrintSupport"
4756         else
4757             MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
4758             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/Qt"
4759         fi
4760         HOST_MOC="$QTDIR/bin/moc"
4761         HOST_RCC="$QTDIR/bin/rcc"
4762     fi
4763     if test -z "$HOST_MOC"; then
4764         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
4765 incorrect])
4766     fi
4767     if test -z "$HOST_RCC"; then
4768         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is
4769 incorrect])
4770     fi
4772     MOC=$HOST_MOC
4773     RCC=$HOST_RCC
4775     MOZ_ENABLE_QMSYSTEM2=
4776     PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
4777                       MOZ_ENABLE_QMSYSTEM2=1,
4778                       MOZ_ENABLE_QMSYSTEM2=)
4780     if test "$MOZ_ENABLE_QMSYSTEM2"; then
4781       MOZ_ENABLE_QMSYSTEM2=1
4782       MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
4783       MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
4784       AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
4785     fi
4787     MOZ_ENABLE_QTNETWORK=
4788     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
4789                       MOZ_ENABLE_QTNETWORK=1,
4790                       MOZ_ENABLE_QTNETWORK=)
4792     if test "$MOZ_ENABLE_QTNETWORK"; then
4793       MOZ_ENABLE_QTNETWORK=1
4794       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
4795     fi
4797     MOZ_ENABLE_QTMOBILITY=
4798     PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
4799                       MOZ_ENABLE_QTMOBILITY=1,
4800                       MOZ_ENABLE_QTMOBILITY=)
4801     if test "$MOZ_ENABLE_QTMOBILITY"; then
4802        MOZ_ENABLE_QTMOBILITY=1
4803        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
4804        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
4805     else
4806        AC_CHECK_LIB(QtSensors, main, [
4807           MOZ_ENABLE_QTMOBILITY=1
4808           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMobility"
4809           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtSensors"
4810           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtFeedback"
4811           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtLocation"
4812           MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
4813        ])
4814     fi
4815     if test "$MOZ_ENABLE_QTMOBILITY"; then
4816        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
4817     fi
4820 AC_SUBST(GTK_CONFIG)
4821 AC_SUBST(TK_CFLAGS)
4822 AC_SUBST(TK_LIBS)
4824 AC_SUBST(MOZ_ENABLE_GTK2)
4825 AC_SUBST(MOZ_ENABLE_QT)
4826 AC_SUBST(MOZ_ENABLE_QTNETWORK)
4827 AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
4828 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4829 AC_SUBST(MOZ_ENABLE_XREMOTE)
4830 AC_SUBST(MOZ_GTK2_CFLAGS)
4831 AC_SUBST(MOZ_GTK2_LIBS)
4832 AC_SUBST(MOZ_WIDGET_GTK)
4833 AC_SUBST(MOZ_QT_CFLAGS)
4834 AC_SUBST(MOZ_QT_LIBS)
4836 AC_SUBST(MOC)
4837 AC_SUBST(RCC)
4839 AC_SUBST(MOZ_X11)
4841 dnl ========================================================
4842 dnl =
4843 dnl = Components & Features
4844 dnl =
4845 dnl ========================================================
4846 MOZ_ARG_HEADER(Components and Features)
4848 dnl ========================================================
4849 dnl = Localization
4850 dnl ========================================================
4851 MOZ_ARG_ENABLE_STRING(ui-locale,
4852 [  --enable-ui-locale=ab-CD
4853                           Select the user interface locale (default: en-US)],
4854     MOZ_UI_LOCALE=$enableval )
4855 AC_SUBST(MOZ_UI_LOCALE)
4857 dnl ========================================================
4858 dnl = Trademarked Branding
4859 dnl ========================================================
4860 MOZ_ARG_ENABLE_BOOL(official-branding,
4861 [  --enable-official-branding
4862                           Enable Official mozilla.org Branding
4863                           Do not distribute builds with
4864                           --enable-official-branding unless you have
4865                           permission to use trademarks per
4866                           http://www.mozilla.org/foundation/trademarks/ .],
4868   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
4869     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
4870   else
4871     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
4872     MOZ_OFFICIAL_BRANDING=1
4873   fi
4874 ], MOZ_OFFICIAL_BRANDING=)
4876 AC_SUBST(MOZ_OFFICIAL_BRANDING)
4877 if test -n "$MOZ_OFFICIAL_BRANDING"; then
4878   AC_DEFINE(MOZ_OFFICIAL_BRANDING)
4881 MOZ_ARG_WITH_STRING(branding,
4882 [  --with-branding=dir     Use branding from the specified directory.],
4883     MOZ_BRANDING_DIRECTORY=$withval)
4885 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
4886 if test -z "$REAL_BRANDING_DIRECTORY"; then
4887   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
4890 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
4891   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
4894 AC_SUBST(MOZ_BRANDING_DIRECTORY)
4896 dnl ========================================================
4897 dnl = Distribution ID
4898 dnl ========================================================
4899 MOZ_ARG_WITH_STRING(distribution-id,
4900 [  --with-distribution-id=ID
4901                           Set distribution-specific id (default=org.mozilla)],
4902 [ val=`echo $withval`
4903     MOZ_DISTRIBUTION_ID="$val"])
4905 if test -z "$MOZ_DISTRIBUTION_ID"; then
4906    MOZ_DISTRIBUTION_ID="org.mozilla"
4909 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
4910 AC_SUBST(MOZ_DISTRIBUTION_ID)
4913 dnl ========================================================
4914 dnl complex text support off by default
4915 dnl ========================================================
4916 MOZ_ARG_DISABLE_BOOL(pango,
4917 [  --disable-pango         Disable usage of Pango ],
4918     MOZ_PANGO=,
4919     MOZ_PANGO=1)
4921 dnl ========================================================
4922 dnl = Pango
4923 dnl ========================================================
4924 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
4925 then
4926     AC_SUBST(MOZ_PANGO)
4928     if test "$MOZ_PANGO"
4929     then
4930         PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
4932         PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
4933         AC_SUBST(MOZ_PANGO_CFLAGS)
4934         AC_SUBST(MOZ_PANGO_LIBS)
4935         AC_DEFINE(MOZ_PANGO)
4936     else
4937         PKG_CHECK_MODULES(FT2, freetype2 > 6.1.0)
4938         AC_SUBST(FT2_CFLAGS)
4939         AC_SUBST(FT2_LIBS)
4940     fi
4943 dnl ========================================================
4944 dnl = GnomeVFS, GIO and GConf support module
4945 dnl ========================================================
4947 if test "$MOZ_X11"
4948 then
4949     dnl build the GIO extension by default only when the
4950     dnl GTK2 toolkit is in use.
4951     if test "$MOZ_ENABLE_GTK2"
4952     then
4953         MOZ_ENABLE_GIO=1
4954         MOZ_ENABLE_GCONF=1
4955     fi
4957     dnl ========================================================
4958     dnl = GnomeVFS support module
4959     dnl ========================================================
4960     MOZ_ARG_ENABLE_BOOL(gnomevfs,
4961     [  --enable-gnomevfs       Enable GnomeVFS support (default: disabled)],
4962         MOZ_ENABLE_GNOMEVFS=force,
4963         MOZ_ENABLE_GNOMEVFS=)
4965     if test "$MOZ_ENABLE_GNOMEVFS"
4966     then
4967         PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
4968             MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
4969             MOZ_ENABLE_GNOMEVFS=1
4970             AC_DEFINE(MOZ_ENABLE_GNOMEVFS)
4971         ],[
4972             if test "$MOZ_ENABLE_GNOMEVFS" = "force"
4973             then
4974                 AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
4975             fi
4976             MOZ_ENABLE_GNOMEVFS=
4977         ])
4978     fi
4980     AC_SUBST(MOZ_ENABLE_GNOMEVFS)
4981     AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
4982     AC_SUBST(MOZ_GNOMEVFS_LIBS)
4984     dnl ========================================================
4985     dnl = GIO support module
4986     dnl ========================================================
4987     MOZ_ARG_DISABLE_BOOL(gio,
4988     [  --disable-gio           Disable GIO support],
4989         MOZ_ENABLE_GIO=,
4990         MOZ_ENABLE_GIO=force)
4992     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK2"
4993     then
4994         PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
4995                           [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
4996         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
4997             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
4998             MOZ_ENABLE_GIO=1
4999             AC_DEFINE(MOZ_ENABLE_GIO)
5000         ],[
5001             if test "$MOZ_ENABLE_GIO" = "force"
5002             then
5003                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
5004             fi
5005             MOZ_ENABLE_GIO=
5006         ])
5007     fi
5009     AC_SUBST(MOZ_ENABLE_GIO)
5010     AC_SUBST(MOZ_GIO_CFLAGS)
5011     AC_SUBST(MOZ_GIO_LIBS)
5013     dnl ========================================================
5014     dnl = GConf support module
5015     dnl ========================================================
5016     MOZ_ARG_DISABLE_BOOL(gconf,
5017     [  --disable-gconf      Disable Gconf support ],
5018         MOZ_ENABLE_GCONF=,
5019         MOZ_ENABLE_GCONF=force)
5021     if test "$MOZ_ENABLE_GCONF"
5022     then
5023         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
5024             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
5025             MOZ_ENABLE_GCONF=1
5026         ],[
5027             if test "$MOZ_ENABLE_GCONF" = "force"
5028             then
5029                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
5030             fi
5031             MOZ_ENABLE_GCONF=
5032         ])
5033     fi
5035     if test "$MOZ_ENABLE_GCONF"; then
5036         AC_DEFINE(MOZ_ENABLE_GCONF)
5037     fi
5039     AC_SUBST(MOZ_ENABLE_GCONF)
5040     AC_SUBST(MOZ_GCONF_CFLAGS)
5041     AC_SUBST(MOZ_GCONF_LIBS)
5044 dnl ========================================================
5045 dnl = libproxy support
5046 dnl ========================================================
5048 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
5049 then
5050     MOZ_ENABLE_LIBPROXY=
5052     MOZ_ARG_ENABLE_BOOL(libproxy,
5053     [  --enable-libproxy         Enable libproxy support ],
5054     MOZ_ENABLE_LIBPROXY=1,
5055     MOZ_ENABLE_LIBPROXY=)
5057     if test "$MOZ_ENABLE_LIBPROXY"
5058     then
5059         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
5060         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
5061     fi
5063 AC_SUBST(MOZ_ENABLE_LIBPROXY)
5064 AC_SUBST(MOZ_LIBPROXY_CFLAGS)
5065 AC_SUBST(MOZ_LIBPROXY_LIBS)
5067 dnl ========================================================
5068 dnl = GNOME component (mozgnome)
5069 dnl ========================================================
5071 if test "$MOZ_ENABLE_GTK2"
5072 then
5073     MOZ_ENABLE_GNOME_COMPONENT=1
5075 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
5077 dnl ========================================================
5078 dnl = libgnomeui support module
5079 dnl ========================================================
5081 if test "$MOZ_ENABLE_GTK2"
5082 then
5083     MOZ_ARG_ENABLE_BOOL(gnomeui,
5084     [  --enable-gnomeui        Enable libgnomeui instead of GIO & GTK for icon theme support ],
5085         MOZ_ENABLE_GNOMEUI=force,
5086         MOZ_ENABLE_GNOMEUI=)
5088     if test "$MOZ_ENABLE_GNOMEUI"
5089     then
5090         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
5091         [
5092             MOZ_ENABLE_GNOMEUI=1
5093         ],[
5094             if test "$MOZ_ENABLE_GNOMEUI" = "force"
5095             then
5096                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
5097             fi
5098             MOZ_ENABLE_GNOMEUI=
5099         ])
5100     fi
5102     if test "$MOZ_ENABLE_GNOMEUI"; then
5103         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
5104     fi
5107 AC_SUBST(MOZ_ENABLE_GNOMEUI)
5108 AC_SUBST(MOZ_GNOMEUI_CFLAGS)
5110 dnl ========================================================
5111 dnl = dbus support
5112 dnl ========================================================
5114 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
5115 then
5116     MOZ_ENABLE_DBUS=1
5118     MOZ_ARG_DISABLE_BOOL(dbus,
5119     [  --disable-dbus          Disable dbus support ],
5120         MOZ_ENABLE_DBUS=,
5121         MOZ_ENABLE_DBUS=1)
5123     if test "$MOZ_ENABLE_DBUS"
5124     then
5125         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
5126         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
5127         AC_DEFINE(MOZ_ENABLE_DBUS)
5128     fi
5130 AC_SUBST(MOZ_ENABLE_DBUS)
5131 AC_SUBST(MOZ_DBUS_CFLAGS)
5132 AC_SUBST(MOZ_DBUS_LIBS)
5133 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
5134 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
5136 dnl ========================================================
5137 dnl = Enable Android History instead of Places
5138 dnl ========================================================
5139 if test -n "$MOZ_ANDROID_HISTORY"; then
5140     if test -z "$MOZ_PLACES"; then
5141         AC_DEFINE(MOZ_ANDROID_HISTORY)
5142     else
5143         AC_MSG_ERROR([Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.])
5144     fi
5147 dnl ========================================================
5148 dnl = Build with the Android compositor
5149 dnl ========================================================
5150 if test -n "$MOZ_ANDROID_OMTC"; then
5151      dnl Do this if defined in confvars.sh
5152      AC_DEFINE(MOZ_ANDROID_OMTC)
5155 dnl ========================================================
5156 dnl = Disable WebSMS backend
5157 dnl ========================================================
5158 MOZ_ARG_DISABLE_BOOL(websms-backend,
5159 [  --disable-websms-backend
5160                            Disable WebSMS backend],
5161     MOZ_WEBSMS_BACKEND=,
5162     MOZ_WEBSMS_BACKEND=1)
5164 if test -n "$MOZ_WEBSMS_BACKEND"; then
5165     AC_DEFINE(MOZ_WEBSMS_BACKEND)
5168 dnl ========================================================
5169 dnl = Enable SET_WALLPAPER permission on Android
5170 dnl ========================================================
5171 if test -n "$MOZ_ANDROID_WALLPAPER"; then
5172     AC_DEFINE(MOZ_ANDROID_WALLPAPER)
5175 dnl ========================================================
5176 dnl = Enable NFC permission on Android
5177 dnl ========================================================
5178 if test -n "$MOZ_ANDROID_BEAM"; then
5179     AC_DEFINE(MOZ_ANDROID_BEAM)
5182 dnl ========================================================
5183 dnl = Build Personal Security Manager
5184 dnl ========================================================
5185 MOZ_ARG_DISABLE_BOOL(crypto,
5186 [  --disable-crypto        Disable crypto support (Personal Security Manager)],
5187     MOZ_PSM=,
5188     MOZ_PSM=1 )
5190 dnl ========================================================
5191 dnl = JS Debugger XPCOM component (js/jsd)
5192 dnl ========================================================
5193 MOZ_ARG_DISABLE_BOOL(jsd,
5194 [  --disable-jsd           Disable JavaScript debug library],
5195     MOZ_JSDEBUGGER=,
5196     MOZ_JSDEBUGGER=1)
5199 dnl ========================================================
5200 dnl = Enable IPDL's "expensive" unit tests
5201 dnl ========================================================
5202 MOZ_IPDL_TESTS=
5204 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
5205 [  --enable-ipdl-tests     Enable expensive IPDL tests],
5206     MOZ_IPDL_TESTS=1,
5207     MOZ_IPDL_TESTS=)
5209 if test -n "$MOZ_IPDL_TESTS"; then
5210     AC_DEFINE(MOZ_IPDL_TESTS)
5213 AC_SUBST(MOZ_IPDL_TESTS)
5215 dnl ========================================================
5216 dnl = Disable building dbm
5217 dnl ========================================================
5218 MOZ_ARG_DISABLE_BOOL(dbm,
5219 [  --disable-dbm           Disable building dbm],
5220     NSS_DISABLE_DBM=1,
5221     NSS_DISABLE_DBM=)
5223 dnl bi-directional support always on
5224 IBMBIDI=1
5225 AC_DEFINE(IBMBIDI)
5227 dnl ========================================================
5228 dnl accessibility support on by default on all platforms
5229 dnl ========================================================
5230 MOZ_ARG_DISABLE_BOOL(accessibility,
5231 [  --disable-accessibility Disable accessibility support],
5232     ACCESSIBILITY=,
5233     ACCESSIBILITY=1 )
5234 if test "$ACCESSIBILITY"; then
5235     case "$target" in
5236     *-mingw*)
5237         if test -z "$MIDL"; then
5238             if test "$GCC" != "yes"; then
5239                 AC_MSG_ERROR([MIDL could not be found. Building accessibility without MIDL is not supported.])
5240             else
5241                 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.])
5242             fi
5243         fi
5244     esac
5245     AC_DEFINE(ACCESSIBILITY)
5248 dnl ========================================================
5249 dnl Accessibility is required for the linuxgl widget
5250 dnl backend
5251 dnl ========================================================
5252 if test "${MOZ_WIDGET_TOOLKIT}" = "linuxgl" -a "$ACCESSIBILITY" != "1"; then
5253     AC_MSG_ERROR(["Accessibility is required for the linuxgl widget backend"])
5256 dnl ========================================================
5257 dnl Disable printing
5258 dnl ========================================================
5259 MOZ_ARG_DISABLE_BOOL(printing,
5260 [  --disable-printing      Disable printing support],
5261     NS_PRINTING=,
5262     NS_PRINTING=1)
5264 if test "$NS_PRINTING"; then
5265     AC_DEFINE(NS_PRINTING)
5266     AC_DEFINE(NS_PRINT_PREVIEW)
5269 dnl Turn off webrtc for OS's we don't handle yet, but allow 
5270 dnl --enable-webrtc to override.  Can disable for everything in
5271 dnl the master list above.
5272 if test -n "$MOZ_WEBRTC"; then
5273     case "$target" in
5274     *-linux*|*-mingw*|*-darwin*|*-android*|*-linuxandroid*)
5275         dnl Leave enabled
5276         ;;
5277     *)
5278         dnl default to disabled for all others
5279         MOZ_WEBRTC=
5280         ;;
5281     esac
5284 # target_arch is from {ia32|x64|arm|ppc}
5285 case "$CPU_ARCH" in
5286 x86_64 | ia64)
5287     WEBRTC_TARGET_ARCH=x64
5288     ;;
5290 arm*)
5291     WEBRTC_TARGET_ARCH=arm
5292     ;;
5294 x86)
5295     WEBRTC_TARGET_ARCH=ia32
5296     ;;
5298 ppc*)
5299     WEBRTC_TARGET_ARCH=ppc
5300     ;;
5302 # unsupported arch for webrtc
5303     WEBRTC_TARGET_ARCH=unknown
5304     MOZ_WEBRTC=
5305     ;;
5307 esac
5309 dnl ========================================================
5310 dnl = Disable WebRTC code
5311 dnl ========================================================
5312 MOZ_ARG_DISABLE_BOOL(webrtc,
5313 [  --disable-webrtc        Disable support for WebRTC],
5314     MOZ_WEBRTC=,
5315     MOZ_WEBRTC=1)
5317 if test -n "$MOZ_WEBRTC"; then
5318     AC_DEFINE(MOZ_WEBRTC)
5319     dnl MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
5320     dnl opt/production builds (via MOZ_CRASH())
5321     AC_DEFINE(MOZ_WEBRTC_ASSERT_ALWAYS)
5322     MOZ_RAW=1
5323     MOZ_VP8=1
5324     MOZ_VP8_ENCODER=1
5325     MOZ_VP8_ERROR_CONCEALMENT=1
5327 dnl enable once Signaling lands
5328     MOZ_WEBRTC_SIGNALING=1
5329     AC_DEFINE(MOZ_WEBRTC_SIGNALING)
5330     if test "${OS_TARGET}" = "WINNT"; then
5331         MOZ_WEBRTC_IN_LIBXUL=1
5332     fi
5333 dnl enable once PeerConnection lands
5334     MOZ_PEERCONNECTION=1
5335     AC_DEFINE(MOZ_PEERCONNECTION)
5336     MOZ_SCTP=1
5337     MOZ_SRTP=1
5338     AC_DEFINE(MOZ_SCTP)
5339     AC_DEFINE(MOZ_SRTP)
5342 AC_SUBST(MOZ_WEBRTC)
5343 AC_SUBST(MOZ_WEBRTC_LEAKING_TESTS)
5344 AC_SUBST(MOZ_WEBRTC_SIGNALING)
5345 AC_SUBST(MOZ_PEERCONNECTION)
5346 AC_SUBST(MOZ_WEBRTC_IN_LIBXUL)
5347 AC_SUBST(MOZ_WEBRTC_ASSERT_ALWAYS)
5348 AC_SUBST(MOZ_SCTP)
5349 AC_SUBST(MOZ_SRTP)
5351 case "$target_cpu" in
5352 arm*)
5353     MOZ_SAMPLE_TYPE_S16=1
5354     AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
5355     AC_SUBST(MOZ_SAMPLE_TYPE_S16)
5358     MOZ_SAMPLE_TYPE_FLOAT32=1
5359     AC_DEFINE(MOZ_SAMPLE_TYPE_FLOAT32)
5360     AC_SUBST(MOZ_SAMPLE_TYPE_FLOAT32)
5362 esac
5364 dnl ========================================================
5365 dnl = Disable Speech API code
5366 dnl ========================================================
5367 MOZ_ARG_DISABLE_BOOL(webspeech,
5368 [  --disable-webspeech        Disable support for HTML Speech API],
5369     MOZ_WEBSPEECH=,
5370     MOZ_WEBSPEECH=1)
5372 if test -n "$MOZ_WEBSPEECH"; then
5373     AC_DEFINE(MOZ_WEBSPEECH)
5376 AC_SUBST(MOZ_WEBSPEECH)
5378 dnl ========================================================
5379 dnl = Enable Raw Codecs
5380 dnl ========================================================
5381 MOZ_ARG_ENABLE_BOOL(raw,
5382 [  --enable-raw           Enable support for RAW media],
5383     MOZ_RAW=1,
5384     MOZ_RAW=)
5386 if test -n "$MOZ_RAW"; then
5387     AC_DEFINE(MOZ_RAW)
5390 AC_SUBST(MOZ_RAW)
5392 dnl ========================================================
5393 dnl = Disable Ogg Codecs
5394 dnl ========================================================
5395 MOZ_ARG_DISABLE_BOOL(ogg,
5396 [  --disable-ogg           Disable support for OGG media (Theora video and Vorbis audio)],
5397     MOZ_OGG=,
5398     MOZ_OGG=1)
5400 if test -n "$MOZ_OGG"; then
5401     AC_DEFINE(MOZ_OGG)
5402     MOZ_CUBEB=1
5404     dnl Checks for __attribute__(aligned()) directive
5405     AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5406         [ac_cv_c_attribute_aligned],
5407         [ac_cv_c_attribute_aligned=0
5408          CFLAGS_save="${CFLAGS}"
5409          CFLAGS="${CFLAGS} -Werror"
5410          for ac_cv_c_attr_align_try in 64 32 16 8; do
5411            echo "trying $ac_cv_c_attr_align_try"
5412            AC_TRY_COMPILE([],
5413                           [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5414                           [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5415            if test "$ac_cv_c_attribute_aligned" != 0; then
5416              break;
5417            fi
5418          done
5419            CFLAGS="${CFLAGS_save}"])
5420     if test "${ac_cv_c_attribute_aligned}" != "0"; then
5421       AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5422                          [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5423     fi
5426 dnl ========================================================
5427 dnl = Disable Opus audio codec support
5428 dnl ========================================================
5429 MOZ_ARG_DISABLE_BOOL(opus,
5430 [  --disable-opus          Disable support for Opus audio],
5431     MOZ_OPUS=,
5432     MOZ_OPUS=1)
5434 dnl ========================================================
5435 dnl = Disable VP8 decoder support
5436 dnl ========================================================
5437 MOZ_ARG_DISABLE_BOOL(webm,
5438 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
5439     MOZ_WEBM=,
5440     MOZ_WEBM=1)
5442 if test -n "$MOZ_WEBM"; then
5443     AC_DEFINE(MOZ_WEBM)
5444     MOZ_VP8=1
5447 dnl ========================================================
5448 dnl = Windows Media Foundation support
5449 dnl ========================================================
5450 if test "$OS_ARCH" = "WINNT"; then
5451     dnl Enable Windows Media Foundation support by default.
5452     dnl Note our minimum SDK version is Windows 7 SDK, so we are (currently)
5453     dnl guaranteed to have a recent-enough SDK to build WMF.
5454     MOZ_WMF=1
5457 MOZ_ARG_DISABLE_BOOL(wmf,
5458 [  --disable-wmf  Disable support for Windows Media Foundation],
5459     MOZ_WMF=,
5460     MOZ_WMF=1)
5462 if test -n "$MOZ_WMF"; then
5463     AC_DEFINE(MOZ_WMF)
5464     MOZ_CUBEB=1
5467 dnl ========================================================
5468 dnl = Enable media plugin support
5469 dnl ========================================================
5470 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5471   dnl Enable support on android by default
5472   MOZ_MEDIA_PLUGINS=1
5475 MOZ_ARG_ENABLE_BOOL(media-plugins,
5476 [  --enable-media-plugins  Enable support for media plugins],
5477     MOZ_MEDIA_PLUGINS=1,
5478     MOZ_MEDIA_PLUGINS=)
5480 if test -n "$MOZ_MEDIA_PLUGINS"; then
5481   AC_DEFINE(MOZ_MEDIA_PLUGINS)
5484 dnl ========================================================
5485 dnl = Enable getUserMedia support
5486 dnl ========================================================
5487 MOZ_ARG_ENABLE_BOOL(media-navigator,
5488 [  --enable-media-navigator  Enable support for getUserMedia],
5489     MOZ_MEDIA_NAVIGATOR=1,
5490     MOZ_MEDIA_NAVIGATOR=)
5492 if test -n "$MOZ_MEDIA_NAVIGATOR"; then
5493   AC_DEFINE(MOZ_MEDIA_NAVIGATOR)
5496 dnl ========================================================
5497 dnl = Enable building OMX media plugin (B2G or Android)
5498 dnl ========================================================
5499 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5500   dnl Enable support on android by default
5501   MOZ_OMX_PLUGIN=1
5504 MOZ_ARG_ENABLE_BOOL(omx-plugin,
5505 [  --enable-omx-plugin      Enable building OMX plugin (B2G)],
5506     MOZ_OMX_PLUGIN=1,
5507     MOZ_OMX_PLUGIN=)
5509 if test -n "$MOZ_OMX_PLUGIN"; then
5510     if test "$OS_TARGET" = "Android"; then
5511         dnl Only allow building OMX plugin on Gonk (B2G) or Android
5512         AC_DEFINE(MOZ_OMX_PLUGIN)
5513     else
5514        dnl fail if we're not building on Gonk or Android
5515        AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
5516     fi
5519 dnl system libvpx Support
5520 dnl ========================================================
5521 MOZ_ARG_WITH_BOOL(system-libvpx,
5522 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
5523     MOZ_NATIVE_LIBVPX=1)
5525 MOZ_LIBVPX_CFLAGS=
5526 MOZ_LIBVPX_LIBS=
5528 if test -n "$MOZ_VP8"; then
5529     AC_DEFINE(MOZ_VP8)
5530     if test -n "$MOZ_VP8_ERROR_CONCEALMENT" ; then
5531         AC_DEFINE(MOZ_VP8_ERROR_CONCEALMENT)
5532     fi
5533     if test -n "$MOZ_VP8_ENCODER" ; then
5534         AC_DEFINE(MOZ_VP8_ENCODER)
5535     fi
5537     if test -n "$MOZ_NATIVE_LIBVPX"; then
5538         dnl ============================
5539         dnl === libvpx Version check ===
5540         dnl ============================
5541         dnl Check to see if we have a system libvpx package.
5542         PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.0.0)
5544         MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [], 
5545          [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.])])
5547         _SAVE_LIBS=$LIBS
5548         AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [], 
5549          [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
5550         LIBS=$_SAVE_LIBS
5551     fi
5554 AC_SUBST(MOZ_NATIVE_LIBVPX)
5555 AC_SUBST(MOZ_LIBVPX_CFLAGS)
5556 AC_SUBST(MOZ_LIBVPX_LIBS)
5558 if test "$MOZ_WEBM"; then
5559     MOZ_CUBEB=1
5560     if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then
5561         MOZ_VORBIS=1
5562     else
5563         MOZ_TREMOR=1
5564     fi
5567 if test -n "$MOZ_VP8" -a -z "$MOZ_NATIVE_LIBVPX"; then
5569     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
5570     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
5571     dnl We currently require gcc on all arm platforms.
5572     VPX_AS=$YASM
5573     VPX_ASM_SUFFIX=asm
5574     VPX_NEED_OBJ_INT_EXTRACT=
5576     dnl See if we have assembly on this platform.
5577     case "$OS_ARCH:$CPU_ARCH" in
5578     Darwin:x86)
5579       VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
5580       VPX_X86_ASM=1
5581     ;;
5582     Darwin:x86_64)
5583       VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
5584       VPX_X86_ASM=1
5585     ;;
5586     WINNT:x86_64)
5587       VPX_ASFLAGS="-f x64 -rnasm -pnasm"
5588       VPX_X86_ASM=1
5589     ;;
5590     WINNT:x86)
5591       dnl Check for yasm 1.1 or greater.
5592       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
5593         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.])
5594       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5595         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.])
5596       else
5597         VPX_ASFLAGS="-f win32 -rnasm -pnasm -DPIC"
5598         VPX_X86_ASM=1
5599         dnl The encoder needs obj_int_extract to get asm offsets.
5600       fi
5601     ;;
5602     *:arm*)
5603       if test -n "$GNU_AS" ; then
5604         VPX_AS=$AS
5605         dnl These flags are a lie; they're just used to enable the requisite
5606         dnl opcodes; actual arch detection is done at runtime.
5607         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
5608         VPX_DASH_C_FLAG="-c"
5609         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
5610         VPX_ASM_SUFFIX="$ASM_SUFFIX"
5611         VPX_ARM_ASM=1
5612       fi
5613     ;;
5614     *:x86)
5615       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5616         VPX_ASFLAGS="-f elf32 -rnasm -pnasm"
5617         VPX_X86_ASM=1
5618       fi
5619     ;;
5620     *:x86_64)
5621       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5622         VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5623         VPX_X86_ASM=1
5624       fi
5625     ;;
5626     esac
5628     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_X86_ASM" -a -z "$VPX_AS"; then
5629       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.])
5630     fi
5632     if test -n "$MOZ_VP8_ENCODER" -a \
5633             -z "$GNU_CC" -a -z "$INTEL_CC" -a -z "$CLANG_CC" ; then
5634       dnl We prefer to get asm offsets using inline assembler, which the above
5635       dnl compilers can do. When we're not using one of those, we have to fall
5636       dnl back to obj_int_extract, which reads them from a compiled object
5637       dnl file. Unfortunately, that only works if we're compiling on a system
5638       dnl with the header files for the appropriate object file format.
5639       VPX_NEED_OBJ_INT_EXTRACT=1
5640     fi
5642     if test -n "$VPX_X86_ASM"; then
5643       AC_DEFINE(VPX_X86_ASM)
5644     elif test -n "$VPX_ARM_ASM"; then
5645       AC_DEFINE(VPX_ARM_ASM)
5646     else
5647       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
5648     fi
5651 dnl ========================================================
5652 dnl = Disable Wave decoder support
5653 dnl ========================================================
5654 MOZ_ARG_DISABLE_BOOL(wave,
5655 [  --disable-wave          Disable Wave decoder support],
5656     MOZ_WAVE=,
5657     MOZ_WAVE=1)
5659 if test -n "$MOZ_WAVE"; then
5660     AC_DEFINE(MOZ_WAVE)
5661     MOZ_CUBEB=1
5664 dnl ========================================================
5665 dnl = Handle dependent CUBEB and MEDIA defines
5666 dnl ========================================================
5668 if test -n "$MOZ_SPEEX_RESAMPLER"; then
5669     AC_DEFINE(MOZ_SPEEX_RESAMPLER)
5672 if test -n "$MOZ_SOUNDTOUCH"; then
5673     AC_DEFINE(MOZ_SOUNDTOUCH)
5676 if test -n "$MOZ_CUBEB"; then
5677     AC_DEFINE(MOZ_CUBEB)
5680 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
5681     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/])
5684 if test -n "$MOZ_VORBIS"; then
5685     AC_DEFINE(MOZ_VORBIS)
5688 if test -n "$MOZ_TREMOR"; then
5689     AC_DEFINE(MOZ_TREMOR)
5692 if test -n "$MOZ_OPUS"; then
5693     AC_DEFINE(MOZ_OPUS)
5696 dnl ========================================================
5697 dnl = Check alsa availability on Linux if using sydneyaudio
5698 dnl ========================================================
5700 dnl If using sydneyaudio with Linux, ensure that the alsa library is available
5701 if test -n "$MOZ_CUBEB" -a "$OS_TARGET" = "Linux"; then
5702     MOZ_ALSA=1
5705 MOZ_ARG_ENABLE_BOOL(alsa,
5706 [  --enable-alsa          Enable Alsa support (default on Linux)],
5707 MOZ_ALSA=1,
5708 MOZ_ALSA=)
5710 if test -n "$MOZ_ALSA"; then
5711     AC_DEFINE(MOZ_CUBEB)
5712     PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5713          [echo "$MOZ_ALSA_PKG_ERRORS"
5714           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.)])])
5717 AC_SUBST(MOZ_ALSA)
5718 AC_SUBST(MOZ_ALSA_CFLAGS)
5719 AC_SUBST(MOZ_ALSA_LIBS)
5721 dnl ========================================================
5722 dnl = Enable PulseAudio
5723 dnl ========================================================
5725 MOZ_ARG_ENABLE_BOOL(pulseaudio,
5726 [  --enable-pulseaudio          Enable PulseAudio support (experimental)],
5727 MOZ_PULSEAUDIO=1,
5728 MOZ_PULSEAUDIO=)
5730 if test -n "$MOZ_PULSEAUDIO"; then
5731     AC_DEFINE(MOZ_CUBEB)
5732     PKG_CHECK_MODULES(MOZ_PULSEAUDIO, libpulse, ,
5733          [echo "$MOZ_PULSEAUDIO_PKG_ERRORS"
5734           AC_MSG_ERROR([pulseaudio audio backend requires libpulse package])])
5737 AC_SUBST(MOZ_PULSEAUDIO)
5738 AC_SUBST(MOZ_PULSEAUDIO_CFLAGS)
5739 AC_SUBST(MOZ_PULSEAUDIO_LIBS)
5741 dnl ========================================================
5742 dnl = Enable GStreamer
5743 dnl ========================================================
5744 MOZ_ARG_ENABLE_BOOL(gstreamer,
5745 [  --enable-gstreamer           Enable GStreamer support],
5746 MOZ_GSTREAMER=1,
5747 MOZ_GSTREAMER=)
5749 if test "$MOZ_GSTREAMER"; then
5750     # API version, eg 0.10, 1.0 etc
5751     GST_API_VERSION=0.10
5752     # core/base release number
5753     GST_VERSION=0.10.25
5754     PKG_CHECK_MODULES(GSTREAMER,
5755                       gstreamer-$GST_API_VERSION >= $GST_VERSION
5756                       gstreamer-app-$GST_API_VERSION
5757                       gstreamer-plugins-base-$GST_API_VERSION)
5758     if test -n "$GSTREAMER_LIBS"; then
5759        _SAVE_LDFLAGS=$LDFLAGS
5760        LDFLAGS="$LDFLAGS $GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5761        AC_TRY_LINK(,[return 0;],_HAVE_LIBGSTVIDEO=1,_HAVE_LIBGSTVIDEO=)
5762        if test -n "$_HAVE_LIBGSTVIDEO" ; then
5763           GSTREAMER_LIBS="$GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5764        else
5765           AC_MSG_ERROR([gstreamer video backend requires libgstvideo])
5766        fi
5767        LDFLAGS=$_SAVE_LDFLAGS
5768     else
5769        AC_MSG_ERROR([gstreamer backend requires the gstreamer packages])
5770     fi
5772 AC_SUBST(GSTREAMER_CFLAGS)
5773 AC_SUBST(GSTREAMER_LIBS)
5774 AC_SUBST(MOZ_GSTREAMER)
5776 if test -n "$MOZ_GSTREAMER"; then
5777    AC_DEFINE(MOZ_GSTREAMER)
5781 dnl ========================================================
5782 dnl Permissions System
5783 dnl ========================================================
5784 MOZ_ARG_DISABLE_BOOL(permissions,
5785 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5786     MOZ_PERMISSIONS=,
5787     MOZ_PERMISSIONS=1
5790 dnl ========================================================
5791 dnl NegotiateAuth
5792 dnl ========================================================
5793 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5794 [  --disable-negotiateauth Disable GSS-API negotiation ],
5795     MOZ_AUTH_EXTENSION=,
5796     MOZ_AUTH_EXTENSION=1 )
5798 dnl ========================================================
5799 dnl Pref extensions (autoconfig)
5800 dnl ========================================================
5801 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5802 [  --disable-pref-extensions
5803                           Disable pref extensions such as autoconfig],
5804   MOZ_PREF_EXTENSIONS=,
5805   MOZ_PREF_EXTENSIONS=1 )
5807 dnl ========================================================
5808 dnl Searching of system directories for extensions.
5809 dnl Note: this switch is meant to be used for test builds
5810 dnl whose behavior should not depend on what happens to be
5811 dnl installed on the local machine.
5812 dnl ========================================================
5813 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
5814 [  --disable-system-extension-dirs
5815                           Disable searching system- and account-global
5816                           directories for extensions of any kind; use
5817                           only profile-specific extension directories],
5818   ENABLE_SYSTEM_EXTENSION_DIRS=,
5819   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
5820 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
5821   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
5824 dnl ========================================================
5825 dnl = Universalchardet
5826 dnl ========================================================
5827 MOZ_ARG_DISABLE_BOOL(universalchardet,
5828 [  --disable-universalchardet
5829                           Disable universal encoding detection],
5830   MOZ_UNIVERSALCHARDET=,
5831   MOZ_UNIVERSALCHARDET=1 )
5833 if test -n "${JAVA_BIN_PATH}"; then
5834   dnl Look for javac and jar in the specified path.
5835   JAVA_PATH="$JAVA_BIN_PATH"
5836 else
5837   dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5838   JAVA_PATH="$JAVA_HOME/bin:$PATH"
5841 MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5842 MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5843 MOZ_PATH_PROG(JAVAH, javah, :, [$JAVA_PATH])
5844 MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5846 if test -n "${JAVA_BIN_PATH}" -o \
5847   \( "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk" \); then
5848   if test -z "$JAVA" -o "$JAVA" = ":" -o -z "$JAVAC" -o "$JAVAC" = ":" -o -z "$JAVAH" -o "$JAVAH" = ":" -o -z "$JAR" -o "$JAR" = ":"; then
5849     AC_MSG_ERROR([The programs java, javac, javah and jar were not found.  Set \$JAVA_HOME to your java sdk directory or use --with-java-bin-path={java-bin-dir}])
5850   fi
5853 dnl ========================================================
5854 dnl = ANGLE OpenGL->D3D translator for WebGL
5855 dnl = * only applies to win32
5856 dnl = * enabled by default (shipping build); requires explicit --disable to disable
5857 dnl ========================================================
5858 MOZ_ANGLE_RENDERER=
5859 MOZ_DIRECTX_SDK_PATH=
5860 MOZ_DIRECTX_SDK_CPU_SUFFIX=
5861 MOZ_D3DCOMPILER_CAB=
5862 MOZ_D3DCOMPILER_DLL=
5863 case "$target_os" in
5864 *mingw*)
5865     MOZ_ANGLE_RENDERER=1
5866     ;;
5867 esac
5869 # The DirectX SDK libraries are split into x86 and x64 sub-directories
5870 case "${target_cpu}" in
5871 i*86)
5872   MOZ_DIRECTX_SDK_CPU_SUFFIX=x86
5873   ;;
5874 x86_64)
5875   MOZ_DIRECTX_SDK_CPU_SUFFIX=x64
5876   ;;
5877 esac
5879 MOZ_ARG_DISABLE_BOOL(webgl,
5880 [  --disable-webgl     Disable building of the WebGL implementation],
5881     MOZ_WEBGL_DISABLED=1,
5882     MOZ_WEBGL_DISABLED=)
5884 if test -n "$MOZ_WEBGL_DISABLED"; then
5885   MOZ_WEBGL=
5886   MOZ_ANGLE_RENDERER=
5889 # Locate a DirectX SDK here so we can use it for both ANGLE and
5890 # Joystick support.
5891 if test "$OS_TARGET" = "WINNT" -a -z "$CROSS_COMPILE"; then
5892   # Get the SDK path from the registry.
5893   # First try to get the June 2010 SDK
5894   MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK (June 2010)' | head -n 1`
5895   if test -z "$MOZ_DIRECTX_SDK_REG_KEY" ; then
5896     # Otherwise just take whatever comes first
5897     MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK' | head -n 1`
5898   fi
5899   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'`
5902 if test -n "$MOZ_ANGLE_RENDERER" -a -z "$CROSS_COMPILE"; then
5903   if test -n "`echo $MOZ_DIRECTX_SDK_REG_KEY | grep 'February 2010'`" ; then
5904     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.])
5905   fi
5907   if test -n "$MOZ_DIRECTX_SDK_PATH" &&
5908      test -f "$MOZ_DIRECTX_SDK_PATH"/include/d3dx9.h &&
5909          test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5910     AC_MSG_RESULT([Found DirectX SDK via registry, using $MOZ_DIRECTX_SDK_PATH])
5911   else
5912     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.])
5913   fi
5915   # Get the SDK numeric version (e.g. 43) by looking at the dependencies of d3dx9.lib
5916   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'`
5918   if test -z "$MOZ_D3DX9_VERSION" ; then
5919         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.])
5920   fi
5922   MOZ_D3DCOMPILER_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *D3DCompiler_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
5924   if test -z "$MOZ_D3DCOMPILER_CAB"; then
5925     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.])
5926   fi
5928   MOZ_D3DCOMPILER_DLL=D3DCompiler_$MOZ_D3DX9_VERSION.dll
5931 dnl ========================================================
5932 dnl Gamepad support
5933 dnl ========================================================
5934 MOZ_GAMEPAD=
5935 MOZ_GAMEPAD_BACKEND=stub
5937 # Gamepad DOM is built on supported platforms by default.
5938 case "$OS_TARGET" in
5939      Darwin|WINNT|Linux)
5940        MOZ_GAMEPAD=1
5941        ;;
5942      *)
5943        ;;
5944 esac
5946 MOZ_ARG_DISABLE_BOOL(gamepad,
5947 [  --disable-gamepad   Disable gamepad support],
5948     MOZ_GAMEPAD=,
5949     MOZ_GAMEPAD=1)
5951 if test "$MOZ_GAMEPAD"; then
5952     case "$OS_TARGET" in
5953     Darwin)
5954         MOZ_GAMEPAD_BACKEND=cocoa
5955         ;;
5956     WINNT)
5957         if test -n "$MOZ_DIRECTX_SDK_PATH" ; then
5958             if ! test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5959                MOZ_GAMEPAD=
5960             fi
5961         elif test "$GCC" != "yes"; then
5962             MOZ_GAMEPAD=
5963         fi
5964         if test -z "$MOZ_GAMEPAD"; then
5965            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.])
5966         fi
5967         MOZ_GAMEPAD_BACKEND=windows
5968         ;;
5969     Linux)
5970         MOZ_CHECK_HEADER([linux/joystick.h])
5971         if test "$ac_cv_header_linux_joystick_h" != "yes"; then
5972           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.])
5973         fi
5974         MOZ_GAMEPAD_BACKEND=linux
5975         ;;
5976     *)
5977         ;;
5978    esac
5980   AC_DEFINE(MOZ_GAMEPAD)
5982 AC_SUBST(MOZ_GAMEPAD)
5983 AC_SUBST(MOZ_GAMEPAD_BACKEND)
5985 dnl ========================================================
5986 dnl = Breakpad crash reporting (on by default on supported platforms)
5987 dnl ========================================================
5989 case $target in
5990 i?86-*-mingw*|x86_64-*-mingw*)
5991   MOZ_CRASHREPORTER=1
5992   ;;
5993 i?86-apple-darwin*|x86_64-apple-darwin*)
5994   MOZ_CRASHREPORTER=1
5995   ;;
5996 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
5997   if test "$MOZ_ENABLE_GTK2"; then
5998     MOZ_CRASHREPORTER=1
5999   fi
6000   ;;
6001 *-android*|*-linuxandroid*)
6002   MOZ_CRASHREPORTER=1
6003   ;;
6004 *solaris*)
6005   MOZ_CRASHREPORTER=1
6006   ;;
6007 esac
6009 MOZ_ARG_DISABLE_BOOL(crashreporter,
6010 [  --disable-crashreporter Disable breakpad crash reporting],
6011     MOZ_CRASHREPORTER=,
6012     MOZ_CRASHREPORTER=1)
6014 if test -n "$MOZ_CRASHREPORTER"; then
6015    AC_DEFINE(MOZ_CRASHREPORTER)
6017   if test "$OS_TARGET" = "Linux" -o "$OS_ARCH" = "SunOS" && \
6018     test -z "$SKIP_LIBRARY_CHECKS"; then
6019     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
6020     AC_SUBST(MOZ_GTHREAD_CFLAGS)
6021     AC_SUBST(MOZ_GTHREAD_LIBS)
6022   fi
6024   if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT"; then
6025     AC_MSG_ERROR([Breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.  Use --disable-crashreporter.])
6026   fi
6028   if test "$OS_ARCH" = "WINNT"; then
6029     if test -z "$HAVE_64BIT_OS"; then
6030       MOZ_CRASHREPORTER_INJECTOR=1
6031       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
6032     fi
6033   fi
6035 AC_DEFINE_UNQUOTED(BREAKPAD_CUSTOM_STDINT_H, "mozilla/StandardInteger.h")
6037 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
6038 [  --with-crashreporter-enable-percent=NN
6039                           Enable sending crash reports by default on NN% of users. (default=100)],
6040 [ val=`echo $withval | sed 's/[^0-9]//g'`
6041     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
6043 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
6044    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
6046 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
6048 dnl ========================================================
6049 dnl = libjpeg-turbo configuration
6050 dnl ========================================================
6051 MOZ_LIBJPEG_TURBO=
6052 if test -z "$MOZ_NATIVE_JPEG"; then
6053     MOZ_LIBJPEG_TURBO=1
6056 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
6057 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
6058     MOZ_LIBJPEG_TURBO=,
6059     MOZ_LIBJPEG_TURBO=1)
6061 if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
6062     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
6065 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
6066 dnl files.
6068 if test -n "$MOZ_LIBJPEG_TURBO"; then
6070   dnl Do we support libjpeg-turbo on this platform?
6071   case "$OS_ARCH:$OS_TEST" in
6072   Darwin:i?86)
6073     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
6074     LIBJPEG_TURBO_X86_ASM=1
6075   ;;
6076   Darwin:x86_64)
6077     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
6078     LIBJPEG_TURBO_X64_ASM=1
6079   ;;
6080   WINNT:x86|WINNT:i?86)
6081     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
6082     LIBJPEG_TURBO_X86_ASM=1
6083   ;;
6084   WINNT:x86_64)
6085     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
6086     LIBJPEG_TURBO_X64_ASM=1
6087   ;;
6088   *:arm*)
6089     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
6090     LIBJPEG_TURBO_ARM_ASM=1
6091   ;;
6092   *:x86|*:i?86)
6093     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6094       LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6095       LIBJPEG_TURBO_X86_ASM=1
6096     fi
6097   ;;
6098   *:x86_64)
6099     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6100       LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6101       LIBJPEG_TURBO_X64_ASM=1
6102     fi
6103   ;;
6104   esac
6108 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
6109 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
6110 dnl it doesn't exist or we have too old of a version.
6111 if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
6112     LIBJPEG_TURBO_AS=$YASM
6114     if test -z "$LIBJPEG_TURBO_AS" ; then
6115         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.])
6116     fi
6118     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
6119     dnl on Linux and 1.1 or newer everywhere else.
6120     if test "$OS_ARCH" = "Linux" ; then
6121         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
6122             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.])
6123         fi
6124     else
6125         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
6126             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.])
6127         fi
6128     fi
6131 dnl If we're on an ARM system which supports libjpeg-turbo's asm routines and
6132 dnl --disable-libjpeg-turbo wasn't passed, use the C compiler as the assembler.
6133 if test -n "$LIBJPEG_TURBO_ARM_ASM" ; then
6134     echo "Using $AS as the assembler for ARM code."
6135     LIBJPEG_TURBO_AS=$AS
6138 if test -n "$LIBJPEG_TURBO_X86_ASM"; then
6139     AC_DEFINE(LIBJPEG_TURBO_X86_ASM)
6140 elif test -n "$LIBJPEG_TURBO_X64_ASM"; then
6141     AC_DEFINE(LIBJPEG_TURBO_X64_ASM)
6142 elif test -n "$LIBJPEG_TURBO_ARM_ASM"; then
6143     AC_DEFINE(LIBJPEG_TURBO_ARM_ASM)
6144 elif test -n "$MOZ_LIBJPEG_TURBO"; then
6145     dnl Warn if we're not building the optimized routines, even though the user
6146     dnl didn't specify --disable-libjpeg-turbo.
6147     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
6150 dnl ========================================================
6151 dnl = Enable compilation of specific extension modules
6152 dnl ========================================================
6154 MOZ_ARG_ENABLE_STRING(extensions,
6155 [  --enable-extensions     Enable extensions],
6156 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6157     if test "$option" = "yes" -o "$option" = "all"; then
6158         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
6159     elif test "$option" = "no" -o "$option" = "none"; then
6160         MOZ_EXTENSIONS=""
6161     elif test "$option" = "default"; then
6162         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
6163     elif test `echo "$option" | grep -c \^-` != 0; then
6164         option=`echo $option | sed 's/^-//'`
6165         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
6166     else
6167         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
6168     fi
6169 done],
6170     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
6172 if test -z "$MOZ_ENABLE_GNOMEVFS" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6173     # Suppress warning on non-X11 platforms
6174     if test -n "$MOZ_X11"; then
6175         AC_MSG_WARN([Removing gnomevfs from MOZ_EXTENSIONS due to no --enable-gnomevfs.])
6176     fi
6177     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6180 dnl Do not build gnomevfs with libxul based apps
6181 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6182     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6185 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6186     # Suppress warning on non-X11 platforms
6187     if test -n "$MOZ_X11"; then
6188         AC_MSG_WARN([Removing gio from MOZ_EXTENSIONS due to --disable-gio.])
6189     fi
6190     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6193 dnl Do not build gio with libxul based apps
6194 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6195     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6198 if test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6199     MOZ_GIO_COMPONENT=1
6200     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6202 AC_SUBST(MOZ_GIO_COMPONENT)
6204 if test -z "$MOZ_JSDEBUGGER" -a `echo "$MOZ_EXTENSIONS" | grep -c venkman` -ne 0; then
6205     AC_MSG_WARN([Cannot build venkman without JavaScript debug library. Removing venkman from MOZ_EXTENSIONS.])
6206     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|venkman||'`
6209 dnl Remove dupes
6210 MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
6212 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6213 dnl when trying to build a nonexistent extension.
6214 for extension in $MOZ_EXTENSIONS; do
6215     if test ! -d "${srcdir}/extensions/${extension}"; then
6216         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6217     fi
6218 done
6220 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
6221   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
6224 dnl ========================================================
6225 dnl CSS3 Flexbox Support
6226 dnl ========================================================
6227 if test -n "$MOZ_FLEXBOX"; then
6228   AC_DEFINE(MOZ_FLEXBOX)
6231 dnl ========================================================
6232 dnl Build Freetype in the tree
6233 dnl ========================================================
6234 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6235 [  --enable-tree-freetype  Enable Tree FreeType],
6236     MOZ_TREE_FREETYPE=1,
6237     MOZ_TREE_FREETYPE= )
6238 if test -n "$MOZ_TREE_FREETYPE"; then
6239    if test -n "$_WIN32_MSVC"; then
6240       AC_ERROR("building with in-tree freetype is not supported on MSVC")
6241    fi
6242    AC_DEFINE(MOZ_TREE_FREETYPE)
6243    AC_SUBST(MOZ_TREE_FREETYPE)
6244    MOZ_ENABLE_CAIRO_FT=1
6245    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6246    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6247    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6248    FT2_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6249    CAIRO_FT_OSLIBS=''
6250    CAIRO_FT_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6251    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6252    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6253    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6254    AC_SUBST(CAIRO_FT_CFLAGS)
6257 dnl ========================================================
6258 dnl Installer
6259 dnl ========================================================
6260 dnl Abort Windows build if the required major version and
6261 dnl minimum minor version of Unicode NSIS isn't in the path
6262 dnl (unless in case of cross compiling, for which Unicode
6263 dnl is not yet sufficient).
6264 if test "$OS_ARCH" = "WINNT"; then
6265     REQ_NSIS_MAJOR_VER=2
6266     MIN_NSIS_MINOR_VER=46
6267     MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensisu-2.46 makensis)
6268     if test -n "$MAKENSISU" -a "$MAKENSISU" != ":"; then
6269       AC_MSG_RESULT([yes])
6270       changequote(,)
6271       MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\).*\-Unicode$/\1/g'`
6272       changequote([,])
6273       if test ! "$MAKENSISU_VER" = ""; then
6274           MAKENSISU_MAJOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $1 }'`
6275           MAKENSISU_MINOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $2 }'`
6276       fi
6277       AC_MSG_CHECKING([for Unicode NSIS with major version == $REQ_NSIS_MAJOR_VER and minor version >= $MIN_NSIS_MINOR_VER])
6278       if test "$MAKENSISU_VER" = "" || \
6279          test ! "$MAKENSISU_MAJOR_VER" = "$REQ_NSIS_MAJOR_VER" -o \
6280               ! "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER; then
6281           AC_MSG_RESULT([no])
6282           if test -z "$CROSS_COMPILE"; then
6283             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.])
6284           else
6285             MAKENSISU=
6286           fi
6287       fi
6288     elif test -z "$CROSS_COMPILE"; then
6289       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.])
6290     else
6291       MAKENSISU=
6292     fi
6295 dnl ========================================================
6296 dnl Web App Runtime
6297 dnl ========================================================
6298 MOZ_ARG_DISABLE_BOOL(webapp-runtime,
6299 [  --disable-webapp-runtime  Disable Web App Runtime],
6300     MOZ_WEBAPP_RUNTIME=,
6301     MOZ_WEBAPP_RUNTIME=1)
6302 if test "$MOZ_WIDGET_TOOLKIT" != "windows" -a "$MOZ_WIDGET_TOOLKIT" != "cocoa" -a "$MOZ_WIDGET_TOOLKIT" != "gtk2"; then
6303     MOZ_WEBAPP_RUNTIME=
6305 if test "$OS_ARCH" = "WINNT" -a -z "$MAKENSISU" -a -n "$CROSS_COMPILE"; then
6306     MOZ_WEBAPP_RUNTIME=
6308 AC_SUBST(MOZ_WEBAPP_RUNTIME)
6309 if test "$MOZ_WEBAPP_RUNTIME"; then
6310     AC_DEFINE(MOZ_WEBAPP_RUNTIME)
6313 AC_MSG_CHECKING([for tar archiver])
6314 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6315 if test -z "$TAR"; then
6316     AC_MSG_ERROR([no tar archiver found in \$PATH])
6318 AC_MSG_RESULT([$TAR])
6319 AC_SUBST(TAR)
6321 AC_MSG_CHECKING([for wget])
6322 AC_CHECK_PROGS(WGET, wget, "")
6323 AC_MSG_RESULT([$WGET])
6324 AC_SUBST(WGET)
6326 dnl ========================================================
6327 dnl Signing
6328 dnl ========================================================
6330 if test -n "$MOZ_SIGN_CMD"; then
6331     AC_DEFINE(MOZ_SIGNING)
6334 dnl ========================================================
6335 dnl Maintenance Service
6336 dnl ========================================================
6338 MOZ_ARG_ENABLE_BOOL(maintenance-service,
6339 [  --enable-maintenance-service       Enable building of maintenanceservice],
6340     MOZ_MAINTENANCE_SERVICE=1,
6341     MOZ_MAINTENANCE_SERVICE= )
6343 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
6344   if test "$OS_ARCH" = "WINNT"; then
6345     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
6346   else
6347     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
6348   fi
6351 dnl ========================================================
6352 dnl Verify MAR signatures
6353 dnl ========================================================
6355 MOZ_ARG_ENABLE_BOOL(verify-mar,
6356 [  --enable-verify-mar     Enable verifying MAR signatures],
6357     MOZ_VERIFY_MAR_SIGNATURE=1,
6358     MOZ_VERIFY_MAR_SIGNATURE= )
6360 if test -n "$MOZ_VERIFY_MAR_SIGNATURE"; then
6361   if test "$OS_ARCH" = "WINNT"; then
6362     AC_DEFINE(MOZ_VERIFY_MAR_SIGNATURE)
6363   else
6364     AC_MSG_ERROR([Can only build with --enable-verify-mar with a Windows target])
6365   fi
6368 dnl ========================================================
6369 dnl Enable building the signmar program.
6370 dnl This option is much different than the --enable-verify-mar option.
6371 dnl --enable-verify-mar is for enabling the verification check on MAR
6372 dnl files in the updater.  The --enable-signmar option is for building
6373 dnl the signmar program.
6374 dnl ========================================================
6376 MOZ_ARG_ENABLE_BOOL(signmar,
6377 [  --enable-signmar     Enable building the signmar program],
6378     MOZ_ENABLE_SIGNMAR=1,
6379     MOZ_ENABLE_SIGNMAR= )
6381 if test -n "$MOZ_ENABLE_SIGNMAR"; then
6382   AC_DEFINE(MOZ_ENABLE_SIGNMAR)
6385 dnl ========================================================
6386 dnl Updater
6387 dnl ========================================================
6389 MOZ_ARG_DISABLE_BOOL(updater,
6390 [  --disable-updater       Disable building of updater],
6391     MOZ_UPDATER=,
6392     MOZ_UPDATER=1 )
6394 if test -n "$MOZ_UPDATER"; then
6395     AC_DEFINE(MOZ_UPDATER)
6398 # tools/update-packaging is not checked out by default.
6399 MOZ_ARG_ENABLE_BOOL(update-packaging,
6400 [  --enable-update-packaging
6401                           Enable tools/update-packaging],
6402     MOZ_UPDATE_PACKAGING=1,
6403     MOZ_UPDATE_PACKAGING= )
6404 AC_SUBST(MOZ_UPDATE_PACKAGING)
6406 dnl ========================================================
6407 dnl build the tests by default
6408 dnl ========================================================
6409 MOZ_ARG_DISABLE_BOOL(tests,
6410 [  --disable-tests         Do not build test libraries & programs],
6411     ENABLE_TESTS=,
6412     ENABLE_TESTS=1 )
6414 # Currently GTest is linked into libxul. This means it must be off by default.
6415 # Follow up will be to generate libxul.so and libxul-test.so to let GTest
6416 # be compiled along with ENABLE_TESTS
6417 MOZ_ARG_ENABLE_BOOL(gtest,
6418 [  --enable-gtest
6419                           Enable GTest libxul unit test.],
6420     MOZ_ENABLE_GTEST=1,
6421     MOZ_ENABLE_GTEST= )
6423 if test -n "$MOZ_ENABLE_GTEST"; then
6424     if test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "Linux" -o "${OS_TARGET}" = "Android"; then
6425         MOZ_ENABLE_GTEST=1
6426         GTEST_HAS_RTTI=0
6427         AC_DEFINE(MOZ_ENABLE_GTEST)
6428         AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0)
6429         AC_SUBST(MOZ_ENABLE_GTEST)
6430         AC_SUBST(GTEST_HAS_RTTI)
6431     else
6432         AC_MSG_ERROR([Cannot build with --enable-gtest on this platform.])
6433     fi
6434     if test "${OS_TARGET}" = "Android"; then
6435         AC_DEFINE(GTEST_OS_LINUX_ANDROID)
6436         AC_DEFINE(GTEST_USE_OWN_TR1_TUPLE)
6437         AC_DEFINE_UNQUOTED(GTEST_HAS_CLONE, 0)
6438         AC_SUBST(GTEST_OS_LINUX_ANDROID)
6439         AC_SUBST(GTEST_USE_OWN_TR1_TUPLE)
6440         AC_SUBST(GTEST_HAS_CLONE)
6441     fi
6444 dnl ========================================================
6445 dnl parental controls (for Windows Vista)
6446 dnl ========================================================
6447 MOZ_ARG_DISABLE_BOOL(parental-controls,
6448 [  --disable-parental-controls
6449                           Do not build parental controls],
6450    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6451    MOZ_DISABLE_PARENTAL_CONTROLS=)
6452 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6453     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6456 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6458 dnl ========================================================
6459 dnl = Disable DOMCrypto
6460 dnl ========================================================
6461 if test -n "$MOZ_DISABLE_CRYPTOLEGACY"; then
6462     AC_DEFINE(MOZ_DISABLE_CRYPTOLEGACY)
6464 AC_SUBST(MOZ_DISABLE_CRYPTOLEGACY)
6466 dnl ========================================================
6467 dnl = Disable libpkix
6468 dnl ========================================================
6469 if test -n "$NSS_NO_LIBPKIX"; then
6470     AC_DEFINE(NSS_NO_LIBPKIX)
6472 AC_SUBST(NSS_NO_LIBPKIX)
6475 dnl ========================================================
6476 dnl =
6477 dnl = Module specific options
6478 dnl =
6479 dnl ========================================================
6480 MOZ_ARG_HEADER(Individual module options)
6482 dnl ========================================================
6483 dnl = Disable feed handling components
6484 dnl ========================================================
6485 MOZ_ARG_DISABLE_BOOL(feeds,
6486 [  --disable-feeds         Disable feed handling and processing components],
6487     MOZ_FEEDS=,
6488     MOZ_FEEDS=1 )
6489 if test -n "$MOZ_FEEDS"; then
6490     AC_DEFINE(MOZ_FEEDS)
6491 else
6492     if test "$MOZ_BUILD_APP" = "browser"; then
6493         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6494     fi
6497 dnl ========================================================
6498 dnl Check for sqlite
6499 dnl ========================================================
6501 MOZ_NATIVE_SQLITE=
6502 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6503 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6504 MOZ_NATIVE_SQLITE=1,
6505 MOZ_NATIVE_SQLITE= )
6507 if test -z "$MOZ_NATIVE_SQLITE"
6508 then
6509     SQLITE_CFLAGS=
6510     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
6511 else
6512     dnl ============================
6513     dnl === SQLite Version check ===
6514     dnl ============================
6515     dnl Check to see if the system SQLite package is new enough.
6516     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6518     dnl ==================================
6519     dnl === SQLITE_SECURE_DELETE check ===
6520     dnl ==================================
6521     dnl Check to see if the system SQLite package is compiled with
6522     dnl SQLITE_SECURE_DELETE enabled.
6523     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
6524     _SAVE_CFLAGS="$CFLAGS"
6525     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6526     _SAVE_LIBS="$LIBS"
6527     LIBS="$LIBS $SQLITE_LIBS"
6528     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6529         AC_TRY_RUN([
6530             #include "sqlite3.h"
6532             int main(int argc, char **argv){
6533               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
6534             }],
6535             ac_cv_sqlite_secure_delete=yes,
6536             ac_cv_sqlite_secure_delete=no,
6537             ac_cv_sqlite_secure_delete=no
6538         )
6539     ])
6540     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6541     CFLAGS="$_SAVE_CFLAGS"
6542     LIBS="$_SAVE_LIBS"
6543     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6544         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
6545     fi
6547     dnl ===============================
6548     dnl === SQLITE_THREADSAFE check ===
6549     dnl ===============================
6550     dnl Check to see if the system SQLite package is compiled with
6551     dnl SQLITE_THREADSAFE enabled.
6552     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
6553     _SAVE_CFLAGS="$CFLAGS"
6554     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6555     _SAVE_LIBS="$LIBS"
6556     LIBS="$LIBS $SQLITE_LIBS"
6557     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
6558         AC_TRY_RUN([
6559             #include "sqlite3.h"
6561             int main(int argc, char **argv){
6562               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
6563             }],
6564             ac_cv_sqlite_threadsafe=yes,
6565             ac_cv_sqlite_threadsafe=no,
6566             ac_cv_sqlite_threadsafe=no
6567         )
6568     ])
6569     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
6570     CFLAGS="$_SAVE_CFLAGS"
6571     LIBS="$_SAVE_LIBS"
6572     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
6573         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
6574     fi
6576     dnl ================================
6577     dnl === SQLITE_ENABLE_FTS3 check ===
6578     dnl ================================
6579     dnl check to see if the system SQLite package is compiled with
6580     dnl SQLITE_ENABLE_FTS3 enabled.
6581     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
6582     _SAVE_CFLAGS="$CFLAGS"
6583     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6584     _SAVE_LIBS="$LIBS"
6585     LIBS="$LIBS $SQLITE_LIBS"
6586     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
6587         AC_TRY_RUN([
6588             #include "sqlite3.h"
6590             int main(int argc, char **argv){
6591               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
6592             }],
6593             ac_cv_sqlite_enable_fts3=yes,
6594             ac_cv_sqlite_enable_fts3=no,
6595             ac_cv_sqlite_enable_fts3=no
6596         )
6597     ])
6598     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
6599     CFLAGS="$_SAVE_CFLAGS"
6600     LIBS="$_SAVE_LIBS"
6601     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
6602         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
6603     fi
6605     dnl =========================================
6606     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
6607     dnl =========================================
6608     dnl check to see if the system SQLite package is compiled with
6609     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
6610     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
6611     _SAVE_CFLAGS="$CFLAGS"
6612     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6613     _SAVE_LIBS="$LIBS"
6614     LIBS="$LIBS $SQLITE_LIBS"
6615     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
6616         AC_TRY_RUN([
6617             #include "sqlite3.h"
6619             int main(int argc, char **argv){
6620               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
6621             }],
6622             ac_cv_sqlite_enable_unlock_notify=yes,
6623             ac_cv_sqlite_enable_unlock_notify=no,
6624             ac_cv_sqlite_enable_unlock_notify=no
6625         )
6626     ])
6627     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
6628     CFLAGS="$_SAVE_CFLAGS"
6629     LIBS="$_SAVE_LIBS"
6630     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
6631         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
6632     fi
6635 if test -n "$MOZ_NATIVE_SQLITE"; then
6636     AC_DEFINE(MOZ_NATIVE_SQLITE)
6638 AC_SUBST(MOZ_NATIVE_SQLITE)
6640 dnl ========================================================
6641 dnl = Enable help viewer (off by default)
6642 dnl ========================================================
6643 if test -n "$MOZ_HELP_VIEWER"; then
6644      dnl Do this if defined in confvars.sh
6645      AC_DEFINE(MOZ_HELP_VIEWER)
6648 dnl ========================================================
6649 dnl = Enable safe browsing (anti-phishing)
6650 dnl ========================================================
6651 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6652 [  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation],
6653     MOZ_SAFE_BROWSING=1,
6654     MOZ_SAFE_BROWSING= )
6655 if test -n "$MOZ_SAFE_BROWSING"; then
6656     AC_DEFINE(MOZ_SAFE_BROWSING)
6658 AC_SUBST(MOZ_SAFE_BROWSING)
6660 dnl ========================================================
6661 dnl = Enable url-classifier
6662 dnl ========================================================
6663 dnl Implicitly enabled by default if building with safe-browsing
6664 if test -n "$MOZ_SAFE_BROWSING"; then
6665     MOZ_URL_CLASSIFIER=1
6667 MOZ_ARG_ENABLE_BOOL(url-classifier,
6668 [  --enable-url-classifier Enable url classifier module],
6669     MOZ_URL_CLASSIFIER=1,
6670     MOZ_URL_CLASSIFIER= )
6671 if test -n "$MOZ_URL_CLASSIFIER"; then
6672     AC_DEFINE(MOZ_URL_CLASSIFIER)
6674 AC_SUBST(MOZ_URL_CLASSIFIER)
6676 dnl ========================================================
6677 dnl = Disable zipwriter
6678 dnl ========================================================
6679 MOZ_ARG_DISABLE_BOOL(zipwriter,
6680 [  --disable-zipwriter     Disable zipwriter component],
6681     MOZ_ZIPWRITER=,
6682     MOZ_ZIPWRITER=1 )
6683 AC_SUBST(MOZ_ZIPWRITER)
6685 dnl ========================================================
6686 dnl = libconic
6687 dnl ========================================================
6688 dnl superseded by QtNetwork starting from 4.7
6689 MOZ_ENABLE_LIBCONIC=1
6691 if test -n "$MOZ_ENABLE_QT"; then
6692   if test "$MOZ_ENABLE_QTNETWORK"; then
6693     MOZ_ENABLE_LIBCONIC=
6694   fi
6697 MOZ_ARG_DISABLE_BOOL(libconic,
6698 [  --disable-libconic      Disable libconic],
6699     MOZ_ENABLE_LIBCONIC=,
6700     MOZ_ENABLE_LIBCONIC=1 )
6702 if test -n "$MOZ_ENABLE_LIBCONIC"; then
6703     PKG_CHECK_MODULES(LIBCONIC, conic,
6704                       MOZ_ENABLE_LIBCONIC=1,
6705                       MOZ_ENABLE_LIBCONIC=)
6707 if test "$MOZ_ENABLE_LIBCONIC"; then
6708     AC_DEFINE(MOZ_ENABLE_LIBCONIC)
6711 AC_SUBST(MOZ_ENABLE_LIBCONIC)
6712 AC_SUBST(LIBCONIC_CFLAGS)
6713 AC_SUBST(LIBCONIC_LIBS)
6715 dnl ========================================================
6716 dnl = Maemo checks
6717 dnl ========================================================
6719 MAEMO_SDK_TARGET_VER=-1
6721 MOZ_ARG_WITH_STRING(maemo-version,
6722 [  --with-maemo-version=MAEMO_SDK_TARGET_VER
6723                           Maemo SDK Version],
6724   MAEMO_SDK_TARGET_VER=$withval)
6726 case "$MAEMO_SDK_TARGET_VER" in
6728     MOZ_PLATFORM_MAEMO=5
6729     ;;
6732     MOZ_PLATFORM_MAEMO=6
6733     ;;
6736     dnl We aren't compiling for Maemo, move on.
6737     ;;
6739     AC_MSG_ERROR([Unknown Maemo Version.  Try setting --with-maemo-version to 5 or 6.])
6740     ;;
6741 esac
6743 if test $MOZ_PLATFORM_MAEMO; then
6744    AC_DEFINE_UNQUOTED([MOZ_PLATFORM_MAEMO], $MOZ_PLATFORM_MAEMO)
6746    if test -z "$MOZ_ENABLE_DBUS"; then
6747        AC_MSG_ERROR([DBus is required when building for Maemo])
6748    fi
6750    MOZ_GFX_OPTIMIZE_MOBILE=1
6751    MOZ_GL_DEFAULT_PROVIDER=EGL
6752    MOZ_MAEMO_LIBLOCATION=
6754    if test $MOZ_PLATFORM_MAEMO = 5; then
6755       dnl if we have Xcomposite we should also have Xdamage and Xfixes
6756       MOZ_CHECK_HEADERS([X11/extensions/Xdamage.h], [],
6757           [AC_MSG_ERROR([Couldn't find X11/extensions/Xdamage.h which is required for composited plugins.])])
6758       AC_CHECK_LIB(Xcomposite, XCompositeRedirectWindow, [XCOMPOSITE_LIBS="-lXcomposite -lXdamage -lXfixes"],
6759                    [MISSING_X="$MISSING_X -lXcomposite"], $XLIBS)
6761       AC_SUBST(XCOMPOSITE_LIBS)
6763       PKG_CHECK_MODULES(LIBHILDONMIME,libhildonmime, _LIB_FOUND=1, _LIB_FOUND=)
6764       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONMIME_LIBS"
6765       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONMIME_CFLAGS"
6766       if test -z "$_LIB_FOUND"; then
6767          AC_MSG_ERROR([Hildon Mime is required when building for Maemo])
6768       fi
6771       PKG_CHECK_MODULES(LIBOSSO,libosso, _LIB_FOUND=1, _LIB_FOUND=)
6772       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBOSSO_LIBS"
6773       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBOSSO_CFLAGS"
6774       if test -z "$_LIB_FOUND"; then
6775          AC_MSG_ERROR([LibOSSO is required when building for Maemo])
6776       fi
6778       PKG_CHECK_MODULES(LIBHILDONFM,hildon-fm-2, _LIB_FOUND=1, _LIB_FOUND=)
6779       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONFM_LIBS"
6780       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONFM_CFLAGS"
6781       if test -z "$_LIB_FOUND"; then
6782          AC_MSG_ERROR([Hildon FM-2 is required when building for Maemo])
6783       fi
6785    fi
6786    if test $MOZ_PLATFORM_MAEMO = 6; then
6788       PKG_CHECK_MODULES(LIBCONTENTMANAGER, ContentManager QtSparql,
6789                         _LIB_FOUND=1,
6790                         _LIB_FOUND=)
6791       if test "$_LIB_FOUND"; then
6792          MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTMANAGER_LIBS"
6793          MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTMANAGER_CFLAGS"
6794          MOZ_ENABLE_CONTENTMANAGER=1
6795          AC_DEFINE(MOZ_ENABLE_CONTENTMANAGER)
6796       else
6797          AC_MSG_WARN([Cannot find libcontentmanager and or QtSparql building for Maemo 6])
6798       fi
6799       AC_SUBST(MOZ_ENABLE_CONTENTMANAGER)
6801       dnl ========================================================
6802       dnl = Enable meego libcontentaction
6803       dnl ========================================================
6804       MOZ_ARG_ENABLE_BOOL(meegocontentaction,
6805       [  --enable-meegocontentaction           Enable meegocontentaction support],
6806          MOZ_MEEGOCONTENTACTION=1,
6807          MOZ_MEEGOCONTENTACTION=)
6809       if test -n "$MOZ_MEEGOCONTENTACTION"; then
6811          PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
6812          if test "$_LIB_FOUND"; then
6813             MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTACTION_LIBS"
6814             MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTACTION_CFLAGS"
6815             MOZ_ENABLE_CONTENTACTION=1
6816             AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
6817             AC_SUBST(MOZ_ENABLE_CONTENTACTION)
6818          fi
6819       fi
6821       MOZ_ARG_ENABLE_BOOL(meegotouch,
6822       [  --enable-meegotouch  Enable meegotouch support],
6823          MOZ_MEEGOTOUCHENABLED=1,
6824          MOZ_MEEGOTOUCHENABLED=)
6826       if test -n "$MOZ_MEEGOTOUCHENABLED"; then
6827           PKG_CHECK_MODULES(MOZ_MEEGOTOUCH, meegotouchcore, _LIB_FOUND=1, _LIB_FOUND=)
6828           if test "$_LIB_FOUND"; then
6829               MOZ_QT_CFLAGS="$MOZ_MEEGOTOUCH_CFLAGS $MOZ_QT_CFLAGS"
6830               MOZ_QT_LIBS="$MOZ_MEEGOTOUCH_LIBS $MOZ_QT_LIBS"
6831               AC_DEFINE(MOZ_ENABLE_MEEGOTOUCH)
6832           else
6833               AC_MSG_WARN([Cannot meegotouchcore-dev. Disabling Meegotouch support.])
6834           fi
6835       fi
6836    fi
6838    PKG_CHECK_MODULES(LIBLOCATION,liblocation, _LIB_FOUND=1, _LIB_FOUND=)
6839    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBLOCATION_LIBS"
6840    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBLOCATION_CFLAGS"
6841    if test "$_LIB_FOUND"; then
6842       MOZ_MAEMO_LIBLOCATION=1
6843       AC_DEFINE(MOZ_MAEMO_LIBLOCATION)
6844    else
6845       AC_MSG_WARN([Cannot liblocation-dev. Disabling Maemo geolocation.])
6846    fi
6847    AC_SUBST(MOZ_MAEMO_LIBLOCATION)
6849    PKG_CHECK_MODULES(LIBMEEGOTOUCHSHARE, ShareUiInterface-maemo-meegotouch >= 0.3.31 mdatauri, _LIB_FOUND=1, _LIB_FOUND=)
6850    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBMEEGOTOUCHSHARE_LIBS"
6851    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBMEEGOTOUCHSHARE_CFLAGS"
6852    if test "$_LIB_FOUND"; then
6853       MOZ_ENABLE_MEEGOTOUCHSHARE=1
6854       AC_DEFINE(MOZ_ENABLE_MEEGOTOUCHSHARE)
6855    else
6856       AC_MSG_WARN([Cannot find maemo-meegotouch-interfaces-dev or libmdatauri-dev. Disabling meegotouch share ui.])
6857    fi
6858    AC_SUBST(MOZ_ENABLE_MEEGOTOUCHSHARE)
6860    AC_SUBST(MOZ_PLATFORM_MAEMO_LIBS)
6861    AC_SUBST(MOZ_PLATFORM_MAEMO_CFLAGS)
6864 dnl ========================================================
6865 dnl GL provider
6866 dnl ========================================================
6867 MOZ_GL_PROVIDER=
6868 MOZ_ARG_WITH_STRING(gl-provider,
6869 [  --with-gl-provider=ID
6870                           Set GL provider backend type],
6871 [ val=`echo $withval`
6872     MOZ_GL_PROVIDER="$val"])
6874 if test -n "$MOZ_GL_PROVIDER"; then
6875 MOZ_GL_DEFAULT_PROVIDER=$MOZ_GL_PROVIDER
6876 AC_SUBST(MOZ_GL_PROVIDER)
6877 AC_DEFINE_UNQUOTED(MOZ_GL_PROVIDER, GLContextProvider$MOZ_GL_PROVIDER)
6879 AC_SUBST(MOZ_GL_DEFAULT_PROVIDER)
6880 AC_DEFINE_UNQUOTED(GL_PROVIDER_$MOZ_GL_DEFAULT_PROVIDER)
6882 dnl ========================================================
6883 dnl = faststripe theme
6884 dnl ========================================================
6885 MOZ_ARG_ENABLE_BOOL(faststripe,
6886 [  --enable-faststripe     Use faststripe theme],
6887     MOZ_THEME_FASTSTRIPE=1,
6888     MOZ_THEME_FASTSTRIPE= )
6889 AC_SUBST(MOZ_THEME_FASTSTRIPE)
6891 dnl ========================================================
6892 dnl =
6893 dnl = Feature options that require extra sources to be pulled
6894 dnl =
6895 dnl ========================================================
6896 dnl MOZ_ARG_HEADER(Features that require extra sources)
6898 dnl ========================================================
6899 dnl =
6900 dnl = Debugging Options
6901 dnl =
6902 dnl ========================================================
6903 MOZ_ARG_HEADER(Debugging and Optimizations)
6905 dnl ========================================================
6906 dnl = Disable building with debug info.
6907 dnl = Debugging is OFF by default
6908 dnl ========================================================
6909 if test -z "$MOZ_DEBUG_FLAGS"; then
6910   MOZ_DEBUG_FLAGS="-g"
6913 MOZ_ARG_ENABLE_STRING(debug,
6914 [  --enable-debug[=DBG]    Enable building with developer debug info
6915                            (using compiler flags DBG)],
6916 [ if test "$enableval" != "no"; then
6917     MOZ_DEBUG=1
6918     if test -n "$enableval" -a "$enableval" != "yes"; then
6919         MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6920         _MOZ_DEBUG_FLAGS_SET=1
6921     fi
6922   else
6923     MOZ_DEBUG=
6924   fi ],
6925   MOZ_DEBUG=)
6927 MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG -DTRACING"
6928 MOZ_ARG_WITH_STRING(debug-label,
6929 [  --with-debug-label=LABELS
6930                           Define DEBUG_<value> for each comma-separated
6931                           value given.],
6932 [ for option in `echo $withval | sed 's/,/ /g'`; do
6933     MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${option}"
6934 done])
6936 MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
6938 if test -n "$MOZ_DEBUG"; then
6939     AC_MSG_CHECKING([for valid debug flags])
6940     _SAVE_CFLAGS=$CFLAGS
6941     CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS"
6942     AC_TRY_COMPILE([#include <stdio.h>],
6943         [printf("Hello World\n");],
6944         _results=yes,
6945         _results=no)
6946     AC_MSG_RESULT([$_results])
6947     if test "$_results" = "no"; then
6948         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_DEBUG_FLAGS])
6949     fi
6950     CFLAGS=$_SAVE_CFLAGS
6953 dnl ========================================================
6954 dnl enable mobile optimizations
6955 dnl ========================================================
6956 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
6957 [  --enable-mobile-optimize
6958                           Enable mobile optimizations],
6959     MOZ_GFX_OPTIMIZE_MOBILE=1)
6961 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
6963 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
6964     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
6967 dnl ========================================================
6968 dnl = Enable code optimization. ON by default.
6969 dnl ========================================================
6970 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
6971         MOZ_OPTIMIZE_FLAGS="-O"
6974 MOZ_ARG_ENABLE_STRING(optimize,
6975 [  --disable-optimize      Disable compiler optimization
6976   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
6977 [ if test "$enableval" != "no"; then
6978     MOZ_OPTIMIZE=1
6979     if test -n "$enableval" -a "$enableval" != "yes"; then
6980         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
6981         MOZ_OPTIMIZE=2
6982     fi
6983 else
6984     MOZ_OPTIMIZE=
6985 fi ], MOZ_OPTIMIZE=1)
6987 MOZ_SET_FRAMEPTR_FLAGS
6989 if test "$COMPILE_ENVIRONMENT"; then
6990 if test -n "$MOZ_OPTIMIZE"; then
6991     AC_MSG_CHECKING([for valid optimization flags])
6992     _SAVE_CFLAGS=$CFLAGS
6993     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
6994     AC_TRY_COMPILE([#include <stdio.h>],
6995         [printf("Hello World\n");],
6996         _results=yes,
6997         _results=no)
6998     AC_MSG_RESULT([$_results])
6999     if test "$_results" = "no"; then
7000         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
7001     fi
7002     CFLAGS=$_SAVE_CFLAGS
7004 fi # COMPILE_ENVIRONMENT
7006 AC_SUBST(MOZ_OPTIMIZE)
7007 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
7008 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
7009 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
7010 AC_SUBST(MOZ_ALLOW_HEAP_EXECUTE_FLAGS)
7011 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
7012 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
7014 dnl ========================================================
7015 dnl = Enable generation of debug symbols
7016 dnl ========================================================
7017 MOZ_ARG_ENABLE_STRING(debug-symbols,
7018 [  --enable-debug-symbols[=DBG]
7019                           Enable debugging symbols (using compiler flags DBG)],
7020 [ if test "$enableval" != "no"; then
7021       MOZ_DEBUG_SYMBOLS=1
7022       if test -n "$enableval" -a "$enableval" != "yes"; then
7023           if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
7024               MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
7025           else
7026               AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
7027           fi
7028       fi
7029   else
7030       MOZ_DEBUG_SYMBOLS=
7031   fi ],
7032   MOZ_DEBUG_SYMBOLS=1)
7034 if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
7035     AC_DEFINE(MOZ_DEBUG_SYMBOLS)
7036     export MOZ_DEBUG_SYMBOLS
7039 dnl ========================================================
7040 dnl = Enable any treating of compile warnings as errors
7041 dnl ========================================================
7042 MOZ_ARG_ENABLE_BOOL(warnings-as-errors,
7043 [  --enable-warnings-as-errors
7044                           Enable treating of warnings as errors],
7045     MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
7046     MOZ_ENABLE_WARNINGS_AS_ERRORS=)
7047 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
7048    WARNINGS_AS_ERRORS=''
7051 dnl ========================================================
7052 dnl = Disable runtime logging checks
7053 dnl ========================================================
7054 MOZ_ARG_DISABLE_BOOL(logging,
7055 [  --disable-logging       Disable logging facilities],
7056     NS_DISABLE_LOGGING=1,
7057     NS_DISABLE_LOGGING= )
7058 if test "$NS_DISABLE_LOGGING"; then
7059     AC_DEFINE(NS_DISABLE_LOGGING)
7060 else
7061     AC_DEFINE(MOZ_LOGGING)
7064 dnl ========================================================
7065 dnl = This will enable logging of addref, release, ctor, dtor.
7066 dnl ========================================================
7067 _ENABLE_LOGREFCNT=42
7068 MOZ_ARG_ENABLE_BOOL(logrefcnt,
7069 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
7070     _ENABLE_LOGREFCNT=1,
7071     _ENABLE_LOGREFCNT= )
7072 if test "$_ENABLE_LOGREFCNT" = "1"; then
7073     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
7074 elif test -z "$_ENABLE_LOGREFCNT"; then
7075     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
7078 dnl ========================================================
7079 dnl moz_dump_painting
7080 dnl ========================================================
7081 MOZ_ARG_ENABLE_BOOL(dump-painting,
7082 [  --enable-dump-painting          Enable paint debugging.],
7083     MOZ_DUMP_PAINTING=1,
7084     MOZ_DUMP_PAINTING= )
7085 if test -n "$MOZ_DUMP_PAINTING"; then
7086     AC_DEFINE(MOZ_DUMP_PAINTING)
7087     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
7089 if test -n "$MOZ_DEBUG"; then
7090     AC_DEFINE(MOZ_DUMP_PAINTING)
7093 dnl ========================================================
7094 dnl = Enable trace malloc
7095 dnl ========================================================
7096 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
7097 MOZ_ARG_ENABLE_BOOL(trace-malloc,
7098 [  --enable-trace-malloc   Enable malloc tracing; also disables DMD and jemalloc],
7099     NS_TRACE_MALLOC=1,
7100     NS_TRACE_MALLOC= )
7101 if test "$NS_TRACE_MALLOC"; then
7102   # Please, Mr. Linker Man, don't take away our symbol names
7103   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
7104   USE_ELF_DYNSTR_GC=
7105   AC_DEFINE(NS_TRACE_MALLOC)
7107 AC_SUBST(NS_TRACE_MALLOC)
7109 dnl ========================================================
7110 dnl = Enable DMD
7111 dnl ========================================================
7113 MOZ_ARG_ENABLE_BOOL(dmd,
7114 [  --enable-dmd            Enable DMD; also enables jemalloc and replace-malloc],
7115     MOZ_DMD=1,
7116     MOZ_DMD= )
7118 if test "$NS_TRACE_MALLOC"; then        # trace-malloc disables DMD
7119     MOZ_DMD=
7121 if test "$MOZ_DMD"; then
7122     USE_ELF_DYNSTR_GC=
7123     AC_DEFINE(MOZ_DMD)
7125     if test "${CPU_ARCH}" = "arm"; then
7126         CFLAGS="$CFLAGS -funwind-tables"
7127         CXXFLAGS="$CXXFLAGS -funwind-tables"
7128     fi
7130     MOZ_MEMORY=1                        # DMD enables jemalloc
7131     MOZ_REPLACE_MALLOC=1                # DMD enables replace-malloc
7133 AC_SUBST(MOZ_DMD)
7135 dnl ========================================================
7136 dnl = Enable jemalloc
7137 dnl ========================================================
7138 MOZ_ARG_ENABLE_BOOL(jemalloc,
7139 [  --enable-jemalloc       Replace memory allocator with jemalloc],
7140     MOZ_MEMORY=1,
7141     MOZ_MEMORY=)
7143 if test "$NS_TRACE_MALLOC"; then
7144     MOZ_MEMORY=
7147 if test "${OS_TARGET}" = "Android"; then
7148   dnl On Android, we use WRAP_LDFLAGS to link everything to mozglue
7149   :
7150 elif test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "OS2"; then
7151   dnl On Windows, OSX and OS2, we want to link all our binaries against mozglue
7152   if test -z "$GNU_CC"; then
7153     MOZ_GLUE_LDFLAGS='$(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
7154   else
7155     MOZ_GLUE_LDFLAGS='-L$(LIBXUL_DIST)/lib $(call EXPAND_LIBNAME,mozglue)'
7156   fi
7157 else
7158   dnl On other Unix systems, we only want to link executables against mozglue
7159   MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
7160   dnl On other Unix systems, where mozglue is a static library, jemalloc is
7161   dnl separated for the SDK, so we need to add it here.
7162   if test "$MOZ_MEMORY" = 1 -o \( "$LIBXUL_SDK" -a -f "$LIBXUL_SDK/lib/${LIB_PREFIX}memory.${LIB_SUFFIX}" \); then
7163     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib)'
7164   fi
7165   MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(MKSHLIB_UNFORCE_ALL)'
7166   if test -n "$GNU_CC"; then
7167     dnl And we need mozglue symbols to be exported.
7168     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
7169   fi
7170   if test "$MOZ_LINKER" = 1; then
7171     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS $MOZ_ZLIB_LIBS"
7172   fi
7175 dnl ========================================================
7176 dnl = Enable dynamic replacement of malloc implementation
7177 dnl ========================================================
7178 MOZ_ARG_ENABLE_BOOL(replace-malloc,
7179 [  --enable-replace-malloc   Enable ability to dynamically replace the malloc implementation],
7180     MOZ_REPLACE_MALLOC=1,
7181     MOZ_REPLACE_MALLOC= )
7183 if test -n "$MOZ_REPLACE_MALLOC" -a -z "$MOZ_MEMORY"; then
7184     dnl We don't want to enable jemalloc unconditionally because it may be a
7185     dnl deliberate choice not to enable it (bug 702250, for instance)
7186     AC_MSG_ERROR([--enable-replace-malloc requires --enable-jemalloc])
7187 elif test -n "$MOZ_REPLACE_MALLOC"; then
7188     MOZ_NATIVE_JEMALLOC=
7190     dnl Replace-malloc Mac linkage quirks
7191     if test -n "$MACOSX_DEPLOYMENT_TARGET"; then
7192         AC_CACHE_CHECK([how to do weak dynamic linking],
7193             ac_cv_weak_dynamic_linking,
7194             [echo 'extern void foo() __attribute__((weak_import));int bar() { if (foo) foo(); return 0; }' > conftest.c
7195              if AC_TRY_COMMAND([${CC-cc} -o conftest${DLL_SUFFIX} $CFLAGS -dynamiclib $LDFLAGS -Wl,-U,_foo conftest.c $LIBS 1>&5]) &&
7196                 test -s conftest${DLL_SUFFIX}; then
7197                  dnl There are several ways the linker can put link edit rules in a binary:
7198                  dnl - classic info only (for OSX < 10.6)
7199                  dnl - dyld info only
7200                  dnl - both
7201                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO_ONLY" > /dev/null; then
7202                      _CLASSIC_INFO=
7203                  else
7204                      _CLASSIC_INFO=1
7205                  fi
7206                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO" > /dev/null; then
7207                      _DYLD_INFO=1
7208                  else
7209                      _DYLD_INFO=
7210                  fi
7211                  dnl With classic info, we need to build with -flat_namespace.
7212                  dnl With dyld info, Xcode 4.5 does the right thing without additional flags,
7213                  dnl but Xcode < 4.5 requires a dummy library and -flat_namespace because it
7214                  dnl forgets to set the weak flag in the dyld info.
7215                  dnl See http://glandium.org/blog/?p=2764 for more details.
7216                  dnl
7217                  dnl Values for ac_cv_weak_dynamic_linking, and subsequently
7218                  dnl MOZ_REPLACE_MALLOC_LINKAGE are thus:
7219                  dnl - "flat namespace" when -flat_namespace alone is needed
7220                  dnl - "dummy library" when a dummy library and -flat_namespace are needed
7221                  dnl - "compiler support" when nothing is needed
7222                  if test -n "$_DYLD_INFO" && dyldinfo -bind conftest${DLL_SUFFIX} 2> /dev/null | grep "_foo (weak import)" > /dev/null; then
7223                      if test -n "$_CLASSIC_INFO"; then
7224                          ac_cv_weak_dynamic_linking="flat namespace"
7225                      else
7226                          ac_cv_weak_dynamic_linking="compiler support"
7227                      fi
7228                  else
7229                      if test -n "$_DYLD_INFO"; then
7230                          ac_cv_weak_dynamic_linking="dummy library"
7231                      else
7232                          ac_cv_weak_dynamic_linking="flat namespace"
7233                      fi
7234                  fi
7235              else
7236                  AC_ERROR([couldn't compile a simple C file])
7237              fi
7238              rm -rf conftest*])
7239         MOZ_REPLACE_MALLOC_LINKAGE="$ac_cv_weak_dynamic_linking"
7240     fi
7242 AC_SUBST(MOZ_REPLACE_MALLOC)
7243 AC_SUBST(MOZ_REPLACE_MALLOC_LINKAGE)
7245 dnl ========================================================
7246 dnl = Jemalloc build setup
7247 dnl ========================================================
7248 if test -z "$MOZ_MEMORY"; then
7249   if test -n "$MOZ_JEMALLOC3" -a -z "$MOZ_REPLACE_MALLOC"; then
7250     MOZ_NATIVE_JEMALLOC=1
7251     AC_CHECK_FUNCS(mallctl nallocm,,
7252       [MOZ_NATIVE_JEMALLOC=
7253        break])
7254     if test -n "$MOZ_NATIVE_JEMALLOC"; then
7255       MOZ_MEMORY=1
7256       AC_DEFINE(MOZ_MEMORY)
7257       AC_DEFINE(MOZ_JEMALLOC3)
7258       AC_DEFINE(MOZ_NATIVE_JEMALLOC)
7259     fi
7260   fi
7261   case "${target}" in
7262     *-mingw*)
7263       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
7264         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.])
7265       fi
7266       ;;
7267   esac
7268 else
7269   dnl Don't try to run compiler tests on Windows
7270   if test "$OS_ARCH" = "WINNT"; then
7271     if test -z "$HAVE_64BIT_OS"; then
7272       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7273     else
7274       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7275     fi
7276   else
7277     AC_CHECK_SIZEOF([int *], [4])
7278     case "${ac_cv_sizeof_int_p}" in
7279     4)
7280       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7281       ;;
7282     8)
7283       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7284       ;;
7285     *)
7286       AC_MSG_ERROR([Unexpected pointer size])
7287       ;;
7288     esac
7289   fi
7291   AC_DEFINE(MOZ_MEMORY)
7292   if test -n "$MOZ_JEMALLOC3"; then
7293     AC_DEFINE(MOZ_JEMALLOC3)
7294   fi
7295   if test "x$MOZ_DEBUG" = "x1"; then
7296     AC_DEFINE(MOZ_MEMORY_DEBUG)
7297   fi
7298   dnl The generic feature tests that determine how to compute ncpus are long and
7299   dnl complicated.  Therefore, simply define special cpp variables for the
7300   dnl platforms we have special knowledge of.
7301   case "${target}" in
7302   *-darwin*)
7303     AC_DEFINE(MOZ_MEMORY_DARWIN)
7304     ;;
7305   *-*freebsd*)
7306     AC_DEFINE(MOZ_MEMORY_BSD)
7307     ;;
7308   *-android*|*-linuxandroid*)
7309     AC_DEFINE(MOZ_MEMORY_LINUX)
7310     AC_DEFINE(MOZ_MEMORY_ANDROID)
7311     if test -z "$gonkdir"; then
7312       _WRAP_MALLOC=1
7313     else
7314       AC_DEFINE(MOZ_MEMORY_GONK)
7315     fi
7316     MOZ_GLUE_LDFLAGS=
7317     ;;
7318   *-*linux*)
7319     AC_DEFINE(MOZ_MEMORY_LINUX)
7320     ;;
7321   *-netbsd*)
7322     AC_DEFINE(MOZ_MEMORY_BSD)
7323     ;;
7324   *-solaris*)
7325     AC_DEFINE(MOZ_MEMORY_SOLARIS)
7326     ;;
7327   *-mingw*)
7328     AC_DEFINE(MOZ_MEMORY_WINDOWS)
7329     if test -z "$MOZ_DEBUG"; then
7330       WIN32_CRT_LIBS="msvcrt.lib msvcprt.lib"
7331     else
7332       WIN32_CRT_LIBS="msvcrtd.lib msvcprtd.lib"
7333     fi
7334     dnl Look for a broken crtdll.obj
7335     WIN32_CRTDLL_FULLPATH=`lib -nologo -list $WIN32_CRT_LIBS | grep crtdll\\.obj`
7336     lib -NOLOGO -OUT:crtdll.obj $WIN32_CRT_LIBS -EXTRACT:$WIN32_CRTDLL_FULLPATH
7337     if grep -q '__imp__\{0,1\}free' crtdll.obj; then
7338       MOZ_GLUE_LDFLAGS='-LIBPATH:$(DIST)/lib -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcrtd -NODEFAULTLIB:msvcprt -NODEFAULTLIB:msvcprtd -DEFAULTLIB:mozcrt'
7339       dnl Also pass this to NSPR/NSS
7340       DLLFLAGS="$DLLFLAGS $MOZ_GLUE_LDFLAGS"
7341     else
7342       DLLFLAGS="$DLLFLAGS -LIBPATH:\$(DIST)/lib -DEFAULTLIB:mozglue"
7343     fi
7344     rm crtdll.obj
7346     export DLLFLAGS
7347     ;;
7348   *)
7349     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
7350     ;;
7351   esac
7352 fi # MOZ_MEMORY
7353 AC_SUBST(MOZ_MEMORY)
7354 AC_SUBST(MOZ_JEMALLOC3)
7355 AC_SUBST(MOZ_NATIVE_JEMALLOC)
7356 AC_SUBST(MOZ_GLUE_LDFLAGS)
7357 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
7358 AC_SUBST(WIN32_CRT_LIBS)
7359 dnl Need to set this for make because NSS doesn't have configure
7360 AC_SUBST(DLLFLAGS)
7362 dnl We need to wrap dlopen and related functions on Android because we use
7363 dnl our own linker.
7364 if test "$OS_TARGET" = Android; then
7365     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
7366     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
7367     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_GetEnv,--wrap=PR_SetEnv"
7368     if test -z "$gonkdir"; then
7369         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork,--wrap=raise"
7370         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"
7371     fi
7374 dnl ========================================================
7375 dnl = Use malloc wrapper lib
7376 dnl ========================================================
7377 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
7378 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
7379     _WRAP_MALLOC=1,
7380     _WRAP_MALLOC= )
7382 if test -n "$_WRAP_MALLOC"; then
7383     if test -n "$GNU_CC"; then
7384         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
7385         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
7386         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
7387         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
7388         dnl Wrap operator new and operator delete on Android.
7389         if test "$OS_TARGET" = "Android"; then
7390             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_Znwj,--wrap=_Znaj,--wrap=_ZdlPv,--wrap=_ZdaPv"
7391             dnl Wrap the nothrow variants too.
7392             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_ZnwjRKSt9nothrow_t,--wrap=_ZnajRKSt9nothrow_t,--wrap=_ZdlPvRKSt9nothrow_t,--wrap=_ZdaPvRKSt9nothrow_t"
7393         fi
7394     else
7395         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
7396     fi
7399 dnl ========================================================
7400 dnl = Location of malloc wrapper lib
7401 dnl ========================================================
7402 MOZ_ARG_WITH_STRING(wrap-malloc,
7403 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
7404     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
7406 dnl ========================================================
7407 dnl = Use JS Call tracing
7408 dnl ========================================================
7409 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
7410 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
7411     MOZ_TRACE_JSCALLS=1,
7412     MOZ_TRACE_JSCALLS= )
7413 if test -n "$MOZ_TRACE_JSCALLS"; then
7414     AC_DEFINE(MOZ_TRACE_JSCALLS)
7417 dnl ========================================================
7418 dnl = Use incremental GC
7419 dnl ========================================================
7420 JSGC_INCREMENTAL=1
7421 MOZ_ARG_DISABLE_BOOL(gcincremental,
7422 [  --disable-gcincremental Disable incremental GC],
7423     JSGC_INCREMENTAL= )
7424 if test -n "$JSGC_INCREMENTAL"; then
7425     AC_DEFINE(JSGC_INCREMENTAL)
7428 dnl ========================================================
7429 dnl Zealous JavaScript GC
7430 dnl ========================================================
7431 MOZ_ARG_ENABLE_BOOL(gczeal,
7432 [  --enable-gczeal         Enable zealous JavaScript GCing],
7433     JS_GC_ZEAL=1,
7434     JS_GC_ZEAL= )
7435 if test -n "$JS_GC_ZEAL"; then
7436     AC_DEFINE(JS_GC_ZEAL)
7439 dnl ========================================================
7440 dnl JS opt-mode assertions and minidump instrumentation
7441 dnl ========================================================
7442 MOZ_ARG_ENABLE_BOOL(js-diagnostics,
7443 [  --enable-js-diagnostics
7444                           Enable JS diagnostic assertions and breakpad data],
7445     JS_CRASH_DIAGNOSTICS=1,
7446     JS_CRASH_DIAGNOSTICS= )
7447 if test -n "$JS_CRASH_DIAGNOSTICS"; then
7448     AC_DEFINE(JS_CRASH_DIAGNOSTICS)
7451 MOZ_CHECK_CCACHE
7452 MOZ_CHECK_COMPILER_WRAPPER
7454 dnl ========================================================
7455 dnl = Enable static checking using gcc-dehydra
7456 dnl ========================================================
7458 MOZ_ARG_WITH_STRING(static-checking,
7459 [  --with-static-checking=path/to/gcc_dehydra.so
7460                           Enable static checking of code using GCC-dehydra],
7461     DEHYDRA_PATH=$withval,
7462     DEHYDRA_PATH= )
7464 if test -n "$DEHYDRA_PATH"; then
7465     if test ! -f "$DEHYDRA_PATH"; then
7466         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7467     fi
7468     AC_DEFINE(NS_STATIC_CHECKING)
7470 AC_SUBST(DEHYDRA_PATH)
7472 dnl ========================================================
7473 dnl = Enable using the clang plugin to build
7474 dnl ========================================================
7476 MOZ_ARG_ENABLE_BOOL(clang-plugin,
7477 [  --enable-clang-plugin   Enable building with the mozilla clang plugin ],
7478    ENABLE_CLANG_PLUGIN=1,
7479    ENABLE_CLANG_PLUGIN= )
7480 if test -n "$ENABLE_CLANG_PLUGIN"; then
7481     if test -z "$CLANG_CC"; then
7482         AC_MSG_ERROR([Can't use clang plugin without clang.])
7483     fi
7484     AC_DEFINE(MOZ_CLANG_PLUGIN)
7487 AC_SUBST(ENABLE_CLANG_PLUGIN)
7489 dnl ========================================================
7490 dnl = Enable stripping of libs & executables
7491 dnl ========================================================
7492 MOZ_ARG_ENABLE_BOOL(strip,
7493 [  --enable-strip          Enable stripping of libs & executables ],
7494     ENABLE_STRIP=1,
7495     ENABLE_STRIP= )
7497 dnl ========================================================
7498 dnl = Enable stripping of libs & executables when packaging
7499 dnl ========================================================
7500 MOZ_ARG_ENABLE_BOOL(install-strip,
7501 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7502     PKG_SKIP_STRIP= ,
7503     PKG_SKIP_STRIP=1)
7505 dnl ========================================================
7506 dnl = --enable-elf-dynstr-gc
7507 dnl ========================================================
7508 MOZ_ARG_ENABLE_BOOL(elf-dynstr-gc,
7509 [  --enable-elf-dynstr-gc  Enable elf dynstr garbage collector (opt builds only)],
7510     USE_ELF_DYNSTR_GC=1,
7511     USE_ELF_DYNSTR_GC= )
7513 dnl ========================================================
7514 dnl = --disable-elf-hack
7515 dnl ========================================================
7517 USE_ELF_HACK=1
7518 MOZ_ARG_DISABLE_BOOL(elf-hack,
7519 [  --disable-elf-hack      Disable elf hacks],
7520     USE_ELF_HACK=,
7521     USE_ELF_HACK=1)
7523 # Disable elf hack for profiling because the built in profiler
7524 # doesn't read the segments properly with elf hack. This is
7525 # temporary and should be fixed soon in the profiler.
7526 if test "$MOZ_PROFILING" = 1; then
7527   USE_ELF_HACK=
7530 # Only enable elfhack where supported
7531 if test "$USE_ELF_HACK" = 1; then
7532     case "${HOST_OS_ARCH},${OS_ARCH}" in
7533     Linux,Linux)
7534         case "${CPU_ARCH}" in
7535         arm | x86 | x86_64)
7536             USE_ELF_HACK=1
7537             ;;
7538         *)
7539             USE_ELF_HACK=
7540             ;;
7541         esac
7542         ;;
7543     *)
7544         USE_ELF_HACK=
7545         ;;
7546     esac
7549 if test "$USE_ELF_HACK" = 1; then
7550     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
7551     dnl memory addresses it maps to. The result is that by the time elfhack
7552     dnl kicks in, it is not possible to apply relocations because of that,
7553     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
7554     dnl segment. It makes elfhack mostly useless, so considering the problems
7555     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
7556     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
7557     dnl the linker creates PT_GNU_RELRO segments.
7558     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
7559         LINK_WITH_PT_GNU_RELRO,
7560         [echo "int main() {return 0;}" > conftest.${ac_ext}
7561          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
7562             test -s conftest${ac_exeext}; then
7563             if ${TOOLCHAIN_PREFIX}readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
7564                 LINK_WITH_PT_GNU_RELRO=yes
7565             else
7566                 LINK_WITH_PT_GNU_RELRO=no
7567             fi
7568          else
7569              dnl We really don't expect to get here, but just in case
7570              AC_ERROR([couldn't compile a simple C file])
7571          fi
7572          rm -rf conftest*])
7573     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
7574         AC_MSG_WARN([Disabling elfhack])
7575         USE_ELF_HACK=
7576     fi
7579 dnl ========================================================
7580 dnl = libstdc++ compatibility hacks
7581 dnl ========================================================
7583 STDCXX_COMPAT=
7584 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
7585 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
7586     STDCXX_COMPAT=1)
7588 AC_SUBST(STDCXX_COMPAT)
7590 if test -n "$STDCXX_COMPAT"; then
7591    eval $(CXX="$CXX" $PYTHON $_topsrcdir/build/autoconf/libstdcxx.py)
7592    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
7593    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
7596 dnl ========================================================
7597 dnl =
7598 dnl = Profiling and Instrumenting
7599 dnl =
7600 dnl ========================================================
7601 MOZ_ARG_HEADER(Profiling and Instrumenting)
7603 dnl ========================================================
7604 dnl = Enable runtime visual profiling logger
7605 dnl ========================================================
7606 MOZ_ARG_ENABLE_BOOL(visual-event-tracer,
7607 [  --enable-visual-event-tracer   Enable visual event tracer instrumentation],
7608     MOZ_VISUAL_EVENT_TRACER=1,
7609     MOZ_VISUAL_EVENT_TRACER=)
7610 if test -n "$MOZ_VISUAL_EVENT_TRACER"; then
7611     AC_DEFINE(MOZ_VISUAL_EVENT_TRACER)
7614 dnl ========================================================
7615 dnl Turn on reflow counting
7616 dnl ========================================================
7617 MOZ_ARG_ENABLE_BOOL(reflow-perf,
7618 [  --enable-reflow-perf    Enable reflow performance tracing],
7619     MOZ_REFLOW_PERF=1,
7620     MOZ_REFLOW_PERF= )
7621 if test -n "$MOZ_REFLOW_PERF"; then
7622     AC_DEFINE(MOZ_REFLOW_PERF)
7625 dnl ========================================================
7626 dnl Enable code size metrics.
7627 dnl ========================================================
7628 MOZ_ARG_ENABLE_BOOL(codesighs,
7629 [  --enable-codesighs      Enable code size analysis tools],
7630     _ENABLE_CODESIGHS=1,
7631     _ENABLE_CODESIGHS= )
7632 if test -n "$_ENABLE_CODESIGHS"; then
7633     if test -d $srcdir/tools/codesighs; then
7634         MOZ_MAPINFO=1
7635     else
7636         AC_MSG_ERROR([Codesighs directory $srcdir/tools/codesighs required.])
7637     fi
7640 dnl ========================================================
7641 dnl = Enable Radio Interface for B2G (Gonk usually)
7642 dnl ========================================================
7643 MOZ_ARG_ENABLE_BOOL(b2g-ril,
7644 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
7645     MOZ_B2G_RIL=1,
7646     MOZ_B2G_RIL= )
7647 if test -n "$MOZ_B2G_RIL"; then
7648     AC_DEFINE(MOZ_B2G_RIL)
7650 AC_SUBST(MOZ_B2G_RIL)
7652 dnl ========================================================
7653 dnl = Enable Radio FM for B2G (Gonk usually)
7654 dnl ========================================================
7655 if test -n "$MOZ_B2G_FM"; then
7656     AC_DEFINE(MOZ_B2G_FM)
7658 AC_SUBST(MOZ_B2G_FM)
7660 dnl ========================================================
7661 dnl = Enable Bluetooth Interface for B2G (Gonk usually)
7662 dnl ========================================================
7663 MOZ_ARG_ENABLE_BOOL(b2g-bt,
7664 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
7665     MOZ_B2G_BT=1,
7666     MOZ_B2G_BT= )
7667 if test -n "$MOZ_B2G_BT"; then
7668     AC_DEFINE(MOZ_B2G_BT)
7670 AC_SUBST(MOZ_B2G_BT)
7672 dnl ========================================================
7673 dnl = Enable Support for Time Manager API
7674 dnl ========================================================
7675 if test -n "$MOZ_TIME_MANAGER"; then
7676     AC_DEFINE(MOZ_TIME_MANAGER)
7678 AC_SUBST(MOZ_TIME_MANAGER)
7680 dnl ========================================================
7681 dnl = Enable Camera Interface for B2G (Gonk usually)
7682 dnl ========================================================
7683 MOZ_ARG_ENABLE_BOOL(b2g-camera,
7684 [  --enable-b2g-camera      Set compile flags necessary for compiling camera API for B2G ],
7685     MOZ_B2G_CAMERA=1,
7686     MOZ_B2G_CAMERA= )
7687 if test -n "$MOZ_B2G_CAMERA"; then
7688    AC_DEFINE(MOZ_B2G_CAMERA)
7690 AC_SUBST(MOZ_B2G_CAMERA)
7692 dnl ========================================================
7693 dnl = Enable Support B2G-specific changes to the NSS
7694 dnl = certificate trust database.
7695 dnl ========================================================
7696 if test -n "$MOZ_B2G_CERTDATA"; then
7697     AC_DEFINE(MOZ_B2G_CERTDATA)
7699 AC_SUBST(MOZ_B2G_CERTDATA)
7701 dnl ========================================================
7702 dnl = Enable Support for Payment API
7703 dnl ========================================================
7704 if test -n "$MOZ_PAY"; then
7705     AC_DEFINE(MOZ_PAY)
7707 AC_SUBST(MOZ_PAY)
7709 dnl ========================================================
7710 dnl = Enable Support for AudioChannelManager API
7711 dnl ========================================================
7712 if test -n "$MOZ_AUDIO_CHANNEL_MANAGER"; then
7713     AC_DEFINE(MOZ_AUDIO_CHANNEL_MANAGER)
7715 AC_SUBST(MOZ_AUDIO_CHANNEL_MANAGER)
7717 dnl ========================================================
7718 dnl = Support for demangling undefined symbols
7719 dnl ========================================================
7720 if test -z "$SKIP_LIBRARY_CHECKS"; then
7721     AC_LANG_SAVE
7722     AC_LANG_CPLUSPLUS
7723     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7724     AC_LANG_RESTORE
7727 # Demangle only for debug or trace-malloc or DMD builds
7728 MOZ_DEMANGLE_SYMBOLS=
7729 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
7730     MOZ_DEMANGLE_SYMBOLS=1
7731     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7733 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7735 dnl ========================================================
7736 dnl = Support for gcc stack unwinding (from gcc 3.3)
7737 dnl ========================================================
7738 if test -z "$SKIP_LIBRARY_CHECKS"; then
7739     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7742 dnl ========================================================
7743 dnl JIT observers
7744 dnl ========================================================
7746 MOZ_ARG_WITH_STRING(jitreport-granularity,
7747 [  --jitreport-granularity=N
7748                            Default granularity at which to report JIT code
7749                            to external tools
7750                              0 - no info
7751                              1 - code ranges for whole functions only
7752                              2 - per-line information
7753                              3 - per-op information],
7754   JITREPORT_GRANULARITY=$withval,
7755   JITREPORT_GRANULARITY=3)
7757 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
7759 dnl ========================================================
7760 dnl =
7761 dnl = Misc. Options
7762 dnl =
7763 dnl ========================================================
7764 MOZ_ARG_HEADER(Misc. Options)
7766 dnl ========================================================
7767 dnl update xterm title
7768 dnl ========================================================
7769 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7770 [  --enable-xterm-updates  Update XTERM titles with current command.],
7771     MOZ_UPDATE_XTERM=1,
7772     MOZ_UPDATE_XTERM= )
7774 dnl =========================================================
7775 dnl = Chrome format
7776 dnl =========================================================
7777 MOZ_ARG_ENABLE_STRING([chrome-format],
7778 [  --enable-chrome-format=jar|flat|omni
7779                           Select FORMAT of chrome files during packaging],
7780     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7782 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7783     MOZ_CHROME_FILE_FORMAT=jar
7786 if test "$MOZ_CHROME_FILE_FORMAT" = "symlink"; then
7787     AC_MSG_ERROR([--enable-chrome-format=symlink has been deprecated. It is now used by default in $DIST/bin on platforms that support it])
7790 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
7791     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7792     test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
7793     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, or omni])
7796 dnl =========================================================
7797 dnl Omnijar packaging (bug 552121)
7798 dnl =========================================================
7799 dnl Omnijar packaging is compatible with flat packaging.
7800 dnl In unpackaged builds, omnijar looks for files as if
7801 dnl things were flat packaged. After packaging, all files
7802 dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
7803 dnl is set to flat since putting files into jars is only
7804 dnl done during packaging with omnijar.
7805 if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
7806     MOZ_OMNIJAR=1
7807     AC_DEFINE(MOZ_OMNIJAR)
7809 MOZ_PACKAGER_FORMAT="$MOZ_CHROME_FILE_FORMAT"
7810 if test "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2" -o "$MOZ_WIDGET_TOOLKIT" = "android"; then
7811     MOZ_CHROME_FILE_FORMAT=flat
7812 else
7813     MOZ_CHROME_FILE_FORMAT=symlink
7816 OMNIJAR_NAME=omni.ja
7817 AC_SUBST(OMNIJAR_NAME)
7818 AC_SUBST(MOZ_OMNIJAR)
7819 AC_SUBST(MOZ_PACKAGER_FORMAT)
7821 dnl ========================================================
7822 dnl = Define default location for MOZILLA_FIVE_HOME
7823 dnl ========================================================
7824 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7825 [  --with-default-mozilla-five-home
7826                           Set the default value for MOZILLA_FIVE_HOME],
7827 [ val=`echo $withval`
7828   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7830 dnl ========================================================
7831 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7832 dnl ========================================================
7833 MOZ_ARG_WITH_STRING(user-appdir,
7834 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7835 [ val=`echo $withval`
7836 if echo "$val" | grep "\/" >/dev/null; then
7837     AC_MSG_ERROR("Homedir must be single relative path.")
7838 else
7839     MOZ_USER_DIR="$val"
7840 fi])
7842 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7844 dnl ========================================================
7845 dnl = Doxygen configuration
7846 dnl ========================================================
7847 dnl Use commas to specify multiple dirs to this arg
7848 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7849 MOZ_ARG_WITH_STRING(doc-input-dirs,
7850 [  --with-doc-input-dirs=DIRS
7851                           Header/idl dirs to create docs from],
7852 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7853 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7855 dnl Use commas to specify multiple dirs to this arg
7856 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7857 MOZ_ARG_WITH_STRING(doc-include-dirs,
7858 [  --with-doc-include-dirs=DIRS
7859                           Include dirs to preprocess doc headers],
7860 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7861 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7863 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7864 MOZ_ARG_WITH_STRING(doc-output-dir,
7865 [  --with-doc-output-dir=DIR
7866                           Dir to generate docs into],
7867 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7868 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7870 if test -z "$SKIP_COMPILER_CHECKS"; then
7871 dnl ========================================================
7872 dnl =
7873 dnl = Compiler Options
7874 dnl =
7875 dnl ========================================================
7876 MOZ_ARG_HEADER(Compiler Options)
7878 dnl ========================================================
7879 dnl Check for gcc -pipe support
7880 dnl ========================================================
7881 AC_MSG_CHECKING([for -pipe support])
7882 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
7883     dnl Any gcc that supports firefox supports -pipe.
7884     CFLAGS="$CFLAGS -pipe"
7885     CXXFLAGS="$CXXFLAGS -pipe"
7886     AC_MSG_RESULT([yes])
7887 else
7888     AC_MSG_RESULT([no])
7891 dnl ========================================================
7892 dnl Profile guided optimization (gcc checks)
7893 dnl ========================================================
7894 dnl Test for profiling options
7895 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7897 _SAVE_CFLAGS="$CFLAGS"
7898 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
7900 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7901 AC_TRY_COMPILE([], [return 0;],
7902                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7903                  result="yes" ], result="no")
7904 AC_MSG_RESULT([$result])
7906 if test $result = "yes"; then
7907   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7908   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
7909   PROFILE_USE_LDFLAGS="-fprofile-use"
7912 CFLAGS="$_SAVE_CFLAGS"
7914 if test -n "$INTEL_CC"; then
7915   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
7916   PROFILE_GEN_LDFLAGS=
7917   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
7918   PROFILE_USE_LDFLAGS=
7921 dnl Sun Studio on Solaris
7922 if test "$SOLARIS_SUNPRO_CC"; then
7923   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
7924   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
7925   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
7926   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
7929 AC_SUBST(PROFILE_GEN_CFLAGS)
7930 AC_SUBST(PROFILE_GEN_LDFLAGS)
7931 AC_SUBST(PROFILE_USE_CFLAGS)
7932 AC_SUBST(PROFILE_USE_LDFLAGS)
7934 AC_LANG_CPLUSPLUS
7936 dnl ========================================================
7937 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
7938 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
7939 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
7940 dnl ========================================================
7941 _SAVE_CXXFLAGS=$CXXFLAGS
7942 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
7943 AC_CACHE_CHECK(for correct overload resolution with const and templates,
7944     ac_nscap_nonconst_opeq_bug,
7945     [AC_TRY_COMPILE([
7946                       template <class T>
7947                       class Pointer
7948                         {
7949                         public:
7950                           T* myPtr;
7951                         };
7953                       template <class T, class U>
7954                       int operator==(const Pointer<T>& rhs, U* lhs)
7955                         {
7956                           return rhs.myPtr == lhs;
7957                         }
7959                       template <class T, class U>
7960                       int operator==(const Pointer<T>& rhs, const U* lhs)
7961                         {
7962                           return rhs.myPtr == lhs;
7963                         }
7964                     ],
7965                     [
7966                       Pointer<int> foo;
7967                       const int* bar;
7968                       return foo == bar;
7969                     ],
7970                     ac_nscap_nonconst_opeq_bug="no",
7971                     ac_nscap_nonconst_opeq_bug="yes")])
7972 CXXFLAGS="$_SAVE_CXXFLAGS"
7974 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
7975     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
7977 fi # ! SKIP_COMPILER_CHECKS
7979 AC_DEFINE(CPP_THROW_NEW, [throw()])
7980 AC_LANG_C
7982 if test "$COMPILE_ENVIRONMENT"; then
7983 MOZ_EXPAND_LIBS
7984 fi # COMPILE_ENVIRONMENT
7986 dnl ========================================================
7987 dnl =
7988 dnl = Build depencency options
7989 dnl =
7990 dnl ========================================================
7991 MOZ_ARG_HEADER(Build dependencies)
7993 if test "$GNU_CC" -a "$GNU_CXX"; then
7994   _DEPEND_CFLAGS='-MD -MP -MF $(MDDEPDIR)/$(@F).pp'
7995 dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
7996 elif test "$SOLARIS_SUNPRO_CC"; then
7997   _DEPEND_CFLAGS=
7998 else
7999   dnl Don't override this for MSVC
8000   if test -z "$_WIN32_MSVC"; then
8001     _USE_CPP_INCLUDE_FLAG=
8002     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
8003     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
8004   else
8005     echo '#include <stdio.h>' > dummy-hello.c
8006     changequote(,)
8007     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
8008     changequote([,])
8009     if test -z "$CL_INCLUDES_PREFIX"; then
8010         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
8011     fi
8012     AC_SUBST(CL_INCLUDES_PREFIX)
8013     rm -f dummy-hello.c
8014   fi
8017 dnl ========================================================
8018 dnl =
8019 dnl = Static Build Options
8020 dnl =
8021 dnl ========================================================
8022 MOZ_ARG_HEADER(Static build options)
8024 # split JS out by default to avoid VS2005 PGO crash (bug 591836).
8025 if test "$OS_ARCH" = "WINNT"; then
8026   ENABLE_SHARED_JS=1
8029 MOZ_ARG_ENABLE_BOOL(shared-js,
8030 [  --enable-shared-js
8031                           Create a shared JavaScript library.],
8032     ENABLE_SHARED_JS=1,
8033     ENABLE_SHARED_JS=)
8035 if test -n "$ENABLE_SHARED_JS"; then
8036   JS_SHARED_LIBRARY=1
8037   MOZ_JS_LIBS="$MOZ_JS_SHARED_LIBS"
8038 else
8039   MOZ_JS_LIBS="$MOZ_JS_STATIC_LIBS"
8040   AC_DEFINE(MOZ_STATIC_JS)
8042 AC_SUBST(JS_SHARED_LIBRARY)
8044 AC_SUBST(LIBXUL_LIBS)
8045 XPCOM_LIBS="$LIBXUL_LIBS"
8047 dnl ========================================================
8048 dnl =
8049 dnl = Standalone module options
8050 dnl =
8051 dnl ========================================================
8052 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
8054 dnl Check for GLib.
8055 dnl ========================================================
8057 if test -z "$SKIP_PATH_CHECKS"; then
8058 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
8059     if test "$MOZ_ENABLE_GTK2" -o "$USE_ELF_DYNSTR_GC" ; then
8060         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
8061     fi
8065 if test -z "${GLIB_GMODULE_LIBS}" \
8066    -a -n "${GLIB_CONFIG}"\
8067     -a "${GLIB_CONFIG}" != no\
8068 ; then
8069     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
8072 AC_SUBST(GLIB_CFLAGS)
8073 AC_SUBST(GLIB_LIBS)
8074 AC_SUBST(GLIB_GMODULE_LIBS)
8076 dnl ========================================================
8077 dnl Graphics checks.
8078 dnl ========================================================
8080 if test "${OS_TARGET}" = "WINNT" -o "${OS_ARCH}" = "Darwin" -o "${MOZ_WIDGET_TOOLKIT}" = "android" -o "${MOZ_WIDGET_TOOLKIT}" = "gtk2"; then
8081 MOZ_ENABLE_SKIA=1
8082 else
8083 MOZ_ENABLE_SKIA=
8086 MOZ_ARG_ENABLE_BOOL(skia,
8087 [  --enable-skia   Enable use of Skia],
8088 MOZ_ENABLE_SKIA=1,
8089 MOZ_ENABLE_SKIA=)
8091 if test "$USE_FC_FREETYPE"; then
8092     if test "$COMPILE_ENVIRONMENT"; then
8093         dnl ========================================================
8094         dnl = Check for freetype2 and its functionality
8095         dnl ========================================================
8096         PKG_CHECK_MODULES(FT2, freetype2 >= 6.1.0, _HAVE_FREETYPE2=1, _HAVE_FREETYPE2=)
8098         if test "$_HAVE_FREETYPE2"; then
8099             _SAVE_LIBS="$LIBS"
8100             _SAVE_CFLAGS="$CFLAGS"
8101             LIBS="$LIBS $FT2_LIBS"
8102             CFLAGS="$CFLAGS $FT2_CFLAGS"
8104             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
8105                 ac_cv_member_FT_Bitmap_Size_y_ppem,
8106                 [AC_TRY_COMPILE([#include <ft2build.h>
8107                                  #include FT_FREETYPE_H],
8108                                 [FT_Bitmap_Size s;
8109                                  if (sizeof s.y_ppem) return 0;
8110                                  return 1],
8111                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
8112                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
8113             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
8114                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
8115             else
8116                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
8117             fi
8118             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
8119                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
8120                                [FT_Bitmap_Size structure includes y_ppem field])
8122             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table FT_Select_Size)
8124             LIBS="$_SAVE_LIBS"
8125             CFLAGS="$_SAVE_CFLAGS"
8126         fi
8128         _SAVE_CPPFLAGS="$CPPFLAGS"
8129         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
8130         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
8131             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
8132         CPPFLAGS="$_SAVE_CPPFLAGS"
8133     else
8134         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
8135     fi
8137     PKG_CHECK_MODULES(_FONTCONFIG, fontconfig,
8138     [
8139         if test "$MOZ_PANGO"; then
8140             MOZ_PANGO_CFLAGS="$MOZ_PANGO_CFLAGS $_FONTCONFIG_CFLAGS"
8141             MOZ_PANGO_LIBS="$MOZ_PANGO_LIBS $_FONTCONFIG_LIBS"
8142         else
8143             FT2_CFLAGS="$FT2_CFLAGS $_FONTCONFIG_CFLAGS"
8144             FT2_LIBS="$FT2_LIBS $_FONTCONFIG_LIBS"
8145         fi
8146     ])
8149 dnl ========================================================
8150 dnl Check for pixman and cairo
8151 dnl ========================================================
8153 MOZ_TREE_CAIRO=1
8154 MOZ_ARG_ENABLE_BOOL(system-cairo,
8155 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
8156 MOZ_TREE_CAIRO=,
8157 MOZ_TREE_CAIRO=1 )
8159 MOZ_TREE_PIXMAN=1
8160 MOZ_ARG_ENABLE_BOOL(system-pixman,
8161 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
8162 MOZ_TREE_PIXMAN=,
8163 MOZ_TREE_PIXMAN=force,
8164 MOZ_TREE_PIXMAN=1 )
8166 # System cairo depends on system pixman
8167 if test "$MOZ_TREE_PIXMAN" = "force"; then
8168     if test -z "$MOZ_TREE_CAIRO"; then
8169         AC_MSG_ERROR([--disable-system-pixman is incompatible with --enable-system-cairo.])
8170     else
8171         MOZ_TREE_PIXMAN=1
8172     fi
8173 elif test -z "$MOZ_TREE_CAIRO"; then
8174     MOZ_TREE_PIXMAN=
8177 if test "$MOZ_TREE_PIXMAN"; then
8178     AC_DEFINE(MOZ_TREE_PIXMAN)
8179     MOZ_PIXMAN_CFLAGS=""
8180     MOZ_PIXMAN_LIBS='$(call EXPAND_LIBNAME_PATH,mozlibpixman,$(DEPTH)/gfx/cairo/libpixman/src)'
8181 else
8182     PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.19.2)
8183     MOZ_PIXMAN_CFLAGS="$PIXMAN_CFLAGS"
8184     MOZ_PIXMAN_LIBS="$PIXMAN_LIBS"
8186 AC_SUBST(MOZ_PIXMAN_CFLAGS)
8187 AC_SUBST(MOZ_PIXMAN_LIBS)
8189 # Check for headers defining standard int types.
8190 MOZ_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
8192 if test "$MOZ_TREE_CAIRO"; then
8193     MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
8194     AC_DEFINE(MOZ_TREE_CAIRO)
8196     # For now we assume that we will have a uint64_t available through
8197     # one of the above headers or mozstdint.h.
8198     AC_DEFINE(HAVE_UINT64_T)
8200     # Define macros for cairo-features.h
8201     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
8202     if test "$MOZ_X11"; then
8203         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
8204         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
8205         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
8206         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8207         MOZ_ENABLE_CAIRO_FT=1
8208         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
8209     fi
8210     case "$MOZ_WIDGET_TOOLKIT" in
8211       qt)
8212         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
8213         ;;
8214       cocoa | uikit)
8215         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
8216         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
8217         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
8218         ;;
8219       windows)
8220         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
8221         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
8222         if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
8223             WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
8224             WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
8225             MOZ_ENABLE_D2D_SURFACE=1
8226             MOZ_ENABLE_DWRITE_FONT=1
8227         else
8228             WIN32_DWRITE_FONT_FEATURE=
8229             WIN32_D2D_SURFACE_FEATURE=
8230         fi
8232         MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
8234         dnl D3D10 Layers depend on D2D Surfaces.
8235         if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
8236           MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
8237         fi
8238         ;;
8239       os2)
8240         OS2_SURFACE_FEATURE="#define CAIRO_HAS_OS2_SURFACE 1"
8241         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8242         MOZ_ENABLE_CAIRO_FT=1
8243         CAIRO_FT_CFLAGS="-I${MZFTCFGFT2}/include"
8244         CAIRO_FT_OSLIBS="-L${MZFTCFGFT2}/lib -lmozft -lmzfntcfg"
8245         CAIRO_FT_LIBS=""
8246         ;;
8247     esac
8248     if test "$USE_FC_FREETYPE"; then
8249         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
8250     fi
8251     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
8252     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
8253     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
8254     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
8255     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
8256     AC_SUBST(CAIRO_FT_CFLAGS)
8258     AC_SUBST(PS_SURFACE_FEATURE)
8259     AC_SUBST(PDF_SURFACE_FEATURE)
8260     AC_SUBST(SVG_SURFACE_FEATURE)
8261     AC_SUBST(XLIB_SURFACE_FEATURE)
8262     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
8263     AC_SUBST(QUARTZ_SURFACE_FEATURE)
8264     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
8265     AC_SUBST(WIN32_SURFACE_FEATURE)
8266     AC_SUBST(OS2_SURFACE_FEATURE)
8267     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
8268     AC_SUBST(FT_FONT_FEATURE)
8269     AC_SUBST(FC_FONT_FEATURE)
8270     AC_SUBST(WIN32_FONT_FEATURE)
8271     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
8272     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
8273     AC_SUBST(QUARTZ_FONT_FEATURE)
8274     AC_SUBST(PNG_FUNCTIONS_FEATURE)
8275     AC_SUBST(QT_SURFACE_FEATURE)
8276     AC_SUBST(TEE_SURFACE_FEATURE)
8278     MOZ_CAIRO_LIBS='$(call EXPAND_LIBNAME_PATH,mozcairo,$(DEPTH)/gfx/cairo/cairo/src)'" $CAIRO_FT_LIBS"
8279     MOZ_CAIRO_OSLIBS='${CAIRO_FT_OSLIBS}'
8281     if test "$MOZ_X11"; then
8282         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
8283     fi
8285     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
8286 else
8287     PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION)
8288     MOZ_CAIRO_CFLAGS="$CAIRO_CFLAGS"
8289     MOZ_CAIRO_LIBS="$CAIRO_LIBS"
8290     PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
8291     if test "$MOZ_X11"; then
8292         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
8293         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
8294         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_LIBS"
8295         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
8296     fi
8299 AC_SUBST(MOZ_TREE_CAIRO)
8300 AC_SUBST(MOZ_CAIRO_CFLAGS)
8301 AC_SUBST(MOZ_CAIRO_LIBS)
8302 AC_SUBST(MOZ_CAIRO_OSLIBS)
8303 AC_SUBST(MOZ_TREE_PIXMAN)
8305 dnl ========================================================
8306 dnl qcms
8307 dnl ========================================================
8309 QCMS_LIBS='$(DEPTH)/gfx/qcms/$(LIB_PREFIX)mozqcms.$(LIB_SUFFIX)'
8310 AC_SUBST(QCMS_LIBS)
8312 dnl ========================================================
8313 dnl HarfBuzz
8314 dnl ========================================================
8315 MOZ_HARFBUZZ_LIBS='$(DEPTH)/gfx/harfbuzz/src/$(LIB_PREFIX)mozharfbuzz.$(LIB_SUFFIX)'
8316 AC_SUBST(MOZ_HARFBUZZ_LIBS)
8318 dnl ========================================================
8319 dnl SIL Graphite
8320 dnl ========================================================
8321 MOZ_GRAPHITE_LIBS='$(DEPTH)/gfx/graphite2/src/$(LIB_PREFIX)mozgraphite2.$(LIB_SUFFIX)'
8322 AC_SUBST(MOZ_GRAPHITE_LIBS)
8324 dnl ========================================================
8325 dnl OTS
8326 dnl ========================================================
8327 MOZ_OTS_LIBS='$(DEPTH)/gfx/ots/src/$(LIB_PREFIX)mozots.$(LIB_SUFFIX)'
8328 AC_SUBST(MOZ_OTS_LIBS)
8330 dnl ========================================================
8331 dnl Skia 
8332 dnl ========================================================
8333 if test "$MOZ_ENABLE_SKIA"; then
8334   MOZ_SKIA_LIBS='$(DEPTH)/gfx/skia/$(LIB_PREFIX)skia.$(LIB_SUFFIX)'
8335   AC_DEFINE(MOZ_ENABLE_SKIA)
8336   AC_DEFINE(USE_SKIA)
8337   if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
8338     AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
8339   elif test "$OS_ARCH" = "WINNT"; then
8340     AC_DEFINE(SKIA_DLL)
8341     AC_DEFINE(GR_DLL)
8342   fi
8344   if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64"; then
8345     MOZ_ENABLE_SKIA_GPU=1
8346     AC_DEFINE(USE_SKIA_GPU)
8347     AC_SUBST(MOZ_ENABLE_SKIA_GPU)
8348   fi
8349 else
8350   MOZ_SKIA_LIBS=
8352 AC_SUBST(MOZ_ENABLE_SKIA)
8353 AC_SUBST(MOZ_SKIA_LIBS)
8355 dnl ========================================================
8356 dnl disable xul
8357 dnl ========================================================
8358 MOZ_ARG_DISABLE_BOOL(xul,
8359 [  --disable-xul           Disable XUL],
8360     MOZ_XUL= )
8361 if test "$MOZ_XUL"; then
8362   AC_DEFINE(MOZ_XUL)
8363 else
8364   dnl remove extensions that require XUL
8365   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/venkman//' -e 's/irc//' -e 's/tasks//'`
8368 AC_SUBST(MOZ_XUL)
8370 dnl ========================================================
8371 dnl disable profile locking
8372 dnl   do no use this in applications that can have more than
8373 dnl   one process accessing the profile directory.
8374 dnl ========================================================
8375 MOZ_ARG_DISABLE_BOOL(profilelocking,
8376 [  --disable-profilelocking
8377                           Disable profile locking],
8378     MOZ_PROFILELOCKING=,
8379     MOZ_PROFILELOCKING=1 )
8380 if test "$MOZ_PROFILELOCKING"; then
8381   AC_DEFINE(MOZ_PROFILELOCKING)
8384 dnl ========================================================
8385 dnl necko configuration options
8386 dnl ========================================================
8389 dnl option to disable various necko protocols
8391 MOZ_ARG_ENABLE_STRING(necko-protocols,
8392 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8393                           Enable/disable specific protocol handlers],
8394 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8395     if test "$option" = "yes" -o "$option" = "all"; then
8396         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8397     elif test "$option" = "no" -o "$option" = "none"; then
8398         NECKO_PROTOCOLS=""
8399     elif test "$option" = "default"; then
8400         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8401     elif test `echo "$option" | grep -c \^-` != 0; then
8402         option=`echo $option | sed 's/^-//'`
8403         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8404     else
8405         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8406     fi
8407 done],
8408     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8409 dnl Remove dupes
8410 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
8411 AC_SUBST(NECKO_PROTOCOLS)
8412 for p in $NECKO_PROTOCOLS; do
8413     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8414     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_PROTOCOL_$p"
8415 done
8418 dnl option to disable necko's wifi scanner
8420 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8421 [  --disable-necko-wifi    Disable necko wifi scanner],
8422     NECKO_WIFI=,
8423     NECKO_WIFI=1)
8425 if test "$OS_ARCH" = "OS2"; then
8426   dnl OS/2 implementation of Necko-WiFi support will be added in bug 506566
8427   NECKO_WIFI=
8429 if test "$NECKO_WIFI" -a \
8430         "$OS_ARCH" != "Linux" -a \
8431         "$OS_ARCH" != "Darwin" -a \
8432         "$OS_ARCH" != "SunOS" -a \
8433         "$OS_ARCH" != "WINNT"; then
8434   AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use --disable-necko-wifi])
8437 if test "$NECKO_WIFI"; then
8438   AC_DEFINE(NECKO_WIFI)
8439   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
8441 AC_SUBST(NECKO_WIFI)
8444 dnl option to disable cookies
8446 MOZ_ARG_DISABLE_BOOL(cookies,
8447 [  --disable-cookies       Disable cookie support],
8448     NECKO_COOKIES=,
8449     NECKO_COOKIES=1)
8450 AC_SUBST(NECKO_COOKIES)
8451 if test "$NECKO_COOKIES"; then
8452     AC_DEFINE(NECKO_COOKIES)
8453     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
8457 dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
8459 MOZ_ARG_DISABLE_BOOL(ctypes,
8460 [  --disable-ctypes        Disable js-ctypes],
8461     BUILD_CTYPES=,
8462     BUILD_CTYPES=1)
8463 AC_SUBST(BUILD_CTYPES)
8464 if test "$BUILD_CTYPES"; then
8465     AC_DEFINE(BUILD_CTYPES)
8468 dnl Build Places if required
8469 if test "$MOZ_PLACES"; then
8470   AC_DEFINE(MOZ_PLACES)
8473 dnl Build SocialAPI if required
8474 if test "$MOZ_SOCIAL"; then
8475   AC_DEFINE(MOZ_SOCIAL)
8478 dnl Build Common JS modules provided by services.
8479 AC_SUBST(MOZ_SERVICES_COMMON)
8480 if test -n "$MOZ_SERVICES_COMMON"; then
8481   AC_DEFINE(MOZ_SERVICES_COMMON)
8484 dnl Build Services crypto component (used by Sync)
8485 AC_SUBST(MOZ_SERVICES_CRYPTO)
8486 if test -n "$MOZ_SERVICES_CRYPTO"; then
8487   AC_DEFINE(MOZ_SERVICES_CRYPTO)
8490 dnl Build Firefox Health Reporter Service
8491 AC_SUBST(MOZ_SERVICES_HEALTHREPORT)
8492 if test -n "$MOZ_SERVICES_HEALTHREPORT"; then
8493   AC_DEFINE(MOZ_SERVICES_HEALTHREPORT)
8496 dnl Build Services metrics component
8497 AC_SUBST(MOZ_SERVICES_METRICS)
8498 if test -n "$MOZ_SERVICES_METRICS"; then
8499   AC_DEFINE(MOZ_SERVICES_METRICS)
8502 dnl Build Notifications if required
8503 AC_SUBST(MOZ_SERVICES_NOTIFICATIONS)
8504 if test -n "$MOZ_SERVICES_NOTIFICATIONS"; then
8505   AC_DEFINE(MOZ_SERVICES_NOTIFICATIONS)
8508 dnl Build Sync Services if required
8509 AC_SUBST(MOZ_SERVICES_SYNC)
8510 if test -n "$MOZ_SERVICES_SYNC"; then
8511   AC_DEFINE(MOZ_SERVICES_SYNC)
8514 dnl Build Captive Portal Detector if required
8515 AC_SUBST(MOZ_CAPTIVEDETECT)
8516 if test -n "$MOZ_CAPTIVEDETECT"; then
8517   AC_DEFINE(MOZ_CAPTIVEDETECT)
8520 dnl Build WBMP decoder if required
8521 AC_SUBST(MOZ_WBMP)
8522 if test -n "$MOZ_WBMP"; then
8523   AC_DEFINE(MOZ_WBMP)
8526 dnl ========================================================
8527 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
8528     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8531 if test "$MOZ_APP_COMPONENT_INCLUDE"; then
8532   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
8535 if test "$MOZ_APP_COMPONENT_MODULES"; then
8536   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_MODULES, $MOZ_APP_COMPONENT_MODULES)
8539 dnl ========================================================
8540 dnl =
8541 dnl = Maintainer debug option (no --enable equivalent)
8542 dnl =
8543 dnl ========================================================
8545 AC_SUBST(AR)
8546 AC_SUBST(AR_FLAGS)
8547 AC_SUBST(AR_LIST)
8548 AC_SUBST(AR_EXTRACT)
8549 AC_SUBST(AR_DELETE)
8550 AC_SUBST(AS)
8551 AC_SUBST(ASFLAGS)
8552 AC_SUBST(AS_DASH_C_FLAG)
8553 AC_SUBST(LD)
8554 AC_SUBST(RC)
8555 AC_SUBST(RCFLAGS)
8556 AC_SUBST(MC)
8557 AC_SUBST(WINDRES)
8558 AC_SUBST(IMPLIB)
8559 AC_SUBST(FILTER)
8560 AC_SUBST(BIN_FLAGS)
8561 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8562 AC_SUBST(MOZ_UPDATE_XTERM)
8563 AC_SUBST(MOZ_PLATFORM_MAEMO)
8564 AC_SUBST(MOZ_AUTH_EXTENSION)
8565 AC_SUBST(MOZ_PERMISSIONS)
8566 AC_SUBST(MOZ_PREF_EXTENSIONS)
8567 AC_SUBST(MOZ_JS_LIBS)
8568 AC_SUBST(MOZ_PSM)
8569 AC_SUBST(MOZ_DEBUG)
8570 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8571 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8572 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8573 AC_SUBST(MOZ_DEBUG_FLAGS)
8574 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8575 AC_SUBST(WARNINGS_AS_ERRORS)
8576 AC_SUBST(MOZ_EXTENSIONS)
8577 AC_SUBST(MOZ_JSDEBUGGER)
8578 AC_SUBST(MOZ_ENABLE_PROFILER_SPS)
8579 AC_SUBST(MOZ_JPROF)
8580 AC_SUBST(MOZ_SHARK)
8581 AC_SUBST(MOZ_INSTRUMENTS)
8582 AC_SUBST(MOZ_CALLGRIND)
8583 AC_SUBST(MOZ_VTUNE)
8584 AC_SUBST(MOZ_PROFILING)
8585 AC_SUBST(LIBICONV)
8586 AC_SUBST(MOZ_PLACES)
8587 AC_SUBST(MOZ_SOCIAL)
8588 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8589 AC_SUBST(MOZ_FEEDS)
8590 AC_SUBST(NS_PRINTING)
8591 AC_SUBST(MOZ_WEBGL)
8592 AC_SUBST(MOZ_HELP_VIEWER)
8593 AC_SUBST(TOOLCHAIN_PREFIX)
8595 AC_SUBST(JAVA)
8596 AC_SUBST(JAVAC)
8597 AC_SUBST(JAVAH)
8598 AC_SUBST(JAR)
8600 AC_SUBST(MOZ_PROFILELOCKING)
8602 AC_SUBST(ENABLE_TESTS)
8603 AC_SUBST(ENABLE_MARIONETTE)
8604 AC_SUBST(IBMBIDI)
8605 AC_SUBST(MOZ_UNIVERSALCHARDET)
8606 AC_SUBST(ACCESSIBILITY)
8607 AC_SUBST(MOZ_SPELLCHECK)
8608 AC_SUBST(MOZ_ANDROID_OMTC)
8609 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
8610 AC_SUBST(MOZ_ONLY_TOUCH_EVENTS)
8611 AC_SUBST(MOZ_CRASHREPORTER)
8612 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
8613 AC_SUBST(MOZ_CRASHREPORTER_UPLOAD_FULL_SYMBOLS)
8614 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
8615 AC_SUBST(MOZ_STUB_INSTALLER)
8616 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
8617 AC_SUBST(MOZ_ENABLE_SIGNMAR)
8618 AC_SUBST(MOZ_UPDATER)
8619 AC_SUBST(MOZ_ANGLE_RENDERER)
8620 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
8621 AC_SUBST(MOZ_DIRECTX_SDK_CPU_SUFFIX)
8622 AC_SUBST(MOZ_D3DX9_VERSION)
8623 AC_SUBST(MOZ_D3DCOMPILER_CAB)
8624 AC_SUBST(MOZ_D3DCOMPILER_DLL)
8625 AC_SUBST(MOZ_METRO)
8627 AC_SUBST(MOZ_ANDROID_HISTORY)
8628 AC_SUBST(MOZ_WEBSMS_BACKEND)
8629 AC_SUBST(MOZ_ANDROID_WALLPAPER)
8630 AC_SUBST(MOZ_ANDROID_BEAM)
8631 AC_SUBST(ENABLE_STRIP)
8632 AC_SUBST(PKG_SKIP_STRIP)
8633 AC_SUBST(STRIP_FLAGS)
8634 AC_SUBST(USE_ELF_DYNSTR_GC)
8635 AC_SUBST(USE_ELF_HACK)
8636 AC_SUBST(INCREMENTAL_LINKER)
8637 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8638 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8640 AC_SUBST(MOZ_FIX_LINK_PATHS)
8641 AC_SUBST(XPCOM_LIBS)
8642 AC_SUBST(XPCOM_FROZEN_LDOPTS)
8643 AC_SUBST(XPCOM_GLUE_LDOPTS)
8644 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
8645 AC_SUBST(XPCOM_STATICRUNTIME_GLUE_LDOPTS)
8646 AC_SUBST(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS)
8648 AC_SUBST(USE_DEPENDENT_LIBS)
8650 AC_SUBST(MOZ_BUILD_ROOT)
8651 AC_SUBST(MOZ_OS2_TOOLS)
8653 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8654 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8655 AC_SUBST(MOZ_LINKER_EXTRACT)
8657 dnl ========================================================
8658 dnl = Mac bundle name prefix
8659 dnl ========================================================
8660 MOZ_ARG_WITH_STRING(macbundlename-prefix,
8661 [  --with-macbundlename-prefix=prefix
8662                           Prefix for MOZ_MACBUNDLE_NAME],
8663 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
8665 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
8666 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
8667   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
8670 if test "$MOZ_DEBUG"; then
8671   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
8672 else
8673   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
8675 AC_SUBST(MOZ_MACBUNDLE_NAME)
8677 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
8678 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr '[A-Z]' '[a-z]'`
8679 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
8680 if test "$MOZ_DEBUG"; then
8681   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
8684 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
8685 AC_SUBST(MOZ_MACBUNDLE_ID)
8687 dnl ========================================================
8688 dnl = Child Process Name for IPC
8689 dnl ========================================================
8690 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
8691   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
8692 else
8693   # We want to let Android unpack the file at install time, but it only does
8694   # so if the file is named libsomething.so. The lib/ path is also required
8695   # because the unpacked file will be under the lib/ subdirectory and will
8696   # need to be executed from that path.
8697   MOZ_CHILD_PROCESS_NAME="lib/libplugin-container.so"
8699 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
8701 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
8702 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
8704 # The following variables are available to branding and application
8705 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
8706 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
8707 # impacts profile location and user-visible fields.
8708 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
8709 # versions of a given application (e.g. Aurora and Firefox both use
8710 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
8711 # for application.ini's "Name" field, which controls profile location in
8712 # the absence of a "Profile" field (see below), and various system
8713 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
8714 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
8715 # Mac Bundle name, Updater, Installer), it is typically used for nightly
8716 # builds (e.g. Aurora for Firefox).
8717 # - MOZ_APP_VERSION: Defines the application version number.
8718 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
8719 # defaults to a lowercase form of MOZ_APP_BASENAME.
8720 # - MOZ_APP_PROFILE: When set, used for application.ini's
8721 # "Profile" field, which controls profile location.
8722 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
8723 # crash reporter server url.
8724 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
8725 # - MOZ_EXTENSION_MANAGER: When set, enabled extension manager.
8727 if test -z "$MOZ_APP_NAME"; then
8728    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
8731 # For extensions and langpacks, we require a max version that is compatible
8732 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
8733 # 10.0a1 and 10.0a2 aren't affected
8734 # 10.0 becomes 10.0.*
8735 # 10.0.1 becomes 10.0.*
8736 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
8737 if test -z "$IS_ALPHA"; then
8738   changequote(,)
8739   MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*.[0-9]*\).*|\1|"`.*
8740   changequote([,])
8741 else
8742   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
8745 MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"}
8746 AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION")
8747 AC_DEFINE_UNQUOTED(MOZ_B2G_OS_NAME,"$MOZ_B2G_OS_NAME")
8749 AC_SUBST(MOZ_APP_NAME)
8750 AC_SUBST(MOZ_APP_DISPLAYNAME)
8751 AC_SUBST(MOZ_APP_BASENAME)
8752 AC_SUBST(MOZ_APP_VENDOR)
8753 AC_SUBST(MOZ_APP_PROFILE)
8754 AC_SUBST(MOZ_APP_ID)
8755 AC_SUBST(MAR_CHANNEL_ID)
8756 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
8757 AC_SUBST(MOZ_PROFILE_MIGRATOR)
8758 AC_SUBST(MOZ_EXTENSION_MANAGER)
8759 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
8760 AC_SUBST(MOZ_APP_UA_NAME)
8761 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
8762 AC_SUBST(MOZ_APP_VERSION)
8763 AC_SUBST(MOZ_APP_MAXVERSION)
8764 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
8765 AC_SUBST(FIREFOX_VERSION)
8766 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
8767 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
8768   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
8770 AC_DEFINE_UNQUOTED(MOZ_UA_BUILDID, "$MOZ_UA_BUILDID")
8771 AC_SUBST(MOZ_UA_BUILDID)
8773 AC_SUBST(MOZ_APP_STATIC_INI)
8775 AC_SUBST(MOZ_PKG_SPECIAL)
8777 AC_SUBST(MOZILLA_OFFICIAL)
8779 AC_DEFINE_UNQUOTED(MOZ_TELEMETRY_DISPLAY_REV, 2)
8780 AC_SUBST(MOZ_TELEMETRY_DISPLAY_REV)
8782 if test "$MOZ_TELEMETRY_REPORTING"; then
8783     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
8785     # Enable Telemetry by default for nightly and aurora channels
8786     if test "$MOZ_UPDATE_CHANNEL" = "nightly" -o \
8787         "$MOZ_UPDATE_CHANNEL" = "aurora"; then
8788         AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
8789     fi
8792 dnl If we have any service that uploads data (and requires data submission
8793 dnl policy alert), set MOZ_DATA_REPORTING.
8794 dnl We need SUBST for build system and DEFINE for xul preprocessor.
8795 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"; then
8796   MOZ_DATA_REPORTING=1
8797   AC_DEFINE(MOZ_DATA_REPORTING)
8798   AC_SUBST(MOZ_DATA_REPORTING)
8801 dnl win32 options
8802 AC_SUBST(MOZ_MAPINFO)
8803 AC_SUBST(MOZ_BROWSE_INFO)
8804 AC_SUBST(MOZ_TOOLS_DIR)
8805 AC_SUBST(WIN32_REDIST_DIR)
8806 AC_SUBST(MAKENSISU)
8808 dnl Echo the CFLAGS to remove extra whitespace.
8809 CFLAGS=`echo \
8810         $_WARNINGS_CFLAGS \
8811         $CFLAGS`
8813 CXXFLAGS=`echo \
8814         $_WARNINGS_CXXFLAGS \
8815         $CXXFLAGS`
8817 COMPILE_CFLAGS=`echo \
8818     $_DEFINES_CFLAGS \
8819         $_DEPEND_CFLAGS \
8820     $COMPILE_CFLAGS`
8822 COMPILE_CXXFLAGS=`echo \
8823     $_DEFINES_CXXFLAGS \
8824         $_DEPEND_CFLAGS \
8825     $COMPILE_CXXFLAGS`
8827 AC_SUBST(SYSTEM_LIBXUL)
8828 AC_SUBST(MOZ_NATIVE_JPEG)
8829 AC_SUBST(MOZ_NATIVE_PNG)
8830 AC_SUBST(MOZ_NATIVE_BZ2)
8832 AC_SUBST(MOZ_FLEXBOX)
8833 AC_SUBST(MOZ_JPEG_CFLAGS)
8834 AC_SUBST(MOZ_JPEG_LIBS)
8835 AC_SUBST(MOZ_BZ2_CFLAGS)
8836 AC_SUBST(MOZ_BZ2_LIBS)
8837 AC_SUBST(MOZ_PNG_CFLAGS)
8838 AC_SUBST(MOZ_PNG_LIBS)
8840 AC_SUBST(NSPR_CFLAGS)
8841 AC_SUBST(NSPR_LIBS)
8842 AC_SUBST(MOZ_NATIVE_NSPR)
8844 AC_SUBST(NSS_CFLAGS)
8845 AC_SUBST(NSS_LIBS)
8846 AC_SUBST(MOZ_NATIVE_NSS)
8847 AC_SUBST(NSS_DISABLE_DBM)
8849 OS_CFLAGS="$CFLAGS"
8850 OS_CXXFLAGS="$CXXFLAGS"
8851 OS_CPPFLAGS="$CPPFLAGS"
8852 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
8853 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
8854 OS_LDFLAGS="$LDFLAGS"
8855 OS_LIBS="$LIBS"
8856 AC_SUBST(OS_CFLAGS)
8857 AC_SUBST(OS_CXXFLAGS)
8858 AC_SUBST(OS_CPPFLAGS)
8859 AC_SUBST(OS_COMPILE_CFLAGS)
8860 AC_SUBST(OS_COMPILE_CXXFLAGS)
8861 AC_SUBST(OS_LDFLAGS)
8862 AC_SUBST(OS_LIBS)
8863 AC_SUBST(CROSS_COMPILE)
8864 AC_SUBST(WCHAR_CFLAGS)
8866 AC_SUBST(HOST_CC)
8867 AC_SUBST(HOST_CXX)
8868 AC_SUBST(HOST_CFLAGS)
8869 AC_SUBST(HOST_CXXFLAGS)
8870 AC_SUBST(HOST_LDFLAGS)
8871 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8872 AC_SUBST(HOST_AR)
8873 AC_SUBST(HOST_AR_FLAGS)
8874 AC_SUBST(HOST_LD)
8875 AC_SUBST(HOST_RANLIB)
8876 AC_SUBST(HOST_NSPR_MDCPUCFG)
8877 AC_SUBST(HOST_BIN_SUFFIX)
8878 AC_SUBST(HOST_OS_ARCH)
8880 AC_SUBST(TARGET_CPU)
8881 AC_SUBST(TARGET_VENDOR)
8882 AC_SUBST(TARGET_OS)
8883 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8884 AC_SUBST(TARGET_MD_ARCH)
8885 AC_SUBST(TARGET_XPCOM_ABI)
8886 AC_SUBST(OS_TARGET)
8887 AC_SUBST(OS_ARCH)
8888 AC_SUBST(OS_RELEASE)
8889 AC_SUBST(OS_TEST)
8890 AC_SUBST(CPU_ARCH)
8891 AC_SUBST(INTEL_ARCHITECTURE)
8893 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
8895 AC_SUBST(WRAP_LDFLAGS)
8896 AC_SUBST(MKSHLIB)
8897 AC_SUBST(MKCSHLIB)
8898 AC_SUBST(MKSHLIB_FORCE_ALL)
8899 AC_SUBST(MKSHLIB_UNFORCE_ALL)
8900 AC_SUBST(DSO_CFLAGS)
8901 AC_SUBST(DSO_PIC_CFLAGS)
8902 AC_SUBST(DSO_LDOPTS)
8903 AC_SUBST(LIB_PREFIX)
8904 AC_SUBST(DLL_PREFIX)
8905 AC_SUBST(DLL_SUFFIX)
8906 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
8907 AC_SUBST(LIB_SUFFIX)
8908 AC_SUBST(OBJ_SUFFIX)
8909 AC_SUBST(BIN_SUFFIX)
8910 AC_SUBST(ASM_SUFFIX)
8911 AC_SUBST(IMPORT_LIB_SUFFIX)
8912 AC_SUBST(USE_N32)
8913 AC_SUBST(CC_VERSION)
8914 AC_SUBST(CXX_VERSION)
8915 AC_SUBST(MSMANIFEST_TOOL)
8916 AC_SUBST(NS_ENABLE_TSF)
8917 AC_SUBST(MOZ_NSS_PATCH)
8918 AC_SUBST(MOZ_APP_COMPONENT_LIBS)
8919 AC_SUBST(MOZ_APP_EXTRA_LIBS)
8921 AC_SUBST(MOZ_SPEEX_RESAMPLER)
8922 AC_SUBST(MOZ_SOUNDTOUCH)
8923 AC_SUBST(MOZ_CUBEB)
8924 AC_SUBST(MOZ_WAVE)
8925 AC_SUBST(MOZ_VORBIS)
8926 AC_SUBST(MOZ_TREMOR)
8927 AC_SUBST(MOZ_OPUS)
8928 AC_SUBST(MOZ_WEBM)
8929 AC_SUBST(MOZ_DASH)
8930 AC_SUBST(MOZ_WMF)
8931 AC_SUBST(MOZ_MEDIA_PLUGINS)
8932 AC_SUBST(MOZ_OMX_PLUGIN)
8933 AC_SUBST(MOZ_VP8_ERROR_CONCEALMENT)
8934 AC_SUBST(MOZ_VP8_ENCODER)
8935 AC_SUBST(MOZ_VP8)
8936 AC_SUBST(MOZ_OGG)
8937 AC_SUBST(VPX_AS)
8938 AC_SUBST(VPX_ASFLAGS)
8939 AC_SUBST(VPX_DASH_C_FLAG)
8940 AC_SUBST(VPX_AS_CONVERSION)
8941 AC_SUBST(VPX_ASM_SUFFIX)
8942 AC_SUBST(VPX_X86_ASM)
8943 AC_SUBST(VPX_ARM_ASM)
8944 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
8945 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
8946 AC_SUBST(LIBJPEG_TURBO_AS)
8947 AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
8948 AC_SUBST(LIBJPEG_TURBO_X86_ASM)
8949 AC_SUBST(LIBJPEG_TURBO_X64_ASM)
8950 AC_SUBST(LIBJPEG_TURBO_ARM_ASM)
8952 AC_SUBST(MOZ_PACKAGE_JSSHELL)
8953 AC_SUBST(MOZ_FOLD_LIBS)
8955 AC_SUBST(MOZ_ENABLE_SZIP)
8956 AC_SUBST(MOZ_SZIP_FLAGS)
8958 AC_MSG_CHECKING([for posix_fallocate])
8959 AC_TRY_LINK([#define _XOPEN_SOURCE 600
8960   #include <fcntl.h>],
8961                  [posix_fallocate(0, 0, 0);],
8962                  [ac_cv___posix_fallocate=true],
8963                  [ac_cv___posix_fallocate=false])
8965 if test "$ac_cv___posix_fallocate" = true ; then
8966   AC_DEFINE(HAVE_POSIX_FALLOCATE)
8967   AC_MSG_RESULT(yes)
8968 else
8969   AC_MSG_RESULT(no)
8972 dnl Check for missing components
8973 if test "$COMPILE_ENVIRONMENT"; then
8974 if test "$MOZ_X11"; then
8975     if test "$WITHOUT_X11"; then
8976         AC_MSG_ERROR([--without-x specified and MOZ_X11 still defined])
8977     fi
8978     dnl ====================================================
8979     dnl = Check if X headers exist
8980     dnl ====================================================
8981     _SAVE_CFLAGS=$CFLAGS
8982     CFLAGS="$CFLAGS $XCFLAGS"
8983     AC_TRY_COMPILE([
8984         #include <stdio.h>
8985         #include <stdlib.h>
8986         #include <X11/Xlib.h>
8987         #include <X11/Intrinsic.h>
8988         #include <X11/extensions/XShm.h>
8989     ],
8990     [
8991         Display *dpy = 0;
8992         if ((dpy = XOpenDisplay(NULL)) == NULL) {
8993             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
8994             exit(1);
8995         }
8996     ], [],
8997     [ AC_MSG_ERROR([Could not compile basic X program.]) ])
8998     CFLAGS="$_SAVE_CFLAGS"
9000     if test -n "$MISSING_X"; then
9001         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
9002     fi
9004 fi # MOZ_X11
9006 dnl Check for headers, etc. needed by WebGL.
9007 if test "$MOZ_GL_DEFAULT_PROVIDER" = "GLX"; then
9008     MOZ_CHECK_HEADER(GL/glx.h)
9009     if test "$ac_cv_header_GL_glx_h" != "yes"; then
9010         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))])
9011     fi
9012 fi # MOZ_GL_DEFAULT_PROVIDER=GLX
9013 fi # COMPILE_ENVIRONMENT
9015 dnl Set various defines and substitutions
9016 dnl ========================================================
9018 if test "$OS_ARCH" = "Darwin"; then
9019   AC_DEFINE(XP_UNIX)
9020 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2"; then
9021   AC_DEFINE(XP_UNIX)
9024 if test "$MOZ_DEBUG"; then
9025     AC_DEFINE(MOZ_REFLOW_PERF)
9026     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
9029 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then
9030     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
9031     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
9032     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
9033     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
9034     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
9035     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
9036     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
9037     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
9040 AC_SUBST(MOZILLA_VERSION)
9042 AC_SUBST(ac_configure_args)
9044 dnl Spit out some output
9045 dnl ========================================================
9047 dnl The following defines are used by xpcom
9048 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
9049 CPP_THROW_NEW
9050 HAVE_CPP_2BYTE_WCHAR_T
9051 HAVE_CPP_AMBIGUITY_RESOLVING_USING
9052 HAVE_CPP_CHAR16_T
9053 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
9054 HAVE_CPP_PARTIAL_SPECIALIZATION
9055 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
9056 NEED_CPP_UNUSED_IMPLEMENTATIONS
9057 NEW_H
9058 HAVE_GETPAGESIZE
9059 HAVE_ICONV
9060 HAVE_ICONV_WITH_CONST_INPUT
9061 HAVE_MBRTOWC
9062 HAVE_WCRTOMB
9063 HAVE_STATVFS64
9064 HAVE_STATVFS
9065 HAVE_STATFS64
9066 HAVE_STATFS
9067 HAVE_SYS_STATVFS_H
9068 HAVE_SYS_STATFS_H
9069 HAVE_SYS_VFS_H
9070 HAVE_SYS_MOUNT_H
9073 # FUTURE? Consider moving all these to moz.build files.
9074 AC_CONFIG_HEADER(
9075 netwerk/necko-config.h
9076 xpcom/xpcom-config.h
9077 xpcom/xpcom-private.h
9080 AC_OUTPUT([mozilla-config.h])
9082 # Hack around an Apple bug that affects the egrep that comes with OS X 10.7.
9083 # "env ARCHPREFERENCE=i386,x86_64 arch egrep" first tries to use the 32-bit
9084 # Intel part of the egrep fat binary, even on 64-bit systems, and falls back on
9085 # the 64-bit part if it's not a fat binary, as can happen with MacPorts. We
9086 # (apparently) only need this hack when egrep's "pattern" is particularly long
9087 # (as in the following code) and the first egrep on our $PATH is Apple's.  See
9088 # bug 655339.
9089 case "$host" in
9090 *-apple-darwin11*)
9091     FIXED_EGREP="env ARCHPREFERENCE=i386,x86_64 arch egrep"
9092     ;;
9094     FIXED_EGREP="egrep"
9095     ;;
9096 esac
9098 # Generate Makefiles for WebRTC directly from .gyp files
9099 if test "${OS_TARGET}" = "WINNT"; then
9100    if test "$HAVE_64BIT_OS"; then
9101       OS_BITS=64
9102    else
9103       OS_BITS=32
9104    fi
9105    EXTRA_GYP_DEFINES="-D MSVS_VERSION=${_MSVS_VERSION} -D MSVS_OS_BITS=${OS_BITS}"
9107 elif test "${OS_TARGET}" = "Android"; then
9108    if test "${MOZ_WIDGET_TOOLKIT}" = "gonk"; then
9109       EXTRA_GYP_DEFINES="-G os=linux "
9110    else
9111       EXTRA_GYP_DEFINES="-D gtest_target_type=executable -D android_toolchain=${android_toolchain} -G os=android "
9112    fi
9115 if test -n "$ARM_ARCH"; then
9116     if test "$ARM_ARCH" -lt 7; then
9117         EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D armv7=0 "
9118     else
9119         if test "${OS_TARGET}" = "Android"; then
9120             EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D armv7=1 "
9121         else
9122             dnl CPU detection for ARM works on Android only.  armv7 always uses CPU detection, so
9123             dnl we have to set armv7=0 for non-Android target
9124             EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D armv7=0 "
9125         fi
9126     fi
9129 # Don't try to compile sse4.1 code if toolchain doesn't support
9130 if test -z "$HAVE_TOOLCHAIN_SUPPORT_MSSE4_1"; then
9131   EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D yuv_disable_asm=1"
9134 if test -n "$MOZ_WEBRTC"; then
9135    AC_MSG_RESULT("generating WebRTC Makefiles...")
9137    if test "${MOZ_WIDGET_TOOLKIT}" = "gonk"; then
9138       EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D build_with_gonk=1 -D include_internal_audio_device=0"
9139    fi
9141 dnl Any --include files must also appear in -D FORCED_INCLUDE_FILE= entries
9142 dnl so that regeneration via dependencies works correctly
9143    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"
9145    if test -n HAVE_CLOCK_MONOTONIC; then
9146       WEBRTC_CONFIG="${WEBRTC_CONFIG} -D have_clock_monotonic=1"
9147    else
9148       WEBRTC_CONFIG="${WEBRTC_CONFIG} -D have_clock_monotonic=0"
9149    fi
9151    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}"
9153    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9154      $GYP_WEBRTC_OPTIONS \
9155      --generator-output=${_objdir}/media/webrtc/trunk \
9156      ${srcdir}/media/webrtc/trunk/peerconnection.gyp
9157    if test "$?" != 0; then
9158       AC_MSG_ERROR([failed to generate WebRTC Makefiles])
9159    fi
9161    # XXX disable until we land the tranche with signaling
9162    if test -n "$MOZ_WEBRTC_SIGNALING"; then
9163      AC_MSG_RESULT("generating WebRTC/Signaling Makefiles...")
9164      $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9165        $GYP_WEBRTC_OPTIONS \
9166        -D build_for_test=0 \
9167        --generator-output=${_objdir}/media/webrtc/signaling \
9168        ${srcdir}/media/webrtc/signaling/signaling.gyp
9169      if test "$?" != 0; then
9170         AC_MSG_ERROR([failed to generate WebRTC/Signaling Makefiles])
9171      fi
9173      AC_MSG_RESULT("generating WebRTC/SignalingTest Makefiles...")
9174      $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9175        $GYP_WEBRTC_OPTIONS \
9176        -D build_for_test=1 \
9177        --generator-output=${_objdir}/media/webrtc/signalingtest \
9178        ${srcdir}/media/webrtc/signaling/signaling.gyp
9179      if test "$?" != 0; then
9180        AC_MSG_ERROR([failed to generate WebRTC/SignalingTest Makefiles])
9181      fi
9182    fi
9184    AC_MSG_RESULT("generating gtest Makefiles...")
9185    # Ok to pass some extra -D's that are ignored here
9186    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9187      $GYP_WEBRTC_OPTIONS \
9188      --generator-output=${_objdir}/media/webrtc/trunk/testing/ \
9189      ${srcdir}/media/webrtc/trunk/testing/gtest.gyp
9190    if test "$?" != 0; then
9191       AC_MSG_ERROR([failed to generate gtest Makefiles])
9192    fi
9194    AC_MSG_RESULT("generating nrappkit Makefiles...")
9195    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9196      $GYP_WEBRTC_OPTIONS \
9197      --generator-output=${_objdir}/media/mtransport/third_party/nrappkit \
9198      ${srcdir}/media/mtransport/third_party/nrappkit/nrappkit.gyp
9199    if test "$?" != 0; then
9200       AC_MSG_ERROR([failed to generate nrappkit Makefiles])
9201    fi
9203    AC_MSG_RESULT("generating nICEr Makefiles...")
9204    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9205      $GYP_WEBRTC_OPTIONS \
9206      --generator-output=${_objdir}/media/mtransport/third_party/nICEr \
9207      ${srcdir}/media/mtransport/third_party/nICEr/nicer.gyp
9208    if test "$?" != 0; then
9209       AC_MSG_ERROR([failed to generate nICEr Makefiles])
9210    fi
9213 # Generate a JSON config file for unittest harnesses etc to read
9214 # build configuration details from in a standardized way.
9215 OS_TARGET=${OS_TARGET} \
9216 TARGET_CPU=${TARGET_CPU} \
9217 MOZ_DEBUG=${MOZ_DEBUG} \
9218 MOZ_WIDGET_TOOLKIT=${MOZ_WIDGET_TOOLKIT} \
9219 UNIVERSAL_BINARY=${UNIVERSAL_BINARY} \
9220 MOZ_CRASHREPORTER=${MOZ_CRASHREPORTER} \
9221 MOZ_APP_NAME=${MOZ_APP_NAME} \
9222 TOPSRCDIR=${_topsrcdir} \
9223 MOZ_ASAN=${MOZ_ASAN} \
9224   $PYTHON ${_topsrcdir}/config/writemozinfo.py ./mozinfo.json.tmp
9225 if cmp -s ./mozinfo.json.tmp ./mozinfo.json; then
9226   rm ./mozinfo.json.tmp
9227 else
9228   mv -f ./mozinfo.json.tmp ./mozinfo.json
9231 # Run jemalloc configure script
9233 if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC3" -o -n "$MOZ_REPLACE_MALLOC"; then
9234   ac_configure_args="$_SUBDIR_CONFIG_ARGS --build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
9235   if test -n "$MOZ_REPLACE_MALLOC"; then
9236     # When using replace_malloc, we always want memalign and valloc exported from jemalloc.
9237     ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
9238     ac_configure_args="$ac_configure_args ac_cv_func_valloc=yes"
9239   fi
9240   if test -n "$MOZ_JEMALLOC3"; then
9241     case "${OS_ARCH}" in
9242       WINNT|Darwin)
9243         # We want jemalloc functions to be kept hidden on both Mac and Windows
9244         # See memory/build/mozmemory_wrap.h for details.
9245         ac_configure_args="$ac_configure_args --without-export"
9246         ;;
9247     esac
9248   elif test "${OS_ARCH}" = Darwin; then
9249     # When building as a replace-malloc lib, disabling the zone allocator
9250     # forces to use pthread_atfork.
9251     ac_configure_args="$ac_configure_args --disable-zone-allocator"
9252   fi
9253   _MANGLE="malloc posix_memalign aligned_alloc calloc realloc free memalign valloc malloc_usable_size"
9254   JEMALLOC_WRAPPER=
9255   if test -z "$MOZ_REPLACE_MALLOC"; then
9256     case "$OS_ARCH" in
9257       Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
9258         MANGLE=$_MANGLE
9259         ;;
9260     esac
9261   elif test -z "$MOZ_JEMALLOC3"; then
9262     MANGLE=$_MANGLE
9263     JEMALLOC_WRAPPER=replace_
9264   fi
9265   if test -n "$MANGLE"; then
9266     MANGLED=
9267     if test -n "$_WRAP_MALLOC" -a -z "$JEMALLOC_WRAPPER"; then
9268       JEMALLOC_WRAPPER=__wrap_
9269     fi
9270     for mangle in ${MANGLE}; do
9271       if test -n "$MANGLED"; then
9272         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle,$MANGLED"
9273       else
9274         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle"
9275       fi
9276     done
9277     ac_configure_args="$ac_configure_args --with-mangling=$MANGLED"
9278   fi
9279   unset CONFIG_FILES
9280   if test -z "$MOZ_TLS"; then
9281     ac_configure_args="$ac_configure_args --disable-tls"
9282   fi
9283   EXTRA_CFLAGS="$CFLAGS"
9284   for var in AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS EXTRA_CFLAGS LDFLAGS; do
9285     ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
9286   done
9287   if test "$CROSS_COMPILE"; then
9288     ac_configure_args="$ac_configure_args je_cv_static_page_shift=12"
9289   fi
9290   _save_cache_file="$cache_file"
9291   cache_file=$_objdir/memory/jemalloc/src/config.cache
9293   if ! test -e memory/jemalloc; then
9294     mkdir -p memory/jemalloc
9295   fi
9297   AC_OUTPUT_SUBDIRS(memory/jemalloc/src)
9298   cache_file="$_save_cache_file"
9299   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9302 # Run freetype configure script
9304 if test "$MOZ_TREE_FREETYPE"; then
9305    export CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS -std=c99"
9306    export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS"
9307    export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS"
9308    export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS"
9309    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
9310    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes"
9312    if ! test -e modules; then
9313      mkdir modules
9314    fi
9316    AC_OUTPUT_SUBDIRS(modules/freetype2)
9319 if test -z "$direct_nspr_config"; then
9320     dnl ========================================================
9321     dnl = Setup a nice relatively clean build environment for
9322     dnl = sub-configures.
9323     dnl ========================================================
9324     CC="$_SUBDIR_CC"
9325     CXX="$_SUBDIR_CXX"
9326     CFLAGS="$_SUBDIR_CFLAGS"
9327     CPPFLAGS="$_SUBDIR_CPPFLAGS"
9328     CXXFLAGS="$_SUBDIR_CXXFLAGS"
9329     LDFLAGS="$_SUBDIR_LDFLAGS"
9330     HOST_CC="$_SUBDIR_HOST_CC"
9331     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9332     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9333     RC=
9336 unset MAKEFILES
9337 unset CONFIG_FILES
9339 # Run all configure scripts specified by a subconfigure
9340 if test -n "$_subconfigure_subdir"; then
9341   _save_ac_configure_args="$ac_configure_args"
9342   ac_configure_args="$_subconfigure_config_args"
9343   AC_OUTPUT_SUBDIRS("$_subconfigure_subdir")
9344   ac_configure_args="$_save_ac_configure_args"
9347 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9348 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9350 export WRAP_LDFLAGS
9352 if test -n "$_WRAP_MALLOC"; then
9353     # Avoid doubling wrap malloc arguments
9354     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
9357 if test -z "$MOZ_NATIVE_NSPR"; then
9358     ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
9359     if test -z "$MOZ_DEBUG"; then
9360         ac_configure_args="$ac_configure_args --disable-debug"
9361     else
9362         ac_configure_args="$ac_configure_args --enable-debug"
9363     fi
9364     if test "$MOZ_OPTIMIZE" = "1"; then
9365         ac_configure_args="$ac_configure_args --enable-optimize"
9366     elif test -z "$MOZ_OPTIMIZE"; then
9367         ac_configure_args="$ac_configure_args --disable-optimize"
9368     fi
9369     if test -n "$HAVE_64BIT_OS"; then
9370         ac_configure_args="$ac_configure_args --enable-64bit"
9371     fi
9372     if test -n "$USE_ARM_KUSER"; then
9373         ac_configure_args="$ac_configure_args --with-arm-kuser"
9374     fi
9375     ac_configure_args="$ac_configure_args $NSPR_CONFIGURE_ARGS"
9376     if test -n "$MOZ_LINKER" -a "$ac_cv_func_dladdr" = no ; then
9377       # dladdr is supported by the new linker, even when the system linker doesn't
9378       # support it. Trick nspr into using dladdr when it's not supported.
9379       _SAVE_CPPFLAGS="$CPPFLAGS"
9380       export CPPFLAGS="-include $_topsrcdir/mozglue/linker/dladdr.h $CPPFLAGS"
9381     fi
9382     _SAVE_LDFLAGS="$LDFLAGS"
9383     export LDFLAGS="$LDFLAGS $NSPR_LDFLAGS"
9384     AC_OUTPUT_SUBDIRS(nsprpub)
9385     LDFLAGS="$_SAVE_LDFLAGS"
9386     if test -n "$MOZ_LINKER" -a "$ac_cv_func_dladdr" = no; then
9387       unset CPPFLAGS
9388       CPPFLAGS="$_SAVE_CFLAGS"
9389     fi
9390     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9393 dnl ========================================================
9394 dnl = Setup a nice relatively clean build environment for
9395 dnl = sub-configures.
9396 dnl ========================================================
9397 CC="$_SUBDIR_CC"
9398 CXX="$_SUBDIR_CXX"
9399 CFLAGS="$_SUBDIR_CFLAGS"
9400 CPPFLAGS="$_SUBDIR_CPPFLAGS"
9401 CXXFLAGS="$_SUBDIR_CXXFLAGS"
9402 LDFLAGS="$_SUBDIR_LDFLAGS"
9403 HOST_CC="$_SUBDIR_HOST_CC"
9404 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9405 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9408 if test -n "$ENABLE_CLANG_PLUGIN"; then
9409     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9410     AC_OUTPUT_SUBDIRS(build/clang-plugin)
9414 # Run the SpiderMonkey 'configure' script.
9415 dist=$MOZ_BUILD_ROOT/dist
9416 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9417 ac_configure_args="$ac_configure_args --enable-threadsafe"
9418 if test "$BUILD_CTYPES"; then
9419     # Build js-ctypes on the platforms we can.
9420     ac_configure_args="$ac_configure_args --enable-ctypes"
9422 if test -z "$JS_SHARED_LIBRARY" ; then
9423     ac_configure_args="$ac_configure_args --disable-shared-js"
9425 if test -z "$MOZ_NATIVE_NSPR"; then
9426     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
9427     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
9429 ac_configure_args="$ac_configure_args --with-dist-dir=../../dist"
9430 ac_configure_args="$ac_configure_args --prefix=$dist"
9431 if test "$MOZ_MEMORY"; then
9432    ac_configure_args="$ac_configure_args --enable-jemalloc"
9434 if test -n "$MOZ_GLUE_LDFLAGS"; then
9435    export MOZ_GLUE_LDFLAGS
9437 if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
9438    export MOZ_GLUE_PROGRAM_LDFLAGS
9440 if test "$MOZ_NATIVE_ZLIB" != 1 -a "$OS_ARCH" = "WINNT"; then
9441    MOZ_ZLIB_LIBS=
9443 export MOZ_NATIVE_ZLIB
9444 export MOZ_ZLIB_CFLAGS
9445 export MOZ_ZLIB_LIBS
9446 export MOZ_APP_NAME
9447 export DONT_POPULATE_VIRTUALENV=1
9448 export PYTHON
9449 export MOZILLA_CENTRAL_PATH=$_topsrcdir
9450 export STLPORT_CPPFLAGS
9451 export STLPORT_LDFLAGS
9452 export STLPORT_LIBS
9453 export JS_STANDALONE=no
9455 if ! test -e js; then
9456     mkdir js
9459 AC_OUTPUT_SUBDIRS(js/src)
9460 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9462 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR