bug 827304 - rename browser_clickToPlayPluginScriptAccessPopup.js because it's long...
[gecko.git] / configure.in
blob1e062c7d1784d8a04cb8798cb966909b2c427bee
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 MOZ_DEB_TIMESTAMP=`date +"%a, %d  %b %Y %T %z"   2>&1`
20 AC_SUBST(MOZ_DEB_TIMESTAMP)
22 dnl ========================================================
23 dnl =
24 dnl = Don't change the following two lines.  Doing so breaks:
25 dnl =
26 dnl = CFLAGS="-foo" ./configure
27 dnl =
28 dnl ========================================================
29 CFLAGS="${CFLAGS=}"
30 CPPFLAGS="${CPPFLAGS=}"
31 CXXFLAGS="${CXXFLAGS=}"
32 LDFLAGS="${LDFLAGS=}"
33 HOST_CFLAGS="${HOST_CFLAGS=}"
34 HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
35 HOST_LDFLAGS="${HOST_LDFLAGS=}"
37 dnl ========================================================
38 dnl = Preserve certain environment flags passed to configure
39 dnl = We want sub projects to receive the same flags
40 dnl = untainted by this configure script
41 dnl ========================================================
42 _SUBDIR_CC="$CC"
43 _SUBDIR_CXX="$CXX"
44 _SUBDIR_CFLAGS="$CFLAGS"
45 _SUBDIR_CPPFLAGS="$CPPFLAGS"
46 _SUBDIR_CXXFLAGS="$CXXFLAGS"
47 _SUBDIR_LDFLAGS="$LDFLAGS"
48 _SUBDIR_HOST_CC="$HOST_CC"
49 _SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
50 _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
51 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
52 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
54 dnl Set the version number of the libs included with mozilla
55 dnl ========================================================
56 MOZJPEG=62
57 MOZPNG=10513
58 NSPR_VERSION=4
59 NSS_VERSION=3
61 dnl Set the minimum version of toolkit libs used by mozilla
62 dnl ========================================================
63 GLIB_VERSION=1.2.0
64 PERL_VERSION=5.006
65 CAIRO_VERSION=1.10
66 PANGO_VERSION=1.14.0
67 GTK2_VERSION=2.10.0
68 WINDRES_VERSION=2.14.90
69 W32API_VERSION=3.14
70 GNOMEVFS_VERSION=2.0
71 GNOMEUI_VERSION=2.2.0
72 GCONF_VERSION=1.2.1
73 GIO_VERSION=2.20
74 STARTUP_NOTIFICATION_VERSION=0.8
75 DBUS_VERSION=0.60
76 SQLITE_VERSION=3.7.15.2
78 MSMANIFEST_TOOL=
80 dnl Set various checks
81 dnl ========================================================
82 MISSING_X=
83 AC_PROG_AWK
85 dnl Initialize the Pthread test variables early so they can be
86 dnl  overridden by each platform.
87 dnl ========================================================
88 USE_PTHREADS=
89 _PTHREAD_LDFLAGS=""
91 dnl Do not allow a separate objdir build if a srcdir build exists.
92 dnl ==============================================================
93 _topsrcdir=`cd \`dirname $0\`; pwd`
94 _objdir=`pwd`
96 if test "$_topsrcdir" != "$_objdir"
97 then
98   # Check for a couple representative files in the source tree
99   _conflict_files=
100   for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
101     if test -f $file; then
102       _conflict_files="$_conflict_files $file"
103     fi
104   done
105   if test "$_conflict_files"; then
106     echo "***"
107     echo "*   Your source tree contains these files:"
108     for file in $_conflict_files; do
109       echo "*         $file"
110     done
111     cat 1>&2 <<-EOF
112         *   This indicates that you previously built in the source tree.
113         *   A source tree build can confuse the separate objdir build.
114         *
115         *   To clean up the source tree:
116         *     1. cd $_topsrcdir
117         *     2. gmake distclean
118         ***
119         EOF
120     exit 1
121     break
122   fi
124 MOZ_BUILD_ROOT=`pwd`
126 dnl Do not allow building if a clobber is required
127 dnl ==============================================================
128 dnl TODO Make this better, ideally this would clobber automaticially
129 if test -e $_objdir/CLOBBER; then
130   if test $_topsrcdir/CLOBBER -nt $_objdir/CLOBBER; then
131     echo "      ***"
132     echo "      *       The CLOBBER file has been updated, indicating that an incremental build"
133     echo "      *       since your last build will probably not work. A full build is required."
134     echo "      *       The change that caused this is:"
135     cat $_topsrcdir/CLOBBER | sed '/^#/d' | sed 's/^/   *       /'
136     echo "      *       "
137     echo "      *       The easiest way to fix this is to manually delete your objdir:"
138     echo "      *       rm -rf $_objdir"
139     echo "      *       "
140     echo "      *       Or, if you know this clobber doesn't apply to you, it can be ignored with:"
141     echo "      *       cp '$_topsrcdir/CLOBBER' $_objdir"
142     echo "      ***"
143     exit 1
144     break;
145   fi
146 else
147   touch $_objdir/CLOBBER
150 MOZ_PYTHON
152 MOZ_DEFAULT_COMPILER
154 COMPILE_ENVIRONMENT=1
155 MOZ_ARG_DISABLE_BOOL(compile-environment,
156 [  --disable-compile-environment
157                           Disable compiler/library checks.],
158     COMPILE_ENVIRONMENT= )
159 AC_SUBST(COMPILE_ENVIRONMENT)
161 MOZ_ARG_WITH_STRING(l10n-base,
162 [  --with-l10n-base=DIR    path to l10n repositories],
163     L10NBASEDIR=$withval)
164 if test -n "$L10NBASEDIR"; then
165     if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
166         AC_MSG_ERROR([--with-l10n-base must specify a path])
167     elif test -d "$L10NBASEDIR"; then
168         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd`
169     else
170         AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
171     fi
173 AC_SUBST(L10NBASEDIR)
175 dnl Check for Perl first -- needed for win32 SDK checks
176 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
177 if test -z "$PERL" -o "$PERL" = ":"; then
178     AC_MSG_ERROR([perl not found in \$PATH])
181 AC_SUBST(GAIADIR)
182 if test -n "$GAIADIR" ; then
183     AC_DEFINE(PACKAGE_GAIA)
186 MOZ_ARG_WITH_STRING(gonk,
187 [  --with-gonk=DIR
188                location of gonk dir],
189     gonkdir=$withval)
191 MOZ_ARG_WITH_STRING(gonk-toolchain-prefix,
192 [  --with-gonk-toolchain-prefix=DIR
193                           prefix to gonk toolchain commands],
194     gonk_toolchain_prefix=$withval)
196 if test -n "$gonkdir" ; then
197     kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
198     android_source="$gonkdir"
199     ANDROID_SOURCE="$android_source"
200     ANDROID_NDK="${ANDROID_SOURCE}/ndk"
202     dnl set up compilers
203     TOOLCHAIN_PREFIX="$gonk_toolchain_prefix"
204     AS="$gonk_toolchain_prefix"as
205     CC="$gonk_toolchain_prefix"gcc
206     CXX="$gonk_toolchain_prefix"g++
207     CPP="$gonk_toolchain_prefix"cpp
208     LD="$gonk_toolchain_prefix"ld
209     AR="$gonk_toolchain_prefix"ar
210     RANLIB="$gonk_toolchain_prefix"ranlib
211     STRIP="$gonk_toolchain_prefix"strip
212     OBJCOPY="$gonk_toolchain_prefix"objcopy
214     STLPORT_CPPFLAGS="-I$gonkdir/ndk/sources/cxx-stl/stlport/stlport/ -I$gonkdir/external/stlport/stlport/"
215     STLPORT_LIBS="-lstlport"
217     case "$target_cpu" in
218     arm)
219         ARCH_DIR=arch-arm
220         ;;
221     i?86)
222         ARCH_DIR=arch-x86
223         ;;
224     esac
226     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/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/hardware/libhardware_legacy/include -I$gonkdir/system -I$gonkdir/system/core/include -isystem $gonkdir/bionic -I$gonkdir/frameworks/base/include -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib $CPPFLAGS -I$gonkdir/frameworks/base/services/sensorservice -I$gonkdir/frameworks/base/services/camera -I$gonkdir/system/media/wilhelm/include -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/dalvik/libnativehelper/include/nativehelper"
227     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
228     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS $STLPORT_CPPFLAGS"
229     dnl Add -llog by default, since we use it all over the place.
230     LIBS="$LIBS -llog $STLPORT_LIBS"
232     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"
234     dnl prevent cross compile section from using these flags as host flags
235     if test -z "$HOST_CPPFLAGS" ; then
236         HOST_CPPFLAGS=" "
237     fi
238     if test -z "$HOST_CFLAGS" ; then
239         HOST_CFLAGS=" "
240     fi
241     if test -z "$HOST_CXXFLAGS" ; then
242         HOST_CXXFLAGS=" "
243     fi
244     if test -z "$HOST_LDFLAGS" ; then
245         HOST_LDFLAGS=" "
246     fi
248     AC_DEFINE(ANDROID)
249     AC_DEFINE(HAVE_SYS_UIO_H)
250     AC_DEFINE(HAVE_PTHREADS)
251     CROSS_COMPILE=1
252     MOZ_CHROME_FILE_FORMAT=omni
253     direct_nspr_config=1
254 else
255     MOZ_ANDROID_NDK
257     case "$target" in
258     *-android*|*-linuxandroid*)
259         if test -z "$ANDROID_PACKAGE_NAME" ; then
260             ANDROID_PACKAGE_NAME='org.mozilla.$(MOZ_APP_NAME)'
261         fi
262         MOZ_CHROME_FILE_FORMAT=omni
263         ZLIB_DIR=yes
264         ;;
265     *-linux*)
266         AC_PATH_PROG(OBJCOPY,objcopy)
267         ;;
268     esac
271 AC_SUBST(ANDROID_SOURCE)
272 AC_SUBST(ANDROID_PACKAGE_NAME)
273 AC_SUBST(OBJCOPY)
275 dnl ========================================================
276 dnl Checks for compilers.
277 dnl ========================================================
278 dnl Set CROSS_COMPILE in the environment when running configure
279 dnl to use the cross-compile setup for now
280 dnl ========================================================
282 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
283 AR_FLAGS='cr $@'
285 if test "$COMPILE_ENVIRONMENT"; then
287 if test -n "$CROSS_COMPILE" -a "$target" != "$host"; then
288     echo "cross compiling from $host to $target"
289     cross_compiling=yes
291     _SAVE_CC="$CC"
292     _SAVE_CFLAGS="$CFLAGS"
293     _SAVE_LDFLAGS="$LDFLAGS"
295     AC_MSG_CHECKING([for host c compiler])
296     AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc cl icc, "")
297     if test -z "$HOST_CC"; then
298         AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
299     fi
300     AC_MSG_RESULT([$HOST_CC])
301     AC_MSG_CHECKING([for host c++ compiler])
302     AC_CHECK_PROGS(HOST_CXX, $HOST_CXX $CCC c++ g++ gcc CC cxx cc++ cl icc, "")
303     if test -z "$HOST_CXX"; then
304         AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
305     fi
306     AC_MSG_RESULT([$HOST_CXX])
308     if test -z "$HOST_CFLAGS"; then
309         HOST_CFLAGS="$CFLAGS"
310     fi
311     if test -z "$HOST_CXXFLAGS"; then
312         HOST_CXXFLAGS="$CXXFLAGS"
313     fi
314     if test -z "$HOST_LDFLAGS"; then
315         HOST_LDFLAGS="$LDFLAGS"
316     fi
317     if test -z "$HOST_AR_FLAGS"; then
318         HOST_AR_FLAGS="$AR_FLAGS"
319     fi
320     AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
321     AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
322     CC="$HOST_CC"
323     CFLAGS="$HOST_CFLAGS"
324     LDFLAGS="$HOST_LDFLAGS"
326     AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
327     AC_TRY_COMPILE([], [return(0);],
328         [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
329         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
331     CC="$HOST_CXX"
332     CFLAGS="$HOST_CXXFLAGS"
334     AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
335     AC_TRY_COMPILE([], [return(0);],
336         [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
337         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
339     CC=$_SAVE_CC
340     CFLAGS=$_SAVE_CFLAGS
341     LDFLAGS=$_SAVE_LDFLAGS
343     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :)
344     unset ac_cv_prog_CC
345     AC_PROG_CC
346     AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :)
347     unset ac_cv_prog_CXX
348     AC_PROG_CXX
350     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", :)
351     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", :)
352     MOZ_PATH_PROGS(AS, $AS "${target_alias}-as" "${target}-as", :)
353     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", :)
354     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :)
355     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :)
356     AC_DEFINE(CROSS_COMPILE)
357 else
358     AC_PROG_CC
359     case "$target" in
360     *-mingw*)
361       # Work around the conftest.exe access problem on Windows
362       sleep 2
363     esac
364     AC_PROG_CXX
365     AC_PROG_RANLIB
366     MOZ_PATH_PROGS(AS, $AS as, $CC)
367     AC_CHECK_PROGS(AR, ar, :)
368     AC_CHECK_PROGS(LD, ld, :)
369     AC_CHECK_PROGS(STRIP, strip, :)
370     AC_CHECK_PROGS(WINDRES, windres, :)
371     if test -z "$HOST_CC"; then
372         HOST_CC="$CC"
373     fi
374     if test -z "$HOST_CFLAGS"; then
375         HOST_CFLAGS="$CFLAGS"
376     fi
377     if test -z "$HOST_CXX"; then
378         HOST_CXX="$CXX"
379     fi
380     if test -z "$HOST_CXXFLAGS"; then
381         HOST_CXXFLAGS="$CXXFLAGS"
382     fi
383     if test -z "$HOST_LDFLAGS"; then
384         HOST_LDFLAGS="$LDFLAGS"
385     fi
386     if test -z "$HOST_RANLIB"; then
387         HOST_RANLIB="$RANLIB"
388     fi
389     if test -z "$HOST_AR"; then
390         HOST_AR="$AR"
391     fi
392     if test -z "$HOST_AR_FLAGS"; then
393         HOST_AR_FLAGS="$AR_FLAGS"
394     fi
397 if test -n "$MOZ_WINCONSOLE"; then
398     AC_DEFINE(MOZ_WINCONSOLE)
401 MOZ_TOOL_VARIABLES
403 dnl ========================================================
404 dnl Special win32 checks
405 dnl ========================================================
407 MOZ_ARG_ENABLE_BOOL(metro,
408 [  --enable-metro           Enable Windows Metro build targets],
409     MOZ_METRO=1,
410     MOZ_METRO=)
411 if test -n "$MOZ_METRO"; then
412     AC_DEFINE(MOZ_METRO)
413     # Target the Windows 8 Kit
414     WINSDK_TARGETVER=602
415     WINVER=502
416     # toolkit/library/makefile.in needs these, see nsDllMain.
417     CRTDLLVERSION=110
418     CRTEXPDLLVERSION=1-1-0
419 else
420     # Target the Windows 7 SDK by default
421     WINSDK_TARGETVER=601
422     WINVER=502
425 AC_SUBST(CRTDLLVERSION)
426 AC_SUBST(CRTEXPDLLVERSION)
428 if test -n "$MOZ_METRO"; then
429   case "$target" in
430   *-mingw*)
431     ;;
432   *)
433     AC_MSG_ERROR([Metro builds only valid on the windows platform.]);
434     ;;
435   esac
438 MOZ_ARG_WITH_STRING(windows-version,
439 [  --with-windows-version=WINSDK_TARGETVER
440                           Windows SDK version to target. Lowest version
441                           currently allowed is 601 (Win7), highest is 602 (Win8)],
442   WINSDK_TARGETVER=$withval)
444 # Currently only two sdk versions allowed, 601 and 602
445 case "$WINSDK_TARGETVER" in
446 601|602)
447     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
448     ;;
451     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER)]);
452     ;;
453 esac
455 case "$target" in
456 *-mingw*)
457     if test "$GCC" != "yes"; then
458         # Check to see if we are really running in a msvc environemnt
459         _WIN32_MSVC=1
460         AC_CHECK_PROGS(MIDL, midl)
462         # Make sure compilers are valid
463         CFLAGS="$CFLAGS -TC -nologo"
464         CXXFLAGS="$CXXFLAGS -TP -nologo"
465         AC_LANG_SAVE
466         AC_LANG_C
467         AC_TRY_COMPILE([#include <stdio.h>],
468             [ printf("Hello World\n"); ],,
469             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
471         AC_LANG_CPLUSPLUS
472         AC_TRY_COMPILE([#include <new.h>],
473             [ unsigned *test = new unsigned(42); ],,
474             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
475         AC_LANG_RESTORE
477         changequote(,)
478         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
479         changequote([,])
481         # Determine compiler version
482         CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
483         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
484         _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
485         _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
486         _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
487         _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
489         CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
490         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
492         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
493             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
494         fi
496         if test "$_CC_MAJOR_VERSION" = "14"; then
497             dnl Require VC8SP1 or newer.
498             dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762.
499             if test "$_CC_RELEASE" -lt 50727 -o \
500                     \( "$_CC_RELEASE" -eq 50727 -a "$_CC_BUILD" -lt 762 \); then
501               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.])
502             fi
504             _CC_SUITE=8
505             _MSVS_VERSION=2005
506             AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
507             AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
508         elif test "$_CC_MAJOR_VERSION" = "15"; then
509             _CC_SUITE=9
510             _MSVS_VERSION=2008
511             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
512             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
513         elif test "$_CC_MAJOR_VERSION" = "16"; then
514             _CC_SUITE=10
515             _MSVS_VERSION=2010
516             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
517             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
518         elif test "$_CC_MAJOR_VERSION" = "17"; then
519             _CC_SUITE=11
520             _MSVS_VERSION=2012
521             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
522             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
523         else
524             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
525         fi
527         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
529         if test -n "$WIN32_REDIST_DIR"; then
530           if test ! -d "$WIN32_REDIST_DIR"; then
531             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
532           fi
533           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
534         fi
536         dnl Confirm we have the pri tools on win8 builds
537         if test -n "$MOZ_METRO"; then
538           AC_MSG_CHECKING([for makepri])
539           AC_CHECK_PROGS(MAKEPRI, makepri, "")
540           if test -z "MAKEPRI" ; then
541               AC_MSG_ERROR([makepri.exe is required for generating metro browser install components. It should be in the Win8 SDK.])
542           fi
543           AC_SUBST(MAKEPRI)
544         fi
546         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
547         dnl not something else like "magnetic tape manipulation utility".
548         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
549         if test -z "$MSMT_TOOL"; then
550           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
551         fi
553         changequote(,)
554         _MSMT_VER_FILTER='s|.*[^!-~]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
555         changequote([,])
556         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
557         if test -z "$MSMANIFEST_TOOL_VERSION"; then
558           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
559         fi
561         MSMANIFEST_TOOL=1
562         unset MSMT_TOOL
564         # Check linker version
565         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
566         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
567         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
568             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
569         fi
571         INCREMENTAL_LINKER=1
573         # Check midl version
574         _MIDL_FULL_VERSION=`"${MIDL}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
575         _MIDL_MAJOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
576         _MIDL_MINOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
577         _MIDL_REV_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
578         # Add flags if necessary
579         AC_MSG_CHECKING([for midl flags])
580         case "$target" in
581         i*86-*)
582             if test \( "$_MIDL_MAJOR_VERSION" = "7" -a "$_MIDL_MINOR_VERSION" = "00" -a "$_MIDL_REV_VERSION" = "0499" \); then
583                 # MIDL version 7.00.0499 defaults /env win64 on x64 platforms.
584                 # MIDL version 7.00.0500 or later has no problem.
585                 MIDL_FLAGS="${MIDL_FLAGS} -env win32"
586                 AC_MSG_RESULT([need -env win32])
587             else
588                 AC_MSG_RESULT([none needed])
589             fi
590             ;;
591         x86_64-*)
592             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
593             ;;
594         *)
595             AC_MSG_RESULT([none needed])
596             ;;
597         esac
599         # Identify which version of the SDK we're building with
600         # Windows Server 2008 and newer SDKs have WinSDKVer.h, get the version
601         # from there
602         MOZ_CHECK_HEADERS([winsdkver.h])
603         if test "$ac_cv_header_winsdkver_h" = "yes"; then
604             # Get the highest _WIN32_WINNT and NTDDI versions supported
605             # Take the higher of the two
606             # This is done because the Windows 7 beta SDK reports its
607             # NTDDI_MAXVER to be 0x06000100 instead of 0x06010000, as it should
608             AC_CACHE_CHECK(for highest Windows version supported by this SDK,
609                            ac_cv_winsdk_maxver,
610                            [cat > conftest.h <<EOF
611 #include <winsdkver.h>
612 #include <sdkddkver.h>
614 #if (NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER) > NTDDI_MAXVER)
615 #define WINSDK_MAXVER NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER)
616 #else
617 #define WINSDK_MAXVER NTDDI_MAXVER
618 #endif
620 WINSDK_MAXVER
622                             ac_cv_winsdk_maxver=`$CPP conftest.h 2>/dev/null | tail -n1`
623                             rm -f conftest.h
624                            ])
625             MOZ_WINSDK_MAXVER=${ac_cv_winsdk_maxver}
626         else
627             # Any SDK which doesn't have WinSDKVer.h is too old.
628             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.])
629         fi
631         unset _MSVC_VER_FILTER
633         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
634             [
635                 AC_LANG_SAVE
636                 AC_LANG_CPLUSPLUS
637                 _SAVE_CXXFLAGS="$CXXFLAGS"
638                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
639                 AC_TRY_COMPILE([#include <exception>],
640                             [std::_Throw(std::exception()); return 0;],
641                             ac_cv_have_std__Throw="yes",
642                             ac_cv_have_std__Throw="no")
643                 CXXFLAGS="$_SAVE_CXXFLAGS"
644                 AC_LANG_RESTORE
645             ])
647         if test "$ac_cv_have_std__Throw" = "yes"; then
648             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
649                            ac_cv_have_dllimport_exception_bug,
650                 [
651                     AC_LANG_SAVE
652                     AC_LANG_CPLUSPLUS
653                     _SAVE_CXXFLAGS="$CXXFLAGS"
654                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
655                     AC_TRY_LINK([#include <vector>],
656                                 [std::vector<int> v; return v.at(1);],
657                                 ac_cv_have_dllimport_exception_bug="no",
658                                 ac_cv_have_dllimport_exception_bug="yes")
659                     CXXFLAGS="$_SAVE_CXXFLAGS"
660                     AC_LANG_RESTORE
661                 ])
662             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
663                 WRAP_STL_INCLUDES=1
664                 MOZ_MSVC_STL_WRAP__Throw=1
665                 AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
666             fi
667         else
668             AC_CACHE_CHECK(for overridable _RAISE,
669                            ac_cv_have__RAISE,
670                 [
671                     AC_LANG_SAVE
672                     AC_LANG_CPLUSPLUS
673                     _SAVE_CXXFLAGS="$CXXFLAGS"
674                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
675                     AC_TRY_COMPILE([#include <xstddef>
676                                     #undef _RAISE
677                                     #define _RAISE(x) externallyDefinedFunction((x).what())
678                                     #include <vector>
679                                    ],
680                                    [std::vector<int> v; return v.at(1);],
681                                    ac_cv_have__RAISE="no",
682                                    ac_cv_have__RAISE="yes")
683                     CXXFLAGS="$_SAVE_CXXFLAGS"
684                     AC_LANG_RESTORE
685                 ])
686             if test "$ac_cv_have__RAISE" = "yes"; then
687                 WRAP_STL_INCLUDES=1
688                 MOZ_MSVC_STL_WRAP__RAISE=1
689                 AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
690             else
691                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
692             fi
693         fi
695         if test "$WRAP_STL_INCLUDES" = "1"; then
696             STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
697         fi
698     else
699         # Check w32api version
700         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
701         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
702         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
703         AC_TRY_COMPILE([#include <w32api.h>],
704             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
705                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
706                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
707                 #error "test failed."
708             #endif
709             , [ res=yes ], [ res=no ])
710         AC_MSG_RESULT([$res])
711         if test "$res" != "yes"; then
712             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
713         fi
714         # Check windres version
715         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
716         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
717         AC_MSG_RESULT([$_WINDRES_VERSION])
718         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
719         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
720         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
721         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
722         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
723         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
724         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
725                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
726                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
727                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
728                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
729                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
730         then
731             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
732         fi
734         AC_CHECK_PROGS(MIDL, $target-widl widl)
735         if test -n "$MIDL"; then
736             case "$target" in
737             i*86-*)
738                 MIDL_FLAGS="$MIDL_FLAGS --win32 -m32"
739                 ;;
740             x86_64-*)
741                 MIDL_FLAGS="$MIDL_FLAGS --win64 -m64"
742                 ;;
743             esac
744         fi
746         MOZ_WINSDK_MAXVER=0x06020000
747     fi # !GNU_CC
749     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
750     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
751     # Require OS features provided by IE 6.0 SP2 (XP SP2)
752     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
754     # If the maximum version supported by this SDK is lower than the target
755     # version, error out
756     AC_MSG_CHECKING([for Windows SDK being recent enough])
757     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
758         AC_MSG_RESULT("yes")
759     else
760         AC_MSG_RESULT("no")
761         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.])
762     fi
763     
764     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
765     # Definitions matching sdkddkver.h
766     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
767     ;;
768 esac
770 AC_PROG_CPP
771 AC_PROG_CXXCPP
773 if test -n "$_WIN32_MSVC"; then
774     SKIP_PATH_CHECKS=1
775     SKIP_COMPILER_CHECKS=1
776     SKIP_LIBRARY_CHECKS=1
778     # Since we're skipping compiler and library checks, hard-code
779     # some facts here.
780     AC_DEFINE(HAVE_IO_H)
781     AC_DEFINE(HAVE_SETBUF)
782     AC_DEFINE(HAVE_ISATTY)
785 fi # COMPILE_ENVIRONMENT
787 AC_SUBST(MIDL_FLAGS)
788 AC_SUBST(_MSC_VER)
790 AC_SUBST(GNU_AS)
791 AC_SUBST(GNU_LD)
792 AC_SUBST(GNU_CC)
793 AC_SUBST(GNU_CXX)
794 AC_SUBST(INTEL_CC)
795 AC_SUBST(INTEL_CXX)
797 AC_SUBST(STL_FLAGS)
798 AC_SUBST(WRAP_STL_INCLUDES)
799 AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
800 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
802 dnl ========================================================
803 dnl Checks for programs.
804 dnl ========================================================
805 AC_PROG_INSTALL
806 AC_PROG_LN_S
808 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
809 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
810 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
811 _perl_res=$?
812 AC_MSG_RESULT([$_perl_version])
814 if test "$_perl_res" != 0; then
815     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
819 AC_MSG_CHECKING([for full perl installation])
820 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
821 _perl_res=$?
822 if test "$_perl_res" != 0; then
823     AC_MSG_RESULT([no])
824     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
825 else
826     AC_MSG_RESULT([yes])
829 MOZ_ARG_WITH_BOOL(system-ply,
830 [  --with-system-ply       Use system installed python ply library],
831     [if $PYTHON -c 'import ply' 2>&5; then
832          MOZ_SYSTEM_PLY=1
833      else
834          AC_MSG_ERROR([python ply library is not found but --with-system-ply was requested])
835      fi])
837 AC_SUBST(MOZ_SYSTEM_PLY)
839 if test -z "$COMPILE_ENVIRONMENT"; then
840     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
842 AC_SUBST(NSINSTALL_BIN)
844 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
845 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
846 MOZ_PATH_PROGS(UNZIP, unzip)
847 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
848     AC_MSG_ERROR([unzip not found in \$PATH])
850 MOZ_PATH_PROGS(ZIP, zip)
851 if test -z "$ZIP" -o "$ZIP" = ":"; then
852     AC_MSG_ERROR([zip not found in \$PATH])
854 MOZ_PATH_PROG(XARGS, xargs)
855 if test -z "$XARGS" -o "$XARGS" = ":"; then
856     AC_MSG_ERROR([xargs not found in \$PATH .])
859 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
860 AC_SUBST(RPMBUILD)
862 if test "$COMPILE_ENVIRONMENT"; then
864 dnl ========================================================
865 dnl = Mac OS X toolchain support
866 dnl ========================================================
868 case "$target_os" in
869 darwin*)
870     dnl Current known valid versions for GCC_VERSION are 2.95.2 3.1 3.3 4.0.
871     dnl 4.0 identifies itself as 4.0.x, so strip the decidecimal for
872     dnl the environment and includedir purposes (when using an SDK, below),
873     dnl but remember the full version number for the libdir (SDK).
874     changequote(,)
875     GCC_VERSION_FULL=`echo $CXX_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
876     GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
877     changequote([,])
878     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
879         dnl Bug 280479, but this keeps popping up in bug 292530 too because
880         dnl 4.0.0/4061 is the default compiler in Tiger.
881         changequote(,)
882         GCC_BUILD=`echo $CXX_VERSION | $PERL -pe 's/^.*build ([^ )]*).*/$1/'`
883         changequote([,])
884         if test "$GCC_BUILD" = "4061" ; then
885             AC_MSG_ERROR([You are attempting to use Apple gcc 4.0 build 4061.
886 This compiler was supplied with Xcode 2.0, and contains bugs that prevent it
887 from building Mozilla. Upgrade to Xcode 2.1 or later.])
888         fi
889     fi
891     dnl xcodebuild needs GCC_VERSION defined in the environment, since it
892     dnl doesn't respect the CC/CXX setting.  With GCC_VERSION set, it will use
893     dnl /usr/bin/g(cc|++)-$GCC_VERSION.
894     MOZ_PATH_PROGS(PBBUILD_BIN, pbbuild xcodebuild pbxbuild)
896     dnl sdp was formerly in /Developer/Tools.  As of Mac OS X 10.4 (Darwin 8),
897     dnl it has moved into /usr/bin.
898     MOZ_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
899     ;;
900 esac
902 AC_SUBST(GCC_VERSION)
904 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
905 dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
906 dnl when we can run target binaries.
907 AC_SUBST(UNIVERSAL_BINARY)
908 AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
910 dnl ========================================================
911 dnl Check for MacOS deployment target version
912 dnl ========================================================
914 MOZ_ARG_ENABLE_STRING(macos-target,
915                       [  --enable-macos-target=VER (default=10.6)
916                           Set the minimum MacOS version needed at runtime],
917                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
919 case "$target" in
920 *-darwin*)
921     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
922         dnl Use the specified value
923         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
924     else
925         dnl No value specified on the command line or in the environment,
926         dnl use architecture minimum.
927         export MACOSX_DEPLOYMENT_TARGET=10.6
928     fi
929     ;;
930 esac
932 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
934 dnl ========================================================
935 dnl = Mac OS X SDK support
936 dnl ========================================================
937 MACOS_SDK_DIR=
938 NEXT_ROOT=
939 MOZ_ARG_WITH_STRING(macos-sdk,
940 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
941     MACOS_SDK_DIR=$withval)
943 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
944 dnl NEXT_ROOT will be set and exported only if it's needed.
945 AC_SUBST(MACOS_SDK_DIR)
946 AC_SUBST(NEXT_ROOT)
948 if test "$MACOS_SDK_DIR"; then
949   dnl Sync this section with the ones in NSPR and NSS.
950   dnl Changes to the cross environment here need to be accounted for in
951   dnl the libIDL checks (below) and xpidl build.
953   if test ! -d "$MACOS_SDK_DIR"; then
954     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
955 specify a valid SDK.  SDKs are installed when the optional cross-development
956 tools are selected during the Xcode/Developer Tools installation.])
957   fi
959   GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
960   if test "$GCC_VERSION_MAJOR" -lt "4" ; then
961     AC_MSG_ERROR([You need to upgrade the compiler version to 4.x])
962   else
963     CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
964     CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
966     dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
967     CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
968     CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
970     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
971       dnl If gcc >= 4.0, we're guaranteed to be on Tiger, which has an ld
972       dnl that supports -syslibroot.  Don't set NEXT_ROOT because it will
973       dnl be ignored and cause warnings when -syslibroot is specified.
974       dnl gcc 4.0.1 will pass -syslibroot to ld automatically based on
975       dnl the -isysroot it receives, so this is only needed with 4.0.0.
976       LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
977     fi
978   fi
980   AC_LANG_SAVE
981   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
982   AC_LANG_CPLUSPLUS
983   AC_TRY_COMPILE([#include <new>],[],
984    result=yes,
985    result=no)
986   AC_LANG_RESTORE
987   AC_MSG_RESULT($result)
989   if test "$result" = "no" ; then
990     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
991   fi
994 fi # COMPILE_ENVIRONMENT
996 AC_MSG_CHECKING([compiler version])
997 # Just print it so it shows up in the logs.
998 cc_version=$($CC --version)
999 AC_MSG_RESULT([$cc_version])
1001 if test -n "$MAKE"; then
1002   if test `echo $MAKE | grep -c make.py` != 1; then
1003      NOT_PYMAKE=$MAKE
1004   fi
1007 case "$host_os" in
1008 mingw*)
1009     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
1010     ;;
1012     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
1013     ;;
1014 esac
1015 if test "$GMAKE" = ":"; then
1016    AC_MSG_ERROR([GNU make not found])
1018 AC_SUBST(GMAKE)
1020 if test -z "$MAKE"; then
1021   MAKE=$GMAKE
1024 if test "$COMPILE_ENVIRONMENT"; then
1026 AC_PATH_XTRA
1028 XCFLAGS="$X_CFLAGS"
1030 fi # COMPILE_ENVIRONMENT
1032 dnl ========================================================
1033 dnl set the defaults first
1034 dnl ========================================================
1035 AS_BIN=$AS
1036 AR_LIST='$(AR) t'
1037 AR_EXTRACT='$(AR) x'
1038 AR_DELETE='$(AR) d'
1039 AS='$(CC)'
1040 AS_DASH_C_FLAG='-c'
1041 DLL_PREFIX=lib
1042 LIB_PREFIX=lib
1043 DLL_SUFFIX=.so
1044 OBJ_SUFFIX=o
1045 LIB_SUFFIX=a
1046 ASM_SUFFIX=s
1047 IMPORT_LIB_SUFFIX=
1048 TARGET_MD_ARCH=unix
1049 DIRENT_INO=d_ino
1050 MOZ_USER_DIR=".mozilla"
1052 MOZ_JPEG_CFLAGS=
1053 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)'
1054 MOZ_BZ2_CFLAGS=
1055 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
1056 MOZ_PNG_CFLAGS=
1057 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
1059 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
1060 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
1061 DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core -lmozalloc'
1062 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
1063 XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom -lmozalloc'
1064 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
1065 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
1066 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
1068 # These are specially defined on Windows only
1069 case "$target" in
1070 *-mingw*)
1071   XPCOM_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
1072   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime.$(LIB_SUFFIX)'
1073   ;;
1075   XPCOM_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_GLUE_LDOPTS
1076   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_STANDALONE_GLUE_LDOPTS
1077   ;;
1078 esac
1080 MOZ_FS_LAYOUT=unix
1082 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
1084 USE_DEPENDENT_LIBS=1
1086 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
1088 if test -n "$CROSS_COMPILE"; then
1089     OS_TARGET="${target_os}"
1090     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
1091     OS_RELEASE=
1092     case "${target_os}" in
1093         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
1094         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
1095         gnu*)         OS_ARCH=GNU ;;
1096         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
1097         mingw*)       OS_ARCH=WINNT OS_TARGET=WINNT ;;
1098         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
1099     esac
1100     case "${target}" in
1101         *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
1102     esac
1103 else
1104     OS_TARGET=`uname -s`
1105     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
1106     OS_RELEASE=`uname -r`
1109 # Before this used `uname -m` when not cross compiling
1110 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
1111 OS_TEST="${target_cpu}"
1113 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
1115 #######################################################################
1116 # Master "Core Components" macros for getting the OS target           #
1117 #######################################################################
1120 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
1121 # cross-compilation.
1125 # Define and override various archtecture-specific variables, including
1126 # HOST_OS_ARCH
1127 # OS_ARCH
1128 # OS_TEST
1129 # OS_TARGET
1130 # OS_RELEASE
1131 # OS_MINOR_RELEASE
1134 case "$HOST_OS_ARCH" in
1135 mingw*)
1136     HOST_OS_ARCH=WINNT
1137     ;;
1138 darwin*)
1139     HOST_OS_ARCH=Darwin
1140     ;;
1141 linux*)
1142     HOST_OS_ARCH=Linux
1143     ;;
1144 solaris*)
1145     HOST_OS_ARCH=SunOS
1146     SOLARIS_SUNPRO_CC=
1147     SOLARIS_SUNPRO_CXX=
1148     if test -z "$GNU_CC"; then
1149         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1150             SOLARIS_SUNPRO_CC=1
1151        fi
1152     fi
1154     if test -z "$GNU_CXX"; then
1155        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1156            SOLARIS_SUNPRO_CXX=1
1157        fi
1158     fi
1159     AC_SUBST(SOLARIS_SUNPRO_CC)
1160     AC_SUBST(SOLARIS_SUNPRO_CXX)
1161     ;;
1162 OS_2)
1163     HOST_OS_ARCH=OS2
1164     ;;
1165 esac
1167 case "$OS_ARCH" in
1168 WINNT)
1169     if test -z "$CROSS_COMPILE" ; then
1170         OS_TEST=`uname -p`
1171     fi
1172     ;;
1173 Windows_NT)
1175 # If uname -s returns "Windows_NT", we assume that we are using
1176 # the uname.exe in MKS toolkit.
1178 # The -r option of MKS uname only returns the major version number.
1179 # So we need to use its -v option to get the minor version number.
1180 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1182     OS_ARCH=WINNT
1183     OS_TARGET=WINNT
1184     OS_MINOR_RELEASE=`uname -v`
1185     if test "$OS_MINOR_RELEASE" = "00"; then
1186         OS_MINOR_RELEASE=0
1187     fi
1188     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1189     ;;
1190 MINGW*_NT*)
1192 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1193 # the uname.exe in the MSYS tools.
1195     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1196     OS_ARCH=WINNT
1197     OS_TARGET=WINNT
1198     ;;
1199 AIX)
1200     OS_RELEASE=`uname -v`.`uname -r`
1201     OS_TEST=${target_cpu}
1202     ;;
1203 OS_2)
1204     OS_ARCH=OS2
1205     OS_TARGET=OS2
1206     OS_RELEASE=`uname -v`
1207     ;;
1208 Darwin)
1209     case "${target_cpu}" in
1210     powerpc*)
1211         OS_TEST=ppc
1212         ;;
1213     i*86*)
1214         OS_TEST=i386
1215         ;;
1216     x86_64)
1217         OS_TEST=x86_64
1218         ;;
1219     *)
1220         if test -z "$CROSS_COMPILE" ; then
1221             OS_TEST=`uname -p`
1222         fi
1223         ;;
1224     esac
1225     ;;
1226 esac
1228 # Only set CPU_ARCH if we recognize the value of OS_TEST
1230 case "$OS_TEST" in
1231 *86 | i86pc)
1232     CPU_ARCH=x86
1233     ;;
1235 powerpc64 | ppc64)
1236     CPU_ARCH=ppc64
1237     ;;
1239 powerpc | ppc | rs6000)
1240     CPU_ARCH=ppc
1241     ;;
1243 Alpha | alpha | ALPHA)
1244     CPU_ARCH=Alpha
1245     ;;
1247 s390)
1248     CPU_ARCH=s390
1249     ;;
1251 s390x)
1252     CPU_ARCH=s390x
1253     ;;
1255 hppa* | parisc)
1256     CPU_ARCH=hppa
1257     ;;
1259 sun4u | sparc*)
1260     CPU_ARCH=sparc
1261     ;;
1263 x86_64 | ia64)
1264     CPU_ARCH="$OS_TEST"
1265     ;;
1267 arm*)
1268     CPU_ARCH=arm
1269     ;;
1271 mips|mipsel)
1272     CPU_ARCH="mips"
1273     ;;
1274 esac
1276 if test -z "$OS_TARGET"; then
1277     OS_TARGET=$OS_ARCH
1279 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1281 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1282 dnl ===============================================================
1283 INTEL_ARCHITECTURE=
1284 case "$OS_TEST" in
1285     x86_64|i?86)
1286       INTEL_ARCHITECTURE=1
1287 esac
1289 dnl Configure platform-specific CPU architecture compiler options.
1290 dnl ==============================================================
1291 MOZ_ARCH_OPTS
1293 dnl =================================================================
1294 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1295 dnl which is bad when cross compiling.
1296 dnl =================================================================
1297 if test "$COMPILE_ENVIRONMENT"; then
1298 configure_static_assert_macros='
1299 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1300 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1301 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1304 dnl test that the macros actually work:
1305 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1306 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1307  [AC_LANG_SAVE
1308   AC_LANG_C
1309   ac_cv_static_assertion_macros_work="yes"
1310   AC_TRY_COMPILE([$configure_static_assert_macros],
1311                  [CONFIGURE_STATIC_ASSERT(1)],
1312                  ,
1313                  ac_cv_static_assertion_macros_work="no")
1314   AC_TRY_COMPILE([$configure_static_assert_macros],
1315                  [CONFIGURE_STATIC_ASSERT(0)],
1316                  ac_cv_static_assertion_macros_work="no",
1317                  )
1318   AC_LANG_CPLUSPLUS
1319   AC_TRY_COMPILE([$configure_static_assert_macros],
1320                  [CONFIGURE_STATIC_ASSERT(1)],
1321                  ,
1322                  ac_cv_static_assertion_macros_work="no")
1323   AC_TRY_COMPILE([$configure_static_assert_macros],
1324                  [CONFIGURE_STATIC_ASSERT(0)],
1325                  ac_cv_static_assertion_macros_work="no",
1326                  )
1327   AC_LANG_RESTORE
1328  ])
1329 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1330 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1331     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1333 fi # COMPILE_ENVIRONMENT
1335 dnl ========================================================
1336 dnl Android libstdc++, placed here so it can use MOZ_ARCH
1337 dnl computed above.
1338 dnl ========================================================
1340 MOZ_ANDROID_STLPORT
1342 dnl ========================================================
1343 dnl Suppress Clang Argument Warnings
1344 dnl ========================================================
1345 if test -n "$CLANG_CC"; then
1346     _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
1347     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
1349 if test -n "$CLANG_CXX"; then
1350     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
1353 dnl ========================================================
1354 dnl = Use Address Sanitizer
1355 dnl ========================================================
1356 MOZ_ARG_ENABLE_BOOL(address-sanitizer,
1357 [  --enable-address-sanitizer       Enable Address Sanitizer (default=no)],
1358     MOZ_ASAN=1,
1359     MOZ_ASAN= )
1360 if test -n "$MOZ_ASAN"; then
1361     MOZ_LLVM_HACKS=1
1362     AC_DEFINE(MOZ_ASAN)
1364 AC_SUBST(MOZ_ASAN)
1366 dnl ========================================================
1367 dnl = Enable hacks required for LLVM instrumentations
1368 dnl ========================================================
1369 MOZ_ARG_ENABLE_BOOL(llvm-hacks,
1370 [  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)],
1371     MOZ_LLVM_HACKS=1,
1372     MOZ_LLVM_HACKS= )
1373 if test -n "$MOZ_LLVM_HACKS"; then
1374     MOZ_NO_WLZDEFS=1
1375     MOZ_CFLAGS_NSS=1
1377 AC_SUBST(MOZ_NO_WLZDEFS)
1378 AC_SUBST(MOZ_CFLAGS_NSS)
1380 dnl ========================================================
1381 dnl GNU specific defaults
1382 dnl ========================================================
1383 if test "$GNU_CC"; then
1384     # Per bug 719659 comment 2, some of the headers on ancient build machines
1385     # may require gnu89 inline semantics.  But otherwise, we use C99.
1386     CFLAGS="$CFLAGS -std=gnu99 -fgnu89-inline"
1387     # FIXME: Let us build with strict aliasing. bug 414641.
1388     CFLAGS="$CFLAGS -fno-strict-aliasing"
1389     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1390     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1391     DSO_LDOPTS='-shared'
1392     if test "$GCC_USE_GNU_LD"; then
1393         # Some tools like ASan use a runtime library that is only
1394         # linked against executables, so we must allow undefined
1395         # symbols for shared objects in some cases.
1396         if test -z "$MOZ_NO_WLZDEFS"; then
1397             # Don't allow undefined symbols in libraries
1398             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1399         fi
1400     fi
1401     WARNINGS_AS_ERRORS='-Werror -Wno-error=uninitialized'
1402     DSO_CFLAGS=''
1403     DSO_PIC_CFLAGS='-fPIC'
1404     ASFLAGS="$ASFLAGS -fPIC"
1405     AC_MSG_CHECKING([for --noexecstack option to as])
1406     _SAVE_CFLAGS=$CFLAGS
1407     CFLAGS="$CFLAGS -Wa,--noexecstack"
1408     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
1409                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
1410                      AC_MSG_RESULT([no]))
1411     CFLAGS=$_SAVE_CFLAGS
1412     AC_MSG_CHECKING([for -z noexecstack option to ld])
1413     _SAVE_LDFLAGS=$LDFLAGS
1414     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
1415     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
1416                   AC_MSG_RESULT([no])
1417                   LDFLAGS=$_SAVE_LDFLAGS)
1418     AC_MSG_CHECKING([for --build-id option to ld])
1419     _SAVE_LDFLAGS=$LDFLAGS
1420     LDFLAGS="$LDFLAGS -Wl,--build-id"
1421     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1422                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,--build-id"],
1423                   AC_MSG_RESULT([no])
1424                   LDFLAGS=$_SAVE_LDFLAGS)
1427     # Check for -mssse3 on $CC
1428     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
1429     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
1430     _SAVE_CFLAGS=$CFLAGS
1431     CFLAGS="$CFLAGS -mssse3"
1432     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
1433                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
1434                      AC_MSG_RESULT([no]))
1435     CFLAGS=$_SAVE_CFLAGS
1436     AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
1438     # Turn on GNU-specific warnings:
1439     # -Wall - turn on a lot of warnings
1440     # -pedantic - this is turned on below
1441     # -Wpointer-arith - enabled with -pedantic, but good to have even if not
1442     # -Wdeclaration-after-statement - MSVC doesn't like these
1443     # -Werror=return-type - catches missing returns, zero false positives
1444     # -Wtype-limits - catches overflow bugs, few false positives
1445     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1446     #
1447     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
1448     MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
1449     MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
1450     MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
1451     
1452     # Turn off the following warnings that -Wall/-pedantic turn on:
1453     # -Wno-unused - lots of violations in third-party code
1454     # -Wno-overlength-strings - we exceed the minimum maximum length frequently
1455     #
1456     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
1457     MOZ_C_SUPPORTS_WARNING(-Wno-, overlength-strings, ac_c_has_wno_overlength_strings)
1459     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
1460        # Don't use -Wcast-align with ICC or clang
1461        case "$CPU_ARCH" in
1462            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1463            hppa | ia64 | sparc | arm)
1464            ;;
1465            *)
1466         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1467            ;;
1468        esac
1469     fi
1471     dnl Turn pedantic on but disable the warnings for long long
1472     _PEDANTIC=1
1474     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1475     _USE_CPP_INCLUDE_FLAG=1
1477 elif test "$SOLARIS_SUNPRO_CC"; then
1478     DSO_CFLAGS=''
1479     if test "$CPU_ARCH" = "sparc"; then
1480         # for Sun Studio on Solaris/SPARC
1481         DSO_PIC_CFLAGS='-xcode=pic32'
1482     else
1483         DSO_PIC_CFLAGS='-KPIC'
1484     fi
1485     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1486 else
1487     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1488     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1490     DSO_LDOPTS='-shared'
1491     if test "$GNU_LD"; then
1492         # Don't allow undefined symbols in libraries
1493         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1494     fi
1496     DSO_CFLAGS=''
1497     DSO_PIC_CFLAGS='-KPIC'
1498     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1501 if test "$GNU_CXX"; then
1502     # FIXME: Let us build with strict aliasing. bug 414641.
1503     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
1505     # Turn on GNU-specific warnings:
1506     # -Wall - turn on a lot of warnings
1507     # -pedantic - this is turned on below
1508     # -Wpointer-arith - enabled with -pedantic, but good to have even if not
1509     # -Woverloaded-virtual - ???
1510     # -Werror=return-type - catches missing returns, zero false positives
1511     # -Wtype-limits - catches overflow bugs, few false positives
1512     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1513     #
1514     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
1515     MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
1516     MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
1517     MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
1519     # Turn off the following warnings that -Wall/-pedantic turn on:
1520     # -Wno-ctor-dtor-privacy - ???
1521     # -Wno-overlength-strings - we exceed the minimum maximum length frequently 
1522     # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
1523     # -Wno-variadic-macros - ???
1524     #
1525     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-ctor-dtor-privacy"
1526     MOZ_CXX_SUPPORTS_WARNING(-Wno-, overlength-strings, ac_cxx_has_wno_overlength_strings)
1527     MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
1528     MOZ_CXX_SUPPORTS_WARNING(-Wno-, variadic-macros, ac_cxx_has_wno_variadic_macros)
1530     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
1531        # Don't use -Wcast-align with ICC or clang
1532        case "$CPU_ARCH" in
1533            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1534            hppa | ia64 | sparc | arm)
1535            ;;
1536            *)
1537         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1538            ;;
1539        esac
1540     fi
1542     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1543     _USE_CPP_INCLUDE_FLAG=1
1545     # Recent clang and gcc support C++11 deleted functions without warnings if
1546     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
1547     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
1548     # unused.  But clang's warning can be disabled, so when compiling with clang
1549     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
1550     # deleted function syntax.
1551     if test "$CLANG_CXX"; then
1552         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
1553         MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
1554     fi
1556 else
1557     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
1560 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1561 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1562 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1563 dnl normal behavior.
1564 dnl ========================================================
1565 MKSHLIB_FORCE_ALL=
1566 MKSHLIB_UNFORCE_ALL=
1568 if test "$COMPILE_ENVIRONMENT"; then
1569 if test "$GNU_CC"; then
1570   AC_MSG_CHECKING(whether ld has archive extraction flags)
1571   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1572    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1573     ac_cv_mkshlib_force_and_unforce="no"
1574     exec 3<&0 <<LOOP_INPUT
1575         force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1576         force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1577         force="-Wl,-all";              unforce="-Wl,-none"
1578 LOOP_INPUT
1579     while read line
1580     do
1581       eval $line
1582       LDFLAGS=$force
1583       LIBS=$unforce
1584       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1585     done
1586     exec 0<&3 3<&-
1587     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1588    ])
1589   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1590     AC_MSG_RESULT(no)
1591   else
1592     AC_MSG_RESULT(yes)
1593     eval $ac_cv_mkshlib_force_and_unforce
1594     MKSHLIB_FORCE_ALL=$force
1595     MKSHLIB_UNFORCE_ALL=$unforce
1596   fi
1597 fi # GNU_CC
1598 fi # COMPILE_ENVIRONMENT
1600 dnl ========================================================
1601 dnl Checking for 64-bit OS
1602 dnl ========================================================
1603 if test "$COMPILE_ENVIRONMENT"; then
1604 AC_LANG_SAVE
1605 AC_LANG_C
1606 AC_MSG_CHECKING(for 64-bit OS)
1607 AC_TRY_COMPILE([$configure_static_assert_macros],
1608                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1609                result="yes", result="no")
1610 AC_MSG_RESULT("$result")
1611 if test "$result" = "yes"; then
1612     AC_DEFINE(HAVE_64BIT_OS)
1613     HAVE_64BIT_OS=1
1615 AC_SUBST(HAVE_64BIT_OS)
1616 AC_LANG_RESTORE
1617 fi # COMPILE_ENVIRONMENT
1619 dnl ========================================================
1620 dnl Enable high-memory support on OS/2 by default.
1621 dnl ========================================================
1622 MOZ_OS2_HIGH_MEMORY=1
1623 MOZ_ARG_DISABLE_BOOL(os2-high-mem,
1624 [  --disable-os2-high-mem  Disable high-memory support on OS/2],
1625     MOZ_OS2_HIGH_MEMORY=,
1626     MOZ_OS2_HIGH_MEMORY=1 )
1627 AC_SUBST(MOZ_OS2_HIGH_MEMORY)
1629 dnl ========================================================
1630 dnl = Use profiling compile flags
1631 dnl ========================================================
1632 MOZ_ARG_ENABLE_BOOL(profiling,
1633 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1634     MOZ_PROFILING=1,
1635     MOZ_PROFILING= )
1637 # For profiling builds keep the symbol information
1638 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
1639     case "$OS_TARGET" in
1640     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
1641         STRIP_FLAGS="--strip-debug"
1642         ;;
1643     esac
1646 dnl ========================================================
1647 dnl = Use incremental GC
1648 dnl ========================================================
1649 JSGC_INCREMENTAL=1
1650 MOZ_ARG_DISABLE_BOOL(gcincremental,
1651 [  --disable-gcincremental Disable incremental GC],
1652     JSGC_INCREMENTAL= )
1653 if test -n "$JSGC_INCREMENTAL"; then
1654     AC_DEFINE(JSGC_INCREMENTAL)
1657 dnl ========================================================
1658 dnl = Use generational GC
1659 dnl ========================================================
1660 MOZ_ARG_ENABLE_BOOL(gcgenerational,
1661 [  --enable-gcgenerational Enable generational GC],
1662     JSGC_GENERATIONAL=1,
1663     JSGC_GENERATIONAL= )
1664 if test -n "$JSGC_GENERATIONAL"; then
1665     AC_DEFINE(JSGC_GENERATIONAL)
1668 dnl ========================================================
1669 dnl = Perform moving GC stack rooting analysis
1670 dnl ========================================================
1671 MOZ_ARG_ENABLE_BOOL(root-analysis,
1672 [  --enable-root-analysis  Enable moving GC stack root analysis],
1673     JSGC_ROOT_ANALYSIS=1,
1674     JSGC_ROOT_ANALYSIS= )
1675 if test -n "$JSGC_ROOT_ANALYSIS"; then
1676     AC_DEFINE(JSGC_ROOT_ANALYSIS)
1679 dnl ========================================================
1680 dnl = Use exact stack rooting for GC
1681 dnl ========================================================
1682 MOZ_ARG_ENABLE_BOOL(exact-rooting,
1683 [  --enable-exact-rooting  Enable use of exact stack roots for GC],
1684     JSGC_USE_EXACT_ROOTING=1,
1685     JSGC_USE_EXACT_ROOTING= )
1686 if test -n "$JSGC_USE_EXACT_ROOTING"; then
1687     AC_DEFINE(JSGC_USE_EXACT_ROOTING)
1690 dnl ========================================================
1691 dnl = Use Valgrind
1692 dnl ========================================================
1693 MOZ_ARG_ENABLE_BOOL(valgrind,
1694 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
1695     MOZ_VALGRIND=1,
1696     MOZ_VALGRIND= )
1697 if test -n "$MOZ_VALGRIND"; then
1698     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1699         AC_MSG_ERROR(
1700             [--enable-valgrind specified but Valgrind is not installed]))
1701     AC_DEFINE(MOZ_VALGRIND)
1703 AC_SUBST(MOZ_VALGRIND)
1705 dnl ========================================================
1706 dnl jprof
1707 dnl ========================================================
1708 MOZ_ARG_ENABLE_BOOL(jprof,
1709 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
1710     MOZ_JPROF=1,
1711     MOZ_JPROF= )
1712 if test -n "$MOZ_JPROF"; then
1713     MOZ_PROFILING=1
1714     AC_DEFINE(MOZ_JPROF)
1717 dnl ========================================================
1718 dnl SPS Profiler
1719 dnl ========================================================
1720 MOZ_ENABLE_PROFILER_SPS=1
1722 case "${OS_TARGET}" in
1723 Android)
1724     case "${CPU_ARCH}" in
1725     x86 | arm) ;;
1726     *)
1727         MOZ_ENABLE_PROFILER_SPS=
1728     esac
1729     ;;
1730 Linux)
1731     case "${CPU_ARCH}" in
1732     x86 | x86_64) ;;
1733     *)
1734         MOZ_ENABLE_PROFILER_SPS=
1735     esac
1736     ;;
1737 WINNT|Darwin) ;;
1739     MOZ_ENABLE_PROFILER_SPS=
1740     ;;
1741 esac
1743 if test -n "$MOZ_ENABLE_PROFILER_SPS"; then
1744     AC_DEFINE(MOZ_ENABLE_PROFILER_SPS)
1747 dnl ========================================================
1748 dnl shark
1749 dnl ========================================================
1750 MOZ_ARG_ENABLE_BOOL(shark,
1751 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
1752     MOZ_SHARK=1,
1753     MOZ_SHARK= )
1754 if test -n "$MOZ_SHARK"; then
1755     MOZ_PROFILING=1
1756     AC_DEFINE(MOZ_SHARK)
1759 dnl ========================================================
1760 dnl callgrind
1761 dnl ========================================================
1762 MOZ_ARG_ENABLE_BOOL(callgrind,
1763 [  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.],
1764     MOZ_CALLGRIND=1,
1765     MOZ_CALLGRIND= )
1766 if test -n "$MOZ_CALLGRIND"; then
1767     MOZ_PROFILING=1
1768     AC_DEFINE(MOZ_CALLGRIND)
1771 dnl ========================================================
1772 dnl vtune
1773 dnl ========================================================
1774 MOZ_ARG_ENABLE_BOOL(vtune,
1775 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
1776     MOZ_VTUNE=1,
1777     MOZ_VTUNE= )
1778 if test -n "$MOZ_VTUNE"; then
1779     MOZ_PROFILING=1
1780     AC_DEFINE(MOZ_VTUNE)
1783 dnl ========================================================
1784 dnl Profiling
1785 dnl ========================================================
1786 if test -n "$MOZ_PROFILING"; then
1787     AC_DEFINE(MOZ_PROFILING)
1790 dnl ========================================================
1791 dnl System overrides of the defaults for host
1792 dnl ========================================================
1793 case "$host" in
1794 *mingw*)
1795     if test -n "$_WIN32_MSVC"; then
1796         HOST_AR=lib
1797         HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
1798         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
1799         HOST_RANLIB='echo ranlib'
1800     else
1801         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
1802     fi
1803     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
1804     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1805     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1806     HOST_BIN_SUFFIX=.exe
1807     case "$host" in
1808     *mingw*)
1809         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1810         ;;
1811     esac
1813     case "${host_cpu}" in
1814     i*86)
1815         if test -n "$_WIN32_MSVC"; then
1816             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
1817         fi
1818         ;;
1819     x86_64)
1820         if test -n "$_WIN32_MSVC"; then
1821             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
1822         fi
1823         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1824         ;;
1825     esac
1826     ;;
1828 *-darwin*)
1829     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1830     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1831     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1832     ;;
1834 *-linux*|*-kfreebsd*-gnu|*-gnu*)
1835     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1836     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1837     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1838     ;;
1840 *os2*)
1841     HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
1842     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
1843     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1844     HOST_BIN_SUFFIX=.exe
1845     MOZ_FIX_LINK_PATHS=
1846     ;;
1849     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1850     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1851     ;;
1852 esac
1854 dnl Check for using a custom <stdint.h> implementation
1855 dnl ========================================================
1856 AC_MSG_CHECKING(for custom <stdint.h> implementation)
1857 if test "$MOZ_CUSTOM_STDINT_H"; then
1858   AC_DEFINE_UNQUOTED(MOZ_CUSTOM_STDINT_H, "$MOZ_CUSTOM_STDINT_H")
1859   AC_MSG_RESULT(using $MOZ_CUSTOM_STDINT_H)
1860 else
1861   AC_MSG_RESULT(none specified)
1864 dnl Get mozilla version from central milestone file
1865 MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
1866 MOZILLA_UAVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -uaversion`
1868 dnl Get version of various core apps from the version files.
1869 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
1871 if test -z "$FIREFOX_VERSION"; then
1872     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
1875 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
1876 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
1877 AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
1879 MOZ_DOING_LTO(lto_is_enabled)
1881 dnl ========================================================
1882 dnl System overrides of the defaults for target
1883 dnl ========================================================
1885 case "$target" in
1886 *-aix*)
1887     AC_DEFINE(AIX)
1888     if test ! "$GNU_CC"; then
1889         if test ! "$HAVE_64BIT_OS"; then
1890             # Compiling with Visual Age C++ object model compat is the
1891             # default. To compile with object model ibm, add
1892             # AIX_OBJMODEL=ibm to .mozconfig.
1893             if test "$AIX_OBJMODEL" = "ibm"; then
1894                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
1895             else
1896                 AIX_OBJMODEL=compat
1897             fi
1898         else
1899             AIX_OBJMODEL=compat
1900         fi
1901         AC_SUBST(AIX_OBJMODEL)
1902         DSO_LDOPTS='-qmkshrobj=1'
1903         DSO_CFLAGS='-qflag=w:w'
1904         DSO_PIC_CFLAGS=
1905         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
1906         MOZ_FIX_LINK_PATHS=
1907         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1908         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1909         if test "$COMPILE_ENVIRONMENT"; then
1910             AC_LANG_SAVE
1911             AC_LANG_CPLUSPLUS
1912             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
1913             AC_TRY_COMPILE([],
1914                 [#if (__IBMCPP__ < 900)
1915                  #error "Bad compiler"
1916                  #endif],
1917                 _BAD_COMPILER=,_BAD_COMPILER=1)
1918             if test -n "$_BAD_COMPILER"; then
1919                 AC_MSG_RESULT([no])
1920                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
1921             else
1922                 AC_MSG_RESULT([yes])
1923             fi
1924             AC_LANG_RESTORE
1925             TARGET_COMPILER_ABI="ibmc"
1926             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
1927             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
1928         fi
1929     fi
1930     case "${target_os}" in
1931     aix4.1*)
1932         DLL_SUFFIX='_shr.a'
1933         ;;
1934     esac
1935     if test "$COMPILE_ENVIRONMENT"; then
1936         MOZ_CHECK_HEADERS(sys/inttypes.h)
1937     fi
1938     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1939     ;;
1941 *-darwin*)
1942     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1943     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1944     MOZ_OPTIMIZE_FLAGS="-O3"
1945     _PEDANTIC=
1946     # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
1947     if test "$HAVE_64BIT_OS"; then
1948         MOZ_MEMORY=1
1949     fi
1950     DLL_SUFFIX=".dylib"
1951     DSO_LDOPTS=''
1952     STRIP_FLAGS="$STRIP_FLAGS -x -S"
1953     # Check whether we're targeting OS X or iOS
1954     AC_CACHE_CHECK(for iOS target,
1955                    ac_cv_ios_target,
1956                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
1957 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
1958 #error not iOS
1959 #endif],
1960                                    [],
1961                                    ac_cv_ios_target="yes",
1962                                    ac_cv_ios_target="no")])
1963     if test "$ac_cv_ios_target" = "yes"; then
1964         AC_DEFINE(XP_IOS)
1965         AC_DEFINE(XP_DARWIN)
1966         _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
1967     else
1968         AC_DEFINE(XP_MACOSX)
1969         AC_DEFINE(XP_DARWIN)
1970         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
1971         # The ExceptionHandling framework is needed for Objective-C exception
1972         # logging code in nsObjCExceptions.h. Currently we only use that in debug
1973         # builds.
1974         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
1975     fi
1976     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1979     if test "x$lto_is_enabled" = "xyes"; then
1980         echo "Skipping -dead_strip because lto is enabled."
1981     dnl DTrace and -dead_strip don't interact well. See bug 403132.
1982     dnl ===================================================================
1983     elif test "x$enable_dtrace" = "xyes"; then
1984         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
1985     else
1986         dnl check for the presence of the -dead_strip linker flag
1987         AC_MSG_CHECKING([for -dead_strip option to ld])
1988         _SAVE_LDFLAGS=$LDFLAGS
1989         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
1990         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
1991         if test -n "$_HAVE_DEAD_STRIP" ; then
1992             AC_MSG_RESULT([yes])
1993             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
1994         else
1995             AC_MSG_RESULT([no])
1996         fi
1998         LDFLAGS=$_SAVE_LDFLAGS
1999     fi
2001     dnl With newer linkers we need to pass -allow_heap_execute because of
2002     dnl Microsoft Silverlight (5.1.10411.0 at least).
2003     AC_MSG_CHECKING([for -allow_heap_execute option to ld])
2004     _SAVE_LDFLAGS=$LDFLAGS
2005     LDFLAGS="$LDFLAGS -Wl,-allow_heap_execute"
2006     AC_TRY_LINK(,[return 0;],_HAVE_ALLOW_HEAP_EXECUTE=1,
2007                 _HAVE_ALLOW_HEAP_EXECUTE=)
2008     if test -n "$_HAVE_ALLOW_HEAP_EXECUTE" ; then
2009         AC_MSG_RESULT([yes])
2010         MOZ_ALLOW_HEAP_EXECUTE_FLAGS="-Wl,-allow_heap_execute"
2011     else
2012         AC_MSG_RESULT([no])
2013     fi
2014     LDFLAGS=$_SAVE_LDFLAGS
2016     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
2017     ;;
2019 ia64*-hpux*)
2020     DLL_SUFFIX=".so"
2021     if test ! "$GNU_CC"; then
2022        DSO_LDOPTS='-b'
2023        DSO_CFLAGS=""
2024        DSO_PIC_CFLAGS=
2025        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
2026        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
2027        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2028     else
2029        DSO_LDOPTS='-b -E'
2030        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2031        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2032     fi
2033     MOZ_FIX_LINK_PATHS=
2034     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2035     AC_DEFINE(_LARGEFILE64_SOURCE)
2036     ;;
2038 *-hpux*)
2039     DLL_SUFFIX=".sl"
2040     if test ! "$GNU_CC"; then
2041         DSO_LDOPTS='-b -Wl,+s'
2042         DSO_CFLAGS=""
2043         DSO_PIC_CFLAGS="+Z"
2044         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
2045         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
2046         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2047     else
2048         DSO_LDOPTS='-b -E +s'
2049         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2050         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2051     fi
2052     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
2053     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2054     ;;
2056 *-android*|*-linuxandroid*)
2057     AC_DEFINE(NO_PW_GECOS)
2058     no_x=yes
2059     if test -n "$gonkdir"; then
2060         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
2061         MOZ_B2G_RIL=1
2062         MOZ_B2G_BT=1
2063         MOZ_B2G_FM=1
2064     else
2065         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
2066         MOZ_LINKER=1
2067     fi
2068     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2070     MOZ_GFX_OPTIMIZE_MOBILE=1
2071     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
2072     ;;
2074 *-*linux*)
2075     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2076     # Similarly for GNU_CXX and INTEL_CXX.
2077     if test "$INTEL_CC" -o "$INTEL_CXX"; then
2078         # -Os has been broken on Intel's C/C++ compilers for quite a
2079         # while; Intel recommends against using it.
2080         MOZ_OPTIMIZE_FLAGS="-O2"
2081         MOZ_DEBUG_FLAGS="-g"
2082     elif test "$GNU_CC" -o "$GNU_CXX"; then
2083         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2084         case $GCC_VERSION in
2085         4.1.*|4.2.*|4.5.*)
2086             # -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
2087             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
2088         esac
2089         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
2090         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
2091         MOZ_DEBUG_FLAGS="-g"
2092     fi
2094     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2096     MOZ_MEMORY=1
2098     case "${target_cpu}" in
2099     alpha*)
2100         CFLAGS="$CFLAGS -mieee"
2101         CXXFLAGS="$CXXFLAGS -mieee"
2102     ;;
2103     i*86)
2104         USE_ELF_DYNSTR_GC=1
2105     ;;
2106     mips*)
2107         MOZ_DEBUG_FLAGS="-g" # We want inlining
2108     ;;
2109     esac
2111     if test -z "$MC"; then
2112         MC=mc.exe
2113     fi
2114     ;;
2115 *-mingw*)
2116     DSO_CFLAGS=
2117     DSO_PIC_CFLAGS=
2118     DLL_SUFFIX=.dll
2119     RC=rc.exe
2120     MC=mc.exe
2121     # certain versions of cygwin's makedepend barf on the
2122     # #include <string> vs -I./dist/include/string issue so don't use it
2123     if test -n "$GNU_CC"; then
2124         CC="$CC -mwindows"
2125         CXX="$CXX -mwindows"
2126         CPP="$CPP -mwindows"
2127         CFLAGS="$CFLAGS -mms-bitfields"
2128         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2129         DSO_LDOPTS='-shared'
2130         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2131         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2132         RC='$(WINDRES)'
2133         # Use temp file for windres (bug 213281)
2134         RCFLAGS='-O coff --use-temp-file'
2135         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2136         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32 -lnetapi32"
2137         MOZ_FIX_LINK_PATHS=
2138         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
2139         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
2140         DLL_PREFIX=
2141         IMPORT_LIB_SUFFIX=dll.a
2142         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2144         # We use mix of both POSIX and Win32 printf format across the tree, so format
2145         # warnings are useless on mingw.
2146         MOZ_C_SUPPORTS_WARNING(-Wno-, format, ac_c_has_wno_format)
2147         MOZ_CXX_SUPPORTS_WARNING(-Wno-, format, ac_cxx_has_wno_format)
2148     else
2149         TARGET_COMPILER_ABI=msvc
2150         HOST_CC='$(CC)'
2151         HOST_CXX='$(CXX)'
2152         HOST_LD='$(LD)'
2153         if test "$AS_BIN"; then
2154             AS="$(basename "$AS_BIN")"
2155         fi
2156         AR='lib'
2157         AR_FLAGS='-NOLOGO -OUT:"$@"'
2158         AR_EXTRACT=
2159         RANLIB='echo not_ranlib'
2160         STRIP='echo not_strip'
2161         PKG_SKIP_STRIP=1
2162         XARGS=xargs
2163         ZIP=zip
2164         UNZIP=unzip
2165         DOXYGEN=:
2166         ASM_SUFFIX=asm
2167         OBJ_SUFFIX=obj
2168         LIB_SUFFIX=lib
2169         DLL_PREFIX=
2170         LIB_PREFIX=
2171         IMPORT_LIB_SUFFIX=lib
2172         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2173         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2174         MKSHLIB_FORCE_ALL=
2175         MKSHLIB_UNFORCE_ALL=
2176         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2177         _USE_CPP_INCLUDE_FLAG=1
2178         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2179         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2180         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2181         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2182         # MSVC warning C4345 warns of newly conformant behavior as of VS2003.
2183         # MSVC warning C4351 warns of newly conformant behavior as of VS2005.
2184         # MSVC warning C4800 warns when a value is implicitly cast to bool,
2185         # because this also forces narrowing to a single byte, which can be a
2186         # perf hit.  But this matters so little in practice (and often we want
2187         # that behavior) that it's better to turn it off.
2188         # MSVC warning C4819 warns some UTF-8 characters (e.g. copyright sign)
2189         # on non-Western system locales even if it is in a comment.
2190         CFLAGS="$CFLAGS -wd4819"
2191         CXXFLAGS="$CXXFLAGS -wd4345 -wd4351 -wd4800 -wd4819"
2192         # make 'foo == bar;' error out
2193         CFLAGS="$CFLAGS -we4553"
2194         CXXFLAGS="$CXXFLAGS -we4553"
2195         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib netapi32.lib"
2196         MOZ_DEBUG_FLAGS='-Zi'
2197         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2198         WARNINGS_AS_ERRORS='-WX'
2199         MOZ_OPTIMIZE_FLAGS='-O1'
2200         MOZ_FIX_LINK_PATHS=
2201         DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2202         XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2203         LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2204         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2205         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2206         dnl For profile-guided optimization
2207         PROFILE_GEN_CFLAGS="-GL"
2208         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2209         dnl XXX: PGO builds can fail with warnings treated as errors,
2210         dnl specifically "no profile data available" appears to be
2211         dnl treated as an error sometimes. This might be a consequence
2212         dnl of using WARNINGS_AS_ERRORS in some modules, combined
2213         dnl with the linker doing most of the work in the whole-program
2214         dnl optimization/PGO case. I think it's probably a compiler bug,
2215         dnl but we work around it here.
2216         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2217         dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2218         dnl Probably also a compiler bug, but what can you do?
2219         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2220         LDFLAGS="$LDFLAGS -DYNAMICBASE"
2221     fi
2222     AC_DEFINE(HAVE_SNPRINTF)
2223     AC_DEFINE(_WINDOWS)
2224     AC_DEFINE(WIN32)
2225     AC_DEFINE(XP_WIN)
2226     AC_DEFINE(XP_WIN32)
2227     AC_DEFINE(HW_THREADS)
2228     AC_DEFINE(STDC_HEADERS)
2229     AC_DEFINE(NEW_H, <new>)
2230     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2231     TARGET_MD_ARCH=win32
2232     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2233     BIN_SUFFIX='.exe'
2234     MOZ_USER_DIR="Mozilla"
2236     dnl Hardcode to win95 for now - cls
2237     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2239     dnl set NO_X11 defines here as the general check is skipped on win32
2240     no_x=yes
2241     AC_DEFINE(NO_X11)
2243     case "$host" in
2244     *-mingw*)
2245         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2246         L10NBASEDIR=`cd $L10NBASEDIR && pwd -W`
2247         ;;
2248     esac
2250     case "$host" in
2251     *-mingw*)
2252         if test -z "$MOZ_TOOLS"; then
2253             AC_MSG_ERROR([MOZ_TOOLS is not set])
2254         fi
2255         MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2256         if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2257             AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2258         fi
2259         MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2260         if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2261             AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2262         fi
2263         ;;
2264     esac
2266     case "$host_os" in
2267     cygwin*|msvc*|mks*)
2268         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.])
2269         ;;
2270     esac
2272     case "$target" in
2273     i*86-*)
2274         if test "$HAVE_64BIT_OS"; then
2275             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2276         fi
2278         if test -n "$GNU_CC"; then
2279             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
2280             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
2281             LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup"
2282         else
2283             AC_DEFINE(HAVE_STDCALL)
2284             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
2285             LDFLAGS="$LDFLAGS -SAFESEH"
2286         fi
2288         AC_DEFINE(_X86_)
2289         ;;
2290     x86_64-*)
2291         if test -n "$_WIN32_MSVC"; then
2292             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
2293         fi
2294         AC_DEFINE(_AMD64_)
2295         ;;
2296     *)
2297         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2298         ;;
2299     esac
2301     if test "$HAVE_64BIT_OS"; then
2302         AC_DEFINE(_WIN64)
2303     fi
2304     ;;
2306 *-netbsd*)
2307     DSO_CFLAGS=''
2308     CFLAGS="$CFLAGS -Dunix"
2309     CXXFLAGS="$CXXFLAGS -Dunix"
2310     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2311         DLL_SUFFIX=".so"
2312         DSO_PIC_CFLAGS='-fPIC -DPIC'
2313         DSO_LDOPTS='-shared'
2314         BIN_FLAGS='-Wl,--export-dynamic'
2315     else
2316         DSO_PIC_CFLAGS='-fPIC -DPIC'
2317         DLL_SUFFIX=".so.1.0"
2318         DSO_LDOPTS='-shared'
2319     fi
2320     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2321     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2322     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2323     if test "$LIBRUNPATH"; then
2324         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2325     fi
2326     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2327     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2328     ;;
2330 *-openbsd*)
2331     if test "$SO_VERSION"; then
2332         DLL_SUFFIX=".so.$SO_VERSION"
2333     else
2334         DLL_SUFFIX=".so.1.0"
2335     fi
2336     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
2337     DSO_CFLAGS=''
2338     DSO_PIC_CFLAGS='-fPIC'
2339     DSO_LDOPTS='-shared -fPIC'
2340     if test "$LIBRUNPATH"; then
2341         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2342     fi
2343     ;;
2345 *-os2*)
2346     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2347     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2348     AC_DEFINE(OS2)
2349     AC_DEFINE(XP_OS2)
2350     AC_DEFINE(OS2EMX_PLAIN_CHAR)
2351     AC_DEFINE(TCPV40HDRS)
2352     DLL_PREFIX=
2353     LIB_PREFIX=
2354     LIB_SUFFIX=lib
2355     BIN_SUFFIX=".exe"
2356     DLL_SUFFIX=".dll"
2357     IMPORT_LIB_SUFFIX=lib
2358     DSO_PIC_CFLAGS=
2359     AR=emxomfar
2360     AR_FLAGS='r $@'
2361     CFLAGS="$CFLAGS -Zomf"
2362     CXXFLAGS="$CXXFLAGS -Zomf"
2363     DSO_LDOPTS='-Zdll'
2364     BIN_FLAGS='-Zlinker /ST:0x100000'
2365     IMPLIB='emximp -o'
2366     FILTER='true'
2367     LDFLAGS='-Zmap'
2368     WARNINGS_AS_ERRORS='-Werror'
2369     MOZ_DEBUG_FLAGS="-g -fno-inline"
2370     MOZ_OPTIMIZE_FLAGS="-O2"
2371     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2372     DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2373     LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2374     TARGET_MD_ARCH=os2
2375     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
2376     RC=rc.exe
2377     MC=mc.exe
2378     RCFLAGS='-n'
2379     MOZ_USER_DIR="Mozilla"
2380     ZIP="$ZIP -X"
2382     if test "$MOZTOOLS"; then
2383         MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
2384     else
2385         AC_MSG_ERROR([MOZTOOLS is not set])
2386     fi
2387     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2388         DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2389         LDFLAGS="$LDFLAGS -Zhigh-mem"
2390         MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
2391         AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2392     fi
2394     # GCC for OS/2 currently predefines these, but we don't want them
2395     _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
2396     _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
2398     AC_CACHE_CHECK(for __declspec(dllexport),
2399         ac_os2_declspec,
2400         [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
2401                         [return 0;],
2402                         ac_os2_declspec="yes",
2403                         ac_os2_declspec="no")])
2404     if test "$ac_os2_declspec" != "yes"; then
2405         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
2406     fi
2407     ;;
2409 *-solaris*)
2410     AC_DEFINE(SOLARIS)
2411     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2412     MOZ_FIX_LINK_PATHS=
2413     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2414     # libraries one level up (e.g. libnspr4.so)
2415     if test "$SOLARIS_SUNPRO_CC"; then
2416        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2417        LIBS="-lCrun -lCstd -lc $LIBS"
2418        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2419        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2420        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2421        LDFLAGS="-xildoff $LDFLAGS"
2422        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2423            _SAVE_LDFLAGS=$LDFLAGS
2424            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
2425            AC_TRY_LINK([#include <stdio.h>],
2426                        [printf("Hello World\n");],
2427                        ,
2428                        [LDFLAGS=$_SAVE_LDFLAGS])
2429        fi
2430        MOZ_OPTIMIZE_FLAGS="-xO4"
2431        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2432        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2433        MKSHLIB_FORCE_ALL='-z allextract'
2434        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2435        DSO_LDOPTS='-G'
2436        AR_LIST="$AR t"
2437        AR_EXTRACT="$AR x"
2438        AR_DELETE="$AR d"
2439        AR='$(CXX) -xar'
2440        AR_FLAGS='-o $@'
2441        AS='/usr/ccs/bin/as'
2442        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2443        AS_DASH_C_FLAG=''
2444        TARGET_COMPILER_ABI="sunc"
2445        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2446        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2447        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2448        AC_LANG_SAVE
2449        AC_LANG_CPLUSPLUS
2450        AC_TRY_COMPILE([],
2451            [#if (__SUNPRO_CC < 0x590)
2452            #error "Denied"
2453            #endif],
2454            _BAD_COMPILER=,_BAD_COMPILER=1)
2455        if test -n "$_BAD_COMPILER"; then
2456            _res="no"
2457            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2458        else
2459            _res="yes"
2460        fi
2461        AC_TRY_COMPILE([],
2462            [#if (__SUNPRO_CC >= 0x5100)
2463            #error "Sun C++ 5.10 or above"
2464            #endif],
2465            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2466        if test "$_ABOVE_SS12U1"; then
2467            # disable xannotate
2468            CXXFLAGS="$CXXFLAGS -xannotate=no"
2469        fi
2470        AC_MSG_RESULT([$_res])
2471        AC_LANG_RESTORE
2472     else
2473        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2474        LIBS="-lc $LIBS"
2475        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2476        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2477        ASFLAGS="$ASFLAGS -fPIC"
2478        DSO_LDOPTS='-shared'
2479        WARNINGS_AS_ERRORS='-Werror'
2480        _WARNINGS_CFLAGS=''
2481        _WARNINGS_CXXFLAGS=''
2482        if test "$OS_RELEASE" = "5.3"; then
2483            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2484        fi
2485     fi
2486     if test "$OS_RELEASE" = "5.5.1"; then
2487         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2488     fi
2489     ;;
2491 *-sunos*)
2492     DSO_LDOPTS='-Bdynamic'
2493     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2494     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2495     AC_DEFINE(SUNOS4)
2496     AC_DEFINE(SPRINTF_RETURNS_STRING)
2497     case "$(target_os)" in
2498     sunos4.1*)
2499         DLL_SUFFIX='.so.1.0'
2500         ;;
2501     esac
2502     ;;
2504 *-os2*)
2505     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2506     ;;
2508 esac
2510 AC_SUBST(MOZ_LINKER)
2511 if test -n "$MOZ_LINKER"; then
2512   AC_DEFINE(MOZ_LINKER)
2514 AC_SUBST(MOZ_ENABLE_SZIP)
2516 dnl Only one oddball right now (QNX), but this gives us flexibility
2517 dnl if any other platforms need to override this in the future.
2518 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2520 dnl ========================================================
2521 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2522 dnl by now will not have any way to link most binaries (tests
2523 dnl as well as viewer, apprunner, etc.), because some symbols
2524 dnl will be left out of the "composite" .so's by ld as unneeded.
2525 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2526 dnl they can link in the static libs that provide the missing
2527 dnl symbols.
2528 dnl ========================================================
2529 NO_LD_ARCHIVE_FLAGS=
2530 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2531     NO_LD_ARCHIVE_FLAGS=1
2533 case "$target" in
2534 *-os2*)
2535     NO_LD_ARCHIVE_FLAGS=
2536     ;;
2537 *-aix4.3*|*-aix5*)
2538     NO_LD_ARCHIVE_FLAGS=
2539     ;;
2540 *-mingw*)
2541     if test -z "$GNU_CC"; then
2542         NO_LD_ARCHIVE_FLAGS=
2543     fi
2544     ;;
2545 esac
2546 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2548 dnl ========================================================
2549 dnl = Flags to strip unused symbols from .so components and
2550 dnl = to export jemalloc symbols when linking a program
2551 dnl ========================================================
2552 case "$target" in
2553     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2554         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2555         ;;
2556     *-solaris*)
2557         if test -z "$GNU_CC"; then
2558          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2559         else
2560          if test -z "$GCC_USE_GNU_LD"; then
2561           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2562          else
2563           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2564          fi
2565         fi
2566         ;;
2567     *-darwin*)
2568         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2569         ;;
2570     *-mingw*)
2571         if test -n "$GNU_CC"; then
2572            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2573         fi
2574         ;;
2575 esac
2577 if test -z "$COMPILE_ENVIRONMENT"; then
2578     SKIP_COMPILER_CHECKS=1
2579     SKIP_LIBRARY_CHECKS=1
2582 MOZ_COMPILER_OPTS
2583 if test -z "$SKIP_COMPILER_CHECKS"; then
2584 dnl Checks for typedefs, structures, and compiler characteristics.
2585 dnl ========================================================
2586 AC_HEADER_STDC
2587 AC_C_CONST
2588 AC_TYPE_MODE_T
2589 AC_TYPE_OFF_T
2590 AC_TYPE_PID_T
2591 AC_TYPE_SIZE_T
2592 AC_LANG_CPLUSPLUS
2593 AC_MSG_CHECKING(for __stdcall)
2594 AC_CACHE_VAL(ac_cv___stdcall,
2595  [AC_TRY_COMPILE([template <typename Method> struct foo;
2596                   template <> struct foo<void (*)()> {};
2597                   template <> struct foo<void (__stdcall*)()> {};],
2598                  [],
2599                  [ac_cv___stdcall=true],
2600                  [ac_cv___stdcall=false])])
2601 if test "$ac_cv___stdcall" = true ; then
2602   AC_DEFINE(HAVE_STDCALL)
2603   AC_MSG_RESULT(yes)
2604 else
2605   AC_MSG_RESULT(no)
2607 AC_LANG_C
2608 AC_MSG_CHECKING(for ssize_t)
2609 AC_CACHE_VAL(ac_cv_type_ssize_t,
2610  [AC_TRY_COMPILE([#include <stdio.h>
2611                   #include <sys/types.h>],
2612                  [ssize_t foo = 0;],
2613                  [ac_cv_type_ssize_t=true],
2614                  [ac_cv_type_ssize_t=false])])
2615 if test "$ac_cv_type_ssize_t" = true ; then
2616   AC_DEFINE(HAVE_SSIZE_T)
2617   AC_MSG_RESULT(yes)
2618 else
2619   AC_MSG_RESULT(no)
2621 AC_STRUCT_ST_BLKSIZE
2622 AC_MSG_CHECKING(for siginfo_t)
2623 AC_CACHE_VAL(ac_cv_siginfo_t,
2624  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
2625                   #include <signal.h>],
2626                  [siginfo_t* info;],
2627                  [ac_cv_siginfo_t=true],
2628                  [ac_cv_siginfo_t=false])])
2629 if test "$ac_cv_siginfo_t" = true ; then
2630   AC_DEFINE(HAVE_SIGINFO_T)
2631   AC_MSG_RESULT(yes)
2632 else
2633   AC_MSG_RESULT(no)
2636 dnl Check for int64, uint, and uint_t.
2637 dnl ========================================================
2638 AC_MSG_CHECKING(for int64)
2639 AC_CACHE_VAL(ac_cv_int64,
2640  [AC_TRY_COMPILE([#include <stdio.h>
2641                   #include <sys/types.h>],
2642                  [int64 foo = 0;],
2643                  [ac_cv_int64=true],
2644                  [ac_cv_int64=false])])
2645 if test "$ac_cv_int64" = true ; then
2646   AC_DEFINE(HAVE_INT64)
2647   AC_MSG_RESULT(yes)
2648 else
2649   AC_MSG_RESULT(no)
2651 AC_MSG_CHECKING(for uint)
2652 AC_CACHE_VAL(ac_cv_uint,
2653  [AC_TRY_COMPILE([#include <stdio.h>
2654                   #include <sys/types.h>],
2655                  [uint foo = 0;],
2656                  [ac_cv_uint=true],
2657                  [ac_cv_uint=false])])
2658 if test "$ac_cv_uint" = true ; then
2659   AC_DEFINE(HAVE_UINT)
2660   AC_MSG_RESULT(yes)
2661 else
2662   AC_MSG_RESULT(no)
2664 AC_MSG_CHECKING(for uint_t)
2665 AC_CACHE_VAL(ac_cv_uint_t,
2666  [AC_TRY_COMPILE([#include <stdio.h>
2667                   #include <sys/types.h>],
2668                  [uint_t foo = 0;],
2669                  [ac_cv_uint_t=true],
2670                  [ac_cv_uint_t=false])])
2671 if test "$ac_cv_uint_t" = true ; then
2672   AC_DEFINE(HAVE_UINT_T)
2673   AC_MSG_RESULT(yes)
2674 else
2675   AC_MSG_RESULT(no)
2678 dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
2679 dnl are defined when compiling C++ but not C.  Since the result of this
2680 dnl test is used only in C++, do it in C++.
2681 AC_LANG_CPLUSPLUS
2683 AC_MSG_CHECKING(for uname.domainname)
2684 AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
2685     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2686         [ struct utsname *res; char *domain;
2687             (void)uname(res);  if (res != 0) { domain = res->domainname; } ],
2688         [ac_cv_have_uname_domainname_field=true],
2689         [ac_cv_have_uname_domainname_field=false])])
2691 if test "$ac_cv_have_uname_domainname_field" = "true"; then
2692     AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
2693     AC_MSG_RESULT(yes)
2694 else
2695     AC_MSG_RESULT(no)
2698 AC_MSG_CHECKING(for uname.__domainname)
2699 AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
2700     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2701         [ struct utsname *res; char *domain;
2702             (void)uname(res);  if (res != 0) { domain = res->__domainname; } ],
2703         [ac_cv_have_uname_us_domainname_field=true],
2704         [ac_cv_have_uname_us_domainname_field=false])])
2706 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
2707     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
2708     AC_MSG_RESULT(yes)
2709 else
2710     AC_MSG_RESULT(no)
2713 dnl Check whether we can use gcc's c++0x mode
2714 AC_LANG_CPLUSPLUS
2716 if test "$GNU_CXX"; then
2717     _SAVE_CXXFLAGS=$CXXFLAGS
2718     CXXFLAGS="$CXXFLAGS -std=gnu++0x"
2720     AC_CACHE_CHECK(for gcc c++0x headers bug without rtti,
2721         ac_cv_cxx0x_headers_bug,
2722         [AC_TRY_COMPILE([#include <memory>], [],
2723                         ac_cv_cxx0x_headers_bug="no",
2724                         ac_cv_cxx0x_headers_bug="yes")])
2725     CXXFLAGS="$_SAVE_CXXFLAGS"
2726     if test "$ac_cv_cxx0x_headers_bug" = "no"; then
2727         CXXFLAGS="$CXXFLAGS -std=gnu++0x"
2728     fi
2731 dnl Check for usable char16_t (2 bytes, unsigned)
2732 dnl (we might not need the unsignedness check anymore)
2733 AC_CACHE_CHECK(for usable char16_t (2 bytes, unsigned),
2734     ac_cv_have_usable_char16_t,
2735     [AC_TRY_COMPILE([$configure_static_assert_macros],
2736                     [CONFIGURE_STATIC_ASSERT(sizeof(char16_t) == 2);
2737                      CONFIGURE_STATIC_ASSERT(char16_t(-1) > char16_t(0));
2738                      CONFIGURE_STATIC_ASSERT(sizeof((u"hello")[0]) == 2);
2739                      CONFIGURE_STATIC_ASSERT(sizeof(u'a') == 2);
2740                      CONFIGURE_STATIC_ASSERT(u'\xFFFF' > u'\x0')],
2741                     ac_cv_have_usable_char16_t="yes",
2742                     ac_cv_have_usable_char16_t="no")])
2743 if test "$ac_cv_have_usable_char16_t" = "yes"; then
2744     AC_DEFINE(HAVE_CPP_CHAR16_T)
2745     HAVE_CPP_CHAR16_T=1
2746 elif test "$GNU_CXX"; then
2747     CXXFLAGS="$_SAVE_CXXFLAGS"
2750 dnl Check for usable wchar_t (2 bytes, unsigned)
2751 dnl (we really don't need the unsignedness check anymore)
2752 dnl ========================================================
2754 AC_CACHE_CHECK(for usable wchar_t (2 bytes, unsigned),
2755     ac_cv_have_usable_wchar_v2,
2756     [AC_TRY_COMPILE([#include <stddef.h>
2757                      $configure_static_assert_macros],
2758                     [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
2759                      CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
2760                     ac_cv_have_usable_wchar_v2="yes",
2761                     ac_cv_have_usable_wchar_v2="no")])
2762 if test "$ac_cv_have_usable_wchar_v2" = "yes"; then
2763     AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
2764     HAVE_CPP_2BYTE_WCHAR_T=1
2765 elif test "$ac_cv_have_usable_char16_t" != "yes"; then
2766 dnl This is really gcc-only
2767 dnl Do this test using CXX only since some versions of gcc
2768 dnl 2.95-2.97 have a signed wchar_t in c++ only and some versions
2769 dnl only have short-wchar support for c++.
2770 dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
2772     _SAVE_CXXFLAGS=$CXXFLAGS
2773     CXXFLAGS="$CXXFLAGS -fshort-wchar"
2775     AC_CACHE_CHECK(for compiler -fshort-wchar option,
2776         ac_cv_have_usable_wchar_option_v2,
2777         [AC_TRY_LINK([#include <stddef.h>
2778                       $configure_static_assert_macros],
2779                      [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
2780                       CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
2781                      ac_cv_have_usable_wchar_option_v2="yes",
2782                      ac_cv_have_usable_wchar_option_v2="no")])
2784     if test "$ac_cv_have_usable_wchar_option_v2" = "yes"; then
2785         AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
2786         HAVE_CPP_2BYTE_WCHAR_T=1
2787         if test "$OS_TARGET" = Android; then
2788             WCHAR_CFLAGS="-fshort-wchar -Wl,--no-wchar-size-warning"
2789             CXXFLAGS="$CXXFLAGS -Wl,--no-wchar-size-warning"
2790             CFLAGS="$CFLAGS -Wl,--no-wchar-size-warning"
2791             DSO_LDOPTS="$DSO_LDOPTS -Wl,--no-wchar-size-warning"
2792         else
2793             WCHAR_CFLAGS="-fshort-wchar"
2794         fi
2795     else
2796         CXXFLAGS=$_SAVE_CXXFLAGS
2797     fi
2800 AC_LANG_C
2802 dnl Check for .hidden assembler directive and visibility attribute.
2803 dnl Borrowed from glibc configure.in
2804 dnl ===============================================================
2805 if test "$GNU_CC"; then
2806   AC_CACHE_CHECK(for visibility(hidden) attribute,
2807                  ac_cv_visibility_hidden,
2808                  [cat > conftest.c <<EOF
2809                   int foo __attribute__ ((visibility ("hidden"))) = 1;
2811                   ac_cv_visibility_hidden=no
2812                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2813                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2814                       ac_cv_visibility_hidden=yes
2815                     fi
2816                   fi
2817                   rm -f conftest.[cs]
2818                  ])
2819   if test "$ac_cv_visibility_hidden" = "yes"; then
2820     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
2822     AC_CACHE_CHECK(for visibility(default) attribute,
2823                    ac_cv_visibility_default,
2824                    [cat > conftest.c <<EOF
2825                     int foo __attribute__ ((visibility ("default"))) = 1;
2827                     ac_cv_visibility_default=no
2828                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2829                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2830                         ac_cv_visibility_default=yes
2831                       fi
2832                     fi
2833                     rm -f conftest.[cs]
2834                    ])
2835     if test "$ac_cv_visibility_default" = "yes"; then
2836       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
2838       AC_CACHE_CHECK(for visibility pragma support,
2839                      ac_cv_visibility_pragma,
2840                      [cat > conftest.c <<EOF
2841 #pragma GCC visibility push(hidden)
2842                       int foo_hidden = 1;
2843 #pragma GCC visibility push(default)
2844                       int foo_default = 1;
2846                       ac_cv_visibility_pragma=no
2847                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2848                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
2849                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
2850                             ac_cv_visibility_pragma=yes
2851                           fi
2852                         fi
2853                       fi
2854                       rm -f conftest.[cs]
2855                     ])
2856       if test "$ac_cv_visibility_pragma" = "yes"; then
2857         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
2858                        ac_cv_have_visibility_class_bug,
2859                        [cat > conftest.c <<EOF
2860 #pragma GCC visibility push(hidden)
2861 struct __attribute__ ((visibility ("default"))) TestStruct {
2862   static void Init();
2864 __attribute__ ((visibility ("default"))) void TestFunc() {
2865   TestStruct::Init();
2868                        ac_cv_have_visibility_class_bug=no
2869                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2870                          ac_cv_have_visibility_class_bug=yes
2871                        else
2872                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
2873                            ac_cv_have_visibility_class_bug=yes
2874                          fi
2875                        fi
2876                        rm -rf conftest.{c,S}
2877                        ])
2879         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
2880                        ac_cv_have_visibility_builtin_bug,
2881                        [cat > conftest.c <<EOF
2882 #pragma GCC visibility push(hidden)
2883 #pragma GCC visibility push(default)
2884 #include <string.h>
2885 #pragma GCC visibility pop
2887 __attribute__ ((visibility ("default"))) void Func() {
2888   char c[[100]];
2889   memset(c, 0, sizeof(c));
2892                        ac_cv_have_visibility_builtin_bug=no
2893                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2894                          ac_cv_have_visibility_builtin_bug=yes
2895                        else
2896                          if test `grep -c "@PLT" conftest.S` = 0; then
2897                            ac_cv_visibility_builtin_bug=yes
2898                          fi
2899                        fi
2900                        rm -f conftest.{c,S}
2901                        ])
2902         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
2903                 "$ac_cv_have_visibility_class_bug" = "no"; then
2904           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
2905           WRAP_SYSTEM_INCLUDES=1
2906           STL_FLAGS='-I$(DIST)/stl_wrappers'
2907           WRAP_STL_INCLUDES=1
2908         else
2909           VISIBILITY_FLAGS='-fvisibility=hidden'
2910         fi # have visibility pragma bug
2911       fi   # have visibility pragma
2912     fi     # have visibility(default) attribute
2913   fi       # have visibility(hidden) attribute
2914 fi         # GNU_CC
2916 # visibility hidden flag for Sun Studio on Solaris
2917 if test "$SOLARIS_SUNPRO_CC"; then
2918 VISIBILITY_FLAGS='-xldscope=hidden'
2919 fi         # Sun Studio on Solaris
2921 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2922 AC_SUBST(VISIBILITY_FLAGS)
2924 MOZ_GCC_PR49911
2925 MOZ_GCC_PR39608
2926 MOZ_LLVM_PR8927
2928 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
2929 dnl ========================================================
2930 if test "$GNU_CC"; then
2931   CFLAGS_save="${CFLAGS}"
2932   CFLAGS="${CFLAGS} -Werror"
2933   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
2934                  ac_cv_force_align_arg_pointer,
2935                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
2936                                  [],
2937                                  ac_cv_force_align_arg_pointer="yes",
2938                                  ac_cv_force_align_arg_pointer="no")])
2939   CFLAGS="${CFLAGS_save}"
2940   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
2941     HAVE_GCC_ALIGN_ARG_POINTER=1
2942   else
2943     HAVE_GCC_ALIGN_ARG_POINTER=
2944   fi
2946 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
2948 dnl Checks for header files.
2949 dnl ========================================================
2950 AC_HEADER_DIRENT
2951 case "$target_os" in
2952 freebsd*|openbsd*)
2953 # for stuff like -lXshm
2954     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
2955     ;;
2956 esac
2957 MOZ_CHECK_COMMON_HEADERS
2959 dnl These are all the places some variant of statfs can be hiding.
2960 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
2962 dnl Quota support
2963 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
2964 MOZ_CHECK_HEADERS([linux/quota.h],,,[#include <sys/socket.h>])
2966 dnl SCTP support - needs various network include headers
2967 MOZ_CHECK_HEADERS([linux/if_addr.h linux/rtnetlink.h],,,[#include <sys/socket.h>])
2969 MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
2971 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
2972 AC_CACHE_CHECK(for sockaddr_in.sin_len,
2973                    ac_cv_sockaddr_in_sin_len,
2974                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2975                                     #include <sys/types.h>
2976                                     #endif
2977                                     #include <netinet/in.h>
2978                                     struct sockaddr_in x;
2979                                     void *foo = (void*) &x.sin_len;],
2980                                    [],
2981                                    [ac_cv_sockaddr_in_sin_len=true],
2982                                    [ac_cv_sockaddr_in_sin_len=false])])
2983 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
2984   AC_DEFINE(HAVE_SIN_LEN)
2985 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
2986   AC_DEFINE(HAVE_SCONN_LEN)
2989 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
2990                ac_cv_sockaddr_in6_sin6_len,
2991                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2992                                 #include <sys/types.h>
2993                                 #endif
2994                                 #include <netinet/in.h>
2995                                 struct sockaddr_in6 x;
2996                                 void *foo = (void*) &x.sin6_len;],
2997                                [],
2998                                [ac_cv_sockaddr_in6_sin6_len=true],
2999                                [ac_cv_sockaddr_in6_sin6_len=false])])
3000 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
3001   AC_DEFINE(HAVE_SIN6_LEN)
3004 AC_CACHE_CHECK(for sockaddr.sa_len,
3005                ac_cv_sockaddr_sa_len,
3006                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
3007                                 #include <sys/types.h>
3008                                 #endif
3009                                 #include <sys/socket.h>
3010                                 struct sockaddr x;
3011                                 void *foo = (void*) &x.sa_len;],
3012                                [],
3013                                [ac_cv_sockaddr_sa_len=true],
3014                                [ac_cv_sockaddr_sa_len=false])])
3015 if test "$ac_cv_sockaddr_sa_len" = true ; then
3016   AC_DEFINE(HAVE_SA_LEN)
3019 dnl Check whether the compiler supports the new-style C++ standard
3020 dnl library headers (i.e. <new>) or needs the old "new.h"
3021 AC_LANG_CPLUSPLUS
3022 NEW_H=new.h
3023 MOZ_CHECK_HEADER(new, [NEW_H=new])
3024 AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
3025 AC_LANG_C
3027 AC_ARG_ENABLE(dtrace,
3028               [  --enable-dtrace         build with dtrace support if available (default=no)],
3029               [enable_dtrace="yes"],)
3030 if test "x$enable_dtrace" = "xyes"; then
3031   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
3032   if test -n "$HAVE_DTRACE"; then
3033       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
3034   else
3035       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
3036   fi
3038 AC_SUBST(HAVE_DTRACE)
3040 case $target in
3041 *-aix4.3*|*-aix5*)
3042         ;;
3044         MOZ_CHECK_HEADERS(sys/cdefs.h)
3045         ;;
3046 esac
3048 MOZ_LINUX_PERF_EVENT
3050 dnl Checks for libraries.
3051 dnl ========================================================
3052 case $target in
3053 *-hpux11.*)
3054         ;;
3056         AC_CHECK_LIB(c_r, gethostbyname_r)
3057         ;;
3058 esac
3060 dnl We don't want to link with libdl even if it's present on OS X, since
3061 dnl it's not used and not part of the default installation. OS/2 has dlfcn
3062 dnl in libc.
3063 dnl We don't want to link against libm or libpthread on Darwin since
3064 dnl they both are just symlinks to libSystem and explicitly linking
3065 dnl against libSystem causes issues when debugging (see bug 299601).
3066 case $target in
3067 *-darwin*)
3068     ;;
3069 *-os2*)
3070     ;;
3072     AC_SEARCH_LIBS(dlopen, dl,
3073         MOZ_CHECK_HEADER(dlfcn.h,
3074         AC_DEFINE(HAVE_DLOPEN)))
3075     ;;
3076 esac
3078 _SAVE_CFLAGS="$CFLAGS"
3079 CFLAGS="$CFLAGS -D_GNU_SOURCE"
3080 AC_CHECK_FUNCS(dladdr memmem)
3081 CFLAGS="$_SAVE_CFLAGS"
3083 if test ! "$GNU_CXX"; then
3085     case $target in
3086     *-aix*)
3087         AC_CHECK_LIB(C_r, demangle)
3088         ;;
3089      *)
3090         AC_CHECK_LIB(C, demangle)
3091         ;;
3092      esac
3095 dnl OS/2 has socket in libc.
3096 case $target in
3097 *-os2*)
3098     ;;
3100     AC_CHECK_LIB(socket, socket)
3101 esac
3103 XLDFLAGS="$X_LIBS"
3104 XLIBS="$X_EXTRA_LIBS"
3106 dnl ========================================================
3107 dnl Checks for X libraries.
3108 dnl Ordering is important.
3109 dnl Xt is dependent upon SM as of X11R6
3110 dnl ========================================================
3111 if test "$no_x" = "yes"; then
3112     AC_DEFINE(NO_X11)
3113 else
3114     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
3115         XLIBS="-lX11 $XLIBS"
3116         _SAVE_LDFLAGS="$LDFLAGS"
3117         LDFLAGS="$XLDFLAGS $LDFLAGS"
3118         AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
3119                 [MISSING_X="$MISSING_X -lX11"], $XLIBS)
3120         AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
3121                 [MISSING_X="$MISSING_X -lXext"], $XLIBS)
3123         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
3124         unset ac_cv_lib_Xt_XtFree
3125             AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
3126             AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
3127         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
3128                     [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
3129         ])
3131     # AIX needs the motif library linked before libXt to prevent
3132     # crashes in plugins linked against Motif - Bug #98892
3133     case "${target_os}" in
3134     aix*)
3135         XT_LIBS="-lXm $XT_LIBS"
3136         ;;
3137     esac
3139     dnl ========================================================
3140     dnl = Check for XShm
3141     dnl ========================================================
3142     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
3143         $XLIBS $XEXT_LIBS)
3145     dnl ========================================================
3146     dnl = Check for Xss
3147     dnl ========================================================
3148     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
3149         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
3150             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
3151              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
3153         LDFLAGS="$_SAVE_LDFLAGS"
3154 fi # $no_x
3156 AC_SUBST(XCFLAGS)
3157 AC_SUBST(XLDFLAGS)
3158 AC_SUBST(XLIBS)
3159 AC_SUBST(XEXT_LIBS)
3160 AC_SUBST(XT_LIBS)
3161 AC_SUBST(XSS_LIBS)
3163 dnl ========================================================
3164 dnl = pthread support
3165 dnl = Start by checking whether the system support pthreads
3166 dnl ========================================================
3167 case "$target_os" in
3168 darwin*)
3169     USE_PTHREADS=1
3170     ;;
3172     MOZ_CHECK_PTHREADS(pthreads,
3173         USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
3174         MOZ_CHECK_PTHREADS(pthread,
3175             USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
3176             MOZ_CHECK_PTHREADS(c_r,
3177                 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
3178                 MOZ_CHECK_PTHREADS(c,
3179                     USE_PTHREADS=1
3180                 )
3181             )
3182         )
3183     )
3184     ;;
3185 esac
3187 dnl ========================================================
3188 dnl Check the command line for --with-pthreads
3189 dnl ========================================================
3190 MOZ_ARG_WITH_BOOL(pthreads,
3191 [  --with-pthreads         Force use of system pthread library with NSPR ],
3192 [ if test "$USE_PTHREADS"x = x; then
3193     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
3194 fi],
3195     USE_PTHREADS=
3196     _PTHREAD_LDFLAGS=
3199 dnl ========================================================
3200 dnl Do the platform specific pthread hackery
3201 dnl ========================================================
3202 if test "$USE_PTHREADS"x != x
3203 then
3204         dnl
3205         dnl See if -pthread is supported.
3206         dnl
3207         rm -f conftest*
3208         ac_cv_have_dash_pthread=no
3209         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
3210         echo 'int main() { return 0; }' | cat > conftest.c
3211         ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
3212         if test $? -eq 0; then
3213                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3214                         ac_cv_have_dash_pthread=yes
3215                 case "$target_os" in
3216                 freebsd*)
3217 # Freebsd doesn't use -pthread for compiles, it uses them for linking
3218                 ;;
3219                 *)
3220                             CFLAGS="$CFLAGS -pthread"
3221                             CXXFLAGS="$CXXFLAGS -pthread"
3222                 ;;
3223                 esac
3224                 fi
3225         fi
3226         rm -f conftest*
3227     AC_MSG_RESULT($ac_cv_have_dash_pthread)
3229         dnl
3230         dnl See if -pthreads is supported.
3231         dnl
3232     ac_cv_have_dash_pthreads=no
3233     if test "$ac_cv_have_dash_pthread" = "no"; then
3234             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
3235         echo 'int main() { return 0; }' | cat > conftest.c
3236             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
3237         if test $? -eq 0; then
3238                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3239                             ac_cv_have_dash_pthreads=yes
3240                             CFLAGS="$CFLAGS -pthreads"
3241                             CXXFLAGS="$CXXFLAGS -pthreads"
3242                     fi
3243             fi
3244             rm -f conftest*
3245         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
3246     fi
3248         case "$target" in
3249             *-*-freebsd*)
3250                         AC_DEFINE(_REENTRANT)
3251                         AC_DEFINE(_THREAD_SAFE)
3252                         dnl -pthread links in -lpthread, so don't specify it explicitly.
3253                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3254                                 _PTHREAD_LDFLAGS="-pthread"
3255                         fi
3256                         ;;
3258             *-*-openbsd*|*-*-bsdi*)
3259                         AC_DEFINE(_REENTRANT)
3260                         AC_DEFINE(_THREAD_SAFE)
3261                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3262                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3263                 _PTHREAD_LDFLAGS="-pthread"
3264                         fi
3265                         ;;
3267             *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3268                         AC_DEFINE(_REENTRANT)
3269                         ;;
3271             *-aix4.3*|*-aix5*)
3272                         AC_DEFINE(_REENTRANT)
3273                         ;;
3275             *-hpux11.*)
3276                         AC_DEFINE(_REENTRANT)
3277                         ;;
3279             *-*-solaris*)
3280                         AC_DEFINE(_REENTRANT)
3281                         if test "$SOLARIS_SUNPRO_CC"; then
3282                                 CFLAGS="$CFLAGS -mt"
3283                                 CXXFLAGS="$CXXFLAGS -mt"
3284                         fi
3285                         ;;
3286         esac
3287     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3291 dnl Checks for library functions.
3292 dnl ========================================================
3293 AC_PROG_GCC_TRADITIONAL
3294 AC_FUNC_MEMCMP
3295 AC_CHECK_FUNCS(random strerror lchown fchmod snprintf memmove rint stat64 lstat64 truncate64 setbuf isatty)
3296 AC_CHECK_FUNCS(statvfs64 statvfs statfs64 statfs)
3297 AC_CHECK_FUNCS(flockfile getpagesize)
3298 AC_CHECK_FUNCS(localtime_r strtok_r)
3300 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
3301 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
3302                ac_cv_clock_monotonic,
3303                [for libs in "" -lrt; do
3304                     _SAVE_LIBS="$LIBS"
3305                     LIBS="$LIBS $libs"
3306                     AC_TRY_LINK([#include <time.h>],
3307                                  [ struct timespec ts;
3308                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
3309                                  ac_cv_clock_monotonic=$libs
3310                                  LIBS="$_SAVE_LIBS"
3311                                  break,
3312                                  ac_cv_clock_monotonic=no)
3313                     LIBS="$_SAVE_LIBS"
3314                 done])
3315 if test "$ac_cv_clock_monotonic" != "no"; then
3316     HAVE_CLOCK_MONOTONIC=1
3317     REALTIME_LIBS=$ac_cv_clock_monotonic
3318     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3319     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3320     AC_SUBST(REALTIME_LIBS)
3323 dnl check for wcrtomb/mbrtowc
3324 dnl =======================================================================
3325 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3326 AC_LANG_SAVE
3327 AC_LANG_CPLUSPLUS
3328 AC_CACHE_CHECK(for wcrtomb,
3329     ac_cv_have_wcrtomb,
3330     [AC_TRY_LINK([#include <wchar.h>],
3331                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3332                  ac_cv_have_wcrtomb="yes",
3333                  ac_cv_have_wcrtomb="no")])
3334 if test "$ac_cv_have_wcrtomb" = "yes"; then
3335     AC_DEFINE(HAVE_WCRTOMB)
3337 AC_CACHE_CHECK(for mbrtowc,
3338     ac_cv_have_mbrtowc,
3339     [AC_TRY_LINK([#include <wchar.h>],
3340                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3341                  ac_cv_have_mbrtowc="yes",
3342                  ac_cv_have_mbrtowc="no")])
3343 if test "$ac_cv_have_mbrtowc" = "yes"; then
3344     AC_DEFINE(HAVE_MBRTOWC)
3346 AC_LANG_RESTORE
3349 AC_CACHE_CHECK(
3350     [for res_ninit()],
3351     ac_cv_func_res_ninit,
3352     [AC_TRY_LINK([
3353         #ifdef linux
3354         #define _BSD_SOURCE 1
3355         #endif
3356         #include <resolv.h>
3357         ],
3358         [int foo = res_ninit(&_res);],
3359         [ac_cv_func_res_ninit=yes],
3360         [ac_cv_func_res_ninit=no])
3361     ])
3363 if test "$ac_cv_func_res_ninit" = "yes"; then
3364     AC_DEFINE(HAVE_RES_NINIT)
3365 dnl must add the link line we do something as foolish as this... dougt
3366 dnl else
3367 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3368 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3371 AC_LANG_CPLUSPLUS
3372 AC_CACHE_CHECK(
3373     [for gnu_get_libc_version()],
3374     ac_cv_func_gnu_get_libc_version,
3375     [AC_TRY_LINK([
3376         #ifdef HAVE_GNU_LIBC_VERSION_H
3377         #include <gnu/libc-version.h>
3378         #endif
3379         ],
3380         [const char *glibc_version = gnu_get_libc_version();],
3381         [ac_cv_func_gnu_get_libc_version=yes],
3382         [ac_cv_func_gnu_get_libc_version=no]
3383         )]
3384     )
3386 if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
3387     AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
3390 case $target_os in
3391     darwin*|mingw*|os2*)
3392         ;;
3393     *)
3395 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3396     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3397         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3398 _SAVE_LIBS=$LIBS
3399 LIBS="$LIBS $_ICONV_LIBS"
3400 AC_CACHE_CHECK(
3401     [for iconv()],
3402     ac_cv_func_iconv,
3403     [AC_TRY_LINK([
3404         #include <stdlib.h>
3405         #include <iconv.h>
3406         ],
3407         [
3408             iconv_t h = iconv_open("", "");
3409             iconv(h, NULL, NULL, NULL, NULL);
3410             iconv_close(h);
3411         ],
3412         [ac_cv_func_iconv=yes],
3413         [ac_cv_func_iconv=no]
3414         )]
3415     )
3416 if test "$ac_cv_func_iconv" = "yes"; then
3417     AC_DEFINE(HAVE_ICONV)
3418     DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
3419     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3420     LIBICONV="$_ICONV_LIBS"
3421     AC_CACHE_CHECK(
3422         [for iconv() with const input],
3423         ac_cv_func_const_iconv,
3424         [AC_TRY_COMPILE([
3425             #include <stdlib.h>
3426             #include <iconv.h>
3427             ],
3428             [
3429                 const char *input = "testing";
3430                 iconv_t h = iconv_open("", "");
3431                 iconv(h, &input, NULL, NULL, NULL);
3432                 iconv_close(h);
3433             ],
3434             [ac_cv_func_const_iconv=yes],
3435             [ac_cv_func_const_iconv=no]
3436             )]
3437         )
3438     if test "$ac_cv_func_const_iconv" = "yes"; then
3439         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3440     fi
3442 LIBS=$_SAVE_LIBS
3444     ;;
3445 esac
3447 AM_LANGINFO_CODESET
3449 AC_LANG_C
3451 dnl **********************
3452 dnl *** va_copy checks ***
3453 dnl **********************
3454 dnl we currently check for all three va_copy possibilities, so we get
3455 dnl all results in config.log for bug reports.
3456 AC_MSG_CHECKING(for an implementation of va_copy())
3457 AC_CACHE_VAL(ac_cv_va_copy,[
3458     AC_TRY_RUN([
3459         #include <stdarg.h>
3460         void f (int i, ...) {
3461             va_list args1, args2;
3462             va_start (args1, i);
3463             va_copy (args2, args1);
3464             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3465                 exit (1);
3466             va_end (args1); va_end (args2);
3467         }
3468         int main() { f (0, 42); return 0; }],
3469         ac_cv_va_copy=yes,
3470         ac_cv_va_copy=no,
3471         ac_cv_va_copy=no
3472     )
3474 AC_MSG_RESULT($ac_cv_va_copy)
3475 AC_MSG_CHECKING(for an implementation of __va_copy())
3476 AC_CACHE_VAL(ac_cv___va_copy,[
3477     AC_TRY_RUN([
3478         #include <stdarg.h>
3479         void f (int i, ...) {
3480             va_list args1, args2;
3481             va_start (args1, i);
3482             __va_copy (args2, args1);
3483             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3484                 exit (1);
3485             va_end (args1); va_end (args2);
3486         }
3487         int main() { f (0, 42); return 0; }],
3488         ac_cv___va_copy=yes,
3489         ac_cv___va_copy=no,
3490         ac_cv___va_copy=no
3491     )
3493 AC_MSG_RESULT($ac_cv___va_copy)
3494 AC_MSG_CHECKING(whether va_lists can be copied by value)
3495 AC_CACHE_VAL(ac_cv_va_val_copy,[
3496     AC_TRY_RUN([
3497         #include <stdarg.h>
3498         void f (int i, ...) {
3499             va_list args1, args2;
3500             va_start (args1, i);
3501             args2 = args1;
3502             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3503                 exit (1);
3504             va_end (args1); va_end (args2);
3505         }
3506         int main() { f (0, 42); return 0; }],
3507         ac_cv_va_val_copy=yes,
3508         ac_cv_va_val_copy=no,
3509         ac_cv_va_val_copy=yes
3510     )
3512 if test "x$ac_cv_va_copy" = "xyes"; then
3513     AC_DEFINE(VA_COPY, va_copy)
3514     AC_DEFINE(HAVE_VA_COPY)
3515 elif test "x$ac_cv___va_copy" = "xyes"; then
3516     AC_DEFINE(VA_COPY, __va_copy)
3517     AC_DEFINE(HAVE_VA_COPY)
3520 if test "x$ac_cv_va_val_copy" = "xno"; then
3521    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3523 AC_MSG_RESULT($ac_cv_va_val_copy)
3525 dnl ===================================================================
3526 dnl ========================================================
3527 dnl Put your C++ language/feature checks below
3528 dnl ========================================================
3529 AC_LANG_CPLUSPLUS
3531 ARM_ABI_PREFIX=
3532 if test "$GNU_CC"; then
3533   if test "$CPU_ARCH" = "arm" ; then
3534     AC_CACHE_CHECK(for ARM EABI,
3535         ac_cv_gcc_arm_eabi,
3536         [AC_TRY_COMPILE([],
3537                         [
3538 #if defined(__ARM_EABI__)
3539   return 0;
3540 #else
3541 #error Not ARM EABI.
3542 #endif
3543                         ],
3544                         ac_cv_gcc_arm_eabi="yes",
3545                         ac_cv_gcc_arm_eabi="no")])
3546     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
3547         HAVE_ARM_EABI=1
3548         ARM_ABI_PREFIX=eabi-
3549     else
3550         ARM_ABI_PREFIX=oabi-
3551     fi
3552   fi
3554   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
3557 dnl Check for support of modern template specialization syntax
3558 dnl Test code and requirement from scc@netscape.com.
3559 dnl Autoconf cut-and-paste job by waterson@netscape.com
3560 AC_CACHE_CHECK(for modern C++ template specialization syntax support,
3561                ac_cv_cpp_modern_specialize_template_syntax,
3562                [AC_TRY_COMPILE(template <class T> struct X { int a; };
3563                                class Y {};
3564                                template <> struct X<Y> { double a; };,
3565                                X<int> int_x;
3566                                X<Y> y_x;,
3567                                ac_cv_cpp_modern_specialize_template_syntax=yes,
3568                                ac_cv_cpp_modern_specialize_template_syntax=no)])
3569 if test "$ac_cv_cpp_modern_specialize_template_syntax" = no ; then
3570   AC_MSG_ERROR([The C++ compiler does not support template specialization])
3573 dnl Some compilers support only full specialization, and some don't.
3574 AC_CACHE_CHECK(whether partial template specialization works,
3575                ac_cv_cpp_partial_specialization,
3576                [AC_TRY_COMPILE(template <class T> class Foo {};
3577                                template <class T> class Foo<T*> {};,
3578                                return 0;,
3579                                ac_cv_cpp_partial_specialization=yes,
3580                                ac_cv_cpp_partial_specialization=no)])
3581 if test "$ac_cv_cpp_partial_specialization" = yes ; then
3582   AC_DEFINE(HAVE_CPP_PARTIAL_SPECIALIZATION)
3585 dnl Check to see if we can resolve ambiguity with |using|.
3586 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
3587                ac_cv_cpp_ambiguity_resolving_using,
3588                [AC_TRY_COMPILE(class X {
3589                                  public: int go(const X&) {return 3;}
3590                                          int jo(const X&) {return 3;}
3591                                };
3592                                class Y : public X {
3593                                  public:  int go(int) {return 2;}
3594                                           int jo(int) {return 2;}
3595                                           using X::jo;
3596                                  private: using X::go;
3597                                };,
3598                                X x; Y y; y.jo(x);,
3599                                ac_cv_cpp_ambiguity_resolving_using=yes,
3600                                ac_cv_cpp_ambiguity_resolving_using=no)])
3601 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
3602    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
3605 dnl See if a dynamic_cast to void* gives the most derived object.
3606 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
3607                ac_cv_cpp_dynamic_cast_void_ptr,
3608                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
3609                             class Y { int j; public: virtual ~Y() { } };
3610                             class Z : public X, public Y { int k; };
3612                             int main() {
3613                                  Z mdo;
3614                                  X *subx = (X*)&mdo;
3615                                  Y *suby = (Y*)&mdo;
3616                                  return !((((void*)&mdo != (void*)subx) &&
3617                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
3618                                           (((void*)&mdo != (void*)suby) &&
3619                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
3620                             }],
3621                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
3622                            ac_cv_cpp_dynamic_cast_void_ptr=no,
3623                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
3624 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
3625    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
3629 dnl note that this one is reversed - if the test fails, then
3630 dnl we require implementations of unused virtual methods. Which
3631 dnl really blows because it means we'll have useless vtable
3632 dnl bloat.
3633 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
3634                ac_cv_cpp_unused_required,
3635                [AC_TRY_LINK(class X {private: virtual void never_called();};,
3636                                X x;,
3637                                ac_cv_cpp_unused_required=no,
3638                                ac_cv_cpp_unused_required=yes)])
3639 if test "$ac_cv_cpp_unused_required" = yes ; then
3640    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
3644 dnl Some compilers have trouble comparing a constant reference to a templatized
3645 dnl class to zero, and require an explicit operator==() to be defined that takes
3646 dnl an int. This test separates the strong from the weak.
3648 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
3649                ac_cv_trouble_comparing_to_zero,
3650                [AC_TRY_COMPILE([#include <algorithm>
3651                                 template <class T> class Foo {};
3652                                 class T2;
3653                                 template <class T> int operator==(const T2*, const T&) { return 0; }
3654                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
3655                                [Foo<int> f; return (0 != f);],
3656                                ac_cv_trouble_comparing_to_zero=no,
3657                                ac_cv_trouble_comparing_to_zero=yes)])
3658 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
3659   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
3662 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
3663 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
3664 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
3665 # linking XUL.
3666 _SAVE_LDFLAGS=$LDFLAGS
3667 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
3668 AC_CACHE_CHECK(for __thread keyword for TLS variables,
3669                ac_cv_thread_keyword,
3670                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
3671                             [return tlsIsMainThread;],
3672                             ac_cv_thread_keyword=yes,
3673                             ac_cv_thread_keyword=no)])
3674 LDFLAGS=$_SAVE_LDFLAGS
3675 # The custom dynamic linker doesn't support TLS variables
3676 MOZ_TLS=
3677 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
3678   # mips builds fail with TLS variables because of a binutils bug.
3679   # See bug 528687
3680   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
3681   case "${target}" in
3682     mips*-*)
3683       :
3684       ;;
3685     *-android*|*-linuxandroid*)
3686       :
3687       ;;
3688     *-openbsd*)
3689       :
3690       ;;
3691     *)
3692       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
3693       MOZ_TLS=1
3694       ;;
3695   esac
3698 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
3699 if test -n "$MOZ_LINKER"; then
3700   if test "$CPU_ARCH" = arm; then
3701     dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
3702     ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]]*\).*/\1/p'`
3703     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
3704     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
3705       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3706       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3707     fi
3708   fi
3711 dnl The custom linker doesn't support text relocations, but NDK >= r6b
3712 dnl creates some (http://code.google.com/p/android/issues/detail?id=23203)
3713 dnl We however want to avoid these text relocations, and this can be done
3714 dnl by making gcc not link crtbegin and crtend. In the broken NDKs, crtend
3715 dnl doesn't contain anything at all, beside placeholders for some sections,
3716 dnl and crtbegin only contains a finalizer function that calls
3717 dnl __cxa_finalize. The custom linker actually takes care of calling
3718 dnl __cxa_finalize when the library doesn't call it itself, which makes it
3719 dnl safe not to link crtbegin. Besides, previous versions of the NDK didn't
3720 dnl link crtbegin and crtend at all.
3721 if test -n "$MOZ_LINKER" -a "$OS_TARGET" = "Android"; then
3722   AC_CACHE_CHECK([whether the CRT objects have text relocations],
3723     ac_cv_crt_has_text_relocations,
3724     [echo 'int foo() { return 0; }' > conftest.cpp
3725      if AC_TRY_COMMAND(${CXX-g++} -o conftest${DLL_SUFFIX} $CXXFLAGS $DSO_LDOPTS $LDFLAGS conftest.cpp $LIBS 1>&5) &&
3726         test -s conftest${DLL_SUFFIX}; then
3727        if ${TOOLCHAIN_PREFIX}readelf -d conftest${DLL_SUFFIX} | grep TEXTREL > /dev/null; then
3728          ac_cv_crt_has_text_relocations=yes
3729        else
3730          ac_cv_crt_has_text_relocations=no
3731        fi
3732      else
3733        AC_ERROR([couldn't compile a simple C file])
3734      fi
3735      rm -rf conftest*])
3736   if test "$ac_cv_crt_has_text_relocations" = yes; then
3737     dnl While we want libraries to skip the CRT files, we don't want
3738     dnl executables to be treated the same way. We thus set the flag
3739     dnl in DSO_LDOPTS and not LDFLAGS. However, to pass it to nspr,
3740     dnl we need to use LDFLAGS because nspr doesn't inherit DSO_LDOPTS.
3741     dnl Using LDFLAGS in nspr is safe, since we only really build
3742     dnl libraries there.
3743     DSO_LDOPTS="$DSO_LDOPTS -nostartfiles"
3744     NSPR_LDFLAGS="$NSPR_LDFLAGS -nostartfiles"
3745   fi
3748 dnl Check for the existence of various allocation headers/functions
3750 MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h"
3751 MALLOC_H=
3753 for file in $MALLOC_HEADERS; do
3754   MOZ_CHECK_HEADER($file, [MALLOC_H=$file])
3755   if test "$MALLOC_H" != ""; then
3756     AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
3757     break
3758   fi
3759 done
3761 MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
3762 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
3764 AC_CHECK_FUNCS(malloc_usable_size)
3766 dnl See if compiler supports some gcc-style attributes
3768 AC_CACHE_CHECK(for __attribute__((always_inline)),
3769                ac_cv_attribute_always_inline,
3770                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
3771                                [],
3772                                ac_cv_attribute_always_inline=yes,
3773                                ac_cv_attribute_always_inline=no)])
3775 AC_CACHE_CHECK(for __attribute__((malloc)),
3776                ac_cv_attribute_malloc,
3777                [AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
3778                                [],
3779                                ac_cv_attribute_malloc=yes,
3780                                ac_cv_attribute_malloc=no)])
3782 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
3783                ac_cv_attribute_warn_unused,
3784                [AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
3785                                [],
3786                                ac_cv_attribute_warn_unused=yes,
3787                                ac_cv_attribute_warn_unused=no)])
3789 dnl End of C++ language/feature checks
3790 AC_LANG_C
3792 dnl ========================================================
3793 dnl =  Internationalization checks
3794 dnl ========================================================
3796 dnl Internationalization and Locale support is different
3797 dnl on various UNIX platforms.  Checks for specific i18n
3798 dnl features go here.
3800 dnl check for LC_MESSAGES
3801 AC_CACHE_CHECK(for LC_MESSAGES,
3802                 ac_cv_i18n_lc_messages,
3803                 [AC_TRY_COMPILE([#include <locale.h>],
3804                                 [int category = LC_MESSAGES;],
3805                                 ac_cv_i18n_lc_messages=yes,
3806                                 ac_cv_i18n_lc_messages=no)])
3807 if test "$ac_cv_i18n_lc_messages" = yes; then
3808    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
3811 AC_HAVE_FUNCS(localeconv)
3812 fi # ! SKIP_COMPILER_CHECKS
3814 TARGET_XPCOM_ABI=
3815 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
3816     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
3819 dnl Mozilla specific options
3820 dnl ========================================================
3821 dnl The macros used for command line options
3822 dnl are defined in build/autoconf/altoptions.m4.
3824 dnl If the compiler supports these attributes, define them as
3825 dnl convenience macros.
3826 if test "$ac_cv_attribute_malloc" = yes ; then
3827   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
3828 else
3829   AC_DEFINE(NS_ATTR_MALLOC,)
3832 if test "$ac_cv_attribute_warn_unused" = yes ; then
3833   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
3834 else
3835   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
3838 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
3839 dnl features that Windows actually does support.
3841 if test -n "$SKIP_COMPILER_CHECKS"; then
3842    dnl Windows has malloc.h
3843    AC_DEFINE(MALLOC_H, [<malloc.h>])
3844    AC_DEFINE(HAVE_FORCEINLINE)
3845    AC_DEFINE(HAVE_LOCALECONV)
3846 fi # SKIP_COMPILER_CHECKS
3848 dnl ========================================================
3849 dnl =
3850 dnl = Check for external package dependencies
3851 dnl =
3852 dnl ========================================================
3853 MOZ_ARG_HEADER(External Packages)
3855 MOZ_ARG_WITH_STRING(libxul-sdk,
3856 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
3857   LIBXUL_SDK_DIR=$withval)
3859 if test "$LIBXUL_SDK_DIR" = "yes"; then
3860     AC_MSG_ERROR([--with-libxul-sdk must specify a path])
3861 elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
3862     LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
3864     if test ! -f "$LIBXUL_SDK/include/xpcom-config.h"; then
3865         AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
3866     fi
3869 AC_SUBST(LIBXUL_SDK)
3871 if test -n "$LIBXUL_SDK"; then
3872     LIBXUL_DIST="$LIBXUL_SDK"
3873 else
3874     LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
3876 AC_SUBST(LIBXUL_DIST)
3878 SYSTEM_LIBXUL=
3880 MOZ_ARG_WITH_BOOL(system-libxul,
3881 [  --with-system-libxul    Use system installed libxul SDK],
3882     SYSTEM_LIBXUL=1)
3884 dnl ========================================================
3885 dnl = If NSPR was not detected in the system,
3886 dnl = use the one in the source tree (mozilla/nsprpub)
3887 dnl ========================================================
3888 MOZ_ARG_WITH_BOOL(system-nspr,
3889 [  --with-system-nspr      Use system installed NSPR],
3890     _USE_SYSTEM_NSPR=1 )
3892 if test -n "$_USE_SYSTEM_NSPR"; then
3893     AM_PATH_NSPR(4.9.4, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])])
3896 if test -n "$MOZ_NATIVE_NSPR"; then
3897     _SAVE_CFLAGS=$CFLAGS
3898     CFLAGS="$CFLAGS $NSPR_CFLAGS"
3899     AC_TRY_COMPILE([#include "prtypes.h"],
3900                 [#ifndef PR_STATIC_ASSERT
3901                  #error PR_STATIC_ASSERT not defined or requires including prtypes.h
3902                  #endif],
3903                 [MOZ_NATIVE_NSPR=1],
3904                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
3905     AC_TRY_COMPILE([#include "prtypes.h"],
3906                 [#ifndef PR_UINT64
3907                  #error PR_UINT64 not defined or requires including prtypes.h
3908                  #endif],
3909                 [MOZ_NATIVE_NSPR=1],
3910                 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
3911     CFLAGS=$_SAVE_CFLAGS
3912 else
3913     if test -z "$LIBXUL_SDK"; then
3914         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
3915         if test -n "$GNU_CC"; then
3916             NSPR_LIBS="-L${LIBXUL_DIST}/lib -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
3917         else
3918             NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
3919         fi
3920     else
3921         NSPR_CFLAGS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --includedir="${LIBXUL_DIST}/include/nspr" --cflags`
3922         NSPR_LIBS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --libdir="${LIBXUL_DIST}"/lib --libs`
3923     fi
3926 dnl set GRE_MILESTONE
3927 dnl ========================================================
3928 if test -n "$LIBXUL_SDK"; then
3929     GRE_MILESTONE=`$PYTHON "$_topsrcdir"/config/printconfigsetting.py "$LIBXUL_DIST"/bin/platform.ini Build Milestone`
3930 else
3931     GRE_MILESTONE=`tail -n 1 "$_topsrcdir"/config/milestone.txt 2>/dev/null || tail -1 "$_topsrcdir"/config/milestone.txt`
3933 AC_SUBST(GRE_MILESTONE)
3935 dnl system libevent Support
3936 dnl ========================================================
3937 MOZ_ARG_WITH_STRING(system-libevent,
3938 [  --with-system-libevent[=PFX]
3939                           Use system libevent [installed at prefix PFX]],
3940     LIBEVENT_DIR=$withval)
3942 _SAVE_CFLAGS=$CFLAGS
3943 _SAVE_LDFLAGS=$LDFLAGS
3944 _SAVE_LIBS=$LIBS
3945 if test "$LIBEVENT_DIR" = yes; then
3946     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
3947         MOZ_NATIVE_LIBEVENT=1,
3948         LIBEVENT_DIR=/usr)
3950 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
3951     MOZ_NATIVE_LIBEVENT=
3952 elif test -z "$MOZ_NATIVE_LIBEVENT"; then
3953     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
3954     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
3955     MOZ_CHECK_HEADER(event.h,
3956         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
3957              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
3958          fi],
3959         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
3960     AC_CHECK_LIB(event, event_init,
3961                  [MOZ_NATIVE_LIBEVENT=1
3962                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
3963                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
3964                  [MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
3966 CFLAGS=$_SAVE_CFLAGS
3967 LDFLAGS=$_SAVE_LDFLAGS
3968 LIBS=$_SAVE_LIBS
3970 AC_SUBST(MOZ_NATIVE_LIBEVENT)
3971 AC_SUBST(MOZ_LIBEVENT_CFLAGS)
3972 AC_SUBST(MOZ_LIBEVENT_LIBS)
3974 dnl ========================================================
3975 dnl = If NSS was not detected in the system,
3976 dnl = use the one in the source tree (mozilla/security/nss)
3977 dnl ========================================================
3979 MOZ_ARG_WITH_BOOL(system-nss,
3980 [  --with-system-nss       Use system installed NSS],
3981     _USE_SYSTEM_NSS=1 )
3983 if test -n "$_USE_SYSTEM_NSS"; then
3984     AM_PATH_NSS(3.14.2, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
3987 if test -n "$MOZ_NATIVE_NSS"; then
3988    NSS_LIBS="$NSS_LIBS -lcrmf"
3989 else
3990    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
3991    NSS_DEP_LIBS="\
3992         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
3993         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)smime$NSS_VERSION\$(DLL_SUFFIX) \
3994         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)ssl$NSS_VERSION\$(DLL_SUFFIX) \
3995         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nss$NSS_VERSION\$(DLL_SUFFIX) \
3996         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nssutil$NSS_VERSION\$(DLL_SUFFIX)"
3998    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2"; then
3999        NSS_LIBS="\
4000         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
4001         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
4002         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
4003         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
4004         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
4005    else
4006        NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
4007    fi
4010 dnl ======================
4011 dnl Detect yasm
4012 dnl ======================
4014 AC_MSG_CHECKING([for YASM assembler])
4015 AC_CHECK_PROGS(YASM, yasm, "")
4017 if test -n "$YASM"; then
4018   dnl Pull out yasm's version string
4019   YASM_VERSION=`yasm --version | $AWK '/^yasm/ { print $2 }'`
4020   _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
4021   _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
4022   _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
4023   _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
4026 if test -z "$SKIP_LIBRARY_CHECKS"; then
4027 dnl system JPEG support
4028 dnl ========================================================
4029 MOZ_ARG_WITH_STRING(system-jpeg,
4030 [  --with-system-jpeg[=PFX]
4031                           Use system libjpeg [installed at prefix PFX]],
4032     JPEG_DIR=$withval)
4034 _SAVE_CFLAGS=$CFLAGS
4035 _SAVE_LDFLAGS=$LDFLAGS
4036 _SAVE_LIBS=$LIBS
4037 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
4038     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
4039     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
4041 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
4042     MOZ_NATIVE_JPEG=
4043 else
4044     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_NATIVE_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_NATIVE_JPEG=)
4047 if test "$MOZ_NATIVE_JPEG" = 1; then
4048     AC_TRY_COMPILE([ #include <stdio.h>
4049                      #include <sys/types.h>
4050                      #include <jpeglib.h> ],
4051                    [ #if JPEG_LIB_VERSION < $MOZJPEG
4052                      #error "Insufficient JPEG library version ($MOZJPEG required)."
4053                      #endif
4054                      #ifndef JCS_EXTENSIONS
4055                      #error "libjpeg-turbo JCS_EXTENSIONS required"
4056                      #endif
4057                      ],
4058                    MOZ_NATIVE_JPEG=1,
4059                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
4061 CFLAGS=$_SAVE_CFLAGS
4062 LDFLAGS=$_SAVE_LDFLAGS
4063 LIBS=$_SAVE_LIBS
4065 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
4066     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
4067     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
4069 fi # SKIP_LIBRARY_CHECKS
4071 dnl system ZLIB support
4072 dnl ========================================================
4073 MOZ_ZLIB_CHECK([1.2.3])
4075 if test "$MOZ_NATIVE_ZLIB" != 1; then
4076     MOZ_ZLIB_CFLAGS=
4077     MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,'"$MOZ_BUILD_ROOT"'/modules/zlib/src)'
4080 if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
4081     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
4084 if test -z "$SKIP_LIBRARY_CHECKS"; then
4085 dnl system BZIP2 Support
4086 dnl ========================================================
4087 MOZ_ARG_WITH_STRING(system-bz2,
4088 [  --with-system-bz2[=PFX]
4089                           Use system libbz2 [installed at prefix PFX]],
4090     BZ2_DIR=$withval)
4092 _SAVE_CFLAGS=$CFLAGS
4093 _SAVE_LDFLAGS=$LDFLAGS
4094 _SAVE_LIBS=$LIBS
4095 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
4096     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
4097     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
4099 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
4100     MOZ_NATIVE_BZ2=
4101 else
4102     AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_NATIVE_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
4103         [MOZ_NATIVE_BZ2= MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS=])
4105 CFLAGS=$_SAVE_CFLAGS
4106 LDFLAGS=$_SAVE_LDFLAGS
4107 LIBS=$_SAVE_LIBS
4109 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_NATIVE_BZ2" = 1; then
4110     MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
4111     MOZ_BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
4114 dnl system PNG Support
4115 dnl ========================================================
4116 MOZ_ARG_WITH_STRING(system-png,
4117 [  --with-system-png[=PFX]
4118                           Use system libpng [installed at prefix PFX]],
4119     PNG_DIR=$withval)
4121 _SAVE_CFLAGS=$CFLAGS
4122 _SAVE_LDFLAGS=$LDFLAGS
4123 _SAVE_LIBS=$LIBS
4124 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
4125     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
4126     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
4128 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
4129     MOZ_NATIVE_PNG=
4130 else
4131     AC_CHECK_LIB(png, png_get_valid, [MOZ_NATIVE_PNG=1 MOZ_PNG_LIBS="-lpng"],
4132                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4133     AC_CHECK_LIB(png, png_get_acTL, ,
4134                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
4136 if test "$MOZ_NATIVE_PNG" = 1; then
4137     AC_TRY_COMPILE([ #include <stdio.h>
4138                      #include <sys/types.h>
4139                      #include <png.h> ],
4140                    [ #if PNG_LIBPNG_VER < $MOZPNG
4141                      #error "Insufficient libpng version ($MOZPNG required)."
4142                      #endif
4143                      #ifndef PNG_UINT_31_MAX
4144                      #error "Insufficient libpng version."
4145                      #endif ],
4146                    MOZ_NATIVE_PNG=1,
4147                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4149 CFLAGS=$_SAVE_CFLAGS
4150 LDFLAGS=$_SAVE_LDFLAGS
4151 LIBS=$_SAVE_LIBS
4153 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_NATIVE_PNG" = 1; then
4154     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
4155     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
4158 fi # SKIP_LIBRARY_CHECKS
4160 dnl system HunSpell Support
4161 dnl ========================================================
4162 MOZ_ARG_ENABLE_BOOL(system-hunspell,
4163 [  --enable-system-hunspell
4164                           Use system hunspell (located with pkgconfig)],
4165     MOZ_NATIVE_HUNSPELL=1 )
4167 if test -n "$MOZ_NATIVE_HUNSPELL"; then
4168     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
4171 AC_SUBST(MOZ_NATIVE_HUNSPELL)
4173 dnl ========================================================
4174 dnl system libffi Support
4175 dnl ========================================================
4176 MOZ_ARG_ENABLE_BOOL(system-ffi,
4177 [  --enable-system-ffi       Use system libffi (located with pkgconfig)],
4178     MOZ_NATIVE_FFI=1 )
4180 if test -n "$MOZ_NATIVE_FFI"; then
4181     # Vanilla libffi 3.0.9 needs a few patches from upcoming version 3.0.10
4182     # for non-GCC compilers.
4183     if test -z "$GNU_CC"; then
4184         PKG_CHECK_MODULES(MOZ_FFI, libffi > 3.0.9)
4185     else
4186         PKG_CHECK_MODULES(MOZ_FFI, libffi >= 3.0.9)
4187     fi
4188     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS"
4191 dnl ========================================================
4192 dnl Java SDK support
4193 dnl ========================================================
4195 JAVA_BIN_PATH=
4196 MOZ_ARG_WITH_STRING(java-bin-path,
4197 [  --with-java-bin-path=dir
4198                           Location of Java binaries (java, javac, jar)],
4199     JAVA_BIN_PATH=$withval)
4201 dnl ========================================================
4202 dnl =
4203 dnl = Application
4204 dnl =
4205 dnl ========================================================
4207 MOZ_ARG_HEADER(Application)
4209 ENABLE_TESTS=1
4210 ENABLE_SYSTEM_EXTENSION_DIRS=1
4211 MOZ_BRANDING_DIRECTORY=
4212 MOZ_OFFICIAL_BRANDING=
4213 MOZ_FEEDS=1
4214 MOZ_FLEXBOX=1
4215 MOZ_WEBAPP_RUNTIME=
4216 MOZ_JSDEBUGGER=1
4217 MOZ_AUTH_EXTENSION=1
4218 MOZ_OGG=1
4219 MOZ_RAW=
4220 MOZ_SYDNEYAUDIO=
4221 MOZ_SPEEX_RESAMPLER=1
4222 MOZ_SOUNDTOUCH=1
4223 MOZ_CUBEB=
4224 MOZ_VORBIS=
4225 MOZ_TREMOR=
4226 MOZ_WAVE=1
4227 MOZ_SAMPLE_TYPE_FLOAT32=
4228 MOZ_SAMPLE_TYPE_S16=
4229 MOZ_MEDIA=
4230 MOZ_OPUS=1
4231 MOZ_WEBM=1
4232 MOZ_DASH=1
4233 MOZ_WMF=
4234 MOZ_WEBRTC=1
4235 MOZ_PEERCONNECTION=
4236 MOZ_SRTP=
4237 MOZ_WEBRTC_SIGNALING=
4238 MOZ_WEBRTC_IN_LIBXUL=
4239 MOZ_SCTP=
4240 MOZ_MEDIA_PLUGINS=
4241 MOZ_MEDIA_NAVIGATOR=
4242 MOZ_OMX_PLUGIN=
4243 MOZ_VP8=
4244 MOZ_VP8_ERROR_CONCEALMENT=
4245 MOZ_VP8_ENCODER=
4246 VPX_AS=
4247 VPX_ASFLAGS=
4248 VPX_AS_DASH_C_FLAG=
4249 VPX_AS_CONVERSION=
4250 VPX_ASM_SUFFIX=
4251 VPX_X86_ASM=
4252 VPX_ARM_ASM=
4253 LIBJPEG_TURBO_AS=
4254 LIBJPEG_TURBO_ASFLAGS=
4255 LIBJPEG_TURBO_X86_ASM=
4256 LIBJPEG_TURBO_X64_ASM=
4257 LIBJPEG_TURBO_ARM_ASM=
4258 MOZ_PANGO=1
4259 MOZ_PERMISSIONS=1
4260 MOZ_PLACES=1
4261 MOZ_PREF_EXTENSIONS=1
4262 MOZ_PROFILELOCKING=1
4263 MOZ_PSM=1
4264 MOZ_REFLOW_PERF=
4265 MOZ_SAFE_BROWSING=
4266 MOZ_HELP_VIEWER=
4267 MOZ_SPELLCHECK=1
4268 MOZ_ANDROID_OMTC=
4269 MOZ_ONLY_TOUCH_EVENTS=
4270 MOZ_TOOLKIT_SEARCH=1
4271 MOZ_UI_LOCALE=en-US
4272 MOZ_UNIVERSALCHARDET=1
4273 MOZ_URL_CLASSIFIER=
4274 MOZ_XUL=1
4275 MOZ_ZIPWRITER=1
4276 NS_PRINTING=1
4277 MOZ_PDF_PRINTING=
4278 MOZ_DISABLE_DOMCRYPTO=
4279 NSS_DISABLE_DBM=
4280 NECKO_WIFI=1
4281 NECKO_COOKIES=1
4282 NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg device"
4283 USE_ARM_KUSER=
4284 BUILD_CTYPES=1
4285 MOZ_USE_NATIVE_POPUP_WINDOWS=
4286 MOZ_ANDROID_HISTORY=
4287 MOZ_WEBSMS_BACKEND=
4288 MOZ_GRAPHITE=1
4289 ACCESSIBILITY=1
4290 MOZ_SYS_MSG=
4291 MOZ_TIME_MANAGER=
4292 MOZ_PAY=
4293 MOZ_AUDIO_CHANNEL_MANAGER=
4295 case "$target_os" in
4296     mingw*)
4297         NS_ENABLE_TSF=1
4298         AC_DEFINE(NS_ENABLE_TSF)
4299         ;;
4300 esac
4302 case "${target}" in
4303     *-android*|*-linuxandroid*)
4304         if test "$CPU_ARCH" = "arm" ; then
4305           USE_ARM_KUSER=1
4306         fi
4308         NSS_DISABLE_DBM=1
4309         if test -z "$gonkdir"; then
4310           NECKO_WIFI=
4311         else
4312           NECKO_WIFI=1
4313         fi
4314         MOZ_THEME_FASTSTRIPE=1
4315         MOZ_TREE_FREETYPE=1
4316         MOZ_MEMORY=1
4317         MOZ_RAW=1
4318         ;;
4320 esac
4322 MOZ_ARG_ENABLE_STRING(application,
4323 [  --enable-application=APP
4324                           Options include:
4325                             browser (Firefox)
4326                             xulrunner
4327                             tools/update-packaging (AUS-related packaging tools)],
4328 [ MOZ_BUILD_APP=$enableval ] )
4330 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
4331 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
4332   XULRUNNER_STUB_NAME=$withval)
4334 if test -z "$XULRUNNER_STUB_NAME"; then
4335   case "$target_os" in
4336   darwin*)
4337     XULRUNNER_STUB_NAME=xulrunner
4338     ;;
4339   *)
4340     XULRUNNER_STUB_NAME=xulrunner-stub
4341   esac
4343 AC_SUBST(XULRUNNER_STUB_NAME)
4345 AC_MSG_CHECKING([for application to build])
4346 if test -z "$MOZ_BUILD_APP"; then
4347   AC_MSG_RESULT([browser])
4348   MOZ_BUILD_APP=browser
4349 else
4350   # default mobile to be mobile/xul
4351   if test "$MOZ_BUILD_APP" = "mobile" ; then
4352     MOZ_BUILD_APP=mobile/xul
4353   fi
4354   # We have a valid application only if it has a build.mk file in its top
4355   # directory.
4356   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
4357     AC_MSG_RESULT([none])
4358     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
4359   else
4360     AC_MSG_RESULT([$MOZ_BUILD_APP])
4361   fi
4364 # The app update channel is 'default' when not supplied. The value is used in
4365 # the application's confvars.sh so it must be set before confvars.sh is called.
4366 MOZ_ARG_ENABLE_STRING([update-channel],
4367 [  --enable-update-channel=CHANNEL
4368                           Select application update channel (default=default)],
4369     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
4371 if test -z "$MOZ_UPDATE_CHANNEL"; then
4372     MOZ_UPDATE_CHANNEL=default
4374 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
4375 AC_SUBST(MOZ_UPDATE_CHANNEL)
4377 # Allow the application to influence configure with a confvars.sh script.
4379 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4380 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4381   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4382   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4383 else
4384   AC_MSG_RESULT([no])
4387 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
4388 MOZ_ARG_WITH_STRING(app-name,
4389 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
4390 WITH_APP_NAME=$withval,
4393 if test -n "$WITH_APP_NAME" ; then
4394     MOZ_APP_NAME="$WITH_APP_NAME"
4397 MOZ_ARG_WITH_STRING(app-basename,
4398 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
4399 WITH_APP_BASENAME=$withval,
4402 if test -n "$WITH_APP_BASENAME" ; then
4403     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
4406 # Now is a good time to test for logic errors, define mismatches, etc.
4407 case "$MOZ_BUILD_APP" in
4408 xulrunner)
4409   if test "$LIBXUL_SDK"; then
4410     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4411   fi
4412   ;;
4413 esac
4415 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4416 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4417 # MOZ_BUILD_APP.
4418 case "$MOZ_BUILD_APP" in
4419 browser)
4420   AC_DEFINE(MOZ_PHOENIX)
4421   ;;
4423 xulrunner)
4424   AC_DEFINE(MOZ_XULRUNNER)
4425   ;;
4426 b2g)
4427   AC_DEFINE(MOZ_B2G)
4428   ;;
4429 esac
4431 AC_SUBST(MOZ_BUILD_APP)
4432 AC_SUBST(MOZ_PHOENIX)
4433 AC_SUBST(MOZ_XULRUNNER)
4434 AC_SUBST(MOZ_B2G)
4436 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4438 dnl ========================================================
4439 dnl Check android sdk version depending on mobile target
4440 dnl ========================================================
4442 if test -z "$gonkdir" ; then
4443     # Minimum Android SDK API Level we require.
4444     case "$MOZ_BUILD_APP" in
4445     mobile/xul)
4446         android_min_api_level=13
4447         ;;
4448     mobile/android)
4449         android_min_api_level=16
4450         ;;
4451     esac
4453     MOZ_ANDROID_SDK($android_min_api_level)
4456 dnl ========================================================
4457 dnl =
4458 dnl = Toolkit Options
4459 dnl =
4460 dnl ========================================================
4461 MOZ_ARG_HEADER(Toolkit Options)
4463     dnl ========================================================
4464     dnl = Select the default toolkit
4465     dnl ========================================================
4466         MOZ_ARG_ENABLE_STRING(default-toolkit,
4467         [  --enable-default-toolkit=TK
4468                           Select default toolkit
4469                           Platform specific defaults:
4470                             Mac OS X - cairo-cocoa
4471                             OS/2 - cairo-os2
4472                             Win32 - cairo-windows
4473                             * - cairo-gtk2
4474                             * - cairo-qt],
4475     [ _DEFAULT_TOOLKIT=$enableval ],
4476     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4478     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4479         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4480         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4481         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4482         -o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
4483         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
4484         -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
4485         -o "$_DEFAULT_TOOLKIT" = "cairo-android" \
4486         -o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
4487     then
4488         dnl nglayout only supports building with one toolkit,
4489         dnl so ignore everything after the first comma (",").
4490         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4491     else
4492         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4493     fi
4495 MOZ_ARG_WITHOUT_BOOL(x,
4496 [  --without-x              Build without X11],
4497     WITHOUT_X11=1)
4499 dnl ========================================================
4500 dnl = Enable the toolkit as needed                         =
4501 dnl ========================================================
4503 MOZ_WIDGET_GTK=
4505 case "$MOZ_WIDGET_TOOLKIT" in
4507 cairo-windows)
4508     MOZ_WIDGET_TOOLKIT=windows
4509     MOZ_WEBGL=1
4510     MOZ_PDF_PRINTING=1
4511     MOZ_INSTRUMENT_EVENT_LOOP=1
4512     ;;
4514 cairo-gtk2|cairo-gtk2-x11)
4515     MOZ_WIDGET_TOOLKIT=gtk2
4516     MOZ_ENABLE_GTK2=1
4517     MOZ_ENABLE_XREMOTE=1
4518     MOZ_WEBGL=1
4519     MOZ_GL_DEFAULT_PROVIDER=GLX
4521     AC_DEFINE(MOZ_X11)
4522     MOZ_X11=1
4523     USE_FC_FREETYPE=1
4525     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4526     TK_LIBS='$(MOZ_GTK2_LIBS)'
4527     AC_DEFINE(MOZ_WIDGET_GTK2)
4528     MOZ_WIDGET_GTK=2
4529     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4530     MOZ_PDF_PRINTING=1
4531     MOZ_INSTRUMENT_EVENT_LOOP=1
4532     ;;
4534 cairo-qt)
4535     MOZ_WIDGET_TOOLKIT=qt
4536     MOZ_ENABLE_QT=1
4537     if test -z "$WITHOUT_X11"; then
4538       MOZ_ENABLE_XREMOTE=1
4539       MOZ_GL_DEFAULT_PROVIDER=GLX
4540       MOZ_X11=1
4541       AC_DEFINE(MOZ_X11)
4542       XT_LIBS=
4543     fi
4545     MOZ_WEBGL=1
4546     USE_ELF_DYNSTR_GC=
4547     USE_FC_FREETYPE=1
4548     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4549     TK_LIBS='$(MOZ_QT_LIBS)'
4550     AC_DEFINE(MOZ_WIDGET_QT)
4551     MOZ_PDF_PRINTING=1
4552     AC_DEFINE(QT_NO_KEYWORDS)
4553     ;;
4555 cairo-os2)
4556     MOZ_WIDGET_TOOLKIT=os2
4557     USE_FC_FREETYPE=1
4558     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4559     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4560     MOZ_PDF_PRINTING=1
4561     ;;
4563 cairo-cocoa)
4564     MOZ_WIDGET_TOOLKIT=cocoa
4565     AC_DEFINE(MOZ_WIDGET_COCOA)
4566     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
4567     TK_LIBS='-framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
4568     TK_CFLAGS="-DNO_X11"
4569     CFLAGS="$CFLAGS $TK_CFLAGS"
4570     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4571     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
4572     MOZ_USER_DIR="Mozilla"
4573     MOZ_FS_LAYOUT=bundle
4574     MOZ_WEBGL=1
4575     MOZ_INSTRUMENT_EVENT_LOOP=1
4576     ;;
4578 cairo-uikit)
4579     MOZ_WIDGET_TOOLKIT=uikit
4580     AC_DEFINE(MOZ_WIDGET_UIKIT)
4581     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
4582     TK_CFLAGS="-DNO_X11"
4583     TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
4584     CFLAGS="$CFLAGS $TK_CFLAGS"
4585     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4586     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
4587     MOZ_USER_DIR="Mozilla"
4588     MOZ_FS_LAYOUT=bundle
4589     ;;
4591 cairo-android)
4592     AC_DEFINE(MOZ_WIDGET_ANDROID)
4593     MOZ_WIDGET_TOOLKIT=android
4594     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4595     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4596     MOZ_WEBGL=1
4597     MOZ_PDF_PRINTING=1
4598     MOZ_INSTRUMENT_EVENT_LOOP=1
4599     ;;
4601 cairo-gonk)
4602     AC_DEFINE(MOZ_WIDGET_GONK)
4603     AC_DEFINE(MOZ_TOUCH)
4604     MOZ_WIDGET_TOOLKIT=gonk
4605     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4606     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4607     MOZ_WEBGL=1
4608     MOZ_PDF_PRINTING=1
4609     MOZ_TOUCH=1
4610     ;;
4612 esac
4614 AC_SUBST(MOZ_PDF_PRINTING)
4615 if test "$MOZ_PDF_PRINTING"; then
4616    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
4617    AC_DEFINE(MOZ_PDF_PRINTING)
4620 if test "$MOZ_ENABLE_XREMOTE"; then
4621     AC_DEFINE(MOZ_ENABLE_XREMOTE)
4624 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
4625    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
4628 if test "$COMPILE_ENVIRONMENT"; then
4629   if test "$MOZ_ENABLE_GTK2"; then
4630     if test "$MOZ_X11"; then
4631       GDK_PACKAGES=gdk-x11-2.0
4632     fi
4634     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4635   fi
4637 fi # COMPILE_ENVIRONMENT
4639 AC_SUBST(MOZ_FS_LAYOUT)
4641 dnl ========================================================
4642 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4643 dnl their usage and use them in spidermonkey.
4644 dnl ========================================================
4645 MOZ_ARG_WITH_BOOL(arm-kuser,
4646 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4647     USE_ARM_KUSER=1,)
4648 if test -n "$USE_ARM_KUSER"; then
4649    AC_DEFINE(USE_ARM_KUSER)
4652 dnl ========================================================
4653 dnl = startup-notification support module
4654 dnl ========================================================
4656 if test "$MOZ_ENABLE_GTK2"
4657 then
4658     MOZ_ENABLE_STARTUP_NOTIFICATION=
4660     MOZ_ARG_ENABLE_BOOL(startup-notification,
4661     [  --enable-startup-notification
4662                           Enable startup-notification support (default: disabled) ],
4663         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
4664         MOZ_ENABLE_STARTUP_NOTIFICATION=)
4665     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
4666     then
4667         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
4668                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
4669         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
4670             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
4671             then
4672                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
4673             fi
4674             MOZ_ENABLE_STARTUP_NOTIFICATION=
4675         ])
4676     fi
4678     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
4679         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
4680     fi
4682     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
4684 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
4685 AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
4686 AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
4688 dnl ========================================================
4689 dnl = QT support
4690 dnl ========================================================
4691 if test "$MOZ_ENABLE_QT"
4692 then
4693     MOZ_ARG_WITH_STRING(qtdir,
4694     [  --with-qtdir=\$dir       Specify Qt directory ],
4695     [ QTDIR=$withval])
4697     if test -z "$QTDIR"; then
4698         PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore QtOpenGL)
4699         PKG_CHECK_MODULES(MOZ_QT5, QtWidgets QtMultimedia QtPrintSupport,
4700                       MOZ_ENABLE_QT5=1,
4701                       MOZ_ENABLE_QT5=)
4702         if test "$MOZ_ENABLE_QT5"; then
4703             echo "Using qt5"
4704             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $MOZ_QT5_CFLAGS"
4705             MOZ_QT_LIBS="$MOZ_QT_LIBS $MOZ_QT5_LIBS"
4706         fi
4708         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
4709         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
4710     else
4711         MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
4713         MOZ_QT_CFLAGS="-DQT_SHARED"
4714         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
4715         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/Qt"
4716         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
4717         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
4718         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
4719         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
4720         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative"
4721         HOST_MOC="$QTDIR/bin/moc"
4722         HOST_RCC="$QTDIR/bin/rcc"
4724         # QtWidgets was introduced only in Qt5
4725         if test -d $QTDIR/include/QtWidgets; then
4726             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtWidgets"
4727             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport"
4728             MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtWidgets -lQtPrintSupport"
4729         fi
4730     fi
4731     if test -z "$HOST_MOC"; then
4732         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
4733 incorrect])
4734     fi
4735     if test -z "$HOST_RCC"; then
4736         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is
4737 incorrect])
4738     fi
4740     MOC=$HOST_MOC
4741     RCC=$HOST_RCC
4743     MOZ_ENABLE_QMSYSTEM2=
4744     PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
4745                       MOZ_ENABLE_QMSYSTEM2=1,
4746                       MOZ_ENABLE_QMSYSTEM2=)
4748     if test "$MOZ_ENABLE_QMSYSTEM2"; then
4749       MOZ_ENABLE_QMSYSTEM2=1
4750       MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
4751       MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
4752       AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
4753     fi
4755     MOZ_ENABLE_QTNETWORK=
4756     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
4757                       MOZ_ENABLE_QTNETWORK=1,
4758                       MOZ_ENABLE_QTNETWORK=)
4760     if test "$MOZ_ENABLE_QTNETWORK"; then
4761       MOZ_ENABLE_QTNETWORK=1
4762       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
4763     fi
4765     MOZ_ENABLE_QTMOBILITY=
4766     PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
4767                       MOZ_ENABLE_QTMOBILITY=1,
4768                       MOZ_ENABLE_QTMOBILITY=)
4769     if test "$MOZ_ENABLE_QTMOBILITY"; then
4770        MOZ_ENABLE_QTMOBILITY=1
4771        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
4772        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
4773     else
4774        AC_CHECK_LIB(QtSensors, main, [
4775           MOZ_ENABLE_QTMOBILITY=1
4776           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMobility"
4777           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtSensors"
4778           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtFeedback"
4779           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtLocation"
4780           MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
4781        ])
4782     fi
4783     if test "$MOZ_ENABLE_QTMOBILITY"; then
4784        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
4785     fi
4788 AC_SUBST(GTK_CONFIG)
4789 AC_SUBST(TK_CFLAGS)
4790 AC_SUBST(TK_LIBS)
4792 AC_SUBST(MOZ_ENABLE_GTK2)
4793 AC_SUBST(MOZ_ENABLE_QT)
4794 AC_SUBST(MOZ_ENABLE_QTNETWORK)
4795 AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
4796 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4797 AC_SUBST(MOZ_ENABLE_XREMOTE)
4798 AC_SUBST(MOZ_GTK2_CFLAGS)
4799 AC_SUBST(MOZ_GTK2_LIBS)
4800 AC_SUBST(MOZ_WIDGET_GTK)
4801 AC_SUBST(MOZ_QT_CFLAGS)
4802 AC_SUBST(MOZ_QT_LIBS)
4804 AC_SUBST(MOC)
4805 AC_SUBST(RCC)
4807 AC_SUBST(MOZ_X11)
4809 dnl ========================================================
4810 dnl =
4811 dnl = Components & Features
4812 dnl =
4813 dnl ========================================================
4814 MOZ_ARG_HEADER(Components and Features)
4816 dnl ========================================================
4817 dnl = Localization
4818 dnl ========================================================
4819 MOZ_ARG_ENABLE_STRING(ui-locale,
4820 [  --enable-ui-locale=ab-CD
4821                           Select the user interface locale (default: en-US)],
4822     MOZ_UI_LOCALE=$enableval )
4823 AC_SUBST(MOZ_UI_LOCALE)
4825 dnl ========================================================
4826 dnl = Trademarked Branding
4827 dnl ========================================================
4828 MOZ_ARG_ENABLE_BOOL(official-branding,
4829 [  --enable-official-branding
4830                           Enable Official mozilla.org Branding
4831                           Do not distribute builds with
4832                           --enable-official-branding unless you have
4833                           permission to use trademarks per
4834                           http://www.mozilla.org/foundation/trademarks/ .],
4836   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
4837     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
4838   else
4839     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
4840     MOZ_OFFICIAL_BRANDING=1
4841   fi
4842 ], MOZ_OFFICIAL_BRANDING=)
4844 AC_SUBST(MOZ_OFFICIAL_BRANDING)
4845 if test -n "$MOZ_OFFICIAL_BRANDING"; then
4846   AC_DEFINE(MOZ_OFFICIAL_BRANDING)
4849 MOZ_ARG_WITH_STRING(branding,
4850 [  --with-branding=dir     Use branding from the specified directory.],
4851     MOZ_BRANDING_DIRECTORY=$withval)
4853 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
4854 if test -z "$REAL_BRANDING_DIRECTORY"; then
4855   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
4858 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
4859   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
4862 AC_SUBST(MOZ_BRANDING_DIRECTORY)
4864 dnl ========================================================
4865 dnl = Distribution ID
4866 dnl ========================================================
4867 MOZ_ARG_WITH_STRING(distribution-id,
4868 [  --with-distribution-id=ID
4869                           Set distribution-specific id (default=org.mozilla)],
4870 [ val=`echo $withval`
4871     MOZ_DISTRIBUTION_ID="$val"])
4873 if test -z "$MOZ_DISTRIBUTION_ID"; then
4874    MOZ_DISTRIBUTION_ID="org.mozilla"
4877 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
4878 AC_SUBST(MOZ_DISTRIBUTION_ID)
4881 dnl ========================================================
4882 dnl complex text support off by default
4883 dnl ========================================================
4884 MOZ_ARG_DISABLE_BOOL(pango,
4885 [  --disable-pango         Disable usage of Pango ],
4886     MOZ_PANGO=,
4887     MOZ_PANGO=1)
4889 dnl ========================================================
4890 dnl = Pango
4891 dnl ========================================================
4892 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
4893 then
4894     AC_SUBST(MOZ_PANGO)
4896     if test "$MOZ_PANGO"
4897     then
4898         PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
4900         PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
4901         AC_SUBST(MOZ_PANGO_CFLAGS)
4902         AC_SUBST(MOZ_PANGO_LIBS)
4903         AC_DEFINE(MOZ_PANGO)
4904     else
4905         PKG_CHECK_MODULES(FT2, freetype2 > 6.1.0)
4906         AC_SUBST(FT2_CFLAGS)
4907         AC_SUBST(FT2_LIBS)
4908     fi
4911 dnl ========================================================
4912 dnl = GnomeVFS, GIO and GConf support module
4913 dnl ========================================================
4915 if test "$MOZ_X11"
4916 then
4917     dnl build the GIO extension by default only when the
4918     dnl GTK2 toolkit is in use.
4919     if test "$MOZ_ENABLE_GTK2"
4920     then
4921         MOZ_ENABLE_GIO=1
4922         MOZ_ENABLE_GCONF=1
4923     fi
4925     dnl ========================================================
4926     dnl = GnomeVFS support module
4927     dnl ========================================================
4928     MOZ_ARG_ENABLE_BOOL(gnomevfs,
4929     [  --enable-gnomevfs       Enable GnomeVFS support (default: disabled)],
4930         MOZ_ENABLE_GNOMEVFS=force,
4931         MOZ_ENABLE_GNOMEVFS=)
4933     if test "$MOZ_ENABLE_GNOMEVFS"
4934     then
4935         PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
4936             MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
4937             MOZ_ENABLE_GNOMEVFS=1
4938             AC_DEFINE(MOZ_ENABLE_GNOMEVFS)
4939         ],[
4940             if test "$MOZ_ENABLE_GNOMEVFS" = "force"
4941             then
4942                 AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
4943             fi
4944             MOZ_ENABLE_GNOMEVFS=
4945         ])
4946     fi
4948     AC_SUBST(MOZ_ENABLE_GNOMEVFS)
4949     AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
4950     AC_SUBST(MOZ_GNOMEVFS_LIBS)
4952     dnl ========================================================
4953     dnl = GIO support module
4954     dnl ========================================================
4955     MOZ_ARG_DISABLE_BOOL(gio,
4956     [  --disable-gio           Disable GIO support],
4957         MOZ_ENABLE_GIO=,
4958         MOZ_ENABLE_GIO=force)
4960     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK2"
4961     then
4962         PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
4963                           [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
4964         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
4965             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
4966             MOZ_ENABLE_GIO=1
4967             AC_DEFINE(MOZ_ENABLE_GIO)
4968         ],[
4969             if test "$MOZ_ENABLE_GIO" = "force"
4970             then
4971                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
4972             fi
4973             MOZ_ENABLE_GIO=
4974         ])
4975     fi
4977     AC_SUBST(MOZ_ENABLE_GIO)
4978     AC_SUBST(MOZ_GIO_CFLAGS)
4979     AC_SUBST(MOZ_GIO_LIBS)
4981     dnl ========================================================
4982     dnl = GConf support module
4983     dnl ========================================================
4984     MOZ_ARG_DISABLE_BOOL(gconf,
4985     [  --disable-gconf      Disable Gconf support ],
4986         MOZ_ENABLE_GCONF=,
4987         MOZ_ENABLE_GCONF=force)
4989     if test "$MOZ_ENABLE_GCONF"
4990     then
4991         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
4992             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
4993             MOZ_ENABLE_GCONF=1
4994         ],[
4995             if test "$MOZ_ENABLE_GCONF" = "force"
4996             then
4997                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
4998             fi
4999             MOZ_ENABLE_GCONF=
5000         ])
5001     fi
5003     if test "$MOZ_ENABLE_GCONF"; then
5004         AC_DEFINE(MOZ_ENABLE_GCONF)
5005     fi
5007     AC_SUBST(MOZ_ENABLE_GCONF)
5008     AC_SUBST(MOZ_GCONF_CFLAGS)
5009     AC_SUBST(MOZ_GCONF_LIBS)
5012 dnl ========================================================
5013 dnl = libproxy support
5014 dnl ========================================================
5016 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
5017 then
5018     MOZ_ENABLE_LIBPROXY=
5020     MOZ_ARG_ENABLE_BOOL(libproxy,
5021     [  --enable-libproxy         Enable libproxy support ],
5022     MOZ_ENABLE_LIBPROXY=1,
5023     MOZ_ENABLE_LIBPROXY=)
5025     if test "$MOZ_ENABLE_LIBPROXY"
5026     then
5027         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
5028         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
5029     fi
5031 AC_SUBST(MOZ_ENABLE_LIBPROXY)
5032 AC_SUBST(MOZ_LIBPROXY_CFLAGS)
5033 AC_SUBST(MOZ_LIBPROXY_LIBS)
5035 dnl ========================================================
5036 dnl = GNOME component (mozgnome)
5037 dnl ========================================================
5039 if test "$MOZ_ENABLE_GTK2"
5040 then
5041     MOZ_ENABLE_GNOME_COMPONENT=1
5043 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
5045 dnl ========================================================
5046 dnl = libgnomeui support module
5047 dnl ========================================================
5049 if test "$MOZ_ENABLE_GTK2"
5050 then
5051     MOZ_ARG_ENABLE_BOOL(gnomeui,
5052     [  --enable-gnomeui        Enable libgnomeui instead of GIO & GTK for icon theme support ],
5053         MOZ_ENABLE_GNOMEUI=force,
5054         MOZ_ENABLE_GNOMEUI=)
5056     if test "$MOZ_ENABLE_GNOMEUI"
5057     then
5058         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
5059         [
5060             MOZ_ENABLE_GNOMEUI=1
5061         ],[
5062             if test "$MOZ_ENABLE_GNOMEUI" = "force"
5063             then
5064                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
5065             fi
5066             MOZ_ENABLE_GNOMEUI=
5067         ])
5068     fi
5070     if test "$MOZ_ENABLE_GNOMEUI"; then
5071         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
5072     fi
5075 AC_SUBST(MOZ_ENABLE_GNOMEUI)
5076 AC_SUBST(MOZ_GNOMEUI_CFLAGS)
5078 dnl ========================================================
5079 dnl = dbus support
5080 dnl ========================================================
5082 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
5083 then
5084     MOZ_ENABLE_DBUS=1
5086     MOZ_ARG_DISABLE_BOOL(dbus,
5087     [  --disable-dbus          Disable dbus support ],
5088         MOZ_ENABLE_DBUS=,
5089         MOZ_ENABLE_DBUS=1)
5091     if test "$MOZ_ENABLE_DBUS"
5092     then
5093         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
5094         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
5095         AC_DEFINE(MOZ_ENABLE_DBUS)
5096     fi
5098 AC_SUBST(MOZ_ENABLE_DBUS)
5099 AC_SUBST(MOZ_DBUS_CFLAGS)
5100 AC_SUBST(MOZ_DBUS_LIBS)
5101 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
5102 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
5104 dnl ========================================================
5105 dnl = Enable Android History instead of Places
5106 dnl ========================================================
5107 if test -n "$MOZ_ANDROID_HISTORY"; then
5108     if test -z "$MOZ_PLACES"; then
5109         AC_DEFINE(MOZ_ANDROID_HISTORY)
5110     else
5111         AC_MSG_ERROR([Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.])
5112     fi
5115 dnl ========================================================
5116 dnl = Build with the Android compositor
5117 dnl ========================================================
5118 if test -n "$MOZ_ANDROID_OMTC"; then
5119      dnl Do this if defined in confvars.sh
5120      AC_DEFINE(MOZ_ANDROID_OMTC)
5123 dnl ========================================================
5124 dnl = Disable WebSMS backend
5125 dnl ========================================================
5126 MOZ_ARG_DISABLE_BOOL(websms-backend,
5127 [  --disable-websms-backend
5128                            Disable WebSMS backend],
5129     MOZ_WEBSMS_BACKEND=,
5130     MOZ_WEBSMS_BACKEND=1)
5132 if test -n "$MOZ_WEBSMS_BACKEND"; then
5133     AC_DEFINE(MOZ_WEBSMS_BACKEND)
5136 dnl ========================================================
5137 dnl = Build Personal Security Manager
5138 dnl ========================================================
5139 MOZ_ARG_DISABLE_BOOL(crypto,
5140 [  --disable-crypto        Disable crypto support (Personal Security Manager)],
5141     MOZ_PSM=,
5142     MOZ_PSM=1 )
5144 dnl ========================================================
5145 dnl = JS Debugger XPCOM component (js/jsd)
5146 dnl ========================================================
5147 MOZ_ARG_DISABLE_BOOL(jsd,
5148 [  --disable-jsd           Disable JavaScript debug library],
5149     MOZ_JSDEBUGGER=,
5150     MOZ_JSDEBUGGER=1)
5153 dnl ========================================================
5154 dnl = Enable IPDL's "expensive" unit tests
5155 dnl ========================================================
5156 MOZ_IPDL_TESTS=
5158 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
5159 [  --enable-ipdl-tests     Enable expensive IPDL tests],
5160     MOZ_IPDL_TESTS=1,
5161     MOZ_IPDL_TESTS=)
5163 if test -n "$MOZ_IPDL_TESTS"; then
5164     AC_DEFINE(MOZ_IPDL_TESTS)
5167 AC_SUBST(MOZ_IPDL_TESTS)
5169 dnl ========================================================
5170 dnl = Turns off code necessary for e10s compatibility
5171 dnl ========================================================
5172 dnl This is a temporary flag to be removed in bug 662601 when
5173 dnl it's no longer needed
5175 MOZ_E10S_COMPAT=
5177 MOZ_ARG_ENABLE_BOOL(e10s-compat,
5178 [  --enable-e10s-compat     Turns off code for e10s compat],
5179     MOZ_E10S_COMPAT=1,
5180     MOZ_E10S_COMPAT=)
5182 if test -n "$MOZ_E10S_COMPAT"; then
5183     AC_DEFINE(MOZ_E10S_COMPAT)
5186 dnl ========================================================
5187 dnl = Disable building dbm
5188 dnl ========================================================
5189 MOZ_ARG_DISABLE_BOOL(dbm,
5190 [  --disable-dbm           Disable building dbm],
5191     NSS_DISABLE_DBM=1,
5192     NSS_DISABLE_DBM=)
5194 dnl bi-directional support always on
5195 IBMBIDI=1
5196 AC_DEFINE(IBMBIDI)
5198 dnl ========================================================
5199 dnl accessibility support on by default on all platforms
5200 dnl ========================================================
5201 MOZ_ARG_DISABLE_BOOL(accessibility,
5202 [  --disable-accessibility Disable accessibility support],
5203     ACCESSIBILITY=,
5204     ACCESSIBILITY=1 )
5205 if test "$ACCESSIBILITY"; then
5206     case "$target" in
5207     *-mingw*)
5208         if test -z "$MIDL"; then
5209             if test "$GCC" != "yes"; then
5210                 AC_MSG_ERROR([MIDL could not be found. Building accessibility without MIDL is not supported.])
5211             else
5212                 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.])
5213             fi
5214         fi
5215     esac
5216     AC_DEFINE(ACCESSIBILITY)
5219 dnl ========================================================
5220 dnl Accessibility is required for the linuxgl widget
5221 dnl backend
5222 dnl ========================================================
5223 if test "${MOZ_WIDGET_TOOLKIT}" = "linuxgl" -a "$ACCESSIBILITY" != "1"; then
5224     AC_MSG_ERROR(["Accessibility is required for the linuxgl widget backend"])
5227 dnl ========================================================
5228 dnl Disable printing
5229 dnl ========================================================
5230 MOZ_ARG_DISABLE_BOOL(printing,
5231 [  --disable-printing      Disable printing support],
5232     NS_PRINTING=,
5233     NS_PRINTING=1)
5235 if test "$NS_PRINTING"; then
5236     AC_DEFINE(NS_PRINTING)
5237     AC_DEFINE(NS_PRINT_PREVIEW)
5240 dnl Turn off webrtc for OS's we don't handle yet, but allow 
5241 dnl --enable-webrtc to override.  Can disable for everything in
5242 dnl the master list above.
5243 if test -n "$MOZ_WEBRTC"; then
5244     case "$target" in
5245     *-android*|*-linuxandroid*)
5246         dnl Make sure doesn't get matched by *-linux*
5247         MOZ_WEBRTC=
5248         ;;
5249     *-linux*|*-mingw*|*-darwin*)
5250         dnl Leave enabled
5251         ;;
5252     *)
5253         dnl default to disabled for all others
5254         MOZ_WEBRTC=
5255         ;;
5256     esac
5259 dnl ========================================================
5260 dnl = Disable WebRTC code
5261 dnl ========================================================
5262 MOZ_ARG_DISABLE_BOOL(webrtc,
5263 [  --disable-webrtc        Disable support for WebRTC],
5264     MOZ_WEBRTC=,
5265     MOZ_WEBRTC=1)
5267 if test -n "$MOZ_WEBRTC"; then
5268     AC_DEFINE(MOZ_WEBRTC)
5269     MOZ_MEDIA=1
5270     MOZ_RAW=1
5271     MOZ_VP8=1
5272     MOZ_VP8_ENCODER=1
5273     MOZ_VP8_ERROR_CONCEALMENT=1
5275     dnl OpenSLES is only available in Android 2.3 and later; we'll change this
5276     dnl hard dependency to a dynamic load with graceful runtime failure before
5277     dnl we make --enable-webrtc on by default in Android (bug 815905)
5278     dnl
5279     if test "$OS_TARGET" = "Android"; then
5280        LDFLAGS="$LDFLAGS -lOpenSLES"
5281     fi
5282     case "$target" in
5283     *-android*|*-linuxandroid*)
5284        LDFLAGS="$LDFLAGS -lOpenSLES"
5285        ;;
5286     esac
5288 dnl enable once Signaling lands
5289     MOZ_WEBRTC_SIGNALING=1
5290     AC_DEFINE(MOZ_WEBRTC_SIGNALING)
5291     if test "${OS_TARGET}" = "WINNT"; then
5292         MOZ_WEBRTC_IN_LIBXUL=1
5293     fi
5294 dnl enable once PeerConnection lands
5295     MOZ_PEERCONNECTION=1
5296     AC_DEFINE(MOZ_PEERCONNECTION)
5297     MOZ_SCTP=1
5298     MOZ_SRTP=1
5299     AC_DEFINE(MOZ_SCTP)
5300     AC_DEFINE(MOZ_SRTP)
5303 AC_SUBST(MOZ_WEBRTC)
5304 AC_SUBST(MOZ_WEBRTC_LEAKING_TESTS)
5305 AC_SUBST(MOZ_WEBRTC_SIGNALING)
5306 AC_SUBST(MOZ_PEERCONNECTION)
5307 AC_SUBST(MOZ_WEBRTC_IN_LIBXUL)
5308 AC_SUBST(MOZ_SCTP)
5309 AC_SUBST(MOZ_SRTP)
5311 case "$target_cpu" in
5312 arm*)
5313     MOZ_SAMPLE_TYPE_S16=1
5314     AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
5315     AC_SUBST(MOZ_SAMPLE_TYPE_S16)
5318     MOZ_SAMPLE_TYPE_FLOAT32=1
5319     AC_DEFINE(MOZ_SAMPLE_TYPE_FLOAT32)
5320     AC_SUBST(MOZ_SAMPLE_TYPE_FLOAT32)
5322 esac
5324 dnl ========================================================
5325 dnl = Enable Raw Codecs
5326 dnl ========================================================
5327 MOZ_ARG_ENABLE_BOOL(raw,
5328 [  --enable-raw           Enable support for RAW media],
5329     MOZ_RAW=1,
5330     MOZ_RAW=)
5332 if test -n "$MOZ_RAW"; then
5333     AC_DEFINE(MOZ_RAW)
5334     MOZ_MEDIA=1
5337 AC_SUBST(MOZ_RAW)
5339 dnl ========================================================
5340 dnl = Disable Ogg Codecs
5341 dnl ========================================================
5342 MOZ_ARG_DISABLE_BOOL(ogg,
5343 [  --disable-ogg           Disable support for OGG media (Theora video and Vorbis audio)],
5344     MOZ_OGG=,
5345     MOZ_OGG=1)
5347 if test -n "$MOZ_OGG"; then
5348     AC_DEFINE(MOZ_OGG)
5349     MOZ_SYDNEYAUDIO=1
5350     MOZ_CUBEB=1
5351     MOZ_MEDIA=1
5353     dnl Checks for __attribute__(aligned()) directive
5354     AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5355         [ac_cv_c_attribute_aligned],
5356         [ac_cv_c_attribute_aligned=0
5357          CFLAGS_save="${CFLAGS}"
5358          CFLAGS="${CFLAGS} -Werror"
5359          for ac_cv_c_attr_align_try in 64 32 16 8; do
5360            echo "trying $ac_cv_c_attr_align_try"
5361            AC_TRY_COMPILE([],
5362                           [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5363                           [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5364            if test "$ac_cv_c_attribute_aligned" != 0; then
5365              break;
5366            fi
5367          done
5368            CFLAGS="${CFLAGS_save}"])
5369     if test "${ac_cv_c_attribute_aligned}" != "0"; then
5370       AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5371                          [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5372     fi
5375 dnl ========================================================
5376 dnl = Disable Opus audio codec support
5377 dnl ========================================================
5378 MOZ_ARG_DISABLE_BOOL(opus,
5379 [  --disable-opus          Disable support for Opus audio],
5380     MOZ_OPUS=,
5381     MOZ_OPUS=1)
5383 dnl ========================================================
5384 dnl = Disable VP8 decoder support
5385 dnl ========================================================
5386 MOZ_ARG_DISABLE_BOOL(webm,
5387 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
5388     MOZ_WEBM=,
5389     MOZ_WEBM=1)
5391 if test -n "$MOZ_WEBM"; then
5392     AC_DEFINE(MOZ_WEBM)
5393     MOZ_VP8=1
5396 dnl ========================================================
5397 dnl = Disable DASH-WebM support
5398 dnl ========================================================
5399 MOZ_ARG_DISABLE_BOOL(dash,
5400 [  --disable-dash          Disable support for DASH-WebM],
5401     MOZ_DASH=,
5402     MOZ_DASH=1)
5404 if test -n "$MOZ_DASH"; then
5405     if test -n "$MOZ_WEBM"; then
5406         AC_DEFINE(MOZ_DASH)
5407     else
5408         dnl Fail if WebM is not enabled as well as DASH.
5409         AC_MSG_ERROR([WebM is currently disabled and must be enabled for DASH
5410                      to work.])
5411     fi
5415 dnl ========================================================
5416 dnl = Windows Media Foundation support
5417 dnl ========================================================
5418 if test "$OS_ARCH" = "WINNT"; then
5419     dnl Enable Windows Media Foundation support by default.
5420     dnl Note our minimum SDK version is Windows 7 SDK, so we are (currently)
5421     dnl guaranteed to have a recent-enough SDK to build WMF.
5422     MOZ_WMF=1
5425 MOZ_ARG_DISABLE_BOOL(wmf,
5426 [  --disable-wmf  Disable support for Windows Media Foundation],
5427     MOZ_WMF=,
5428     MOZ_WMF=1)
5430 if test -n "$MOZ_WMF"; then
5431     AC_DEFINE(MOZ_WMF)
5432     MOZ_SYDNEYAUDIO=1
5433     MOZ_CUBEB=1
5434     MOZ_MEDIA=1
5437 dnl ========================================================
5438 dnl = Enable media plugin support
5439 dnl ========================================================
5440 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5441   dnl Enable support on android by default
5442   MOZ_MEDIA_PLUGINS=1
5445 MOZ_ARG_ENABLE_BOOL(media-plugins,
5446 [  --enable-media-plugins  Enable support for media plugins],
5447     MOZ_MEDIA_PLUGINS=1,
5448     MOZ_MEDIA_PLUGINS=)
5450 if test -n "$MOZ_MEDIA_PLUGINS"; then
5451   AC_DEFINE(MOZ_MEDIA_PLUGINS)
5454 dnl ========================================================
5455 dnl = Enable getUserMedia support
5456 dnl ========================================================
5457 MOZ_ARG_ENABLE_BOOL(media-navigator,
5458 [  --enable-media-navigator  Enable support for getUserMedia],
5459     MOZ_MEDIA_NAVIGATOR=1,
5460     MOZ_MEDIA_NAVIGATOR=)
5462 if test -n "$MOZ_MEDIA_NAVIGATOR"; then
5463   AC_DEFINE(MOZ_MEDIA_NAVIGATOR)
5466 dnl ========================================================
5467 dnl = Enable building OMX media plugin (B2G or Android)
5468 dnl ========================================================
5469 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5470   dnl Enable support on android by default
5471   MOZ_OMX_PLUGIN=1
5474 MOZ_ARG_ENABLE_BOOL(omx-plugin,
5475 [  --enable-omx-plugin      Enable building OMX plugin (B2G)],
5476     MOZ_OMX_PLUGIN=1,
5477     MOZ_OMX_PLUGIN=)
5479 if test -n "$MOZ_OMX_PLUGIN"; then
5480     if test "$OS_TARGET" = "Android"; then
5481         dnl Only allow building OMX plugin on Gonk (B2G) or Android
5482         AC_DEFINE(MOZ_OMX_PLUGIN)
5483     else
5484        dnl fail if we're not building on Gonk or Android
5485        AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
5486     fi
5489 dnl system libvpx Support
5490 dnl ========================================================
5491 MOZ_ARG_WITH_BOOL(system-libvpx,
5492 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
5493     MOZ_NATIVE_LIBVPX=1)
5495 MOZ_LIBVPX_CFLAGS=
5496 MOZ_LIBVPX_LIBS=
5498 if test -n "$MOZ_VP8"; then
5499     AC_DEFINE(MOZ_VP8)
5500     if test -n "$MOZ_VP8_ERROR_CONCEALMENT" ; then
5501         AC_DEFINE(MOZ_VP8_ERROR_CONCEALMENT)
5502     fi
5503     if test -n "$MOZ_VP8_ENCODER" ; then
5504         AC_DEFINE(MOZ_VP8_ENCODER)
5505     fi
5507     if test -n "$MOZ_NATIVE_LIBVPX"; then
5508         dnl ============================
5509         dnl === libvpx Version check ===
5510         dnl ============================
5511         dnl Check to see if we have a system libvpx package.
5512         PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.0.0)
5514         MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [], 
5515          [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.])])
5517         _SAVE_LIBS=$LIBS
5518         AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [], 
5519          [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
5520         LIBS=$_SAVE_LIBS
5521     fi
5524 AC_SUBST(MOZ_NATIVE_LIBVPX)
5525 AC_SUBST(MOZ_LIBVPX_CFLAGS)
5526 AC_SUBST(MOZ_LIBVPX_LIBS)
5528 if test "$MOZ_WEBM"; then
5529     MOZ_SYDNEYAUDIO=1
5530     MOZ_CUBEB=1
5531     MOZ_MEDIA=1
5532     if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then
5533         MOZ_VORBIS=1
5534     else
5535         MOZ_TREMOR=1
5536     fi
5539 if test -n "$MOZ_VP8" -a -z "$MOZ_NATIVE_LIBVPX"; then
5541     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
5542     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
5543     dnl We currently require gcc on all arm platforms.
5544     VPX_AS=$YASM
5545     VPX_ASM_SUFFIX=asm
5546     VPX_NEED_OBJ_INT_EXTRACT=
5548     dnl See if we have assembly on this platform.
5549     case "$OS_ARCH:$CPU_ARCH" in
5550     Darwin:x86)
5551       VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
5552       VPX_X86_ASM=1
5553     ;;
5554     Darwin:x86_64)
5555       VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
5556       VPX_X86_ASM=1
5557     ;;
5558     WINNT:x86_64)
5559       VPX_ASFLAGS="-f x64 -rnasm -pnasm"
5560       VPX_X86_ASM=1
5561     ;;
5562     WINNT:x86)
5563       dnl Check for yasm 1.1 or greater.
5564       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
5565         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.])
5566       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5567         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.])
5568       else
5569         VPX_ASFLAGS="-f win32 -rnasm -pnasm -DPIC"
5570         VPX_X86_ASM=1
5571         dnl The encoder needs obj_int_extract to get asm offsets.
5572       fi
5573     ;;
5574     *:arm*)
5575       if test -n "$GNU_AS" ; then
5576         VPX_AS=$AS
5577         dnl These flags are a lie; they're just used to enable the requisite
5578         dnl opcodes; actual arch detection is done at runtime.
5579         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
5580         VPX_DASH_C_FLAG="-c"
5581         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
5582         VPX_ASM_SUFFIX="$ASM_SUFFIX"
5583         VPX_ARM_ASM=1
5584       fi
5585     ;;
5586     *:x86)
5587       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5588         VPX_ASFLAGS="-f elf32 -rnasm -pnasm"
5589         VPX_X86_ASM=1
5590       fi
5591     ;;
5592     *:x86_64)
5593       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5594         VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5595         VPX_X86_ASM=1
5596       fi
5597     ;;
5598     esac
5600     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_X86_ASM" -a -z "$VPX_AS"; then
5601       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.])
5602     fi
5604     if test -n "$MOZ_VP8_ENCODER" -a \
5605             -z "$GNU_CC" -a -z "$INTEL_CC" -a -z "$CLANG_CC" ; then
5606       dnl We prefer to get asm offsets using inline assembler, which the above
5607       dnl compilers can do. When we're not using one of those, we have to fall
5608       dnl back to obj_int_extract, which reads them from a compiled object
5609       dnl file. Unfortunately, that only works if we're compiling on a system
5610       dnl with the header files for the appropriate object file format.
5611       VPX_NEED_OBJ_INT_EXTRACT=1
5612     fi
5614     if test -n "$VPX_X86_ASM"; then
5615       AC_DEFINE(VPX_X86_ASM)
5616     elif test -n "$VPX_ARM_ASM"; then
5617       AC_DEFINE(VPX_ARM_ASM)
5618     else
5619       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
5620     fi
5623 dnl ========================================================
5624 dnl = Disable Wave decoder support
5625 dnl ========================================================
5626 MOZ_ARG_DISABLE_BOOL(wave,
5627 [  --disable-wave          Disable Wave decoder support],
5628     MOZ_WAVE=,
5629     MOZ_WAVE=1)
5631 if test -n "$MOZ_WAVE"; then
5632     AC_DEFINE(MOZ_WAVE)
5633     MOZ_SYDNEYAUDIO=1
5634     MOZ_CUBEB=1
5635     MOZ_MEDIA=1
5638 dnl ========================================================
5639 dnl = Handle dependent SYDNEYAUDIO, CUBEB, and MEDIA defines
5640 dnl ========================================================
5642 if test -n "$MOZ_SYDNEYAUDIO"; then
5643     AC_DEFINE(MOZ_SYDNEYAUDIO)
5646 if test -n "$MOZ_SPEEX_RESAMPLER"; then
5647     AC_DEFINE(MOZ_SPEEX_RESAMPLER)
5650 if test -n "$MOZ_SOUNDTOUCH"; then
5651     AC_DEFINE(MOZ_SOUNDTOUCH)
5654 if test -n "$MOZ_CUBEB"; then
5655     case "$target" in
5656     *-android*|*-linuxandroid*)
5657         if test -n "$gonkdir"; then
5658             AC_DEFINE(MOZ_CUBEB)
5659         fi
5660         dnl No Android implementation of libcubeb yet.
5661         ;;
5662     *-linux*)
5663         AC_DEFINE(MOZ_CUBEB)
5664         ;;
5665     *-mingw*)
5666         AC_DEFINE(MOZ_CUBEB)
5667         ;;
5668     *-darwin*)
5669         AC_DEFINE(MOZ_CUBEB)
5670         ;;
5671     *-openbsd*)
5672         AC_DEFINE(MOZ_CUBEB)
5673         ;;
5674     *)
5675         dnl Other targets will be enabled soon.
5676         ;;
5677     esac
5680 if test -n "$MOZ_MEDIA"; then
5681     AC_DEFINE(MOZ_MEDIA)
5684 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
5685     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/])
5688 if test -n "$MOZ_VORBIS"; then
5689     AC_DEFINE(MOZ_VORBIS)
5692 if test -n "$MOZ_TREMOR"; then
5693     AC_DEFINE(MOZ_TREMOR)
5696 if test -n "$MOZ_OPUS"; then
5697     AC_DEFINE(MOZ_OPUS)
5700 dnl ========================================================
5701 dnl = Check alsa availability on Linux if using sydneyaudio
5702 dnl ========================================================
5704 dnl If using sydneyaudio with Linux, ensure that the alsa library is available
5705 if test -n "$MOZ_SYDNEYAUDIO" -a "$OS_TARGET" = "Linux"; then
5706     MOZ_ALSA=1
5709 MOZ_ARG_ENABLE_BOOL(alsa,
5710 [  --enable-alsa          Enable Alsa support (default on Linux)],
5711 MOZ_ALSA=1,
5712 MOZ_ALSA=)
5714 if test -n "$MOZ_ALSA"; then
5715     AC_DEFINE(MOZ_CUBEB)
5716     PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5717          [echo "$MOZ_ALSA_PKG_ERRORS"
5718           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.)])])
5721 AC_SUBST(MOZ_ALSA)
5722 AC_SUBST(MOZ_ALSA_CFLAGS)
5723 AC_SUBST(MOZ_ALSA_LIBS)
5725 dnl ========================================================
5726 dnl = Enable PulseAudio
5727 dnl ========================================================
5729 MOZ_ARG_ENABLE_BOOL(pulseaudio,
5730 [  --enable-pulseaudio          Enable PulseAudio support (experimental)],
5731 MOZ_PULSEAUDIO=1,
5732 MOZ_PULSEAUDIO=)
5734 if test -n "$MOZ_PULSEAUDIO"; then
5735     AC_DEFINE(MOZ_CUBEB)
5736     PKG_CHECK_MODULES(MOZ_PULSEAUDIO, libpulse, ,
5737          [echo "$MOZ_PULSEAUDIO_PKG_ERRORS"
5738           AC_MSG_ERROR([pulseaudio audio backend requires libpulse package])])
5741 AC_SUBST(MOZ_PULSEAUDIO)
5742 AC_SUBST(MOZ_PULSEAUDIO_CFLAGS)
5743 AC_SUBST(MOZ_PULSEAUDIO_LIBS)
5745 dnl ========================================================
5746 dnl = Enable GStreamer
5747 dnl ========================================================
5748 MOZ_ARG_ENABLE_BOOL(gstreamer,
5749 [  --enable-gstreamer           Enable GStreamer support],
5750 MOZ_GSTREAMER=1,
5751 MOZ_GSTREAMER=)
5753 if test "$MOZ_GSTREAMER"; then
5754     # API version, eg 0.10, 1.0 etc
5755     GST_API_VERSION=0.10
5756     # core/base release number
5757     # depend on >= 0.10.33 as that's when the playbin2 source-setup signal was
5758     # introduced
5759     GST_VERSION=0.10.33
5760     PKG_CHECK_MODULES(GSTREAMER,
5761                       gstreamer-$GST_API_VERSION >= $GST_VERSION
5762                       gstreamer-app-$GST_API_VERSION
5763                       gstreamer-plugins-base-$GST_API_VERSION)
5764     if test -n "$GSTREAMER_LIBS"; then
5765        _SAVE_LDFLAGS=$LDFLAGS
5766        LDFLAGS="$LDFLAGS $GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5767        AC_TRY_LINK(,[return 0;],_HAVE_LIBGSTVIDEO=1,_HAVE_LIBGSTVIDEO=)
5768        if test -n "$_HAVE_LIBGSTVIDEO" ; then
5769           GSTREAMER_LIBS="$GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5770        else
5771           AC_MSG_ERROR([gstreamer video backend requires libgstvideo])
5772        fi
5773        LDFLAGS=$_SAVE_LDFLAGS
5774     else
5775        AC_MSG_ERROR([gstreamer backend requires the gstreamer packages])
5776     fi
5778 AC_SUBST(GSTREAMER_CFLAGS)
5779 AC_SUBST(GSTREAMER_LIBS)
5780 AC_SUBST(MOZ_GSTREAMER)
5782 if test -n "$MOZ_GSTREAMER"; then
5783    AC_DEFINE(MOZ_GSTREAMER)
5784    MOZ_MEDIA=1
5788 dnl ========================================================
5789 dnl Permissions System
5790 dnl ========================================================
5791 MOZ_ARG_DISABLE_BOOL(permissions,
5792 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5793     MOZ_PERMISSIONS=,
5794     MOZ_PERMISSIONS=1
5797 dnl ========================================================
5798 dnl NegotiateAuth
5799 dnl ========================================================
5800 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5801 [  --disable-negotiateauth Disable GSS-API negotiation ],
5802     MOZ_AUTH_EXTENSION=,
5803     MOZ_AUTH_EXTENSION=1 )
5805 dnl ========================================================
5806 dnl Pref extensions (autoconfig)
5807 dnl ========================================================
5808 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5809 [  --disable-pref-extensions
5810                           Disable pref extensions such as autoconfig],
5811   MOZ_PREF_EXTENSIONS=,
5812   MOZ_PREF_EXTENSIONS=1 )
5814 dnl ========================================================
5815 dnl Searching of system directories for extensions.
5816 dnl Note: this switch is meant to be used for test builds
5817 dnl whose behavior should not depend on what happens to be
5818 dnl installed on the local machine.
5819 dnl ========================================================
5820 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
5821 [  --disable-system-extension-dirs
5822                           Disable searching system- and account-global
5823                           directories for extensions of any kind; use
5824                           only profile-specific extension directories],
5825   ENABLE_SYSTEM_EXTENSION_DIRS=,
5826   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
5827 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
5828   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
5831 dnl ========================================================
5832 dnl = Universalchardet
5833 dnl ========================================================
5834 MOZ_ARG_DISABLE_BOOL(universalchardet,
5835 [  --disable-universalchardet
5836                           Disable universal encoding detection],
5837   MOZ_UNIVERSALCHARDET=,
5838   MOZ_UNIVERSALCHARDET=1 )
5840 if test -n "${JAVA_BIN_PATH}"; then
5841   dnl Look for javac and jar in the specified path.
5842   JAVA_PATH="$JAVA_BIN_PATH"
5843 else
5844   dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5845   JAVA_PATH="$JAVA_HOME/bin:$PATH"
5848 MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5849 MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5850 MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5852 if test -n "${JAVA_BIN_PATH}" -o \
5853   \( "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk" \); then
5854   if test -z "$JAVA" -o "$JAVA" = ":" -o -z "$JAVAC" -o "$JAVAC" = ":" -o -z "$JAR" -o "$JAR" = ":"; then
5855     AC_MSG_ERROR([The programs java, javac and jar were not found.  Set \$JAVA_HOME to your java sdk directory or use --with-java-bin-path={java-bin-dir}])
5856   fi
5859 dnl ========================================================
5860 dnl = ANGLE OpenGL->D3D translator for WebGL
5861 dnl = * only applies to win32
5862 dnl = * enabled by default (shipping build); requires explicit --disable to disable
5863 dnl ========================================================
5864 MOZ_ANGLE_RENDERER=
5865 MOZ_DIRECTX_SDK_PATH=
5866 MOZ_DIRECTX_SDK_CPU_SUFFIX=
5867 MOZ_D3DX9_VERSION=
5868 MOZ_D3DX9_CAB=
5869 MOZ_D3DCOMPILER_CAB=
5870 MOZ_D3DX9_DLL=
5871 MOZ_D3DCOMPILER_DLL=
5872 case "$target_os" in
5873 *mingw*)
5874     MOZ_ANGLE_RENDERER=1
5875     ;;
5876 esac
5878 # The DirectX SDK libraries are split into x86 and x64 sub-directories
5879 case "${target_cpu}" in
5880 i*86)
5881   MOZ_DIRECTX_SDK_CPU_SUFFIX=x86
5882   ;;
5883 x86_64)
5884   MOZ_DIRECTX_SDK_CPU_SUFFIX=x64
5885   ;;
5886 esac
5888 MOZ_ARG_DISABLE_BOOL(webgl,
5889 [  --disable-webgl     Disable building of the WebGL implementation],
5890     MOZ_WEBGL_DISABLED=1,
5891     MOZ_WEBGL_DISABLED=)
5893 if test -n "$MOZ_WEBGL_DISABLED"; then
5894   MOZ_WEBGL=
5895   MOZ_ANGLE_RENDERER=
5898 if test -n "$MOZ_ANGLE_RENDERER" -a -z "$CROSS_COMPILE"; then
5899   # Get the SDK path from the registry.
5900   # First try to get the June 2010 SDK
5901   MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK (June 2010)' | head -n 1`
5902   if test -z "$MOZ_DIRECTX_SDK_REG_KEY" ; then
5903     # Otherwise just take whatever comes first
5904     MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK' | head -n 1`
5905   fi
5907   if test -n "`echo $MOZ_DIRECTX_SDK_REG_KEY | grep 'February 2010'`" ; then
5908     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.])
5909   else
5910     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'`
5911   fi
5913   if test -n "$MOZ_DIRECTX_SDK_PATH" &&
5914      test -f "$MOZ_DIRECTX_SDK_PATH"/include/d3dx9.h &&
5915          test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5916     AC_MSG_RESULT([Found DirectX SDK via registry, using $MOZ_DIRECTX_SDK_PATH])
5917   else
5918     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.])
5919   fi
5921   # Get the SDK numeric version (e.g. 43) by looking at the dependencies of d3dx9.lib
5922   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'`
5924   if test -z "$MOZ_D3DX9_VERSION" ; then
5925         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.])
5926   fi
5928   MOZ_D3DX9_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *d3dx9_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
5929   MOZ_D3DCOMPILER_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *D3DCompiler_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
5931   if test -z "$MOZ_D3DX9_CAB" -o -z "$MOZ_D3DCOMPILER_CAB"; then
5932     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.])
5933   fi
5935   MOZ_D3DX9_DLL=d3dx9_$MOZ_D3DX9_VERSION.dll
5936   MOZ_D3DCOMPILER_DLL=D3DCompiler_$MOZ_D3DX9_VERSION.dll
5939 dnl ========================================================
5940 dnl = Breakpad crash reporting (on by default on supported platforms)
5941 dnl ========================================================
5943 case $target in
5944 i?86-*-mingw*|x86_64-*-mingw*)
5945   MOZ_CRASHREPORTER=1
5946   ;;
5947 i?86-apple-darwin*|x86_64-apple-darwin*)
5948   MOZ_CRASHREPORTER=1
5949   ;;
5950 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
5951   if test "$MOZ_ENABLE_GTK2"; then
5952     MOZ_CRASHREPORTER=1
5953   fi
5954   ;;
5955 *-android*|*-linuxandroid*)
5956   MOZ_CRASHREPORTER=1
5957   ;;
5958 *solaris*)
5959   MOZ_CRASHREPORTER=1
5960   ;;
5961 esac
5963 MOZ_ARG_DISABLE_BOOL(crashreporter,
5964 [  --disable-crashreporter Disable breakpad crash reporting],
5965     MOZ_CRASHREPORTER=,
5966     MOZ_CRASHREPORTER=1)
5968 if test -n "$MOZ_CRASHREPORTER"; then
5969    AC_DEFINE(MOZ_CRASHREPORTER)
5971   if test "$OS_TARGET" = "Linux" -o "$OS_ARCH" = "SunOS" && \
5972     test -z "$SKIP_LIBRARY_CHECKS"; then
5973     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
5974     AC_SUBST(MOZ_GTHREAD_CFLAGS)
5975     AC_SUBST(MOZ_GTHREAD_LIBS)
5976   fi
5978   if test "$OS_ARCH" != "$HOST_OS_ARCH"; then
5979     AC_MSG_ERROR([Breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.  Use --disable-crashreporter.])
5980   fi
5982   if test "$OS_ARCH" = "WINNT" -a -z "$HAVE_64BIT_OS"; then
5983     MOZ_CRASHREPORTER_INJECTOR=1
5984     AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
5985   fi
5988 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
5989 [  --with-crashreporter-enable-percent=NN
5990                           Enable sending crash reports by default on NN% of users. (default=100)],
5991 [ val=`echo $withval | sed 's/[^0-9]//g'`
5992     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
5994 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
5995    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
5997 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
5999 dnl ========================================================
6000 dnl = libjpeg-turbo configuration
6001 dnl ========================================================
6002 MOZ_LIBJPEG_TURBO=
6003 if test -z "$MOZ_NATIVE_JPEG"; then
6004     MOZ_LIBJPEG_TURBO=1
6007 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
6008 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
6009     MOZ_LIBJPEG_TURBO=,
6010     MOZ_LIBJPEG_TURBO=1)
6012 if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
6013     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
6016 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
6017 dnl files.
6019 if test -n "$MOZ_LIBJPEG_TURBO"; then
6021   dnl Do we support libjpeg-turbo on this platform?
6022   case "$OS_ARCH:$OS_TEST" in
6023   Darwin:i?86)
6024     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
6025     LIBJPEG_TURBO_X86_ASM=1
6026   ;;
6027   Darwin:x86_64)
6028     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
6029     LIBJPEG_TURBO_X64_ASM=1
6030   ;;
6031   WINNT:x86|WINNT:i?86)
6032     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
6033     LIBJPEG_TURBO_X86_ASM=1
6034   ;;
6035   WINNT:x86_64)
6036     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
6037     LIBJPEG_TURBO_X64_ASM=1
6038   ;;
6039   *:arm*)
6040     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
6041     LIBJPEG_TURBO_ARM_ASM=1
6042   ;;
6043   *:x86|*:i?86)
6044     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6045       LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6046       LIBJPEG_TURBO_X86_ASM=1
6047     fi
6048   ;;
6049   *:x86_64)
6050     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6051       LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6052       LIBJPEG_TURBO_X64_ASM=1
6053     fi
6054   ;;
6055   esac
6059 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
6060 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
6061 dnl it doesn't exist or we have too old of a version.
6062 if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
6063     AC_MSG_CHECKING([for Yasm assembler])
6064     AC_CHECK_PROGS(LIBJPEG_TURBO_AS, yasm, "")
6066     if test -z "$LIBJPEG_TURBO_AS" ; then
6067         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.])
6068     fi
6070     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
6071     dnl on Linux and 1.1 or newer everywhere else.
6072     if test "$OS_ARCH" = "Linux" ; then
6073         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
6074             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.])
6075         fi
6076     else
6077         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
6078             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.])
6079         fi
6080     fi
6083 dnl If we're on an ARM system which supports libjpeg-turbo's asm routines and
6084 dnl --disable-libjpeg-turbo wasn't passed, use the C compiler as the assembler.
6085 if test -n "$LIBJPEG_TURBO_ARM_ASM" ; then
6086     echo "Using $AS as the assembler for ARM code."
6087     LIBJPEG_TURBO_AS=$AS
6090 if test -n "$LIBJPEG_TURBO_X86_ASM"; then
6091     AC_DEFINE(LIBJPEG_TURBO_X86_ASM)
6092 elif test -n "$LIBJPEG_TURBO_X64_ASM"; then
6093     AC_DEFINE(LIBJPEG_TURBO_X64_ASM)
6094 elif test -n "$LIBJPEG_TURBO_ARM_ASM"; then
6095     AC_DEFINE(LIBJPEG_TURBO_ARM_ASM)
6096 elif test -n "$MOZ_LIBJPEG_TURBO"; then
6097     dnl Warn if we're not building the optimized routines, even though the user
6098     dnl didn't specify --disable-libjpeg-turbo.
6099     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
6102 dnl ========================================================
6103 dnl = Enable compilation of specific extension modules
6104 dnl ========================================================
6106 MOZ_ARG_ENABLE_STRING(extensions,
6107 [  --enable-extensions     Enable extensions],
6108 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6109     if test "$option" = "yes" -o "$option" = "all"; then
6110         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
6111     elif test "$option" = "no" -o "$option" = "none"; then
6112         MOZ_EXTENSIONS=""
6113     elif test "$option" = "default"; then
6114         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
6115     elif test `echo "$option" | grep -c \^-` != 0; then
6116         option=`echo $option | sed 's/^-//'`
6117         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
6118     else
6119         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
6120     fi
6121 done],
6122     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
6124 if test -z "$MOZ_ENABLE_GNOMEVFS" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6125     # Suppress warning on non-X11 platforms
6126     if test -n "$MOZ_X11"; then
6127         AC_MSG_WARN([Removing gnomevfs from MOZ_EXTENSIONS due to no --enable-gnomevfs.])
6128     fi
6129     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6132 dnl Do not build gnomevfs with libxul based apps
6133 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6134     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6137 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6138     # Suppress warning on non-X11 platforms
6139     if test -n "$MOZ_X11"; then
6140         AC_MSG_WARN([Removing gio from MOZ_EXTENSIONS due to --disable-gio.])
6141     fi
6142     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6145 dnl Do not build gio with libxul based apps
6146 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6147     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6150 if test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6151     MOZ_GIO_COMPONENT=1
6152     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6154 AC_SUBST(MOZ_GIO_COMPONENT)
6156 if test -z "$MOZ_JSDEBUGGER" -a `echo "$MOZ_EXTENSIONS" | grep -c venkman` -ne 0; then
6157     AC_MSG_WARN([Cannot build venkman without JavaScript debug library. Removing venkman from MOZ_EXTENSIONS.])
6158     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|venkman||'`
6161 dnl Remove dupes
6162 MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
6164 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6165 dnl when trying to build a nonexistent extension.
6166 for extension in $MOZ_EXTENSIONS; do
6167     if test ! -d "${srcdir}/extensions/${extension}"; then
6168         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6169     fi
6170 done
6172 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
6173   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
6176 dnl ========================================================
6177 dnl CSS3 Flexbox Support
6178 dnl ========================================================
6179 if test -n "$MOZ_FLEXBOX"; then
6180   AC_DEFINE(MOZ_FLEXBOX)
6183 dnl ========================================================
6184 dnl Build Freetype in the tree
6185 dnl ========================================================
6186 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6187 [  --enable-tree-freetype  Enable Tree FreeType],
6188     MOZ_TREE_FREETYPE=1,
6189     MOZ_TREE_FREETYPE= )
6190 if test -n "$MOZ_TREE_FREETYPE"; then
6191    if test -n "$_WIN32_MSVC"; then
6192       AC_ERROR("building with in-tree freetype is not supported on MSVC")
6193    fi
6194    AC_DEFINE(MOZ_TREE_FREETYPE)
6195    AC_SUBST(MOZ_TREE_FREETYPE)
6196    MOZ_ENABLE_CAIRO_FT=1
6197    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6198    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6199    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6200    FT2_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6201    CAIRO_FT_OSLIBS=''
6202    CAIRO_FT_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6203    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6204    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6205    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6206    AC_SUBST(CAIRO_FT_CFLAGS)
6209 dnl ========================================================
6210 dnl Installer
6211 dnl ========================================================
6212 dnl Abort Windows build if the required major version and
6213 dnl minimum minor version of Unicode NSIS isn't in the path
6214 dnl (unless in case of cross compiling, for which Unicode
6215 dnl is not yet sufficient).
6216 if test "$OS_ARCH" = "WINNT"; then
6217     REQ_NSIS_MAJOR_VER=2
6218     MIN_NSIS_MINOR_VER=46
6219     MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensisu-2.46 makensis)
6220     if test -n "$MAKENSISU" -a "$MAKENSISU" != ":"; then
6221       AC_MSG_RESULT([yes])
6222       changequote(,)
6223       MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\)\-Unicode$/\1/g'`
6224       changequote([,])
6225       if test ! "$MAKENSISU_VER" = ""; then
6226           MAKENSISU_MAJOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $1 }'`
6227           MAKENSISU_MINOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $2 }'`
6228       fi
6229       AC_MSG_CHECKING([for Unicode NSIS with major version == $REQ_NSIS_MAJOR_VER and minor version >= $MIN_NSIS_MINOR_VER])
6230       if test "$MAKENSISU_VER" = "" || \
6231          test ! "$MAKENSISU_MAJOR_VER" = "$REQ_NSIS_MAJOR_VER" -o \
6232               ! "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER; then
6233           AC_MSG_RESULT([no])
6234           if test -z "$CROSS_COMPILE"; then
6235             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.])
6236           else
6237             MAKENSISU=
6238           fi
6239       fi
6240     elif test -z "$CROSS_COMPILE"; then
6241       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.])
6242     else
6243       MAKENSISU=
6244     fi
6247 dnl ========================================================
6248 dnl Web App Runtime
6249 dnl ========================================================
6250 MOZ_ARG_DISABLE_BOOL(webapp-runtime,
6251 [  --disable-webapp-runtime  Disable Web App Runtime],
6252     MOZ_WEBAPP_RUNTIME=,
6253     MOZ_WEBAPP_RUNTIME=1)
6254 if test "$MOZ_WIDGET_TOOLKIT" != "windows" -a "$MOZ_WIDGET_TOOLKIT" != "cocoa" -a "$MOZ_WIDGET_TOOLKIT" != "gtk2"; then
6255     MOZ_WEBAPP_RUNTIME=
6257 if test "$OS_ARCH" = "WINNT" -a -z "$MAKENSISU" -a -n "$CROSS_COMPILE"; then
6258     MOZ_WEBAPP_RUNTIME=
6260 AC_SUBST(MOZ_WEBAPP_RUNTIME)
6261 if test "$MOZ_WEBAPP_RUNTIME"; then
6262     AC_DEFINE(MOZ_WEBAPP_RUNTIME)
6265 AC_MSG_CHECKING([for tar archiver])
6266 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6267 if test -z "$TAR"; then
6268     AC_MSG_ERROR([no tar archiver found in \$PATH])
6270 AC_MSG_RESULT([$TAR])
6271 AC_SUBST(TAR)
6273 AC_MSG_CHECKING([for wget])
6274 AC_CHECK_PROGS(WGET, wget, "")
6275 AC_MSG_RESULT([$WGET])
6276 AC_SUBST(WGET)
6278 dnl ========================================================
6279 dnl Signing
6280 dnl ========================================================
6282 if test -n "$MOZ_SIGN_CMD"; then
6283     AC_DEFINE(MOZ_SIGNING)
6286 dnl ========================================================
6287 dnl Maintenance Service
6288 dnl ========================================================
6290 MOZ_ARG_ENABLE_BOOL(maintenance-service,
6291 [  --enable-maintenance-service       Enable building of maintenanceservice],
6292     MOZ_MAINTENANCE_SERVICE=1,
6293     MOZ_MAINTENANCE_SERVICE= )
6295 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
6296   if test "$OS_ARCH" = "WINNT"; then
6297     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
6298   else
6299     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
6300   fi
6303 dnl ========================================================
6304 dnl Verify MAR signatures
6305 dnl ========================================================
6307 MOZ_ARG_ENABLE_BOOL(verify-mar,
6308 [  --enable-verify-mar     Enable verifying MAR signatures],
6309     MOZ_VERIFY_MAR_SIGNATURE=1,
6310     MOZ_VERIFY_MAR_SIGNATURE= )
6312 if test -n "$MOZ_VERIFY_MAR_SIGNATURE"; then
6313   if test "$OS_ARCH" = "WINNT"; then
6314     AC_DEFINE(MOZ_VERIFY_MAR_SIGNATURE)
6315   else
6316     AC_MSG_ERROR([Can only build with --enable-verify-mar with a Windows target])
6317   fi
6320 dnl ========================================================
6321 dnl Enable building the signmar program.
6322 dnl This option is much different than the --enable-verify-mar option.
6323 dnl --enable-verify-mar is for enabling the verification check on MAR
6324 dnl files in the updater.  The --enable-signmar option is for building
6325 dnl the signmar program.
6326 dnl ========================================================
6328 MOZ_ARG_ENABLE_BOOL(signmar,
6329 [  --enable-signmar     Enable building the signmar program],
6330     MOZ_ENABLE_SIGNMAR=1,
6331     MOZ_ENABLE_SIGNMAR= )
6333 if test -n "$MOZ_ENABLE_SIGNMAR"; then
6334   AC_DEFINE(MOZ_ENABLE_SIGNMAR)
6337 dnl ========================================================
6338 dnl Updater
6339 dnl ========================================================
6341 MOZ_ARG_DISABLE_BOOL(updater,
6342 [  --disable-updater       Disable building of updater],
6343     MOZ_UPDATER=,
6344     MOZ_UPDATER=1 )
6346 if test -n "$MOZ_UPDATER"; then
6347     AC_DEFINE(MOZ_UPDATER)
6350 # tools/update-packaging is not checked out by default.
6351 MOZ_ARG_ENABLE_BOOL(update-packaging,
6352 [  --enable-update-packaging
6353                           Enable tools/update-packaging],
6354     MOZ_UPDATE_PACKAGING=1,
6355     MOZ_UPDATE_PACKAGING= )
6356 AC_SUBST(MOZ_UPDATE_PACKAGING)
6358 dnl ========================================================
6359 dnl build the tests by default
6360 dnl ========================================================
6361 MOZ_ARG_DISABLE_BOOL(tests,
6362 [  --disable-tests         Do not build test libraries & programs],
6363     ENABLE_TESTS=,
6364     ENABLE_TESTS=1 )
6366 dnl ========================================================
6367 dnl parental controls (for Windows Vista)
6368 dnl ========================================================
6369 MOZ_ARG_DISABLE_BOOL(parental-controls,
6370 [  --disable-parental-controls
6371                           Do not build parental controls],
6372    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6373    MOZ_DISABLE_PARENTAL_CONTROLS=)
6374 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6375     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6378 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6380 dnl ========================================================
6381 dnl = Disable DOMCrypto
6382 dnl ========================================================
6383 if test -n "$MOZ_DISABLE_DOMCRYPTO"; then
6384     AC_DEFINE(MOZ_DISABLE_DOMCRYPTO)
6387 dnl ========================================================
6388 dnl =
6389 dnl = Module specific options
6390 dnl =
6391 dnl ========================================================
6392 MOZ_ARG_HEADER(Individual module options)
6394 dnl ========================================================
6395 dnl = Disable feed handling components
6396 dnl ========================================================
6397 MOZ_ARG_DISABLE_BOOL(feeds,
6398 [  --disable-feeds         Disable feed handling and processing components],
6399     MOZ_FEEDS=,
6400     MOZ_FEEDS=1 )
6401 if test -n "$MOZ_FEEDS"; then
6402     AC_DEFINE(MOZ_FEEDS)
6403 else
6404     if test "$MOZ_BUILD_APP" = "browser"; then
6405         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6406     fi
6409 dnl ========================================================
6410 dnl Check for sqlite
6411 dnl ========================================================
6413 MOZ_NATIVE_SQLITE=
6414 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6415 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6416 MOZ_NATIVE_SQLITE=1,
6417 MOZ_NATIVE_SQLITE= )
6419 if test -z "$MOZ_NATIVE_SQLITE"
6420 then
6421     SQLITE_CFLAGS=
6422     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
6423 else
6424     dnl ============================
6425     dnl === SQLite Version check ===
6426     dnl ============================
6427     dnl Check to see if the system SQLite package is new enough.
6428     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6430     dnl ==================================
6431     dnl === SQLITE_SECURE_DELETE check ===
6432     dnl ==================================
6433     dnl Check to see if the system SQLite package is compiled with
6434     dnl SQLITE_SECURE_DELETE enabled.
6435     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
6436     _SAVE_CFLAGS="$CFLAGS"
6437     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6438     _SAVE_LIBS="$LIBS"
6439     LIBS="$LIBS $SQLITE_LIBS"
6440     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6441         AC_TRY_RUN([
6442             #include "sqlite3.h"
6444             int main(int argc, char **argv){
6445               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
6446             }],
6447             ac_cv_sqlite_secure_delete=yes,
6448             ac_cv_sqlite_secure_delete=no,
6449             ac_cv_sqlite_secure_delete=no
6450         )
6451     ])
6452     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6453     CFLAGS="$_SAVE_CFLAGS"
6454     LIBS="$_SAVE_LIBS"
6455     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6456         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
6457     fi
6459     dnl ===============================
6460     dnl === SQLITE_THREADSAFE check ===
6461     dnl ===============================
6462     dnl Check to see if the system SQLite package is compiled with
6463     dnl SQLITE_THREADSAFE enabled.
6464     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
6465     _SAVE_CFLAGS="$CFLAGS"
6466     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6467     _SAVE_LIBS="$LIBS"
6468     LIBS="$LIBS $SQLITE_LIBS"
6469     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
6470         AC_TRY_RUN([
6471             #include "sqlite3.h"
6473             int main(int argc, char **argv){
6474               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
6475             }],
6476             ac_cv_sqlite_threadsafe=yes,
6477             ac_cv_sqlite_threadsafe=no,
6478             ac_cv_sqlite_threadsafe=no
6479         )
6480     ])
6481     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
6482     CFLAGS="$_SAVE_CFLAGS"
6483     LIBS="$_SAVE_LIBS"
6484     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
6485         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
6486     fi
6488     dnl ================================
6489     dnl === SQLITE_ENABLE_FTS3 check ===
6490     dnl ================================
6491     dnl check to see if the system SQLite package is compiled with
6492     dnl SQLITE_ENABLE_FTS3 enabled.
6493     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
6494     _SAVE_CFLAGS="$CFLAGS"
6495     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6496     _SAVE_LIBS="$LIBS"
6497     LIBS="$LIBS $SQLITE_LIBS"
6498     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
6499         AC_TRY_RUN([
6500             #include "sqlite3.h"
6502             int main(int argc, char **argv){
6503               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
6504             }],
6505             ac_cv_sqlite_enable_fts3=yes,
6506             ac_cv_sqlite_enable_fts3=no,
6507             ac_cv_sqlite_enable_fts3=no
6508         )
6509     ])
6510     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
6511     CFLAGS="$_SAVE_CFLAGS"
6512     LIBS="$_SAVE_LIBS"
6513     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
6514         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
6515     fi
6517     dnl =========================================
6518     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
6519     dnl =========================================
6520     dnl check to see if the system SQLite package is compiled with
6521     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
6522     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
6523     _SAVE_CFLAGS="$CFLAGS"
6524     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6525     _SAVE_LIBS="$LIBS"
6526     LIBS="$LIBS $SQLITE_LIBS"
6527     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
6528         AC_TRY_RUN([
6529             #include "sqlite3.h"
6531             int main(int argc, char **argv){
6532               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
6533             }],
6534             ac_cv_sqlite_enable_unlock_notify=yes,
6535             ac_cv_sqlite_enable_unlock_notify=no,
6536             ac_cv_sqlite_enable_unlock_notify=no
6537         )
6538     ])
6539     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
6540     CFLAGS="$_SAVE_CFLAGS"
6541     LIBS="$_SAVE_LIBS"
6542     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
6543         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
6544     fi
6547 if test -n "$MOZ_NATIVE_SQLITE"; then
6548     AC_DEFINE(MOZ_NATIVE_SQLITE)
6550 AC_SUBST(MOZ_NATIVE_SQLITE)
6552 dnl ========================================================
6553 dnl = Enable help viewer (off by default)
6554 dnl ========================================================
6555 if test -n "$MOZ_HELP_VIEWER"; then
6556      dnl Do this if defined in confvars.sh
6557      AC_DEFINE(MOZ_HELP_VIEWER)
6560 dnl ========================================================
6561 dnl = Enable safe browsing (anti-phishing)
6562 dnl ========================================================
6563 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6564 [  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation],
6565     MOZ_SAFE_BROWSING=1,
6566     MOZ_SAFE_BROWSING= )
6567 if test -n "$MOZ_SAFE_BROWSING"; then
6568     AC_DEFINE(MOZ_SAFE_BROWSING)
6570 AC_SUBST(MOZ_SAFE_BROWSING)
6572 dnl ========================================================
6573 dnl = Enable url-classifier
6574 dnl ========================================================
6575 dnl Implicitly enabled by default if building with safe-browsing
6576 if test -n "$MOZ_SAFE_BROWSING"; then
6577     MOZ_URL_CLASSIFIER=1
6579 MOZ_ARG_ENABLE_BOOL(url-classifier,
6580 [  --enable-url-classifier Enable url classifier module],
6581     MOZ_URL_CLASSIFIER=1,
6582     MOZ_URL_CLASSIFIER= )
6583 if test -n "$MOZ_URL_CLASSIFIER"; then
6584     AC_DEFINE(MOZ_URL_CLASSIFIER)
6586 AC_SUBST(MOZ_URL_CLASSIFIER)
6588 dnl ========================================================
6589 dnl = Disable zipwriter
6590 dnl ========================================================
6591 MOZ_ARG_DISABLE_BOOL(zipwriter,
6592 [  --disable-zipwriter     Disable zipwriter component],
6593     MOZ_ZIPWRITER=,
6594     MOZ_ZIPWRITER=1 )
6595 AC_SUBST(MOZ_ZIPWRITER)
6597 dnl ========================================================
6598 dnl = libconic
6599 dnl ========================================================
6600 dnl superseded by QtNetwork starting from 4.7
6601 MOZ_ENABLE_LIBCONIC=1
6603 if test -n "$MOZ_ENABLE_QT"; then
6604   if test "$MOZ_ENABLE_QTNETWORK"; then
6605     MOZ_ENABLE_LIBCONIC=
6606   fi
6609 MOZ_ARG_DISABLE_BOOL(libconic,
6610 [  --disable-libconic      Disable libconic],
6611     MOZ_ENABLE_LIBCONIC=,
6612     MOZ_ENABLE_LIBCONIC=1 )
6614 if test -n "$MOZ_ENABLE_LIBCONIC"; then
6615     PKG_CHECK_MODULES(LIBCONIC, conic,
6616                       MOZ_ENABLE_LIBCONIC=1,
6617                       MOZ_ENABLE_LIBCONIC=)
6619 if test "$MOZ_ENABLE_LIBCONIC"; then
6620     AC_DEFINE(MOZ_ENABLE_LIBCONIC)
6623 AC_SUBST(MOZ_ENABLE_LIBCONIC)
6624 AC_SUBST(LIBCONIC_CFLAGS)
6625 AC_SUBST(LIBCONIC_LIBS)
6627 dnl ========================================================
6628 dnl = Maemo checks
6629 dnl ========================================================
6631 MAEMO_SDK_TARGET_VER=-1
6633 MOZ_ARG_WITH_STRING(maemo-version,
6634 [  --with-maemo-version=MAEMO_SDK_TARGET_VER
6635                           Maemo SDK Version],
6636   MAEMO_SDK_TARGET_VER=$withval)
6638 case "$MAEMO_SDK_TARGET_VER" in
6640     MOZ_PLATFORM_MAEMO=5
6641     ;;
6644     MOZ_PLATFORM_MAEMO=6
6645     ;;
6648     dnl We aren't compiling for Maemo, move on.
6649     ;;
6651     AC_MSG_ERROR([Unknown Maemo Version.  Try setting --with-maemo-version to 5 or 6.])
6652     ;;
6653 esac
6655 if test $MOZ_PLATFORM_MAEMO; then
6656    AC_DEFINE_UNQUOTED([MOZ_PLATFORM_MAEMO], $MOZ_PLATFORM_MAEMO)
6658    if test -z "$MOZ_ENABLE_DBUS"; then
6659        AC_MSG_ERROR([DBus is required when building for Maemo])
6660    fi
6662    MOZ_GFX_OPTIMIZE_MOBILE=1
6663    MOZ_GL_DEFAULT_PROVIDER=EGL
6664    MOZ_MAEMO_LIBLOCATION=
6666    if test $MOZ_PLATFORM_MAEMO = 5; then
6667       dnl if we have Xcomposite we should also have Xdamage and Xfixes
6668       MOZ_CHECK_HEADERS([X11/extensions/Xdamage.h], [],
6669           [AC_MSG_ERROR([Couldn't find X11/extensions/Xdamage.h which is required for composited plugins.])])
6670       AC_CHECK_LIB(Xcomposite, XCompositeRedirectWindow, [XCOMPOSITE_LIBS="-lXcomposite -lXdamage -lXfixes"],
6671                    [MISSING_X="$MISSING_X -lXcomposite"], $XLIBS)
6673       AC_SUBST(XCOMPOSITE_LIBS)
6675       PKG_CHECK_MODULES(LIBHILDONMIME,libhildonmime, _LIB_FOUND=1, _LIB_FOUND=)
6676       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONMIME_LIBS"
6677       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONMIME_CFLAGS"
6678       if test -z "$_LIB_FOUND"; then
6679          AC_MSG_ERROR([Hildon Mime is required when building for Maemo])
6680       fi
6683       PKG_CHECK_MODULES(LIBOSSO,libosso, _LIB_FOUND=1, _LIB_FOUND=)
6684       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBOSSO_LIBS"
6685       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBOSSO_CFLAGS"
6686       if test -z "$_LIB_FOUND"; then
6687          AC_MSG_ERROR([LibOSSO is required when building for Maemo])
6688       fi
6690       PKG_CHECK_MODULES(LIBHILDONFM,hildon-fm-2, _LIB_FOUND=1, _LIB_FOUND=)
6691       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONFM_LIBS"
6692       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONFM_CFLAGS"
6693       if test -z "$_LIB_FOUND"; then
6694          AC_MSG_ERROR([Hildon FM-2 is required when building for Maemo])
6695       fi
6697    fi
6698    if test $MOZ_PLATFORM_MAEMO = 6; then
6700       PKG_CHECK_MODULES(LIBCONTENTMANAGER, ContentManager QtSparql,
6701                         _LIB_FOUND=1,
6702                         _LIB_FOUND=)
6703       if test "$_LIB_FOUND"; then
6704          MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTMANAGER_LIBS"
6705          MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTMANAGER_CFLAGS"
6706          MOZ_ENABLE_CONTENTMANAGER=1
6707          AC_DEFINE(MOZ_ENABLE_CONTENTMANAGER)
6708       else
6709          AC_MSG_WARN([Cannot find libcontentmanager and or QtSparql building for Maemo 6])
6710       fi
6711       AC_SUBST(MOZ_ENABLE_CONTENTMANAGER)
6713       dnl ========================================================
6714       dnl = Enable meego libcontentaction
6715       dnl ========================================================
6716       MOZ_ARG_ENABLE_BOOL(meegocontentaction,
6717       [  --enable-meegocontentaction           Enable meegocontentaction support],
6718          MOZ_MEEGOCONTENTACTION=1,
6719          MOZ_MEEGOCONTENTACTION=)
6721       if test -n "$MOZ_MEEGOCONTENTACTION"; then
6723          PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
6724          if test "$_LIB_FOUND"; then
6725             MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTACTION_LIBS"
6726             MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTACTION_CFLAGS"
6727             MOZ_ENABLE_CONTENTACTION=1
6728             AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
6729             AC_SUBST(MOZ_ENABLE_CONTENTACTION)
6730          fi
6731       fi
6733       MOZ_ARG_ENABLE_BOOL(meegotouch,
6734       [  --enable-meegotouch  Enable meegotouch support],
6735          MOZ_MEEGOTOUCHENABLED=1,
6736          MOZ_MEEGOTOUCHENABLED=)
6738       if test -n "$MOZ_MEEGOTOUCHENABLED"; then
6739           PKG_CHECK_MODULES(MOZ_MEEGOTOUCH, meegotouchcore, _LIB_FOUND=1, _LIB_FOUND=)
6740           if test "$_LIB_FOUND"; then
6741               MOZ_QT_CFLAGS="$MOZ_MEEGOTOUCH_CFLAGS $MOZ_QT_CFLAGS"
6742               MOZ_QT_LIBS="$MOZ_MEEGOTOUCH_LIBS $MOZ_QT_LIBS"
6743               AC_DEFINE(MOZ_ENABLE_MEEGOTOUCH)
6744           else
6745               AC_MSG_WARN([Cannot meegotouchcore-dev. Disabling Meegotouch support.])
6746           fi
6747       fi
6748    fi
6750    PKG_CHECK_MODULES(LIBLOCATION,liblocation, _LIB_FOUND=1, _LIB_FOUND=)
6751    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBLOCATION_LIBS"
6752    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBLOCATION_CFLAGS"
6753    if test "$_LIB_FOUND"; then
6754       MOZ_MAEMO_LIBLOCATION=1
6755       AC_DEFINE(MOZ_MAEMO_LIBLOCATION)
6756    else
6757       AC_MSG_WARN([Cannot liblocation-dev. Disabling Maemo geolocation.])
6758    fi
6759    AC_SUBST(MOZ_MAEMO_LIBLOCATION)
6761    PKG_CHECK_MODULES(LIBMEEGOTOUCHSHARE, ShareUiInterface-maemo-meegotouch >= 0.3.31 mdatauri, _LIB_FOUND=1, _LIB_FOUND=)
6762    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBMEEGOTOUCHSHARE_LIBS"
6763    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBMEEGOTOUCHSHARE_CFLAGS"
6764    if test "$_LIB_FOUND"; then
6765       MOZ_ENABLE_MEEGOTOUCHSHARE=1
6766       AC_DEFINE(MOZ_ENABLE_MEEGOTOUCHSHARE)
6767    else
6768       AC_MSG_WARN([Cannot find maemo-meegotouch-interfaces-dev or libmdatauri-dev. Disabling meegotouch share ui.])
6769    fi
6770    AC_SUBST(MOZ_ENABLE_MEEGOTOUCHSHARE)
6772    AC_SUBST(MOZ_PLATFORM_MAEMO_LIBS)
6773    AC_SUBST(MOZ_PLATFORM_MAEMO_CFLAGS)
6776 dnl ========================================================
6777 dnl GL provider
6778 dnl ========================================================
6779 MOZ_GL_PROVIDER=
6780 MOZ_ARG_WITH_STRING(gl-provider,
6781 [  --with-gl-provider=ID
6782                           Set GL provider backend type],
6783 [ val=`echo $withval`
6784     MOZ_GL_PROVIDER="$val"])
6786 if test -n "$MOZ_GL_PROVIDER"; then
6787 MOZ_GL_DEFAULT_PROVIDER=$MOZ_GL_PROVIDER
6788 AC_SUBST(MOZ_GL_PROVIDER)
6789 AC_DEFINE_UNQUOTED(MOZ_GL_PROVIDER, GLContextProvider$MOZ_GL_PROVIDER)
6791 AC_SUBST(MOZ_GL_DEFAULT_PROVIDER)
6792 AC_DEFINE_UNQUOTED(GL_PROVIDER_$MOZ_GL_DEFAULT_PROVIDER)
6794 dnl ========================================================
6795 dnl = faststripe theme
6796 dnl ========================================================
6797 MOZ_ARG_ENABLE_BOOL(faststripe,
6798 [  --enable-faststripe     Use faststripe theme],
6799     MOZ_THEME_FASTSTRIPE=1,
6800     MOZ_THEME_FASTSTRIPE= )
6801 AC_SUBST(MOZ_THEME_FASTSTRIPE)
6803 dnl ========================================================
6804 dnl =
6805 dnl = Feature options that require extra sources to be pulled
6806 dnl =
6807 dnl ========================================================
6808 dnl MOZ_ARG_HEADER(Features that require extra sources)
6810 dnl ========================================================
6811 dnl =
6812 dnl = Debugging Options
6813 dnl =
6814 dnl ========================================================
6815 MOZ_ARG_HEADER(Debugging and Optimizations)
6817 dnl ========================================================
6818 dnl = Disable building with debug info.
6819 dnl = Debugging is OFF by default
6820 dnl ========================================================
6821 if test -z "$MOZ_DEBUG_FLAGS"; then
6822   MOZ_DEBUG_FLAGS="-g"
6825 MOZ_ARG_ENABLE_STRING(debug,
6826 [  --enable-debug[=DBG]    Enable building with developer debug info
6827                            (using compiler flags DBG)],
6828 [ if test "$enableval" != "no"; then
6829     MOZ_DEBUG=1
6830     if test -n "$enableval" -a "$enableval" != "yes"; then
6831         MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6832         _MOZ_DEBUG_FLAGS_SET=1
6833     fi
6834   else
6835     MOZ_DEBUG=
6836   fi ],
6837   MOZ_DEBUG=)
6839 MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG -DTRACING"
6840 MOZ_ARG_WITH_STRING(debug-label,
6841 [  --with-debug-label=LABELS
6842                           Define DEBUG_<value> for each comma-separated
6843                           value given.],
6844 [ for option in `echo $withval | sed 's/,/ /g'`; do
6845     MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${option}"
6846 done])
6848 MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
6850 if test -n "$MOZ_DEBUG"; then
6851     AC_MSG_CHECKING([for valid debug flags])
6852     _SAVE_CFLAGS=$CFLAGS
6853     CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS"
6854     AC_TRY_COMPILE([#include <stdio.h>],
6855         [printf("Hello World\n");],
6856         _results=yes,
6857         _results=no)
6858     AC_MSG_RESULT([$_results])
6859     if test "$_results" = "no"; then
6860         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_DEBUG_FLAGS])
6861     fi
6862     CFLAGS=$_SAVE_CFLAGS
6865 dnl ========================================================
6866 dnl enable mobile optimizations
6867 dnl ========================================================
6868 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
6869 [  --enable-mobile-optimize
6870                           Enable mobile optimizations],
6871     MOZ_GFX_OPTIMIZE_MOBILE=1)
6873 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
6875 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
6876     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
6879 dnl ========================================================
6880 dnl = Enable code optimization. ON by default.
6881 dnl ========================================================
6882 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
6883         MOZ_OPTIMIZE_FLAGS="-O"
6886 MOZ_ARG_ENABLE_STRING(optimize,
6887 [  --disable-optimize      Disable compiler optimization
6888   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
6889 [ if test "$enableval" != "no"; then
6890     MOZ_OPTIMIZE=1
6891     if test -n "$enableval" -a "$enableval" != "yes"; then
6892         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
6893         MOZ_OPTIMIZE=2
6894     fi
6895 else
6896     MOZ_OPTIMIZE=
6897 fi ], MOZ_OPTIMIZE=1)
6899 MOZ_SET_FRAMEPTR_FLAGS
6901 if test "$COMPILE_ENVIRONMENT"; then
6902 if test -n "$MOZ_OPTIMIZE"; then
6903     AC_MSG_CHECKING([for valid optimization flags])
6904     _SAVE_CFLAGS=$CFLAGS
6905     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
6906     AC_TRY_COMPILE([#include <stdio.h>],
6907         [printf("Hello World\n");],
6908         _results=yes,
6909         _results=no)
6910     AC_MSG_RESULT([$_results])
6911     if test "$_results" = "no"; then
6912         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
6913     fi
6914     CFLAGS=$_SAVE_CFLAGS
6916 fi # COMPILE_ENVIRONMENT
6918 AC_SUBST(MOZ_OPTIMIZE)
6919 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
6920 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
6921 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
6922 AC_SUBST(MOZ_ALLOW_HEAP_EXECUTE_FLAGS)
6923 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
6924 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
6926 dnl ========================================================
6927 dnl = Enable generation of debug symbols
6928 dnl ========================================================
6929 MOZ_ARG_ENABLE_STRING(debug-symbols,
6930 [  --enable-debug-symbols[=DBG]
6931                           Enable debugging symbols (using compiler flags DBG)],
6932 [ if test "$enableval" != "no"; then
6933       MOZ_DEBUG_SYMBOLS=1
6934       if test -n "$enableval" -a "$enableval" != "yes"; then
6935           if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
6936               MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6937           else
6938               AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
6939           fi
6940       fi
6941   else
6942       MOZ_DEBUG_SYMBOLS=
6943   fi ],
6944   MOZ_DEBUG_SYMBOLS=1)
6946 if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
6947     AC_DEFINE(MOZ_DEBUG_SYMBOLS)
6948     export MOZ_DEBUG_SYMBOLS
6951 dnl ========================================================
6952 dnl = Enable any treating of compile warnings as errors
6953 dnl ========================================================
6954 MOZ_ARG_ENABLE_BOOL(warnings-as-errors,
6955 [  --enable-warnings-as-errors
6956                           Enable treating of warnings as errors],
6957     MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
6958     MOZ_ENABLE_WARNINGS_AS_ERRORS=)
6959 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
6960    WARNINGS_AS_ERRORS=''
6963 dnl ========================================================
6964 dnl = Disable runtime logging checks
6965 dnl ========================================================
6966 MOZ_ARG_DISABLE_BOOL(logging,
6967 [  --disable-logging       Disable logging facilities],
6968     NS_DISABLE_LOGGING=1,
6969     NS_DISABLE_LOGGING= )
6970 if test "$NS_DISABLE_LOGGING"; then
6971     AC_DEFINE(NS_DISABLE_LOGGING)
6972 else
6973     AC_DEFINE(MOZ_LOGGING)
6976 dnl ========================================================
6977 dnl = This will enable logging of addref, release, ctor, dtor.
6978 dnl ========================================================
6979 _ENABLE_LOGREFCNT=42
6980 MOZ_ARG_ENABLE_BOOL(logrefcnt,
6981 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
6982     _ENABLE_LOGREFCNT=1,
6983     _ENABLE_LOGREFCNT= )
6984 if test "$_ENABLE_LOGREFCNT" = "1"; then
6985     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
6986 elif test -z "$_ENABLE_LOGREFCNT"; then
6987     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
6990 dnl ========================================================
6991 dnl moz_dump_painting
6992 dnl ========================================================
6993 MOZ_ARG_ENABLE_BOOL(dump-painting,
6994 [  --enable-dump-painting          Enable paint debugging.],
6995     MOZ_DUMP_PAINTING=1,
6996     MOZ_DUMP_PAINTING= )
6997 if test -n "$MOZ_DUMP_PAINTING"; then
6998     AC_DEFINE(MOZ_DUMP_PAINTING)
6999     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
7001 if test -n "$MOZ_DEBUG"; then
7002     AC_DEFINE(MOZ_DUMP_PAINTING)
7005 dnl ========================================================
7006 dnl = Enable trace malloc
7007 dnl ========================================================
7008 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
7009 MOZ_ARG_ENABLE_BOOL(trace-malloc,
7010 [  --enable-trace-malloc   Enable malloc tracing; also disables DMD and jemalloc],
7011     NS_TRACE_MALLOC=1,
7012     NS_TRACE_MALLOC= )
7013 if test "$NS_TRACE_MALLOC"; then
7014   # Please, Mr. Linker Man, don't take away our symbol names
7015   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
7016   USE_ELF_DYNSTR_GC=
7017   AC_DEFINE(NS_TRACE_MALLOC)
7019 AC_SUBST(NS_TRACE_MALLOC)
7021 dnl ========================================================
7022 dnl = Enable DMD
7023 dnl ========================================================
7025 MOZ_ARG_ENABLE_BOOL(dmd,
7026 [  --enable-dmd            Enable DMD; also enables jemalloc and replace-malloc],
7027     MOZ_DMD=1,
7028     MOZ_DMD= )
7030 if test "$NS_TRACE_MALLOC"; then        # trace-malloc disables DMD
7031     MOZ_DMD=
7033 if test "$MOZ_DMD"; then
7034     USE_ELF_DYNSTR_GC=
7035     AC_DEFINE(MOZ_DMD)
7037     if test "${CPU_ARCH}" = "arm"; then
7038         CFLAGS="$CFLAGS -funwind-tables"
7039         CXXFLAGS="$CXXFLAGS -funwind-tables"
7040     fi
7042     MOZ_MEMORY=1                        # DMD enables jemalloc
7043     MOZ_REPLACE_MALLOC=1                # DMD enables replace-malloc
7045 AC_SUBST(MOZ_DMD)
7047 dnl ========================================================
7048 dnl = Enable jemalloc
7049 dnl ========================================================
7050 MOZ_ARG_ENABLE_BOOL(jemalloc,
7051 [  --enable-jemalloc       Replace memory allocator with jemalloc],
7052     MOZ_MEMORY=1,
7053     MOZ_MEMORY=)
7055 if test "$NS_TRACE_MALLOC"; then
7056     MOZ_MEMORY=
7059 if test "${OS_TARGET}" = "Android"; then
7060   dnl On Android, we use WRAP_LDFLAGS to link everything to mozglue
7061   :
7062 elif test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "OS2"; then
7063   dnl On Windows, OSX and OS2, we want to link all our binaries against mozglue
7064   if test -z "$GNU_CC"; then
7065     MOZ_GLUE_LDFLAGS='$(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
7066   else
7067     MOZ_GLUE_LDFLAGS='-L$(LIBXUL_DIST)/lib $(call EXPAND_LIBNAME,mozglue)'
7068   fi
7069 else
7070   dnl On other Unix systems, we only want to link executables against mozglue
7071   MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
7072   dnl On other Unix systems, where mozglue is a static library, jemalloc is
7073   dnl separated for the SDK, so we need to add it here.
7074   if test "$MOZ_MEMORY" = 1 -o \( "$LIBXUL_SDK" -a -f "$LIBXUL_SDK/lib/${LIB_PREFIX}memory.${LIB_SUFFIX}" \); then
7075     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib)'
7076   fi
7077   MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(MKSHLIB_UNFORCE_ALL)'
7078   if test -n "$GNU_CC"; then
7079     dnl And we need mozglue symbols to be exported.
7080     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
7081   fi
7082   if test "$MOZ_LINKER" = 1; then
7083     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS $MOZ_ZLIB_LIBS"
7084   fi
7087 dnl ========================================================
7088 dnl = Enable dynamic replacement of malloc implementation
7089 dnl ========================================================
7090 MOZ_ARG_ENABLE_BOOL(replace-malloc,
7091 [  --enable-replace-malloc   Enable ability to dynamically replace the malloc implementation],
7092     MOZ_REPLACE_MALLOC=1,
7093     MOZ_REPLACE_MALLOC= )
7095 if test -n "$MOZ_REPLACE_MALLOC" -a -z "$MOZ_MEMORY"; then
7096     dnl We don't want to enable jemalloc unconditionally because it may be a
7097     dnl deliberate choice not to enable it (bug 702250, for instance)
7098     AC_MSG_ERROR([--enable-replace-malloc requires --enable-jemalloc])
7099 elif test -n "$MOZ_REPLACE_MALLOC"; then
7100     MOZ_NATIVE_JEMALLOC=
7102     dnl Replace-malloc Mac linkage quirks
7103     if test -n "$MACOSX_DEPLOYMENT_TARGET"; then
7104         AC_CACHE_CHECK([how to do weak dynamic linking],
7105             ac_cv_weak_dynamic_linking,
7106             [echo 'extern void foo() __attribute__((weak_import));int bar() { if (foo) foo(); return 0; }' > conftest.c
7107              if AC_TRY_COMMAND([${CC-cc} -o conftest${DLL_SUFFIX} $CFLAGS -dynamiclib $LDFLAGS -Wl,-U,_foo conftest.c $LIBS 1>&5]) &&
7108                 test -s conftest${DLL_SUFFIX}; then
7109                  dnl There are several ways the linker can put link edit rules in a binary:
7110                  dnl - classic info only (for OSX < 10.6)
7111                  dnl - dyld info only
7112                  dnl - both
7113                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO_ONLY" > /dev/null; then
7114                      _CLASSIC_INFO=
7115                  else
7116                      _CLASSIC_INFO=1
7117                  fi
7118                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO" > /dev/null; then
7119                      _DYLD_INFO=1
7120                  else
7121                      _DYLD_INFO=
7122                  fi
7123                  dnl With classic info, we need to build with -flat_namespace.
7124                  dnl With dyld info, Xcode 4.5 does the right thing without additional flags,
7125                  dnl but Xcode < 4.5 requires a dummy library and -flat_namespace because it
7126                  dnl forgets to set the weak flag in the dyld info.
7127                  dnl See http://glandium.org/blog/?p=2764 for more details.
7128                  dnl
7129                  dnl Values for ac_cv_weak_dynamic_linking, and subsequently
7130                  dnl MOZ_REPLACE_MALLOC_LINKAGE are thus:
7131                  dnl - "flat namespace" when -flat_namespace alone is needed
7132                  dnl - "dummy library" when a dummy library and -flat_namespace are needed
7133                  dnl - "compiler support" when nothing is needed
7134                  if test -n "$_DYLD_INFO" && dyldinfo -bind conftest${DLL_SUFFIX} 2> /dev/null | grep "_foo (weak import)" > /dev/null; then
7135                      if test -n "$_CLASSIC_INFO"; then
7136                          ac_cv_weak_dynamic_linking="flat namespace"
7137                      else
7138                          ac_cv_weak_dynamic_linking="compiler support"
7139                      fi
7140                  else
7141                      if test -n "$_DYLD_INFO"; then
7142                          ac_cv_weak_dynamic_linking="dummy library"
7143                      else
7144                          ac_cv_weak_dynamic_linking="flat namespace"
7145                      fi
7146                  fi
7147              else
7148                  AC_ERROR([couldn't compile a simple C file])
7149              fi
7150              rm -rf conftest*])
7151         MOZ_REPLACE_MALLOC_LINKAGE="$ac_cv_weak_dynamic_linking"
7152     fi
7154 AC_SUBST(MOZ_REPLACE_MALLOC)
7155 AC_SUBST(MOZ_REPLACE_MALLOC_LINKAGE)
7157 dnl ========================================================
7158 dnl = Jemalloc build setup
7159 dnl ========================================================
7160 if test -z "$MOZ_MEMORY"; then
7161   if test -n "$MOZ_JEMALLOC3" -a -z "$MOZ_REPLACE_MALLOC"; then
7162     MOZ_NATIVE_JEMALLOC=1
7163     AC_CHECK_FUNCS(mallctl nallocm,,
7164       [MOZ_NATIVE_JEMALLOC=
7165        break])
7166     if test -n "$MOZ_NATIVE_JEMALLOC"; then
7167       MOZ_MEMORY=1
7168       AC_DEFINE(MOZ_MEMORY)
7169       AC_DEFINE(MOZ_JEMALLOC3)
7170       AC_DEFINE(MOZ_NATIVE_JEMALLOC)
7171     fi
7172   fi
7173   case "${target}" in
7174     *-mingw*)
7175       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
7176         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.])
7177       fi
7178       ;;
7179   esac
7180 else
7181   dnl Don't try to run compiler tests on Windows
7182   if test "$OS_ARCH" = "WINNT"; then
7183     if test -z "$HAVE_64BIT_OS"; then
7184       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7185     else
7186       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7187     fi
7188   else
7189     AC_CHECK_SIZEOF([int *], [4])
7190     case "${ac_cv_sizeof_int_p}" in
7191     4)
7192       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7193       ;;
7194     8)
7195       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7196       ;;
7197     *)
7198       AC_MSG_ERROR([Unexpected pointer size])
7199       ;;
7200     esac
7201   fi
7203   AC_DEFINE(MOZ_MEMORY)
7204   if test -n "$MOZ_JEMALLOC3"; then
7205     AC_DEFINE(MOZ_JEMALLOC3)
7206   fi
7207   if test "x$MOZ_DEBUG" = "x1"; then
7208     AC_DEFINE(MOZ_MEMORY_DEBUG)
7209   fi
7210   dnl The generic feature tests that determine how to compute ncpus are long and
7211   dnl complicated.  Therefore, simply define special cpp variables for the
7212   dnl platforms we have special knowledge of.
7213   case "${target}" in
7214   *-darwin*)
7215     AC_DEFINE(MOZ_MEMORY_DARWIN)
7216     ;;
7217   *-*freebsd*)
7218     AC_DEFINE(MOZ_MEMORY_BSD)
7219     ;;
7220   *-android*|*-linuxandroid*)
7221     AC_DEFINE(MOZ_MEMORY_LINUX)
7222     AC_DEFINE(MOZ_MEMORY_ANDROID)
7223     if test -z "$gonkdir"; then
7224       _WRAP_MALLOC=1
7225     else
7226       AC_DEFINE(MOZ_MEMORY_GONK)
7227     fi
7228     MOZ_GLUE_LDFLAGS=
7229     ;;
7230   *-*linux*)
7231     AC_DEFINE(MOZ_MEMORY_LINUX)
7232     ;;
7233   *-netbsd*)
7234     AC_DEFINE(MOZ_MEMORY_BSD)
7235     ;;
7236   *-solaris*)
7237     AC_DEFINE(MOZ_MEMORY_SOLARIS)
7238     ;;
7239   *-mingw*)
7240     AC_DEFINE(MOZ_MEMORY_WINDOWS)
7241     if test -z "$MOZ_DEBUG"; then
7242       WIN32_CRT_LIBS="msvcrt.lib msvcprt.lib"
7243     else
7244       WIN32_CRT_LIBS="msvcrtd.lib msvcprtd.lib"
7245     fi
7246     dnl Look for a broken crtdll.obj
7247     WIN32_CRTDLL_FULLPATH=`lib -nologo -list $WIN32_CRT_LIBS | grep crtdll\\.obj`
7248     lib -NOLOGO -OUT:crtdll.obj $WIN32_CRT_LIBS -EXTRACT:$WIN32_CRTDLL_FULLPATH
7249     if grep -q '__imp__\{0,1\}free' crtdll.obj; then
7250       MOZ_GLUE_LDFLAGS='-LIBPATH:$(DIST)/lib -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcrtd -NODEFAULTLIB:msvcprt -NODEFAULTLIB:msvcprtd -DEFAULTLIB:mozcrt'
7251       dnl Also pass this to NSPR/NSS
7252       DLLFLAGS="$DLLFLAGS $MOZ_GLUE_LDFLAGS"
7253     else
7254       DLLFLAGS="$DLLFLAGS -LIBPATH:\$(DIST)/lib -DEFAULTLIB:mozglue"
7255     fi
7256     rm crtdll.obj
7258     export DLLFLAGS
7259     ;;
7260   *)
7261     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
7262     ;;
7263   esac
7264 fi # MOZ_MEMORY
7265 AC_SUBST(MOZ_MEMORY)
7266 AC_SUBST(MOZ_JEMALLOC3)
7267 AC_SUBST(MOZ_NATIVE_JEMALLOC)
7268 AC_SUBST(MOZ_GLUE_LDFLAGS)
7269 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
7270 AC_SUBST(WIN32_CRT_LIBS)
7271 dnl Need to set this for make because NSS doesn't have configure
7272 AC_SUBST(DLLFLAGS)
7274 dnl We need to wrap dlopen and related functions on Android because we use
7275 dnl our own linker.
7276 if test "$OS_TARGET" = Android; then
7277     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
7278     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
7279     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_GetEnv,--wrap=PR_SetEnv"
7280     if test -z "$gonkdir"; then
7281         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork,--wrap=raise"
7282         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"
7283     fi
7286 dnl ========================================================
7287 dnl = Use malloc wrapper lib
7288 dnl ========================================================
7289 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
7290 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
7291     _WRAP_MALLOC=1,
7292     _WRAP_MALLOC= )
7294 if test -n "$_WRAP_MALLOC"; then
7295     if test -n "$GNU_CC"; then
7296         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
7297         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
7298         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
7299         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
7300         dnl Wrap operator new and operator delete on Android.
7301         if test "$OS_TARGET" = "Android"; then
7302             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_Znwj,--wrap=_Znaj,--wrap=_ZdlPv,--wrap=_ZdaPv"
7303             dnl Wrap the nothrow variants too.
7304             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_ZnwjRKSt9nothrow_t,--wrap=_ZnajRKSt9nothrow_t,--wrap=_ZdlPvRKSt9nothrow_t,--wrap=_ZdaPvRKSt9nothrow_t"
7305         fi
7306     else
7307         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
7308     fi
7311 dnl ========================================================
7312 dnl = Location of malloc wrapper lib
7313 dnl ========================================================
7314 MOZ_ARG_WITH_STRING(wrap-malloc,
7315 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
7316     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
7318 dnl ========================================================
7319 dnl = Use JS Call tracing
7320 dnl ========================================================
7321 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
7322 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
7323     MOZ_TRACE_JSCALLS=1,
7324     MOZ_TRACE_JSCALLS= )
7325 if test -n "$MOZ_TRACE_JSCALLS"; then
7326     AC_DEFINE(MOZ_TRACE_JSCALLS)
7329 dnl ========================================================
7330 dnl = Use incremental GC
7331 dnl ========================================================
7332 JSGC_INCREMENTAL=1
7333 MOZ_ARG_DISABLE_BOOL(gcincremental,
7334 [  --disable-gcincremental Disable incremental GC],
7335     JSGC_INCREMENTAL= )
7336 if test -n "$JSGC_INCREMENTAL"; then
7337     AC_DEFINE(JSGC_INCREMENTAL)
7340 dnl ========================================================
7341 dnl ETW - Event Tracing for Windows
7342 dnl ========================================================
7343 MOZ_ARG_ENABLE_BOOL(ETW,
7344 [  --enable-ETW            Enable ETW (Event Tracing for Windows) event reporting],
7345     MOZ_ETW=1,
7346     MOZ_ETW= )
7347 if test -n "$MOZ_ETW"; then
7348     AC_DEFINE(MOZ_ETW)
7351 if test -n "$MOZ_ETW"; then
7352     if test -z "$MOZ_WINSDK_TARGETVER"; then
7353         AC_MSG_ERROR([--enable-ETW is only valid on Windows])
7354     fi
7357 dnl ========================================================
7358 dnl Zealous JavaScript GC
7359 dnl ========================================================
7360 MOZ_ARG_ENABLE_BOOL(gczeal,
7361 [  --enable-gczeal         Enable zealous JavaScript GCing],
7362     JS_GC_ZEAL=1,
7363     JS_GC_ZEAL= )
7364 if test -n "$JS_GC_ZEAL"; then
7365     AC_DEFINE(JS_GC_ZEAL)
7368 dnl ========================================================
7369 dnl JS opt-mode assertions and minidump instrumentation
7370 dnl ========================================================
7371 MOZ_ARG_ENABLE_BOOL(js-diagnostics,
7372 [  --enable-js-diagnostics
7373                           Enable JS diagnostic assertions and breakpad data],
7374     JS_CRASH_DIAGNOSTICS=1,
7375     JS_CRASH_DIAGNOSTICS= )
7376 if test -n "$JS_CRASH_DIAGNOSTICS"; then
7377     AC_DEFINE(JS_CRASH_DIAGNOSTICS)
7380 MOZ_CHECK_CCACHE
7382 dnl ========================================================
7383 dnl = Enable static checking using gcc-dehydra
7384 dnl ========================================================
7386 MOZ_ARG_WITH_STRING(static-checking,
7387 [  --with-static-checking=path/to/gcc_dehydra.so
7388                           Enable static checking of code using GCC-dehydra],
7389     DEHYDRA_PATH=$withval,
7390     DEHYDRA_PATH= )
7392 if test -n "$DEHYDRA_PATH"; then
7393     if test ! -f "$DEHYDRA_PATH"; then
7394         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7395     fi
7396     AC_DEFINE(NS_STATIC_CHECKING)
7398 AC_SUBST(DEHYDRA_PATH)
7400 dnl ========================================================
7401 dnl = Enable stripping of libs & executables
7402 dnl ========================================================
7403 MOZ_ARG_ENABLE_BOOL(strip,
7404 [  --enable-strip          Enable stripping of libs & executables ],
7405     ENABLE_STRIP=1,
7406     ENABLE_STRIP= )
7408 dnl ========================================================
7409 dnl = Enable stripping of libs & executables when packaging
7410 dnl ========================================================
7411 MOZ_ARG_ENABLE_BOOL(install-strip,
7412 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7413     PKG_SKIP_STRIP= ,
7414     PKG_SKIP_STRIP=1)
7416 dnl ========================================================
7417 dnl = --enable-elf-dynstr-gc
7418 dnl ========================================================
7419 MOZ_ARG_ENABLE_BOOL(elf-dynstr-gc,
7420 [  --enable-elf-dynstr-gc  Enable elf dynstr garbage collector (opt builds only)],
7421     USE_ELF_DYNSTR_GC=1,
7422     USE_ELF_DYNSTR_GC= )
7424 dnl ========================================================
7425 dnl = --disable-elf-hack
7426 dnl ========================================================
7428 USE_ELF_HACK=1
7429 MOZ_ARG_DISABLE_BOOL(elf-hack,
7430 [  --disable-elf-hack      Disable elf hacks],
7431     USE_ELF_HACK=,
7432     USE_ELF_HACK=1)
7434 # Disable elf hack for profiling because the built in profiler
7435 # doesn't read the segments properly with elf hack. This is
7436 # temporary and should be fixed soon in the profiler.
7437 if test "$MOZ_PROFILING" = 1; then
7438   USE_ELF_HACK=
7441 # Only enable elfhack where supported
7442 if test "$USE_ELF_HACK" = 1; then
7443     case "${HOST_OS_ARCH},${OS_ARCH}" in
7444     Linux,Linux)
7445         case "${CPU_ARCH}" in
7446         arm | x86 | x86_64)
7447             USE_ELF_HACK=1
7448             ;;
7449         *)
7450             USE_ELF_HACK=
7451             ;;
7452         esac
7453         ;;
7454     *)
7455         USE_ELF_HACK=
7456         ;;
7457     esac
7460 if test "$USE_ELF_HACK" = 1; then
7461     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
7462     dnl memory addresses it maps to. The result is that by the time elfhack
7463     dnl kicks in, it is not possible to apply relocations because of that,
7464     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
7465     dnl segment. It makes elfhack mostly useless, so considering the problems
7466     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
7467     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
7468     dnl the linker creates PT_GNU_RELRO segments.
7469     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
7470         LINK_WITH_PT_GNU_RELRO,
7471         [echo "int main() {return 0;}" > conftest.${ac_ext}
7472          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
7473             test -s conftest${ac_exeext}; then
7474             if ${TOOLCHAIN_PREFIX}readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
7475                 LINK_WITH_PT_GNU_RELRO=yes
7476             else
7477                 LINK_WITH_PT_GNU_RELRO=no
7478             fi
7479          else
7480              dnl We really don't expect to get here, but just in case
7481              AC_ERROR([couldn't compile a simple C file])
7482          fi
7483          rm -rf conftest*])
7484     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
7485         AC_MSG_WARN([Disabling elfhack])
7486         USE_ELF_HACK=
7487     fi
7490 dnl ========================================================
7491 dnl = libstdc++ compatibility hacks
7492 dnl ========================================================
7494 STDCXX_COMPAT=
7495 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
7496 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
7497     STDCXX_COMPAT=1)
7499 AC_SUBST(STDCXX_COMPAT)
7501 if test -n "$STDCXX_COMPAT"; then
7502    eval $(CXX="$CXX" $PYTHON $_topsrcdir/build/autoconf/libstdcxx.py)
7503    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
7504    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
7507 dnl ========================================================
7508 dnl =
7509 dnl = Profiling and Instrumenting
7510 dnl =
7511 dnl ========================================================
7512 MOZ_ARG_HEADER(Profiling and Instrumenting)
7514 dnl ========================================================
7515 dnl = Enable runtime visual profiling logger
7516 dnl ========================================================
7517 MOZ_ARG_ENABLE_BOOL(visual-event-tracer,
7518 [  --enable-visual-event-tracer   Enable visual event tracer instrumentation],
7519     MOZ_VISUAL_EVENT_TRACER=1,
7520     MOZ_VISUAL_EVENT_TRACER=)
7521 if test -n "$MOZ_VISUAL_EVENT_TRACER"; then
7522     AC_DEFINE(MOZ_VISUAL_EVENT_TRACER)
7525 dnl ========================================================
7526 dnl Turn on reflow counting
7527 dnl ========================================================
7528 MOZ_ARG_ENABLE_BOOL(reflow-perf,
7529 [  --enable-reflow-perf    Enable reflow performance tracing],
7530     MOZ_REFLOW_PERF=1,
7531     MOZ_REFLOW_PERF= )
7532 if test -n "$MOZ_REFLOW_PERF"; then
7533     AC_DEFINE(MOZ_REFLOW_PERF)
7536 dnl ========================================================
7537 dnl Enable code size metrics.
7538 dnl ========================================================
7539 MOZ_ARG_ENABLE_BOOL(codesighs,
7540 [  --enable-codesighs      Enable code size analysis tools],
7541     _ENABLE_CODESIGHS=1,
7542     _ENABLE_CODESIGHS= )
7543 if test -n "$_ENABLE_CODESIGHS"; then
7544     if test -d $srcdir/tools/codesighs; then
7545         MOZ_MAPINFO=1
7546     else
7547         AC_MSG_ERROR([Codesighs directory $srcdir/tools/codesighs required.])
7548     fi
7551 dnl ========================================================
7552 dnl = Enable Radio Interface for B2G (Gonk usually)
7553 dnl ========================================================
7554 MOZ_ARG_ENABLE_BOOL(b2g-ril,
7555 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
7556     MOZ_B2G_RIL=1,
7557     MOZ_B2G_RIL= )
7558 if test -n "$MOZ_B2G_RIL"; then
7559     AC_DEFINE(MOZ_B2G_RIL)
7561 AC_SUBST(MOZ_B2G_RIL)
7563 dnl ========================================================
7564 dnl = Enable Radio FM for B2G (Gonk usually)
7565 dnl ========================================================
7566 if test -n "$MOZ_B2G_FM"; then
7567     AC_DEFINE(MOZ_B2G_FM)
7569 AC_SUBST(MOZ_B2G_FM)
7571 dnl ========================================================
7572 dnl = Enable Bluetooth Interface for B2G (Gonk usually)
7573 dnl ========================================================
7574 MOZ_ARG_ENABLE_BOOL(b2g-bt,
7575 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
7576     MOZ_B2G_BT=1,
7577     MOZ_B2G_BT= )
7578 if test -n "$MOZ_B2G_BT"; then
7579     AC_DEFINE(MOZ_B2G_BT)
7581 AC_SUBST(MOZ_B2G_BT)
7583 dnl ========================================================
7584 dnl = Enable Support for System Messages API
7585 dnl ========================================================
7586 if test -n "$MOZ_SYS_MSG"; then
7587     AC_DEFINE(MOZ_SYS_MSG)
7589 AC_SUBST(MOZ_SYS_MSG)
7591 dnl ========================================================
7592 dnl = Enable Support for Time Manager API
7593 dnl ========================================================
7594 if test -n "$MOZ_TIME_MANAGER"; then
7595     AC_DEFINE(MOZ_TIME_MANAGER)
7597 AC_SUBST(MOZ_TIME_MANAGER)
7599 dnl ========================================================
7600 dnl = Enable Camera Interface for B2G (Gonk usually)
7601 dnl ========================================================
7602 MOZ_ARG_ENABLE_BOOL(b2g-camera,
7603 [  --enable-b2g-camera      Set compile flags necessary for compiling camera API for B2G ],
7604     MOZ_B2G_CAMERA=1,
7605     MOZ_B2G_CAMERA= )
7606 if test -n "$MOZ_B2G_CAMERA"; then
7607    AC_DEFINE(MOZ_B2G_CAMERA)
7609 AC_SUBST(MOZ_B2G_CAMERA)
7611 dnl ========================================================
7612 dnl = Enable Support B2G-specific changes to the NSS
7613 dnl = certificate trust database.
7614 dnl ========================================================
7615 if test -n "$MOZ_B2G_CERTDATA"; then
7616     AC_DEFINE(MOZ_B2G_CERTDATA)
7618 AC_SUBST(MOZ_B2G_CERTDATA)
7620 dnl ========================================================
7621 dnl = Enable Support for Payment API
7622 dnl ========================================================
7623 if test -n "$MOZ_PAY"; then
7624     AC_DEFINE(MOZ_PAY)
7626 AC_SUBST(MOZ_PAY)
7628 dnl ========================================================
7629 dnl = Enable Support for AudioChannelManager API
7630 dnl ========================================================
7631 if test -n "$MOZ_AUDIO_CHANNEL_MANAGER"; then
7632     AC_DEFINE(MOZ_AUDIO_CHANNEL_MANAGER)
7634 AC_SUBST(MOZ_AUDIO_CHANNEL_MANAGER)
7636 dnl ========================================================
7637 dnl = Support for demangling undefined symbols
7638 dnl ========================================================
7639 if test -z "$SKIP_LIBRARY_CHECKS"; then
7640     AC_LANG_SAVE
7641     AC_LANG_CPLUSPLUS
7642     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7643     AC_LANG_RESTORE
7646 # Demangle only for debug or trace-malloc or DMD builds
7647 MOZ_DEMANGLE_SYMBOLS=
7648 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
7649     MOZ_DEMANGLE_SYMBOLS=1
7650     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7652 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7654 dnl ========================================================
7655 dnl = Support for gcc stack unwinding (from gcc 3.3)
7656 dnl ========================================================
7657 if test -z "$SKIP_LIBRARY_CHECKS"; then
7658     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7661 dnl ========================================================
7662 dnl JIT observers
7663 dnl ========================================================
7665 MOZ_ARG_WITH_STRING(jitreport-granularity,
7666 [  --jitreport-granularity=N
7667                            Default granularity at which to report JIT code
7668                            to external tools
7669                              0 - no info
7670                              1 - code ranges for whole functions only
7671                              2 - per-line information
7672                              3 - per-op information],
7673   JITREPORT_GRANULARITY=$withval,
7674   JITREPORT_GRANULARITY=3)
7676 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
7678 dnl ========================================================
7679 dnl =
7680 dnl = Misc. Options
7681 dnl =
7682 dnl ========================================================
7683 MOZ_ARG_HEADER(Misc. Options)
7685 dnl ========================================================
7686 dnl update xterm title
7687 dnl ========================================================
7688 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7689 [  --enable-xterm-updates  Update XTERM titles with current command.],
7690     MOZ_UPDATE_XTERM=1,
7691     MOZ_UPDATE_XTERM= )
7693 dnl =========================================================
7694 dnl = Chrome format
7695 dnl =========================================================
7696 MOZ_ARG_ENABLE_STRING([chrome-format],
7697 [  --enable-chrome-format=jar|flat|both|symlink|omni
7698                           Select FORMAT of chrome files (default=jar)],
7699     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7701 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7702     MOZ_CHROME_FILE_FORMAT=jar
7705 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
7706     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7707     test "$MOZ_CHROME_FILE_FORMAT" != "symlink" &&
7708     test "$MOZ_CHROME_FILE_FORMAT" != "both" &&
7709     test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
7710     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, both, symlink, or omni])
7713 dnl =========================================================
7714 dnl Omnijar packaging (bug 552121)
7715 dnl =========================================================
7716 dnl Omnijar packaging is compatible with flat packaging.
7717 dnl In unpackaged builds, omnijar looks for files as if
7718 dnl things were flat packaged. After packaging, all files
7719 dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
7720 dnl is set to flat since putting files into jars is only
7721 dnl done during packaging with omnijar.
7722 if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
7723     MOZ_OMNIJAR=1
7724     AC_DEFINE(MOZ_OMNIJAR)
7725     if test "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2" -o "$MOZ_WIDGET_TOOLKIT" = "android"; then
7726         MOZ_CHROME_FILE_FORMAT=flat
7727     else
7728         MOZ_CHROME_FILE_FORMAT=symlink
7729     fi
7730 elif test "$MOZ_CHROME_FILE_FORMAT" = "jar"; then
7731     AC_DEFINE(MOZ_CHROME_FILE_FORMAT_JAR)
7734 OMNIJAR_NAME=omni.ja
7735 AC_SUBST(OMNIJAR_NAME)
7736 AC_SUBST(MOZ_OMNIJAR)
7738 dnl ========================================================
7739 dnl = Define default location for MOZILLA_FIVE_HOME
7740 dnl ========================================================
7741 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7742 [  --with-default-mozilla-five-home
7743                           Set the default value for MOZILLA_FIVE_HOME],
7744 [ val=`echo $withval`
7745   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7747 dnl ========================================================
7748 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7749 dnl ========================================================
7750 MOZ_ARG_WITH_STRING(user-appdir,
7751 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7752 [ val=`echo $withval`
7753 if echo "$val" | grep "\/" >/dev/null; then
7754     AC_MSG_ERROR("Homedir must be single relative path.")
7755 else
7756     MOZ_USER_DIR="$val"
7757 fi])
7759 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7761 dnl ========================================================
7762 dnl = Doxygen configuration
7763 dnl ========================================================
7764 dnl Use commas to specify multiple dirs to this arg
7765 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7766 MOZ_ARG_WITH_STRING(doc-input-dirs,
7767 [  --with-doc-input-dirs=DIRS
7768                           Header/idl dirs to create docs from],
7769 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7770 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7772 dnl Use commas to specify multiple dirs to this arg
7773 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7774 MOZ_ARG_WITH_STRING(doc-include-dirs,
7775 [  --with-doc-include-dirs=DIRS
7776                           Include dirs to preprocess doc headers],
7777 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7778 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7780 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7781 MOZ_ARG_WITH_STRING(doc-output-dir,
7782 [  --with-doc-output-dir=DIR
7783                           Dir to generate docs into],
7784 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7785 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7787 if test -z "$SKIP_COMPILER_CHECKS"; then
7788 dnl ========================================================
7789 dnl =
7790 dnl = Compiler Options
7791 dnl =
7792 dnl ========================================================
7793 MOZ_ARG_HEADER(Compiler Options)
7795 dnl ========================================================
7796 dnl Check for gcc -pipe support
7797 dnl ========================================================
7798 AC_MSG_CHECKING([for -pipe support])
7799 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
7800     dnl Any gcc that supports firefox supports -pipe.
7801     CFLAGS="$CFLAGS -pipe"
7802     CXXFLAGS="$CXXFLAGS -pipe"
7803     AC_MSG_RESULT([yes])
7804 else
7805     AC_MSG_RESULT([no])
7808 dnl ========================================================
7809 dnl Profile guided optimization (gcc checks)
7810 dnl ========================================================
7811 dnl Test for profiling options
7812 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7814 _SAVE_CFLAGS="$CFLAGS"
7815 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
7817 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7818 AC_TRY_COMPILE([], [return 0;],
7819                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7820                  result="yes" ], result="no")
7821 AC_MSG_RESULT([$result])
7823 if test $result = "yes"; then
7824   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7825   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
7826   PROFILE_USE_LDFLAGS="-fprofile-use"
7829 CFLAGS="$_SAVE_CFLAGS"
7831 if test -n "$INTEL_CC"; then
7832   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
7833   PROFILE_GEN_LDFLAGS=
7834   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
7835   PROFILE_USE_LDFLAGS=
7838 dnl Sun Studio on Solaris
7839 if test "$SOLARIS_SUNPRO_CC"; then
7840   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
7841   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
7842   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
7843   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
7846 AC_SUBST(PROFILE_GEN_CFLAGS)
7847 AC_SUBST(PROFILE_GEN_LDFLAGS)
7848 AC_SUBST(PROFILE_USE_CFLAGS)
7849 AC_SUBST(PROFILE_USE_LDFLAGS)
7851 AC_LANG_CPLUSPLUS
7853 dnl ========================================================
7854 dnl Test for -pedantic bustage
7855 dnl ========================================================
7856 MOZ_ARG_DISABLE_BOOL(pedantic,
7857 [  --disable-pedantic      Issue all warnings demanded by strict ANSI C ],
7858 _PEDANTIC= )
7859 if test "$_PEDANTIC"; then
7860     _SAVE_CXXFLAGS=$CXXFLAGS
7861     CXXFLAGS="$CXXFLAGS -pedantic ${_WARNINGS_CXXFLAGS} -Wno-long-long"
7862     AC_MSG_CHECKING([whether C++ compiler has -pedantic long long bug])
7863     AC_TRY_COMPILE([$configure_static_assert_macros],
7864                    [CONFIGURE_STATIC_ASSERT(sizeof(long long) == 8)],
7865                    result="no", result="yes" )
7866     AC_MSG_RESULT([$result])
7867     CXXFLAGS="$_SAVE_CXXFLAGS"
7869     case "$result" in
7870     no)
7871         _WARNINGS_CFLAGS="-pedantic ${_WARNINGS_CFLAGS} -Wno-long-long"
7872         _WARNINGS_CXXFLAGS="-pedantic ${_WARNINGS_CXXFLAGS} -Wno-long-long"
7873         ;;
7874     yes)
7875         AC_MSG_ERROR([Your compiler appears to have a known bug where long long is miscompiled when using -pedantic.  Reconfigure using --disable-pedantic. ])
7876         ;;
7877     esac
7880 dnl ========================================================
7881 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
7882 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
7883 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
7884 dnl ========================================================
7885 _SAVE_CXXFLAGS=$CXXFLAGS
7886 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
7887 AC_CACHE_CHECK(for correct overload resolution with const and templates,
7888     ac_nscap_nonconst_opeq_bug,
7889     [AC_TRY_COMPILE([
7890                       template <class T>
7891                       class Pointer
7892                         {
7893                         public:
7894                           T* myPtr;
7895                         };
7897                       template <class T, class U>
7898                       int operator==(const Pointer<T>& rhs, U* lhs)
7899                         {
7900                           return rhs.myPtr == lhs;
7901                         }
7903                       template <class T, class U>
7904                       int operator==(const Pointer<T>& rhs, const U* lhs)
7905                         {
7906                           return rhs.myPtr == lhs;
7907                         }
7908                     ],
7909                     [
7910                       Pointer<int> foo;
7911                       const int* bar;
7912                       return foo == bar;
7913                     ],
7914                     ac_nscap_nonconst_opeq_bug="no",
7915                     ac_nscap_nonconst_opeq_bug="yes")])
7916 CXXFLAGS="$_SAVE_CXXFLAGS"
7918 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
7919     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
7921 fi # ! SKIP_COMPILER_CHECKS
7923 AC_DEFINE(CPP_THROW_NEW, [throw()])
7924 AC_LANG_C
7926 if test "$COMPILE_ENVIRONMENT"; then
7927 MOZ_EXPAND_LIBS
7928 fi # COMPILE_ENVIRONMENT
7930 dnl ========================================================
7931 dnl =
7932 dnl = Build depencency options
7933 dnl =
7934 dnl ========================================================
7935 MOZ_ARG_HEADER(Build dependencies)
7937 if test "$GNU_CC" -a "$GNU_CXX"; then
7938   _DEPEND_CFLAGS='$(filter-out %/.pp,-MD -MF $(MDDEPDIR)/$(@F).pp)'
7939 dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
7940 elif test "$SOLARIS_SUNPRO_CC"; then
7941   _DEPEND_CFLAGS=
7942 else
7943   dnl Don't override this for MSVC
7944   if test -z "$_WIN32_MSVC"; then
7945     _USE_CPP_INCLUDE_FLAG=
7946     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7947     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7948   else
7949     echo '#include <stdio.h>' > dummy-hello.c
7950     changequote(,)
7951     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
7952     changequote([,])
7953     if test -z "$CL_INCLUDES_PREFIX"; then
7954         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
7955     fi
7956     AC_SUBST(CL_INCLUDES_PREFIX)
7957     rm -f dummy-hello.c
7958   fi
7961 dnl ========================================================
7962 dnl =
7963 dnl = Static Build Options
7964 dnl =
7965 dnl ========================================================
7966 MOZ_ARG_HEADER(Static build options)
7968 # split JS out by default to avoid VS2005 PGO crash (bug 591836).
7969 if test "$OS_ARCH" = "WINNT" -a "$CPU_ARCH" != "x86_64" ; then
7970   ENABLE_SHARED_JS=1
7973 MOZ_ARG_ENABLE_BOOL(shared-js,
7974 [  --enable-shared-js
7975                           Create a shared JavaScript library.],
7976     ENABLE_SHARED_JS=1,
7977     ENABLE_SHARED_JS=)
7979 if test -n "$ENABLE_SHARED_JS"; then
7980   JS_SHARED_LIBRARY=1
7981   MOZ_JS_LIBS="$MOZ_JS_SHARED_LIBS"
7982 else
7983   MOZ_JS_LIBS="$MOZ_JS_STATIC_LIBS"
7984   AC_DEFINE(MOZ_STATIC_JS)
7986 AC_SUBST(JS_SHARED_LIBRARY)
7988 AC_SUBST(LIBXUL_LIBS)
7989 XPCOM_LIBS="$LIBXUL_LIBS"
7991 dnl ========================================================
7992 dnl =
7993 dnl = Standalone module options
7994 dnl =
7995 dnl ========================================================
7996 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
7998 dnl Check for GLib.
7999 dnl ========================================================
8001 if test -z "$SKIP_PATH_CHECKS"; then
8002 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
8003     if test "$MOZ_ENABLE_GTK2" -o "$USE_ELF_DYNSTR_GC" ; then
8004         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
8005     fi
8009 if test -z "${GLIB_GMODULE_LIBS}" \
8010    -a -n "${GLIB_CONFIG}"\
8011     -a "${GLIB_CONFIG}" != no\
8012 ; then
8013     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
8016 AC_SUBST(GLIB_CFLAGS)
8017 AC_SUBST(GLIB_LIBS)
8018 AC_SUBST(GLIB_GMODULE_LIBS)
8020 dnl ========================================================
8021 dnl Graphics checks.
8022 dnl ========================================================
8024 if test "${OS_TARGET}" = "WINNT" -o "${OS_ARCH}" = "Darwin" -o "${MOZ_WIDGET_TOOLKIT}" = "android" -o "${MOZ_WIDGET_TOOLKIT}" = "gtk2"; then
8025 MOZ_ENABLE_SKIA=1
8026 else
8027 MOZ_ENABLE_SKIA=
8030 MOZ_ARG_ENABLE_BOOL(skia,
8031 [  --enable-skia   Enable use of Skia],
8032 MOZ_ENABLE_SKIA=1,
8033 MOZ_ENABLE_SKIA=)
8035 if test "$USE_FC_FREETYPE"; then
8036     if test "$COMPILE_ENVIRONMENT"; then
8037         dnl ========================================================
8038         dnl = Check for freetype2 and its functionality
8039         dnl ========================================================
8040         PKG_CHECK_MODULES(FT2, freetype2 >= 6.1.0, _HAVE_FREETYPE2=1, _HAVE_FREETYPE2=)
8042         if test "$_HAVE_FREETYPE2"; then
8043             _SAVE_LIBS="$LIBS"
8044             _SAVE_CFLAGS="$CFLAGS"
8045             LIBS="$LIBS $FT2_LIBS"
8046             CFLAGS="$CFLAGS $FT2_CFLAGS"
8048             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
8049                 ac_cv_member_FT_Bitmap_Size_y_ppem,
8050                 [AC_TRY_COMPILE([#include <ft2build.h>
8051                                  #include FT_FREETYPE_H],
8052                                 [FT_Bitmap_Size s;
8053                                  if (sizeof s.y_ppem) return 0;
8054                                  return 1],
8055                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
8056                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
8057             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
8058                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
8059             else
8060                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
8061             fi
8062             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
8063                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
8064                                [FT_Bitmap_Size structure includes y_ppem field])
8066             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table FT_Select_Size)
8068             LIBS="$_SAVE_LIBS"
8069             CFLAGS="$_SAVE_CFLAGS"
8070         fi
8072         _SAVE_CPPFLAGS="$CPPFLAGS"
8073         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
8074         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
8075             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
8076         CPPFLAGS="$_SAVE_CPPFLAGS"
8077     else
8078         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
8079     fi
8081     PKG_CHECK_MODULES(_FONTCONFIG, fontconfig,
8082     [
8083         if test "$MOZ_PANGO"; then
8084             MOZ_PANGO_CFLAGS="$MOZ_PANGO_CFLAGS $_FONTCONFIG_CFLAGS"
8085             MOZ_PANGO_LIBS="$MOZ_PANGO_LIBS $_FONTCONFIG_LIBS"
8086         else
8087             FT2_CFLAGS="$FT2_CFLAGS $_FONTCONFIG_CFLAGS"
8088             FT2_LIBS="$FT2_LIBS $_FONTCONFIG_LIBS"
8089         fi
8090     ])
8093 dnl ========================================================
8094 dnl Check for pixman and cairo
8095 dnl ========================================================
8097 MOZ_TREE_CAIRO=1
8098 MOZ_ARG_ENABLE_BOOL(system-cairo,
8099 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
8100 MOZ_TREE_CAIRO=,
8101 MOZ_TREE_CAIRO=1 )
8103 MOZ_TREE_PIXMAN=1
8104 MOZ_ARG_ENABLE_BOOL(system-pixman,
8105 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
8106 MOZ_TREE_PIXMAN=,
8107 MOZ_TREE_PIXMAN=force,
8108 MOZ_TREE_PIXMAN=1 )
8110 # System cairo depends on system pixman
8111 if test "$MOZ_TREE_PIXMAN" = "force"; then
8112     if test -z "$MOZ_TREE_CAIRO"; then
8113         AC_MSG_ERROR([--disable-system-pixman is incompatible with --enable-system-cairo.])
8114     else
8115         MOZ_TREE_PIXMAN=1
8116     fi
8117 elif test -z "$MOZ_TREE_CAIRO"; then
8118     MOZ_TREE_PIXMAN=
8121 if test "$MOZ_TREE_PIXMAN"; then
8122     AC_DEFINE(MOZ_TREE_PIXMAN)
8123     MOZ_PIXMAN_CFLAGS=""
8124     MOZ_PIXMAN_LIBS='$(call EXPAND_LIBNAME_PATH,mozlibpixman,$(DEPTH)/gfx/cairo/libpixman/src)'
8125 else
8126     PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.19.2)
8127     MOZ_PIXMAN_CFLAGS="$PIXMAN_CFLAGS"
8128     MOZ_PIXMAN_LIBS="$PIXMAN_LIBS"
8130 AC_SUBST(MOZ_PIXMAN_CFLAGS)
8131 AC_SUBST(MOZ_PIXMAN_LIBS)
8133 # Check for headers defining standard int types.
8134 MOZ_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
8136 if test "$MOZ_TREE_CAIRO"; then
8137     MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
8138     AC_DEFINE(MOZ_TREE_CAIRO)
8140     # For now we assume that we will have a uint64_t available through
8141     # one of the above headers or mozstdint.h.
8142     AC_DEFINE(HAVE_UINT64_T)
8144     # Define macros for cairo-features.h
8145     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
8146     if test "$MOZ_X11"; then
8147         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
8148         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
8149         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
8150         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8151         MOZ_ENABLE_CAIRO_FT=1
8152         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
8153     fi
8154     case "$MOZ_WIDGET_TOOLKIT" in
8155       qt)
8156         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
8157         ;;
8158       cocoa | uikit)
8159         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
8160         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
8161         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
8162         ;;
8163       windows)
8164         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
8165         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
8166         if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
8167             WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
8168             WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
8169             MOZ_ENABLE_D2D_SURFACE=1
8170             MOZ_ENABLE_DWRITE_FONT=1
8171         else
8172             WIN32_DWRITE_FONT_FEATURE=
8173             WIN32_D2D_SURFACE_FEATURE=
8174         fi
8176         MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
8178         dnl D3D10 Layers depend on D2D Surfaces.
8179         if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
8180           MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
8181         fi
8182         ;;
8183       os2)
8184         OS2_SURFACE_FEATURE="#define CAIRO_HAS_OS2_SURFACE 1"
8185         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8186         MOZ_ENABLE_CAIRO_FT=1
8187         CAIRO_FT_CFLAGS="-I${MZFTCFGFT2}/include"
8188         CAIRO_FT_OSLIBS="-L${MZFTCFGFT2}/lib -lmozft -lmzfntcfg"
8189         CAIRO_FT_LIBS=""
8190         ;;
8191     esac
8192     if test "$USE_FC_FREETYPE"; then
8193         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
8194     fi
8195     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
8196     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
8197     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
8198     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
8199     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
8200     AC_SUBST(CAIRO_FT_CFLAGS)
8202     AC_SUBST(PS_SURFACE_FEATURE)
8203     AC_SUBST(PDF_SURFACE_FEATURE)
8204     AC_SUBST(SVG_SURFACE_FEATURE)
8205     AC_SUBST(XLIB_SURFACE_FEATURE)
8206     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
8207     AC_SUBST(QUARTZ_SURFACE_FEATURE)
8208     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
8209     AC_SUBST(WIN32_SURFACE_FEATURE)
8210     AC_SUBST(OS2_SURFACE_FEATURE)
8211     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
8212     AC_SUBST(FT_FONT_FEATURE)
8213     AC_SUBST(FC_FONT_FEATURE)
8214     AC_SUBST(WIN32_FONT_FEATURE)
8215     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
8216     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
8217     AC_SUBST(QUARTZ_FONT_FEATURE)
8218     AC_SUBST(PNG_FUNCTIONS_FEATURE)
8219     AC_SUBST(QT_SURFACE_FEATURE)
8220     AC_SUBST(TEE_SURFACE_FEATURE)
8222     MOZ_CAIRO_LIBS='$(call EXPAND_LIBNAME_PATH,mozcairo,$(DEPTH)/gfx/cairo/cairo/src)'" $CAIRO_FT_LIBS"
8223     MOZ_CAIRO_OSLIBS='${CAIRO_FT_OSLIBS}'
8225     if test "$MOZ_X11"; then
8226         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
8227     fi
8229     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
8230 else
8231     PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION)
8232     MOZ_CAIRO_CFLAGS="$CAIRO_CFLAGS"
8233     MOZ_CAIRO_LIBS="$CAIRO_LIBS"
8234     PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
8235     if test "$MOZ_X11"; then
8236         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
8237         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
8238         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_LIBS"
8239         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
8240     fi
8243 AC_SUBST(MOZ_TREE_CAIRO)
8244 AC_SUBST(MOZ_CAIRO_CFLAGS)
8245 AC_SUBST(MOZ_CAIRO_LIBS)
8246 AC_SUBST(MOZ_CAIRO_OSLIBS)
8247 AC_SUBST(MOZ_TREE_PIXMAN)
8249 dnl ========================================================
8250 dnl qcms
8251 dnl ========================================================
8253 QCMS_LIBS='$(DEPTH)/gfx/qcms/$(LIB_PREFIX)mozqcms.$(LIB_SUFFIX)'
8254 AC_SUBST(QCMS_LIBS)
8256 dnl ========================================================
8257 dnl HarfBuzz
8258 dnl ========================================================
8259 MOZ_HARFBUZZ_LIBS='$(DEPTH)/gfx/harfbuzz/src/$(LIB_PREFIX)mozharfbuzz.$(LIB_SUFFIX)'
8260 AC_SUBST(MOZ_HARFBUZZ_LIBS)
8262 dnl ========================================================
8263 dnl SIL Graphite
8264 dnl ========================================================
8265 if test "$MOZ_GRAPHITE"; then
8266   MOZ_GRAPHITE_LIBS='$(DEPTH)/gfx/graphite2/src/$(LIB_PREFIX)mozgraphite2.$(LIB_SUFFIX)'
8267   AC_DEFINE(MOZ_GRAPHITE)
8268 else
8269   MOZ_GRAPHITE_LIBS=
8271 AC_SUBST(MOZ_GRAPHITE)
8272 AC_SUBST(MOZ_GRAPHITE_LIBS)
8274 dnl ========================================================
8275 dnl OTS
8276 dnl ========================================================
8277 MOZ_OTS_LIBS='$(DEPTH)/gfx/ots/src/$(LIB_PREFIX)mozots.$(LIB_SUFFIX)'
8278 AC_SUBST(MOZ_OTS_LIBS)
8280 dnl ========================================================
8281 dnl Skia 
8282 dnl ========================================================
8283 if test "$MOZ_ENABLE_SKIA"; then
8284   MOZ_SKIA_LIBS='$(DEPTH)/gfx/skia/$(LIB_PREFIX)skia.$(LIB_SUFFIX)'
8285   AC_DEFINE(MOZ_ENABLE_SKIA)
8286 else
8287   MOZ_SKIA_LIBS=
8289 AC_SUBST(MOZ_ENABLE_SKIA)
8290 AC_SUBST(MOZ_SKIA_LIBS)
8292 dnl ========================================================
8293 dnl disable xul
8294 dnl ========================================================
8295 MOZ_ARG_DISABLE_BOOL(xul,
8296 [  --disable-xul           Disable XUL],
8297     MOZ_XUL= )
8298 if test "$MOZ_XUL"; then
8299   AC_DEFINE(MOZ_XUL)
8300 else
8301   dnl remove extensions that require XUL
8302   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/venkman//' -e 's/irc//' -e 's/tasks//'`
8305 AC_SUBST(MOZ_XUL)
8307 dnl ========================================================
8308 dnl disable profile locking
8309 dnl   do no use this in applications that can have more than
8310 dnl   one process accessing the profile directory.
8311 dnl ========================================================
8312 MOZ_ARG_DISABLE_BOOL(profilelocking,
8313 [  --disable-profilelocking
8314                           Disable profile locking],
8315     MOZ_PROFILELOCKING=,
8316     MOZ_PROFILELOCKING=1 )
8317 if test "$MOZ_PROFILELOCKING"; then
8318   AC_DEFINE(MOZ_PROFILELOCKING)
8321 dnl ========================================================
8322 dnl necko configuration options
8323 dnl ========================================================
8326 dnl option to disable various necko protocols
8328 MOZ_ARG_ENABLE_STRING(necko-protocols,
8329 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8330                           Enable/disable specific protocol handlers],
8331 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8332     if test "$option" = "yes" -o "$option" = "all"; then
8333         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8334     elif test "$option" = "no" -o "$option" = "none"; then
8335         NECKO_PROTOCOLS=""
8336     elif test "$option" = "default"; then
8337         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8338     elif test `echo "$option" | grep -c \^-` != 0; then
8339         option=`echo $option | sed 's/^-//'`
8340         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8341     else
8342         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8343     fi
8344 done],
8345     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8346 dnl Remove dupes
8347 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
8348 AC_SUBST(NECKO_PROTOCOLS)
8349 for p in $NECKO_PROTOCOLS; do
8350     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8351     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_PROTOCOL_$p"
8352 done
8355 dnl option to disable necko's wifi scanner
8357 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8358 [  --disable-necko-wifi    Disable necko wifi scanner],
8359     NECKO_WIFI=,
8360     NECKO_WIFI=1)
8362 if test "$OS_ARCH" = "OS2"; then
8363   dnl OS/2 implementation of Necko-WiFi support will be added in bug 506566
8364   NECKO_WIFI=
8366 if test "$NECKO_WIFI" -a \
8367         "$OS_ARCH" != "Linux" -a \
8368         "$OS_ARCH" != "Darwin" -a \
8369         "$OS_ARCH" != "SunOS" -a \
8370         "$OS_ARCH" != "WINNT"; then
8371   AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use --disable-necko-wifi])
8374 if test "$NECKO_WIFI"; then
8375   AC_DEFINE(NECKO_WIFI)
8376   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
8378 AC_SUBST(NECKO_WIFI)
8381 dnl option to disable cookies
8383 MOZ_ARG_DISABLE_BOOL(cookies,
8384 [  --disable-cookies       Disable cookie support],
8385     NECKO_COOKIES=,
8386     NECKO_COOKIES=1)
8387 AC_SUBST(NECKO_COOKIES)
8388 if test "$NECKO_COOKIES"; then
8389     AC_DEFINE(NECKO_COOKIES)
8390     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
8394 dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
8396 MOZ_ARG_DISABLE_BOOL(ctypes,
8397 [  --disable-ctypes        Disable js-ctypes],
8398     BUILD_CTYPES=,
8399     BUILD_CTYPES=1)
8400 AC_SUBST(BUILD_CTYPES)
8401 if test "$BUILD_CTYPES"; then
8402     AC_DEFINE(BUILD_CTYPES)
8405 dnl Build Places if required
8406 if test "$MOZ_PLACES"; then
8407   AC_DEFINE(MOZ_PLACES)
8410 dnl Build Apps in the Cloud (AITC) if required
8411 AC_SUBST(MOZ_SERVICES_AITC)
8412 if test -n "$MOZ_SERVICES_AITC"; then
8413   AC_DEFINE(MOZ_SERVICES_AITC)
8416 dnl Build Common JS modules provided by services.
8417 AC_SUBST(MOZ_SERVICES_COMMON)
8418 if test -n "$MOZ_SERVICES_COMMON"; then
8419   AC_DEFINE(MOZ_SERVICES_COMMON)
8422 dnl Build Services crypto component (used by Sync)
8423 AC_SUBST(MOZ_SERVICES_CRYPTO)
8424 if test -n "$MOZ_SERVICES_CRYPTO"; then
8425   AC_DEFINE(MOZ_SERVICES_CRYPTO)
8428 dnl Build Firefox Health Reporter Service
8429 AC_SUBST(MOZ_SERVICES_HEALTHREPORT)
8430 if test -n "$MOZ_SERVICES_HEALTHREPORT"; then
8431   AC_DEFINE(MOZ_SERVICES_HEALTHREPORT)
8434 dnl Build Services metrics component
8435 AC_SUBST(MOZ_SERVICES_METRICS)
8436 if test -n "$MOZ_SERVICES_METRICS"; then
8437   AC_DEFINE(MOZ_SERVICES_METRICS)
8440 dnl Build Notifications if required
8441 AC_SUBST(MOZ_SERVICES_NOTIFICATIONS)
8442 if test -n "$MOZ_SERVICES_NOTIFICATIONS"; then
8443   AC_DEFINE(MOZ_SERVICES_NOTIFICATIONS)
8446 dnl Build Sync Services if required
8447 AC_SUBST(MOZ_SERVICES_SYNC)
8448 if test -n "$MOZ_SERVICES_SYNC"; then
8449   AC_DEFINE(MOZ_SERVICES_SYNC)
8452 dnl ========================================================
8453 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
8454     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8457 if test "$MOZ_APP_COMPONENT_INCLUDE"; then
8458   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
8461 if test "$MOZ_APP_COMPONENT_MODULES"; then
8462   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_MODULES, $MOZ_APP_COMPONENT_MODULES)
8465 dnl ========================================================
8466 dnl =
8467 dnl = Maintainer debug option (no --enable equivalent)
8468 dnl =
8469 dnl ========================================================
8471 AC_SUBST(AR)
8472 AC_SUBST(AR_FLAGS)
8473 AC_SUBST(AR_LIST)
8474 AC_SUBST(AR_EXTRACT)
8475 AC_SUBST(AR_DELETE)
8476 AC_SUBST(AS)
8477 AC_SUBST(ASFLAGS)
8478 AC_SUBST(AS_DASH_C_FLAG)
8479 AC_SUBST(LD)
8480 AC_SUBST(RC)
8481 AC_SUBST(RCFLAGS)
8482 AC_SUBST(MC)
8483 AC_SUBST(WINDRES)
8484 AC_SUBST(IMPLIB)
8485 AC_SUBST(FILTER)
8486 AC_SUBST(BIN_FLAGS)
8487 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8488 AC_SUBST(MOZ_UPDATE_XTERM)
8489 AC_SUBST(MOZ_PLATFORM_MAEMO)
8490 AC_SUBST(MOZ_AUTH_EXTENSION)
8491 AC_SUBST(MOZ_PERMISSIONS)
8492 AC_SUBST(MOZ_PREF_EXTENSIONS)
8493 AC_SUBST(MOZ_JS_LIBS)
8494 AC_SUBST(MOZ_PSM)
8495 AC_SUBST(MOZ_DEBUG)
8496 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8497 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8498 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8499 AC_SUBST(MOZ_DEBUG_FLAGS)
8500 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8501 AC_SUBST(WARNINGS_AS_ERRORS)
8502 AC_SUBST(MOZ_EXTENSIONS)
8503 AC_SUBST(MOZ_JSDEBUGGER)
8504 AC_SUBST(MOZ_ENABLE_PROFILER_SPS)
8505 AC_SUBST(MOZ_JPROF)
8506 AC_SUBST(MOZ_SHARK)
8507 AC_SUBST(MOZ_CALLGRIND)
8508 AC_SUBST(MOZ_VTUNE)
8509 AC_SUBST(MOZ_ETW)
8510 AC_SUBST(MOZ_PROFILING)
8511 AC_SUBST(LIBICONV)
8512 AC_SUBST(MOZ_PLACES)
8513 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8514 AC_SUBST(MOZ_FEEDS)
8515 AC_SUBST(NS_PRINTING)
8516 AC_SUBST(MOZ_WEBGL)
8517 AC_SUBST(MOZ_HELP_VIEWER)
8518 AC_SUBST(TOOLCHAIN_PREFIX)
8520 AC_SUBST(JAVA)
8521 AC_SUBST(JAVAC)
8522 AC_SUBST(JAR)
8524 AC_SUBST(MOZ_PROFILELOCKING)
8526 AC_SUBST(ENABLE_TESTS)
8527 AC_SUBST(ENABLE_MARIONETTE)
8528 AC_SUBST(IBMBIDI)
8529 AC_SUBST(MOZ_UNIVERSALCHARDET)
8530 AC_SUBST(ACCESSIBILITY)
8531 AC_SUBST(MOZ_SPELLCHECK)
8532 AC_SUBST(MOZ_ANDROID_OMTC)
8533 AC_SUBST(MOZ_ONLY_TOUCH_EVENTS)
8534 AC_SUBST(MOZ_CRASHREPORTER)
8535 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
8536 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
8537 AC_SUBST(MOZ_STUB_INSTALLER)
8538 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
8539 AC_SUBST(MOZ_ENABLE_SIGNMAR)
8540 AC_SUBST(MOZ_UPDATER)
8541 AC_SUBST(MOZ_ANGLE_RENDERER)
8542 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
8543 AC_SUBST(MOZ_DIRECTX_SDK_CPU_SUFFIX)
8544 AC_SUBST(MOZ_D3DX9_VERSION)
8545 AC_SUBST(MOZ_D3DX9_CAB)
8546 AC_SUBST(MOZ_D3DCOMPILER_CAB)
8547 AC_SUBST(MOZ_D3DX9_DLL)
8548 AC_SUBST(MOZ_D3DCOMPILER_DLL)
8549 AC_SUBST(MOZ_METRO)
8551 AC_SUBST(MOZ_ANDROID_HISTORY)
8552 AC_SUBST(MOZ_WEBSMS_BACKEND)
8553 AC_SUBST(ENABLE_STRIP)
8554 AC_SUBST(PKG_SKIP_STRIP)
8555 AC_SUBST(STRIP_FLAGS)
8556 AC_SUBST(USE_ELF_DYNSTR_GC)
8557 AC_SUBST(USE_ELF_HACK)
8558 AC_SUBST(INCREMENTAL_LINKER)
8559 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8560 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8562 AC_SUBST(MOZ_FIX_LINK_PATHS)
8563 AC_SUBST(XPCOM_LIBS)
8564 AC_SUBST(XPCOM_FROZEN_LDOPTS)
8565 AC_SUBST(XPCOM_GLUE_LDOPTS)
8566 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
8567 AC_SUBST(XPCOM_STATICRUNTIME_GLUE_LDOPTS)
8568 AC_SUBST(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS)
8570 AC_SUBST(USE_DEPENDENT_LIBS)
8572 AC_SUBST(MOZ_BUILD_ROOT)
8573 AC_SUBST(MOZ_OS2_TOOLS)
8575 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8576 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8577 AC_SUBST(MOZ_LINKER_EXTRACT)
8578 AC_SUBST(MOZ_PER_WINDOW_PRIVATE_BROWSING)
8580 if test -n "$MOZ_PER_WINDOW_PRIVATE_BROWSING" ; then
8581     AC_DEFINE(MOZ_PER_WINDOW_PRIVATE_BROWSING)
8584 dnl ========================================================
8585 dnl = Mac bundle name prefix
8586 dnl ========================================================
8587 MOZ_ARG_WITH_STRING(macbundlename-prefix,
8588 [  --with-macbundlename-prefix=prefix
8589                           Prefix for MOZ_MACBUNDLE_NAME],
8590 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
8592 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
8593 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
8594   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
8597 if test "$MOZ_DEBUG"; then
8598   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
8599 else
8600   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
8602 AC_SUBST(MOZ_MACBUNDLE_NAME)
8604 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
8605 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr '[A-Z]' '[a-z]'`
8606 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
8607 if test "$MOZ_DEBUG"; then
8608   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
8611 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
8612 AC_SUBST(MOZ_MACBUNDLE_ID)
8614 # The following variables are available to branding and application
8615 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
8616 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
8617 # impacts profile location and user-visible fields.
8618 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
8619 # versions of a given application (e.g. Aurora and Firefox both use
8620 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
8621 # for application.ini's "Name" field, which controls profile location in
8622 # the absence of a "Profile" field (see below), and various system
8623 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
8624 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
8625 # Mac Bundle name, Updater, Installer), it is typically used for nightly
8626 # builds (e.g. Aurora for Firefox).
8627 # - MOZ_APP_VERSION: Defines the application version number.
8628 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
8629 # defaults to a lowercase form of MOZ_APP_BASENAME.
8630 # - MOZ_APP_PROFILE: When set, used for application.ini's
8631 # "Profile" field, which controls profile location.
8632 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
8633 # crash reporter server url.
8634 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
8635 # - MOZ_EXTENSION_MANAGER: When set, enabled extension manager.
8637 if test -z "$MOZ_APP_NAME"; then
8638    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
8641 # For extensions and langpacks, we require a max version that is compatible
8642 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
8643 # 10.0a1 and 10.0a2 aren't affected
8644 # 10.0 becomes 10.0.*
8645 # 10.0.1 becomes 10.0.*
8646 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
8647 if test -z "$IS_ALPHA"; then
8648   changequote(,)
8649   MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*.[0-9]*\).*|\1|"`.*
8650   changequote([,])
8651 else
8652   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
8655 MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"}
8656 AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION")
8657 AC_DEFINE_UNQUOTED(MOZ_B2G_OS_NAME,"$MOZ_B2G_OS_NAME")
8659 AC_SUBST(MOZ_APP_NAME)
8660 AC_SUBST(MOZ_APP_DISPLAYNAME)
8661 AC_SUBST(MOZ_APP_BASENAME)
8662 AC_SUBST(MOZ_APP_VENDOR)
8663 AC_SUBST(MOZ_APP_PROFILE)
8664 AC_SUBST(MOZ_APP_ID)
8665 AC_SUBST(MAR_CHANNEL_ID)
8666 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
8667 AC_SUBST(MOZ_PROFILE_MIGRATOR)
8668 AC_SUBST(MOZ_EXTENSION_MANAGER)
8669 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
8670 AC_SUBST(MOZ_APP_UA_NAME)
8671 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
8672 AC_SUBST(MOZ_APP_VERSION)
8673 AC_SUBST(MOZ_APP_MAXVERSION)
8674 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
8675 AC_SUBST(FIREFOX_VERSION)
8676 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
8677 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
8678   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
8680 AC_DEFINE_UNQUOTED(MOZ_UA_BUILDID, "$MOZ_UA_BUILDID")
8681 AC_SUBST(MOZ_UA_BUILDID)
8683 AC_SUBST(MOZ_APP_STATIC_INI)
8685 AC_SUBST(MOZ_PKG_SPECIAL)
8687 AC_SUBST(MOZILLA_OFFICIAL)
8689 AC_DEFINE_UNQUOTED(MOZ_TELEMETRY_DISPLAY_REV, 2)
8690 AC_SUBST(MOZ_TELEMETRY_DISPLAY_REV)
8692 if test "$MOZ_TELEMETRY_REPORTING"; then
8693     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
8695     # Enable Telemetry by default for nightly and aurora channels
8696     if test "$MOZ_UPDATE_CHANNEL" = "nightly" -o \
8697         "$MOZ_UPDATE_CHANNEL" = "aurora"; then
8698         AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
8699     fi
8702 dnl If we have any service that uploads data (and requires data submission
8703 dnl policy alert), set MOZ_DATA_REPORTING.
8704 dnl We need SUBST for build system and DEFINE for xul preprocessor.
8705 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "MOZ_CRASHREPORTER"; then
8706   MOZ_DATA_REPORTING=1
8707   AC_DEFINE(MOZ_DATA_REPORTING)
8708   AC_SUBST(MOZ_DATA_REPORTING)
8711 dnl win32 options
8712 AC_SUBST(MOZ_MAPINFO)
8713 AC_SUBST(MOZ_BROWSE_INFO)
8714 AC_SUBST(MOZ_TOOLS_DIR)
8715 AC_SUBST(WIN32_REDIST_DIR)
8716 AC_SUBST(MAKENSISU)
8718 dnl Echo the CFLAGS to remove extra whitespace.
8719 CFLAGS=`echo \
8720         $_WARNINGS_CFLAGS \
8721         $CFLAGS`
8723 CXXFLAGS=`echo \
8724         $_WARNINGS_CXXFLAGS \
8725         $CXXFLAGS`
8727 COMPILE_CFLAGS=`echo \
8728     $_DEFINES_CFLAGS \
8729         $_DEPEND_CFLAGS \
8730     $COMPILE_CFLAGS`
8732 COMPILE_CXXFLAGS=`echo \
8733     $_DEFINES_CXXFLAGS \
8734         $_DEPEND_CFLAGS \
8735     $COMPILE_CXXFLAGS`
8737 AC_SUBST(SYSTEM_LIBXUL)
8738 AC_SUBST(MOZ_NATIVE_JPEG)
8739 AC_SUBST(MOZ_NATIVE_PNG)
8740 AC_SUBST(MOZ_NATIVE_BZ2)
8742 AC_SUBST(MOZ_FLEXBOX)
8743 AC_SUBST(MOZ_JPEG_CFLAGS)
8744 AC_SUBST(MOZ_JPEG_LIBS)
8745 AC_SUBST(MOZ_BZ2_CFLAGS)
8746 AC_SUBST(MOZ_BZ2_LIBS)
8747 AC_SUBST(MOZ_PNG_CFLAGS)
8748 AC_SUBST(MOZ_PNG_LIBS)
8750 AC_SUBST(NSPR_CFLAGS)
8751 AC_SUBST(NSPR_LIBS)
8752 AC_SUBST(MOZ_NATIVE_NSPR)
8754 AC_SUBST(NSS_CFLAGS)
8755 AC_SUBST(NSS_LIBS)
8756 AC_SUBST(NSS_DEP_LIBS)
8757 AC_SUBST(MOZ_NATIVE_NSS)
8758 AC_SUBST(NSS_DISABLE_DBM)
8760 OS_CFLAGS="$CFLAGS"
8761 OS_CXXFLAGS="$CXXFLAGS"
8762 OS_CPPFLAGS="$CPPFLAGS"
8763 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
8764 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
8765 OS_LDFLAGS="$LDFLAGS"
8766 OS_LIBS="$LIBS"
8767 AC_SUBST(OS_CFLAGS)
8768 AC_SUBST(OS_CXXFLAGS)
8769 AC_SUBST(OS_CPPFLAGS)
8770 AC_SUBST(OS_COMPILE_CFLAGS)
8771 AC_SUBST(OS_COMPILE_CXXFLAGS)
8772 AC_SUBST(OS_LDFLAGS)
8773 AC_SUBST(OS_LIBS)
8774 AC_SUBST(CROSS_COMPILE)
8775 AC_SUBST(WCHAR_CFLAGS)
8777 AC_SUBST(HOST_CC)
8778 AC_SUBST(HOST_CXX)
8779 AC_SUBST(HOST_CFLAGS)
8780 AC_SUBST(HOST_CXXFLAGS)
8781 AC_SUBST(HOST_LDFLAGS)
8782 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8783 AC_SUBST(HOST_AR)
8784 AC_SUBST(HOST_AR_FLAGS)
8785 AC_SUBST(HOST_LD)
8786 AC_SUBST(HOST_RANLIB)
8787 AC_SUBST(HOST_NSPR_MDCPUCFG)
8788 AC_SUBST(HOST_BIN_SUFFIX)
8789 AC_SUBST(HOST_OS_ARCH)
8791 AC_SUBST(TARGET_CPU)
8792 AC_SUBST(TARGET_VENDOR)
8793 AC_SUBST(TARGET_OS)
8794 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8795 AC_SUBST(TARGET_MD_ARCH)
8796 AC_SUBST(TARGET_XPCOM_ABI)
8797 AC_SUBST(OS_TARGET)
8798 AC_SUBST(OS_ARCH)
8799 AC_SUBST(OS_RELEASE)
8800 AC_SUBST(OS_TEST)
8801 AC_SUBST(CPU_ARCH)
8802 AC_SUBST(INTEL_ARCHITECTURE)
8804 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
8806 AC_SUBST(WRAP_LDFLAGS)
8807 AC_SUBST(MKSHLIB)
8808 AC_SUBST(MKCSHLIB)
8809 AC_SUBST(MKSHLIB_FORCE_ALL)
8810 AC_SUBST(MKSHLIB_UNFORCE_ALL)
8811 AC_SUBST(DSO_CFLAGS)
8812 AC_SUBST(DSO_PIC_CFLAGS)
8813 AC_SUBST(DSO_LDOPTS)
8814 AC_SUBST(LIB_PREFIX)
8815 AC_SUBST(DLL_PREFIX)
8816 AC_SUBST(DLL_SUFFIX)
8817 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
8818 AC_SUBST(LIB_SUFFIX)
8819 AC_SUBST(OBJ_SUFFIX)
8820 AC_SUBST(BIN_SUFFIX)
8821 AC_SUBST(ASM_SUFFIX)
8822 AC_SUBST(IMPORT_LIB_SUFFIX)
8823 AC_SUBST(USE_N32)
8824 AC_SUBST(CC_VERSION)
8825 AC_SUBST(CXX_VERSION)
8826 AC_SUBST(MSMANIFEST_TOOL)
8827 AC_SUBST(NS_ENABLE_TSF)
8828 AC_SUBST(MOZ_NSS_PATCH)
8829 AC_SUBST(MOZ_APP_COMPONENT_LIBS)
8830 AC_SUBST(MOZ_APP_EXTRA_LIBS)
8832 AC_SUBST(MOZ_MEDIA)
8833 AC_SUBST(MOZ_SYDNEYAUDIO)
8834 AC_SUBST(MOZ_SPEEX_RESAMPLER)
8835 AC_SUBST(MOZ_SOUNDTOUCH)
8836 AC_SUBST(MOZ_CUBEB)
8837 AC_SUBST(MOZ_WAVE)
8838 AC_SUBST(MOZ_VORBIS)
8839 AC_SUBST(MOZ_TREMOR)
8840 AC_SUBST(MOZ_OPUS)
8841 AC_SUBST(MOZ_WEBM)
8842 AC_SUBST(MOZ_DASH)
8843 AC_SUBST(MOZ_WMF)
8844 AC_SUBST(MOZ_MEDIA_PLUGINS)
8845 AC_SUBST(MOZ_OMX_PLUGIN)
8846 AC_SUBST(MOZ_VP8_ERROR_CONCEALMENT)
8847 AC_SUBST(MOZ_VP8_ENCODER)
8848 AC_SUBST(MOZ_VP8)
8849 AC_SUBST(MOZ_OGG)
8850 AC_SUBST(VPX_AS)
8851 AC_SUBST(VPX_ASFLAGS)
8852 AC_SUBST(VPX_DASH_C_FLAG)
8853 AC_SUBST(VPX_AS_CONVERSION)
8854 AC_SUBST(VPX_ASM_SUFFIX)
8855 AC_SUBST(VPX_X86_ASM)
8856 AC_SUBST(VPX_ARM_ASM)
8857 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
8858 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
8859 AC_SUBST(LIBJPEG_TURBO_AS)
8860 AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
8861 AC_SUBST(LIBJPEG_TURBO_X86_ASM)
8862 AC_SUBST(LIBJPEG_TURBO_X64_ASM)
8863 AC_SUBST(LIBJPEG_TURBO_ARM_ASM)
8865 AC_SUBST(MOZ_PACKAGE_JSSHELL)
8867 AC_MSG_CHECKING([for posix_fallocate])
8868 AC_TRY_LINK([#define _XOPEN_SOURCE 600
8869   #include <fcntl.h>],
8870                  [posix_fallocate(0, 0, 0);],
8871                  [ac_cv___posix_fallocate=true],
8872                  [ac_cv___posix_fallocate=false])
8874 if test "$ac_cv___posix_fallocate" = true ; then
8875   AC_DEFINE(HAVE_POSIX_FALLOCATE)
8876   AC_MSG_RESULT(yes)
8877 else
8878   AC_MSG_RESULT(no)
8881 dnl Check for missing components
8882 if test "$COMPILE_ENVIRONMENT"; then
8883 if test "$MOZ_X11"; then
8884     if test "$WITHOUT_X11"; then
8885         AC_MSG_ERROR([--without-x specified and MOZ_X11 still defined])
8886     fi
8887     dnl ====================================================
8888     dnl = Check if X headers exist
8889     dnl ====================================================
8890     _SAVE_CFLAGS=$CFLAGS
8891     CFLAGS="$CFLAGS $XCFLAGS"
8892     AC_TRY_COMPILE([
8893         #include <stdio.h>
8894         #include <stdlib.h>
8895         #include <X11/Xlib.h>
8896         #include <X11/Intrinsic.h>
8897         #include <X11/extensions/XShm.h>
8898     ],
8899     [
8900         Display *dpy = 0;
8901         if ((dpy = XOpenDisplay(NULL)) == NULL) {
8902             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
8903             exit(1);
8904         }
8905     ], [],
8906     [ AC_MSG_ERROR([Could not compile basic X program.]) ])
8907     CFLAGS="$_SAVE_CFLAGS"
8909     if test -n "$MISSING_X"; then
8910         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
8911     fi
8913 fi # MOZ_X11
8915 dnl Check for headers, etc. needed by WebGL.
8916 if test "$MOZ_GL_DEFAULT_PROVIDER" = "GLX"; then
8917     MOZ_CHECK_HEADER(GL/glx.h)
8918     if test "$ac_cv_header_GL_glx_h" != "yes"; then
8919         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))])
8920     fi
8921 fi # MOZ_GL_DEFAULT_PROVIDER=GLX
8922 fi # COMPILE_ENVIRONMENT
8924 dnl Set various defines and substitutions
8925 dnl ========================================================
8927 if test "$OS_ARCH" = "Darwin"; then
8928   AC_DEFINE(XP_UNIX)
8929 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2"; then
8930   AC_DEFINE(XP_UNIX)
8933 if test "$MOZ_DEBUG"; then
8934     AC_DEFINE(MOZ_REFLOW_PERF)
8935     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
8938 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then
8939     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
8940     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
8941     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
8942     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
8943     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
8944     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
8945     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
8946     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
8949 AC_SUBST(MOZILLA_VERSION)
8951 AC_SUBST(ac_configure_args)
8953 dnl Spit out some output
8954 dnl ========================================================
8956 dnl The following defines are used by xpcom
8957 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
8958 CPP_THROW_NEW
8959 HAVE_CPP_2BYTE_WCHAR_T
8960 HAVE_CPP_AMBIGUITY_RESOLVING_USING
8961 HAVE_CPP_CHAR16_T
8962 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
8963 HAVE_CPP_PARTIAL_SPECIALIZATION
8964 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
8965 NEED_CPP_UNUSED_IMPLEMENTATIONS
8966 NEW_H
8967 HAVE_GETPAGESIZE
8968 HAVE_ICONV
8969 HAVE_ICONV_WITH_CONST_INPUT
8970 HAVE_MBRTOWC
8971 HAVE_WCRTOMB
8972 HAVE_STATVFS64
8973 HAVE_STATVFS
8974 HAVE_STATFS64
8975 HAVE_STATFS
8976 HAVE_SYS_STATVFS_H
8977 HAVE_SYS_STATFS_H
8978 HAVE_SYS_VFS_H
8979 HAVE_SYS_MOUNT_H
8982 AC_CONFIG_HEADER(
8983 netwerk/necko-config.h
8984 xpcom/xpcom-config.h
8985 xpcom/xpcom-private.h
8988 # Hack around an Apple bug that affects the egrep that comes with OS X 10.7.
8989 # "env ARCHPREFERENCE=i386,x86_64 arch egrep" first tries to use the 32-bit
8990 # Intel part of the egrep fat binary, even on 64-bit systems, and falls back on
8991 # the 64-bit part if it's not a fat binary, as can happen with MacPorts. We
8992 # (apparently) only need this hack when egrep's "pattern" is particularly long
8993 # (as in the following code) and the first egrep on our $PATH is Apple's.  See
8994 # bug 655339.
8995 case "$host" in
8996 *-apple-darwin11*)
8997     FIXED_EGREP="env ARCHPREFERENCE=i386,x86_64 arch egrep"
8998     ;;
9000     FIXED_EGREP="egrep"
9001     ;;
9002 esac
9004 dnl Load the list of Makefiles to generate.
9005 dnl   To add new Makefiles, edit allmakefiles.sh.
9006 dnl   allmakefiles.sh sets the variable, MAKEFILES.
9007 . ${srcdir}/allmakefiles.sh
9009 echo $MAKEFILES > unallmakefiles
9011 AC_OUTPUT($MAKEFILES)
9013 # target_arch is from {ia32|x64|arm}
9014 case "$CPU_ARCH" in
9015 x86_64 | ia64)
9016     WEBRTC_TARGET_ARCH=x64
9017     ;;
9019 arm*)
9020     WEBRTC_TARGET_ARCH=arm
9021     ;;
9023 x86)
9024     WEBRTC_TARGET_ARCH=ia32
9025     ;;
9028 # unsupported arch for webrtc
9029     WEBRTC_TARGET_ARCH=unknown
9030     MOZ_WEBRTC=
9031     ;;
9033 esac
9035 # Generate Makefiles for WebRTC directly from .gyp files
9036 if test "${OS_TARGET}" = "WINNT"; then
9037    if test "$HAVE_64BIT_OS"; then
9038       OS_BITS=64
9039    else
9040       OS_BITS=32
9041    fi
9042    EXTRA_GYP_DEFINES="-D MSVS_VERSION=${_MSVS_VERSION} -D MSVS_OS_BITS=${OS_BITS}"
9044 elif test "${OS_TARGET}" = "Android"; then
9045    EXTRA_GYP_DEFINES="-D gtest_target_type=executable -D android_toolchain=${android_toolchain} -G os=android "
9046    if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
9047       EXTRA_GYP_DEFINES+=" -D armv7=0 "
9048    else
9049       EXTRA_GYP_DEFINES+=" -D armv7=1 "
9050    fi
9053 if test -n "$MOZ_WEBRTC"; then
9054    AC_MSG_RESULT("generating WebRTC Makefiles...")
9056 dnl Any --include files must also appear in -D FORCED_INCLUDE_FILE= entries
9057 dnl so that regeneration via dependencies works correctly
9058    WEBRTC_CONFIG="-D build_with_mozilla=1 --include ${srcdir}/media/webrtc/webrtc_config.gypi -D FORCED_INCLUDE_FILE=${srcdir}/media/webrtc/webrtc_config.gypi"
9060    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}"
9062    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9063      $GYP_WEBRTC_OPTIONS \
9064      --generator-output=${_objdir}/media/webrtc/trunk \
9065      ${srcdir}/media/webrtc/trunk/peerconnection.gyp
9066    if test "$?" != 0; then
9067       AC_MSG_ERROR([failed to generate WebRTC Makefiles])
9068    fi
9070    # XXX disable until we land the tranche with signaling
9071    if test -n "$MOZ_WEBRTC_SIGNALING"; then
9072      AC_MSG_RESULT("generating WebRTC/Signaling Makefiles...")
9073      $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9074        $GYP_WEBRTC_OPTIONS \
9075        -D build_for_test=0 \
9076        --generator-output=${_objdir}/media/webrtc/signaling \
9077        ${srcdir}/media/webrtc/signaling/signaling.gyp
9078      if test "$?" != 0; then
9079         AC_MSG_ERROR([failed to generate WebRTC/Signaling Makefiles])
9080      fi
9082      AC_MSG_RESULT("generating WebRTC/SignalingTest Makefiles...")
9083      $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9084        $GYP_WEBRTC_OPTIONS \
9085        -D build_for_test=1 \
9086        --generator-output=${_objdir}/media/webrtc/signalingtest \
9087        ${srcdir}/media/webrtc/signaling/signaling.gyp
9088      if test "$?" != 0; then
9089        AC_MSG_ERROR([failed to generate WebRTC/SignalingTest Makefiles])
9090      fi
9091    fi
9093    AC_MSG_RESULT("generating gtest Makefiles...")
9094    # Ok to pass some extra -D's that are ignored here
9095    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9096      $GYP_WEBRTC_OPTIONS \
9097      --generator-output=${_objdir}/media/webrtc/trunk/testing/ \
9098      ${srcdir}/media/webrtc/trunk/testing/gtest.gyp
9099    if test "$?" != 0; then
9100       AC_MSG_ERROR([failed to generate gtest Makefiles])
9101    fi
9103    AC_MSG_RESULT("generating nrappkit Makefiles...")
9104    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9105      $GYP_WEBRTC_OPTIONS \
9106      --generator-output=${_objdir}/media/mtransport/third_party/nrappkit \
9107      ${srcdir}/media/mtransport/third_party/nrappkit/nrappkit.gyp
9108    if test "$?" != 0; then
9109       AC_MSG_ERROR([failed to generate nrappkit Makefiles])
9110    fi
9112    AC_MSG_RESULT("generating nICEr Makefiles...")
9113    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9114      $GYP_WEBRTC_OPTIONS \
9115      --generator-output=${_objdir}/media/mtransport/third_party/nICEr \
9116      ${srcdir}/media/mtransport/third_party/nICEr/nicer.gyp
9117    if test "$?" != 0; then
9118       AC_MSG_ERROR([failed to generate nICEr Makefiles])
9119    fi
9122 # Generate a JSON config file for unittest harnesses etc to read
9123 # build configuration details from in a standardized way.
9124 OS_TARGET=${OS_TARGET} \
9125 TARGET_CPU=${TARGET_CPU} \
9126 MOZ_DEBUG=${MOZ_DEBUG} \
9127 MOZ_WIDGET_TOOLKIT=${MOZ_WIDGET_TOOLKIT} \
9128 UNIVERSAL_BINARY=${UNIVERSAL_BINARY} \
9129 MOZ_CRASHREPORTER=${MOZ_CRASHREPORTER} \
9130 MOZ_APP_NAME=${MOZ_APP_NAME} \
9131 MOZ_PER_WINDOW_PRIVATE_BROWSING=${MOZ_PER_WINDOW_PRIVATE_BROWSING} \
9132   $PYTHON ${_topsrcdir}/config/writemozinfo.py ./mozinfo.json.tmp
9133 if cmp -s ./mozinfo.json.tmp ./mozinfo.json; then
9134   rm ./mozinfo.json.tmp
9135 else
9136   mv -f ./mozinfo.json.tmp ./mozinfo.json
9139 # Run jemalloc configure script
9141 if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC3" -o -n "$MOZ_REPLACE_MALLOC"; then
9142   ac_configure_args="$_SUBDIR_CONFIG_ARGS --build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
9143   if test -n "$MOZ_REPLACE_MALLOC"; then
9144     # When using replace_malloc, we always want memalign and valloc exported from jemalloc.
9145     ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
9146     ac_configure_args="$ac_configure_args ac_cv_func_valloc=yes"
9147   fi
9148   if test -n "$MOZ_JEMALLOC3"; then
9149     case "${OS_ARCH}" in
9150       WINNT|Darwin)
9151         # We want jemalloc functions to be kept hidden on both Mac and Windows
9152         # See memory/build/mozmemory_wrap.h for details.
9153         ac_configure_args="$ac_configure_args --without-export"
9154         ;;
9155     esac
9156   elif test "${OS_ARCH}" = Darwin; then
9157     # When building as a replace-malloc lib, disabling the zone allocator
9158     # forces to use pthread_atfork.
9159     ac_configure_args="$ac_configure_args --disable-zone-allocator"
9160   fi
9161   _MANGLE="malloc posix_memalign aligned_alloc calloc realloc free memalign valloc malloc_usable_size"
9162   JEMALLOC_WRAPPER=
9163   if test -z "$MOZ_REPLACE_MALLOC"; then
9164     case "$OS_ARCH" in
9165       Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
9166         MANGLE=$_MANGLE
9167         ;;
9168     esac
9169   elif test -z "$MOZ_JEMALLOC3"; then
9170     MANGLE=$_MANGLE
9171     JEMALLOC_WRAPPER=replace_
9172   fi
9173   if test -n "$MANGLE"; then
9174     MANGLED=
9175     if test -n "$_WRAP_MALLOC" -a -z "$JEMALLOC_WRAPPER"; then
9176       JEMALLOC_WRAPPER=__wrap_
9177     fi
9178     for mangle in ${MANGLE}; do
9179       if test -n "$MANGLED"; then
9180         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle,$MANGLED"
9181       else
9182         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle"
9183       fi
9184     done
9185     ac_configure_args="$ac_configure_args --with-mangling=$MANGLED"
9186   fi
9187   unset CONFIG_FILES
9188   if test -z "$MOZ_TLS"; then
9189     ac_configure_args="$ac_configure_args --disable-tls"
9190   fi
9191   EXTRA_CFLAGS="$CFLAGS"
9192   for var in AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS EXTRA_CFLAGS LDFLAGS; do
9193     ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
9194   done
9195   if test "$CROSS_COMPILE"; then
9196     ac_configure_args="$ac_configure_args je_cv_static_page_shift=12"
9197   fi
9198   _save_cache_file="$cache_file"
9199   cache_file=$_objdir/memory/jemalloc/src/config.cache
9200   AC_OUTPUT_SUBDIRS(memory/jemalloc/src)
9201   cache_file="$_save_cache_file"
9202   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9205 # Run freetype configure script
9207 if test "$MOZ_TREE_FREETYPE"; then
9208    export CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS -std=c99"
9209    export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS"
9210    export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS"
9211    export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS"
9212    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
9213    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes"
9214    AC_OUTPUT_SUBDIRS(modules/freetype2)
9217 if test -z "$direct_nspr_config"; then
9218     dnl ========================================================
9219     dnl = Setup a nice relatively clean build environment for
9220     dnl = sub-configures.
9221     dnl ========================================================
9222     CC="$_SUBDIR_CC"
9223     CXX="$_SUBDIR_CXX"
9224     CFLAGS="$_SUBDIR_CFLAGS"
9225     CPPFLAGS="$_SUBDIR_CPPFLAGS"
9226     CXXFLAGS="$_SUBDIR_CXXFLAGS"
9227     LDFLAGS="$_SUBDIR_LDFLAGS"
9228     HOST_CC="$_SUBDIR_HOST_CC"
9229     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9230     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9231     RC=
9234 unset MAKEFILES
9235 unset CONFIG_FILES
9237 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9238 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9240 export WRAP_LDFLAGS
9242 if test -n "$_WRAP_MALLOC"; then
9243     # Avoid doubling wrap malloc arguments
9244     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
9247 if test -z "$MOZ_NATIVE_NSPR"; then
9248     ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
9249     if test -z "$MOZ_DEBUG"; then
9250         ac_configure_args="$ac_configure_args --disable-debug"
9251     else
9252         ac_configure_args="$ac_configure_args --enable-debug"
9253     fi
9254     if test "$MOZ_OPTIMIZE" = "1"; then
9255         ac_configure_args="$ac_configure_args --enable-optimize"
9256     elif test -z "$MOZ_OPTIMIZE"; then
9257         ac_configure_args="$ac_configure_args --disable-optimize"
9258     fi
9259     if test -n "$HAVE_64BIT_OS"; then
9260         ac_configure_args="$ac_configure_args --enable-64bit"
9261     fi
9262     if test -n "$USE_ARM_KUSER"; then
9263         ac_configure_args="$ac_configure_args --with-arm-kuser"
9264     fi
9265     ac_configure_args="$ac_configure_args $NSPR_CONFIGURE_ARGS"
9266     if test -n "$MOZ_LINKER" -a "$ac_cv_func_dladdr" = no ; then
9267       # dladdr is supported by the new linker, even when the system linker doesn't
9268       # support it. Trick nspr into using dladdr when it's not supported.
9269       _SAVE_CPPFLAGS="$CPPFLAGS"
9270       export CPPFLAGS="-include $_topsrcdir/mozglue/linker/dladdr.h $CPPFLAGS"
9271     fi
9272     _SAVE_LDFLAGS="$LDFLAGS"
9273     export LDFLAGS="$LDFLAGS $NSPR_LDFLAGS"
9274     AC_OUTPUT_SUBDIRS(nsprpub)
9275     LDFLAGS="$_SAVE_LDFLAGS"
9276     if test -n "$MOZ_LINKER" -a "$ac_cv_func_dladdr" = no; then
9277       unset CPPFLAGS
9278       CPPFLAGS="$_SAVE_CFLAGS"
9279     fi
9280     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9283 dnl ========================================================
9284 dnl = Setup a nice relatively clean build environment for
9285 dnl = sub-configures.
9286 dnl ========================================================
9287 CC="$_SUBDIR_CC"
9288 CXX="$_SUBDIR_CXX"
9289 CFLAGS="$_SUBDIR_CFLAGS"
9290 CPPFLAGS="$_SUBDIR_CPPFLAGS"
9291 CXXFLAGS="$_SUBDIR_CXXFLAGS"
9292 LDFLAGS="$_SUBDIR_LDFLAGS"
9293 HOST_CC="$_SUBDIR_HOST_CC"
9294 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9295 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9298 # Run the SpiderMonkey 'configure' script.
9299 dist=$MOZ_BUILD_ROOT/dist
9300 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9301 ac_configure_args="$ac_configure_args --enable-threadsafe"
9302 if test "$BUILD_CTYPES"; then
9303     # Build js-ctypes on the platforms we can.
9304     ac_configure_args="$ac_configure_args --enable-ctypes"
9306 if test -z "$JS_SHARED_LIBRARY" ; then
9307     ac_configure_args="$ac_configure_args --disable-shared-js"
9309 if test -z "$MOZ_NATIVE_NSPR"; then
9310     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
9311     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
9313 ac_configure_args="$ac_configure_args --with-dist-dir=../../dist"
9314 ac_configure_args="$ac_configure_args --prefix=$dist"
9315 if test "$MOZ_MEMORY"; then
9316    ac_configure_args="$ac_configure_args --enable-jemalloc"
9318 if test -n "$MOZ_GLUE_LDFLAGS"; then
9319    export MOZ_GLUE_LDFLAGS
9321 if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
9322    export MOZ_GLUE_PROGRAM_LDFLAGS
9324 if test "$MOZ_NATIVE_ZLIB" != 1 -a "$OS_ARCH" = "WINNT"; then
9325    MOZ_ZLIB_LIBS=
9327 export MOZ_NATIVE_ZLIB
9328 export MOZ_ZLIB_CFLAGS
9329 export MOZ_ZLIB_LIBS
9330 export MOZ_APP_NAME
9331 export DONT_POPULATE_VIRTUALENV=1
9332 export PYTHON
9333 export MOZILLA_CENTRAL_PATH=$_topsrcdir
9334 export STLPORT_CPPFLAGS
9335 export STLPORT_LDFLAGS
9336 export STLPORT_LIBS
9337 AC_OUTPUT_SUBDIRS(js/src)
9338 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9340 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR