Bug 863263 part A - Modify some code in nsReadableUtils to support fallible and infal...
[gecko.git] / configure.in
blob3e4cf8659912c6d14d97e61ae670c0e03bd4e4dc
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 if test -n "$GNU_CC" -a -z "$CLANG_CC" ; then
404     if test "$GCC_MAJOR_VERSION" -eq 4 -a "$GCC_MINOR_VERSION" -lt 4 ||
405        test "$GCC_MAJOR_VERSION" -lt 4; then
406         AC_MSG_ERROR([Only GCC 4.4 or newer supported])
407     fi
410 dnl ========================================================
411 dnl Special win32 checks
412 dnl ========================================================
414 MOZ_ARG_ENABLE_BOOL(metro,
415 [  --enable-metro           Enable Windows Metro build targets],
416     MOZ_METRO=1,
417     MOZ_METRO=)
418 if test -n "$MOZ_METRO"; then
419     AC_DEFINE(MOZ_METRO)
420     # Target the Windows 8 Kit
421     WINSDK_TARGETVER=602
422     WINVER=502
423     # toolkit/library/makefile.in needs these, see nsDllMain.
424     CRTDLLVERSION=110
425     CRTEXPDLLVERSION=1-1-0
426 else
427     # Target the Windows 7 SDK by default
428     WINSDK_TARGETVER=601
429     WINVER=502
432 AC_SUBST(CRTDLLVERSION)
433 AC_SUBST(CRTEXPDLLVERSION)
435 MOZ_ARG_WITH_STRING(windows-version,
436 [  --with-windows-version=WINSDK_TARGETVER
437                           Windows SDK version to target. Lowest version
438                           currently allowed is 601 (Win7), highest is 602 (Win8)],
439   WINSDK_TARGETVER=$withval)
441 # Currently only two sdk versions allowed, 601 and 602
442 case "$WINSDK_TARGETVER" in
443 601|602)
444     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
445     ;;
448     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER)]);
449     ;;
450 esac
452 case "$target" in
453 *-mingw*)
454     if test "$GCC" != "yes"; then
455         # Check to see if we are really running in a msvc environemnt
456         _WIN32_MSVC=1
457         AC_CHECK_PROGS(MIDL, midl)
459         # Make sure compilers are valid
460         CFLAGS="$CFLAGS -TC -nologo"
461         CXXFLAGS="$CXXFLAGS -TP -nologo"
462         AC_LANG_SAVE
463         AC_LANG_C
464         AC_TRY_COMPILE([#include <stdio.h>],
465             [ printf("Hello World\n"); ],,
466             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
468         AC_LANG_CPLUSPLUS
469         AC_TRY_COMPILE([#include <new.h>],
470             [ unsigned *test = new unsigned(42); ],,
471             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
472         AC_LANG_RESTORE
474         changequote(,)
475         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
476         changequote([,])
478         # Determine compiler version
479         CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
480         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
481         _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
482         _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
483         _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
484         _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
486         CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
487         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
489         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
490             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
491         fi
493         if test "$_CC_MAJOR_VERSION" = "14"; then
494             dnl Require VC8SP1 or newer.
495             dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762.
496             if test "$_CC_RELEASE" -lt 50727 -o \
497                     \( "$_CC_RELEASE" -eq 50727 -a "$_CC_BUILD" -lt 762 \); then
498               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.])
499             fi
501             _CC_SUITE=8
502             _MSVS_VERSION=2005
503             AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
504             AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
505         elif test "$_CC_MAJOR_VERSION" = "15"; then
506             _CC_SUITE=9
507             _MSVS_VERSION=2008
508             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
509             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
510         elif test "$_CC_MAJOR_VERSION" = "16"; then
511             _CC_SUITE=10
512             _MSVS_VERSION=2010
513             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
514             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
515         elif test "$_CC_MAJOR_VERSION" = "17"; then
516             _CC_SUITE=11
517             _MSVS_VERSION=2012
518             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
519             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
520         else
521             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
522         fi
524         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
526         if test -n "$WIN32_REDIST_DIR"; then
527           if test ! -d "$WIN32_REDIST_DIR"; then
528             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
529           fi
530           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
531         fi
533         dnl Confirm we have the pri tools on win8 builds
534         if test -n "$MOZ_METRO"; then
535           AC_MSG_CHECKING([for makepri])
536           AC_CHECK_PROGS(MAKEPRI, makepri, "")
537           if test -z "MAKEPRI" ; then
538               AC_MSG_ERROR([makepri.exe is required for generating metro browser install components. It should be in the Win8 SDK.])
539           fi
540           AC_SUBST(MAKEPRI)
541         fi
543         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
544         dnl not something else like "magnetic tape manipulation utility".
545         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
546         if test -z "$MSMT_TOOL"; then
547           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
548         fi
550         changequote(,)
551         _MSMT_VER_FILTER='s|.*[^!-~]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
552         changequote([,])
553         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
554         if test -z "$MSMANIFEST_TOOL_VERSION"; then
555           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
556         fi
558         MSMANIFEST_TOOL=1
559         unset MSMT_TOOL
561         # Check linker version
562         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
563         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
564         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
565             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
566         fi
568         INCREMENTAL_LINKER=1
570         # Check midl version
571         _MIDL_FULL_VERSION=`"${MIDL}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
572         _MIDL_MAJOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
573         _MIDL_MINOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
574         _MIDL_REV_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
575         # Add flags if necessary
576         AC_MSG_CHECKING([for midl flags])
577         case "$target" in
578         i*86-*)
579             if test \( "$_MIDL_MAJOR_VERSION" = "7" -a "$_MIDL_MINOR_VERSION" = "00" -a "$_MIDL_REV_VERSION" = "0499" \); then
580                 # MIDL version 7.00.0499 defaults /env win64 on x64 platforms.
581                 # MIDL version 7.00.0500 or later has no problem.
582                 MIDL_FLAGS="${MIDL_FLAGS} -env win32"
583                 AC_MSG_RESULT([need -env win32])
584             else
585                 AC_MSG_RESULT([none needed])
586             fi
587             ;;
588         x86_64-*)
589             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
590             ;;
591         *)
592             AC_MSG_RESULT([none needed])
593             ;;
594         esac
596         # Identify which version of the SDK we're building with
597         # Windows Server 2008 and newer SDKs have WinSDKVer.h, get the version
598         # from there
599         MOZ_CHECK_HEADERS([winsdkver.h])
600         if test "$ac_cv_header_winsdkver_h" = "yes"; then
601             # Get the highest _WIN32_WINNT and NTDDI versions supported
602             # Take the higher of the two
603             # This is done because the Windows 7 beta SDK reports its
604             # NTDDI_MAXVER to be 0x06000100 instead of 0x06010000, as it should
605             AC_CACHE_CHECK(for highest Windows version supported by this SDK,
606                            ac_cv_winsdk_maxver,
607                            [cat > conftest.h <<EOF
608 #include <winsdkver.h>
609 #include <sdkddkver.h>
611 #if (NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER) > NTDDI_MAXVER)
612 #define WINSDK_MAXVER NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER)
613 #else
614 #define WINSDK_MAXVER NTDDI_MAXVER
615 #endif
617 WINSDK_MAXVER
619                             ac_cv_winsdk_maxver=`$CPP conftest.h 2>/dev/null | tail -n1`
620                             rm -f conftest.h
621                            ])
622             MOZ_WINSDK_MAXVER=${ac_cv_winsdk_maxver}
623         else
624             # Any SDK which doesn't have WinSDKVer.h is too old.
625             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.])
626         fi
628         unset _MSVC_VER_FILTER
630         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
631             [
632                 AC_LANG_SAVE
633                 AC_LANG_CPLUSPLUS
634                 _SAVE_CXXFLAGS="$CXXFLAGS"
635                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
636                 AC_TRY_COMPILE([#include <exception>],
637                             [std::_Throw(std::exception()); return 0;],
638                             ac_cv_have_std__Throw="yes",
639                             ac_cv_have_std__Throw="no")
640                 CXXFLAGS="$_SAVE_CXXFLAGS"
641                 AC_LANG_RESTORE
642             ])
644         if test "$ac_cv_have_std__Throw" = "yes"; then
645             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
646                            ac_cv_have_dllimport_exception_bug,
647                 [
648                     AC_LANG_SAVE
649                     AC_LANG_CPLUSPLUS
650                     _SAVE_CXXFLAGS="$CXXFLAGS"
651                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
652                     AC_TRY_LINK([#include <vector>],
653                                 [std::vector<int> v; return v.at(1);],
654                                 ac_cv_have_dllimport_exception_bug="no",
655                                 ac_cv_have_dllimport_exception_bug="yes")
656                     CXXFLAGS="$_SAVE_CXXFLAGS"
657                     AC_LANG_RESTORE
658                 ])
659             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
660                 WRAP_STL_INCLUDES=1
661                 MOZ_MSVC_STL_WRAP__Throw=1
662                 AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
663             fi
664         else
665             AC_CACHE_CHECK(for overridable _RAISE,
666                            ac_cv_have__RAISE,
667                 [
668                     AC_LANG_SAVE
669                     AC_LANG_CPLUSPLUS
670                     _SAVE_CXXFLAGS="$CXXFLAGS"
671                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
672                     AC_TRY_COMPILE([#include <xstddef>
673                                     #undef _RAISE
674                                     #define _RAISE(x) externallyDefinedFunction((x).what())
675                                     #include <vector>
676                                    ],
677                                    [std::vector<int> v; return v.at(1);],
678                                    ac_cv_have__RAISE="no",
679                                    ac_cv_have__RAISE="yes")
680                     CXXFLAGS="$_SAVE_CXXFLAGS"
681                     AC_LANG_RESTORE
682                 ])
683             if test "$ac_cv_have__RAISE" = "yes"; then
684                 WRAP_STL_INCLUDES=1
685                 MOZ_MSVC_STL_WRAP__RAISE=1
686                 AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
687             else
688                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
689             fi
690         fi
692         if test "$WRAP_STL_INCLUDES" = "1"; then
693             STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
694         fi
695     else
696         # Check w32api version
697         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
698         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
699         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
700         AC_TRY_COMPILE([#include <w32api.h>],
701             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
702                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
703                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
704                 #error "test failed."
705             #endif
706             , [ res=yes ], [ res=no ])
707         AC_MSG_RESULT([$res])
708         if test "$res" != "yes"; then
709             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
710         fi
711         # Check windres version
712         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
713         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
714         AC_MSG_RESULT([$_WINDRES_VERSION])
715         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
716         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
717         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
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         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
722                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
723                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
724                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
725                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
726                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
727         then
728             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
729         fi
731         AC_CHECK_PROGS(MIDL, $target-widl widl)
732         if test -n "$MIDL"; then
733             case "$target" in
734             i*86-*)
735                 MIDL_FLAGS="$MIDL_FLAGS --win32 -m32"
736                 ;;
737             x86_64-*)
738                 MIDL_FLAGS="$MIDL_FLAGS --win64 -m64"
739                 ;;
740             esac
741         fi
743         MOZ_WINSDK_MAXVER=0x06020000
744     fi # !GNU_CC
746     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
747     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
748     # Require OS features provided by IE 6.0 SP2 (XP SP2)
749     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
751     # If the maximum version supported by this SDK is lower than the target
752     # version, error out
753     AC_MSG_CHECKING([for Windows SDK being recent enough])
754     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
755         AC_MSG_RESULT("yes")
756     else
757         AC_MSG_RESULT("no")
758         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.])
759     fi
760     
761     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
762     # Definitions matching sdkddkver.h
763     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
764     ;;
765 esac
767 AC_PROG_CPP
768 AC_PROG_CXXCPP
770 if test -n "$_WIN32_MSVC"; then
771     SKIP_PATH_CHECKS=1
772     SKIP_COMPILER_CHECKS=1
773     SKIP_LIBRARY_CHECKS=1
775     # Since we're skipping compiler and library checks, hard-code
776     # some facts here.
777     AC_DEFINE(HAVE_IO_H)
778     AC_DEFINE(HAVE_SETBUF)
779     AC_DEFINE(HAVE_ISATTY)
782 fi # COMPILE_ENVIRONMENT
784 AC_SUBST(MIDL_FLAGS)
785 AC_SUBST(_MSC_VER)
787 AC_SUBST(GNU_AS)
788 AC_SUBST(GNU_LD)
789 AC_SUBST(GNU_CC)
790 AC_SUBST(GNU_CXX)
791 AC_SUBST(INTEL_CC)
792 AC_SUBST(INTEL_CXX)
794 AC_SUBST(STL_FLAGS)
795 AC_SUBST(WRAP_STL_INCLUDES)
796 AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
797 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
799 dnl ========================================================
800 dnl Checks for programs.
801 dnl ========================================================
802 AC_PROG_INSTALL
803 AC_PROG_LN_S
805 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
806 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
807 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
808 _perl_res=$?
809 AC_MSG_RESULT([$_perl_version])
811 if test "$_perl_res" != 0; then
812     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
816 AC_MSG_CHECKING([for full perl installation])
817 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
818 _perl_res=$?
819 if test "$_perl_res" != 0; then
820     AC_MSG_RESULT([no])
821     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
822 else
823     AC_MSG_RESULT([yes])
826 MOZ_ARG_WITH_BOOL(system-ply,
827 [  --with-system-ply       Use system installed python ply library],
828     [if $PYTHON -c 'import ply' 2>&5; then
829          MOZ_SYSTEM_PLY=1
830      else
831          AC_MSG_ERROR([python ply library is not found but --with-system-ply was requested])
832      fi])
834 AC_SUBST(MOZ_SYSTEM_PLY)
836 if test -z "$COMPILE_ENVIRONMENT"; then
837     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
839 AC_SUBST(NSINSTALL_BIN)
841 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
842 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
843 MOZ_PATH_PROGS(UNZIP, unzip)
844 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
845     AC_MSG_ERROR([unzip not found in \$PATH])
847 MOZ_PATH_PROGS(ZIP, zip)
848 if test -z "$ZIP" -o "$ZIP" = ":"; then
849     AC_MSG_ERROR([zip not found in \$PATH])
851 MOZ_PATH_PROG(XARGS, xargs)
852 if test -z "$XARGS" -o "$XARGS" = ":"; then
853     AC_MSG_ERROR([xargs not found in \$PATH .])
856 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
857 AC_SUBST(RPMBUILD)
859 if test "$COMPILE_ENVIRONMENT"; then
861 dnl ========================================================
862 dnl = Mac OS X toolchain support
863 dnl ========================================================
865 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
866 dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
867 dnl when we can run target binaries.
868 AC_SUBST(UNIVERSAL_BINARY)
869 AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
871 MOZ_ARG_WITH_STRING(unify-dist,
872 [  --with-unify-dist=dir   Location of the dist directory to unify with at packaging time (Mac OS X universal build only)],
873     UNIFY_DIST=$withval)
874 if test -n "$UNIVERSAL_BINARY"; then
875     if test -z "$UNIFY_DIST"; then
876         AC_MSG_ERROR([You need to provide the --with-unify-dist=dir argument when performing a universal build])
877     fi
878     case "$UNIFY_DIST" in
879     /*)
880         ;;
881     *)
882         UNIFY_DIST="${MOZ_BUILD_ROOT}/${UNIFY_DIST}"
883         ;;
884     esac
886 AC_SUBST(UNIFY_DIST)
888 dnl ========================================================
889 dnl Check for MacOS deployment target version
890 dnl ========================================================
892 MOZ_ARG_ENABLE_STRING(macos-target,
893                       [  --enable-macos-target=VER (default=10.6)
894                           Set the minimum MacOS version needed at runtime],
895                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
897 case "$target" in
898 *-darwin*)
899     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
900         dnl Use the specified value
901         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
902     else
903         dnl No value specified on the command line or in the environment,
904         dnl use architecture minimum.
905         export MACOSX_DEPLOYMENT_TARGET=10.6
906     fi
907     ;;
908 esac
910 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
912 dnl ========================================================
913 dnl = Mac OS X SDK support
914 dnl ========================================================
915 MACOS_SDK_DIR=
916 NEXT_ROOT=
917 MOZ_ARG_WITH_STRING(macos-sdk,
918 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
919     MACOS_SDK_DIR=$withval)
921 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
922 dnl NEXT_ROOT will be set and exported only if it's needed.
923 AC_SUBST(MACOS_SDK_DIR)
924 AC_SUBST(NEXT_ROOT)
926 if test "$MACOS_SDK_DIR"; then
927   dnl Sync this section with the ones in NSPR and NSS.
928   dnl Changes to the cross environment here need to be accounted for in
929   dnl the libIDL checks (below) and xpidl build.
931   if test ! -d "$MACOS_SDK_DIR"; then
932     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
933 specify a valid SDK.  SDKs are installed when the optional cross-development
934 tools are selected during the Xcode/Developer Tools installation.])
935   fi
937   CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
938   CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
940   dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
941   CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
942   CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
944   AC_LANG_SAVE
945   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
946   AC_LANG_CPLUSPLUS
947   AC_TRY_COMPILE([#include <new>],[],
948    result=yes,
949    result=no)
950   AC_LANG_RESTORE
951   AC_MSG_RESULT($result)
953   if test "$result" = "no" ; then
954     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
955   fi
958 fi # COMPILE_ENVIRONMENT
960 AC_MSG_CHECKING([compiler version])
961 # Just print it so it shows up in the logs.
962 cc_version=$($CC --version)
963 AC_MSG_RESULT([$cc_version])
965 if test -n "$MAKE"; then
966   if test `echo $MAKE | grep -c make.py` != 1; then
967      NOT_PYMAKE=$MAKE
968   fi
971 case "$host_os" in
972 mingw*)
973     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
974     ;;
976     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
977     ;;
978 esac
979 if test "$GMAKE" = ":"; then
980    AC_MSG_ERROR([GNU make not found])
982 AC_SUBST(GMAKE)
984 if test -z "$MAKE"; then
985   MAKE=$GMAKE
988 if test "$COMPILE_ENVIRONMENT"; then
990 AC_PATH_XTRA
992 XCFLAGS="$X_CFLAGS"
994 fi # COMPILE_ENVIRONMENT
996 dnl ========================================================
997 dnl set the defaults first
998 dnl ========================================================
999 AS_BIN=$AS
1000 AR_LIST='$(AR) t'
1001 AR_EXTRACT='$(AR) x'
1002 AR_DELETE='$(AR) d'
1003 AS='$(CC)'
1004 AS_DASH_C_FLAG='-c'
1005 DLL_PREFIX=lib
1006 LIB_PREFIX=lib
1007 DLL_SUFFIX=.so
1008 OBJ_SUFFIX=o
1009 LIB_SUFFIX=a
1010 ASM_SUFFIX=s
1011 IMPORT_LIB_SUFFIX=
1012 TARGET_MD_ARCH=unix
1013 DIRENT_INO=d_ino
1014 MOZ_USER_DIR=".mozilla"
1016 MOZ_JPEG_CFLAGS=
1017 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)'
1018 MOZ_BZ2_CFLAGS=
1019 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
1020 MOZ_PNG_CFLAGS=
1021 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
1023 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
1024 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
1025 DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core -lmozalloc'
1026 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
1027 XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom -lmozalloc'
1028 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
1029 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
1030 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
1032 # These are specially defined on Windows only
1033 case "$target" in
1034 *-mingw*)
1035   XPCOM_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
1036   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime.$(LIB_SUFFIX)'
1037   ;;
1039   XPCOM_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_GLUE_LDOPTS
1040   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_STANDALONE_GLUE_LDOPTS
1041   ;;
1042 esac
1044 MOZ_FS_LAYOUT=unix
1046 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
1048 USE_DEPENDENT_LIBS=1
1050 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
1052 if test -n "$CROSS_COMPILE"; then
1053     OS_TARGET="${target_os}"
1054     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
1055     OS_RELEASE=
1056     case "${target_os}" in
1057         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
1058         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
1059         gnu*)         OS_ARCH=GNU ;;
1060         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
1061         mingw*)       OS_ARCH=WINNT OS_TARGET=WINNT ;;
1062         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
1063     esac
1064     case "${target}" in
1065         *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
1066     esac
1067 else
1068     OS_TARGET=`uname -s`
1069     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
1070     OS_RELEASE=`uname -r`
1073 # Before this used `uname -m` when not cross compiling
1074 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
1075 OS_TEST="${target_cpu}"
1077 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
1079 #######################################################################
1080 # Master "Core Components" macros for getting the OS target           #
1081 #######################################################################
1084 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
1085 # cross-compilation.
1089 # Define and override various archtecture-specific variables, including
1090 # HOST_OS_ARCH
1091 # OS_ARCH
1092 # OS_TEST
1093 # OS_TARGET
1094 # OS_RELEASE
1095 # OS_MINOR_RELEASE
1098 case "$HOST_OS_ARCH" in
1099 mingw*)
1100     HOST_OS_ARCH=WINNT
1101     ;;
1102 darwin*)
1103     HOST_OS_ARCH=Darwin
1104     ;;
1105 linux*)
1106     HOST_OS_ARCH=Linux
1107     ;;
1108 solaris*)
1109     HOST_OS_ARCH=SunOS
1110     SOLARIS_SUNPRO_CC=
1111     SOLARIS_SUNPRO_CXX=
1112     if test -z "$GNU_CC"; then
1113         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1114             SOLARIS_SUNPRO_CC=1
1115        fi
1116     fi
1118     if test -z "$GNU_CXX"; then
1119        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1120            SOLARIS_SUNPRO_CXX=1
1121        fi
1122     fi
1123     AC_SUBST(SOLARIS_SUNPRO_CC)
1124     AC_SUBST(SOLARIS_SUNPRO_CXX)
1125     ;;
1126 OS_2)
1127     HOST_OS_ARCH=OS2
1128     ;;
1129 esac
1131 case "$OS_ARCH" in
1132 WINNT)
1133     if test -z "$CROSS_COMPILE" ; then
1134         OS_TEST=`uname -p`
1135     fi
1136     ;;
1137 Windows_NT)
1139 # If uname -s returns "Windows_NT", we assume that we are using
1140 # the uname.exe in MKS toolkit.
1142 # The -r option of MKS uname only returns the major version number.
1143 # So we need to use its -v option to get the minor version number.
1144 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1146     OS_ARCH=WINNT
1147     OS_TARGET=WINNT
1148     OS_MINOR_RELEASE=`uname -v`
1149     if test "$OS_MINOR_RELEASE" = "00"; then
1150         OS_MINOR_RELEASE=0
1151     fi
1152     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1153     ;;
1154 MINGW*_NT*)
1156 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1157 # the uname.exe in the MSYS tools.
1159     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1160     OS_ARCH=WINNT
1161     OS_TARGET=WINNT
1162     ;;
1163 AIX)
1164     OS_RELEASE=`uname -v`.`uname -r`
1165     OS_TEST=${target_cpu}
1166     ;;
1167 OS_2)
1168     OS_ARCH=OS2
1169     OS_TARGET=OS2
1170     OS_RELEASE=`uname -v`
1171     ;;
1172 Darwin)
1173     case "${target_cpu}" in
1174     powerpc*)
1175         OS_TEST=ppc
1176         ;;
1177     i*86*)
1178         OS_TEST=i386
1179         ;;
1180     x86_64)
1181         OS_TEST=x86_64
1182         ;;
1183     *)
1184         if test -z "$CROSS_COMPILE" ; then
1185             OS_TEST=`uname -p`
1186         fi
1187         ;;
1188     esac
1189     ;;
1190 esac
1192 # Only set CPU_ARCH if we recognize the value of OS_TEST
1194 case "$OS_TEST" in
1195 *86 | i86pc)
1196     CPU_ARCH=x86
1197     ;;
1199 powerpc64 | ppc64)
1200     CPU_ARCH=ppc64
1201     ;;
1203 powerpc | ppc | rs6000)
1204     CPU_ARCH=ppc
1205     ;;
1207 Alpha | alpha | ALPHA)
1208     CPU_ARCH=Alpha
1209     ;;
1211 s390)
1212     CPU_ARCH=s390
1213     ;;
1215 s390x)
1216     CPU_ARCH=s390x
1217     ;;
1219 hppa* | parisc)
1220     CPU_ARCH=hppa
1221     ;;
1223 sun4u | sparc*)
1224     CPU_ARCH=sparc
1225     ;;
1227 x86_64 | ia64)
1228     CPU_ARCH="$OS_TEST"
1229     ;;
1231 arm*)
1232     CPU_ARCH=arm
1233     ;;
1235 mips|mipsel)
1236     CPU_ARCH="mips"
1237     ;;
1238 esac
1240 if test -z "$OS_TARGET"; then
1241     OS_TARGET=$OS_ARCH
1243 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1245 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1246 dnl ===============================================================
1247 INTEL_ARCHITECTURE=
1248 case "$OS_TEST" in
1249     x86_64|i?86)
1250       INTEL_ARCHITECTURE=1
1251 esac
1253 dnl Configure platform-specific CPU architecture compiler options.
1254 dnl ==============================================================
1255 MOZ_ARCH_OPTS
1257 dnl =================================================================
1258 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1259 dnl which is bad when cross compiling.
1260 dnl =================================================================
1261 if test "$COMPILE_ENVIRONMENT"; then
1262 configure_static_assert_macros='
1263 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1264 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1265 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1268 dnl test that the macros actually work:
1269 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1270 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1271  [AC_LANG_SAVE
1272   AC_LANG_C
1273   ac_cv_static_assertion_macros_work="yes"
1274   AC_TRY_COMPILE([$configure_static_assert_macros],
1275                  [CONFIGURE_STATIC_ASSERT(1)],
1276                  ,
1277                  ac_cv_static_assertion_macros_work="no")
1278   AC_TRY_COMPILE([$configure_static_assert_macros],
1279                  [CONFIGURE_STATIC_ASSERT(0)],
1280                  ac_cv_static_assertion_macros_work="no",
1281                  )
1282   AC_LANG_CPLUSPLUS
1283   AC_TRY_COMPILE([$configure_static_assert_macros],
1284                  [CONFIGURE_STATIC_ASSERT(1)],
1285                  ,
1286                  ac_cv_static_assertion_macros_work="no")
1287   AC_TRY_COMPILE([$configure_static_assert_macros],
1288                  [CONFIGURE_STATIC_ASSERT(0)],
1289                  ac_cv_static_assertion_macros_work="no",
1290                  )
1291   AC_LANG_RESTORE
1292  ])
1293 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1294 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1295     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1297 fi # COMPILE_ENVIRONMENT
1299 dnl ========================================================
1300 dnl Android libstdc++, placed here so it can use MOZ_ARCH
1301 dnl computed above.
1302 dnl ========================================================
1304 MOZ_ANDROID_STLPORT
1306 dnl ========================================================
1307 dnl Suppress Clang Argument Warnings
1308 dnl ========================================================
1309 if test -n "$CLANG_CC"; then
1310     _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
1311     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
1313 if test -n "$CLANG_CXX"; then
1314     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
1317 dnl ========================================================
1318 dnl = Use Address Sanitizer
1319 dnl ========================================================
1320 MOZ_ARG_ENABLE_BOOL(address-sanitizer,
1321 [  --enable-address-sanitizer       Enable Address Sanitizer (default=no)],
1322     MOZ_ASAN=1,
1323     MOZ_ASAN= )
1324 if test -n "$MOZ_ASAN"; then
1325     MOZ_LLVM_HACKS=1
1326     AC_DEFINE(MOZ_ASAN)
1328 AC_SUBST(MOZ_ASAN)
1330 dnl ========================================================
1331 dnl = Enable hacks required for LLVM instrumentations
1332 dnl ========================================================
1333 MOZ_ARG_ENABLE_BOOL(llvm-hacks,
1334 [  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)],
1335     MOZ_LLVM_HACKS=1,
1336     MOZ_LLVM_HACKS= )
1337 if test -n "$MOZ_LLVM_HACKS"; then
1338     MOZ_NO_WLZDEFS=1
1339     MOZ_CFLAGS_NSS=1
1341 AC_SUBST(MOZ_NO_WLZDEFS)
1342 AC_SUBST(MOZ_CFLAGS_NSS)
1344 dnl ========================================================
1345 dnl GNU specific defaults
1346 dnl ========================================================
1347 if test "$GNU_CC"; then
1348     # Per bug 719659 comment 2, some of the headers on ancient build machines
1349     # may require gnu89 inline semantics.  But otherwise, we use C99.
1350     CFLAGS="$CFLAGS -std=gnu99 -fgnu89-inline"
1351     # FIXME: Let us build with strict aliasing. bug 414641.
1352     CFLAGS="$CFLAGS -fno-strict-aliasing"
1353     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1354     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1355     DSO_LDOPTS='-shared'
1356     if test "$GCC_USE_GNU_LD"; then
1357         # Some tools like ASan use a runtime library that is only
1358         # linked against executables, so we must allow undefined
1359         # symbols for shared objects in some cases.
1360         if test -z "$MOZ_NO_WLZDEFS"; then
1361             # Don't allow undefined symbols in libraries
1362             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1363         fi
1364     fi
1365     WARNINGS_AS_ERRORS='-Werror'
1366     # Don't treat -Wuninitialized as error b/c it has lots of false positives.
1367     WARNINGS_AS_ERRORS="$WARNINGS_AS_ERRORS -Wno-error=uninitialized"
1368     # Don't treat -Wdeprecated-declarations as error b/c we don't want our
1369     # builds held hostage when a platform-specific API is suddenly deprecated.
1370     WARNINGS_AS_ERRORS="$WARNINGS_AS_ERRORS -Wno-error=deprecated-declarations"
1371     DSO_CFLAGS=''
1372     DSO_PIC_CFLAGS='-fPIC'
1373     ASFLAGS="$ASFLAGS -fPIC"
1374     AC_MSG_CHECKING([for --noexecstack option to as])
1375     _SAVE_CFLAGS=$CFLAGS
1376     CFLAGS="$CFLAGS -Wa,--noexecstack"
1377     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
1378                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
1379                      AC_MSG_RESULT([no]))
1380     CFLAGS=$_SAVE_CFLAGS
1381     AC_MSG_CHECKING([for -z noexecstack option to ld])
1382     _SAVE_LDFLAGS=$LDFLAGS
1383     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
1384     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
1385                   AC_MSG_RESULT([no])
1386                   LDFLAGS=$_SAVE_LDFLAGS)
1387     AC_MSG_CHECKING([for --build-id option to ld])
1388     _SAVE_LDFLAGS=$LDFLAGS
1389     LDFLAGS="$LDFLAGS -Wl,--build-id"
1390     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1391                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,--build-id"],
1392                   AC_MSG_RESULT([no])
1393                   LDFLAGS=$_SAVE_LDFLAGS)
1396     # Check for -mssse3 on $CC
1397     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
1398     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
1399     _SAVE_CFLAGS=$CFLAGS
1400     CFLAGS="$CFLAGS -mssse3"
1401     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
1402                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
1403                      AC_MSG_RESULT([no]))
1404     CFLAGS=$_SAVE_CFLAGS
1405     AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
1407     # Check for -msse4.1 on $CC
1408     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
1409     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
1410     _SAVE_CFLAGS=$CFLAGS
1411     CFLAGS="$CFLAGS -msse4.1"
1412     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
1413                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
1414                      AC_MSG_RESULT([no]))
1415     CFLAGS=$_SAVE_CFLAGS
1416     AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
1418     # Turn on GNU-specific warnings:
1419     # -Wall - turn on a lot of warnings
1420     # -Wpointer-arith - good to have
1421     # -Wdeclaration-after-statement - MSVC doesn't like these
1422     # -Werror=return-type - catches missing returns, zero false positives
1423     # -Wtype-limits - catches overflow bugs, few false positives
1424     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1425     #
1426     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
1427     MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
1428     MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
1429     MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
1430     
1431     # Turn off the following warnings that -Wall turns on:
1432     # -Wno-unused - lots of violations in third-party code
1433     #
1434     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
1436     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
1437        # Don't use -Wcast-align with ICC or clang
1438        case "$CPU_ARCH" in
1439            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1440            hppa | ia64 | sparc | arm)
1441            ;;
1442            *)
1443         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1444            ;;
1445        esac
1446     fi
1448     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1449     _USE_CPP_INCLUDE_FLAG=1
1450     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
1452 elif test "$SOLARIS_SUNPRO_CC"; then
1453     DSO_CFLAGS=''
1454     if test "$CPU_ARCH" = "sparc"; then
1455         # for Sun Studio on Solaris/SPARC
1456         DSO_PIC_CFLAGS='-xcode=pic32'
1457     else
1458         DSO_PIC_CFLAGS='-KPIC'
1459     fi
1460     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1461 else
1462     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1463     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $@ -o $@'
1465     DSO_LDOPTS='-shared'
1466     if test "$GNU_LD"; then
1467         # Don't allow undefined symbols in libraries
1468         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1469     fi
1471     DSO_CFLAGS=''
1472     DSO_PIC_CFLAGS='-KPIC'
1473     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1476 if test "$GNU_CXX"; then
1477     # FIXME: Let us build with strict aliasing. bug 414641.
1478     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
1480     # Turn on GNU-specific warnings:
1481     # -Wall - turn on a lot of warnings
1482     # -Wpointer-arith - good to have
1483     # -Woverloaded-virtual - ???
1484     # -Werror=return-type - catches missing returns, zero false positives
1485     # -Wtype-limits - catches overflow bugs, few false positives
1486     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1487     #
1488     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
1489     MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
1490     MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
1491     MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
1493     # Turn off the following warnings that -Wall turns on:
1494     # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
1495     #
1496     MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
1498     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
1499        # Don't use -Wcast-align with ICC or clang
1500        case "$CPU_ARCH" in
1501            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1502            hppa | ia64 | sparc | arm)
1503            ;;
1504            *)
1505         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1506            ;;
1507        esac
1508     fi
1510     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1511     _USE_CPP_INCLUDE_FLAG=1
1513     # Recent clang and gcc support C++11 deleted functions without warnings if
1514     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
1515     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
1516     # unused.  But clang's warning can be disabled, so when compiling with clang
1517     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
1518     # deleted function syntax.
1519     if test "$CLANG_CXX"; then
1520         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
1521         MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
1522     fi
1524 else
1525     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
1528 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1529 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1530 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1531 dnl normal behavior.
1532 dnl ========================================================
1533 MKSHLIB_FORCE_ALL=
1534 MKSHLIB_UNFORCE_ALL=
1536 if test "$COMPILE_ENVIRONMENT"; then
1537 if test "$GNU_CC"; then
1538   AC_MSG_CHECKING(whether ld has archive extraction flags)
1539   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1540    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1541     ac_cv_mkshlib_force_and_unforce="no"
1542     exec 3<&0 <<LOOP_INPUT
1543         force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1544         force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1545         force="-Wl,-all";              unforce="-Wl,-none"
1546 LOOP_INPUT
1547     while read line
1548     do
1549       eval $line
1550       LDFLAGS=$force
1551       LIBS=$unforce
1552       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1553     done
1554     exec 0<&3 3<&-
1555     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1556    ])
1557   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1558     AC_MSG_RESULT(no)
1559   else
1560     AC_MSG_RESULT(yes)
1561     eval $ac_cv_mkshlib_force_and_unforce
1562     MKSHLIB_FORCE_ALL=$force
1563     MKSHLIB_UNFORCE_ALL=$unforce
1564   fi
1565 fi # GNU_CC
1566 fi # COMPILE_ENVIRONMENT
1568 dnl ========================================================
1569 dnl Checking for 64-bit OS
1570 dnl ========================================================
1571 if test "$COMPILE_ENVIRONMENT"; then
1572 AC_LANG_SAVE
1573 AC_LANG_C
1574 AC_MSG_CHECKING(for 64-bit OS)
1575 AC_TRY_COMPILE([$configure_static_assert_macros],
1576                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1577                result="yes", result="no")
1578 AC_MSG_RESULT("$result")
1579 if test "$result" = "yes"; then
1580     AC_DEFINE(HAVE_64BIT_OS)
1581     HAVE_64BIT_OS=1
1583 AC_SUBST(HAVE_64BIT_OS)
1584 AC_LANG_RESTORE
1585 fi # COMPILE_ENVIRONMENT
1587 dnl ========================================================
1588 dnl Enable high-memory support on OS/2 by default.
1589 dnl ========================================================
1590 MOZ_OS2_HIGH_MEMORY=1
1591 MOZ_ARG_DISABLE_BOOL(os2-high-mem,
1592 [  --disable-os2-high-mem  Disable high-memory support on OS/2],
1593     MOZ_OS2_HIGH_MEMORY=,
1594     MOZ_OS2_HIGH_MEMORY=1 )
1595 AC_SUBST(MOZ_OS2_HIGH_MEMORY)
1597 dnl ========================================================
1598 dnl = Use profiling compile flags
1599 dnl ========================================================
1600 MOZ_ARG_ENABLE_BOOL(profiling,
1601 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1602     MOZ_PROFILING=1,
1603     MOZ_PROFILING= )
1605 # For profiling builds keep the symbol information
1606 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
1607     case "$OS_TARGET" in
1608     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
1609         STRIP_FLAGS="--strip-debug"
1610         ;;
1611     esac
1614 dnl ========================================================
1615 dnl = Use incremental GC
1616 dnl ========================================================
1617 JSGC_INCREMENTAL=1
1618 MOZ_ARG_DISABLE_BOOL(gcincremental,
1619 [  --disable-gcincremental Disable incremental GC],
1620     JSGC_INCREMENTAL= )
1621 if test -n "$JSGC_INCREMENTAL"; then
1622     AC_DEFINE(JSGC_INCREMENTAL)
1625 dnl ========================================================
1626 dnl = Use generational GC
1627 dnl ========================================================
1628 MOZ_ARG_ENABLE_BOOL(gcgenerational,
1629 [  --enable-gcgenerational Enable generational GC],
1630     JSGC_GENERATIONAL=1,
1631     JSGC_GENERATIONAL= )
1632 if test -n "$JSGC_GENERATIONAL"; then
1633     AC_DEFINE(JSGC_GENERATIONAL)
1636 dnl ========================================================
1637 dnl = Perform moving GC stack rooting analysis
1638 dnl ========================================================
1639 MOZ_ARG_ENABLE_BOOL(root-analysis,
1640 [  --enable-root-analysis  Enable moving GC stack root analysis],
1641     JSGC_ROOT_ANALYSIS=1,
1642     JSGC_ROOT_ANALYSIS= )
1643 if test -n "$JSGC_ROOT_ANALYSIS"; then
1644     AC_DEFINE(JSGC_ROOT_ANALYSIS)
1647 dnl ========================================================
1648 dnl = Use exact stack rooting for GC
1649 dnl ========================================================
1650 MOZ_ARG_ENABLE_BOOL(exact-rooting,
1651 [  --enable-exact-rooting  Enable use of exact stack roots for GC],
1652     JSGC_USE_EXACT_ROOTING=1,
1653     JSGC_USE_EXACT_ROOTING= )
1654 if test -n "$JSGC_USE_EXACT_ROOTING"; then
1655     AC_DEFINE(JSGC_USE_EXACT_ROOTING)
1658 dnl ========================================================
1659 dnl = Use Valgrind
1660 dnl ========================================================
1661 MOZ_ARG_ENABLE_BOOL(valgrind,
1662 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
1663     MOZ_VALGRIND=1,
1664     MOZ_VALGRIND= )
1665 if test -n "$MOZ_VALGRIND"; then
1666     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1667         AC_MSG_ERROR(
1668             [--enable-valgrind specified but Valgrind is not installed]))
1669     AC_DEFINE(MOZ_VALGRIND)
1671 AC_SUBST(MOZ_VALGRIND)
1673 dnl ========================================================
1674 dnl jprof
1675 dnl ========================================================
1676 MOZ_ARG_ENABLE_BOOL(jprof,
1677 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
1678     MOZ_JPROF=1,
1679     MOZ_JPROF= )
1680 if test -n "$MOZ_JPROF"; then
1681     MOZ_PROFILING=1
1682     AC_DEFINE(MOZ_JPROF)
1685 dnl ========================================================
1686 dnl SPS Profiler
1687 dnl ========================================================
1688 MOZ_ENABLE_PROFILER_SPS=1
1690 case "${OS_TARGET}" in
1691 Android)
1692     case "${CPU_ARCH}" in
1693     x86 | arm) ;;
1694     *)
1695         MOZ_ENABLE_PROFILER_SPS=
1696     esac
1697     ;;
1698 Linux)
1699     case "${CPU_ARCH}" in
1700     x86 | x86_64) ;;
1701     *)
1702         MOZ_ENABLE_PROFILER_SPS=
1703     esac
1704     ;;
1705 WINNT|Darwin) ;;
1707     MOZ_ENABLE_PROFILER_SPS=
1708     ;;
1709 esac
1711 if test -n "$MOZ_ENABLE_PROFILER_SPS"; then
1712     AC_DEFINE(MOZ_ENABLE_PROFILER_SPS)
1715 dnl ========================================================
1716 dnl shark
1717 dnl ========================================================
1718 MOZ_ARG_ENABLE_BOOL(shark,
1719 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
1720     MOZ_SHARK=1,
1721     MOZ_SHARK= )
1722 if test -n "$MOZ_SHARK"; then
1723     MOZ_PROFILING=1
1724     AC_DEFINE(MOZ_SHARK)
1727 dnl ========================================================
1728 dnl callgrind
1729 dnl ========================================================
1730 MOZ_ARG_ENABLE_BOOL(callgrind,
1731 [  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.],
1732     MOZ_CALLGRIND=1,
1733     MOZ_CALLGRIND= )
1734 if test -n "$MOZ_CALLGRIND"; then
1735     MOZ_PROFILING=1
1736     AC_DEFINE(MOZ_CALLGRIND)
1739 dnl ========================================================
1740 dnl vtune
1741 dnl ========================================================
1742 MOZ_ARG_ENABLE_BOOL(vtune,
1743 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
1744     MOZ_VTUNE=1,
1745     MOZ_VTUNE= )
1746 if test -n "$MOZ_VTUNE"; then
1747     MOZ_PROFILING=1
1748     AC_DEFINE(MOZ_VTUNE)
1751 dnl ========================================================
1752 dnl Profiling
1753 dnl ========================================================
1754 if test -n "$MOZ_PROFILING"; then
1755     AC_DEFINE(MOZ_PROFILING)
1758 dnl ========================================================
1759 dnl System overrides of the defaults for host
1760 dnl ========================================================
1761 case "$host" in
1762 *mingw*)
1763     if test -n "$_WIN32_MSVC"; then
1764         HOST_AR=lib
1765         HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
1766         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
1767         HOST_RANLIB='echo ranlib'
1768     else
1769         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
1770     fi
1771     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
1772     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1773     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1774     HOST_BIN_SUFFIX=.exe
1775     case "$host" in
1776     *mingw*)
1777         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1778         ;;
1779     esac
1781     case "${host_cpu}" in
1782     i*86)
1783         if test -n "$_WIN32_MSVC"; then
1784             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
1785         fi
1786         ;;
1787     x86_64)
1788         if test -n "$_WIN32_MSVC"; then
1789             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
1790         fi
1791         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1792         ;;
1793     esac
1794     ;;
1796 *-darwin*)
1797     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1798     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1799     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1800     ;;
1802 *-linux*|*-kfreebsd*-gnu|*-gnu*)
1803     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1804     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1805     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1806     ;;
1808 *os2*)
1809     HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
1810     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
1811     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1812     HOST_BIN_SUFFIX=.exe
1813     MOZ_FIX_LINK_PATHS=
1814     ;;
1817     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1818     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1819     ;;
1820 esac
1822 dnl Check for using a custom <stdint.h> implementation
1823 dnl ========================================================
1824 AC_MSG_CHECKING(for custom <stdint.h> implementation)
1825 if test "$MOZ_CUSTOM_STDINT_H"; then
1826   AC_DEFINE_UNQUOTED(MOZ_CUSTOM_STDINT_H, "$MOZ_CUSTOM_STDINT_H")
1827   AC_MSG_RESULT(using $MOZ_CUSTOM_STDINT_H)
1828 else
1829   AC_MSG_RESULT(none specified)
1832 dnl Get mozilla version from central milestone file
1833 MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
1834 MOZILLA_UAVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -uaversion`
1836 dnl Get version of various core apps from the version files.
1837 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
1839 if test -z "$FIREFOX_VERSION"; then
1840     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
1843 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
1844 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
1845 AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
1847 MOZ_DOING_LTO(lto_is_enabled)
1849 dnl ========================================================
1850 dnl System overrides of the defaults for target
1851 dnl ========================================================
1853 case "$target" in
1854 *-aix*)
1855     AC_DEFINE(AIX)
1856     if test ! "$GNU_CC"; then
1857         if test ! "$HAVE_64BIT_OS"; then
1858             # Compiling with Visual Age C++ object model compat is the
1859             # default. To compile with object model ibm, add
1860             # AIX_OBJMODEL=ibm to .mozconfig.
1861             if test "$AIX_OBJMODEL" = "ibm"; then
1862                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
1863             else
1864                 AIX_OBJMODEL=compat
1865             fi
1866         else
1867             AIX_OBJMODEL=compat
1868         fi
1869         AC_SUBST(AIX_OBJMODEL)
1870         DSO_LDOPTS='-qmkshrobj=1'
1871         DSO_CFLAGS='-qflag=w:w'
1872         DSO_PIC_CFLAGS=
1873         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
1874         MOZ_FIX_LINK_PATHS=
1875         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1876         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1877         if test "$COMPILE_ENVIRONMENT"; then
1878             AC_LANG_SAVE
1879             AC_LANG_CPLUSPLUS
1880             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
1881             AC_TRY_COMPILE([],
1882                 [#if (__IBMCPP__ < 900)
1883                  #error "Bad compiler"
1884                  #endif],
1885                 _BAD_COMPILER=,_BAD_COMPILER=1)
1886             if test -n "$_BAD_COMPILER"; then
1887                 AC_MSG_RESULT([no])
1888                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
1889             else
1890                 AC_MSG_RESULT([yes])
1891             fi
1892             AC_LANG_RESTORE
1893             TARGET_COMPILER_ABI="ibmc"
1894             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
1895             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
1896         fi
1897     fi
1898     case "${target_os}" in
1899     aix4.1*)
1900         DLL_SUFFIX='_shr.a'
1901         ;;
1902     esac
1903     if test "$COMPILE_ENVIRONMENT"; then
1904         MOZ_CHECK_HEADERS(sys/inttypes.h)
1905     fi
1906     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1907     ;;
1909 *-darwin*)
1910     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1911     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1912     MOZ_OPTIMIZE_FLAGS="-O3"
1913     # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
1914     if test "$HAVE_64BIT_OS"; then
1915         MOZ_MEMORY=1
1916     fi
1917     DLL_SUFFIX=".dylib"
1918     DSO_LDOPTS=''
1919     STRIP_FLAGS="$STRIP_FLAGS -x -S"
1920     # Check whether we're targeting OS X or iOS
1921     AC_CACHE_CHECK(for iOS target,
1922                    ac_cv_ios_target,
1923                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
1924 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
1925 #error not iOS
1926 #endif],
1927                                    [],
1928                                    ac_cv_ios_target="yes",
1929                                    ac_cv_ios_target="no")])
1930     if test "$ac_cv_ios_target" = "yes"; then
1931         AC_DEFINE(XP_IOS)
1932         AC_DEFINE(XP_DARWIN)
1933         _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
1934     else
1935         AC_DEFINE(XP_MACOSX)
1936         AC_DEFINE(XP_DARWIN)
1937         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
1938         # The ExceptionHandling framework is needed for Objective-C exception
1939         # logging code in nsObjCExceptions.h. Currently we only use that in debug
1940         # builds.
1941         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
1942     fi
1943     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1946     if test "x$lto_is_enabled" = "xyes"; then
1947         echo "Skipping -dead_strip because lto is enabled."
1948     dnl DTrace and -dead_strip don't interact well. See bug 403132.
1949     dnl ===================================================================
1950     elif test "x$enable_dtrace" = "xyes"; then
1951         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
1952     else
1953         dnl check for the presence of the -dead_strip linker flag
1954         AC_MSG_CHECKING([for -dead_strip option to ld])
1955         _SAVE_LDFLAGS=$LDFLAGS
1956         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
1957         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
1958         if test -n "$_HAVE_DEAD_STRIP" ; then
1959             AC_MSG_RESULT([yes])
1960             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
1961         else
1962             AC_MSG_RESULT([no])
1963         fi
1965         LDFLAGS=$_SAVE_LDFLAGS
1966     fi
1968     dnl With newer linkers we need to pass -allow_heap_execute because of
1969     dnl Microsoft Silverlight (5.1.10411.0 at least).
1970     AC_MSG_CHECKING([for -allow_heap_execute option to ld])
1971     _SAVE_LDFLAGS=$LDFLAGS
1972     LDFLAGS="$LDFLAGS -Wl,-allow_heap_execute"
1973     AC_TRY_LINK(,[return 0;],_HAVE_ALLOW_HEAP_EXECUTE=1,
1974                 _HAVE_ALLOW_HEAP_EXECUTE=)
1975     if test -n "$_HAVE_ALLOW_HEAP_EXECUTE" ; then
1976         AC_MSG_RESULT([yes])
1977         MOZ_ALLOW_HEAP_EXECUTE_FLAGS="-Wl,-allow_heap_execute"
1978     else
1979         AC_MSG_RESULT([no])
1980     fi
1981     LDFLAGS=$_SAVE_LDFLAGS
1983     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
1984     ;;
1986 ia64*-hpux*)
1987     DLL_SUFFIX=".so"
1988     if test ! "$GNU_CC"; then
1989        DSO_LDOPTS='-b'
1990        DSO_CFLAGS=""
1991        DSO_PIC_CFLAGS=
1992        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
1993        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
1994        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
1995     else
1996        DSO_LDOPTS='-b -E'
1997        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1998        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1999     fi
2000     MOZ_FIX_LINK_PATHS=
2001     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2002     AC_DEFINE(_LARGEFILE64_SOURCE)
2003     ;;
2005 *-hpux*)
2006     DLL_SUFFIX=".sl"
2007     if test ! "$GNU_CC"; then
2008         DSO_LDOPTS='-b -Wl,+s'
2009         DSO_CFLAGS=""
2010         DSO_PIC_CFLAGS="+Z"
2011         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
2012         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
2013         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2014     else
2015         DSO_LDOPTS='-b -E +s'
2016         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2017         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2018     fi
2019     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
2020     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2021     ;;
2023 *-android*|*-linuxandroid*)
2024     AC_DEFINE(NO_PW_GECOS)
2025     no_x=yes
2026     if test -n "$gonkdir"; then
2027         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
2028         MOZ_B2G_RIL=1
2029         MOZ_B2G_BT=1
2030         MOZ_B2G_FM=1
2031     else
2032         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
2033         MOZ_LINKER=1
2034     fi
2035     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2037     MOZ_GFX_OPTIMIZE_MOBILE=1
2038     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
2039     ;;
2041 *-*linux*)
2042     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2043     # Similarly for GNU_CXX and INTEL_CXX.
2044     if test "$INTEL_CC" -o "$INTEL_CXX"; then
2045         # -Os has been broken on Intel's C/C++ compilers for quite a
2046         # while; Intel recommends against using it.
2047         MOZ_OPTIMIZE_FLAGS="-O2"
2048         MOZ_DEBUG_FLAGS="-g"
2049     elif test "$GNU_CC" -o "$GNU_CXX"; then
2050         case $GCC_VERSION in
2051         4.5.*)
2052             # -Os is broken on gcc 4.5.x we need to tweak it to get good results.
2053             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
2054         esac
2055         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
2056         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
2057         MOZ_DEBUG_FLAGS="-g"
2058     fi
2060     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2062     MOZ_MEMORY=1
2064     case "${target_cpu}" in
2065     alpha*)
2066         CFLAGS="$CFLAGS -mieee"
2067         CXXFLAGS="$CXXFLAGS -mieee"
2068     ;;
2069     i*86)
2070         USE_ELF_DYNSTR_GC=1
2071     ;;
2072     mips*)
2073         MOZ_DEBUG_FLAGS="-g" # We want inlining
2074     ;;
2075     esac
2077     if test -z "$MC"; then
2078         MC=mc.exe
2079     fi
2080     ;;
2081 *-mingw*)
2082     DSO_CFLAGS=
2083     DSO_PIC_CFLAGS=
2084     DLL_SUFFIX=.dll
2085     RC=rc.exe
2086     MC=mc.exe
2087     # certain versions of cygwin's makedepend barf on the
2088     # #include <string> vs -I./dist/include/string issue so don't use it
2089     if test -n "$GNU_CC"; then
2090         CC="$CC -mwindows"
2091         CXX="$CXX -mwindows"
2092         CPP="$CPP -mwindows"
2093         CFLAGS="$CFLAGS -mms-bitfields"
2094         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2095         DSO_LDOPTS='-shared'
2096         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2097         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2098         RC='$(WINDRES)'
2099         # Use static libgcc and libstdc++
2100         LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
2101         # Use temp file for windres (bug 213281)
2102         RCFLAGS='-O coff --use-temp-file'
2103         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2104         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32 -lnetapi32"
2105         MOZ_FIX_LINK_PATHS=
2106         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
2107         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
2108         DLL_PREFIX=
2109         IMPORT_LIB_SUFFIX=dll.a
2111         # We use mix of both POSIX and Win32 printf format across the tree, so format
2112         # warnings are useless on mingw.
2113         MOZ_C_SUPPORTS_WARNING(-Wno-, format, ac_c_has_wno_format)
2114         MOZ_CXX_SUPPORTS_WARNING(-Wno-, format, ac_cxx_has_wno_format)
2115     else
2116         TARGET_COMPILER_ABI=msvc
2117         HOST_CC='$(CC)'
2118         HOST_CXX='$(CXX)'
2119         HOST_LD='$(LD)'
2120         if test "$AS_BIN"; then
2121             AS="$(basename "$AS_BIN")"
2122         fi
2123         AR='lib'
2124         AR_FLAGS='-NOLOGO -OUT:"$@"'
2125         AR_EXTRACT=
2126         RANLIB='echo not_ranlib'
2127         STRIP='echo not_strip'
2128         PKG_SKIP_STRIP=1
2129         XARGS=xargs
2130         ZIP=zip
2131         UNZIP=unzip
2132         DOXYGEN=:
2133         ASM_SUFFIX=asm
2134         OBJ_SUFFIX=obj
2135         LIB_SUFFIX=lib
2136         DLL_PREFIX=
2137         LIB_PREFIX=
2138         IMPORT_LIB_SUFFIX=lib
2139         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2140         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2141         MKSHLIB_FORCE_ALL=
2142         MKSHLIB_UNFORCE_ALL=
2143         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2144         _USE_CPP_INCLUDE_FLAG=1
2145         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2146         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2147         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2148         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2149         # MSVC warning C4345 warns of newly conformant behavior as of VS2003.
2150         # MSVC warning C4351 warns of newly conformant behavior as of VS2005.
2151         # MSVC warning C4482 warns when an enum value is refered specifing the
2152         # name of the enum itself.  This behavior is allowed in C++11, and the
2153         # warning has been removed in VS2012.
2154         # MSVC warning C4800 warns when a value is implicitly cast to bool,
2155         # because this also forces narrowing to a single byte, which can be a
2156         # perf hit.  But this matters so little in practice (and often we want
2157         # that behavior) that it's better to turn it off.
2158         # MSVC warning C4819 warns some UTF-8 characters (e.g. copyright sign)
2159         # on non-Western system locales even if it is in a comment.
2160         # khuey says we can safely ignore MSVC warning C4251
2161         CFLAGS="$CFLAGS -wd4819"
2162         CXXFLAGS="$CXXFLAGS -wd4251 -wd4345 -wd4351 -wd4482 -wd4800 -wd4819"
2163         # make 'foo == bar;' error out
2164         CFLAGS="$CFLAGS -we4553"
2165         CXXFLAGS="$CXXFLAGS -we4553"
2166         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib netapi32.lib"
2167         MOZ_DEBUG_FLAGS='-Zi'
2168         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2169         WARNINGS_AS_ERRORS='-WX'
2170         MOZ_OPTIMIZE_FLAGS='-O1'
2171         MOZ_FIX_LINK_PATHS=
2172         DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2173         XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2174         LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2175         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2176         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2177         dnl For profile-guided optimization
2178         PROFILE_GEN_CFLAGS="-GL"
2179         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2180         dnl XXX: PGO builds can fail with warnings treated as errors,
2181         dnl specifically "no profile data available" appears to be
2182         dnl treated as an error sometimes. This might be a consequence
2183         dnl of using WARNINGS_AS_ERRORS in some modules, combined
2184         dnl with the linker doing most of the work in the whole-program
2185         dnl optimization/PGO case. I think it's probably a compiler bug,
2186         dnl but we work around it here.
2187         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2188         dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2189         dnl Probably also a compiler bug, but what can you do?
2190         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2191         LDFLAGS="$LDFLAGS -DYNAMICBASE"
2192         if test "$_MSC_VER" -ge 1500; then
2193             dnl VS2008 or later supports SSSE3
2194             HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
2195             AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
2196         fi
2197     fi
2198     AC_DEFINE(HAVE_SNPRINTF)
2199     AC_DEFINE(_WINDOWS)
2200     AC_DEFINE(WIN32)
2201     AC_DEFINE(XP_WIN)
2202     AC_DEFINE(XP_WIN32)
2203     AC_DEFINE(HW_THREADS)
2204     AC_DEFINE(STDC_HEADERS)
2205     AC_DEFINE(NEW_H, <new>)
2206     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2207     TARGET_MD_ARCH=win32
2208     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2209     BIN_SUFFIX='.exe'
2210     MOZ_USER_DIR="Mozilla"
2212     dnl Hardcode to win95 for now - cls
2213     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2215     dnl set NO_X11 defines here as the general check is skipped on win32
2216     no_x=yes
2217     AC_DEFINE(NO_X11)
2219     case "$host" in
2220     *-mingw*)
2221         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2222         L10NBASEDIR=`cd $L10NBASEDIR && pwd -W`
2223         ;;
2224     esac
2226     case "$host" in
2227     *-mingw*)
2228         if test -z "$MOZ_TOOLS"; then
2229             AC_MSG_ERROR([MOZ_TOOLS is not set])
2230         fi
2231         MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2232         if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2233             AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2234         fi
2235         MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2236         if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2237             AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2238         fi
2239         ;;
2240     esac
2242     case "$host_os" in
2243     cygwin*|msvc*|mks*)
2244         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.])
2245         ;;
2246     esac
2248     case "$target" in
2249     i*86-*)
2250         if test "$HAVE_64BIT_OS"; then
2251             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2252         fi
2254         if test -n "$GNU_CC"; then
2255             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
2256             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
2257             LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup"
2258         else
2259             AC_DEFINE(HAVE_STDCALL)
2260             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
2261             LDFLAGS="$LDFLAGS -SAFESEH"
2262         fi
2264         AC_DEFINE(_X86_)
2265         ;;
2266     x86_64-*)
2267         if test -n "$_WIN32_MSVC"; then
2268             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
2269         fi
2270         AC_DEFINE(_AMD64_)
2271         ;;
2272     *)
2273         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2274         ;;
2275     esac
2277     if test "$HAVE_64BIT_OS"; then
2278         AC_DEFINE(_WIN64)
2279     fi
2280     ;;
2282 *-netbsd*)
2283     DSO_CFLAGS=''
2284     CFLAGS="$CFLAGS -Dunix"
2285     CXXFLAGS="$CXXFLAGS -Dunix"
2286     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2287         DLL_SUFFIX=".so"
2288         DSO_PIC_CFLAGS='-fPIC -DPIC'
2289         DSO_LDOPTS='-shared'
2290         BIN_FLAGS='-Wl,--export-dynamic'
2291     else
2292         DSO_PIC_CFLAGS='-fPIC -DPIC'
2293         DLL_SUFFIX=".so.1.0"
2294         DSO_LDOPTS='-shared'
2295     fi
2296     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2297     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2298     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2299     if test "$LIBRUNPATH"; then
2300         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2301     fi
2302     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2303     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2304     ;;
2306 *-openbsd*)
2307     if test "$SO_VERSION"; then
2308         DLL_SUFFIX=".so.$SO_VERSION"
2309     else
2310         DLL_SUFFIX=".so.1.0"
2311     fi
2312     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
2313     DSO_CFLAGS=''
2314     DSO_PIC_CFLAGS='-fPIC'
2315     DSO_LDOPTS='-shared -fPIC'
2316     if test "$LIBRUNPATH"; then
2317         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2318     fi
2319     ;;
2321 *-os2*)
2322     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2323     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2324     AC_DEFINE(OS2)
2325     AC_DEFINE(XP_OS2)
2326     AC_DEFINE(OS2EMX_PLAIN_CHAR)
2327     AC_DEFINE(TCPV40HDRS)
2328     DLL_PREFIX=
2329     LIB_PREFIX=
2330     LIB_SUFFIX=lib
2331     BIN_SUFFIX=".exe"
2332     DLL_SUFFIX=".dll"
2333     IMPORT_LIB_SUFFIX=lib
2334     DSO_PIC_CFLAGS=
2335     AR=emxomfar
2336     AR_FLAGS='r $@'
2337     CFLAGS="$CFLAGS -Zomf"
2338     CXXFLAGS="$CXXFLAGS -Zomf"
2339     DSO_LDOPTS='-Zdll'
2340     BIN_FLAGS='-Zlinker /ST:0x100000'
2341     IMPLIB='emximp -o'
2342     FILTER='true'
2343     LDFLAGS='-Zmap'
2344     WARNINGS_AS_ERRORS='-Werror'
2345     MOZ_DEBUG_FLAGS="-g -fno-inline"
2346     MOZ_OPTIMIZE_FLAGS="-O2"
2347     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2348     DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2349     LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2350     TARGET_MD_ARCH=os2
2351     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
2352     RC=rc.exe
2353     MC=mc.exe
2354     RCFLAGS='-n'
2355     MOZ_USER_DIR="Mozilla"
2356     ZIP="$ZIP -X"
2357     STRIP=lxlite
2358     STRIP_FLAGS="/yua /ydd /yxd /ynl /anp /b- /cs+ /d /i- /ml1 /mr2 /mf2 /r+ /u+ /x- /zs:0 /zx /zd"
2360     if test "$MOZTOOLS"; then
2361         MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
2362     else
2363         AC_MSG_ERROR([MOZTOOLS is not set])
2364     fi
2365     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2366         DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2367         LDFLAGS="$LDFLAGS -Zhigh-mem"
2368         MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
2369         AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2370     fi
2372     # GCC for OS/2 currently predefines these, but we don't want them
2373     _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
2374     _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
2376     AC_CACHE_CHECK(for __declspec(dllexport),
2377         ac_os2_declspec,
2378         [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
2379                         [return 0;],
2380                         ac_os2_declspec="yes",
2381                         ac_os2_declspec="no")])
2382     if test "$ac_os2_declspec" != "yes"; then
2383         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
2384     fi
2385     ;;
2387 *-solaris*)
2388     AC_DEFINE(SOLARIS)
2389     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2390     MOZ_FIX_LINK_PATHS=
2391     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2392     # libraries one level up (e.g. libnspr4.so)
2393     if test "$SOLARIS_SUNPRO_CC"; then
2394        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2395        LIBS="-lCrun -lCstd -lc $LIBS"
2396        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2397        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2398        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2399        LDFLAGS="-xildoff $LDFLAGS"
2400        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2401            _SAVE_LDFLAGS=$LDFLAGS
2402            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
2403            AC_TRY_LINK([#include <stdio.h>],
2404                        [printf("Hello World\n");],
2405                        ,
2406                        [LDFLAGS=$_SAVE_LDFLAGS])
2407        fi
2408        MOZ_OPTIMIZE_FLAGS="-xO4"
2409        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2410        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2411        MKSHLIB_FORCE_ALL='-z allextract'
2412        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2413        DSO_LDOPTS='-G'
2414        AR_LIST="$AR t"
2415        AR_EXTRACT="$AR x"
2416        AR_DELETE="$AR d"
2417        AR='$(CXX) -xar'
2418        AR_FLAGS='-o $@'
2419        AS='/usr/ccs/bin/as'
2420        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2421        AS_DASH_C_FLAG=''
2422        TARGET_COMPILER_ABI="sunc"
2423        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2424        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2425        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2426        AC_LANG_SAVE
2427        AC_LANG_CPLUSPLUS
2428        AC_TRY_COMPILE([],
2429            [#if (__SUNPRO_CC < 0x590)
2430            #error "Denied"
2431            #endif],
2432            _BAD_COMPILER=,_BAD_COMPILER=1)
2433        if test -n "$_BAD_COMPILER"; then
2434            _res="no"
2435            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2436        else
2437            _res="yes"
2438        fi
2439        AC_TRY_COMPILE([],
2440            [#if (__SUNPRO_CC >= 0x5100)
2441            #error "Sun C++ 5.10 or above"
2442            #endif],
2443            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2444        if test "$_ABOVE_SS12U1"; then
2445            # disable xannotate
2446            CXXFLAGS="$CXXFLAGS -xannotate=no"
2447        fi
2448        AC_MSG_RESULT([$_res])
2449        AC_LANG_RESTORE
2450     else
2451        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2452        LIBS="-lc $LIBS"
2453        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2454        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2455        ASFLAGS="$ASFLAGS -fPIC"
2456        DSO_LDOPTS='-shared'
2457        WARNINGS_AS_ERRORS='-Werror'
2458        _WARNINGS_CFLAGS=''
2459        _WARNINGS_CXXFLAGS=''
2460        if test "$OS_RELEASE" = "5.3"; then
2461            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2462        fi
2463     fi
2464     if test "$OS_RELEASE" = "5.5.1"; then
2465         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2466     fi
2467     ;;
2469 *-sunos*)
2470     DSO_LDOPTS='-Bdynamic'
2471     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2472     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2473     AC_DEFINE(SUNOS4)
2474     AC_DEFINE(SPRINTF_RETURNS_STRING)
2475     case "$(target_os)" in
2476     sunos4.1*)
2477         DLL_SUFFIX='.so.1.0'
2478         ;;
2479     esac
2480     ;;
2482 *-os2*)
2483     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2484     ;;
2486 esac
2488 AC_SUBST(MOZ_LINKER)
2489 if test -n "$MOZ_LINKER"; then
2490   AC_DEFINE(MOZ_LINKER)
2492 AC_SUBST(MOZ_ENABLE_SZIP)
2494 dnl Only one oddball right now (QNX), but this gives us flexibility
2495 dnl if any other platforms need to override this in the future.
2496 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2498 dnl ========================================================
2499 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2500 dnl by now will not have any way to link most binaries (tests
2501 dnl as well as viewer, apprunner, etc.), because some symbols
2502 dnl will be left out of the "composite" .so's by ld as unneeded.
2503 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2504 dnl they can link in the static libs that provide the missing
2505 dnl symbols.
2506 dnl ========================================================
2507 NO_LD_ARCHIVE_FLAGS=
2508 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2509     NO_LD_ARCHIVE_FLAGS=1
2511 case "$target" in
2512 *-os2*)
2513     NO_LD_ARCHIVE_FLAGS=
2514     ;;
2515 *-aix4.3*|*-aix5*)
2516     NO_LD_ARCHIVE_FLAGS=
2517     ;;
2518 *-mingw*)
2519     if test -z "$GNU_CC"; then
2520         NO_LD_ARCHIVE_FLAGS=
2521     fi
2522     ;;
2523 esac
2524 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2526 dnl ========================================================
2527 dnl = Flags to strip unused symbols from .so components and
2528 dnl = to export jemalloc symbols when linking a program
2529 dnl ========================================================
2530 case "$target" in
2531     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2532         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2533         ;;
2534     *-solaris*)
2535         if test -z "$GNU_CC"; then
2536          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2537         else
2538          if test -z "$GCC_USE_GNU_LD"; then
2539           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2540          else
2541           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2542          fi
2543         fi
2544         ;;
2545     *-darwin*)
2546         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2547         ;;
2548     *-mingw*)
2549         if test -n "$GNU_CC"; then
2550            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2551         fi
2552         ;;
2553 esac
2555 if test -z "$COMPILE_ENVIRONMENT"; then
2556     SKIP_COMPILER_CHECKS=1
2557     SKIP_LIBRARY_CHECKS=1
2560 MOZ_COMPILER_OPTS
2561 if test -z "$SKIP_COMPILER_CHECKS"; then
2562 dnl Checks for typedefs, structures, and compiler characteristics.
2563 dnl ========================================================
2564 AC_HEADER_STDC
2565 AC_C_CONST
2566 AC_TYPE_MODE_T
2567 AC_TYPE_OFF_T
2568 AC_TYPE_PID_T
2569 AC_TYPE_SIZE_T
2570 AC_LANG_CPLUSPLUS
2571 AC_MSG_CHECKING(for __stdcall)
2572 AC_CACHE_VAL(ac_cv___stdcall,
2573  [AC_TRY_COMPILE([template <typename Method> struct foo;
2574                   template <> struct foo<void (*)()> {};
2575                   template <> struct foo<void (__stdcall*)()> {};],
2576                  [],
2577                  [ac_cv___stdcall=true],
2578                  [ac_cv___stdcall=false])])
2579 if test "$ac_cv___stdcall" = true ; then
2580   AC_DEFINE(HAVE_STDCALL)
2581   AC_MSG_RESULT(yes)
2582 else
2583   AC_MSG_RESULT(no)
2585 AC_LANG_C
2586 AC_MSG_CHECKING(for ssize_t)
2587 AC_CACHE_VAL(ac_cv_type_ssize_t,
2588  [AC_TRY_COMPILE([#include <stdio.h>
2589                   #include <sys/types.h>],
2590                  [ssize_t foo = 0;],
2591                  [ac_cv_type_ssize_t=true],
2592                  [ac_cv_type_ssize_t=false])])
2593 if test "$ac_cv_type_ssize_t" = true ; then
2594   AC_DEFINE(HAVE_SSIZE_T)
2595   AC_MSG_RESULT(yes)
2596 else
2597   AC_MSG_RESULT(no)
2599 AC_STRUCT_ST_BLKSIZE
2600 AC_MSG_CHECKING(for siginfo_t)
2601 AC_CACHE_VAL(ac_cv_siginfo_t,
2602  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
2603                   #include <signal.h>],
2604                  [siginfo_t* info;],
2605                  [ac_cv_siginfo_t=true],
2606                  [ac_cv_siginfo_t=false])])
2607 if test "$ac_cv_siginfo_t" = true ; then
2608   AC_DEFINE(HAVE_SIGINFO_T)
2609   AC_MSG_RESULT(yes)
2610 else
2611   AC_MSG_RESULT(no)
2614 dnl Check for int64, uint, and uint_t.
2615 dnl ========================================================
2616 AC_MSG_CHECKING(for int64)
2617 AC_CACHE_VAL(ac_cv_int64,
2618  [AC_TRY_COMPILE([#include <stdio.h>
2619                   #include <sys/types.h>],
2620                  [int64 foo = 0;],
2621                  [ac_cv_int64=true],
2622                  [ac_cv_int64=false])])
2623 if test "$ac_cv_int64" = true ; then
2624   AC_DEFINE(HAVE_INT64)
2625   AC_MSG_RESULT(yes)
2626 else
2627   AC_MSG_RESULT(no)
2629 AC_MSG_CHECKING(for uint)
2630 AC_CACHE_VAL(ac_cv_uint,
2631  [AC_TRY_COMPILE([#include <stdio.h>
2632                   #include <sys/types.h>],
2633                  [uint foo = 0;],
2634                  [ac_cv_uint=true],
2635                  [ac_cv_uint=false])])
2636 if test "$ac_cv_uint" = true ; then
2637   AC_DEFINE(HAVE_UINT)
2638   AC_MSG_RESULT(yes)
2639 else
2640   AC_MSG_RESULT(no)
2642 AC_MSG_CHECKING(for uint_t)
2643 AC_CACHE_VAL(ac_cv_uint_t,
2644  [AC_TRY_COMPILE([#include <stdio.h>
2645                   #include <sys/types.h>],
2646                  [uint_t foo = 0;],
2647                  [ac_cv_uint_t=true],
2648                  [ac_cv_uint_t=false])])
2649 if test "$ac_cv_uint_t" = true ; then
2650   AC_DEFINE(HAVE_UINT_T)
2651   AC_MSG_RESULT(yes)
2652 else
2653   AC_MSG_RESULT(no)
2656 dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
2657 dnl are defined when compiling C++ but not C.  Since the result of this
2658 dnl test is used only in C++, do it in C++.
2659 AC_LANG_CPLUSPLUS
2661 AC_MSG_CHECKING(for uname.domainname)
2662 AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
2663     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2664         [ struct utsname *res; char *domain;
2665             (void)uname(res);  if (res != 0) { domain = res->domainname; } ],
2666         [ac_cv_have_uname_domainname_field=true],
2667         [ac_cv_have_uname_domainname_field=false])])
2669 if test "$ac_cv_have_uname_domainname_field" = "true"; then
2670     AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
2671     AC_MSG_RESULT(yes)
2672 else
2673     AC_MSG_RESULT(no)
2676 AC_MSG_CHECKING(for uname.__domainname)
2677 AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
2678     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2679         [ struct utsname *res; char *domain;
2680             (void)uname(res);  if (res != 0) { domain = res->__domainname; } ],
2681         [ac_cv_have_uname_us_domainname_field=true],
2682         [ac_cv_have_uname_us_domainname_field=false])])
2684 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
2685     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
2686     AC_MSG_RESULT(yes)
2687 else
2688     AC_MSG_RESULT(no)
2691 dnl Check whether we can use gcc's c++0x mode
2692 AC_LANG_CPLUSPLUS
2694 if test "$GNU_CXX"; then
2695     _SAVE_CXXFLAGS=$CXXFLAGS
2696     CXXFLAGS="$CXXFLAGS -std=gnu++0x"
2698     AC_CACHE_CHECK(for gcc c++0x headers bug without rtti,
2699         ac_cv_cxx0x_headers_bug,
2700         [AC_TRY_COMPILE([#include <memory>], [],
2701                         ac_cv_cxx0x_headers_bug="no",
2702                         ac_cv_cxx0x_headers_bug="yes")])
2703     CXXFLAGS="$_SAVE_CXXFLAGS"
2704     if test "$ac_cv_cxx0x_headers_bug" = "no"; then
2705         CXXFLAGS="$CXXFLAGS -std=gnu++0x"
2706     fi
2709 dnl Check for usable char16_t (2 bytes, unsigned)
2710 dnl (we might not need the unsignedness check anymore)
2711 AC_CACHE_CHECK(for usable char16_t (2 bytes, unsigned),
2712     ac_cv_have_usable_char16_t,
2713     [AC_TRY_COMPILE([$configure_static_assert_macros],
2714                     [CONFIGURE_STATIC_ASSERT(sizeof(char16_t) == 2);
2715                      CONFIGURE_STATIC_ASSERT(char16_t(-1) > char16_t(0));
2716                      CONFIGURE_STATIC_ASSERT(sizeof((u"hello")[0]) == 2);
2717                      CONFIGURE_STATIC_ASSERT(sizeof(u'a') == 2);
2718                      CONFIGURE_STATIC_ASSERT(u'\xFFFF' > u'\x0')],
2719                     ac_cv_have_usable_char16_t="yes",
2720                     ac_cv_have_usable_char16_t="no")])
2721 if test "$ac_cv_have_usable_char16_t" = "yes"; then
2722     AC_DEFINE(HAVE_CPP_CHAR16_T)
2723     HAVE_CPP_CHAR16_T=1
2724 elif test "$GNU_CXX"; then
2725     CXXFLAGS="$_SAVE_CXXFLAGS"
2728 dnl Check for usable wchar_t (2 bytes, unsigned)
2729 dnl (we really don't need the unsignedness check anymore)
2730 dnl ========================================================
2732 AC_CACHE_CHECK(for usable wchar_t (2 bytes, unsigned),
2733     ac_cv_have_usable_wchar_v2,
2734     [AC_TRY_COMPILE([#include <stddef.h>
2735                      $configure_static_assert_macros],
2736                     [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
2737                      CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
2738                     ac_cv_have_usable_wchar_v2="yes",
2739                     ac_cv_have_usable_wchar_v2="no")])
2740 if test "$ac_cv_have_usable_wchar_v2" = "yes"; then
2741     AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
2742     HAVE_CPP_2BYTE_WCHAR_T=1
2743 elif test "$ac_cv_have_usable_char16_t" != "yes"; then
2744 dnl This is really gcc-only
2745 dnl Do this test using CXX only since some versions of gcc
2746 dnl 2.95-2.97 have a signed wchar_t in c++ only and some versions
2747 dnl only have short-wchar support for c++.
2748 dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
2750     _SAVE_CXXFLAGS=$CXXFLAGS
2751     CXXFLAGS="$CXXFLAGS -fshort-wchar"
2753     AC_CACHE_CHECK(for compiler -fshort-wchar option,
2754         ac_cv_have_usable_wchar_option_v2,
2755         [AC_TRY_LINK([#include <stddef.h>
2756                       $configure_static_assert_macros],
2757                      [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
2758                       CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
2759                      ac_cv_have_usable_wchar_option_v2="yes",
2760                      ac_cv_have_usable_wchar_option_v2="no")])
2762     if test "$ac_cv_have_usable_wchar_option_v2" = "yes"; then
2763         AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
2764         HAVE_CPP_2BYTE_WCHAR_T=1
2765         if test "$OS_TARGET" = Android; then
2766             WCHAR_CFLAGS="-fshort-wchar -Wl,--no-wchar-size-warning"
2767             CXXFLAGS="$CXXFLAGS -Wl,--no-wchar-size-warning"
2768             CFLAGS="$CFLAGS -Wl,--no-wchar-size-warning"
2769             DSO_LDOPTS="$DSO_LDOPTS -Wl,--no-wchar-size-warning"
2770         else
2771             WCHAR_CFLAGS="-fshort-wchar"
2772         fi
2773     else
2774         CXXFLAGS=$_SAVE_CXXFLAGS
2775     fi
2778 AC_LANG_C
2780 dnl Check for .hidden assembler directive and visibility attribute.
2781 dnl Borrowed from glibc configure.in
2782 dnl ===============================================================
2783 if test "$GNU_CC"; then
2784   AC_CACHE_CHECK(for visibility(hidden) attribute,
2785                  ac_cv_visibility_hidden,
2786                  [cat > conftest.c <<EOF
2787                   int foo __attribute__ ((visibility ("hidden"))) = 1;
2789                   ac_cv_visibility_hidden=no
2790                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2791                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2792                       ac_cv_visibility_hidden=yes
2793                     fi
2794                   fi
2795                   rm -f conftest.[cs]
2796                  ])
2797   if test "$ac_cv_visibility_hidden" = "yes"; then
2798     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
2800     AC_CACHE_CHECK(for visibility(default) attribute,
2801                    ac_cv_visibility_default,
2802                    [cat > conftest.c <<EOF
2803                     int foo __attribute__ ((visibility ("default"))) = 1;
2805                     ac_cv_visibility_default=no
2806                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2807                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2808                         ac_cv_visibility_default=yes
2809                       fi
2810                     fi
2811                     rm -f conftest.[cs]
2812                    ])
2813     if test "$ac_cv_visibility_default" = "yes"; then
2814       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
2816       AC_CACHE_CHECK(for visibility pragma support,
2817                      ac_cv_visibility_pragma,
2818                      [cat > conftest.c <<EOF
2819 #pragma GCC visibility push(hidden)
2820                       int foo_hidden = 1;
2821 #pragma GCC visibility push(default)
2822                       int foo_default = 1;
2824                       ac_cv_visibility_pragma=no
2825                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2826                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
2827                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
2828                             ac_cv_visibility_pragma=yes
2829                           fi
2830                         fi
2831                       fi
2832                       rm -f conftest.[cs]
2833                     ])
2834       if test "$ac_cv_visibility_pragma" = "yes"; then
2835         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
2836                        ac_cv_have_visibility_class_bug,
2837                        [cat > conftest.c <<EOF
2838 #pragma GCC visibility push(hidden)
2839 struct __attribute__ ((visibility ("default"))) TestStruct {
2840   static void Init();
2842 __attribute__ ((visibility ("default"))) void TestFunc() {
2843   TestStruct::Init();
2846                        ac_cv_have_visibility_class_bug=no
2847                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2848                          ac_cv_have_visibility_class_bug=yes
2849                        else
2850                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
2851                            ac_cv_have_visibility_class_bug=yes
2852                          fi
2853                        fi
2854                        rm -rf conftest.{c,S}
2855                        ])
2857         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
2858                        ac_cv_have_visibility_builtin_bug,
2859                        [cat > conftest.c <<EOF
2860 #pragma GCC visibility push(hidden)
2861 #pragma GCC visibility push(default)
2862 #include <string.h>
2863 #pragma GCC visibility pop
2865 __attribute__ ((visibility ("default"))) void Func() {
2866   char c[[100]];
2867   memset(c, 0, sizeof(c));
2870                        ac_cv_have_visibility_builtin_bug=no
2871                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2872                          ac_cv_have_visibility_builtin_bug=yes
2873                        else
2874                          if test `grep -c "@PLT" conftest.S` = 0; then
2875                            ac_cv_visibility_builtin_bug=yes
2876                          fi
2877                        fi
2878                        rm -f conftest.{c,S}
2879                        ])
2880         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
2881                 "$ac_cv_have_visibility_class_bug" = "no"; then
2882           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
2883           WRAP_SYSTEM_INCLUDES=1
2884           STL_FLAGS='-I$(DIST)/stl_wrappers'
2885           WRAP_STL_INCLUDES=1
2886         else
2887           VISIBILITY_FLAGS='-fvisibility=hidden'
2888         fi # have visibility pragma bug
2889       fi   # have visibility pragma
2890     fi     # have visibility(default) attribute
2891   fi       # have visibility(hidden) attribute
2892 fi         # GNU_CC
2894 # visibility hidden flag for Sun Studio on Solaris
2895 if test "$SOLARIS_SUNPRO_CC"; then
2896 VISIBILITY_FLAGS='-xldscope=hidden'
2897 fi         # Sun Studio on Solaris
2899 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2900 AC_SUBST(VISIBILITY_FLAGS)
2902 MOZ_GCC_PR49911
2903 MOZ_GCC_PR39608
2904 MOZ_LLVM_PR8927
2906 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
2907 dnl ========================================================
2908 if test "$GNU_CC"; then
2909   CFLAGS_save="${CFLAGS}"
2910   CFLAGS="${CFLAGS} -Werror"
2911   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
2912                  ac_cv_force_align_arg_pointer,
2913                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
2914                                  [],
2915                                  ac_cv_force_align_arg_pointer="yes",
2916                                  ac_cv_force_align_arg_pointer="no")])
2917   CFLAGS="${CFLAGS_save}"
2918   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
2919     HAVE_GCC_ALIGN_ARG_POINTER=1
2920   else
2921     HAVE_GCC_ALIGN_ARG_POINTER=
2922   fi
2924 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
2926 dnl Checks for header files.
2927 dnl ========================================================
2928 AC_HEADER_DIRENT
2929 case "$target_os" in
2930 freebsd*|openbsd*)
2931 # for stuff like -lXshm
2932     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
2933     ;;
2934 esac
2935 MOZ_CHECK_COMMON_HEADERS
2937 dnl These are all the places some variant of statfs can be hiding.
2938 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
2940 dnl Quota support
2941 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
2942 MOZ_CHECK_HEADERS([linux/quota.h],,,[#include <sys/socket.h>])
2944 dnl SCTP support - needs various network include headers
2945 MOZ_CHECK_HEADERS([linux/if_addr.h linux/rtnetlink.h],,,[#include <sys/socket.h>])
2947 MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
2949 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
2950 AC_CACHE_CHECK(for sockaddr_in.sin_len,
2951                    ac_cv_sockaddr_in_sin_len,
2952                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2953                                     #include <sys/types.h>
2954                                     #endif
2955                                     #include <netinet/in.h>
2956                                     struct sockaddr_in x;
2957                                     void *foo = (void*) &x.sin_len;],
2958                                    [],
2959                                    [ac_cv_sockaddr_in_sin_len=true],
2960                                    [ac_cv_sockaddr_in_sin_len=false])])
2961 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
2962   AC_DEFINE(HAVE_SIN_LEN)
2963 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
2964   AC_DEFINE(HAVE_SCONN_LEN)
2967 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
2968                ac_cv_sockaddr_in6_sin6_len,
2969                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2970                                 #include <sys/types.h>
2971                                 #endif
2972                                 #include <netinet/in.h>
2973                                 struct sockaddr_in6 x;
2974                                 void *foo = (void*) &x.sin6_len;],
2975                                [],
2976                                [ac_cv_sockaddr_in6_sin6_len=true],
2977                                [ac_cv_sockaddr_in6_sin6_len=false])])
2978 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
2979   AC_DEFINE(HAVE_SIN6_LEN)
2982 AC_CACHE_CHECK(for sockaddr.sa_len,
2983                ac_cv_sockaddr_sa_len,
2984                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2985                                 #include <sys/types.h>
2986                                 #endif
2987                                 #include <sys/socket.h>
2988                                 struct sockaddr x;
2989                                 void *foo = (void*) &x.sa_len;],
2990                                [],
2991                                [ac_cv_sockaddr_sa_len=true],
2992                                [ac_cv_sockaddr_sa_len=false])])
2993 if test "$ac_cv_sockaddr_sa_len" = true ; then
2994   AC_DEFINE(HAVE_SA_LEN)
2997 dnl Check whether the compiler supports the new-style C++ standard
2998 dnl library headers (i.e. <new>) or needs the old "new.h"
2999 AC_LANG_CPLUSPLUS
3000 NEW_H=new.h
3001 MOZ_CHECK_HEADER(new, [NEW_H=new])
3002 AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
3003 AC_LANG_C
3005 AC_ARG_ENABLE(dtrace,
3006               [  --enable-dtrace         build with dtrace support if available (default=no)],
3007               [enable_dtrace="yes"],)
3008 if test "x$enable_dtrace" = "xyes"; then
3009   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
3010   if test -n "$HAVE_DTRACE"; then
3011       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
3012   else
3013       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
3014   fi
3016 AC_SUBST(HAVE_DTRACE)
3018 case $target in
3019 *-aix4.3*|*-aix5*)
3020         ;;
3022         MOZ_CHECK_HEADERS(sys/cdefs.h)
3023         ;;
3024 esac
3026 MOZ_LINUX_PERF_EVENT
3028 dnl Checks for libraries.
3029 dnl ========================================================
3030 case $target in
3031 *-hpux11.*)
3032         ;;
3034         AC_CHECK_LIB(c_r, gethostbyname_r)
3035         ;;
3036 esac
3038 dnl We don't want to link with libdl even if it's present on OS X, since
3039 dnl it's not used and not part of the default installation. OS/2 has dlfcn
3040 dnl in libc.
3041 dnl We don't want to link against libm or libpthread on Darwin since
3042 dnl they both are just symlinks to libSystem and explicitly linking
3043 dnl against libSystem causes issues when debugging (see bug 299601).
3044 case $target in
3045 *-darwin*)
3046     ;;
3047 *-os2*)
3048     ;;
3050     AC_SEARCH_LIBS(dlopen, dl,
3051         MOZ_CHECK_HEADER(dlfcn.h,
3052         AC_DEFINE(HAVE_DLOPEN)))
3053     ;;
3054 esac
3056 _SAVE_CFLAGS="$CFLAGS"
3057 CFLAGS="$CFLAGS -D_GNU_SOURCE"
3058 AC_CHECK_FUNCS(dladdr memmem)
3059 CFLAGS="$_SAVE_CFLAGS"
3061 if test ! "$GNU_CXX"; then
3063     case $target in
3064     *-aix*)
3065         AC_CHECK_LIB(C_r, demangle)
3066         ;;
3067      *)
3068         AC_CHECK_LIB(C, demangle)
3069         ;;
3070      esac
3073 dnl OS/2 has socket in libc.
3074 case $target in
3075 *-os2*)
3076     ;;
3078     AC_CHECK_LIB(socket, socket)
3079 esac
3081 XLDFLAGS="$X_LIBS"
3082 XLIBS="$X_EXTRA_LIBS"
3084 dnl ========================================================
3085 dnl Checks for X libraries.
3086 dnl Ordering is important.
3087 dnl Xt is dependent upon SM as of X11R6
3088 dnl ========================================================
3089 if test "$no_x" = "yes"; then
3090     AC_DEFINE(NO_X11)
3091 else
3092     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
3093         XLIBS="-lX11 $XLIBS"
3094         _SAVE_LDFLAGS="$LDFLAGS"
3095         LDFLAGS="$XLDFLAGS $LDFLAGS"
3096         AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
3097                 [MISSING_X="$MISSING_X -lX11"], $XLIBS)
3098         AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
3099                 [MISSING_X="$MISSING_X -lXext"], $XLIBS)
3101         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
3102         unset ac_cv_lib_Xt_XtFree
3103             AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
3104             AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
3105         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
3106                     [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
3107         ])
3109     # AIX needs the motif library linked before libXt to prevent
3110     # crashes in plugins linked against Motif - Bug #98892
3111     case "${target_os}" in
3112     aix*)
3113         XT_LIBS="-lXm $XT_LIBS"
3114         ;;
3115     esac
3117     dnl ========================================================
3118     dnl = Check for XShm
3119     dnl ========================================================
3120     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
3121         $XLIBS $XEXT_LIBS)
3123     dnl ========================================================
3124     dnl = Check for Xss
3125     dnl ========================================================
3126     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
3127         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
3128             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
3129              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
3131         LDFLAGS="$_SAVE_LDFLAGS"
3132 fi # $no_x
3134 AC_SUBST(XCFLAGS)
3135 AC_SUBST(XLDFLAGS)
3136 AC_SUBST(XLIBS)
3137 AC_SUBST(XEXT_LIBS)
3138 AC_SUBST(XT_LIBS)
3139 AC_SUBST(XSS_LIBS)
3141 dnl ========================================================
3142 dnl = pthread support
3143 dnl = Start by checking whether the system support pthreads
3144 dnl ========================================================
3145 case "$target_os" in
3146 darwin*)
3147     USE_PTHREADS=1
3148     ;;
3150     MOZ_CHECK_PTHREADS(pthreads,
3151         USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
3152         MOZ_CHECK_PTHREADS(pthread,
3153             USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
3154             MOZ_CHECK_PTHREADS(c_r,
3155                 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
3156                 MOZ_CHECK_PTHREADS(c,
3157                     USE_PTHREADS=1
3158                 )
3159             )
3160         )
3161     )
3162     ;;
3163 esac
3165 dnl ========================================================
3166 dnl Check the command line for --with-pthreads
3167 dnl ========================================================
3168 MOZ_ARG_WITH_BOOL(pthreads,
3169 [  --with-pthreads         Force use of system pthread library with NSPR ],
3170 [ if test "$USE_PTHREADS"x = x; then
3171     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
3172 fi],
3173     USE_PTHREADS=
3174     _PTHREAD_LDFLAGS=
3177 dnl ========================================================
3178 dnl Do the platform specific pthread hackery
3179 dnl ========================================================
3180 if test "$USE_PTHREADS"x != x
3181 then
3182         dnl
3183         dnl See if -pthread is supported.
3184         dnl
3185         rm -f conftest*
3186         ac_cv_have_dash_pthread=no
3187         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
3188         echo 'int main() { return 0; }' | cat > conftest.c
3189         ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
3190         if test $? -eq 0; then
3191                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3192                         ac_cv_have_dash_pthread=yes
3193                 case "$target_os" in
3194                 freebsd*)
3195 # Freebsd doesn't use -pthread for compiles, it uses them for linking
3196                 ;;
3197                 *)
3198                             CFLAGS="$CFLAGS -pthread"
3199                             CXXFLAGS="$CXXFLAGS -pthread"
3200                 ;;
3201                 esac
3202                 fi
3203         fi
3204         rm -f conftest*
3205     AC_MSG_RESULT($ac_cv_have_dash_pthread)
3207         dnl
3208         dnl See if -pthreads is supported.
3209         dnl
3210     ac_cv_have_dash_pthreads=no
3211     if test "$ac_cv_have_dash_pthread" = "no"; then
3212             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
3213         echo 'int main() { return 0; }' | cat > conftest.c
3214             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
3215         if test $? -eq 0; then
3216                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3217                             ac_cv_have_dash_pthreads=yes
3218                             CFLAGS="$CFLAGS -pthreads"
3219                             CXXFLAGS="$CXXFLAGS -pthreads"
3220                     fi
3221             fi
3222             rm -f conftest*
3223         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
3224     fi
3226         case "$target" in
3227             *-*-freebsd*)
3228                         AC_DEFINE(_REENTRANT)
3229                         AC_DEFINE(_THREAD_SAFE)
3230                         dnl -pthread links in -lpthread, so don't specify it explicitly.
3231                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3232                                 _PTHREAD_LDFLAGS="-pthread"
3233                         fi
3234                         ;;
3236             *-*-openbsd*|*-*-bsdi*)
3237                         AC_DEFINE(_REENTRANT)
3238                         AC_DEFINE(_THREAD_SAFE)
3239                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3240                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3241                 _PTHREAD_LDFLAGS="-pthread"
3242                         fi
3243                         ;;
3245             *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3246                         AC_DEFINE(_REENTRANT)
3247                         ;;
3249             *-aix4.3*|*-aix5*)
3250                         AC_DEFINE(_REENTRANT)
3251                         ;;
3253             *-hpux11.*)
3254                         AC_DEFINE(_REENTRANT)
3255                         ;;
3257             *-*-solaris*)
3258                         AC_DEFINE(_REENTRANT)
3259                         if test "$SOLARIS_SUNPRO_CC"; then
3260                                 CFLAGS="$CFLAGS -mt"
3261                                 CXXFLAGS="$CXXFLAGS -mt"
3262                         fi
3263                         ;;
3264         esac
3265     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3269 dnl Checks for library functions.
3270 dnl ========================================================
3271 AC_PROG_GCC_TRADITIONAL
3272 AC_FUNC_MEMCMP
3273 AC_CHECK_FUNCS(random strerror lchown fchmod snprintf memmove rint stat64 lstat64 truncate64 setbuf isatty)
3274 AC_CHECK_FUNCS(statvfs64 statvfs statfs64 statfs)
3275 AC_CHECK_FUNCS(flockfile getpagesize)
3276 AC_CHECK_FUNCS(localtime_r strtok_r)
3278 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
3279 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
3280                ac_cv_clock_monotonic,
3281                [for libs in "" -lrt; do
3282                     _SAVE_LIBS="$LIBS"
3283                     LIBS="$LIBS $libs"
3284                     AC_TRY_LINK([#include <time.h>],
3285                                  [ struct timespec ts;
3286                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
3287                                  ac_cv_clock_monotonic=$libs
3288                                  LIBS="$_SAVE_LIBS"
3289                                  break,
3290                                  ac_cv_clock_monotonic=no)
3291                     LIBS="$_SAVE_LIBS"
3292                 done])
3293 if test "$ac_cv_clock_monotonic" != "no"; then
3294     HAVE_CLOCK_MONOTONIC=1
3295     REALTIME_LIBS=$ac_cv_clock_monotonic
3296     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3297     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3298     AC_SUBST(REALTIME_LIBS)
3301 dnl check for wcrtomb/mbrtowc
3302 dnl =======================================================================
3303 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3304 AC_LANG_SAVE
3305 AC_LANG_CPLUSPLUS
3306 AC_CACHE_CHECK(for wcrtomb,
3307     ac_cv_have_wcrtomb,
3308     [AC_TRY_LINK([#include <wchar.h>],
3309                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3310                  ac_cv_have_wcrtomb="yes",
3311                  ac_cv_have_wcrtomb="no")])
3312 if test "$ac_cv_have_wcrtomb" = "yes"; then
3313     AC_DEFINE(HAVE_WCRTOMB)
3315 AC_CACHE_CHECK(for mbrtowc,
3316     ac_cv_have_mbrtowc,
3317     [AC_TRY_LINK([#include <wchar.h>],
3318                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3319                  ac_cv_have_mbrtowc="yes",
3320                  ac_cv_have_mbrtowc="no")])
3321 if test "$ac_cv_have_mbrtowc" = "yes"; then
3322     AC_DEFINE(HAVE_MBRTOWC)
3324 AC_LANG_RESTORE
3327 AC_CACHE_CHECK(
3328     [for res_ninit()],
3329     ac_cv_func_res_ninit,
3330     [AC_TRY_LINK([
3331         #ifdef linux
3332         #define _BSD_SOURCE 1
3333         #endif
3334         #include <resolv.h>
3335         ],
3336         [int foo = res_ninit(&_res);],
3337         [ac_cv_func_res_ninit=yes],
3338         [ac_cv_func_res_ninit=no])
3339     ])
3341 if test "$ac_cv_func_res_ninit" = "yes"; then
3342     AC_DEFINE(HAVE_RES_NINIT)
3343 dnl must add the link line we do something as foolish as this... dougt
3344 dnl else
3345 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3346 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3349 AC_LANG_CPLUSPLUS
3350 AC_CACHE_CHECK(
3351     [for gnu_get_libc_version()],
3352     ac_cv_func_gnu_get_libc_version,
3353     [AC_TRY_LINK([
3354         #ifdef HAVE_GNU_LIBC_VERSION_H
3355         #include <gnu/libc-version.h>
3356         #endif
3357         ],
3358         [const char *glibc_version = gnu_get_libc_version();],
3359         [ac_cv_func_gnu_get_libc_version=yes],
3360         [ac_cv_func_gnu_get_libc_version=no]
3361         )]
3362     )
3364 if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
3365     AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
3368 case $target_os in
3369     darwin*|mingw*|os2*)
3370         ;;
3371     *)
3373 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3374     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3375         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3376 _SAVE_LIBS=$LIBS
3377 LIBS="$LIBS $_ICONV_LIBS"
3378 AC_CACHE_CHECK(
3379     [for iconv()],
3380     ac_cv_func_iconv,
3381     [AC_TRY_LINK([
3382         #include <stdlib.h>
3383         #include <iconv.h>
3384         ],
3385         [
3386             iconv_t h = iconv_open("", "");
3387             iconv(h, NULL, NULL, NULL, NULL);
3388             iconv_close(h);
3389         ],
3390         [ac_cv_func_iconv=yes],
3391         [ac_cv_func_iconv=no]
3392         )]
3393     )
3394 if test "$ac_cv_func_iconv" = "yes"; then
3395     AC_DEFINE(HAVE_ICONV)
3396     DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
3397     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3398     LIBICONV="$_ICONV_LIBS"
3399     AC_CACHE_CHECK(
3400         [for iconv() with const input],
3401         ac_cv_func_const_iconv,
3402         [AC_TRY_COMPILE([
3403             #include <stdlib.h>
3404             #include <iconv.h>
3405             ],
3406             [
3407                 const char *input = "testing";
3408                 iconv_t h = iconv_open("", "");
3409                 iconv(h, &input, NULL, NULL, NULL);
3410                 iconv_close(h);
3411             ],
3412             [ac_cv_func_const_iconv=yes],
3413             [ac_cv_func_const_iconv=no]
3414             )]
3415         )
3416     if test "$ac_cv_func_const_iconv" = "yes"; then
3417         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3418     fi
3420 LIBS=$_SAVE_LIBS
3422     ;;
3423 esac
3425 AM_LANGINFO_CODESET
3427 AC_LANG_C
3429 dnl **********************
3430 dnl *** va_copy checks ***
3431 dnl **********************
3432 dnl we currently check for all three va_copy possibilities, so we get
3433 dnl all results in config.log for bug reports.
3434 AC_MSG_CHECKING(for an implementation of va_copy())
3435 AC_CACHE_VAL(ac_cv_va_copy,[
3436     AC_TRY_RUN([
3437         #include <stdarg.h>
3438         void f (int i, ...) {
3439             va_list args1, args2;
3440             va_start (args1, i);
3441             va_copy (args2, args1);
3442             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3443                 exit (1);
3444             va_end (args1); va_end (args2);
3445         }
3446         int main() { f (0, 42); return 0; }],
3447         ac_cv_va_copy=yes,
3448         ac_cv_va_copy=no,
3449         ac_cv_va_copy=no
3450     )
3452 AC_MSG_RESULT($ac_cv_va_copy)
3453 AC_MSG_CHECKING(for an implementation of __va_copy())
3454 AC_CACHE_VAL(ac_cv___va_copy,[
3455     AC_TRY_RUN([
3456         #include <stdarg.h>
3457         void f (int i, ...) {
3458             va_list args1, args2;
3459             va_start (args1, i);
3460             __va_copy (args2, args1);
3461             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3462                 exit (1);
3463             va_end (args1); va_end (args2);
3464         }
3465         int main() { f (0, 42); return 0; }],
3466         ac_cv___va_copy=yes,
3467         ac_cv___va_copy=no,
3468         ac_cv___va_copy=no
3469     )
3471 AC_MSG_RESULT($ac_cv___va_copy)
3472 AC_MSG_CHECKING(whether va_lists can be copied by value)
3473 AC_CACHE_VAL(ac_cv_va_val_copy,[
3474     AC_TRY_RUN([
3475         #include <stdarg.h>
3476         void f (int i, ...) {
3477             va_list args1, args2;
3478             va_start (args1, i);
3479             args2 = args1;
3480             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3481                 exit (1);
3482             va_end (args1); va_end (args2);
3483         }
3484         int main() { f (0, 42); return 0; }],
3485         ac_cv_va_val_copy=yes,
3486         ac_cv_va_val_copy=no,
3487         ac_cv_va_val_copy=yes
3488     )
3490 if test "x$ac_cv_va_copy" = "xyes"; then
3491     AC_DEFINE(VA_COPY, va_copy)
3492     AC_DEFINE(HAVE_VA_COPY)
3493 elif test "x$ac_cv___va_copy" = "xyes"; then
3494     AC_DEFINE(VA_COPY, __va_copy)
3495     AC_DEFINE(HAVE_VA_COPY)
3498 if test "x$ac_cv_va_val_copy" = "xno"; then
3499    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3501 AC_MSG_RESULT($ac_cv_va_val_copy)
3503 dnl ===================================================================
3504 dnl ========================================================
3505 dnl Put your C++ language/feature checks below
3506 dnl ========================================================
3507 AC_LANG_CPLUSPLUS
3509 ARM_ABI_PREFIX=
3510 if test "$GNU_CC"; then
3511   if test "$CPU_ARCH" = "arm" ; then
3512     AC_CACHE_CHECK(for ARM EABI,
3513         ac_cv_gcc_arm_eabi,
3514         [AC_TRY_COMPILE([],
3515                         [
3516 #if defined(__ARM_EABI__)
3517   return 0;
3518 #else
3519 #error Not ARM EABI.
3520 #endif
3521                         ],
3522                         ac_cv_gcc_arm_eabi="yes",
3523                         ac_cv_gcc_arm_eabi="no")])
3524     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
3525         HAVE_ARM_EABI=1
3526         ARM_ABI_PREFIX=eabi-
3527     else
3528         ARM_ABI_PREFIX=oabi-
3529     fi
3530   fi
3532   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
3535 dnl Check for support of modern template specialization syntax
3536 dnl Test code and requirement from scc@netscape.com.
3537 dnl Autoconf cut-and-paste job by waterson@netscape.com
3538 AC_CACHE_CHECK(for modern C++ template specialization syntax support,
3539                ac_cv_cpp_modern_specialize_template_syntax,
3540                [AC_TRY_COMPILE(template <class T> struct X { int a; };
3541                                class Y {};
3542                                template <> struct X<Y> { double a; };,
3543                                X<int> int_x;
3544                                X<Y> y_x;,
3545                                ac_cv_cpp_modern_specialize_template_syntax=yes,
3546                                ac_cv_cpp_modern_specialize_template_syntax=no)])
3547 if test "$ac_cv_cpp_modern_specialize_template_syntax" = no ; then
3548   AC_MSG_ERROR([The C++ compiler does not support template specialization])
3551 dnl Some compilers support only full specialization, and some don't.
3552 AC_CACHE_CHECK(whether partial template specialization works,
3553                ac_cv_cpp_partial_specialization,
3554                [AC_TRY_COMPILE(template <class T> class Foo {};
3555                                template <class T> class Foo<T*> {};,
3556                                return 0;,
3557                                ac_cv_cpp_partial_specialization=yes,
3558                                ac_cv_cpp_partial_specialization=no)])
3559 if test "$ac_cv_cpp_partial_specialization" = yes ; then
3560   AC_DEFINE(HAVE_CPP_PARTIAL_SPECIALIZATION)
3563 dnl Check to see if we can resolve ambiguity with |using|.
3564 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
3565                ac_cv_cpp_ambiguity_resolving_using,
3566                [AC_TRY_COMPILE(class X {
3567                                  public: int go(const X&) {return 3;}
3568                                          int jo(const X&) {return 3;}
3569                                };
3570                                class Y : public X {
3571                                  public:  int go(int) {return 2;}
3572                                           int jo(int) {return 2;}
3573                                           using X::jo;
3574                                  private: using X::go;
3575                                };,
3576                                X x; Y y; y.jo(x);,
3577                                ac_cv_cpp_ambiguity_resolving_using=yes,
3578                                ac_cv_cpp_ambiguity_resolving_using=no)])
3579 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
3580    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
3583 dnl See if a dynamic_cast to void* gives the most derived object.
3584 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
3585                ac_cv_cpp_dynamic_cast_void_ptr,
3586                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
3587                             class Y { int j; public: virtual ~Y() { } };
3588                             class Z : public X, public Y { int k; };
3590                             int main() {
3591                                  Z mdo;
3592                                  X *subx = (X*)&mdo;
3593                                  Y *suby = (Y*)&mdo;
3594                                  return !((((void*)&mdo != (void*)subx) &&
3595                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
3596                                           (((void*)&mdo != (void*)suby) &&
3597                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
3598                             }],
3599                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
3600                            ac_cv_cpp_dynamic_cast_void_ptr=no,
3601                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
3602 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
3603    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
3607 dnl note that this one is reversed - if the test fails, then
3608 dnl we require implementations of unused virtual methods. Which
3609 dnl really blows because it means we'll have useless vtable
3610 dnl bloat.
3611 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
3612                ac_cv_cpp_unused_required,
3613                [AC_TRY_LINK(class X {private: virtual void never_called();};,
3614                                X x;,
3615                                ac_cv_cpp_unused_required=no,
3616                                ac_cv_cpp_unused_required=yes)])
3617 if test "$ac_cv_cpp_unused_required" = yes ; then
3618    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
3622 dnl Some compilers have trouble comparing a constant reference to a templatized
3623 dnl class to zero, and require an explicit operator==() to be defined that takes
3624 dnl an int. This test separates the strong from the weak.
3626 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
3627                ac_cv_trouble_comparing_to_zero,
3628                [AC_TRY_COMPILE([#include <algorithm>
3629                                 template <class T> class Foo {};
3630                                 class T2;
3631                                 template <class T> int operator==(const T2*, const T&) { return 0; }
3632                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
3633                                [Foo<int> f; return (0 != f);],
3634                                ac_cv_trouble_comparing_to_zero=no,
3635                                ac_cv_trouble_comparing_to_zero=yes)])
3636 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
3637   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
3640 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
3641 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
3642 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
3643 # linking XUL.
3644 _SAVE_LDFLAGS=$LDFLAGS
3645 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
3646 AC_CACHE_CHECK(for __thread keyword for TLS variables,
3647                ac_cv_thread_keyword,
3648                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
3649                             [return tlsIsMainThread;],
3650                             ac_cv_thread_keyword=yes,
3651                             ac_cv_thread_keyword=no)])
3652 LDFLAGS=$_SAVE_LDFLAGS
3653 # The custom dynamic linker doesn't support TLS variables
3654 MOZ_TLS=
3655 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
3656   # mips builds fail with TLS variables because of a binutils bug.
3657   # See bug 528687
3658   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
3659   case "${target}" in
3660     mips*-*)
3661       :
3662       ;;
3663     *-android*|*-linuxandroid*)
3664       :
3665       ;;
3666     *-openbsd*)
3667       :
3668       ;;
3669     *)
3670       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
3671       MOZ_TLS=1
3672       ;;
3673   esac
3676 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
3677 if test -n "$MOZ_LINKER"; then
3678   if test "$CPU_ARCH" = arm; then
3679     dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
3680     ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]]*\).*/\1/p'`
3681     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
3682     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
3683       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3684       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3685     fi
3686   fi
3689 dnl The custom linker doesn't support text relocations, but NDK >= r6b
3690 dnl creates some (http://code.google.com/p/android/issues/detail?id=23203)
3691 dnl We however want to avoid these text relocations, and this can be done
3692 dnl by making gcc not link crtbegin and crtend. In the broken NDKs, crtend
3693 dnl doesn't contain anything at all, beside placeholders for some sections,
3694 dnl and crtbegin only contains a finalizer function that calls
3695 dnl __cxa_finalize. The custom linker actually takes care of calling
3696 dnl __cxa_finalize when the library doesn't call it itself, which makes it
3697 dnl safe not to link crtbegin. Besides, previous versions of the NDK didn't
3698 dnl link crtbegin and crtend at all.
3699 if test -n "$MOZ_LINKER" -a "$OS_TARGET" = "Android"; then
3700   AC_CACHE_CHECK([whether the CRT objects have text relocations],
3701     ac_cv_crt_has_text_relocations,
3702     [echo 'int foo() { return 0; }' > conftest.cpp
3703      if AC_TRY_COMMAND(${CXX-g++} -o conftest${DLL_SUFFIX} $CXXFLAGS $DSO_LDOPTS $LDFLAGS conftest.cpp $LIBS 1>&5) &&
3704         test -s conftest${DLL_SUFFIX}; then
3705        if ${TOOLCHAIN_PREFIX}readelf -d conftest${DLL_SUFFIX} | grep TEXTREL > /dev/null; then
3706          ac_cv_crt_has_text_relocations=yes
3707        else
3708          ac_cv_crt_has_text_relocations=no
3709        fi
3710      else
3711        AC_ERROR([couldn't compile a simple C file])
3712      fi
3713      rm -rf conftest*])
3714   if test "$ac_cv_crt_has_text_relocations" = yes; then
3715     dnl While we want libraries to skip the CRT files, we don't want
3716     dnl executables to be treated the same way. We thus set the flag
3717     dnl in DSO_LDOPTS and not LDFLAGS. However, to pass it to nspr,
3718     dnl we need to use LDFLAGS because nspr doesn't inherit DSO_LDOPTS.
3719     dnl Using LDFLAGS in nspr is safe, since we only really build
3720     dnl libraries there.
3721     DSO_LDOPTS="$DSO_LDOPTS -nostartfiles"
3722     NSPR_LDFLAGS="$NSPR_LDFLAGS -nostartfiles"
3723   fi
3726 dnl Check for the existence of various allocation headers/functions
3728 MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h"
3729 MALLOC_H=
3731 for file in $MALLOC_HEADERS; do
3732   MOZ_CHECK_HEADER($file, [MALLOC_H=$file])
3733   if test "$MALLOC_H" != ""; then
3734     AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
3735     break
3736   fi
3737 done
3739 MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
3740 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
3742 AC_CHECK_FUNCS(malloc_usable_size)
3744 dnl See if compiler supports some gcc-style attributes
3746 AC_CACHE_CHECK(for __attribute__((always_inline)),
3747                ac_cv_attribute_always_inline,
3748                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
3749                                [],
3750                                ac_cv_attribute_always_inline=yes,
3751                                ac_cv_attribute_always_inline=no)])
3753 AC_CACHE_CHECK(for __attribute__((malloc)),
3754                ac_cv_attribute_malloc,
3755                [AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
3756                                [],
3757                                ac_cv_attribute_malloc=yes,
3758                                ac_cv_attribute_malloc=no)])
3760 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
3761                ac_cv_attribute_warn_unused,
3762                [AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
3763                                [],
3764                                ac_cv_attribute_warn_unused=yes,
3765                                ac_cv_attribute_warn_unused=no)])
3767 dnl End of C++ language/feature checks
3768 AC_LANG_C
3770 dnl ========================================================
3771 dnl =  Internationalization checks
3772 dnl ========================================================
3774 dnl Internationalization and Locale support is different
3775 dnl on various UNIX platforms.  Checks for specific i18n
3776 dnl features go here.
3778 dnl check for LC_MESSAGES
3779 AC_CACHE_CHECK(for LC_MESSAGES,
3780                 ac_cv_i18n_lc_messages,
3781                 [AC_TRY_COMPILE([#include <locale.h>],
3782                                 [int category = LC_MESSAGES;],
3783                                 ac_cv_i18n_lc_messages=yes,
3784                                 ac_cv_i18n_lc_messages=no)])
3785 if test "$ac_cv_i18n_lc_messages" = yes; then
3786    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
3789 AC_HAVE_FUNCS(localeconv)
3790 fi # ! SKIP_COMPILER_CHECKS
3792 TARGET_XPCOM_ABI=
3793 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
3794     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
3797 dnl Mozilla specific options
3798 dnl ========================================================
3799 dnl The macros used for command line options
3800 dnl are defined in build/autoconf/altoptions.m4.
3802 dnl If the compiler supports these attributes, define them as
3803 dnl convenience macros.
3804 if test "$ac_cv_attribute_malloc" = yes ; then
3805   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
3806 else
3807   AC_DEFINE(NS_ATTR_MALLOC,)
3810 if test "$ac_cv_attribute_warn_unused" = yes ; then
3811   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
3812 else
3813   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
3816 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
3817 dnl features that Windows actually does support.
3819 if test -n "$SKIP_COMPILER_CHECKS"; then
3820    dnl Windows has malloc.h
3821    AC_DEFINE(MALLOC_H, [<malloc.h>])
3822    AC_DEFINE(HAVE_FORCEINLINE)
3823    AC_DEFINE(HAVE_LOCALECONV)
3824 fi # SKIP_COMPILER_CHECKS
3826 dnl ========================================================
3827 dnl =
3828 dnl = Check for external package dependencies
3829 dnl =
3830 dnl ========================================================
3831 MOZ_ARG_HEADER(External Packages)
3833 MOZ_ARG_WITH_STRING(libxul-sdk,
3834 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
3835   LIBXUL_SDK_DIR=$withval)
3837 if test "$LIBXUL_SDK_DIR" = "yes"; then
3838     AC_MSG_ERROR([--with-libxul-sdk must specify a path])
3839 elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
3840     LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
3842     if test ! -f "$LIBXUL_SDK/include/xpcom-config.h"; then
3843         AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
3844     fi
3847 AC_SUBST(LIBXUL_SDK)
3849 if test -n "$LIBXUL_SDK"; then
3850     LIBXUL_DIST="$LIBXUL_SDK"
3851 else
3852     LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
3854 AC_SUBST(LIBXUL_DIST)
3856 SYSTEM_LIBXUL=
3858 MOZ_ARG_WITH_BOOL(system-libxul,
3859 [  --with-system-libxul    Use system installed libxul SDK],
3860     SYSTEM_LIBXUL=1)
3862 dnl ========================================================
3863 dnl = If NSPR was not detected in the system,
3864 dnl = use the one in the source tree (mozilla/nsprpub)
3865 dnl ========================================================
3866 MOZ_ARG_WITH_BOOL(system-nspr,
3867 [  --with-system-nspr      Use system installed NSPR],
3868     _USE_SYSTEM_NSPR=1 )
3870 if test -n "$_USE_SYSTEM_NSPR"; then
3871     AM_PATH_NSPR(4.9.6, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])])
3874 if test -n "$MOZ_NATIVE_NSPR"; then
3875     _SAVE_CFLAGS=$CFLAGS
3876     CFLAGS="$CFLAGS $NSPR_CFLAGS"
3877     AC_TRY_COMPILE([#include "prtypes.h"],
3878                 [#ifndef PR_STATIC_ASSERT
3879                  #error PR_STATIC_ASSERT not defined or requires including prtypes.h
3880                  #endif],
3881                 [MOZ_NATIVE_NSPR=1],
3882                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
3883     AC_TRY_COMPILE([#include "prtypes.h"],
3884                 [#ifndef PR_UINT64
3885                  #error PR_UINT64 not defined or requires including prtypes.h
3886                  #endif],
3887                 [MOZ_NATIVE_NSPR=1],
3888                 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
3889     CFLAGS=$_SAVE_CFLAGS
3890 else
3891     if test -z "$LIBXUL_SDK"; then
3892         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
3893         if test -n "$GNU_CC"; then
3894             NSPR_LIBS="-L${LIBXUL_DIST}/lib -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
3895         else
3896             NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
3897         fi
3898     else
3899         NSPR_CFLAGS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --includedir="${LIBXUL_DIST}/include/nspr" --cflags`
3900         NSPR_LIBS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --libdir="${LIBXUL_DIST}"/lib --libs`
3901     fi
3904 dnl set GRE_MILESTONE
3905 dnl ========================================================
3906 if test -n "$LIBXUL_SDK"; then
3907     GRE_MILESTONE=`$PYTHON "$_topsrcdir"/config/printconfigsetting.py "$LIBXUL_DIST"/bin/platform.ini Build Milestone`
3908 else
3909     GRE_MILESTONE=`tail -n 1 "$_topsrcdir"/config/milestone.txt 2>/dev/null || tail -1 "$_topsrcdir"/config/milestone.txt`
3911 AC_SUBST(GRE_MILESTONE)
3913 dnl system libevent Support
3914 dnl ========================================================
3915 MOZ_ARG_WITH_STRING(system-libevent,
3916 [  --with-system-libevent[=PFX]
3917                           Use system libevent [installed at prefix PFX]],
3918     LIBEVENT_DIR=$withval)
3920 _SAVE_CFLAGS=$CFLAGS
3921 _SAVE_LDFLAGS=$LDFLAGS
3922 _SAVE_LIBS=$LIBS
3923 if test "$LIBEVENT_DIR" = yes; then
3924     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
3925         MOZ_NATIVE_LIBEVENT=1,
3926         LIBEVENT_DIR=/usr)
3928 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
3929     MOZ_NATIVE_LIBEVENT=
3930 elif test -z "$MOZ_NATIVE_LIBEVENT"; then
3931     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
3932     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
3933     MOZ_CHECK_HEADER(event.h,
3934         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
3935              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
3936          fi],
3937         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
3938     AC_CHECK_LIB(event, event_init,
3939                  [MOZ_NATIVE_LIBEVENT=1
3940                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
3941                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
3942                  [MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
3944 CFLAGS=$_SAVE_CFLAGS
3945 LDFLAGS=$_SAVE_LDFLAGS
3946 LIBS=$_SAVE_LIBS
3948 AC_SUBST(MOZ_NATIVE_LIBEVENT)
3949 AC_SUBST(MOZ_LIBEVENT_CFLAGS)
3950 AC_SUBST(MOZ_LIBEVENT_LIBS)
3952 dnl ========================================================
3953 dnl = If NSS was not detected in the system,
3954 dnl = use the one in the source tree (mozilla/security/nss)
3955 dnl ========================================================
3957 MOZ_ARG_WITH_BOOL(system-nss,
3958 [  --with-system-nss       Use system installed NSS],
3959     _USE_SYSTEM_NSS=1 )
3961 if test -n "$_USE_SYSTEM_NSS"; then
3962     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])])
3965 if test -n "$MOZ_NATIVE_NSS"; then
3966    NSS_LIBS="$NSS_LIBS -lcrmf"
3967 else
3968    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
3969    NSS_DEP_LIBS="\
3970         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
3971         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)smime$NSS_VERSION\$(DLL_SUFFIX) \
3972         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)ssl$NSS_VERSION\$(DLL_SUFFIX) \
3973         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nss$NSS_VERSION\$(DLL_SUFFIX) \
3974         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nssutil$NSS_VERSION\$(DLL_SUFFIX)"
3976    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2"; then
3977        NSS_LIBS="\
3978         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
3979         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
3980         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
3981         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
3982         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
3983    else
3984        NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
3985    fi
3988 dnl ======================
3989 dnl Detect yasm
3990 dnl ======================
3992 AC_MSG_CHECKING([for YASM assembler])
3993 AC_CHECK_PROGS(YASM, yasm, "")
3995 if test -n "$YASM"; then
3996   dnl Pull out yasm's version string
3997   YASM_VERSION=`yasm --version | $AWK '/^yasm/ { print $2 }'`
3998   _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
3999   _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
4000   _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
4001   _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
4004 if test -z "$SKIP_LIBRARY_CHECKS"; then
4005 dnl system JPEG support
4006 dnl ========================================================
4007 MOZ_ARG_WITH_STRING(system-jpeg,
4008 [  --with-system-jpeg[=PFX]
4009                           Use system libjpeg [installed at prefix PFX]],
4010     JPEG_DIR=$withval)
4012 _SAVE_CFLAGS=$CFLAGS
4013 _SAVE_LDFLAGS=$LDFLAGS
4014 _SAVE_LIBS=$LIBS
4015 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
4016     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
4017     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
4019 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
4020     MOZ_NATIVE_JPEG=
4021 else
4022     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_NATIVE_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_NATIVE_JPEG=)
4025 if test "$MOZ_NATIVE_JPEG" = 1; then
4026     AC_TRY_COMPILE([ #include <stdio.h>
4027                      #include <sys/types.h>
4028                      #include <jpeglib.h> ],
4029                    [ #if JPEG_LIB_VERSION < $MOZJPEG
4030                      #error "Insufficient JPEG library version ($MOZJPEG required)."
4031                      #endif
4032                      #ifndef JCS_EXTENSIONS
4033                      #error "libjpeg-turbo JCS_EXTENSIONS required"
4034                      #endif
4035                      ],
4036                    MOZ_NATIVE_JPEG=1,
4037                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
4039 CFLAGS=$_SAVE_CFLAGS
4040 LDFLAGS=$_SAVE_LDFLAGS
4041 LIBS=$_SAVE_LIBS
4043 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
4044     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
4045     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
4047 fi # SKIP_LIBRARY_CHECKS
4049 dnl system ZLIB support
4050 dnl ========================================================
4051 MOZ_ZLIB_CHECK([1.2.3])
4053 if test "$MOZ_NATIVE_ZLIB" != 1; then
4054     MOZ_ZLIB_CFLAGS=
4055     MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,'"$MOZ_BUILD_ROOT"'/modules/zlib/src)'
4058 if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
4059     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
4062 if test -z "$SKIP_LIBRARY_CHECKS"; then
4063 dnl system BZIP2 Support
4064 dnl ========================================================
4065 MOZ_ARG_WITH_STRING(system-bz2,
4066 [  --with-system-bz2[=PFX]
4067                           Use system libbz2 [installed at prefix PFX]],
4068     BZ2_DIR=$withval)
4070 _SAVE_CFLAGS=$CFLAGS
4071 _SAVE_LDFLAGS=$LDFLAGS
4072 _SAVE_LIBS=$LIBS
4073 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
4074     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
4075     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
4077 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
4078     MOZ_NATIVE_BZ2=
4079 else
4080     AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_NATIVE_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
4081         [MOZ_NATIVE_BZ2= MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS=])
4083 CFLAGS=$_SAVE_CFLAGS
4084 LDFLAGS=$_SAVE_LDFLAGS
4085 LIBS=$_SAVE_LIBS
4087 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_NATIVE_BZ2" = 1; then
4088     MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
4089     MOZ_BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
4092 dnl system PNG Support
4093 dnl ========================================================
4094 MOZ_ARG_WITH_STRING(system-png,
4095 [  --with-system-png[=PFX]
4096                           Use system libpng [installed at prefix PFX]],
4097     PNG_DIR=$withval)
4099 _SAVE_CFLAGS=$CFLAGS
4100 _SAVE_LDFLAGS=$LDFLAGS
4101 _SAVE_LIBS=$LIBS
4102 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
4103     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
4104     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
4106 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
4107     MOZ_NATIVE_PNG=
4108 else
4109     AC_CHECK_LIB(png, png_get_valid, [MOZ_NATIVE_PNG=1 MOZ_PNG_LIBS="-lpng"],
4110                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4111     AC_CHECK_LIB(png, png_get_acTL, ,
4112                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
4114 if test "$MOZ_NATIVE_PNG" = 1; then
4115     AC_TRY_COMPILE([ #include <stdio.h>
4116                      #include <sys/types.h>
4117                      #include <png.h> ],
4118                    [ #if PNG_LIBPNG_VER < $MOZPNG
4119                      #error "Insufficient libpng version ($MOZPNG required)."
4120                      #endif
4121                      #ifndef PNG_UINT_31_MAX
4122                      #error "Insufficient libpng version."
4123                      #endif ],
4124                    MOZ_NATIVE_PNG=1,
4125                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4127 CFLAGS=$_SAVE_CFLAGS
4128 LDFLAGS=$_SAVE_LDFLAGS
4129 LIBS=$_SAVE_LIBS
4131 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_NATIVE_PNG" = 1; then
4132     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
4133     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
4136 fi # SKIP_LIBRARY_CHECKS
4138 dnl system HunSpell Support
4139 dnl ========================================================
4140 MOZ_ARG_ENABLE_BOOL(system-hunspell,
4141 [  --enable-system-hunspell
4142                           Use system hunspell (located with pkgconfig)],
4143     MOZ_NATIVE_HUNSPELL=1 )
4145 if test -n "$MOZ_NATIVE_HUNSPELL"; then
4146     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
4149 AC_SUBST(MOZ_NATIVE_HUNSPELL)
4151 dnl ========================================================
4152 dnl system libffi Support
4153 dnl ========================================================
4154 MOZ_ARG_ENABLE_BOOL(system-ffi,
4155 [  --enable-system-ffi       Use system libffi (located with pkgconfig)],
4156     MOZ_NATIVE_FFI=1 )
4158 if test -n "$MOZ_NATIVE_FFI"; then
4159     # Vanilla libffi 3.0.9 needs a few patches from upcoming version 3.0.10
4160     # for non-GCC compilers.
4161     if test -z "$GNU_CC"; then
4162         PKG_CHECK_MODULES(MOZ_FFI, libffi > 3.0.9)
4163     else
4164         PKG_CHECK_MODULES(MOZ_FFI, libffi >= 3.0.9)
4165     fi
4166     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS"
4169 dnl ========================================================
4170 dnl Java SDK support
4171 dnl ========================================================
4173 JAVA_BIN_PATH=
4174 MOZ_ARG_WITH_STRING(java-bin-path,
4175 [  --with-java-bin-path=dir
4176                           Location of Java binaries (java, javac, jar)],
4177     JAVA_BIN_PATH=$withval)
4179 dnl ========================================================
4180 dnl =
4181 dnl = Application
4182 dnl =
4183 dnl ========================================================
4185 MOZ_ARG_HEADER(Application)
4187 ENABLE_TESTS=1
4188 ENABLE_SYSTEM_EXTENSION_DIRS=1
4189 MOZ_BRANDING_DIRECTORY=
4190 MOZ_OFFICIAL_BRANDING=
4191 MOZ_FEEDS=1
4192 MOZ_FLEXBOX=1
4193 MOZ_WEBAPP_RUNTIME=
4194 MOZ_JSDEBUGGER=1
4195 MOZ_AUTH_EXTENSION=1
4196 MOZ_OGG=1
4197 MOZ_RAW=
4198 MOZ_SYDNEYAUDIO=
4199 MOZ_SPEEX_RESAMPLER=1
4200 MOZ_SOUNDTOUCH=1
4201 MOZ_CUBEB=
4202 MOZ_VORBIS=
4203 MOZ_TREMOR=
4204 MOZ_WAVE=1
4205 MOZ_SAMPLE_TYPE_FLOAT32=
4206 MOZ_SAMPLE_TYPE_S16=
4207 MOZ_MEDIA=
4208 MOZ_OPUS=1
4209 MOZ_WEBM=1
4210 MOZ_DASH=1
4211 MOZ_WMF=
4212 MOZ_WEBRTC=1
4213 MOZ_PEERCONNECTION=
4214 MOZ_SRTP=
4215 MOZ_WEBRTC_SIGNALING=
4216 MOZ_WEBRTC_IN_LIBXUL=
4217 MOZ_SCTP=
4218 MOZ_MEDIA_PLUGINS=
4219 MOZ_MEDIA_NAVIGATOR=
4220 MOZ_OMX_PLUGIN=
4221 MOZ_VP8=
4222 MOZ_VP8_ERROR_CONCEALMENT=
4223 MOZ_VP8_ENCODER=
4224 MOZ_WEBVTT=1
4225 VPX_AS=
4226 VPX_ASFLAGS=
4227 VPX_AS_DASH_C_FLAG=
4228 VPX_AS_CONVERSION=
4229 VPX_ASM_SUFFIX=
4230 VPX_X86_ASM=
4231 VPX_ARM_ASM=
4232 LIBJPEG_TURBO_AS=
4233 LIBJPEG_TURBO_ASFLAGS=
4234 LIBJPEG_TURBO_X86_ASM=
4235 LIBJPEG_TURBO_X64_ASM=
4236 LIBJPEG_TURBO_ARM_ASM=
4237 MOZ_PANGO=1
4238 MOZ_PERMISSIONS=1
4239 MOZ_PLACES=1
4240 MOZ_PREF_EXTENSIONS=1
4241 MOZ_PROFILELOCKING=1
4242 MOZ_PSM=1
4243 MOZ_REFLOW_PERF=
4244 MOZ_SAFE_BROWSING=
4245 MOZ_HELP_VIEWER=
4246 MOZ_SPELLCHECK=1
4247 MOZ_ANDROID_OMTC=
4248 MOZ_ONLY_TOUCH_EVENTS=
4249 MOZ_TOOLKIT_SEARCH=1
4250 MOZ_UI_LOCALE=en-US
4251 MOZ_UNIVERSALCHARDET=1
4252 MOZ_URL_CLASSIFIER=
4253 MOZ_XUL=1
4254 MOZ_ZIPWRITER=1
4255 NS_PRINTING=1
4256 MOZ_PDF_PRINTING=
4257 MOZ_DISABLE_CRYPTOLEGACY=
4258 NSS_DISABLE_DBM=
4259 NECKO_WIFI=1
4260 NECKO_COOKIES=1
4261 NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg device"
4262 USE_ARM_KUSER=
4263 BUILD_CTYPES=1
4264 MOZ_USE_NATIVE_POPUP_WINDOWS=
4265 MOZ_ANDROID_HISTORY=
4266 MOZ_WEBSMS_BACKEND=
4267 ACCESSIBILITY=1
4268 MOZ_SYS_MSG=
4269 MOZ_TIME_MANAGER=
4270 MOZ_PAY=
4271 MOZ_AUDIO_CHANNEL_MANAGER=
4273 case "$target_os" in
4274     mingw*)
4275         NS_ENABLE_TSF=1
4276         AC_DEFINE(NS_ENABLE_TSF)
4277         ;;
4278 esac
4280 case "${target}" in
4281     *-android*|*-linuxandroid*)
4282         if test "$CPU_ARCH" = "arm" ; then
4283           USE_ARM_KUSER=1
4284         fi
4286         NSS_DISABLE_DBM=1
4287         if test -z "$gonkdir"; then
4288           NECKO_WIFI=
4289         else
4290           NECKO_WIFI=1
4291         fi
4292         MOZ_THEME_FASTSTRIPE=1
4293         MOZ_TREE_FREETYPE=1
4294         MOZ_MEMORY=1
4295         MOZ_RAW=1
4296         ;;
4298 esac
4300 MOZ_ARG_WITH_STRING(external-source-dir,
4301 [  --with-external-source-dir=dir
4302                           External directory containing additional build files.],
4303 [ EXTERNAL_SOURCE_DIR=$withval])
4304 AC_SUBST(EXTERNAL_SOURCE_DIR)
4306 MOZ_ARG_ENABLE_STRING(application,
4307 [  --enable-application=APP
4308                           Options include:
4309                             browser (Firefox)
4310                             xulrunner
4311                             tools/update-packaging (AUS-related packaging tools)],
4312 [ MOZ_BUILD_APP=$enableval ] )
4314 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
4315 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
4316   XULRUNNER_STUB_NAME=$withval)
4318 if test -z "$XULRUNNER_STUB_NAME"; then
4319   case "$target_os" in
4320   darwin*)
4321     XULRUNNER_STUB_NAME=xulrunner
4322     ;;
4323   *)
4324     XULRUNNER_STUB_NAME=xulrunner-stub
4325   esac
4327 AC_SUBST(XULRUNNER_STUB_NAME)
4329 AC_MSG_CHECKING([for application to build])
4330 if test -z "$MOZ_BUILD_APP"; then
4331   AC_MSG_RESULT([browser])
4332   MOZ_BUILD_APP=browser
4333 else
4334   # "mobile" no longer exists.
4335   if test "$MOZ_BUILD_APP" = "mobile" ; then
4336     AC_MSG_RESULT([none])
4337     AC_MSG_ERROR([--enable-application=mobile is no longer supported.])
4338   fi
4339   # We have a valid application only if it has a build.mk file in its top
4340   # directory.
4341   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
4342     AC_MSG_RESULT([none])
4343     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
4344   else
4345     AC_MSG_RESULT([$MOZ_BUILD_APP])
4346   fi
4349 # The app update channel is 'default' when not supplied. The value is used in
4350 # the application's confvars.sh so it must be set before confvars.sh is called.
4351 MOZ_ARG_ENABLE_STRING([update-channel],
4352 [  --enable-update-channel=CHANNEL
4353                           Select application update channel (default=default)],
4354     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
4356 if test -z "$MOZ_UPDATE_CHANNEL"; then
4357     MOZ_UPDATE_CHANNEL=default
4359 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
4360 AC_SUBST(MOZ_UPDATE_CHANNEL)
4362 # Allow the application to influence configure with a confvars.sh script.
4364 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4365 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4366   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4367   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4368 else
4369   AC_MSG_RESULT([no])
4372 # Allow the application to provide a subconfigure script
4373 if test -f "${srcdir}/${MOZ_BUILD_APP}/configure.in" ; then
4374   do_output_subdirs() {
4375     if test -n "$_subconfigure_subdirs"; then
4376       AC_MSG_ERROR([Cannot specify more than one sub-sub-configure])
4377      fi
4378     _subconfigure_subdir="$1"
4379     _subconfigure_config_args="$ac_configure_args"
4380   }
4381   tmpscript=`mktemp -t subscript.XXXXXX` || exit 1
4382   m4 "${srcdir}/build/autoconf/subconfigure.m4" \
4383      "${srcdir}/build/autoconf/altoptions.m4" \
4384      "${srcdir}/${MOZ_BUILD_APP}/configure.in" > $tmpscript
4385   . $tmpscript
4386   rm -f $tmpscript
4389 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
4390 MOZ_ARG_WITH_STRING(app-name,
4391 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
4392 WITH_APP_NAME=$withval,
4395 if test -n "$WITH_APP_NAME" ; then
4396     MOZ_APP_NAME="$WITH_APP_NAME"
4399 MOZ_ARG_WITH_STRING(app-basename,
4400 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
4401 WITH_APP_BASENAME=$withval,
4404 if test -n "$WITH_APP_BASENAME" ; then
4405     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
4408 # Now is a good time to test for logic errors, define mismatches, etc.
4409 case "$MOZ_BUILD_APP" in
4410 xulrunner)
4411   if test "$LIBXUL_SDK"; then
4412     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4413   fi
4414   ;;
4415 esac
4417 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4418 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4419 # MOZ_BUILD_APP.
4420 case "$MOZ_BUILD_APP" in
4421 browser)
4422   AC_DEFINE(MOZ_PHOENIX)
4423   ;;
4425 xulrunner)
4426   AC_DEFINE(MOZ_XULRUNNER)
4427   ;;
4428 b2g)
4429   AC_DEFINE(MOZ_B2G)
4430   ;;
4431 esac
4433 AC_SUBST(MOZ_BUILD_APP)
4434 AC_SUBST(MOZ_PHOENIX)
4435 AC_SUBST(MOZ_XULRUNNER)
4436 AC_SUBST(MOZ_B2G)
4438 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4440 dnl ========================================================
4441 dnl Check android sdk version depending on mobile target
4442 dnl ========================================================
4444 if test -z "$gonkdir" ; then
4445     # Minimum Android SDK API Level we require.
4446     case "$MOZ_BUILD_APP" in
4447     mobile/android)
4448         android_min_api_level=16
4449         ;;
4450     esac
4452     MOZ_ANDROID_SDK($android_min_api_level)
4455 dnl ========================================================
4456 dnl =
4457 dnl = Toolkit Options
4458 dnl =
4459 dnl ========================================================
4460 MOZ_ARG_HEADER(Toolkit Options)
4462     dnl ========================================================
4463     dnl = Select the default toolkit
4464     dnl ========================================================
4465         MOZ_ARG_ENABLE_STRING(default-toolkit,
4466         [  --enable-default-toolkit=TK
4467                           Select default toolkit
4468                           Platform specific defaults:
4469                             Mac OS X - cairo-cocoa
4470                             OS/2 - cairo-os2
4471                             Win32 - cairo-windows
4472                             * - cairo-gtk2
4473                             * - cairo-qt],
4474     [ _DEFAULT_TOOLKIT=$enableval ],
4475     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4477     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4478         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4479         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4480         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4481         -o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
4482         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
4483         -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
4484         -o "$_DEFAULT_TOOLKIT" = "cairo-android" \
4485         -o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
4486     then
4487         dnl nglayout only supports building with one toolkit,
4488         dnl so ignore everything after the first comma (",").
4489         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4490     else
4491         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4492     fi
4494 MOZ_ARG_WITHOUT_BOOL(x,
4495 [  --without-x              Build without X11],
4496     WITHOUT_X11=1)
4498 dnl ========================================================
4499 dnl = Enable the toolkit as needed                         =
4500 dnl ========================================================
4502 MOZ_WIDGET_GTK=
4504 case "$MOZ_WIDGET_TOOLKIT" in
4506 cairo-windows)
4507     MOZ_WIDGET_TOOLKIT=windows
4508     MOZ_WEBGL=1
4509     MOZ_PDF_PRINTING=1
4510     MOZ_INSTRUMENT_EVENT_LOOP=1
4511     ;;
4513 cairo-gtk2|cairo-gtk2-x11)
4514     MOZ_WIDGET_TOOLKIT=gtk2
4515     MOZ_ENABLE_GTK2=1
4516     MOZ_ENABLE_XREMOTE=1
4517     MOZ_WEBGL=1
4518     MOZ_GL_DEFAULT_PROVIDER=GLX
4520     AC_DEFINE(MOZ_X11)
4521     MOZ_X11=1
4522     USE_FC_FREETYPE=1
4524     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4525     TK_LIBS='$(MOZ_GTK2_LIBS)'
4526     AC_DEFINE(MOZ_WIDGET_GTK2)
4527     MOZ_WIDGET_GTK=2
4528     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4529     MOZ_PDF_PRINTING=1
4530     MOZ_INSTRUMENT_EVENT_LOOP=1
4531     ;;
4533 cairo-qt)
4534     MOZ_WIDGET_TOOLKIT=qt
4535     MOZ_ENABLE_QT=1
4536     if test -z "$WITHOUT_X11"; then
4537       MOZ_ENABLE_XREMOTE=1
4538       MOZ_GL_DEFAULT_PROVIDER=GLX
4539       MOZ_X11=1
4540       AC_DEFINE(MOZ_X11)
4541       XT_LIBS=
4542     fi
4544     MOZ_WEBGL=1
4545     USE_ELF_DYNSTR_GC=
4546     USE_FC_FREETYPE=1
4547     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4548     TK_LIBS='$(MOZ_QT_LIBS)'
4549     AC_DEFINE(MOZ_WIDGET_QT)
4550     MOZ_PDF_PRINTING=1
4551     AC_DEFINE(QT_NO_KEYWORDS)
4552     ;;
4554 cairo-os2)
4555     MOZ_WIDGET_TOOLKIT=os2
4556     USE_FC_FREETYPE=1
4557     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4558     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4559     MOZ_PDF_PRINTING=1
4560     ;;
4562 cairo-cocoa)
4563     MOZ_WIDGET_TOOLKIT=cocoa
4564     AC_DEFINE(MOZ_WIDGET_COCOA)
4565     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
4566     TK_LIBS='-framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
4567     TK_CFLAGS="-DNO_X11"
4568     CFLAGS="$CFLAGS $TK_CFLAGS"
4569     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4570     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
4571     MOZ_USER_DIR="Mozilla"
4572     MOZ_FS_LAYOUT=bundle
4573     MOZ_WEBGL=1
4574     MOZ_INSTRUMENT_EVENT_LOOP=1
4575     ;;
4577 cairo-uikit)
4578     MOZ_WIDGET_TOOLKIT=uikit
4579     AC_DEFINE(MOZ_WIDGET_UIKIT)
4580     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
4581     TK_CFLAGS="-DNO_X11"
4582     TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
4583     CFLAGS="$CFLAGS $TK_CFLAGS"
4584     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4585     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
4586     MOZ_USER_DIR="Mozilla"
4587     MOZ_FS_LAYOUT=bundle
4588     ;;
4590 cairo-android)
4591     AC_DEFINE(MOZ_WIDGET_ANDROID)
4592     MOZ_WIDGET_TOOLKIT=android
4593     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4594     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4595     MOZ_WEBGL=1
4596     MOZ_PDF_PRINTING=1
4597     MOZ_INSTRUMENT_EVENT_LOOP=1
4598     ;;
4600 cairo-gonk)
4601     AC_DEFINE(MOZ_WIDGET_GONK)
4602     AC_DEFINE(MOZ_TOUCH)
4603     MOZ_WIDGET_TOOLKIT=gonk
4604     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4605     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4606     MOZ_WEBGL=1
4607     MOZ_PDF_PRINTING=1
4608     MOZ_TOUCH=1
4609     ;;
4611 esac
4613 AC_SUBST(MOZ_PDF_PRINTING)
4614 if test "$MOZ_PDF_PRINTING"; then
4615    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
4616    AC_DEFINE(MOZ_PDF_PRINTING)
4619 if test "$MOZ_ENABLE_XREMOTE"; then
4620     AC_DEFINE(MOZ_ENABLE_XREMOTE)
4623 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
4624    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
4627 if test "$COMPILE_ENVIRONMENT"; then
4628   if test "$MOZ_ENABLE_GTK2"; then
4629     if test "$MOZ_X11"; then
4630       GDK_PACKAGES=gdk-x11-2.0
4631     fi
4633     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4634   fi
4636 fi # COMPILE_ENVIRONMENT
4638 AC_SUBST(MOZ_FS_LAYOUT)
4640 dnl ========================================================
4641 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4642 dnl their usage and use them in spidermonkey.
4643 dnl ========================================================
4644 MOZ_ARG_WITH_BOOL(arm-kuser,
4645 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4646     USE_ARM_KUSER=1,)
4647 if test -n "$USE_ARM_KUSER"; then
4648    AC_DEFINE(USE_ARM_KUSER)
4651 dnl ========================================================
4652 dnl = startup-notification support module
4653 dnl ========================================================
4655 if test "$MOZ_ENABLE_GTK2"
4656 then
4657     MOZ_ENABLE_STARTUP_NOTIFICATION=
4659     MOZ_ARG_ENABLE_BOOL(startup-notification,
4660     [  --enable-startup-notification
4661                           Enable startup-notification support (default: disabled) ],
4662         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
4663         MOZ_ENABLE_STARTUP_NOTIFICATION=)
4664     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
4665     then
4666         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
4667                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
4668         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
4669             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
4670             then
4671                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
4672             fi
4673             MOZ_ENABLE_STARTUP_NOTIFICATION=
4674         ])
4675     fi
4677     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
4678         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
4679     fi
4681     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
4683 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
4684 AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
4685 AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
4687 dnl ========================================================
4688 dnl = QT support
4689 dnl ========================================================
4690 if test "$MOZ_ENABLE_QT"
4691 then
4692     MOZ_ARG_WITH_STRING(qtdir,
4693     [  --with-qtdir=\$dir       Specify Qt directory ],
4694     [ QTDIR=$withval])
4696     if test -z "$QTDIR"; then
4697         PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore QtOpenGL)
4698         PKG_CHECK_MODULES(MOZ_QT5, Qt5Widgets Qt5Multimedia Qt5PrintSupport,
4699                       MOZ_ENABLE_QT5=1,
4700                       MOZ_ENABLE_QT5=)
4701         if test "$MOZ_ENABLE_QT5"; then
4702             echo "Using qt5"
4703             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $MOZ_QT5_CFLAGS"
4704             MOZ_QT_LIBS="$MOZ_QT_LIBS $MOZ_QT5_LIBS"
4705         fi
4707         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
4708         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
4709     else
4710         MOZ_QT_CFLAGS="-DQT_SHARED"
4711         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
4712         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
4713         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
4714         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
4715         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
4716         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative"
4718         # QtWidgets was introduced only in Qt5
4719         if test -d $QTDIR/include/QtWidgets; then
4720             echo "Using qt5"
4721             MOZ_QT_LIBS="-L$QTDIR/lib/ -lQt5Gui -lQt5Network -lQt5Core -lQt5Xml -lQt5OpenGL"
4722             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui/5.0.1/QtGui"
4723             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtWidgets"
4724             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport"
4725             MOZ_QT_LIBS="$MOZ_QT_LIBS -lQt5Widgets -lQt5PrintSupport"
4726         else
4727             MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
4728             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/Qt"
4729         fi
4730         HOST_MOC="$QTDIR/bin/moc"
4731         HOST_RCC="$QTDIR/bin/rcc"
4732     fi
4733     if test -z "$HOST_MOC"; then
4734         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
4735 incorrect])
4736     fi
4737     if test -z "$HOST_RCC"; then
4738         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is
4739 incorrect])
4740     fi
4742     MOC=$HOST_MOC
4743     RCC=$HOST_RCC
4745     MOZ_ENABLE_QMSYSTEM2=
4746     PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
4747                       MOZ_ENABLE_QMSYSTEM2=1,
4748                       MOZ_ENABLE_QMSYSTEM2=)
4750     if test "$MOZ_ENABLE_QMSYSTEM2"; then
4751       MOZ_ENABLE_QMSYSTEM2=1
4752       MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
4753       MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
4754       AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
4755     fi
4757     MOZ_ENABLE_QTNETWORK=
4758     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
4759                       MOZ_ENABLE_QTNETWORK=1,
4760                       MOZ_ENABLE_QTNETWORK=)
4762     if test "$MOZ_ENABLE_QTNETWORK"; then
4763       MOZ_ENABLE_QTNETWORK=1
4764       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
4765     fi
4767     MOZ_ENABLE_QTMOBILITY=
4768     PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
4769                       MOZ_ENABLE_QTMOBILITY=1,
4770                       MOZ_ENABLE_QTMOBILITY=)
4771     if test "$MOZ_ENABLE_QTMOBILITY"; then
4772        MOZ_ENABLE_QTMOBILITY=1
4773        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
4774        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
4775     else
4776        AC_CHECK_LIB(QtSensors, main, [
4777           MOZ_ENABLE_QTMOBILITY=1
4778           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMobility"
4779           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtSensors"
4780           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtFeedback"
4781           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtLocation"
4782           MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
4783        ])
4784     fi
4785     if test "$MOZ_ENABLE_QTMOBILITY"; then
4786        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
4787     fi
4790 AC_SUBST(GTK_CONFIG)
4791 AC_SUBST(TK_CFLAGS)
4792 AC_SUBST(TK_LIBS)
4794 AC_SUBST(MOZ_ENABLE_GTK2)
4795 AC_SUBST(MOZ_ENABLE_QT)
4796 AC_SUBST(MOZ_ENABLE_QTNETWORK)
4797 AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
4798 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4799 AC_SUBST(MOZ_ENABLE_XREMOTE)
4800 AC_SUBST(MOZ_GTK2_CFLAGS)
4801 AC_SUBST(MOZ_GTK2_LIBS)
4802 AC_SUBST(MOZ_WIDGET_GTK)
4803 AC_SUBST(MOZ_QT_CFLAGS)
4804 AC_SUBST(MOZ_QT_LIBS)
4806 AC_SUBST(MOC)
4807 AC_SUBST(RCC)
4809 AC_SUBST(MOZ_X11)
4811 dnl ========================================================
4812 dnl =
4813 dnl = Components & Features
4814 dnl =
4815 dnl ========================================================
4816 MOZ_ARG_HEADER(Components and Features)
4818 dnl ========================================================
4819 dnl = Localization
4820 dnl ========================================================
4821 MOZ_ARG_ENABLE_STRING(ui-locale,
4822 [  --enable-ui-locale=ab-CD
4823                           Select the user interface locale (default: en-US)],
4824     MOZ_UI_LOCALE=$enableval )
4825 AC_SUBST(MOZ_UI_LOCALE)
4827 dnl ========================================================
4828 dnl = Trademarked Branding
4829 dnl ========================================================
4830 MOZ_ARG_ENABLE_BOOL(official-branding,
4831 [  --enable-official-branding
4832                           Enable Official mozilla.org Branding
4833                           Do not distribute builds with
4834                           --enable-official-branding unless you have
4835                           permission to use trademarks per
4836                           http://www.mozilla.org/foundation/trademarks/ .],
4838   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
4839     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
4840   else
4841     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
4842     MOZ_OFFICIAL_BRANDING=1
4843   fi
4844 ], MOZ_OFFICIAL_BRANDING=)
4846 AC_SUBST(MOZ_OFFICIAL_BRANDING)
4847 if test -n "$MOZ_OFFICIAL_BRANDING"; then
4848   AC_DEFINE(MOZ_OFFICIAL_BRANDING)
4851 MOZ_ARG_WITH_STRING(branding,
4852 [  --with-branding=dir     Use branding from the specified directory.],
4853     MOZ_BRANDING_DIRECTORY=$withval)
4855 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
4856 if test -z "$REAL_BRANDING_DIRECTORY"; then
4857   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
4860 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
4861   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
4864 AC_SUBST(MOZ_BRANDING_DIRECTORY)
4866 dnl ========================================================
4867 dnl = Distribution ID
4868 dnl ========================================================
4869 MOZ_ARG_WITH_STRING(distribution-id,
4870 [  --with-distribution-id=ID
4871                           Set distribution-specific id (default=org.mozilla)],
4872 [ val=`echo $withval`
4873     MOZ_DISTRIBUTION_ID="$val"])
4875 if test -z "$MOZ_DISTRIBUTION_ID"; then
4876    MOZ_DISTRIBUTION_ID="org.mozilla"
4879 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
4880 AC_SUBST(MOZ_DISTRIBUTION_ID)
4883 dnl ========================================================
4884 dnl complex text support off by default
4885 dnl ========================================================
4886 MOZ_ARG_DISABLE_BOOL(pango,
4887 [  --disable-pango         Disable usage of Pango ],
4888     MOZ_PANGO=,
4889     MOZ_PANGO=1)
4891 dnl ========================================================
4892 dnl = Pango
4893 dnl ========================================================
4894 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
4895 then
4896     AC_SUBST(MOZ_PANGO)
4898     if test "$MOZ_PANGO"
4899     then
4900         PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
4902         PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
4903         AC_SUBST(MOZ_PANGO_CFLAGS)
4904         AC_SUBST(MOZ_PANGO_LIBS)
4905         AC_DEFINE(MOZ_PANGO)
4906     else
4907         PKG_CHECK_MODULES(FT2, freetype2 > 6.1.0)
4908         AC_SUBST(FT2_CFLAGS)
4909         AC_SUBST(FT2_LIBS)
4910     fi
4913 dnl ========================================================
4914 dnl = GnomeVFS, GIO and GConf support module
4915 dnl ========================================================
4917 if test "$MOZ_X11"
4918 then
4919     dnl build the GIO extension by default only when the
4920     dnl GTK2 toolkit is in use.
4921     if test "$MOZ_ENABLE_GTK2"
4922     then
4923         MOZ_ENABLE_GIO=1
4924         MOZ_ENABLE_GCONF=1
4925     fi
4927     dnl ========================================================
4928     dnl = GnomeVFS support module
4929     dnl ========================================================
4930     MOZ_ARG_ENABLE_BOOL(gnomevfs,
4931     [  --enable-gnomevfs       Enable GnomeVFS support (default: disabled)],
4932         MOZ_ENABLE_GNOMEVFS=force,
4933         MOZ_ENABLE_GNOMEVFS=)
4935     if test "$MOZ_ENABLE_GNOMEVFS"
4936     then
4937         PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
4938             MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
4939             MOZ_ENABLE_GNOMEVFS=1
4940             AC_DEFINE(MOZ_ENABLE_GNOMEVFS)
4941         ],[
4942             if test "$MOZ_ENABLE_GNOMEVFS" = "force"
4943             then
4944                 AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
4945             fi
4946             MOZ_ENABLE_GNOMEVFS=
4947         ])
4948     fi
4950     AC_SUBST(MOZ_ENABLE_GNOMEVFS)
4951     AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
4952     AC_SUBST(MOZ_GNOMEVFS_LIBS)
4954     dnl ========================================================
4955     dnl = GIO support module
4956     dnl ========================================================
4957     MOZ_ARG_DISABLE_BOOL(gio,
4958     [  --disable-gio           Disable GIO support],
4959         MOZ_ENABLE_GIO=,
4960         MOZ_ENABLE_GIO=force)
4962     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK2"
4963     then
4964         PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
4965                           [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
4966         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
4967             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
4968             MOZ_ENABLE_GIO=1
4969             AC_DEFINE(MOZ_ENABLE_GIO)
4970         ],[
4971             if test "$MOZ_ENABLE_GIO" = "force"
4972             then
4973                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
4974             fi
4975             MOZ_ENABLE_GIO=
4976         ])
4977     fi
4979     AC_SUBST(MOZ_ENABLE_GIO)
4980     AC_SUBST(MOZ_GIO_CFLAGS)
4981     AC_SUBST(MOZ_GIO_LIBS)
4983     dnl ========================================================
4984     dnl = GConf support module
4985     dnl ========================================================
4986     MOZ_ARG_DISABLE_BOOL(gconf,
4987     [  --disable-gconf      Disable Gconf support ],
4988         MOZ_ENABLE_GCONF=,
4989         MOZ_ENABLE_GCONF=force)
4991     if test "$MOZ_ENABLE_GCONF"
4992     then
4993         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
4994             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
4995             MOZ_ENABLE_GCONF=1
4996         ],[
4997             if test "$MOZ_ENABLE_GCONF" = "force"
4998             then
4999                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
5000             fi
5001             MOZ_ENABLE_GCONF=
5002         ])
5003     fi
5005     if test "$MOZ_ENABLE_GCONF"; then
5006         AC_DEFINE(MOZ_ENABLE_GCONF)
5007     fi
5009     AC_SUBST(MOZ_ENABLE_GCONF)
5010     AC_SUBST(MOZ_GCONF_CFLAGS)
5011     AC_SUBST(MOZ_GCONF_LIBS)
5014 dnl ========================================================
5015 dnl = libproxy support
5016 dnl ========================================================
5018 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
5019 then
5020     MOZ_ENABLE_LIBPROXY=
5022     MOZ_ARG_ENABLE_BOOL(libproxy,
5023     [  --enable-libproxy         Enable libproxy support ],
5024     MOZ_ENABLE_LIBPROXY=1,
5025     MOZ_ENABLE_LIBPROXY=)
5027     if test "$MOZ_ENABLE_LIBPROXY"
5028     then
5029         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
5030         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
5031     fi
5033 AC_SUBST(MOZ_ENABLE_LIBPROXY)
5034 AC_SUBST(MOZ_LIBPROXY_CFLAGS)
5035 AC_SUBST(MOZ_LIBPROXY_LIBS)
5037 dnl ========================================================
5038 dnl = GNOME component (mozgnome)
5039 dnl ========================================================
5041 if test "$MOZ_ENABLE_GTK2"
5042 then
5043     MOZ_ENABLE_GNOME_COMPONENT=1
5045 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
5047 dnl ========================================================
5048 dnl = libgnomeui support module
5049 dnl ========================================================
5051 if test "$MOZ_ENABLE_GTK2"
5052 then
5053     MOZ_ARG_ENABLE_BOOL(gnomeui,
5054     [  --enable-gnomeui        Enable libgnomeui instead of GIO & GTK for icon theme support ],
5055         MOZ_ENABLE_GNOMEUI=force,
5056         MOZ_ENABLE_GNOMEUI=)
5058     if test "$MOZ_ENABLE_GNOMEUI"
5059     then
5060         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
5061         [
5062             MOZ_ENABLE_GNOMEUI=1
5063         ],[
5064             if test "$MOZ_ENABLE_GNOMEUI" = "force"
5065             then
5066                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
5067             fi
5068             MOZ_ENABLE_GNOMEUI=
5069         ])
5070     fi
5072     if test "$MOZ_ENABLE_GNOMEUI"; then
5073         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
5074     fi
5077 AC_SUBST(MOZ_ENABLE_GNOMEUI)
5078 AC_SUBST(MOZ_GNOMEUI_CFLAGS)
5080 dnl ========================================================
5081 dnl = dbus support
5082 dnl ========================================================
5084 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
5085 then
5086     MOZ_ENABLE_DBUS=1
5088     MOZ_ARG_DISABLE_BOOL(dbus,
5089     [  --disable-dbus          Disable dbus support ],
5090         MOZ_ENABLE_DBUS=,
5091         MOZ_ENABLE_DBUS=1)
5093     if test "$MOZ_ENABLE_DBUS"
5094     then
5095         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
5096         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
5097         AC_DEFINE(MOZ_ENABLE_DBUS)
5098     fi
5100 AC_SUBST(MOZ_ENABLE_DBUS)
5101 AC_SUBST(MOZ_DBUS_CFLAGS)
5102 AC_SUBST(MOZ_DBUS_LIBS)
5103 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
5104 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
5106 dnl ========================================================
5107 dnl = Enable Android History instead of Places
5108 dnl ========================================================
5109 if test -n "$MOZ_ANDROID_HISTORY"; then
5110     if test -z "$MOZ_PLACES"; then
5111         AC_DEFINE(MOZ_ANDROID_HISTORY)
5112     else
5113         AC_MSG_ERROR([Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.])
5114     fi
5117 dnl ========================================================
5118 dnl = Build with the Android compositor
5119 dnl ========================================================
5120 if test -n "$MOZ_ANDROID_OMTC"; then
5121      dnl Do this if defined in confvars.sh
5122      AC_DEFINE(MOZ_ANDROID_OMTC)
5125 dnl ========================================================
5126 dnl = Disable WebSMS backend
5127 dnl ========================================================
5128 MOZ_ARG_DISABLE_BOOL(websms-backend,
5129 [  --disable-websms-backend
5130                            Disable WebSMS backend],
5131     MOZ_WEBSMS_BACKEND=,
5132     MOZ_WEBSMS_BACKEND=1)
5134 if test -n "$MOZ_WEBSMS_BACKEND"; then
5135     AC_DEFINE(MOZ_WEBSMS_BACKEND)
5138 dnl ========================================================
5139 dnl = Build Personal Security Manager
5140 dnl ========================================================
5141 MOZ_ARG_DISABLE_BOOL(crypto,
5142 [  --disable-crypto        Disable crypto support (Personal Security Manager)],
5143     MOZ_PSM=,
5144     MOZ_PSM=1 )
5146 dnl ========================================================
5147 dnl = JS Debugger XPCOM component (js/jsd)
5148 dnl ========================================================
5149 MOZ_ARG_DISABLE_BOOL(jsd,
5150 [  --disable-jsd           Disable JavaScript debug library],
5151     MOZ_JSDEBUGGER=,
5152     MOZ_JSDEBUGGER=1)
5155 dnl ========================================================
5156 dnl = Enable IPDL's "expensive" unit tests
5157 dnl ========================================================
5158 MOZ_IPDL_TESTS=
5160 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
5161 [  --enable-ipdl-tests     Enable expensive IPDL tests],
5162     MOZ_IPDL_TESTS=1,
5163     MOZ_IPDL_TESTS=)
5165 if test -n "$MOZ_IPDL_TESTS"; then
5166     AC_DEFINE(MOZ_IPDL_TESTS)
5169 AC_SUBST(MOZ_IPDL_TESTS)
5171 dnl ========================================================
5172 dnl = Turns off code necessary for e10s compatibility
5173 dnl ========================================================
5174 dnl This is a temporary flag to be removed in bug 662601 when
5175 dnl it's no longer needed
5177 MOZ_E10S_COMPAT=
5179 MOZ_ARG_ENABLE_BOOL(e10s-compat,
5180 [  --enable-e10s-compat     Turns off code for e10s compat],
5181     MOZ_E10S_COMPAT=1,
5182     MOZ_E10S_COMPAT=)
5184 if test -n "$MOZ_E10S_COMPAT"; then
5185     AC_DEFINE(MOZ_E10S_COMPAT)
5188 dnl ========================================================
5189 dnl = Disable building dbm
5190 dnl ========================================================
5191 MOZ_ARG_DISABLE_BOOL(dbm,
5192 [  --disable-dbm           Disable building dbm],
5193     NSS_DISABLE_DBM=1,
5194     NSS_DISABLE_DBM=)
5196 dnl bi-directional support always on
5197 IBMBIDI=1
5198 AC_DEFINE(IBMBIDI)
5200 dnl ========================================================
5201 dnl accessibility support on by default on all platforms
5202 dnl ========================================================
5203 MOZ_ARG_DISABLE_BOOL(accessibility,
5204 [  --disable-accessibility Disable accessibility support],
5205     ACCESSIBILITY=,
5206     ACCESSIBILITY=1 )
5207 if test "$ACCESSIBILITY"; then
5208     case "$target" in
5209     *-mingw*)
5210         if test -z "$MIDL"; then
5211             if test "$GCC" != "yes"; then
5212                 AC_MSG_ERROR([MIDL could not be found. Building accessibility without MIDL is not supported.])
5213             else
5214                 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.])
5215             fi
5216         fi
5217     esac
5218     AC_DEFINE(ACCESSIBILITY)
5221 dnl ========================================================
5222 dnl Accessibility is required for the linuxgl widget
5223 dnl backend
5224 dnl ========================================================
5225 if test "${MOZ_WIDGET_TOOLKIT}" = "linuxgl" -a "$ACCESSIBILITY" != "1"; then
5226     AC_MSG_ERROR(["Accessibility is required for the linuxgl widget backend"])
5229 dnl ========================================================
5230 dnl Disable printing
5231 dnl ========================================================
5232 MOZ_ARG_DISABLE_BOOL(printing,
5233 [  --disable-printing      Disable printing support],
5234     NS_PRINTING=,
5235     NS_PRINTING=1)
5237 if test "$NS_PRINTING"; then
5238     AC_DEFINE(NS_PRINTING)
5239     AC_DEFINE(NS_PRINT_PREVIEW)
5242 dnl Turn off webrtc for OS's we don't handle yet, but allow 
5243 dnl --enable-webrtc to override.  Can disable for everything in
5244 dnl the master list above.
5245 if test -n "$MOZ_WEBRTC"; then
5246     case "$target" in
5247     *-android*|*-linuxandroid*)
5248         dnl Make sure doesn't get matched by *-linux*
5249         MOZ_WEBRTC=
5250         ;;
5251     *-linux*|*-mingw*|*-darwin*)
5252         dnl Leave enabled
5253         ;;
5254     *)
5255         dnl default to disabled for all others
5256         MOZ_WEBRTC=
5257         ;;
5258     esac
5261 dnl ========================================================
5262 dnl = Disable WebRTC code
5263 dnl ========================================================
5264 MOZ_ARG_DISABLE_BOOL(webrtc,
5265 [  --disable-webrtc        Disable support for WebRTC],
5266     MOZ_WEBRTC=,
5267     MOZ_WEBRTC=1)
5269 if test -n "$MOZ_WEBRTC"; then
5270     AC_DEFINE(MOZ_WEBRTC)
5271     MOZ_MEDIA=1
5272     MOZ_RAW=1
5273     MOZ_VP8=1
5274     MOZ_VP8_ENCODER=1
5275     MOZ_VP8_ERROR_CONCEALMENT=1
5277     dnl OpenSLES is only available in Android 2.3 and later; we'll change this
5278     dnl hard dependency to a dynamic load with graceful runtime failure before
5279     dnl we make --enable-webrtc on by default in Android (bug 815905)
5280     dnl
5281     if test "$OS_TARGET" = "Android"; then
5282        LDFLAGS="$LDFLAGS -lOpenSLES"
5283     fi
5284     case "$target" in
5285     *-android*|*-linuxandroid*)
5286        LDFLAGS="$LDFLAGS -lOpenSLES"
5287        ;;
5288     esac
5290 dnl enable once Signaling lands
5291     MOZ_WEBRTC_SIGNALING=1
5292     AC_DEFINE(MOZ_WEBRTC_SIGNALING)
5293     if test "${OS_TARGET}" = "WINNT"; then
5294         MOZ_WEBRTC_IN_LIBXUL=1
5295     fi
5296 dnl enable once PeerConnection lands
5297     MOZ_PEERCONNECTION=1
5298     AC_DEFINE(MOZ_PEERCONNECTION)
5299     MOZ_SCTP=1
5300     MOZ_SRTP=1
5301     AC_DEFINE(MOZ_SCTP)
5302     AC_DEFINE(MOZ_SRTP)
5305 AC_SUBST(MOZ_WEBRTC)
5306 AC_SUBST(MOZ_WEBRTC_LEAKING_TESTS)
5307 AC_SUBST(MOZ_WEBRTC_SIGNALING)
5308 AC_SUBST(MOZ_PEERCONNECTION)
5309 AC_SUBST(MOZ_WEBRTC_IN_LIBXUL)
5310 AC_SUBST(MOZ_SCTP)
5311 AC_SUBST(MOZ_SRTP)
5313 case "$target_cpu" in
5314 arm*)
5315     MOZ_SAMPLE_TYPE_S16=1
5316     AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
5317     AC_SUBST(MOZ_SAMPLE_TYPE_S16)
5320     MOZ_SAMPLE_TYPE_FLOAT32=1
5321     AC_DEFINE(MOZ_SAMPLE_TYPE_FLOAT32)
5322     AC_SUBST(MOZ_SAMPLE_TYPE_FLOAT32)
5324 esac
5326 dnl ========================================================
5327 dnl = Enable Raw Codecs
5328 dnl ========================================================
5329 MOZ_ARG_ENABLE_BOOL(raw,
5330 [  --enable-raw           Enable support for RAW media],
5331     MOZ_RAW=1,
5332     MOZ_RAW=)
5334 if test -n "$MOZ_RAW"; then
5335     AC_DEFINE(MOZ_RAW)
5336     MOZ_MEDIA=1
5339 AC_SUBST(MOZ_RAW)
5341 dnl ========================================================
5342 dnl = Disable Ogg Codecs
5343 dnl ========================================================
5344 MOZ_ARG_DISABLE_BOOL(ogg,
5345 [  --disable-ogg           Disable support for OGG media (Theora video and Vorbis audio)],
5346     MOZ_OGG=,
5347     MOZ_OGG=1)
5349 if test -n "$MOZ_OGG"; then
5350     AC_DEFINE(MOZ_OGG)
5351     MOZ_SYDNEYAUDIO=1
5352     MOZ_CUBEB=1
5353     MOZ_MEDIA=1
5355     dnl Checks for __attribute__(aligned()) directive
5356     AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5357         [ac_cv_c_attribute_aligned],
5358         [ac_cv_c_attribute_aligned=0
5359          CFLAGS_save="${CFLAGS}"
5360          CFLAGS="${CFLAGS} -Werror"
5361          for ac_cv_c_attr_align_try in 64 32 16 8; do
5362            echo "trying $ac_cv_c_attr_align_try"
5363            AC_TRY_COMPILE([],
5364                           [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5365                           [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5366            if test "$ac_cv_c_attribute_aligned" != 0; then
5367              break;
5368            fi
5369          done
5370            CFLAGS="${CFLAGS_save}"])
5371     if test "${ac_cv_c_attribute_aligned}" != "0"; then
5372       AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5373                          [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5374     fi
5377 dnl ========================================================
5378 dnl = Disable Opus audio codec support
5379 dnl ========================================================
5380 MOZ_ARG_DISABLE_BOOL(opus,
5381 [  --disable-opus          Disable support for Opus audio],
5382     MOZ_OPUS=,
5383     MOZ_OPUS=1)
5385 dnl ========================================================
5386 dnl = Disable VP8 decoder support
5387 dnl ========================================================
5388 MOZ_ARG_DISABLE_BOOL(webm,
5389 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
5390     MOZ_WEBM=,
5391     MOZ_WEBM=1)
5393 if test -n "$MOZ_WEBM"; then
5394     AC_DEFINE(MOZ_WEBM)
5395     MOZ_VP8=1
5398 dnl ========================================================
5399 dnl = Disable DASH-WebM support
5400 dnl ========================================================
5401 MOZ_ARG_DISABLE_BOOL(dash,
5402 [  --disable-dash          Disable support for DASH-WebM],
5403     MOZ_DASH=,
5404     MOZ_DASH=1)
5406 if test -n "$MOZ_DASH"; then
5407     if test -n "$MOZ_WEBM"; then
5408         AC_DEFINE(MOZ_DASH)
5409     else
5410         dnl Fail if WebM is not enabled as well as DASH.
5411         AC_MSG_ERROR([WebM is currently disabled and must be enabled for DASH
5412                      to work.])
5413     fi
5417 dnl ========================================================
5418 dnl = Windows Media Foundation support
5419 dnl ========================================================
5420 if test "$OS_ARCH" = "WINNT"; then
5421     dnl Enable Windows Media Foundation support by default.
5422     dnl Note our minimum SDK version is Windows 7 SDK, so we are (currently)
5423     dnl guaranteed to have a recent-enough SDK to build WMF.
5424     MOZ_WMF=1
5427 MOZ_ARG_DISABLE_BOOL(wmf,
5428 [  --disable-wmf  Disable support for Windows Media Foundation],
5429     MOZ_WMF=,
5430     MOZ_WMF=1)
5432 if test -n "$MOZ_WMF"; then
5433     AC_DEFINE(MOZ_WMF)
5434     MOZ_SYDNEYAUDIO=1
5435     MOZ_CUBEB=1
5436     MOZ_MEDIA=1
5439 dnl ========================================================
5440 dnl = Enable media plugin support
5441 dnl ========================================================
5442 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5443   dnl Enable support on android by default
5444   MOZ_MEDIA_PLUGINS=1
5447 MOZ_ARG_ENABLE_BOOL(media-plugins,
5448 [  --enable-media-plugins  Enable support for media plugins],
5449     MOZ_MEDIA_PLUGINS=1,
5450     MOZ_MEDIA_PLUGINS=)
5452 if test -n "$MOZ_MEDIA_PLUGINS"; then
5453   AC_DEFINE(MOZ_MEDIA_PLUGINS)
5456 dnl ========================================================
5457 dnl = Enable getUserMedia support
5458 dnl ========================================================
5459 MOZ_ARG_ENABLE_BOOL(media-navigator,
5460 [  --enable-media-navigator  Enable support for getUserMedia],
5461     MOZ_MEDIA_NAVIGATOR=1,
5462     MOZ_MEDIA_NAVIGATOR=)
5464 if test -n "$MOZ_MEDIA_NAVIGATOR"; then
5465   AC_DEFINE(MOZ_MEDIA_NAVIGATOR)
5468 dnl ========================================================
5469 dnl = Enable building OMX media plugin (B2G or Android)
5470 dnl ========================================================
5471 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5472   dnl Enable support on android by default
5473   MOZ_OMX_PLUGIN=1
5476 MOZ_ARG_ENABLE_BOOL(omx-plugin,
5477 [  --enable-omx-plugin      Enable building OMX plugin (B2G)],
5478     MOZ_OMX_PLUGIN=1,
5479     MOZ_OMX_PLUGIN=)
5481 if test -n "$MOZ_OMX_PLUGIN"; then
5482     if test "$OS_TARGET" = "Android"; then
5483         dnl Only allow building OMX plugin on Gonk (B2G) or Android
5484         AC_DEFINE(MOZ_OMX_PLUGIN)
5485     else
5486        dnl fail if we're not building on Gonk or Android
5487        AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
5488     fi
5491 dnl system libvpx Support
5492 dnl ========================================================
5493 MOZ_ARG_WITH_BOOL(system-libvpx,
5494 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
5495     MOZ_NATIVE_LIBVPX=1)
5497 MOZ_LIBVPX_CFLAGS=
5498 MOZ_LIBVPX_LIBS=
5500 if test -n "$MOZ_VP8"; then
5501     AC_DEFINE(MOZ_VP8)
5502     if test -n "$MOZ_VP8_ERROR_CONCEALMENT" ; then
5503         AC_DEFINE(MOZ_VP8_ERROR_CONCEALMENT)
5504     fi
5505     if test -n "$MOZ_VP8_ENCODER" ; then
5506         AC_DEFINE(MOZ_VP8_ENCODER)
5507     fi
5509     if test -n "$MOZ_NATIVE_LIBVPX"; then
5510         dnl ============================
5511         dnl === libvpx Version check ===
5512         dnl ============================
5513         dnl Check to see if we have a system libvpx package.
5514         PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.0.0)
5516         MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [], 
5517          [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.])])
5519         _SAVE_LIBS=$LIBS
5520         AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [], 
5521          [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
5522         LIBS=$_SAVE_LIBS
5523     fi
5526 AC_SUBST(MOZ_NATIVE_LIBVPX)
5527 AC_SUBST(MOZ_LIBVPX_CFLAGS)
5528 AC_SUBST(MOZ_LIBVPX_LIBS)
5530 if test "$MOZ_WEBM"; then
5531     MOZ_SYDNEYAUDIO=1
5532     MOZ_CUBEB=1
5533     MOZ_MEDIA=1
5534     if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then
5535         MOZ_VORBIS=1
5536     else
5537         MOZ_TREMOR=1
5538     fi
5541 if test -n "$MOZ_VP8" -a -z "$MOZ_NATIVE_LIBVPX"; then
5543     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
5544     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
5545     dnl We currently require gcc on all arm platforms.
5546     VPX_AS=$YASM
5547     VPX_ASM_SUFFIX=asm
5548     VPX_NEED_OBJ_INT_EXTRACT=
5550     dnl See if we have assembly on this platform.
5551     case "$OS_ARCH:$CPU_ARCH" in
5552     Darwin:x86)
5553       VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
5554       VPX_X86_ASM=1
5555     ;;
5556     Darwin:x86_64)
5557       VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
5558       VPX_X86_ASM=1
5559     ;;
5560     WINNT:x86_64)
5561       VPX_ASFLAGS="-f x64 -rnasm -pnasm"
5562       VPX_X86_ASM=1
5563     ;;
5564     WINNT:x86)
5565       dnl Check for yasm 1.1 or greater.
5566       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
5567         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.])
5568       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5569         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.])
5570       else
5571         VPX_ASFLAGS="-f win32 -rnasm -pnasm -DPIC"
5572         VPX_X86_ASM=1
5573         dnl The encoder needs obj_int_extract to get asm offsets.
5574       fi
5575     ;;
5576     *:arm*)
5577       if test -n "$GNU_AS" ; then
5578         VPX_AS=$AS
5579         dnl These flags are a lie; they're just used to enable the requisite
5580         dnl opcodes; actual arch detection is done at runtime.
5581         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
5582         VPX_DASH_C_FLAG="-c"
5583         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
5584         VPX_ASM_SUFFIX="$ASM_SUFFIX"
5585         VPX_ARM_ASM=1
5586       fi
5587     ;;
5588     *:x86)
5589       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5590         VPX_ASFLAGS="-f elf32 -rnasm -pnasm"
5591         VPX_X86_ASM=1
5592       fi
5593     ;;
5594     *:x86_64)
5595       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5596         VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5597         VPX_X86_ASM=1
5598       fi
5599     ;;
5600     esac
5602     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_X86_ASM" -a -z "$VPX_AS"; then
5603       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.])
5604     fi
5606     if test -n "$MOZ_VP8_ENCODER" -a \
5607             -z "$GNU_CC" -a -z "$INTEL_CC" -a -z "$CLANG_CC" ; then
5608       dnl We prefer to get asm offsets using inline assembler, which the above
5609       dnl compilers can do. When we're not using one of those, we have to fall
5610       dnl back to obj_int_extract, which reads them from a compiled object
5611       dnl file. Unfortunately, that only works if we're compiling on a system
5612       dnl with the header files for the appropriate object file format.
5613       VPX_NEED_OBJ_INT_EXTRACT=1
5614     fi
5616     if test -n "$VPX_X86_ASM"; then
5617       AC_DEFINE(VPX_X86_ASM)
5618     elif test -n "$VPX_ARM_ASM"; then
5619       AC_DEFINE(VPX_ARM_ASM)
5620     else
5621       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
5622     fi
5625 dnl ========================================================
5626 dnl = Disable Wave decoder support
5627 dnl ========================================================
5628 MOZ_ARG_DISABLE_BOOL(wave,
5629 [  --disable-wave          Disable Wave decoder support],
5630     MOZ_WAVE=,
5631     MOZ_WAVE=1)
5633 if test -n "$MOZ_WAVE"; then
5634     AC_DEFINE(MOZ_WAVE)
5635     MOZ_SYDNEYAUDIO=1
5636     MOZ_CUBEB=1
5637     MOZ_MEDIA=1
5640 dnl ========================================================
5641 dnl = Handle dependent SYDNEYAUDIO, CUBEB, and MEDIA defines
5642 dnl ========================================================
5644 if test -n "$MOZ_SYDNEYAUDIO"; then
5645     AC_DEFINE(MOZ_SYDNEYAUDIO)
5648 if test -n "$MOZ_SPEEX_RESAMPLER"; then
5649     AC_DEFINE(MOZ_SPEEX_RESAMPLER)
5652 if test -n "$MOZ_SOUNDTOUCH"; then
5653     AC_DEFINE(MOZ_SOUNDTOUCH)
5656 if test -n "$MOZ_CUBEB"; then
5657     case "$target" in
5658     *-android*|*-linuxandroid*)
5659         if test -n "$gonkdir"; then
5660             AC_DEFINE(MOZ_CUBEB)
5661         fi
5662         dnl No Android implementation of libcubeb yet.
5663         ;;
5664     *-linux*)
5665         AC_DEFINE(MOZ_CUBEB)
5666         ;;
5667     *-mingw*)
5668         AC_DEFINE(MOZ_CUBEB)
5669         ;;
5670     *-darwin*)
5671         AC_DEFINE(MOZ_CUBEB)
5672         ;;
5673     *-openbsd*)
5674         AC_DEFINE(MOZ_CUBEB)
5675         ;;
5676     *)
5677         dnl Other targets will be enabled soon.
5678         ;;
5679     esac
5682 if test -n "$MOZ_MEDIA"; then
5683     AC_DEFINE(MOZ_MEDIA)
5686 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
5687     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/])
5690 if test -n "$MOZ_VORBIS"; then
5691     AC_DEFINE(MOZ_VORBIS)
5694 if test -n "$MOZ_TREMOR"; then
5695     AC_DEFINE(MOZ_TREMOR)
5698 if test -n "$MOZ_OPUS"; then
5699     AC_DEFINE(MOZ_OPUS)
5702 if test -n "$MOZ_WEBVTT"; then
5703     AC_DEFINE(MOZ_WEBVTT)
5706 dnl ========================================================
5707 dnl = Check alsa availability on Linux if using sydneyaudio
5708 dnl ========================================================
5710 dnl If using sydneyaudio with Linux, ensure that the alsa library is available
5711 if test -n "$MOZ_SYDNEYAUDIO" -a "$OS_TARGET" = "Linux"; then
5712     MOZ_ALSA=1
5715 MOZ_ARG_ENABLE_BOOL(alsa,
5716 [  --enable-alsa          Enable Alsa support (default on Linux)],
5717 MOZ_ALSA=1,
5718 MOZ_ALSA=)
5720 if test -n "$MOZ_ALSA"; then
5721     AC_DEFINE(MOZ_CUBEB)
5722     PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5723          [echo "$MOZ_ALSA_PKG_ERRORS"
5724           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.)])])
5727 AC_SUBST(MOZ_ALSA)
5728 AC_SUBST(MOZ_ALSA_CFLAGS)
5729 AC_SUBST(MOZ_ALSA_LIBS)
5731 dnl ========================================================
5732 dnl = Enable PulseAudio
5733 dnl ========================================================
5735 MOZ_ARG_ENABLE_BOOL(pulseaudio,
5736 [  --enable-pulseaudio          Enable PulseAudio support (experimental)],
5737 MOZ_PULSEAUDIO=1,
5738 MOZ_PULSEAUDIO=)
5740 if test -n "$MOZ_PULSEAUDIO"; then
5741     AC_DEFINE(MOZ_CUBEB)
5742     PKG_CHECK_MODULES(MOZ_PULSEAUDIO, libpulse, ,
5743          [echo "$MOZ_PULSEAUDIO_PKG_ERRORS"
5744           AC_MSG_ERROR([pulseaudio audio backend requires libpulse package])])
5747 AC_SUBST(MOZ_PULSEAUDIO)
5748 AC_SUBST(MOZ_PULSEAUDIO_CFLAGS)
5749 AC_SUBST(MOZ_PULSEAUDIO_LIBS)
5751 dnl ========================================================
5752 dnl = Enable GStreamer
5753 dnl ========================================================
5754 MOZ_ARG_ENABLE_BOOL(gstreamer,
5755 [  --enable-gstreamer           Enable GStreamer support],
5756 MOZ_GSTREAMER=1,
5757 MOZ_GSTREAMER=)
5759 if test "$MOZ_GSTREAMER"; then
5760     # API version, eg 0.10, 1.0 etc
5761     GST_API_VERSION=0.10
5762     # core/base release number
5763     GST_VERSION=0.10.25
5764     PKG_CHECK_MODULES(GSTREAMER,
5765                       gstreamer-$GST_API_VERSION >= $GST_VERSION
5766                       gstreamer-app-$GST_API_VERSION
5767                       gstreamer-plugins-base-$GST_API_VERSION)
5768     if test -n "$GSTREAMER_LIBS"; then
5769        _SAVE_LDFLAGS=$LDFLAGS
5770        LDFLAGS="$LDFLAGS $GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5771        AC_TRY_LINK(,[return 0;],_HAVE_LIBGSTVIDEO=1,_HAVE_LIBGSTVIDEO=)
5772        if test -n "$_HAVE_LIBGSTVIDEO" ; then
5773           GSTREAMER_LIBS="$GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5774        else
5775           AC_MSG_ERROR([gstreamer video backend requires libgstvideo])
5776        fi
5777        LDFLAGS=$_SAVE_LDFLAGS
5778     else
5779        AC_MSG_ERROR([gstreamer backend requires the gstreamer packages])
5780     fi
5782 AC_SUBST(GSTREAMER_CFLAGS)
5783 AC_SUBST(GSTREAMER_LIBS)
5784 AC_SUBST(MOZ_GSTREAMER)
5786 if test -n "$MOZ_GSTREAMER"; then
5787    AC_DEFINE(MOZ_GSTREAMER)
5788    MOZ_MEDIA=1
5792 dnl ========================================================
5793 dnl Permissions System
5794 dnl ========================================================
5795 MOZ_ARG_DISABLE_BOOL(permissions,
5796 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5797     MOZ_PERMISSIONS=,
5798     MOZ_PERMISSIONS=1
5801 dnl ========================================================
5802 dnl NegotiateAuth
5803 dnl ========================================================
5804 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5805 [  --disable-negotiateauth Disable GSS-API negotiation ],
5806     MOZ_AUTH_EXTENSION=,
5807     MOZ_AUTH_EXTENSION=1 )
5809 dnl ========================================================
5810 dnl Pref extensions (autoconfig)
5811 dnl ========================================================
5812 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5813 [  --disable-pref-extensions
5814                           Disable pref extensions such as autoconfig],
5815   MOZ_PREF_EXTENSIONS=,
5816   MOZ_PREF_EXTENSIONS=1 )
5818 dnl ========================================================
5819 dnl Searching of system directories for extensions.
5820 dnl Note: this switch is meant to be used for test builds
5821 dnl whose behavior should not depend on what happens to be
5822 dnl installed on the local machine.
5823 dnl ========================================================
5824 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
5825 [  --disable-system-extension-dirs
5826                           Disable searching system- and account-global
5827                           directories for extensions of any kind; use
5828                           only profile-specific extension directories],
5829   ENABLE_SYSTEM_EXTENSION_DIRS=,
5830   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
5831 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
5832   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
5835 dnl ========================================================
5836 dnl = Universalchardet
5837 dnl ========================================================
5838 MOZ_ARG_DISABLE_BOOL(universalchardet,
5839 [  --disable-universalchardet
5840                           Disable universal encoding detection],
5841   MOZ_UNIVERSALCHARDET=,
5842   MOZ_UNIVERSALCHARDET=1 )
5844 if test -n "${JAVA_BIN_PATH}"; then
5845   dnl Look for javac and jar in the specified path.
5846   JAVA_PATH="$JAVA_BIN_PATH"
5847 else
5848   dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5849   JAVA_PATH="$JAVA_HOME/bin:$PATH"
5852 MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5853 MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5854 MOZ_PATH_PROG(JAVAH, javah, :, [$JAVA_PATH])
5855 MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5857 if test -n "${JAVA_BIN_PATH}" -o \
5858   \( "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk" \); then
5859   if test -z "$JAVA" -o "$JAVA" = ":" -o -z "$JAVAC" -o "$JAVAC" = ":" -o -z "$JAVAH" -o "$JAVAH" = ":" -o -z "$JAR" -o "$JAR" = ":"; then
5860     AC_MSG_ERROR([The programs java, javac, javah and jar were not found.  Set \$JAVA_HOME to your java sdk directory or use --with-java-bin-path={java-bin-dir}])
5861   fi
5864 dnl ========================================================
5865 dnl = ANGLE OpenGL->D3D translator for WebGL
5866 dnl = * only applies to win32
5867 dnl = * enabled by default (shipping build); requires explicit --disable to disable
5868 dnl ========================================================
5869 MOZ_ANGLE_RENDERER=
5870 MOZ_DIRECTX_SDK_PATH=
5871 MOZ_DIRECTX_SDK_CPU_SUFFIX=
5872 MOZ_D3DCOMPILER_CAB=
5873 MOZ_D3DCOMPILER_DLL=
5874 case "$target_os" in
5875 *mingw*)
5876     MOZ_ANGLE_RENDERER=1
5877     ;;
5878 esac
5880 # The DirectX SDK libraries are split into x86 and x64 sub-directories
5881 case "${target_cpu}" in
5882 i*86)
5883   MOZ_DIRECTX_SDK_CPU_SUFFIX=x86
5884   ;;
5885 x86_64)
5886   MOZ_DIRECTX_SDK_CPU_SUFFIX=x64
5887   ;;
5888 esac
5890 MOZ_ARG_DISABLE_BOOL(webgl,
5891 [  --disable-webgl     Disable building of the WebGL implementation],
5892     MOZ_WEBGL_DISABLED=1,
5893     MOZ_WEBGL_DISABLED=)
5895 if test -n "$MOZ_WEBGL_DISABLED"; then
5896   MOZ_WEBGL=
5897   MOZ_ANGLE_RENDERER=
5900 if test -n "$MOZ_ANGLE_RENDERER" -a -z "$CROSS_COMPILE"; then
5901   # Get the SDK path from the registry.
5902   # First try to get the June 2010 SDK
5903   MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK (June 2010)' | head -n 1`
5904   if test -z "$MOZ_DIRECTX_SDK_REG_KEY" ; then
5905     # Otherwise just take whatever comes first
5906     MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK' | head -n 1`
5907   fi
5909   if test -n "`echo $MOZ_DIRECTX_SDK_REG_KEY | grep 'February 2010'`" ; then
5910     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.])
5911   else
5912     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'`
5913   fi
5915   if test -n "$MOZ_DIRECTX_SDK_PATH" &&
5916      test -f "$MOZ_DIRECTX_SDK_PATH"/include/d3dx9.h &&
5917          test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5918     AC_MSG_RESULT([Found DirectX SDK via registry, using $MOZ_DIRECTX_SDK_PATH])
5919   else
5920     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.])
5921   fi
5923   # Get the SDK numeric version (e.g. 43) by looking at the dependencies of d3dx9.lib
5924   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'`
5926   if test -z "$MOZ_D3DX9_VERSION" ; then
5927         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.])
5928   fi
5930   MOZ_D3DCOMPILER_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *D3DCompiler_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
5932   if test -z "$MOZ_D3DCOMPILER_CAB"; then
5933     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.])
5934   fi
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"; then
5983     AC_DEFINE_UNQUOTED(BREAKPAD_CUSTOM_STDINT_H, "mozilla/StandardInteger.h")
5984     if test -z "$HAVE_64BIT_OS"; then
5985       MOZ_CRASHREPORTER_INJECTOR=1
5986       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
5987     fi
5988   fi
5991 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
5992 [  --with-crashreporter-enable-percent=NN
5993                           Enable sending crash reports by default on NN% of users. (default=100)],
5994 [ val=`echo $withval | sed 's/[^0-9]//g'`
5995     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
5997 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
5998    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
6000 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
6002 dnl ========================================================
6003 dnl = libjpeg-turbo configuration
6004 dnl ========================================================
6005 MOZ_LIBJPEG_TURBO=
6006 if test -z "$MOZ_NATIVE_JPEG"; then
6007     MOZ_LIBJPEG_TURBO=1
6010 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
6011 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
6012     MOZ_LIBJPEG_TURBO=,
6013     MOZ_LIBJPEG_TURBO=1)
6015 if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
6016     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
6019 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
6020 dnl files.
6022 if test -n "$MOZ_LIBJPEG_TURBO"; then
6024   dnl Do we support libjpeg-turbo on this platform?
6025   case "$OS_ARCH:$OS_TEST" in
6026   Darwin:i?86)
6027     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
6028     LIBJPEG_TURBO_X86_ASM=1
6029   ;;
6030   Darwin:x86_64)
6031     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
6032     LIBJPEG_TURBO_X64_ASM=1
6033   ;;
6034   WINNT:x86|WINNT:i?86)
6035     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
6036     LIBJPEG_TURBO_X86_ASM=1
6037   ;;
6038   WINNT:x86_64)
6039     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
6040     LIBJPEG_TURBO_X64_ASM=1
6041   ;;
6042   *:arm*)
6043     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
6044     LIBJPEG_TURBO_ARM_ASM=1
6045   ;;
6046   *:x86|*:i?86)
6047     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6048       LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6049       LIBJPEG_TURBO_X86_ASM=1
6050     fi
6051   ;;
6052   *:x86_64)
6053     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6054       LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6055       LIBJPEG_TURBO_X64_ASM=1
6056     fi
6057   ;;
6058   esac
6062 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
6063 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
6064 dnl it doesn't exist or we have too old of a version.
6065 if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
6066     AC_MSG_CHECKING([for Yasm assembler])
6067     AC_CHECK_PROGS(LIBJPEG_TURBO_AS, yasm, "")
6069     if test -z "$LIBJPEG_TURBO_AS" ; then
6070         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.])
6071     fi
6073     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
6074     dnl on Linux and 1.1 or newer everywhere else.
6075     if test "$OS_ARCH" = "Linux" ; then
6076         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
6077             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.])
6078         fi
6079     else
6080         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
6081             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.])
6082         fi
6083     fi
6086 dnl If we're on an ARM system which supports libjpeg-turbo's asm routines and
6087 dnl --disable-libjpeg-turbo wasn't passed, use the C compiler as the assembler.
6088 if test -n "$LIBJPEG_TURBO_ARM_ASM" ; then
6089     echo "Using $AS as the assembler for ARM code."
6090     LIBJPEG_TURBO_AS=$AS
6093 if test -n "$LIBJPEG_TURBO_X86_ASM"; then
6094     AC_DEFINE(LIBJPEG_TURBO_X86_ASM)
6095 elif test -n "$LIBJPEG_TURBO_X64_ASM"; then
6096     AC_DEFINE(LIBJPEG_TURBO_X64_ASM)
6097 elif test -n "$LIBJPEG_TURBO_ARM_ASM"; then
6098     AC_DEFINE(LIBJPEG_TURBO_ARM_ASM)
6099 elif test -n "$MOZ_LIBJPEG_TURBO"; then
6100     dnl Warn if we're not building the optimized routines, even though the user
6101     dnl didn't specify --disable-libjpeg-turbo.
6102     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
6105 dnl ========================================================
6106 dnl = Enable compilation of specific extension modules
6107 dnl ========================================================
6109 MOZ_ARG_ENABLE_STRING(extensions,
6110 [  --enable-extensions     Enable extensions],
6111 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6112     if test "$option" = "yes" -o "$option" = "all"; then
6113         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
6114     elif test "$option" = "no" -o "$option" = "none"; then
6115         MOZ_EXTENSIONS=""
6116     elif test "$option" = "default"; then
6117         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
6118     elif test `echo "$option" | grep -c \^-` != 0; then
6119         option=`echo $option | sed 's/^-//'`
6120         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
6121     else
6122         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
6123     fi
6124 done],
6125     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
6127 if test -z "$MOZ_ENABLE_GNOMEVFS" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6128     # Suppress warning on non-X11 platforms
6129     if test -n "$MOZ_X11"; then
6130         AC_MSG_WARN([Removing gnomevfs from MOZ_EXTENSIONS due to no --enable-gnomevfs.])
6131     fi
6132     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6135 dnl Do not build gnomevfs with libxul based apps
6136 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6137     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6140 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6141     # Suppress warning on non-X11 platforms
6142     if test -n "$MOZ_X11"; then
6143         AC_MSG_WARN([Removing gio from MOZ_EXTENSIONS due to --disable-gio.])
6144     fi
6145     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6148 dnl Do not build gio with libxul based apps
6149 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6150     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6153 if test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6154     MOZ_GIO_COMPONENT=1
6155     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6157 AC_SUBST(MOZ_GIO_COMPONENT)
6159 if test -z "$MOZ_JSDEBUGGER" -a `echo "$MOZ_EXTENSIONS" | grep -c venkman` -ne 0; then
6160     AC_MSG_WARN([Cannot build venkman without JavaScript debug library. Removing venkman from MOZ_EXTENSIONS.])
6161     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|venkman||'`
6164 dnl Remove dupes
6165 MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
6167 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6168 dnl when trying to build a nonexistent extension.
6169 for extension in $MOZ_EXTENSIONS; do
6170     if test ! -d "${srcdir}/extensions/${extension}"; then
6171         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6172     fi
6173 done
6175 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
6176   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
6179 dnl ========================================================
6180 dnl CSS3 Flexbox Support
6181 dnl ========================================================
6182 if test -n "$MOZ_FLEXBOX"; then
6183   AC_DEFINE(MOZ_FLEXBOX)
6186 dnl ========================================================
6187 dnl Build Freetype in the tree
6188 dnl ========================================================
6189 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6190 [  --enable-tree-freetype  Enable Tree FreeType],
6191     MOZ_TREE_FREETYPE=1,
6192     MOZ_TREE_FREETYPE= )
6193 if test -n "$MOZ_TREE_FREETYPE"; then
6194    if test -n "$_WIN32_MSVC"; then
6195       AC_ERROR("building with in-tree freetype is not supported on MSVC")
6196    fi
6197    AC_DEFINE(MOZ_TREE_FREETYPE)
6198    AC_SUBST(MOZ_TREE_FREETYPE)
6199    MOZ_ENABLE_CAIRO_FT=1
6200    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6201    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6202    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6203    FT2_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6204    CAIRO_FT_OSLIBS=''
6205    CAIRO_FT_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6206    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6207    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6208    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6209    AC_SUBST(CAIRO_FT_CFLAGS)
6212 dnl ========================================================
6213 dnl Installer
6214 dnl ========================================================
6215 dnl Abort Windows build if the required major version and
6216 dnl minimum minor version of Unicode NSIS isn't in the path
6217 dnl (unless in case of cross compiling, for which Unicode
6218 dnl is not yet sufficient).
6219 if test "$OS_ARCH" = "WINNT"; then
6220     REQ_NSIS_MAJOR_VER=2
6221     MIN_NSIS_MINOR_VER=46
6222     MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensisu-2.46 makensis)
6223     if test -n "$MAKENSISU" -a "$MAKENSISU" != ":"; then
6224       AC_MSG_RESULT([yes])
6225       changequote(,)
6226       MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\).*\-Unicode$/\1/g'`
6227       changequote([,])
6228       if test ! "$MAKENSISU_VER" = ""; then
6229           MAKENSISU_MAJOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $1 }'`
6230           MAKENSISU_MINOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $2 }'`
6231       fi
6232       AC_MSG_CHECKING([for Unicode NSIS with major version == $REQ_NSIS_MAJOR_VER and minor version >= $MIN_NSIS_MINOR_VER])
6233       if test "$MAKENSISU_VER" = "" || \
6234          test ! "$MAKENSISU_MAJOR_VER" = "$REQ_NSIS_MAJOR_VER" -o \
6235               ! "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER; then
6236           AC_MSG_RESULT([no])
6237           if test -z "$CROSS_COMPILE"; then
6238             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.])
6239           else
6240             MAKENSISU=
6241           fi
6242       fi
6243     elif test -z "$CROSS_COMPILE"; then
6244       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.])
6245     else
6246       MAKENSISU=
6247     fi
6250 dnl ========================================================
6251 dnl Web App Runtime
6252 dnl ========================================================
6253 MOZ_ARG_DISABLE_BOOL(webapp-runtime,
6254 [  --disable-webapp-runtime  Disable Web App Runtime],
6255     MOZ_WEBAPP_RUNTIME=,
6256     MOZ_WEBAPP_RUNTIME=1)
6257 if test "$MOZ_WIDGET_TOOLKIT" != "windows" -a "$MOZ_WIDGET_TOOLKIT" != "cocoa" -a "$MOZ_WIDGET_TOOLKIT" != "gtk2"; then
6258     MOZ_WEBAPP_RUNTIME=
6260 if test "$OS_ARCH" = "WINNT" -a -z "$MAKENSISU" -a -n "$CROSS_COMPILE"; then
6261     MOZ_WEBAPP_RUNTIME=
6263 AC_SUBST(MOZ_WEBAPP_RUNTIME)
6264 if test "$MOZ_WEBAPP_RUNTIME"; then
6265     AC_DEFINE(MOZ_WEBAPP_RUNTIME)
6268 AC_MSG_CHECKING([for tar archiver])
6269 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6270 if test -z "$TAR"; then
6271     AC_MSG_ERROR([no tar archiver found in \$PATH])
6273 AC_MSG_RESULT([$TAR])
6274 AC_SUBST(TAR)
6276 AC_MSG_CHECKING([for wget])
6277 AC_CHECK_PROGS(WGET, wget, "")
6278 AC_MSG_RESULT([$WGET])
6279 AC_SUBST(WGET)
6281 dnl ========================================================
6282 dnl Signing
6283 dnl ========================================================
6285 if test -n "$MOZ_SIGN_CMD"; then
6286     AC_DEFINE(MOZ_SIGNING)
6289 dnl ========================================================
6290 dnl Maintenance Service
6291 dnl ========================================================
6293 MOZ_ARG_ENABLE_BOOL(maintenance-service,
6294 [  --enable-maintenance-service       Enable building of maintenanceservice],
6295     MOZ_MAINTENANCE_SERVICE=1,
6296     MOZ_MAINTENANCE_SERVICE= )
6298 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
6299   if test "$OS_ARCH" = "WINNT"; then
6300     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
6301   else
6302     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
6303   fi
6306 dnl ========================================================
6307 dnl Verify MAR signatures
6308 dnl ========================================================
6310 MOZ_ARG_ENABLE_BOOL(verify-mar,
6311 [  --enable-verify-mar     Enable verifying MAR signatures],
6312     MOZ_VERIFY_MAR_SIGNATURE=1,
6313     MOZ_VERIFY_MAR_SIGNATURE= )
6315 if test -n "$MOZ_VERIFY_MAR_SIGNATURE"; then
6316   if test "$OS_ARCH" = "WINNT"; then
6317     AC_DEFINE(MOZ_VERIFY_MAR_SIGNATURE)
6318   else
6319     AC_MSG_ERROR([Can only build with --enable-verify-mar with a Windows target])
6320   fi
6323 dnl ========================================================
6324 dnl Enable building the signmar program.
6325 dnl This option is much different than the --enable-verify-mar option.
6326 dnl --enable-verify-mar is for enabling the verification check on MAR
6327 dnl files in the updater.  The --enable-signmar option is for building
6328 dnl the signmar program.
6329 dnl ========================================================
6331 MOZ_ARG_ENABLE_BOOL(signmar,
6332 [  --enable-signmar     Enable building the signmar program],
6333     MOZ_ENABLE_SIGNMAR=1,
6334     MOZ_ENABLE_SIGNMAR= )
6336 if test -n "$MOZ_ENABLE_SIGNMAR"; then
6337   AC_DEFINE(MOZ_ENABLE_SIGNMAR)
6340 dnl ========================================================
6341 dnl Updater
6342 dnl ========================================================
6344 MOZ_ARG_DISABLE_BOOL(updater,
6345 [  --disable-updater       Disable building of updater],
6346     MOZ_UPDATER=,
6347     MOZ_UPDATER=1 )
6349 if test -n "$MOZ_UPDATER"; then
6350     AC_DEFINE(MOZ_UPDATER)
6353 # tools/update-packaging is not checked out by default.
6354 MOZ_ARG_ENABLE_BOOL(update-packaging,
6355 [  --enable-update-packaging
6356                           Enable tools/update-packaging],
6357     MOZ_UPDATE_PACKAGING=1,
6358     MOZ_UPDATE_PACKAGING= )
6359 AC_SUBST(MOZ_UPDATE_PACKAGING)
6361 dnl ========================================================
6362 dnl build the tests by default
6363 dnl ========================================================
6364 MOZ_ARG_DISABLE_BOOL(tests,
6365 [  --disable-tests         Do not build test libraries & programs],
6366     ENABLE_TESTS=,
6367     ENABLE_TESTS=1 )
6369 # Currently GTest is linked into libxul. This means it must be off by default.
6370 # Follow up will be to generate libxul.so and libxul-test.so to let GTest
6371 # be compiled along with ENABLE_TESTS
6372 MOZ_ARG_ENABLE_BOOL(gtest,
6373 [  --enable-gtest
6374                           Enable GTest libxul unit test.],
6375     MOZ_ENABLE_GTEST=1,
6376     MOZ_ENABLE_GTEST= )
6378 if test -n "$MOZ_ENABLE_GTEST"; then
6379     if test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "Linux"; then
6380         MOZ_ENABLE_GTEST=1
6381         GTEST_HAS_RTTI=0
6382         AC_DEFINE(MOZ_ENABLE_GTEST)
6383         AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0)
6384         AC_SUBST(MOZ_ENABLE_GTEST)
6385         AC_SUBST(GTEST_HAS_RTTI)
6386     else
6387         AC_MSG_ERROR([Cannot build with --enable-gtest on this platform.])
6388     fi
6391 dnl ========================================================
6392 dnl parental controls (for Windows Vista)
6393 dnl ========================================================
6394 MOZ_ARG_DISABLE_BOOL(parental-controls,
6395 [  --disable-parental-controls
6396                           Do not build parental controls],
6397    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6398    MOZ_DISABLE_PARENTAL_CONTROLS=)
6399 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6400     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6403 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6405 dnl ========================================================
6406 dnl = Disable DOMCrypto
6407 dnl ========================================================
6408 if test -n "$MOZ_DISABLE_CRYPTOLEGACY"; then
6409     AC_DEFINE(MOZ_DISABLE_CRYPTOLEGACY)
6411 AC_SUBST(MOZ_DISABLE_CRYPTOLEGACY)
6413 dnl ========================================================
6414 dnl =
6415 dnl = Module specific options
6416 dnl =
6417 dnl ========================================================
6418 MOZ_ARG_HEADER(Individual module options)
6420 dnl ========================================================
6421 dnl = Disable feed handling components
6422 dnl ========================================================
6423 MOZ_ARG_DISABLE_BOOL(feeds,
6424 [  --disable-feeds         Disable feed handling and processing components],
6425     MOZ_FEEDS=,
6426     MOZ_FEEDS=1 )
6427 if test -n "$MOZ_FEEDS"; then
6428     AC_DEFINE(MOZ_FEEDS)
6429 else
6430     if test "$MOZ_BUILD_APP" = "browser"; then
6431         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6432     fi
6435 dnl ========================================================
6436 dnl Check for sqlite
6437 dnl ========================================================
6439 MOZ_NATIVE_SQLITE=
6440 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6441 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6442 MOZ_NATIVE_SQLITE=1,
6443 MOZ_NATIVE_SQLITE= )
6445 if test -z "$MOZ_NATIVE_SQLITE"
6446 then
6447     SQLITE_CFLAGS=
6448     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
6449 else
6450     dnl ============================
6451     dnl === SQLite Version check ===
6452     dnl ============================
6453     dnl Check to see if the system SQLite package is new enough.
6454     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6456     dnl ==================================
6457     dnl === SQLITE_SECURE_DELETE check ===
6458     dnl ==================================
6459     dnl Check to see if the system SQLite package is compiled with
6460     dnl SQLITE_SECURE_DELETE enabled.
6461     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
6462     _SAVE_CFLAGS="$CFLAGS"
6463     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6464     _SAVE_LIBS="$LIBS"
6465     LIBS="$LIBS $SQLITE_LIBS"
6466     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6467         AC_TRY_RUN([
6468             #include "sqlite3.h"
6470             int main(int argc, char **argv){
6471               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
6472             }],
6473             ac_cv_sqlite_secure_delete=yes,
6474             ac_cv_sqlite_secure_delete=no,
6475             ac_cv_sqlite_secure_delete=no
6476         )
6477     ])
6478     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6479     CFLAGS="$_SAVE_CFLAGS"
6480     LIBS="$_SAVE_LIBS"
6481     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6482         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
6483     fi
6485     dnl ===============================
6486     dnl === SQLITE_THREADSAFE check ===
6487     dnl ===============================
6488     dnl Check to see if the system SQLite package is compiled with
6489     dnl SQLITE_THREADSAFE enabled.
6490     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
6491     _SAVE_CFLAGS="$CFLAGS"
6492     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6493     _SAVE_LIBS="$LIBS"
6494     LIBS="$LIBS $SQLITE_LIBS"
6495     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
6496         AC_TRY_RUN([
6497             #include "sqlite3.h"
6499             int main(int argc, char **argv){
6500               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
6501             }],
6502             ac_cv_sqlite_threadsafe=yes,
6503             ac_cv_sqlite_threadsafe=no,
6504             ac_cv_sqlite_threadsafe=no
6505         )
6506     ])
6507     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
6508     CFLAGS="$_SAVE_CFLAGS"
6509     LIBS="$_SAVE_LIBS"
6510     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
6511         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
6512     fi
6514     dnl ================================
6515     dnl === SQLITE_ENABLE_FTS3 check ===
6516     dnl ================================
6517     dnl check to see if the system SQLite package is compiled with
6518     dnl SQLITE_ENABLE_FTS3 enabled.
6519     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
6520     _SAVE_CFLAGS="$CFLAGS"
6521     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6522     _SAVE_LIBS="$LIBS"
6523     LIBS="$LIBS $SQLITE_LIBS"
6524     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
6525         AC_TRY_RUN([
6526             #include "sqlite3.h"
6528             int main(int argc, char **argv){
6529               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
6530             }],
6531             ac_cv_sqlite_enable_fts3=yes,
6532             ac_cv_sqlite_enable_fts3=no,
6533             ac_cv_sqlite_enable_fts3=no
6534         )
6535     ])
6536     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
6537     CFLAGS="$_SAVE_CFLAGS"
6538     LIBS="$_SAVE_LIBS"
6539     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
6540         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
6541     fi
6543     dnl =========================================
6544     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
6545     dnl =========================================
6546     dnl check to see if the system SQLite package is compiled with
6547     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
6548     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
6549     _SAVE_CFLAGS="$CFLAGS"
6550     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6551     _SAVE_LIBS="$LIBS"
6552     LIBS="$LIBS $SQLITE_LIBS"
6553     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
6554         AC_TRY_RUN([
6555             #include "sqlite3.h"
6557             int main(int argc, char **argv){
6558               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
6559             }],
6560             ac_cv_sqlite_enable_unlock_notify=yes,
6561             ac_cv_sqlite_enable_unlock_notify=no,
6562             ac_cv_sqlite_enable_unlock_notify=no
6563         )
6564     ])
6565     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
6566     CFLAGS="$_SAVE_CFLAGS"
6567     LIBS="$_SAVE_LIBS"
6568     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
6569         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
6570     fi
6573 if test -n "$MOZ_NATIVE_SQLITE"; then
6574     AC_DEFINE(MOZ_NATIVE_SQLITE)
6576 AC_SUBST(MOZ_NATIVE_SQLITE)
6578 dnl ========================================================
6579 dnl = Enable help viewer (off by default)
6580 dnl ========================================================
6581 if test -n "$MOZ_HELP_VIEWER"; then
6582      dnl Do this if defined in confvars.sh
6583      AC_DEFINE(MOZ_HELP_VIEWER)
6586 dnl ========================================================
6587 dnl = Enable safe browsing (anti-phishing)
6588 dnl ========================================================
6589 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6590 [  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation],
6591     MOZ_SAFE_BROWSING=1,
6592     MOZ_SAFE_BROWSING= )
6593 if test -n "$MOZ_SAFE_BROWSING"; then
6594     AC_DEFINE(MOZ_SAFE_BROWSING)
6596 AC_SUBST(MOZ_SAFE_BROWSING)
6598 dnl ========================================================
6599 dnl = Enable url-classifier
6600 dnl ========================================================
6601 dnl Implicitly enabled by default if building with safe-browsing
6602 if test -n "$MOZ_SAFE_BROWSING"; then
6603     MOZ_URL_CLASSIFIER=1
6605 MOZ_ARG_ENABLE_BOOL(url-classifier,
6606 [  --enable-url-classifier Enable url classifier module],
6607     MOZ_URL_CLASSIFIER=1,
6608     MOZ_URL_CLASSIFIER= )
6609 if test -n "$MOZ_URL_CLASSIFIER"; then
6610     AC_DEFINE(MOZ_URL_CLASSIFIER)
6612 AC_SUBST(MOZ_URL_CLASSIFIER)
6614 dnl ========================================================
6615 dnl = Disable zipwriter
6616 dnl ========================================================
6617 MOZ_ARG_DISABLE_BOOL(zipwriter,
6618 [  --disable-zipwriter     Disable zipwriter component],
6619     MOZ_ZIPWRITER=,
6620     MOZ_ZIPWRITER=1 )
6621 AC_SUBST(MOZ_ZIPWRITER)
6623 dnl ========================================================
6624 dnl = libconic
6625 dnl ========================================================
6626 dnl superseded by QtNetwork starting from 4.7
6627 MOZ_ENABLE_LIBCONIC=1
6629 if test -n "$MOZ_ENABLE_QT"; then
6630   if test "$MOZ_ENABLE_QTNETWORK"; then
6631     MOZ_ENABLE_LIBCONIC=
6632   fi
6635 MOZ_ARG_DISABLE_BOOL(libconic,
6636 [  --disable-libconic      Disable libconic],
6637     MOZ_ENABLE_LIBCONIC=,
6638     MOZ_ENABLE_LIBCONIC=1 )
6640 if test -n "$MOZ_ENABLE_LIBCONIC"; then
6641     PKG_CHECK_MODULES(LIBCONIC, conic,
6642                       MOZ_ENABLE_LIBCONIC=1,
6643                       MOZ_ENABLE_LIBCONIC=)
6645 if test "$MOZ_ENABLE_LIBCONIC"; then
6646     AC_DEFINE(MOZ_ENABLE_LIBCONIC)
6649 AC_SUBST(MOZ_ENABLE_LIBCONIC)
6650 AC_SUBST(LIBCONIC_CFLAGS)
6651 AC_SUBST(LIBCONIC_LIBS)
6653 dnl ========================================================
6654 dnl = Maemo checks
6655 dnl ========================================================
6657 MAEMO_SDK_TARGET_VER=-1
6659 MOZ_ARG_WITH_STRING(maemo-version,
6660 [  --with-maemo-version=MAEMO_SDK_TARGET_VER
6661                           Maemo SDK Version],
6662   MAEMO_SDK_TARGET_VER=$withval)
6664 case "$MAEMO_SDK_TARGET_VER" in
6666     MOZ_PLATFORM_MAEMO=5
6667     ;;
6670     MOZ_PLATFORM_MAEMO=6
6671     ;;
6674     dnl We aren't compiling for Maemo, move on.
6675     ;;
6677     AC_MSG_ERROR([Unknown Maemo Version.  Try setting --with-maemo-version to 5 or 6.])
6678     ;;
6679 esac
6681 if test $MOZ_PLATFORM_MAEMO; then
6682    AC_DEFINE_UNQUOTED([MOZ_PLATFORM_MAEMO], $MOZ_PLATFORM_MAEMO)
6684    if test -z "$MOZ_ENABLE_DBUS"; then
6685        AC_MSG_ERROR([DBus is required when building for Maemo])
6686    fi
6688    MOZ_GFX_OPTIMIZE_MOBILE=1
6689    MOZ_GL_DEFAULT_PROVIDER=EGL
6690    MOZ_MAEMO_LIBLOCATION=
6692    if test $MOZ_PLATFORM_MAEMO = 5; then
6693       dnl if we have Xcomposite we should also have Xdamage and Xfixes
6694       MOZ_CHECK_HEADERS([X11/extensions/Xdamage.h], [],
6695           [AC_MSG_ERROR([Couldn't find X11/extensions/Xdamage.h which is required for composited plugins.])])
6696       AC_CHECK_LIB(Xcomposite, XCompositeRedirectWindow, [XCOMPOSITE_LIBS="-lXcomposite -lXdamage -lXfixes"],
6697                    [MISSING_X="$MISSING_X -lXcomposite"], $XLIBS)
6699       AC_SUBST(XCOMPOSITE_LIBS)
6701       PKG_CHECK_MODULES(LIBHILDONMIME,libhildonmime, _LIB_FOUND=1, _LIB_FOUND=)
6702       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONMIME_LIBS"
6703       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONMIME_CFLAGS"
6704       if test -z "$_LIB_FOUND"; then
6705          AC_MSG_ERROR([Hildon Mime is required when building for Maemo])
6706       fi
6709       PKG_CHECK_MODULES(LIBOSSO,libosso, _LIB_FOUND=1, _LIB_FOUND=)
6710       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBOSSO_LIBS"
6711       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBOSSO_CFLAGS"
6712       if test -z "$_LIB_FOUND"; then
6713          AC_MSG_ERROR([LibOSSO is required when building for Maemo])
6714       fi
6716       PKG_CHECK_MODULES(LIBHILDONFM,hildon-fm-2, _LIB_FOUND=1, _LIB_FOUND=)
6717       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONFM_LIBS"
6718       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONFM_CFLAGS"
6719       if test -z "$_LIB_FOUND"; then
6720          AC_MSG_ERROR([Hildon FM-2 is required when building for Maemo])
6721       fi
6723    fi
6724    if test $MOZ_PLATFORM_MAEMO = 6; then
6726       PKG_CHECK_MODULES(LIBCONTENTMANAGER, ContentManager QtSparql,
6727                         _LIB_FOUND=1,
6728                         _LIB_FOUND=)
6729       if test "$_LIB_FOUND"; then
6730          MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTMANAGER_LIBS"
6731          MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTMANAGER_CFLAGS"
6732          MOZ_ENABLE_CONTENTMANAGER=1
6733          AC_DEFINE(MOZ_ENABLE_CONTENTMANAGER)
6734       else
6735          AC_MSG_WARN([Cannot find libcontentmanager and or QtSparql building for Maemo 6])
6736       fi
6737       AC_SUBST(MOZ_ENABLE_CONTENTMANAGER)
6739       dnl ========================================================
6740       dnl = Enable meego libcontentaction
6741       dnl ========================================================
6742       MOZ_ARG_ENABLE_BOOL(meegocontentaction,
6743       [  --enable-meegocontentaction           Enable meegocontentaction support],
6744          MOZ_MEEGOCONTENTACTION=1,
6745          MOZ_MEEGOCONTENTACTION=)
6747       if test -n "$MOZ_MEEGOCONTENTACTION"; then
6749          PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
6750          if test "$_LIB_FOUND"; then
6751             MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTACTION_LIBS"
6752             MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTACTION_CFLAGS"
6753             MOZ_ENABLE_CONTENTACTION=1
6754             AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
6755             AC_SUBST(MOZ_ENABLE_CONTENTACTION)
6756          fi
6757       fi
6759       MOZ_ARG_ENABLE_BOOL(meegotouch,
6760       [  --enable-meegotouch  Enable meegotouch support],
6761          MOZ_MEEGOTOUCHENABLED=1,
6762          MOZ_MEEGOTOUCHENABLED=)
6764       if test -n "$MOZ_MEEGOTOUCHENABLED"; then
6765           PKG_CHECK_MODULES(MOZ_MEEGOTOUCH, meegotouchcore, _LIB_FOUND=1, _LIB_FOUND=)
6766           if test "$_LIB_FOUND"; then
6767               MOZ_QT_CFLAGS="$MOZ_MEEGOTOUCH_CFLAGS $MOZ_QT_CFLAGS"
6768               MOZ_QT_LIBS="$MOZ_MEEGOTOUCH_LIBS $MOZ_QT_LIBS"
6769               AC_DEFINE(MOZ_ENABLE_MEEGOTOUCH)
6770           else
6771               AC_MSG_WARN([Cannot meegotouchcore-dev. Disabling Meegotouch support.])
6772           fi
6773       fi
6774    fi
6776    PKG_CHECK_MODULES(LIBLOCATION,liblocation, _LIB_FOUND=1, _LIB_FOUND=)
6777    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBLOCATION_LIBS"
6778    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBLOCATION_CFLAGS"
6779    if test "$_LIB_FOUND"; then
6780       MOZ_MAEMO_LIBLOCATION=1
6781       AC_DEFINE(MOZ_MAEMO_LIBLOCATION)
6782    else
6783       AC_MSG_WARN([Cannot liblocation-dev. Disabling Maemo geolocation.])
6784    fi
6785    AC_SUBST(MOZ_MAEMO_LIBLOCATION)
6787    PKG_CHECK_MODULES(LIBMEEGOTOUCHSHARE, ShareUiInterface-maemo-meegotouch >= 0.3.31 mdatauri, _LIB_FOUND=1, _LIB_FOUND=)
6788    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBMEEGOTOUCHSHARE_LIBS"
6789    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBMEEGOTOUCHSHARE_CFLAGS"
6790    if test "$_LIB_FOUND"; then
6791       MOZ_ENABLE_MEEGOTOUCHSHARE=1
6792       AC_DEFINE(MOZ_ENABLE_MEEGOTOUCHSHARE)
6793    else
6794       AC_MSG_WARN([Cannot find maemo-meegotouch-interfaces-dev or libmdatauri-dev. Disabling meegotouch share ui.])
6795    fi
6796    AC_SUBST(MOZ_ENABLE_MEEGOTOUCHSHARE)
6798    AC_SUBST(MOZ_PLATFORM_MAEMO_LIBS)
6799    AC_SUBST(MOZ_PLATFORM_MAEMO_CFLAGS)
6802 dnl ========================================================
6803 dnl GL provider
6804 dnl ========================================================
6805 MOZ_GL_PROVIDER=
6806 MOZ_ARG_WITH_STRING(gl-provider,
6807 [  --with-gl-provider=ID
6808                           Set GL provider backend type],
6809 [ val=`echo $withval`
6810     MOZ_GL_PROVIDER="$val"])
6812 if test -n "$MOZ_GL_PROVIDER"; then
6813 MOZ_GL_DEFAULT_PROVIDER=$MOZ_GL_PROVIDER
6814 AC_SUBST(MOZ_GL_PROVIDER)
6815 AC_DEFINE_UNQUOTED(MOZ_GL_PROVIDER, GLContextProvider$MOZ_GL_PROVIDER)
6817 AC_SUBST(MOZ_GL_DEFAULT_PROVIDER)
6818 AC_DEFINE_UNQUOTED(GL_PROVIDER_$MOZ_GL_DEFAULT_PROVIDER)
6820 dnl ========================================================
6821 dnl = faststripe theme
6822 dnl ========================================================
6823 MOZ_ARG_ENABLE_BOOL(faststripe,
6824 [  --enable-faststripe     Use faststripe theme],
6825     MOZ_THEME_FASTSTRIPE=1,
6826     MOZ_THEME_FASTSTRIPE= )
6827 AC_SUBST(MOZ_THEME_FASTSTRIPE)
6829 dnl ========================================================
6830 dnl =
6831 dnl = Feature options that require extra sources to be pulled
6832 dnl =
6833 dnl ========================================================
6834 dnl MOZ_ARG_HEADER(Features that require extra sources)
6836 dnl ========================================================
6837 dnl =
6838 dnl = Debugging Options
6839 dnl =
6840 dnl ========================================================
6841 MOZ_ARG_HEADER(Debugging and Optimizations)
6843 dnl ========================================================
6844 dnl = Disable building with debug info.
6845 dnl = Debugging is OFF by default
6846 dnl ========================================================
6847 if test -z "$MOZ_DEBUG_FLAGS"; then
6848   MOZ_DEBUG_FLAGS="-g"
6851 MOZ_ARG_ENABLE_STRING(debug,
6852 [  --enable-debug[=DBG]    Enable building with developer debug info
6853                            (using compiler flags DBG)],
6854 [ if test "$enableval" != "no"; then
6855     MOZ_DEBUG=1
6856     if test -n "$enableval" -a "$enableval" != "yes"; then
6857         MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6858         _MOZ_DEBUG_FLAGS_SET=1
6859     fi
6860   else
6861     MOZ_DEBUG=
6862   fi ],
6863   MOZ_DEBUG=)
6865 MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG -DTRACING"
6866 MOZ_ARG_WITH_STRING(debug-label,
6867 [  --with-debug-label=LABELS
6868                           Define DEBUG_<value> for each comma-separated
6869                           value given.],
6870 [ for option in `echo $withval | sed 's/,/ /g'`; do
6871     MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${option}"
6872 done])
6874 MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
6876 if test -n "$MOZ_DEBUG"; then
6877     AC_MSG_CHECKING([for valid debug flags])
6878     _SAVE_CFLAGS=$CFLAGS
6879     CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS"
6880     AC_TRY_COMPILE([#include <stdio.h>],
6881         [printf("Hello World\n");],
6882         _results=yes,
6883         _results=no)
6884     AC_MSG_RESULT([$_results])
6885     if test "$_results" = "no"; then
6886         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_DEBUG_FLAGS])
6887     fi
6888     CFLAGS=$_SAVE_CFLAGS
6891 dnl ========================================================
6892 dnl enable mobile optimizations
6893 dnl ========================================================
6894 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
6895 [  --enable-mobile-optimize
6896                           Enable mobile optimizations],
6897     MOZ_GFX_OPTIMIZE_MOBILE=1)
6899 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
6901 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
6902     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
6905 dnl ========================================================
6906 dnl = Enable code optimization. ON by default.
6907 dnl ========================================================
6908 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
6909         MOZ_OPTIMIZE_FLAGS="-O"
6912 MOZ_ARG_ENABLE_STRING(optimize,
6913 [  --disable-optimize      Disable compiler optimization
6914   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
6915 [ if test "$enableval" != "no"; then
6916     MOZ_OPTIMIZE=1
6917     if test -n "$enableval" -a "$enableval" != "yes"; then
6918         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
6919         MOZ_OPTIMIZE=2
6920     fi
6921 else
6922     MOZ_OPTIMIZE=
6923 fi ], MOZ_OPTIMIZE=1)
6925 MOZ_SET_FRAMEPTR_FLAGS
6927 if test "$COMPILE_ENVIRONMENT"; then
6928 if test -n "$MOZ_OPTIMIZE"; then
6929     AC_MSG_CHECKING([for valid optimization flags])
6930     _SAVE_CFLAGS=$CFLAGS
6931     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
6932     AC_TRY_COMPILE([#include <stdio.h>],
6933         [printf("Hello World\n");],
6934         _results=yes,
6935         _results=no)
6936     AC_MSG_RESULT([$_results])
6937     if test "$_results" = "no"; then
6938         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
6939     fi
6940     CFLAGS=$_SAVE_CFLAGS
6942 fi # COMPILE_ENVIRONMENT
6944 AC_SUBST(MOZ_OPTIMIZE)
6945 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
6946 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
6947 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
6948 AC_SUBST(MOZ_ALLOW_HEAP_EXECUTE_FLAGS)
6949 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
6950 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
6952 dnl ========================================================
6953 dnl = Enable generation of debug symbols
6954 dnl ========================================================
6955 MOZ_ARG_ENABLE_STRING(debug-symbols,
6956 [  --enable-debug-symbols[=DBG]
6957                           Enable debugging symbols (using compiler flags DBG)],
6958 [ if test "$enableval" != "no"; then
6959       MOZ_DEBUG_SYMBOLS=1
6960       if test -n "$enableval" -a "$enableval" != "yes"; then
6961           if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
6962               MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6963           else
6964               AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
6965           fi
6966       fi
6967   else
6968       MOZ_DEBUG_SYMBOLS=
6969   fi ],
6970   MOZ_DEBUG_SYMBOLS=1)
6972 if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
6973     AC_DEFINE(MOZ_DEBUG_SYMBOLS)
6974     export MOZ_DEBUG_SYMBOLS
6977 dnl ========================================================
6978 dnl = Enable any treating of compile warnings as errors
6979 dnl ========================================================
6980 MOZ_ARG_ENABLE_BOOL(warnings-as-errors,
6981 [  --enable-warnings-as-errors
6982                           Enable treating of warnings as errors],
6983     MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
6984     MOZ_ENABLE_WARNINGS_AS_ERRORS=)
6985 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
6986    WARNINGS_AS_ERRORS=''
6989 dnl ========================================================
6990 dnl = Disable runtime logging checks
6991 dnl ========================================================
6992 MOZ_ARG_DISABLE_BOOL(logging,
6993 [  --disable-logging       Disable logging facilities],
6994     NS_DISABLE_LOGGING=1,
6995     NS_DISABLE_LOGGING= )
6996 if test "$NS_DISABLE_LOGGING"; then
6997     AC_DEFINE(NS_DISABLE_LOGGING)
6998 else
6999     AC_DEFINE(MOZ_LOGGING)
7002 dnl ========================================================
7003 dnl = This will enable logging of addref, release, ctor, dtor.
7004 dnl ========================================================
7005 _ENABLE_LOGREFCNT=42
7006 MOZ_ARG_ENABLE_BOOL(logrefcnt,
7007 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
7008     _ENABLE_LOGREFCNT=1,
7009     _ENABLE_LOGREFCNT= )
7010 if test "$_ENABLE_LOGREFCNT" = "1"; then
7011     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
7012 elif test -z "$_ENABLE_LOGREFCNT"; then
7013     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
7016 dnl ========================================================
7017 dnl moz_dump_painting
7018 dnl ========================================================
7019 MOZ_ARG_ENABLE_BOOL(dump-painting,
7020 [  --enable-dump-painting          Enable paint debugging.],
7021     MOZ_DUMP_PAINTING=1,
7022     MOZ_DUMP_PAINTING= )
7023 if test -n "$MOZ_DUMP_PAINTING"; then
7024     AC_DEFINE(MOZ_DUMP_PAINTING)
7025     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
7027 if test -n "$MOZ_DEBUG"; then
7028     AC_DEFINE(MOZ_DUMP_PAINTING)
7031 dnl ========================================================
7032 dnl = Enable trace malloc
7033 dnl ========================================================
7034 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
7035 MOZ_ARG_ENABLE_BOOL(trace-malloc,
7036 [  --enable-trace-malloc   Enable malloc tracing; also disables DMD and jemalloc],
7037     NS_TRACE_MALLOC=1,
7038     NS_TRACE_MALLOC= )
7039 if test "$NS_TRACE_MALLOC"; then
7040   # Please, Mr. Linker Man, don't take away our symbol names
7041   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
7042   USE_ELF_DYNSTR_GC=
7043   AC_DEFINE(NS_TRACE_MALLOC)
7045 AC_SUBST(NS_TRACE_MALLOC)
7047 dnl ========================================================
7048 dnl = Enable DMD
7049 dnl ========================================================
7051 MOZ_ARG_ENABLE_BOOL(dmd,
7052 [  --enable-dmd            Enable DMD; also enables jemalloc and replace-malloc],
7053     MOZ_DMD=1,
7054     MOZ_DMD= )
7056 if test "$NS_TRACE_MALLOC"; then        # trace-malloc disables DMD
7057     MOZ_DMD=
7059 if test "$MOZ_DMD"; then
7060     USE_ELF_DYNSTR_GC=
7061     AC_DEFINE(MOZ_DMD)
7063     if test "${CPU_ARCH}" = "arm"; then
7064         CFLAGS="$CFLAGS -funwind-tables"
7065         CXXFLAGS="$CXXFLAGS -funwind-tables"
7066     fi
7068     MOZ_MEMORY=1                        # DMD enables jemalloc
7069     MOZ_REPLACE_MALLOC=1                # DMD enables replace-malloc
7071 AC_SUBST(MOZ_DMD)
7073 dnl ========================================================
7074 dnl = Enable jemalloc
7075 dnl ========================================================
7076 MOZ_ARG_ENABLE_BOOL(jemalloc,
7077 [  --enable-jemalloc       Replace memory allocator with jemalloc],
7078     MOZ_MEMORY=1,
7079     MOZ_MEMORY=)
7081 if test "$NS_TRACE_MALLOC"; then
7082     MOZ_MEMORY=
7085 if test "${OS_TARGET}" = "Android"; then
7086   dnl On Android, we use WRAP_LDFLAGS to link everything to mozglue
7087   :
7088 elif test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "OS2"; then
7089   dnl On Windows, OSX and OS2, we want to link all our binaries against mozglue
7090   if test -z "$GNU_CC"; then
7091     MOZ_GLUE_LDFLAGS='$(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
7092   else
7093     MOZ_GLUE_LDFLAGS='-L$(LIBXUL_DIST)/lib $(call EXPAND_LIBNAME,mozglue)'
7094   fi
7095 else
7096   dnl On other Unix systems, we only want to link executables against mozglue
7097   MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
7098   dnl On other Unix systems, where mozglue is a static library, jemalloc is
7099   dnl separated for the SDK, so we need to add it here.
7100   if test "$MOZ_MEMORY" = 1 -o \( "$LIBXUL_SDK" -a -f "$LIBXUL_SDK/lib/${LIB_PREFIX}memory.${LIB_SUFFIX}" \); then
7101     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib)'
7102   fi
7103   MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(MKSHLIB_UNFORCE_ALL)'
7104   if test -n "$GNU_CC"; then
7105     dnl And we need mozglue symbols to be exported.
7106     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
7107   fi
7108   if test "$MOZ_LINKER" = 1; then
7109     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS $MOZ_ZLIB_LIBS"
7110   fi
7113 dnl ========================================================
7114 dnl = Enable dynamic replacement of malloc implementation
7115 dnl ========================================================
7116 MOZ_ARG_ENABLE_BOOL(replace-malloc,
7117 [  --enable-replace-malloc   Enable ability to dynamically replace the malloc implementation],
7118     MOZ_REPLACE_MALLOC=1,
7119     MOZ_REPLACE_MALLOC= )
7121 if test -n "$MOZ_REPLACE_MALLOC" -a -z "$MOZ_MEMORY"; then
7122     dnl We don't want to enable jemalloc unconditionally because it may be a
7123     dnl deliberate choice not to enable it (bug 702250, for instance)
7124     AC_MSG_ERROR([--enable-replace-malloc requires --enable-jemalloc])
7125 elif test -n "$MOZ_REPLACE_MALLOC"; then
7126     MOZ_NATIVE_JEMALLOC=
7128     dnl Replace-malloc Mac linkage quirks
7129     if test -n "$MACOSX_DEPLOYMENT_TARGET"; then
7130         AC_CACHE_CHECK([how to do weak dynamic linking],
7131             ac_cv_weak_dynamic_linking,
7132             [echo 'extern void foo() __attribute__((weak_import));int bar() { if (foo) foo(); return 0; }' > conftest.c
7133              if AC_TRY_COMMAND([${CC-cc} -o conftest${DLL_SUFFIX} $CFLAGS -dynamiclib $LDFLAGS -Wl,-U,_foo conftest.c $LIBS 1>&5]) &&
7134                 test -s conftest${DLL_SUFFIX}; then
7135                  dnl There are several ways the linker can put link edit rules in a binary:
7136                  dnl - classic info only (for OSX < 10.6)
7137                  dnl - dyld info only
7138                  dnl - both
7139                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO_ONLY" > /dev/null; then
7140                      _CLASSIC_INFO=
7141                  else
7142                      _CLASSIC_INFO=1
7143                  fi
7144                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO" > /dev/null; then
7145                      _DYLD_INFO=1
7146                  else
7147                      _DYLD_INFO=
7148                  fi
7149                  dnl With classic info, we need to build with -flat_namespace.
7150                  dnl With dyld info, Xcode 4.5 does the right thing without additional flags,
7151                  dnl but Xcode < 4.5 requires a dummy library and -flat_namespace because it
7152                  dnl forgets to set the weak flag in the dyld info.
7153                  dnl See http://glandium.org/blog/?p=2764 for more details.
7154                  dnl
7155                  dnl Values for ac_cv_weak_dynamic_linking, and subsequently
7156                  dnl MOZ_REPLACE_MALLOC_LINKAGE are thus:
7157                  dnl - "flat namespace" when -flat_namespace alone is needed
7158                  dnl - "dummy library" when a dummy library and -flat_namespace are needed
7159                  dnl - "compiler support" when nothing is needed
7160                  if test -n "$_DYLD_INFO" && dyldinfo -bind conftest${DLL_SUFFIX} 2> /dev/null | grep "_foo (weak import)" > /dev/null; then
7161                      if test -n "$_CLASSIC_INFO"; then
7162                          ac_cv_weak_dynamic_linking="flat namespace"
7163                      else
7164                          ac_cv_weak_dynamic_linking="compiler support"
7165                      fi
7166                  else
7167                      if test -n "$_DYLD_INFO"; then
7168                          ac_cv_weak_dynamic_linking="dummy library"
7169                      else
7170                          ac_cv_weak_dynamic_linking="flat namespace"
7171                      fi
7172                  fi
7173              else
7174                  AC_ERROR([couldn't compile a simple C file])
7175              fi
7176              rm -rf conftest*])
7177         MOZ_REPLACE_MALLOC_LINKAGE="$ac_cv_weak_dynamic_linking"
7178     fi
7180 AC_SUBST(MOZ_REPLACE_MALLOC)
7181 AC_SUBST(MOZ_REPLACE_MALLOC_LINKAGE)
7183 dnl ========================================================
7184 dnl = Jemalloc build setup
7185 dnl ========================================================
7186 if test -z "$MOZ_MEMORY"; then
7187   if test -n "$MOZ_JEMALLOC3" -a -z "$MOZ_REPLACE_MALLOC"; then
7188     MOZ_NATIVE_JEMALLOC=1
7189     AC_CHECK_FUNCS(mallctl nallocm,,
7190       [MOZ_NATIVE_JEMALLOC=
7191        break])
7192     if test -n "$MOZ_NATIVE_JEMALLOC"; then
7193       MOZ_MEMORY=1
7194       AC_DEFINE(MOZ_MEMORY)
7195       AC_DEFINE(MOZ_JEMALLOC3)
7196       AC_DEFINE(MOZ_NATIVE_JEMALLOC)
7197     fi
7198   fi
7199   case "${target}" in
7200     *-mingw*)
7201       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
7202         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.])
7203       fi
7204       ;;
7205   esac
7206 else
7207   dnl Don't try to run compiler tests on Windows
7208   if test "$OS_ARCH" = "WINNT"; then
7209     if test -z "$HAVE_64BIT_OS"; then
7210       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7211     else
7212       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7213     fi
7214   else
7215     AC_CHECK_SIZEOF([int *], [4])
7216     case "${ac_cv_sizeof_int_p}" in
7217     4)
7218       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
7219       ;;
7220     8)
7221       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
7222       ;;
7223     *)
7224       AC_MSG_ERROR([Unexpected pointer size])
7225       ;;
7226     esac
7227   fi
7229   AC_DEFINE(MOZ_MEMORY)
7230   if test -n "$MOZ_JEMALLOC3"; then
7231     AC_DEFINE(MOZ_JEMALLOC3)
7232   fi
7233   if test "x$MOZ_DEBUG" = "x1"; then
7234     AC_DEFINE(MOZ_MEMORY_DEBUG)
7235   fi
7236   dnl The generic feature tests that determine how to compute ncpus are long and
7237   dnl complicated.  Therefore, simply define special cpp variables for the
7238   dnl platforms we have special knowledge of.
7239   case "${target}" in
7240   *-darwin*)
7241     AC_DEFINE(MOZ_MEMORY_DARWIN)
7242     ;;
7243   *-*freebsd*)
7244     AC_DEFINE(MOZ_MEMORY_BSD)
7245     ;;
7246   *-android*|*-linuxandroid*)
7247     AC_DEFINE(MOZ_MEMORY_LINUX)
7248     AC_DEFINE(MOZ_MEMORY_ANDROID)
7249     if test -z "$gonkdir"; then
7250       _WRAP_MALLOC=1
7251     else
7252       AC_DEFINE(MOZ_MEMORY_GONK)
7253     fi
7254     MOZ_GLUE_LDFLAGS=
7255     ;;
7256   *-*linux*)
7257     AC_DEFINE(MOZ_MEMORY_LINUX)
7258     ;;
7259   *-netbsd*)
7260     AC_DEFINE(MOZ_MEMORY_BSD)
7261     ;;
7262   *-solaris*)
7263     AC_DEFINE(MOZ_MEMORY_SOLARIS)
7264     ;;
7265   *-mingw*)
7266     AC_DEFINE(MOZ_MEMORY_WINDOWS)
7267     if test -z "$MOZ_DEBUG"; then
7268       WIN32_CRT_LIBS="msvcrt.lib msvcprt.lib"
7269     else
7270       WIN32_CRT_LIBS="msvcrtd.lib msvcprtd.lib"
7271     fi
7272     dnl Look for a broken crtdll.obj
7273     WIN32_CRTDLL_FULLPATH=`lib -nologo -list $WIN32_CRT_LIBS | grep crtdll\\.obj`
7274     lib -NOLOGO -OUT:crtdll.obj $WIN32_CRT_LIBS -EXTRACT:$WIN32_CRTDLL_FULLPATH
7275     if grep -q '__imp__\{0,1\}free' crtdll.obj; then
7276       MOZ_GLUE_LDFLAGS='-LIBPATH:$(DIST)/lib -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcrtd -NODEFAULTLIB:msvcprt -NODEFAULTLIB:msvcprtd -DEFAULTLIB:mozcrt'
7277       dnl Also pass this to NSPR/NSS
7278       DLLFLAGS="$DLLFLAGS $MOZ_GLUE_LDFLAGS"
7279     else
7280       DLLFLAGS="$DLLFLAGS -LIBPATH:\$(DIST)/lib -DEFAULTLIB:mozglue"
7281     fi
7282     rm crtdll.obj
7284     export DLLFLAGS
7285     ;;
7286   *)
7287     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
7288     ;;
7289   esac
7290 fi # MOZ_MEMORY
7291 AC_SUBST(MOZ_MEMORY)
7292 AC_SUBST(MOZ_JEMALLOC3)
7293 AC_SUBST(MOZ_NATIVE_JEMALLOC)
7294 AC_SUBST(MOZ_GLUE_LDFLAGS)
7295 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
7296 AC_SUBST(WIN32_CRT_LIBS)
7297 dnl Need to set this for make because NSS doesn't have configure
7298 AC_SUBST(DLLFLAGS)
7300 dnl We need to wrap dlopen and related functions on Android because we use
7301 dnl our own linker.
7302 if test "$OS_TARGET" = Android; then
7303     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
7304     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
7305     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_GetEnv,--wrap=PR_SetEnv"
7306     if test -z "$gonkdir"; then
7307         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork,--wrap=raise"
7308         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"
7309     fi
7312 dnl ========================================================
7313 dnl = Use malloc wrapper lib
7314 dnl ========================================================
7315 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
7316 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
7317     _WRAP_MALLOC=1,
7318     _WRAP_MALLOC= )
7320 if test -n "$_WRAP_MALLOC"; then
7321     if test -n "$GNU_CC"; then
7322         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
7323         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
7324         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
7325         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
7326         dnl Wrap operator new and operator delete on Android.
7327         if test "$OS_TARGET" = "Android"; then
7328             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_Znwj,--wrap=_Znaj,--wrap=_ZdlPv,--wrap=_ZdaPv"
7329             dnl Wrap the nothrow variants too.
7330             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_ZnwjRKSt9nothrow_t,--wrap=_ZnajRKSt9nothrow_t,--wrap=_ZdlPvRKSt9nothrow_t,--wrap=_ZdaPvRKSt9nothrow_t"
7331         fi
7332     else
7333         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
7334     fi
7337 dnl ========================================================
7338 dnl = Location of malloc wrapper lib
7339 dnl ========================================================
7340 MOZ_ARG_WITH_STRING(wrap-malloc,
7341 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
7342     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
7344 dnl ========================================================
7345 dnl = Use JS Call tracing
7346 dnl ========================================================
7347 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
7348 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
7349     MOZ_TRACE_JSCALLS=1,
7350     MOZ_TRACE_JSCALLS= )
7351 if test -n "$MOZ_TRACE_JSCALLS"; then
7352     AC_DEFINE(MOZ_TRACE_JSCALLS)
7355 dnl ========================================================
7356 dnl = Use incremental GC
7357 dnl ========================================================
7358 JSGC_INCREMENTAL=1
7359 MOZ_ARG_DISABLE_BOOL(gcincremental,
7360 [  --disable-gcincremental Disable incremental GC],
7361     JSGC_INCREMENTAL= )
7362 if test -n "$JSGC_INCREMENTAL"; then
7363     AC_DEFINE(JSGC_INCREMENTAL)
7366 dnl ========================================================
7367 dnl ETW - Event Tracing for Windows
7368 dnl ========================================================
7369 MOZ_ARG_ENABLE_BOOL(ETW,
7370 [  --enable-ETW            Enable ETW (Event Tracing for Windows) event reporting],
7371     MOZ_ETW=1,
7372     MOZ_ETW= )
7373 if test -n "$MOZ_ETW"; then
7374     AC_DEFINE(MOZ_ETW)
7377 if test -n "$MOZ_ETW"; then
7378     if test -z "$MOZ_WINSDK_TARGETVER"; then
7379         AC_MSG_ERROR([--enable-ETW is only valid on Windows])
7380     fi
7383 dnl ========================================================
7384 dnl Zealous JavaScript GC
7385 dnl ========================================================
7386 MOZ_ARG_ENABLE_BOOL(gczeal,
7387 [  --enable-gczeal         Enable zealous JavaScript GCing],
7388     JS_GC_ZEAL=1,
7389     JS_GC_ZEAL= )
7390 if test -n "$JS_GC_ZEAL"; then
7391     AC_DEFINE(JS_GC_ZEAL)
7394 dnl ========================================================
7395 dnl JS opt-mode assertions and minidump instrumentation
7396 dnl ========================================================
7397 MOZ_ARG_ENABLE_BOOL(js-diagnostics,
7398 [  --enable-js-diagnostics
7399                           Enable JS diagnostic assertions and breakpad data],
7400     JS_CRASH_DIAGNOSTICS=1,
7401     JS_CRASH_DIAGNOSTICS= )
7402 if test -n "$JS_CRASH_DIAGNOSTICS"; then
7403     AC_DEFINE(JS_CRASH_DIAGNOSTICS)
7406 MOZ_CHECK_CCACHE
7408 dnl ========================================================
7409 dnl = Enable static checking using gcc-dehydra
7410 dnl ========================================================
7412 MOZ_ARG_WITH_STRING(static-checking,
7413 [  --with-static-checking=path/to/gcc_dehydra.so
7414                           Enable static checking of code using GCC-dehydra],
7415     DEHYDRA_PATH=$withval,
7416     DEHYDRA_PATH= )
7418 if test -n "$DEHYDRA_PATH"; then
7419     if test ! -f "$DEHYDRA_PATH"; then
7420         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7421     fi
7422     AC_DEFINE(NS_STATIC_CHECKING)
7424 AC_SUBST(DEHYDRA_PATH)
7426 dnl ========================================================
7427 dnl = Enable stripping of libs & executables
7428 dnl ========================================================
7429 MOZ_ARG_ENABLE_BOOL(strip,
7430 [  --enable-strip          Enable stripping of libs & executables ],
7431     ENABLE_STRIP=1,
7432     ENABLE_STRIP= )
7434 dnl ========================================================
7435 dnl = Enable stripping of libs & executables when packaging
7436 dnl ========================================================
7437 MOZ_ARG_ENABLE_BOOL(install-strip,
7438 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7439     PKG_SKIP_STRIP= ,
7440     PKG_SKIP_STRIP=1)
7442 dnl ========================================================
7443 dnl = --enable-elf-dynstr-gc
7444 dnl ========================================================
7445 MOZ_ARG_ENABLE_BOOL(elf-dynstr-gc,
7446 [  --enable-elf-dynstr-gc  Enable elf dynstr garbage collector (opt builds only)],
7447     USE_ELF_DYNSTR_GC=1,
7448     USE_ELF_DYNSTR_GC= )
7450 dnl ========================================================
7451 dnl = --disable-elf-hack
7452 dnl ========================================================
7454 USE_ELF_HACK=1
7455 MOZ_ARG_DISABLE_BOOL(elf-hack,
7456 [  --disable-elf-hack      Disable elf hacks],
7457     USE_ELF_HACK=,
7458     USE_ELF_HACK=1)
7460 # Disable elf hack for profiling because the built in profiler
7461 # doesn't read the segments properly with elf hack. This is
7462 # temporary and should be fixed soon in the profiler.
7463 if test "$MOZ_PROFILING" = 1; then
7464   USE_ELF_HACK=
7467 # Only enable elfhack where supported
7468 if test "$USE_ELF_HACK" = 1; then
7469     case "${HOST_OS_ARCH},${OS_ARCH}" in
7470     Linux,Linux)
7471         case "${CPU_ARCH}" in
7472         arm | x86 | x86_64)
7473             USE_ELF_HACK=1
7474             ;;
7475         *)
7476             USE_ELF_HACK=
7477             ;;
7478         esac
7479         ;;
7480     *)
7481         USE_ELF_HACK=
7482         ;;
7483     esac
7486 if test "$USE_ELF_HACK" = 1; then
7487     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
7488     dnl memory addresses it maps to. The result is that by the time elfhack
7489     dnl kicks in, it is not possible to apply relocations because of that,
7490     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
7491     dnl segment. It makes elfhack mostly useless, so considering the problems
7492     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
7493     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
7494     dnl the linker creates PT_GNU_RELRO segments.
7495     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
7496         LINK_WITH_PT_GNU_RELRO,
7497         [echo "int main() {return 0;}" > conftest.${ac_ext}
7498          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
7499             test -s conftest${ac_exeext}; then
7500             if ${TOOLCHAIN_PREFIX}readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
7501                 LINK_WITH_PT_GNU_RELRO=yes
7502             else
7503                 LINK_WITH_PT_GNU_RELRO=no
7504             fi
7505          else
7506              dnl We really don't expect to get here, but just in case
7507              AC_ERROR([couldn't compile a simple C file])
7508          fi
7509          rm -rf conftest*])
7510     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
7511         AC_MSG_WARN([Disabling elfhack])
7512         USE_ELF_HACK=
7513     fi
7516 dnl ========================================================
7517 dnl = libstdc++ compatibility hacks
7518 dnl ========================================================
7520 STDCXX_COMPAT=
7521 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
7522 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
7523     STDCXX_COMPAT=1)
7525 AC_SUBST(STDCXX_COMPAT)
7527 if test -n "$STDCXX_COMPAT"; then
7528    eval $(CXX="$CXX" $PYTHON $_topsrcdir/build/autoconf/libstdcxx.py)
7529    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
7530    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
7533 dnl ========================================================
7534 dnl =
7535 dnl = Profiling and Instrumenting
7536 dnl =
7537 dnl ========================================================
7538 MOZ_ARG_HEADER(Profiling and Instrumenting)
7540 dnl ========================================================
7541 dnl = Enable runtime visual profiling logger
7542 dnl ========================================================
7543 MOZ_ARG_ENABLE_BOOL(visual-event-tracer,
7544 [  --enable-visual-event-tracer   Enable visual event tracer instrumentation],
7545     MOZ_VISUAL_EVENT_TRACER=1,
7546     MOZ_VISUAL_EVENT_TRACER=)
7547 if test -n "$MOZ_VISUAL_EVENT_TRACER"; then
7548     AC_DEFINE(MOZ_VISUAL_EVENT_TRACER)
7551 dnl ========================================================
7552 dnl Turn on reflow counting
7553 dnl ========================================================
7554 MOZ_ARG_ENABLE_BOOL(reflow-perf,
7555 [  --enable-reflow-perf    Enable reflow performance tracing],
7556     MOZ_REFLOW_PERF=1,
7557     MOZ_REFLOW_PERF= )
7558 if test -n "$MOZ_REFLOW_PERF"; then
7559     AC_DEFINE(MOZ_REFLOW_PERF)
7562 dnl ========================================================
7563 dnl Enable code size metrics.
7564 dnl ========================================================
7565 MOZ_ARG_ENABLE_BOOL(codesighs,
7566 [  --enable-codesighs      Enable code size analysis tools],
7567     _ENABLE_CODESIGHS=1,
7568     _ENABLE_CODESIGHS= )
7569 if test -n "$_ENABLE_CODESIGHS"; then
7570     if test -d $srcdir/tools/codesighs; then
7571         MOZ_MAPINFO=1
7572     else
7573         AC_MSG_ERROR([Codesighs directory $srcdir/tools/codesighs required.])
7574     fi
7577 dnl ========================================================
7578 dnl = Enable Radio Interface for B2G (Gonk usually)
7579 dnl ========================================================
7580 MOZ_ARG_ENABLE_BOOL(b2g-ril,
7581 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
7582     MOZ_B2G_RIL=1,
7583     MOZ_B2G_RIL= )
7584 if test -n "$MOZ_B2G_RIL"; then
7585     AC_DEFINE(MOZ_B2G_RIL)
7587 AC_SUBST(MOZ_B2G_RIL)
7589 dnl ========================================================
7590 dnl = Enable Radio FM for B2G (Gonk usually)
7591 dnl ========================================================
7592 if test -n "$MOZ_B2G_FM"; then
7593     AC_DEFINE(MOZ_B2G_FM)
7595 AC_SUBST(MOZ_B2G_FM)
7597 dnl ========================================================
7598 dnl = Enable Bluetooth Interface for B2G (Gonk usually)
7599 dnl ========================================================
7600 MOZ_ARG_ENABLE_BOOL(b2g-bt,
7601 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
7602     MOZ_B2G_BT=1,
7603     MOZ_B2G_BT= )
7604 if test -n "$MOZ_B2G_BT"; then
7605     AC_DEFINE(MOZ_B2G_BT)
7607 AC_SUBST(MOZ_B2G_BT)
7609 dnl ========================================================
7610 dnl = Enable Support for System Messages API
7611 dnl ========================================================
7612 if test -n "$MOZ_SYS_MSG"; then
7613     AC_DEFINE(MOZ_SYS_MSG)
7615 AC_SUBST(MOZ_SYS_MSG)
7617 dnl ========================================================
7618 dnl = Enable Support for Time Manager API
7619 dnl ========================================================
7620 if test -n "$MOZ_TIME_MANAGER"; then
7621     AC_DEFINE(MOZ_TIME_MANAGER)
7623 AC_SUBST(MOZ_TIME_MANAGER)
7625 dnl ========================================================
7626 dnl = Enable Camera Interface for B2G (Gonk usually)
7627 dnl ========================================================
7628 MOZ_ARG_ENABLE_BOOL(b2g-camera,
7629 [  --enable-b2g-camera      Set compile flags necessary for compiling camera API for B2G ],
7630     MOZ_B2G_CAMERA=1,
7631     MOZ_B2G_CAMERA= )
7632 if test -n "$MOZ_B2G_CAMERA"; then
7633    AC_DEFINE(MOZ_B2G_CAMERA)
7635 AC_SUBST(MOZ_B2G_CAMERA)
7637 dnl ========================================================
7638 dnl = Enable Support B2G-specific changes to the NSS
7639 dnl = certificate trust database.
7640 dnl ========================================================
7641 if test -n "$MOZ_B2G_CERTDATA"; then
7642     AC_DEFINE(MOZ_B2G_CERTDATA)
7644 AC_SUBST(MOZ_B2G_CERTDATA)
7646 dnl ========================================================
7647 dnl = Enable Support for Payment API
7648 dnl ========================================================
7649 if test -n "$MOZ_PAY"; then
7650     AC_DEFINE(MOZ_PAY)
7652 AC_SUBST(MOZ_PAY)
7654 dnl ========================================================
7655 dnl = Enable Support for AudioChannelManager API
7656 dnl ========================================================
7657 if test -n "$MOZ_AUDIO_CHANNEL_MANAGER"; then
7658     AC_DEFINE(MOZ_AUDIO_CHANNEL_MANAGER)
7660 AC_SUBST(MOZ_AUDIO_CHANNEL_MANAGER)
7662 dnl ========================================================
7663 dnl = Support for demangling undefined symbols
7664 dnl ========================================================
7665 if test -z "$SKIP_LIBRARY_CHECKS"; then
7666     AC_LANG_SAVE
7667     AC_LANG_CPLUSPLUS
7668     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7669     AC_LANG_RESTORE
7672 # Demangle only for debug or trace-malloc or DMD builds
7673 MOZ_DEMANGLE_SYMBOLS=
7674 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
7675     MOZ_DEMANGLE_SYMBOLS=1
7676     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7678 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7680 dnl ========================================================
7681 dnl = Support for gcc stack unwinding (from gcc 3.3)
7682 dnl ========================================================
7683 if test -z "$SKIP_LIBRARY_CHECKS"; then
7684     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7687 dnl ========================================================
7688 dnl JIT observers
7689 dnl ========================================================
7691 MOZ_ARG_WITH_STRING(jitreport-granularity,
7692 [  --jitreport-granularity=N
7693                            Default granularity at which to report JIT code
7694                            to external tools
7695                              0 - no info
7696                              1 - code ranges for whole functions only
7697                              2 - per-line information
7698                              3 - per-op information],
7699   JITREPORT_GRANULARITY=$withval,
7700   JITREPORT_GRANULARITY=3)
7702 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
7704 dnl ========================================================
7705 dnl =
7706 dnl = Misc. Options
7707 dnl =
7708 dnl ========================================================
7709 MOZ_ARG_HEADER(Misc. Options)
7711 dnl ========================================================
7712 dnl update xterm title
7713 dnl ========================================================
7714 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7715 [  --enable-xterm-updates  Update XTERM titles with current command.],
7716     MOZ_UPDATE_XTERM=1,
7717     MOZ_UPDATE_XTERM= )
7719 dnl =========================================================
7720 dnl = Chrome format
7721 dnl =========================================================
7722 MOZ_ARG_ENABLE_STRING([chrome-format],
7723 [  --enable-chrome-format=jar|flat|both|symlink|omni
7724                           Select FORMAT of chrome files (default=jar)],
7725     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7727 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7728     MOZ_CHROME_FILE_FORMAT=jar
7731 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
7732     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7733     test "$MOZ_CHROME_FILE_FORMAT" != "symlink" &&
7734     test "$MOZ_CHROME_FILE_FORMAT" != "both" &&
7735     test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
7736     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, both, symlink, or omni])
7739 dnl =========================================================
7740 dnl Omnijar packaging (bug 552121)
7741 dnl =========================================================
7742 dnl Omnijar packaging is compatible with flat packaging.
7743 dnl In unpackaged builds, omnijar looks for files as if
7744 dnl things were flat packaged. After packaging, all files
7745 dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
7746 dnl is set to flat since putting files into jars is only
7747 dnl done during packaging with omnijar.
7748 if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
7749     MOZ_OMNIJAR=1
7750     AC_DEFINE(MOZ_OMNIJAR)
7752 MOZ_PACKAGER_FORMAT="$MOZ_CHROME_FILE_FORMAT"
7753 if test "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2" -o "$MOZ_WIDGET_TOOLKIT" = "android"; then
7754     MOZ_CHROME_FILE_FORMAT=flat
7755 else
7756     MOZ_CHROME_FILE_FORMAT=symlink
7759 OMNIJAR_NAME=omni.ja
7760 AC_SUBST(OMNIJAR_NAME)
7761 AC_SUBST(MOZ_OMNIJAR)
7762 AC_SUBST(MOZ_PACKAGER_FORMAT)
7764 dnl ========================================================
7765 dnl = Define default location for MOZILLA_FIVE_HOME
7766 dnl ========================================================
7767 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7768 [  --with-default-mozilla-five-home
7769                           Set the default value for MOZILLA_FIVE_HOME],
7770 [ val=`echo $withval`
7771   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7773 dnl ========================================================
7774 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7775 dnl ========================================================
7776 MOZ_ARG_WITH_STRING(user-appdir,
7777 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7778 [ val=`echo $withval`
7779 if echo "$val" | grep "\/" >/dev/null; then
7780     AC_MSG_ERROR("Homedir must be single relative path.")
7781 else
7782     MOZ_USER_DIR="$val"
7783 fi])
7785 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7787 dnl ========================================================
7788 dnl = Doxygen configuration
7789 dnl ========================================================
7790 dnl Use commas to specify multiple dirs to this arg
7791 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7792 MOZ_ARG_WITH_STRING(doc-input-dirs,
7793 [  --with-doc-input-dirs=DIRS
7794                           Header/idl dirs to create docs from],
7795 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7796 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7798 dnl Use commas to specify multiple dirs to this arg
7799 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7800 MOZ_ARG_WITH_STRING(doc-include-dirs,
7801 [  --with-doc-include-dirs=DIRS
7802                           Include dirs to preprocess doc headers],
7803 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7804 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7806 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7807 MOZ_ARG_WITH_STRING(doc-output-dir,
7808 [  --with-doc-output-dir=DIR
7809                           Dir to generate docs into],
7810 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7811 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7813 if test -z "$SKIP_COMPILER_CHECKS"; then
7814 dnl ========================================================
7815 dnl =
7816 dnl = Compiler Options
7817 dnl =
7818 dnl ========================================================
7819 MOZ_ARG_HEADER(Compiler Options)
7821 dnl ========================================================
7822 dnl Check for gcc -pipe support
7823 dnl ========================================================
7824 AC_MSG_CHECKING([for -pipe support])
7825 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
7826     dnl Any gcc that supports firefox supports -pipe.
7827     CFLAGS="$CFLAGS -pipe"
7828     CXXFLAGS="$CXXFLAGS -pipe"
7829     AC_MSG_RESULT([yes])
7830 else
7831     AC_MSG_RESULT([no])
7834 dnl ========================================================
7835 dnl Profile guided optimization (gcc checks)
7836 dnl ========================================================
7837 dnl Test for profiling options
7838 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7840 _SAVE_CFLAGS="$CFLAGS"
7841 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
7843 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7844 AC_TRY_COMPILE([], [return 0;],
7845                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7846                  result="yes" ], result="no")
7847 AC_MSG_RESULT([$result])
7849 if test $result = "yes"; then
7850   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7851   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
7852   PROFILE_USE_LDFLAGS="-fprofile-use"
7855 CFLAGS="$_SAVE_CFLAGS"
7857 if test -n "$INTEL_CC"; then
7858   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
7859   PROFILE_GEN_LDFLAGS=
7860   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
7861   PROFILE_USE_LDFLAGS=
7864 dnl Sun Studio on Solaris
7865 if test "$SOLARIS_SUNPRO_CC"; then
7866   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
7867   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
7868   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
7869   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
7872 AC_SUBST(PROFILE_GEN_CFLAGS)
7873 AC_SUBST(PROFILE_GEN_LDFLAGS)
7874 AC_SUBST(PROFILE_USE_CFLAGS)
7875 AC_SUBST(PROFILE_USE_LDFLAGS)
7877 AC_LANG_CPLUSPLUS
7879 dnl ========================================================
7880 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
7881 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
7882 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
7883 dnl ========================================================
7884 _SAVE_CXXFLAGS=$CXXFLAGS
7885 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
7886 AC_CACHE_CHECK(for correct overload resolution with const and templates,
7887     ac_nscap_nonconst_opeq_bug,
7888     [AC_TRY_COMPILE([
7889                       template <class T>
7890                       class Pointer
7891                         {
7892                         public:
7893                           T* myPtr;
7894                         };
7896                       template <class T, class U>
7897                       int operator==(const Pointer<T>& rhs, U* lhs)
7898                         {
7899                           return rhs.myPtr == lhs;
7900                         }
7902                       template <class T, class U>
7903                       int operator==(const Pointer<T>& rhs, const U* lhs)
7904                         {
7905                           return rhs.myPtr == lhs;
7906                         }
7907                     ],
7908                     [
7909                       Pointer<int> foo;
7910                       const int* bar;
7911                       return foo == bar;
7912                     ],
7913                     ac_nscap_nonconst_opeq_bug="no",
7914                     ac_nscap_nonconst_opeq_bug="yes")])
7915 CXXFLAGS="$_SAVE_CXXFLAGS"
7917 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
7918     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
7920 fi # ! SKIP_COMPILER_CHECKS
7922 AC_DEFINE(CPP_THROW_NEW, [throw()])
7923 AC_LANG_C
7925 if test "$COMPILE_ENVIRONMENT"; then
7926 MOZ_EXPAND_LIBS
7927 fi # COMPILE_ENVIRONMENT
7929 dnl ========================================================
7930 dnl =
7931 dnl = Build depencency options
7932 dnl =
7933 dnl ========================================================
7934 MOZ_ARG_HEADER(Build dependencies)
7936 if test "$GNU_CC" -a "$GNU_CXX"; then
7937   _DEPEND_CFLAGS='$(filter-out %/.pp,-MD -MF $(MDDEPDIR)/$(@F).pp)'
7938 dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
7939 elif test "$SOLARIS_SUNPRO_CC"; then
7940   _DEPEND_CFLAGS=
7941 else
7942   dnl Don't override this for MSVC
7943   if test -z "$_WIN32_MSVC"; then
7944     _USE_CPP_INCLUDE_FLAG=
7945     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7946     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7947   else
7948     echo '#include <stdio.h>' > dummy-hello.c
7949     changequote(,)
7950     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
7951     changequote([,])
7952     if test -z "$CL_INCLUDES_PREFIX"; then
7953         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
7954     fi
7955     AC_SUBST(CL_INCLUDES_PREFIX)
7956     rm -f dummy-hello.c
7957   fi
7960 dnl ========================================================
7961 dnl =
7962 dnl = Static Build Options
7963 dnl =
7964 dnl ========================================================
7965 MOZ_ARG_HEADER(Static build options)
7967 # split JS out by default to avoid VS2005 PGO crash (bug 591836).
7968 if test "$OS_ARCH" = "WINNT"; then
7969   ENABLE_SHARED_JS=1
7972 MOZ_ARG_ENABLE_BOOL(shared-js,
7973 [  --enable-shared-js
7974                           Create a shared JavaScript library.],
7975     ENABLE_SHARED_JS=1,
7976     ENABLE_SHARED_JS=)
7978 if test -n "$ENABLE_SHARED_JS"; then
7979   JS_SHARED_LIBRARY=1
7980   MOZ_JS_LIBS="$MOZ_JS_SHARED_LIBS"
7981 else
7982   MOZ_JS_LIBS="$MOZ_JS_STATIC_LIBS"
7983   AC_DEFINE(MOZ_STATIC_JS)
7985 AC_SUBST(JS_SHARED_LIBRARY)
7987 AC_SUBST(LIBXUL_LIBS)
7988 XPCOM_LIBS="$LIBXUL_LIBS"
7990 dnl ========================================================
7991 dnl =
7992 dnl = Standalone module options
7993 dnl =
7994 dnl ========================================================
7995 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
7997 dnl Check for GLib.
7998 dnl ========================================================
8000 if test -z "$SKIP_PATH_CHECKS"; then
8001 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
8002     if test "$MOZ_ENABLE_GTK2" -o "$USE_ELF_DYNSTR_GC" ; then
8003         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
8004     fi
8008 if test -z "${GLIB_GMODULE_LIBS}" \
8009    -a -n "${GLIB_CONFIG}"\
8010     -a "${GLIB_CONFIG}" != no\
8011 ; then
8012     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
8015 AC_SUBST(GLIB_CFLAGS)
8016 AC_SUBST(GLIB_LIBS)
8017 AC_SUBST(GLIB_GMODULE_LIBS)
8019 dnl ========================================================
8020 dnl Graphics checks.
8021 dnl ========================================================
8023 if test "${OS_TARGET}" = "WINNT" -o "${OS_ARCH}" = "Darwin" -o "${MOZ_WIDGET_TOOLKIT}" = "android" -o "${MOZ_WIDGET_TOOLKIT}" = "gtk2"; then
8024 MOZ_ENABLE_SKIA=1
8025 else
8026 MOZ_ENABLE_SKIA=
8029 MOZ_ARG_ENABLE_BOOL(skia,
8030 [  --enable-skia   Enable use of Skia],
8031 MOZ_ENABLE_SKIA=1,
8032 MOZ_ENABLE_SKIA=)
8034 if test "$USE_FC_FREETYPE"; then
8035     if test "$COMPILE_ENVIRONMENT"; then
8036         dnl ========================================================
8037         dnl = Check for freetype2 and its functionality
8038         dnl ========================================================
8039         PKG_CHECK_MODULES(FT2, freetype2 >= 6.1.0, _HAVE_FREETYPE2=1, _HAVE_FREETYPE2=)
8041         if test "$_HAVE_FREETYPE2"; then
8042             _SAVE_LIBS="$LIBS"
8043             _SAVE_CFLAGS="$CFLAGS"
8044             LIBS="$LIBS $FT2_LIBS"
8045             CFLAGS="$CFLAGS $FT2_CFLAGS"
8047             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
8048                 ac_cv_member_FT_Bitmap_Size_y_ppem,
8049                 [AC_TRY_COMPILE([#include <ft2build.h>
8050                                  #include FT_FREETYPE_H],
8051                                 [FT_Bitmap_Size s;
8052                                  if (sizeof s.y_ppem) return 0;
8053                                  return 1],
8054                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
8055                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
8056             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
8057                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
8058             else
8059                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
8060             fi
8061             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
8062                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
8063                                [FT_Bitmap_Size structure includes y_ppem field])
8065             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table FT_Select_Size)
8067             LIBS="$_SAVE_LIBS"
8068             CFLAGS="$_SAVE_CFLAGS"
8069         fi
8071         _SAVE_CPPFLAGS="$CPPFLAGS"
8072         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
8073         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
8074             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
8075         CPPFLAGS="$_SAVE_CPPFLAGS"
8076     else
8077         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
8078     fi
8080     PKG_CHECK_MODULES(_FONTCONFIG, fontconfig,
8081     [
8082         if test "$MOZ_PANGO"; then
8083             MOZ_PANGO_CFLAGS="$MOZ_PANGO_CFLAGS $_FONTCONFIG_CFLAGS"
8084             MOZ_PANGO_LIBS="$MOZ_PANGO_LIBS $_FONTCONFIG_LIBS"
8085         else
8086             FT2_CFLAGS="$FT2_CFLAGS $_FONTCONFIG_CFLAGS"
8087             FT2_LIBS="$FT2_LIBS $_FONTCONFIG_LIBS"
8088         fi
8089     ])
8092 dnl ========================================================
8093 dnl Check for pixman and cairo
8094 dnl ========================================================
8096 MOZ_TREE_CAIRO=1
8097 MOZ_ARG_ENABLE_BOOL(system-cairo,
8098 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
8099 MOZ_TREE_CAIRO=,
8100 MOZ_TREE_CAIRO=1 )
8102 MOZ_TREE_PIXMAN=1
8103 MOZ_ARG_ENABLE_BOOL(system-pixman,
8104 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
8105 MOZ_TREE_PIXMAN=,
8106 MOZ_TREE_PIXMAN=force,
8107 MOZ_TREE_PIXMAN=1 )
8109 # System cairo depends on system pixman
8110 if test "$MOZ_TREE_PIXMAN" = "force"; then
8111     if test -z "$MOZ_TREE_CAIRO"; then
8112         AC_MSG_ERROR([--disable-system-pixman is incompatible with --enable-system-cairo.])
8113     else
8114         MOZ_TREE_PIXMAN=1
8115     fi
8116 elif test -z "$MOZ_TREE_CAIRO"; then
8117     MOZ_TREE_PIXMAN=
8120 if test "$MOZ_TREE_PIXMAN"; then
8121     AC_DEFINE(MOZ_TREE_PIXMAN)
8122     MOZ_PIXMAN_CFLAGS=""
8123     MOZ_PIXMAN_LIBS='$(call EXPAND_LIBNAME_PATH,mozlibpixman,$(DEPTH)/gfx/cairo/libpixman/src)'
8124 else
8125     PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.19.2)
8126     MOZ_PIXMAN_CFLAGS="$PIXMAN_CFLAGS"
8127     MOZ_PIXMAN_LIBS="$PIXMAN_LIBS"
8129 AC_SUBST(MOZ_PIXMAN_CFLAGS)
8130 AC_SUBST(MOZ_PIXMAN_LIBS)
8132 # Check for headers defining standard int types.
8133 MOZ_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
8135 if test "$MOZ_TREE_CAIRO"; then
8136     MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
8137     AC_DEFINE(MOZ_TREE_CAIRO)
8139     # For now we assume that we will have a uint64_t available through
8140     # one of the above headers or mozstdint.h.
8141     AC_DEFINE(HAVE_UINT64_T)
8143     # Define macros for cairo-features.h
8144     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
8145     if test "$MOZ_X11"; then
8146         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
8147         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
8148         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
8149         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8150         MOZ_ENABLE_CAIRO_FT=1
8151         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
8152     fi
8153     case "$MOZ_WIDGET_TOOLKIT" in
8154       qt)
8155         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
8156         ;;
8157       cocoa | uikit)
8158         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
8159         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
8160         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
8161         ;;
8162       windows)
8163         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
8164         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
8165         if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
8166             WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
8167             WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
8168             MOZ_ENABLE_D2D_SURFACE=1
8169             MOZ_ENABLE_DWRITE_FONT=1
8170         else
8171             WIN32_DWRITE_FONT_FEATURE=
8172             WIN32_D2D_SURFACE_FEATURE=
8173         fi
8175         MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
8177         dnl D3D10 Layers depend on D2D Surfaces.
8178         if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
8179           MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
8180         fi
8181         ;;
8182       os2)
8183         OS2_SURFACE_FEATURE="#define CAIRO_HAS_OS2_SURFACE 1"
8184         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8185         MOZ_ENABLE_CAIRO_FT=1
8186         CAIRO_FT_CFLAGS="-I${MZFTCFGFT2}/include"
8187         CAIRO_FT_OSLIBS="-L${MZFTCFGFT2}/lib -lmozft -lmzfntcfg"
8188         CAIRO_FT_LIBS=""
8189         ;;
8190     esac
8191     if test "$USE_FC_FREETYPE"; then
8192         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
8193     fi
8194     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
8195     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
8196     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
8197     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
8198     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
8199     AC_SUBST(CAIRO_FT_CFLAGS)
8201     AC_SUBST(PS_SURFACE_FEATURE)
8202     AC_SUBST(PDF_SURFACE_FEATURE)
8203     AC_SUBST(SVG_SURFACE_FEATURE)
8204     AC_SUBST(XLIB_SURFACE_FEATURE)
8205     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
8206     AC_SUBST(QUARTZ_SURFACE_FEATURE)
8207     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
8208     AC_SUBST(WIN32_SURFACE_FEATURE)
8209     AC_SUBST(OS2_SURFACE_FEATURE)
8210     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
8211     AC_SUBST(FT_FONT_FEATURE)
8212     AC_SUBST(FC_FONT_FEATURE)
8213     AC_SUBST(WIN32_FONT_FEATURE)
8214     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
8215     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
8216     AC_SUBST(QUARTZ_FONT_FEATURE)
8217     AC_SUBST(PNG_FUNCTIONS_FEATURE)
8218     AC_SUBST(QT_SURFACE_FEATURE)
8219     AC_SUBST(TEE_SURFACE_FEATURE)
8221     MOZ_CAIRO_LIBS='$(call EXPAND_LIBNAME_PATH,mozcairo,$(DEPTH)/gfx/cairo/cairo/src)'" $CAIRO_FT_LIBS"
8222     MOZ_CAIRO_OSLIBS='${CAIRO_FT_OSLIBS}'
8224     if test "$MOZ_X11"; then
8225         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
8226     fi
8228     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
8229 else
8230     PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION)
8231     MOZ_CAIRO_CFLAGS="$CAIRO_CFLAGS"
8232     MOZ_CAIRO_LIBS="$CAIRO_LIBS"
8233     PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
8234     if test "$MOZ_X11"; then
8235         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
8236         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
8237         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_LIBS"
8238         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
8239     fi
8242 AC_SUBST(MOZ_TREE_CAIRO)
8243 AC_SUBST(MOZ_CAIRO_CFLAGS)
8244 AC_SUBST(MOZ_CAIRO_LIBS)
8245 AC_SUBST(MOZ_CAIRO_OSLIBS)
8246 AC_SUBST(MOZ_TREE_PIXMAN)
8248 dnl ========================================================
8249 dnl qcms
8250 dnl ========================================================
8252 QCMS_LIBS='$(DEPTH)/gfx/qcms/$(LIB_PREFIX)mozqcms.$(LIB_SUFFIX)'
8253 AC_SUBST(QCMS_LIBS)
8255 dnl ========================================================
8256 dnl HarfBuzz
8257 dnl ========================================================
8258 MOZ_HARFBUZZ_LIBS='$(DEPTH)/gfx/harfbuzz/src/$(LIB_PREFIX)mozharfbuzz.$(LIB_SUFFIX)'
8259 AC_SUBST(MOZ_HARFBUZZ_LIBS)
8261 dnl ========================================================
8262 dnl SIL Graphite
8263 dnl ========================================================
8264 MOZ_GRAPHITE_LIBS='$(DEPTH)/gfx/graphite2/src/$(LIB_PREFIX)mozgraphite2.$(LIB_SUFFIX)'
8265 AC_SUBST(MOZ_GRAPHITE_LIBS)
8267 dnl ========================================================
8268 dnl OTS
8269 dnl ========================================================
8270 MOZ_OTS_LIBS='$(DEPTH)/gfx/ots/src/$(LIB_PREFIX)mozots.$(LIB_SUFFIX)'
8271 AC_SUBST(MOZ_OTS_LIBS)
8273 dnl ========================================================
8274 dnl Skia 
8275 dnl ========================================================
8276 if test "$MOZ_ENABLE_SKIA"; then
8277   MOZ_SKIA_LIBS='$(DEPTH)/gfx/skia/$(LIB_PREFIX)skia.$(LIB_SUFFIX)'
8278   AC_DEFINE(MOZ_ENABLE_SKIA)
8279   AC_DEFINE(USE_SKIA)
8280   if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
8281     AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
8282   fi
8283 else
8284   MOZ_SKIA_LIBS=
8286 AC_SUBST(MOZ_ENABLE_SKIA)
8287 AC_SUBST(MOZ_SKIA_LIBS)
8289 dnl ========================================================
8290 dnl disable xul
8291 dnl ========================================================
8292 MOZ_ARG_DISABLE_BOOL(xul,
8293 [  --disable-xul           Disable XUL],
8294     MOZ_XUL= )
8295 if test "$MOZ_XUL"; then
8296   AC_DEFINE(MOZ_XUL)
8297 else
8298   dnl remove extensions that require XUL
8299   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/venkman//' -e 's/irc//' -e 's/tasks//'`
8302 AC_SUBST(MOZ_XUL)
8304 dnl ========================================================
8305 dnl disable profile locking
8306 dnl   do no use this in applications that can have more than
8307 dnl   one process accessing the profile directory.
8308 dnl ========================================================
8309 MOZ_ARG_DISABLE_BOOL(profilelocking,
8310 [  --disable-profilelocking
8311                           Disable profile locking],
8312     MOZ_PROFILELOCKING=,
8313     MOZ_PROFILELOCKING=1 )
8314 if test "$MOZ_PROFILELOCKING"; then
8315   AC_DEFINE(MOZ_PROFILELOCKING)
8318 dnl ========================================================
8319 dnl necko configuration options
8320 dnl ========================================================
8323 dnl option to disable various necko protocols
8325 MOZ_ARG_ENABLE_STRING(necko-protocols,
8326 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8327                           Enable/disable specific protocol handlers],
8328 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8329     if test "$option" = "yes" -o "$option" = "all"; then
8330         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8331     elif test "$option" = "no" -o "$option" = "none"; then
8332         NECKO_PROTOCOLS=""
8333     elif test "$option" = "default"; then
8334         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8335     elif test `echo "$option" | grep -c \^-` != 0; then
8336         option=`echo $option | sed 's/^-//'`
8337         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8338     else
8339         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8340     fi
8341 done],
8342     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8343 dnl Remove dupes
8344 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
8345 AC_SUBST(NECKO_PROTOCOLS)
8346 for p in $NECKO_PROTOCOLS; do
8347     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8348     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_PROTOCOL_$p"
8349 done
8352 dnl option to disable necko's wifi scanner
8354 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8355 [  --disable-necko-wifi    Disable necko wifi scanner],
8356     NECKO_WIFI=,
8357     NECKO_WIFI=1)
8359 if test "$OS_ARCH" = "OS2"; then
8360   dnl OS/2 implementation of Necko-WiFi support will be added in bug 506566
8361   NECKO_WIFI=
8363 if test "$NECKO_WIFI" -a \
8364         "$OS_ARCH" != "Linux" -a \
8365         "$OS_ARCH" != "Darwin" -a \
8366         "$OS_ARCH" != "SunOS" -a \
8367         "$OS_ARCH" != "WINNT"; then
8368   AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use --disable-necko-wifi])
8371 if test "$NECKO_WIFI"; then
8372   AC_DEFINE(NECKO_WIFI)
8373   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
8375 AC_SUBST(NECKO_WIFI)
8378 dnl option to disable cookies
8380 MOZ_ARG_DISABLE_BOOL(cookies,
8381 [  --disable-cookies       Disable cookie support],
8382     NECKO_COOKIES=,
8383     NECKO_COOKIES=1)
8384 AC_SUBST(NECKO_COOKIES)
8385 if test "$NECKO_COOKIES"; then
8386     AC_DEFINE(NECKO_COOKIES)
8387     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
8391 dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
8393 MOZ_ARG_DISABLE_BOOL(ctypes,
8394 [  --disable-ctypes        Disable js-ctypes],
8395     BUILD_CTYPES=,
8396     BUILD_CTYPES=1)
8397 AC_SUBST(BUILD_CTYPES)
8398 if test "$BUILD_CTYPES"; then
8399     AC_DEFINE(BUILD_CTYPES)
8402 dnl Build Places if required
8403 if test "$MOZ_PLACES"; then
8404   AC_DEFINE(MOZ_PLACES)
8407 dnl Build Common JS modules provided by services.
8408 AC_SUBST(MOZ_SERVICES_COMMON)
8409 if test -n "$MOZ_SERVICES_COMMON"; then
8410   AC_DEFINE(MOZ_SERVICES_COMMON)
8413 dnl Build Services crypto component (used by Sync)
8414 AC_SUBST(MOZ_SERVICES_CRYPTO)
8415 if test -n "$MOZ_SERVICES_CRYPTO"; then
8416   AC_DEFINE(MOZ_SERVICES_CRYPTO)
8419 dnl Build Firefox Health Reporter Service
8420 AC_SUBST(MOZ_SERVICES_HEALTHREPORT)
8421 if test -n "$MOZ_SERVICES_HEALTHREPORT"; then
8422   AC_DEFINE(MOZ_SERVICES_HEALTHREPORT)
8425 dnl Build Services metrics component
8426 AC_SUBST(MOZ_SERVICES_METRICS)
8427 if test -n "$MOZ_SERVICES_METRICS"; then
8428   AC_DEFINE(MOZ_SERVICES_METRICS)
8431 dnl Build Notifications if required
8432 AC_SUBST(MOZ_SERVICES_NOTIFICATIONS)
8433 if test -n "$MOZ_SERVICES_NOTIFICATIONS"; then
8434   AC_DEFINE(MOZ_SERVICES_NOTIFICATIONS)
8437 dnl Build Sync Services if required
8438 AC_SUBST(MOZ_SERVICES_SYNC)
8439 if test -n "$MOZ_SERVICES_SYNC"; then
8440   AC_DEFINE(MOZ_SERVICES_SYNC)
8443 dnl Build Captive Portal Detector if required
8444 AC_SUBST(MOZ_CAPTIVEDETECT)
8445 if test -n "$MOZ_CAPTIVEDETECT"; then
8446   AC_DEFINE(MOZ_CAPTIVEDETECT)
8449 dnl ========================================================
8450 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
8451     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8454 if test "$MOZ_APP_COMPONENT_INCLUDE"; then
8455   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
8458 if test "$MOZ_APP_COMPONENT_MODULES"; then
8459   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_MODULES, $MOZ_APP_COMPONENT_MODULES)
8462 dnl ========================================================
8463 dnl =
8464 dnl = Maintainer debug option (no --enable equivalent)
8465 dnl =
8466 dnl ========================================================
8468 AC_SUBST(AR)
8469 AC_SUBST(AR_FLAGS)
8470 AC_SUBST(AR_LIST)
8471 AC_SUBST(AR_EXTRACT)
8472 AC_SUBST(AR_DELETE)
8473 AC_SUBST(AS)
8474 AC_SUBST(ASFLAGS)
8475 AC_SUBST(AS_DASH_C_FLAG)
8476 AC_SUBST(LD)
8477 AC_SUBST(RC)
8478 AC_SUBST(RCFLAGS)
8479 AC_SUBST(MC)
8480 AC_SUBST(WINDRES)
8481 AC_SUBST(IMPLIB)
8482 AC_SUBST(FILTER)
8483 AC_SUBST(BIN_FLAGS)
8484 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8485 AC_SUBST(MOZ_UPDATE_XTERM)
8486 AC_SUBST(MOZ_PLATFORM_MAEMO)
8487 AC_SUBST(MOZ_AUTH_EXTENSION)
8488 AC_SUBST(MOZ_PERMISSIONS)
8489 AC_SUBST(MOZ_PREF_EXTENSIONS)
8490 AC_SUBST(MOZ_JS_LIBS)
8491 AC_SUBST(MOZ_PSM)
8492 AC_SUBST(MOZ_DEBUG)
8493 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8494 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8495 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8496 AC_SUBST(MOZ_DEBUG_FLAGS)
8497 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8498 AC_SUBST(WARNINGS_AS_ERRORS)
8499 AC_SUBST(MOZ_EXTENSIONS)
8500 AC_SUBST(MOZ_JSDEBUGGER)
8501 AC_SUBST(MOZ_ENABLE_PROFILER_SPS)
8502 AC_SUBST(MOZ_JPROF)
8503 AC_SUBST(MOZ_SHARK)
8504 AC_SUBST(MOZ_CALLGRIND)
8505 AC_SUBST(MOZ_VTUNE)
8506 AC_SUBST(MOZ_ETW)
8507 AC_SUBST(MOZ_PROFILING)
8508 AC_SUBST(LIBICONV)
8509 AC_SUBST(MOZ_PLACES)
8510 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8511 AC_SUBST(MOZ_FEEDS)
8512 AC_SUBST(NS_PRINTING)
8513 AC_SUBST(MOZ_WEBGL)
8514 AC_SUBST(MOZ_HELP_VIEWER)
8515 AC_SUBST(TOOLCHAIN_PREFIX)
8517 AC_SUBST(JAVA)
8518 AC_SUBST(JAVAC)
8519 AC_SUBST(JAVAH)
8520 AC_SUBST(JAR)
8522 AC_SUBST(MOZ_PROFILELOCKING)
8524 AC_SUBST(ENABLE_TESTS)
8525 AC_SUBST(ENABLE_MARIONETTE)
8526 AC_SUBST(IBMBIDI)
8527 AC_SUBST(MOZ_UNIVERSALCHARDET)
8528 AC_SUBST(ACCESSIBILITY)
8529 AC_SUBST(MOZ_SPELLCHECK)
8530 AC_SUBST(MOZ_ANDROID_OMTC)
8531 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
8532 AC_SUBST(MOZ_ONLY_TOUCH_EVENTS)
8533 AC_SUBST(MOZ_CRASHREPORTER)
8534 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
8535 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
8536 AC_SUBST(MOZ_STUB_INSTALLER)
8537 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
8538 AC_SUBST(MOZ_ENABLE_SIGNMAR)
8539 AC_SUBST(MOZ_UPDATER)
8540 AC_SUBST(MOZ_ANGLE_RENDERER)
8541 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
8542 AC_SUBST(MOZ_DIRECTX_SDK_CPU_SUFFIX)
8543 AC_SUBST(MOZ_D3DX9_VERSION)
8544 AC_SUBST(MOZ_D3DCOMPILER_CAB)
8545 AC_SUBST(MOZ_D3DCOMPILER_DLL)
8546 AC_SUBST(MOZ_METRO)
8548 AC_SUBST(MOZ_ANDROID_HISTORY)
8549 AC_SUBST(MOZ_WEBSMS_BACKEND)
8550 AC_SUBST(ENABLE_STRIP)
8551 AC_SUBST(PKG_SKIP_STRIP)
8552 AC_SUBST(STRIP_FLAGS)
8553 AC_SUBST(USE_ELF_DYNSTR_GC)
8554 AC_SUBST(USE_ELF_HACK)
8555 AC_SUBST(INCREMENTAL_LINKER)
8556 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8557 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8559 AC_SUBST(MOZ_FIX_LINK_PATHS)
8560 AC_SUBST(XPCOM_LIBS)
8561 AC_SUBST(XPCOM_FROZEN_LDOPTS)
8562 AC_SUBST(XPCOM_GLUE_LDOPTS)
8563 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
8564 AC_SUBST(XPCOM_STATICRUNTIME_GLUE_LDOPTS)
8565 AC_SUBST(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS)
8567 AC_SUBST(USE_DEPENDENT_LIBS)
8569 AC_SUBST(MOZ_BUILD_ROOT)
8570 AC_SUBST(MOZ_OS2_TOOLS)
8572 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8573 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8574 AC_SUBST(MOZ_LINKER_EXTRACT)
8576 AC_SUBST(MOZ_JSDOWNLOADS)
8578 if test -n "$MOZ_JSDOWNLOADS" ; then
8579     AC_DEFINE(MOZ_JSDOWNLOADS)
8582 dnl ========================================================
8583 dnl = Mac bundle name prefix
8584 dnl ========================================================
8585 MOZ_ARG_WITH_STRING(macbundlename-prefix,
8586 [  --with-macbundlename-prefix=prefix
8587                           Prefix for MOZ_MACBUNDLE_NAME],
8588 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
8590 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
8591 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
8592   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
8595 if test "$MOZ_DEBUG"; then
8596   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
8597 else
8598   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
8600 AC_SUBST(MOZ_MACBUNDLE_NAME)
8602 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
8603 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr '[A-Z]' '[a-z]'`
8604 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
8605 if test "$MOZ_DEBUG"; then
8606   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
8609 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
8610 AC_SUBST(MOZ_MACBUNDLE_ID)
8612 # The following variables are available to branding and application
8613 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
8614 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
8615 # impacts profile location and user-visible fields.
8616 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
8617 # versions of a given application (e.g. Aurora and Firefox both use
8618 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
8619 # for application.ini's "Name" field, which controls profile location in
8620 # the absence of a "Profile" field (see below), and various system
8621 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
8622 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
8623 # Mac Bundle name, Updater, Installer), it is typically used for nightly
8624 # builds (e.g. Aurora for Firefox).
8625 # - MOZ_APP_VERSION: Defines the application version number.
8626 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
8627 # defaults to a lowercase form of MOZ_APP_BASENAME.
8628 # - MOZ_APP_PROFILE: When set, used for application.ini's
8629 # "Profile" field, which controls profile location.
8630 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
8631 # crash reporter server url.
8632 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
8633 # - MOZ_EXTENSION_MANAGER: When set, enabled extension manager.
8635 if test -z "$MOZ_APP_NAME"; then
8636    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
8639 # For extensions and langpacks, we require a max version that is compatible
8640 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
8641 # 10.0a1 and 10.0a2 aren't affected
8642 # 10.0 becomes 10.0.*
8643 # 10.0.1 becomes 10.0.*
8644 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
8645 if test -z "$IS_ALPHA"; then
8646   changequote(,)
8647   MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*.[0-9]*\).*|\1|"`.*
8648   changequote([,])
8649 else
8650   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
8653 MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"}
8654 AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION")
8655 AC_DEFINE_UNQUOTED(MOZ_B2G_OS_NAME,"$MOZ_B2G_OS_NAME")
8657 AC_SUBST(MOZ_APP_NAME)
8658 AC_SUBST(MOZ_APP_DISPLAYNAME)
8659 AC_SUBST(MOZ_APP_BASENAME)
8660 AC_SUBST(MOZ_APP_VENDOR)
8661 AC_SUBST(MOZ_APP_PROFILE)
8662 AC_SUBST(MOZ_APP_ID)
8663 AC_SUBST(MAR_CHANNEL_ID)
8664 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
8665 AC_SUBST(MOZ_PROFILE_MIGRATOR)
8666 AC_SUBST(MOZ_EXTENSION_MANAGER)
8667 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
8668 AC_SUBST(MOZ_APP_UA_NAME)
8669 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
8670 AC_SUBST(MOZ_APP_VERSION)
8671 AC_SUBST(MOZ_APP_MAXVERSION)
8672 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
8673 AC_SUBST(FIREFOX_VERSION)
8674 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
8675 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
8676   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
8678 AC_DEFINE_UNQUOTED(MOZ_UA_BUILDID, "$MOZ_UA_BUILDID")
8679 AC_SUBST(MOZ_UA_BUILDID)
8681 AC_SUBST(MOZ_APP_STATIC_INI)
8683 AC_SUBST(MOZ_PKG_SPECIAL)
8685 AC_SUBST(MOZILLA_OFFICIAL)
8687 AC_DEFINE_UNQUOTED(MOZ_TELEMETRY_DISPLAY_REV, 2)
8688 AC_SUBST(MOZ_TELEMETRY_DISPLAY_REV)
8690 if test "$MOZ_TELEMETRY_REPORTING"; then
8691     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
8693     # Enable Telemetry by default for nightly and aurora channels
8694     if test "$MOZ_UPDATE_CHANNEL" = "nightly" -o \
8695         "$MOZ_UPDATE_CHANNEL" = "aurora"; then
8696         AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
8697     fi
8700 dnl If we have any service that uploads data (and requires data submission
8701 dnl policy alert), set MOZ_DATA_REPORTING.
8702 dnl We need SUBST for build system and DEFINE for xul preprocessor.
8703 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"; then
8704   MOZ_DATA_REPORTING=1
8705   AC_DEFINE(MOZ_DATA_REPORTING)
8706   AC_SUBST(MOZ_DATA_REPORTING)
8709 dnl win32 options
8710 AC_SUBST(MOZ_MAPINFO)
8711 AC_SUBST(MOZ_BROWSE_INFO)
8712 AC_SUBST(MOZ_TOOLS_DIR)
8713 AC_SUBST(WIN32_REDIST_DIR)
8714 AC_SUBST(MAKENSISU)
8716 dnl Echo the CFLAGS to remove extra whitespace.
8717 CFLAGS=`echo \
8718         $_WARNINGS_CFLAGS \
8719         $CFLAGS`
8721 CXXFLAGS=`echo \
8722         $_WARNINGS_CXXFLAGS \
8723         $CXXFLAGS`
8725 COMPILE_CFLAGS=`echo \
8726     $_DEFINES_CFLAGS \
8727         $_DEPEND_CFLAGS \
8728     $COMPILE_CFLAGS`
8730 COMPILE_CXXFLAGS=`echo \
8731     $_DEFINES_CXXFLAGS \
8732         $_DEPEND_CFLAGS \
8733     $COMPILE_CXXFLAGS`
8735 AC_SUBST(SYSTEM_LIBXUL)
8736 AC_SUBST(MOZ_NATIVE_JPEG)
8737 AC_SUBST(MOZ_NATIVE_PNG)
8738 AC_SUBST(MOZ_NATIVE_BZ2)
8740 AC_SUBST(MOZ_FLEXBOX)
8741 AC_SUBST(MOZ_JPEG_CFLAGS)
8742 AC_SUBST(MOZ_JPEG_LIBS)
8743 AC_SUBST(MOZ_BZ2_CFLAGS)
8744 AC_SUBST(MOZ_BZ2_LIBS)
8745 AC_SUBST(MOZ_PNG_CFLAGS)
8746 AC_SUBST(MOZ_PNG_LIBS)
8748 AC_SUBST(NSPR_CFLAGS)
8749 AC_SUBST(NSPR_LIBS)
8750 AC_SUBST(MOZ_NATIVE_NSPR)
8752 AC_SUBST(NSS_CFLAGS)
8753 AC_SUBST(NSS_LIBS)
8754 AC_SUBST(NSS_DEP_LIBS)
8755 AC_SUBST(MOZ_NATIVE_NSS)
8756 AC_SUBST(NSS_DISABLE_DBM)
8758 OS_CFLAGS="$CFLAGS"
8759 OS_CXXFLAGS="$CXXFLAGS"
8760 OS_CPPFLAGS="$CPPFLAGS"
8761 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
8762 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
8763 OS_LDFLAGS="$LDFLAGS"
8764 OS_LIBS="$LIBS"
8765 AC_SUBST(OS_CFLAGS)
8766 AC_SUBST(OS_CXXFLAGS)
8767 AC_SUBST(OS_CPPFLAGS)
8768 AC_SUBST(OS_COMPILE_CFLAGS)
8769 AC_SUBST(OS_COMPILE_CXXFLAGS)
8770 AC_SUBST(OS_LDFLAGS)
8771 AC_SUBST(OS_LIBS)
8772 AC_SUBST(CROSS_COMPILE)
8773 AC_SUBST(WCHAR_CFLAGS)
8775 AC_SUBST(HOST_CC)
8776 AC_SUBST(HOST_CXX)
8777 AC_SUBST(HOST_CFLAGS)
8778 AC_SUBST(HOST_CXXFLAGS)
8779 AC_SUBST(HOST_LDFLAGS)
8780 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8781 AC_SUBST(HOST_AR)
8782 AC_SUBST(HOST_AR_FLAGS)
8783 AC_SUBST(HOST_LD)
8784 AC_SUBST(HOST_RANLIB)
8785 AC_SUBST(HOST_NSPR_MDCPUCFG)
8786 AC_SUBST(HOST_BIN_SUFFIX)
8787 AC_SUBST(HOST_OS_ARCH)
8789 AC_SUBST(TARGET_CPU)
8790 AC_SUBST(TARGET_VENDOR)
8791 AC_SUBST(TARGET_OS)
8792 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8793 AC_SUBST(TARGET_MD_ARCH)
8794 AC_SUBST(TARGET_XPCOM_ABI)
8795 AC_SUBST(OS_TARGET)
8796 AC_SUBST(OS_ARCH)
8797 AC_SUBST(OS_RELEASE)
8798 AC_SUBST(OS_TEST)
8799 AC_SUBST(CPU_ARCH)
8800 AC_SUBST(INTEL_ARCHITECTURE)
8802 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
8804 AC_SUBST(WRAP_LDFLAGS)
8805 AC_SUBST(MKSHLIB)
8806 AC_SUBST(MKCSHLIB)
8807 AC_SUBST(MKSHLIB_FORCE_ALL)
8808 AC_SUBST(MKSHLIB_UNFORCE_ALL)
8809 AC_SUBST(DSO_CFLAGS)
8810 AC_SUBST(DSO_PIC_CFLAGS)
8811 AC_SUBST(DSO_LDOPTS)
8812 AC_SUBST(LIB_PREFIX)
8813 AC_SUBST(DLL_PREFIX)
8814 AC_SUBST(DLL_SUFFIX)
8815 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
8816 AC_SUBST(LIB_SUFFIX)
8817 AC_SUBST(OBJ_SUFFIX)
8818 AC_SUBST(BIN_SUFFIX)
8819 AC_SUBST(ASM_SUFFIX)
8820 AC_SUBST(IMPORT_LIB_SUFFIX)
8821 AC_SUBST(USE_N32)
8822 AC_SUBST(CC_VERSION)
8823 AC_SUBST(CXX_VERSION)
8824 AC_SUBST(MSMANIFEST_TOOL)
8825 AC_SUBST(NS_ENABLE_TSF)
8826 AC_SUBST(MOZ_NSS_PATCH)
8827 AC_SUBST(MOZ_APP_COMPONENT_LIBS)
8828 AC_SUBST(MOZ_APP_EXTRA_LIBS)
8830 AC_SUBST(MOZ_MEDIA)
8831 AC_SUBST(MOZ_SYDNEYAUDIO)
8832 AC_SUBST(MOZ_SPEEX_RESAMPLER)
8833 AC_SUBST(MOZ_SOUNDTOUCH)
8834 AC_SUBST(MOZ_CUBEB)
8835 AC_SUBST(MOZ_WAVE)
8836 AC_SUBST(MOZ_VORBIS)
8837 AC_SUBST(MOZ_TREMOR)
8838 AC_SUBST(MOZ_OPUS)
8839 AC_SUBST(MOZ_WEBM)
8840 AC_SUBST(MOZ_WEBVTT)
8841 AC_SUBST(MOZ_DASH)
8842 AC_SUBST(MOZ_WMF)
8843 AC_SUBST(MOZ_MEDIA_PLUGINS)
8844 AC_SUBST(MOZ_OMX_PLUGIN)
8845 AC_SUBST(MOZ_VP8_ERROR_CONCEALMENT)
8846 AC_SUBST(MOZ_VP8_ENCODER)
8847 AC_SUBST(MOZ_VP8)
8848 AC_SUBST(MOZ_OGG)
8849 AC_SUBST(VPX_AS)
8850 AC_SUBST(VPX_ASFLAGS)
8851 AC_SUBST(VPX_DASH_C_FLAG)
8852 AC_SUBST(VPX_AS_CONVERSION)
8853 AC_SUBST(VPX_ASM_SUFFIX)
8854 AC_SUBST(VPX_X86_ASM)
8855 AC_SUBST(VPX_ARM_ASM)
8856 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
8857 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
8858 AC_SUBST(LIBJPEG_TURBO_AS)
8859 AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
8860 AC_SUBST(LIBJPEG_TURBO_X86_ASM)
8861 AC_SUBST(LIBJPEG_TURBO_X64_ASM)
8862 AC_SUBST(LIBJPEG_TURBO_ARM_ASM)
8864 AC_SUBST(MOZ_PACKAGE_JSSHELL)
8866 AC_MSG_CHECKING([for posix_fallocate])
8867 AC_TRY_LINK([#define _XOPEN_SOURCE 600
8868   #include <fcntl.h>],
8869                  [posix_fallocate(0, 0, 0);],
8870                  [ac_cv___posix_fallocate=true],
8871                  [ac_cv___posix_fallocate=false])
8873 if test "$ac_cv___posix_fallocate" = true ; then
8874   AC_DEFINE(HAVE_POSIX_FALLOCATE)
8875   AC_MSG_RESULT(yes)
8876 else
8877   AC_MSG_RESULT(no)
8880 dnl Check for missing components
8881 if test "$COMPILE_ENVIRONMENT"; then
8882 if test "$MOZ_X11"; then
8883     if test "$WITHOUT_X11"; then
8884         AC_MSG_ERROR([--without-x specified and MOZ_X11 still defined])
8885     fi
8886     dnl ====================================================
8887     dnl = Check if X headers exist
8888     dnl ====================================================
8889     _SAVE_CFLAGS=$CFLAGS
8890     CFLAGS="$CFLAGS $XCFLAGS"
8891     AC_TRY_COMPILE([
8892         #include <stdio.h>
8893         #include <stdlib.h>
8894         #include <X11/Xlib.h>
8895         #include <X11/Intrinsic.h>
8896         #include <X11/extensions/XShm.h>
8897     ],
8898     [
8899         Display *dpy = 0;
8900         if ((dpy = XOpenDisplay(NULL)) == NULL) {
8901             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
8902             exit(1);
8903         }
8904     ], [],
8905     [ AC_MSG_ERROR([Could not compile basic X program.]) ])
8906     CFLAGS="$_SAVE_CFLAGS"
8908     if test -n "$MISSING_X"; then
8909         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
8910     fi
8912 fi # MOZ_X11
8914 dnl Check for headers, etc. needed by WebGL.
8915 if test "$MOZ_GL_DEFAULT_PROVIDER" = "GLX"; then
8916     MOZ_CHECK_HEADER(GL/glx.h)
8917     if test "$ac_cv_header_GL_glx_h" != "yes"; then
8918         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))])
8919     fi
8920 fi # MOZ_GL_DEFAULT_PROVIDER=GLX
8921 fi # COMPILE_ENVIRONMENT
8923 dnl Set various defines and substitutions
8924 dnl ========================================================
8926 if test "$OS_ARCH" = "Darwin"; then
8927   AC_DEFINE(XP_UNIX)
8928 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2"; then
8929   AC_DEFINE(XP_UNIX)
8932 if test "$MOZ_DEBUG"; then
8933     AC_DEFINE(MOZ_REFLOW_PERF)
8934     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
8937 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then
8938     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
8939     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
8940     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
8941     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
8942     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
8943     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
8944     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
8945     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
8948 AC_SUBST(MOZILLA_VERSION)
8950 AC_SUBST(ac_configure_args)
8952 dnl Spit out some output
8953 dnl ========================================================
8955 dnl The following defines are used by xpcom
8956 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
8957 CPP_THROW_NEW
8958 HAVE_CPP_2BYTE_WCHAR_T
8959 HAVE_CPP_AMBIGUITY_RESOLVING_USING
8960 HAVE_CPP_CHAR16_T
8961 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
8962 HAVE_CPP_PARTIAL_SPECIALIZATION
8963 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
8964 NEED_CPP_UNUSED_IMPLEMENTATIONS
8965 NEW_H
8966 HAVE_GETPAGESIZE
8967 HAVE_ICONV
8968 HAVE_ICONV_WITH_CONST_INPUT
8969 HAVE_MBRTOWC
8970 HAVE_WCRTOMB
8971 HAVE_STATVFS64
8972 HAVE_STATVFS
8973 HAVE_STATFS64
8974 HAVE_STATFS
8975 HAVE_SYS_STATVFS_H
8976 HAVE_SYS_STATFS_H
8977 HAVE_SYS_VFS_H
8978 HAVE_SYS_MOUNT_H
8981 # FUTURE? Consider moving all these to moz.build files.
8982 AC_CONFIG_HEADER(
8983 netwerk/necko-config.h
8984 xpcom/xpcom-config.h
8985 xpcom/xpcom-private.h
8988 AC_OUTPUT([mozilla-config.h])
8990 # Hack around an Apple bug that affects the egrep that comes with OS X 10.7.
8991 # "env ARCHPREFERENCE=i386,x86_64 arch egrep" first tries to use the 32-bit
8992 # Intel part of the egrep fat binary, even on 64-bit systems, and falls back on
8993 # the 64-bit part if it's not a fat binary, as can happen with MacPorts. We
8994 # (apparently) only need this hack when egrep's "pattern" is particularly long
8995 # (as in the following code) and the first egrep on our $PATH is Apple's.  See
8996 # bug 655339.
8997 case "$host" in
8998 *-apple-darwin11*)
8999     FIXED_EGREP="env ARCHPREFERENCE=i386,x86_64 arch egrep"
9000     ;;
9002     FIXED_EGREP="egrep"
9003     ;;
9004 esac
9006 # target_arch is from {ia32|x64|arm|ppc}
9007 case "$CPU_ARCH" in
9008 x86_64 | ia64)
9009     WEBRTC_TARGET_ARCH=x64
9010     ;;
9012 arm*)
9013     WEBRTC_TARGET_ARCH=arm
9014     ;;
9016 x86)
9017     WEBRTC_TARGET_ARCH=ia32
9018     ;;
9020 ppc*)
9021     WEBRTC_TARGET_ARCH=ppc
9022     ;;
9024 # unsupported arch for webrtc
9025     WEBRTC_TARGET_ARCH=unknown
9026     MOZ_WEBRTC=
9027     ;;
9029 esac
9031 # Generate Makefiles for WebRTC directly from .gyp files
9032 if test "${OS_TARGET}" = "WINNT"; then
9033    if test "$HAVE_64BIT_OS"; then
9034       OS_BITS=64
9035    else
9036       OS_BITS=32
9037    fi
9038    EXTRA_GYP_DEFINES="-D MSVS_VERSION=${_MSVS_VERSION} -D MSVS_OS_BITS=${OS_BITS}"
9040 elif test "${OS_TARGET}" = "Android"; then
9041    EXTRA_GYP_DEFINES="-D gtest_target_type=executable -D android_toolchain=${android_toolchain} -G os=android "
9042    if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
9043       EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D armv7=0 "
9044    else
9045       EXTRA_GYP_DEFINES="${EXTRA_GYP_DEFINES} -D armv7=1 "
9046    fi
9049 # Don't try to compile sse4.1 code if toolchain doesn't support
9050 if test -z "$HAVE_TOOLCHAIN_SUPPORT_MSSE4_1"; then
9051   EXTRA_GYP_DEFINES="$EXTRA_GYP_DEFINES -D yuv_disable_asm=1"
9054 if test -n "$MOZ_WEBRTC"; then
9055    AC_MSG_RESULT("generating WebRTC Makefiles...")
9057 dnl Any --include files must also appear in -D FORCED_INCLUDE_FILE= entries
9058 dnl so that regeneration via dependencies works correctly
9059    WEBRTC_CONFIG="-D build_with_mozilla=1 -D build_with_chromium=0 --include ${srcdir}/media/webrtc/webrtc_config.gypi -D FORCED_INCLUDE_FILE=${srcdir}/media/webrtc/webrtc_config.gypi"
9061    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}"
9063    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9064      $GYP_WEBRTC_OPTIONS \
9065      --generator-output=${_objdir}/media/webrtc/trunk \
9066      ${srcdir}/media/webrtc/trunk/peerconnection.gyp
9067    if test "$?" != 0; then
9068       AC_MSG_ERROR([failed to generate WebRTC Makefiles])
9069    fi
9071    # XXX disable until we land the tranche with signaling
9072    if test -n "$MOZ_WEBRTC_SIGNALING"; then
9073      AC_MSG_RESULT("generating WebRTC/Signaling Makefiles...")
9074      $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9075        $GYP_WEBRTC_OPTIONS \
9076        -D build_for_test=0 \
9077        --generator-output=${_objdir}/media/webrtc/signaling \
9078        ${srcdir}/media/webrtc/signaling/signaling.gyp
9079      if test "$?" != 0; then
9080         AC_MSG_ERROR([failed to generate WebRTC/Signaling Makefiles])
9081      fi
9083      AC_MSG_RESULT("generating WebRTC/SignalingTest Makefiles...")
9084      $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9085        $GYP_WEBRTC_OPTIONS \
9086        -D build_for_test=1 \
9087        --generator-output=${_objdir}/media/webrtc/signalingtest \
9088        ${srcdir}/media/webrtc/signaling/signaling.gyp
9089      if test "$?" != 0; then
9090        AC_MSG_ERROR([failed to generate WebRTC/SignalingTest Makefiles])
9091      fi
9092    fi
9094    AC_MSG_RESULT("generating gtest Makefiles...")
9095    # Ok to pass some extra -D's that are ignored here
9096    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
9097      $GYP_WEBRTC_OPTIONS \
9098      --generator-output=${_objdir}/media/webrtc/trunk/testing/ \
9099      ${srcdir}/media/webrtc/trunk/testing/gtest.gyp
9100    if test "$?" != 0; then
9101       AC_MSG_ERROR([failed to generate gtest Makefiles])
9102    fi
9104    AC_MSG_RESULT("generating nrappkit Makefiles...")
9105    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9106      $GYP_WEBRTC_OPTIONS \
9107      --generator-output=${_objdir}/media/mtransport/third_party/nrappkit \
9108      ${srcdir}/media/mtransport/third_party/nrappkit/nrappkit.gyp
9109    if test "$?" != 0; then
9110       AC_MSG_ERROR([failed to generate nrappkit Makefiles])
9111    fi
9113    AC_MSG_RESULT("generating nICEr Makefiles...")
9114    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium --format=mozmake \
9115      $GYP_WEBRTC_OPTIONS \
9116      --generator-output=${_objdir}/media/mtransport/third_party/nICEr \
9117      ${srcdir}/media/mtransport/third_party/nICEr/nicer.gyp
9118    if test "$?" != 0; then
9119       AC_MSG_ERROR([failed to generate nICEr Makefiles])
9120    fi
9123 # Generate a JSON config file for unittest harnesses etc to read
9124 # build configuration details from in a standardized way.
9125 OS_TARGET=${OS_TARGET} \
9126 TARGET_CPU=${TARGET_CPU} \
9127 MOZ_DEBUG=${MOZ_DEBUG} \
9128 MOZ_WIDGET_TOOLKIT=${MOZ_WIDGET_TOOLKIT} \
9129 UNIVERSAL_BINARY=${UNIVERSAL_BINARY} \
9130 MOZ_CRASHREPORTER=${MOZ_CRASHREPORTER} \
9131 MOZ_APP_NAME=${MOZ_APP_NAME} \
9132 TOPSRCDIR=${_topsrcdir} \
9133   $PYTHON ${_topsrcdir}/config/writemozinfo.py ./mozinfo.json.tmp
9134 if cmp -s ./mozinfo.json.tmp ./mozinfo.json; then
9135   rm ./mozinfo.json.tmp
9136 else
9137   mv -f ./mozinfo.json.tmp ./mozinfo.json
9140 # Run jemalloc configure script
9142 if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC3" -o -n "$MOZ_REPLACE_MALLOC"; then
9143   ac_configure_args="$_SUBDIR_CONFIG_ARGS --build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
9144   if test -n "$MOZ_REPLACE_MALLOC"; then
9145     # When using replace_malloc, we always want memalign and valloc exported from jemalloc.
9146     ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
9147     ac_configure_args="$ac_configure_args ac_cv_func_valloc=yes"
9148   fi
9149   if test -n "$MOZ_JEMALLOC3"; then
9150     case "${OS_ARCH}" in
9151       WINNT|Darwin)
9152         # We want jemalloc functions to be kept hidden on both Mac and Windows
9153         # See memory/build/mozmemory_wrap.h for details.
9154         ac_configure_args="$ac_configure_args --without-export"
9155         ;;
9156     esac
9157   elif test "${OS_ARCH}" = Darwin; then
9158     # When building as a replace-malloc lib, disabling the zone allocator
9159     # forces to use pthread_atfork.
9160     ac_configure_args="$ac_configure_args --disable-zone-allocator"
9161   fi
9162   _MANGLE="malloc posix_memalign aligned_alloc calloc realloc free memalign valloc malloc_usable_size"
9163   JEMALLOC_WRAPPER=
9164   if test -z "$MOZ_REPLACE_MALLOC"; then
9165     case "$OS_ARCH" in
9166       Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
9167         MANGLE=$_MANGLE
9168         ;;
9169     esac
9170   elif test -z "$MOZ_JEMALLOC3"; then
9171     MANGLE=$_MANGLE
9172     JEMALLOC_WRAPPER=replace_
9173   fi
9174   if test -n "$MANGLE"; then
9175     MANGLED=
9176     if test -n "$_WRAP_MALLOC" -a -z "$JEMALLOC_WRAPPER"; then
9177       JEMALLOC_WRAPPER=__wrap_
9178     fi
9179     for mangle in ${MANGLE}; do
9180       if test -n "$MANGLED"; then
9181         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle,$MANGLED"
9182       else
9183         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle"
9184       fi
9185     done
9186     ac_configure_args="$ac_configure_args --with-mangling=$MANGLED"
9187   fi
9188   unset CONFIG_FILES
9189   if test -z "$MOZ_TLS"; then
9190     ac_configure_args="$ac_configure_args --disable-tls"
9191   fi
9192   EXTRA_CFLAGS="$CFLAGS"
9193   for var in AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS EXTRA_CFLAGS LDFLAGS; do
9194     ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
9195   done
9196   if test "$CROSS_COMPILE"; then
9197     ac_configure_args="$ac_configure_args je_cv_static_page_shift=12"
9198   fi
9199   _save_cache_file="$cache_file"
9200   cache_file=$_objdir/memory/jemalloc/src/config.cache
9202   if ! test -e memory/jemalloc; then
9203     mkdir -p memory/jemalloc
9204   fi
9206   AC_OUTPUT_SUBDIRS(memory/jemalloc/src)
9207   cache_file="$_save_cache_file"
9208   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9211 # Run freetype configure script
9213 if test "$MOZ_TREE_FREETYPE"; then
9214    export CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS -std=c99"
9215    export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS"
9216    export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS"
9217    export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS"
9218    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
9219    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes"
9221    if ! test -e modules; then
9222      mkdir modules
9223    fi
9225    AC_OUTPUT_SUBDIRS(modules/freetype2)
9228 if test -z "$direct_nspr_config"; then
9229     dnl ========================================================
9230     dnl = Setup a nice relatively clean build environment for
9231     dnl = sub-configures.
9232     dnl ========================================================
9233     CC="$_SUBDIR_CC"
9234     CXX="$_SUBDIR_CXX"
9235     CFLAGS="$_SUBDIR_CFLAGS"
9236     CPPFLAGS="$_SUBDIR_CPPFLAGS"
9237     CXXFLAGS="$_SUBDIR_CXXFLAGS"
9238     LDFLAGS="$_SUBDIR_LDFLAGS"
9239     HOST_CC="$_SUBDIR_HOST_CC"
9240     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9241     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9242     RC=
9245 unset MAKEFILES
9246 unset CONFIG_FILES
9248 # Run all configure scripts specified by a subconfigure
9249 if test -n "$_subconfigure_subdir"; then
9250   _save_ac_configure_args="$ac_configure_args"
9251   ac_configure_args="$_subconfigure_config_args"
9252   AC_OUTPUT_SUBDIRS("$_subconfigure_subdir")
9253   ac_configure_args="$_save_ac_configure_args"
9256 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9257 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9259 export WRAP_LDFLAGS
9261 if test -n "$_WRAP_MALLOC"; then
9262     # Avoid doubling wrap malloc arguments
9263     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
9266 if test -z "$MOZ_NATIVE_NSPR"; then
9267     ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
9268     if test -z "$MOZ_DEBUG"; then
9269         ac_configure_args="$ac_configure_args --disable-debug"
9270     else
9271         ac_configure_args="$ac_configure_args --enable-debug"
9272     fi
9273     if test "$MOZ_OPTIMIZE" = "1"; then
9274         ac_configure_args="$ac_configure_args --enable-optimize"
9275     elif test -z "$MOZ_OPTIMIZE"; then
9276         ac_configure_args="$ac_configure_args --disable-optimize"
9277     fi
9278     if test -n "$HAVE_64BIT_OS"; then
9279         ac_configure_args="$ac_configure_args --enable-64bit"
9280     fi
9281     if test -n "$USE_ARM_KUSER"; then
9282         ac_configure_args="$ac_configure_args --with-arm-kuser"
9283     fi
9284     ac_configure_args="$ac_configure_args $NSPR_CONFIGURE_ARGS"
9285     if test -n "$MOZ_LINKER" -a "$ac_cv_func_dladdr" = no ; then
9286       # dladdr is supported by the new linker, even when the system linker doesn't
9287       # support it. Trick nspr into using dladdr when it's not supported.
9288       _SAVE_CPPFLAGS="$CPPFLAGS"
9289       export CPPFLAGS="-include $_topsrcdir/mozglue/linker/dladdr.h $CPPFLAGS"
9290     fi
9291     _SAVE_LDFLAGS="$LDFLAGS"
9292     export LDFLAGS="$LDFLAGS $NSPR_LDFLAGS"
9293     AC_OUTPUT_SUBDIRS(nsprpub)
9294     LDFLAGS="$_SAVE_LDFLAGS"
9295     if test -n "$MOZ_LINKER" -a "$ac_cv_func_dladdr" = no; then
9296       unset CPPFLAGS
9297       CPPFLAGS="$_SAVE_CFLAGS"
9298     fi
9299     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9302 dnl ========================================================
9303 dnl = Setup a nice relatively clean build environment for
9304 dnl = sub-configures.
9305 dnl ========================================================
9306 CC="$_SUBDIR_CC"
9307 CXX="$_SUBDIR_CXX"
9308 CFLAGS="$_SUBDIR_CFLAGS"
9309 CPPFLAGS="$_SUBDIR_CPPFLAGS"
9310 CXXFLAGS="$_SUBDIR_CXXFLAGS"
9311 LDFLAGS="$_SUBDIR_LDFLAGS"
9312 HOST_CC="$_SUBDIR_HOST_CC"
9313 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9314 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9317 # Run the SpiderMonkey 'configure' script.
9318 dist=$MOZ_BUILD_ROOT/dist
9319 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9320 ac_configure_args="$ac_configure_args --enable-threadsafe"
9321 if test "$BUILD_CTYPES"; then
9322     # Build js-ctypes on the platforms we can.
9323     ac_configure_args="$ac_configure_args --enable-ctypes"
9325 if test -z "$JS_SHARED_LIBRARY" ; then
9326     ac_configure_args="$ac_configure_args --disable-shared-js"
9328 if test -z "$MOZ_NATIVE_NSPR"; then
9329     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
9330     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
9332 ac_configure_args="$ac_configure_args --with-dist-dir=../../dist"
9333 ac_configure_args="$ac_configure_args --prefix=$dist"
9334 if test "$MOZ_MEMORY"; then
9335    ac_configure_args="$ac_configure_args --enable-jemalloc"
9337 if test -n "$MOZ_GLUE_LDFLAGS"; then
9338    export MOZ_GLUE_LDFLAGS
9340 if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
9341    export MOZ_GLUE_PROGRAM_LDFLAGS
9343 if test "$MOZ_NATIVE_ZLIB" != 1 -a "$OS_ARCH" = "WINNT"; then
9344    MOZ_ZLIB_LIBS=
9346 export MOZ_NATIVE_ZLIB
9347 export MOZ_ZLIB_CFLAGS
9348 export MOZ_ZLIB_LIBS
9349 export MOZ_APP_NAME
9350 export DONT_POPULATE_VIRTUALENV=1
9351 export PYTHON
9352 export MOZILLA_CENTRAL_PATH=$_topsrcdir
9353 export STLPORT_CPPFLAGS
9354 export STLPORT_LDFLAGS
9355 export STLPORT_LIBS
9356 export JS_STANDALONE=no
9358 if ! test -e js; then
9359     mkdir js
9362 AC_OUTPUT_SUBDIRS(js/src)
9363 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9365 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR