Bug 767240 - Make it easier to create type-specific scoped pointers (TYPE_SPECIFIC_SC...
[gecko.git] / configure.in
blobf2b4041c2bb9e4bf24184e852e2e813ec7e196a5
1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2 dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4:
3 dnl This Source Code Form is subject to the terms of the Mozilla Public
4 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
5 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 dnl Process this file with autoconf to produce a configure script.
8 dnl ========================================================
10 AC_PREREQ(2.13)
11 AC_INIT(config/config.mk)
12 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
13 AC_CANONICAL_SYSTEM
14 TARGET_CPU="${target_cpu}"
15 TARGET_VENDOR="${target_vendor}"
16 TARGET_OS="${target_os}"
18 MOZ_DEB_TIMESTAMP=`date +"%a, %d  %b %Y %T %z"   2>&1`
19 AC_SUBST(MOZ_DEB_TIMESTAMP)
21 dnl ========================================================
22 dnl =
23 dnl = Don't change the following two lines.  Doing so breaks:
24 dnl =
25 dnl = CFLAGS="-foo" ./configure
26 dnl =
27 dnl ========================================================
28 CFLAGS="${CFLAGS=}"
29 CPPFLAGS="${CPPFLAGS=}"
30 CXXFLAGS="${CXXFLAGS=}"
31 LDFLAGS="${LDFLAGS=}"
32 HOST_CFLAGS="${HOST_CFLAGS=}"
33 HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
34 HOST_LDFLAGS="${HOST_LDFLAGS=}"
36 dnl ========================================================
37 dnl = Preserve certain environment flags passed to configure
38 dnl = We want sub projects to receive the same flags
39 dnl = untainted by this configure script
40 dnl ========================================================
41 _SUBDIR_CC="$CC"
42 _SUBDIR_CXX="$CXX"
43 _SUBDIR_CFLAGS="$CFLAGS"
44 _SUBDIR_CPPFLAGS="$CPPFLAGS"
45 _SUBDIR_CXXFLAGS="$CXXFLAGS"
46 _SUBDIR_LDFLAGS="$LDFLAGS"
47 _SUBDIR_HOST_CC="$HOST_CC"
48 _SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
49 _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
50 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
51 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
53 dnl Set the version number of the libs included with mozilla
54 dnl ========================================================
55 MOZJPEG=62
56 MOZPNG=10511
57 NSPR_VERSION=4
58 NSS_VERSION=3
60 dnl Set the minimum version of toolkit libs used by mozilla
61 dnl ========================================================
62 GLIB_VERSION=1.2.0
63 PERL_VERSION=5.006
64 PYTHON_VERSION_MAJOR=2
65 PYTHON_VERSION_MINOR=5
66 CAIRO_VERSION=1.10
67 PANGO_VERSION=1.14.0
68 GTK2_VERSION=2.10.0
69 WINDRES_VERSION=2.14.90
70 W32API_VERSION=3.14
71 GNOMEVFS_VERSION=2.0
72 GNOMEUI_VERSION=2.2.0
73 GCONF_VERSION=1.2.1
74 GIO_VERSION=2.18
75 STARTUP_NOTIFICATION_VERSION=0.8
76 DBUS_VERSION=0.60
77 SQLITE_VERSION=3.7.14
79 MSMANIFEST_TOOL=
81 dnl Set various checks
82 dnl ========================================================
83 MISSING_X=
84 AC_PROG_AWK
86 dnl Initialize the Pthread test variables early so they can be
87 dnl  overridden by each platform.
88 dnl ========================================================
89 USE_PTHREADS=
90 _PTHREAD_LDFLAGS=""
92 dnl Do not allow a separate objdir build if a srcdir build exists.
93 dnl ==============================================================
94 _topsrcdir=`cd \`dirname $0\`; pwd`
95 _objdir=`pwd`
97 if test "$_topsrcdir" != "$_objdir"
98 then
99   # Check for a couple representative files in the source tree
100   _conflict_files=
101   for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
102     if test -f $file; then
103       _conflict_files="$_conflict_files $file"
104     fi
105   done
106   if test "$_conflict_files"; then
107     echo "***"
108     echo "*   Your source tree contains these files:"
109     for file in $_conflict_files; do
110       echo "*         $file"
111     done
112     cat 1>&2 <<-EOF
113         *   This indicates that you previously built in the source tree.
114         *   A source tree build can confuse the separate objdir build.
115         *
116         *   To clean up the source tree:
117         *     1. cd $_topsrcdir
118         *     2. gmake distclean
119         ***
120         EOF
121     exit 1
122     break
123   fi
125 MOZ_BUILD_ROOT=`pwd`
127 MOZ_DEFAULT_COMPILER
129 COMPILE_ENVIRONMENT=1
130 MOZ_ARG_DISABLE_BOOL(compile-environment,
131 [  --disable-compile-environment
132                           Disable compiler/library checks.],
133     COMPILE_ENVIRONMENT= )
134 AC_SUBST(COMPILE_ENVIRONMENT)
136 MOZ_ARG_WITH_STRING(l10n-base,
137 [  --with-l10n-base=DIR    path to l10n repositories],
138     L10NBASEDIR=$withval)
139 if test -n "$L10NBASEDIR"; then
140     if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
141         AC_MSG_ERROR([--with-l10n-base must specify a path])
142     elif test -d "$L10NBASEDIR"; then
143         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd`
144     else
145         AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
146     fi
148 AC_SUBST(L10NBASEDIR)
150 dnl Check for Perl first -- needed for win32 SDK checks
151 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
152 if test -z "$PERL" -o "$PERL" = ":"; then
153     AC_MSG_ERROR([perl not found in \$PATH])
156 AC_SUBST(GAIADIR)
157 if test -n "$GAIADIR" ; then
158     AC_DEFINE(PACKAGE_GAIA)
161 MOZ_ARG_WITH_STRING(gonk,
162 [  --with-gonk=DIR
163                location of gonk dir],
164     gonkdir=$withval)
166 MOZ_ARG_WITH_STRING(gonk-toolchain-prefix,
167 [  --with-gonk-toolchain-prefix=DIR
168                           prefix to gonk toolchain commands],
169     gonk_toolchain_prefix=$withval)
171 if test -n "$gonkdir" ; then
172     kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
173     android_source="$gonkdir"
174     ANDROID_SOURCE="$android_source"
175     ANDROID_NDK="${ANDROID_SOURCE}/ndk"
177     dnl set up compilers
178     TOOLCHAIN_PREFIX="$gonk_toolchain_prefix"
179     AS="$gonk_toolchain_prefix"as
180     CC="$gonk_toolchain_prefix"gcc
181     CXX="$gonk_toolchain_prefix"g++
182     CPP="$gonk_toolchain_prefix"cpp
183     LD="$gonk_toolchain_prefix"ld
184     AR="$gonk_toolchain_prefix"ar
185     RANLIB="$gonk_toolchain_prefix"ranlib
186     STRIP="$gonk_toolchain_prefix"strip
188     STLPORT_CPPFLAGS="-I$gonkdir/ndk/sources/cxx-stl/stlport/stlport/ -I$gonkdir/external/stlport/stlport/"
189     STLPORT_LIBS="-lstlport"
191     case "$target_cpu" in
192     arm)
193         ARCH_DIR=arch-arm
194         ;;
195     i?86)
196         ARCH_DIR=arch-x86
197         ;;
198     esac
200     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"
201     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
202     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS $STLPORT_CPPFLAGS"
203     dnl Add -llog by default, since we use it all over the place.
204     LIBS="$LIBS -llog $STLPORT_LIBS"
206     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"
208     dnl prevent cross compile section from using these flags as host flags
209     if test -z "$HOST_CPPFLAGS" ; then
210         HOST_CPPFLAGS=" "
211     fi
212     if test -z "$HOST_CFLAGS" ; then
213         HOST_CFLAGS=" "
214     fi
215     if test -z "$HOST_CXXFLAGS" ; then
216         HOST_CXXFLAGS=" "
217     fi
218     if test -z "$HOST_LDFLAGS" ; then
219         HOST_LDFLAGS=" "
220     fi
222     AC_DEFINE(ANDROID)
223     AC_DEFINE(HAVE_SYS_UIO_H)
224     AC_DEFINE(HAVE_PTHREADS)
225     CROSS_COMPILE=1
226     MOZ_CHROME_FILE_FORMAT=omni
227     direct_nspr_config=1
228 else
229     MOZ_ANDROID_NDK
231     case "$target" in
232     *-android*|*-linuxandroid*)
233         if test -z "$ANDROID_PACKAGE_NAME" ; then
234             ANDROID_PACKAGE_NAME='org.mozilla.$(MOZ_APP_NAME)'
235         fi
236         MOZ_CHROME_FILE_FORMAT=omni
237         ZLIB_DIR=yes
238         ;;
239     *-linux*)
240         AC_PATH_PROG(OBJCOPY,objcopy)
241         ;;
242     esac
245 AC_SUBST(ANDROID_SOURCE)
246 AC_SUBST(ANDROID_PACKAGE_NAME)
247 AC_SUBST(OBJCOPY)
249 dnl ========================================================
250 dnl Checks for compilers.
251 dnl ========================================================
252 dnl Set CROSS_COMPILE in the environment when running configure
253 dnl to use the cross-compile setup for now
254 dnl ========================================================
256 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
257 AR_FLAGS='cr $@'
259 if test "$COMPILE_ENVIRONMENT"; then
261 if test -n "$CROSS_COMPILE" -a "$target" != "$host"; then
262     echo "cross compiling from $host to $target"
263     cross_compiling=yes
265     _SAVE_CC="$CC"
266     _SAVE_CFLAGS="$CFLAGS"
267     _SAVE_LDFLAGS="$LDFLAGS"
269     AC_MSG_CHECKING([for host c compiler])
270     AC_CHECK_PROGS(HOST_CC, $HOST_CC gcc cc /usr/ucb/cc cl icc, "")
271     if test -z "$HOST_CC"; then
272         AC_MSG_ERROR([no acceptable c compiler found in \$PATH])
273     fi
274     AC_MSG_RESULT([$HOST_CC])
275     AC_MSG_CHECKING([for host c++ compiler])
276     AC_CHECK_PROGS(HOST_CXX, $HOST_CXX $CCC c++ g++ gcc CC cxx cc++ cl icc, "")
277     if test -z "$HOST_CXX"; then
278         AC_MSG_ERROR([no acceptable c++ compiler found in \$PATH])
279     fi
280     AC_MSG_RESULT([$HOST_CXX])
282     if test -z "$HOST_CFLAGS"; then
283         HOST_CFLAGS="$CFLAGS"
284     fi
285     if test -z "$HOST_CXXFLAGS"; then
286         HOST_CXXFLAGS="$CXXFLAGS"
287     fi
288     if test -z "$HOST_LDFLAGS"; then
289         HOST_LDFLAGS="$LDFLAGS"
290     fi
291     if test -z "$HOST_AR_FLAGS"; then
292         HOST_AR_FLAGS="$AR_FLAGS"
293     fi
294     AC_CHECK_PROGS(HOST_RANLIB, $HOST_RANLIB ranlib, ranlib, :)
295     AC_CHECK_PROGS(HOST_AR, $HOST_AR ar, ar, :)
296     CC="$HOST_CC"
297     CFLAGS="$HOST_CFLAGS"
298     LDFLAGS="$HOST_LDFLAGS"
300     AC_MSG_CHECKING([whether the host c compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works])
301     AC_TRY_COMPILE([], [return(0);],
302         [ac_cv_prog_hostcc_works=1 AC_MSG_RESULT([yes])],
303         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CC cannot create executables.]) )
305     CC="$HOST_CXX"
306     CFLAGS="$HOST_CXXFLAGS"
308     AC_MSG_CHECKING([whether the host c++ compiler ($HOST_CXX $HOST_CXXFLAGS $HOST_LDFLAGS) works])
309     AC_TRY_COMPILE([], [return(0);],
310         [ac_cv_prog_hostcxx_works=1 AC_MSG_RESULT([yes])],
311         AC_MSG_ERROR([installation or configuration problem: host compiler $HOST_CXX cannot create executables.]) )
313     CC=$_SAVE_CC
314     CFLAGS=$_SAVE_CFLAGS
315     LDFLAGS=$_SAVE_LDFLAGS
317     AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", :)
318     unset ac_cv_prog_CC
319     AC_PROG_CC
320     AC_CHECK_PROGS(CXX, $CXX "${target_alias}-g++" "${target}-g++", :)
321     unset ac_cv_prog_CXX
322     AC_PROG_CXX
324     AC_CHECK_PROGS(RANLIB, $RANLIB "${target_alias}-ranlib" "${target}-ranlib", :)
325     AC_CHECK_PROGS(AR, $AR "${target_alias}-ar" "${target}-ar", :)
326     MOZ_PATH_PROGS(AS, $AS "${target_alias}-as" "${target}-as", :)
327     AC_CHECK_PROGS(LD, $LD "${target_alias}-ld" "${target}-ld", :)
328     AC_CHECK_PROGS(STRIP, $STRIP "${target_alias}-strip" "${target}-strip", :)
329     AC_CHECK_PROGS(WINDRES, $WINDRES "${target_alias}-windres" "${target}-windres", :)
330     AC_DEFINE(CROSS_COMPILE)
331 else
332     AC_PROG_CC
333     case "$target" in
334     *-mingw*)
335       # Work around the conftest.exe access problem on Windows
336       sleep 2
337     esac
338     AC_PROG_CXX
339     AC_PROG_RANLIB
340     MOZ_PATH_PROGS(AS, $AS as, $CC)
341     AC_CHECK_PROGS(AR, ar, :)
342     AC_CHECK_PROGS(LD, ld, :)
343     AC_CHECK_PROGS(STRIP, strip, :)
344     AC_CHECK_PROGS(WINDRES, windres, :)
345     if test -z "$HOST_CC"; then
346         HOST_CC="$CC"
347     fi
348     if test -z "$HOST_CFLAGS"; then
349         HOST_CFLAGS="$CFLAGS"
350     fi
351     if test -z "$HOST_CXX"; then
352         HOST_CXX="$CXX"
353     fi
354     if test -z "$HOST_CXXFLAGS"; then
355         HOST_CXXFLAGS="$CXXFLAGS"
356     fi
357     if test -z "$HOST_LDFLAGS"; then
358         HOST_LDFLAGS="$LDFLAGS"
359     fi
360     if test -z "$HOST_RANLIB"; then
361         HOST_RANLIB="$RANLIB"
362     fi
363     if test -z "$HOST_AR"; then
364         HOST_AR="$AR"
365     fi
366     if test -z "$HOST_AR_FLAGS"; then
367         HOST_AR_FLAGS="$AR_FLAGS"
368     fi
371 if test -n "$MOZ_WINCONSOLE"; then
372     AC_DEFINE(MOZ_WINCONSOLE)
375 MOZ_TOOL_VARIABLES
377 dnl ========================================================
378 dnl Special win32 checks
379 dnl ========================================================
381 # With win8, sdk target=602, WINVER=602
382 MOZ_ARG_ENABLE_BOOL(metro,
383 [  --enable-metro           Enable Windows Metro build targets],
384     MOZ_METRO=1,
385     MOZ_METRO=)
386 if test -n "$MOZ_METRO"; then
387     AC_DEFINE(MOZ_METRO)
388     # Target the Windows 8 Kit
389     WINSDK_TARGETVER=602
390     # Allow a higher api set
391     WINVER=602
392     # toolkit/library/makefile.in needs these, see nsDllMain.
393     CRTDLLVERSION=110
394     CRTEXPDLLVERSION=1-1-0
395 else
396     # Target the Windows 7 SDK by default
397     WINSDK_TARGETVER=601
398     WINVER=502
401 AC_SUBST(CRTDLLVERSION)
402 AC_SUBST(CRTEXPDLLVERSION)
404 if test -n "$MOZ_METRO"; then
405   case "$target" in
406   *-mingw*)
407     ;;
408   *)
409     AC_MSG_ERROR([Metro builds only valid on the windows platform.]);
410     ;;
411   esac
414 MOZ_ARG_WITH_STRING(windows-version,
415 [  --with-windows-version=WINSDK_TARGETVER
416                           Windows SDK version to target. Lowest version
417                           currently allowed is 601 (Win7), highest is 602 (Win8)],
418   WINSDK_TARGETVER=$withval)
420 # Currently only two sdk versions allowed, 601 and 602
421 case "$WINSDK_TARGETVER" in
422 601|602)
423     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
424     ;;
427     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER)]);
428     ;;
429 esac
431 case "$target" in
432 *-mingw*)
433     if test "$GCC" != "yes"; then
434         # Check to see if we are really running in a msvc environemnt
435         _WIN32_MSVC=1
436         AC_CHECK_PROGS(MIDL, midl)
438         # Make sure compilers are valid
439         CFLAGS="$CFLAGS -TC -nologo"
440         CXXFLAGS="$CXXFLAGS -TP -nologo"
441         AC_LANG_SAVE
442         AC_LANG_C
443         AC_TRY_COMPILE([#include <stdio.h>],
444             [ printf("Hello World\n"); ],,
445             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
447         AC_LANG_CPLUSPLUS
448         AC_TRY_COMPILE([#include <new.h>],
449             [ unsigned *test = new unsigned(42); ],,
450             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
451         AC_LANG_RESTORE
453         changequote(,)
454         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
455         changequote([,])
457         # Determine compiler version
458         CC_VERSION=`"${CC}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
459         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
460         _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
461         _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
462         _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
463         _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
465         CXX_VERSION=`"${CXX}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
466         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
468         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
469             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
470         fi
472         if test "$_CC_MAJOR_VERSION" = "14"; then
473             dnl Require VC8SP1 or newer.
474             dnl VC8 is 14.00.50727.42, VC8SP1 is 14.00.50727.762.
475             if test "$_CC_RELEASE" -lt 50727 -o \
476                     \( "$_CC_RELEASE" -eq 50727 -a "$_CC_BUILD" -lt 762 \); then
477               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.])
478             fi
480             _CC_SUITE=8
481             _MSVS_VERSION=2005
482             AC_DEFINE(_CRT_SECURE_NO_DEPRECATE)
483             AC_DEFINE(_CRT_NONSTDC_NO_DEPRECATE)
484         elif test "$_CC_MAJOR_VERSION" = "15"; then
485             _CC_SUITE=9
486             _MSVS_VERSION=2008
487             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
488             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
489         elif test "$_CC_MAJOR_VERSION" = "16"; then
490             _CC_SUITE=10
491             _MSVS_VERSION=2010
492             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
493             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
494         elif test "$_CC_MAJOR_VERSION" = "17"; then
495             _CC_SUITE=11
496             _MSVS_VERSION=2012
497             AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
498             AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
499         else
500             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
501         fi
503         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
505         if test -n "$WIN32_REDIST_DIR"; then
506           if test ! -d "$WIN32_REDIST_DIR"; then
507             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
508           fi
509           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
510         fi
512         dnl Confirm we have the pri tools on win8 builds
513         if test -n "$MOZ_METRO"; then
514           AC_MSG_CHECKING([for makepri])
515           AC_CHECK_PROGS(MAKEPRI, makepri, "")
516           if test -z "MAKEPRI" ; then
517               AC_MSG_ERROR([makepri.exe is required for generating metro browser install components. It should be in the Win8 SDK.])
518           fi
519           AC_SUBST(MAKEPRI)
520         fi
522         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
523         dnl not something else like "magnetic tape manipulation utility".
524         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
525         if test -z "$MSMT_TOOL"; then
526           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
527         fi
529         changequote(,)
530         _MSMT_VER_FILTER='s|.*[^!-~]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
531         changequote([,])
532         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
533         if test -z "$MSMANIFEST_TOOL_VERSION"; then
534           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
535         fi
537         MSMANIFEST_TOOL=1
538         unset MSMT_TOOL
540         # Check linker version
541         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
542         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
543         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
544             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
545         fi
547         INCREMENTAL_LINKER=1
549         # Check midl version
550         _MIDL_FULL_VERSION=`"${MIDL}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
551         _MIDL_MAJOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
552         _MIDL_MINOR_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
553         _MIDL_REV_VERSION=`echo ${_MIDL_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
554         # Add flags if necessary
555         AC_MSG_CHECKING([for midl flags])
556         case "$target" in
557         i*86-*)
558             if test \( "$_MIDL_MAJOR_VERSION" = "7" -a "$_MIDL_MINOR_VERSION" = "00" -a "$_MIDL_REV_VERSION" = "0499" \); then
559                 # MIDL version 7.00.0499 defaults /env win64 on x64 platforms.
560                 # MIDL version 7.00.0500 or later has no problem.
561                 MIDL_FLAGS="${MIDL_FLAGS} -env win32"
562                 AC_MSG_RESULT([need -env win32])
563             else
564                 AC_MSG_RESULT([none needed])
565             fi
566             ;;
567         x86_64-*)
568             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
569             ;;
570         *)
571             AC_MSG_RESULT([none needed])
572             ;;
573         esac
575         # Identify which version of the SDK we're building with
576         # Windows Server 2008 and newer SDKs have WinSDKVer.h, get the version
577         # from there
578         MOZ_CHECK_HEADERS([winsdkver.h])
579         if test "$ac_cv_header_winsdkver_h" = "yes"; then
580             # Get the highest _WIN32_WINNT and NTDDI versions supported
581             # Take the higher of the two
582             # This is done because the Windows 7 beta SDK reports its
583             # NTDDI_MAXVER to be 0x06000100 instead of 0x06010000, as it should
584             AC_CACHE_CHECK(for highest Windows version supported by this SDK,
585                            ac_cv_winsdk_maxver,
586                            [cat > conftest.h <<EOF
587 #include <winsdkver.h>
588 #include <sdkddkver.h>
590 #if (NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER) > NTDDI_MAXVER)
591 #define WINSDK_MAXVER NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER)
592 #else
593 #define WINSDK_MAXVER NTDDI_MAXVER
594 #endif
596 WINSDK_MAXVER
598                             ac_cv_winsdk_maxver=`$CPP conftest.h 2>/dev/null | tail -n1`
599                             rm -f conftest.h
600                            ])
601             MOZ_WINSDK_MAXVER=${ac_cv_winsdk_maxver}
602         else
603             # Any SDK which doesn't have WinSDKVer.h is too old.
604             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.])
605         fi
607         unset _MSVC_VER_FILTER
609         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
610             [
611                 AC_LANG_SAVE
612                 AC_LANG_CPLUSPLUS
613                 _SAVE_CXXFLAGS="$CXXFLAGS"
614                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
615                 AC_TRY_COMPILE([#include <exception>],
616                             [std::_Throw(std::exception()); return 0;],
617                             ac_cv_have_std__Throw="yes",
618                             ac_cv_have_std__Throw="no")
619                 CXXFLAGS="$_SAVE_CXXFLAGS"
620                 AC_LANG_RESTORE
621             ])
623         if test "$ac_cv_have_std__Throw" = "yes"; then
624             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
625                            ac_cv_have_dllimport_exception_bug,
626                 [
627                     AC_LANG_SAVE
628                     AC_LANG_CPLUSPLUS
629                     _SAVE_CXXFLAGS="$CXXFLAGS"
630                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
631                     AC_TRY_LINK([#include <vector>],
632                                 [std::vector<int> v; return v.at(1);],
633                                 ac_cv_have_dllimport_exception_bug="no",
634                                 ac_cv_have_dllimport_exception_bug="yes")
635                     CXXFLAGS="$_SAVE_CXXFLAGS"
636                     AC_LANG_RESTORE
637                 ])
638             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
639                 WRAP_STL_INCLUDES=1
640                 MOZ_MSVC_STL_WRAP__Throw=1
641                 AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
642             fi
643         else
644             AC_CACHE_CHECK(for overridable _RAISE,
645                            ac_cv_have__RAISE,
646                 [
647                     AC_LANG_SAVE
648                     AC_LANG_CPLUSPLUS
649                     _SAVE_CXXFLAGS="$CXXFLAGS"
650                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
651                     AC_TRY_COMPILE([#include <xstddef>
652                                     #undef _RAISE
653                                     #define _RAISE(x) externallyDefinedFunction((x).what())
654                                     #include <vector>
655                                    ],
656                                    [std::vector<int> v; return v.at(1);],
657                                    ac_cv_have__RAISE="no",
658                                    ac_cv_have__RAISE="yes")
659                     CXXFLAGS="$_SAVE_CXXFLAGS"
660                     AC_LANG_RESTORE
661                 ])
662             if test "$ac_cv_have__RAISE" = "yes"; then
663                 WRAP_STL_INCLUDES=1
664                 MOZ_MSVC_STL_WRAP__RAISE=1
665                 AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
666             else
667                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
668             fi
669         fi
671         if test "$WRAP_STL_INCLUDES" = "1"; then
672             STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
673         fi
674     else
675         # Check w32api version
676         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
677         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
678         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
679         AC_TRY_COMPILE([#include <w32api.h>],
680             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
681                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
682                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
683                 #error "test failed."
684             #endif
685             , [ res=yes ], [ res=no ])
686         AC_MSG_RESULT([$res])
687         if test "$res" != "yes"; then
688             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
689         fi
690         # Check windres version
691         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
692         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
693         AC_MSG_RESULT([$_WINDRES_VERSION])
694         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
695         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
696         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
697         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
698         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
699         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
700         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
701                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
702                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
703                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
704                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
705                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
706         then
707             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
708         fi
710         MOZ_WINSDK_MAXVER=0x06020000
711     fi # !GNU_CC
713     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
714     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
715     # Require OS features provided by IE 6.0 SP2 (XP SP2)
716     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
718     # If the maximum version supported by this SDK is lower than the target
719     # version, error out
720     AC_MSG_CHECKING([for Windows SDK being recent enough])
721     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
722         AC_MSG_RESULT("yes")
723     else
724         AC_MSG_RESULT("no")
725         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.])
726     fi
727     
728     # Make sure the sdk / code we're targeting has the right toolset
729     AC_MSG_CHECKING([SDK and tools are in sync])
730     if test -n "$MOZ_METRO"; then
731       if test "$MOZ_MSVCVERSION" -gt "10"; then
732         AC_MSG_RESULT("yes")
733       else
734         AC_MSG_RESULT("no")
735         AC_MSG_ERROR([Your MOZ_MSVCVERSION equals $MOZ_MSVCVERSION and you've enabled metro build support. You can't target metro without msvc 11 or higher. Disable metro support or switch to a newer set of tools.])
736       fi
737     fi
738       
739     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
740     # Definitions matching sdkddkver.h
741     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
742     ;;
743 esac
745 AC_PROG_CPP
746 AC_PROG_CXXCPP
748 if test -n "$_WIN32_MSVC"; then
749     SKIP_PATH_CHECKS=1
750     SKIP_COMPILER_CHECKS=1
751     SKIP_LIBRARY_CHECKS=1
753     # Since we're skipping compiler and library checks, hard-code
754     # some facts here.
755     AC_DEFINE(HAVE_IO_H)
756     AC_DEFINE(HAVE_SETBUF)
757     AC_DEFINE(HAVE_ISATTY)
760 fi # COMPILE_ENVIRONMENT
762 AC_SUBST(MIDL_FLAGS)
763 AC_SUBST(_MSC_VER)
765 AC_SUBST(GNU_AS)
766 AC_SUBST(GNU_LD)
767 AC_SUBST(GNU_CC)
768 AC_SUBST(GNU_CXX)
769 AC_SUBST(INTEL_CC)
770 AC_SUBST(INTEL_CXX)
772 AC_SUBST(STL_FLAGS)
773 AC_SUBST(WRAP_STL_INCLUDES)
774 AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
775 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
777 dnl ========================================================
778 dnl Checks for programs.
779 dnl ========================================================
780 AC_PROG_INSTALL
781 AC_PROG_LN_S
783 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
784 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
785 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
786 _perl_res=$?
787 AC_MSG_RESULT([$_perl_version])
789 if test "$_perl_res" != 0; then
790     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
794 AC_MSG_CHECKING([for full perl installation])
795 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
796 _perl_res=$?
797 if test "$_perl_res" != 0; then
798     AC_MSG_RESULT([no])
799     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
800 else
801     AC_MSG_RESULT([yes])
804 MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python2.6 python2.5 python)
805 if test -z "$PYTHON"; then
806     AC_MSG_ERROR([python was not found in \$PATH])
809 MOZ_ARG_WITH_BOOL(system-ply,
810 [  --with-system-ply       Use system installed python ply library],
811     [if $PYTHON -c 'import ply' 2>&5; then
812          MOZ_SYSTEM_PLY=1
813      else
814          AC_MSG_ERROR([python ply library is not found but --with-system-ply was requested])
815      fi])
817 AC_SUBST(MOZ_SYSTEM_PLY)
819 if test -z "$COMPILE_ENVIRONMENT"; then
820     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
822 AC_SUBST(NSINSTALL_BIN)
824 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
825 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
826 MOZ_PATH_PROGS(UNZIP, unzip)
827 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
828     AC_MSG_ERROR([unzip not found in \$PATH])
830 MOZ_PATH_PROGS(ZIP, zip)
831 if test -z "$ZIP" -o "$ZIP" = ":"; then
832     AC_MSG_ERROR([zip not found in \$PATH])
834 MOZ_PATH_PROG(XARGS, xargs)
835 if test -z "$XARGS" -o "$XARGS" = ":"; then
836     AC_MSG_ERROR([xargs not found in \$PATH .])
839 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
840 AC_SUBST(RPMBUILD)
842 if test "$COMPILE_ENVIRONMENT"; then
844 dnl ========================================================
845 dnl = Mac OS X toolchain support
846 dnl ========================================================
848 case "$target_os" in
849 darwin*)
850     dnl Current known valid versions for GCC_VERSION are 2.95.2 3.1 3.3 4.0.
851     dnl 4.0 identifies itself as 4.0.x, so strip the decidecimal for
852     dnl the environment and includedir purposes (when using an SDK, below),
853     dnl but remember the full version number for the libdir (SDK).
854     changequote(,)
855     GCC_VERSION_FULL=`echo $CXX_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
856     GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
857     changequote([,])
858     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
859         dnl Bug 280479, but this keeps popping up in bug 292530 too because
860         dnl 4.0.0/4061 is the default compiler in Tiger.
861         changequote(,)
862         GCC_BUILD=`echo $CXX_VERSION | $PERL -pe 's/^.*build ([^ )]*).*/$1/'`
863         changequote([,])
864         if test "$GCC_BUILD" = "4061" ; then
865             AC_MSG_ERROR([You are attempting to use Apple gcc 4.0 build 4061.
866 This compiler was supplied with Xcode 2.0, and contains bugs that prevent it
867 from building Mozilla. Upgrade to Xcode 2.1 or later.])
868         fi
869     fi
871     dnl xcodebuild needs GCC_VERSION defined in the environment, since it
872     dnl doesn't respect the CC/CXX setting.  With GCC_VERSION set, it will use
873     dnl /usr/bin/g(cc|++)-$GCC_VERSION.
874     MOZ_PATH_PROGS(PBBUILD_BIN, pbbuild xcodebuild pbxbuild)
876     dnl sdp was formerly in /Developer/Tools.  As of Mac OS X 10.4 (Darwin 8),
877     dnl it has moved into /usr/bin.
878     MOZ_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
879     ;;
880 esac
882 AC_SUBST(GCC_VERSION)
884 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
885 dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
886 dnl when we can run target binaries.
887 AC_SUBST(UNIVERSAL_BINARY)
888 AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
890 dnl ========================================================
891 dnl Check for MacOS deployment target version
892 dnl ========================================================
894 MOZ_ARG_ENABLE_STRING(macos-target,
895                       [  --enable-macos-target=VER (default=10.6)
896                           Set the minimum MacOS version needed at runtime],
897                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
899 case "$target" in
900 *-darwin*)
901     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
902         dnl Use the specified value
903         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
904     else
905         dnl No value specified on the command line or in the environment,
906         dnl use architecture minimum.
907         export MACOSX_DEPLOYMENT_TARGET=10.6
908     fi
909     ;;
910 esac
912 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
914 dnl ========================================================
915 dnl = Mac OS X SDK support
916 dnl ========================================================
917 MACOS_SDK_DIR=
918 NEXT_ROOT=
919 MOZ_ARG_WITH_STRING(macos-sdk,
920 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
921     MACOS_SDK_DIR=$withval)
923 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
924 dnl NEXT_ROOT will be set and exported only if it's needed.
925 AC_SUBST(MACOS_SDK_DIR)
926 AC_SUBST(NEXT_ROOT)
928 if test "$MACOS_SDK_DIR"; then
929   dnl Sync this section with the ones in NSPR and NSS.
930   dnl Changes to the cross environment here need to be accounted for in
931   dnl the libIDL checks (below) and xpidl build.
933   if test ! -d "$MACOS_SDK_DIR"; then
934     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
935 specify a valid SDK.  SDKs are installed when the optional cross-development
936 tools are selected during the Xcode/Developer Tools installation.])
937   fi
939   GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
940   if test "$GCC_VERSION_MAJOR" -lt "4" ; then
941     AC_MSG_ERROR([You need to upgrade the compiler version to 4.x])
942   else
943     CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
944     CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
946     dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
947     CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
948     CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
950     if test "$GCC_VERSION_FULL" = "4.0.0" ; then
951       dnl If gcc >= 4.0, we're guaranteed to be on Tiger, which has an ld
952       dnl that supports -syslibroot.  Don't set NEXT_ROOT because it will
953       dnl be ignored and cause warnings when -syslibroot is specified.
954       dnl gcc 4.0.1 will pass -syslibroot to ld automatically based on
955       dnl the -isysroot it receives, so this is only needed with 4.0.0.
956       LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}"
957     fi
958   fi
960   AC_LANG_SAVE
961   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
962   AC_LANG_CPLUSPLUS
963   AC_TRY_COMPILE([#include <new>],[],
964    result=yes,
965    result=no)
966   AC_LANG_RESTORE
967   AC_MSG_RESULT($result)
969   if test "$result" = "no" ; then
970     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
971   fi
974 fi # COMPILE_ENVIRONMENT
976 AC_MSG_CHECKING([compiler version])
977 # Just print it so it shows up in the logs.
978 cc_version=$($CC --version)
979 AC_MSG_RESULT([$cc_version])
981 if test -n "$MAKE"; then
982   if test `echo $MAKE | grep -c make.py` != 1; then
983      NOT_PYMAKE=$MAKE
984   fi
987 case "$host_os" in
988 mingw*)
989     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
990     ;;
992     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
993     ;;
994 esac
995 if test "$GMAKE" = ":"; then
996    AC_MSG_ERROR([GNU make not found])
998 AC_SUBST(GMAKE)
1000 if test -z "$MAKE"; then
1001   MAKE=$GMAKE
1004 if test "$COMPILE_ENVIRONMENT"; then
1006 AC_PATH_XTRA
1008 XCFLAGS="$X_CFLAGS"
1010 fi # COMPILE_ENVIRONMENT
1012 dnl ========================================================
1013 dnl set the defaults first
1014 dnl ========================================================
1015 AS_BIN=$AS
1016 AR_LIST='$(AR) t'
1017 AR_EXTRACT='$(AR) x'
1018 AR_DELETE='$(AR) d'
1019 AS='$(CC)'
1020 AS_DASH_C_FLAG='-c'
1021 DLL_PREFIX=lib
1022 LIB_PREFIX=lib
1023 DLL_SUFFIX=.so
1024 OBJ_SUFFIX=o
1025 LIB_SUFFIX=a
1026 ASM_SUFFIX=s
1027 IMPORT_LIB_SUFFIX=
1028 TARGET_MD_ARCH=unix
1029 DIRENT_INO=d_ino
1030 MOZ_USER_DIR=".mozilla"
1032 MOZ_JPEG_CFLAGS=
1033 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)'
1034 MOZ_BZ2_CFLAGS=
1035 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
1036 MOZ_PNG_CFLAGS=
1037 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
1039 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
1040 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
1041 DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core -lmozalloc'
1042 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
1043 XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom -lmozalloc'
1044 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
1045 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
1046 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
1048 # These are specially defined on Windows only
1049 case "$target" in
1050 *-mingw*)
1051   XPCOM_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
1052   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime.$(LIB_SUFFIX)'
1053   ;;
1055   XPCOM_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_GLUE_LDOPTS
1056   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_STANDALONE_GLUE_LDOPTS
1057   ;;
1058 esac
1060 MOZ_FS_LAYOUT=unix
1062 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
1064 USE_DEPENDENT_LIBS=1
1066 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
1068 if test -n "$CROSS_COMPILE"; then
1069     OS_TARGET="${target_os}"
1070     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
1071     OS_RELEASE=
1072     case "${target_os}" in
1073         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
1074         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
1075         gnu*)         OS_ARCH=GNU ;;
1076         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
1077         mingw*)       OS_ARCH=WINNT OS_TARGET=WINNT ;;
1078         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
1079     esac
1080     case "${target}" in
1081         *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
1082     esac
1083 else
1084     OS_TARGET=`uname -s`
1085     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
1086     OS_RELEASE=`uname -r`
1089 # Before this used `uname -m` when not cross compiling
1090 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
1091 OS_TEST="${target_cpu}"
1093 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
1095 #######################################################################
1096 # Master "Core Components" macros for getting the OS target           #
1097 #######################################################################
1100 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
1101 # cross-compilation.
1105 # Define and override various archtecture-specific variables, including
1106 # HOST_OS_ARCH
1107 # OS_ARCH
1108 # OS_TEST
1109 # OS_TARGET
1110 # OS_RELEASE
1111 # OS_MINOR_RELEASE
1114 case "$HOST_OS_ARCH" in
1115 mingw*)
1116     HOST_OS_ARCH=WINNT
1117     ;;
1118 darwin*)
1119     HOST_OS_ARCH=Darwin
1120     ;;
1121 linux*)
1122     HOST_OS_ARCH=Linux
1123     ;;
1124 solaris*)
1125     HOST_OS_ARCH=SunOS
1126     SOLARIS_SUNPRO_CC=
1127     SOLARIS_SUNPRO_CXX=
1128     if test -z "$GNU_CC"; then
1129         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1130             SOLARIS_SUNPRO_CC=1
1131        fi
1132     fi
1134     if test -z "$GNU_CXX"; then
1135        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1136            SOLARIS_SUNPRO_CXX=1
1137        fi
1138     fi
1139     AC_SUBST(SOLARIS_SUNPRO_CC)
1140     AC_SUBST(SOLARIS_SUNPRO_CXX)
1141     ;;
1142 BSD_386)
1143     HOST_OS_ARCH=BSD
1144     ;;
1145 OS_2)
1146     HOST_OS_ARCH=OS2
1147     ;;
1148 esac
1150 case "$OS_ARCH" in
1151 WINNT)
1152     if test -z "$CROSS_COMPILE" ; then
1153         OS_TEST=`uname -p`
1154     fi
1155     ;;
1156 Windows_NT)
1158 # If uname -s returns "Windows_NT", we assume that we are using
1159 # the uname.exe in MKS toolkit.
1161 # The -r option of MKS uname only returns the major version number.
1162 # So we need to use its -v option to get the minor version number.
1163 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1165     OS_ARCH=WINNT
1166     OS_TARGET=WINNT
1167     OS_MINOR_RELEASE=`uname -v`
1168     if test "$OS_MINOR_RELEASE" = "00"; then
1169         OS_MINOR_RELEASE=0
1170     fi
1171     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1172     ;;
1173 MINGW*_NT*)
1175 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1176 # the uname.exe in the MSYS tools.
1178     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1179     OS_ARCH=WINNT
1180     OS_TARGET=WINNT
1181     ;;
1182 AIX)
1183     OS_RELEASE=`uname -v`.`uname -r`
1184     OS_TEST=${target_cpu}
1185     ;;
1186 BSD_386)
1187     OS_ARCH=BSD
1188     ;;
1189 OS_2)
1190     OS_ARCH=OS2
1191     OS_TARGET=OS2
1192     OS_RELEASE=`uname -v`
1193     ;;
1194 Darwin)
1195     case "${target_cpu}" in
1196     powerpc*)
1197         OS_TEST=ppc
1198         ;;
1199     i*86*)
1200         OS_TEST=i386
1201         ;;
1202     x86_64)
1203         OS_TEST=x86_64
1204         ;;
1205     *)
1206         if test -z "$CROSS_COMPILE" ; then
1207             OS_TEST=`uname -p`
1208         fi
1209         ;;
1210     esac
1211     ;;
1212 esac
1214 # Only set CPU_ARCH if we recognize the value of OS_TEST
1216 case "$OS_TEST" in
1217 *86 | i86pc)
1218     CPU_ARCH=x86
1219     ;;
1221 powerpc64 | ppc64)
1222     CPU_ARCH=ppc64
1223     ;;
1225 powerpc | ppc | rs6000)
1226     CPU_ARCH=ppc
1227     ;;
1229 Alpha | alpha | ALPHA)
1230     CPU_ARCH=Alpha
1231     ;;
1233 s390)
1234     CPU_ARCH=s390
1235     ;;
1237 s390x)
1238     CPU_ARCH=s390x
1239     ;;
1241 hppa* | parisc)
1242     CPU_ARCH=hppa
1243     ;;
1245 sun4u | sparc*)
1246     CPU_ARCH=sparc
1247     ;;
1249 x86_64 | ia64)
1250     CPU_ARCH="$OS_TEST"
1251     ;;
1253 arm*)
1254     CPU_ARCH=arm
1255     ;;
1257 mips|mipsel)
1258     CPU_ARCH="mips"
1259     ;;
1260 esac
1262 if test -z "$OS_TARGET"; then
1263     OS_TARGET=$OS_ARCH
1265 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1267 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1268 dnl ===============================================================
1269 INTEL_ARCHITECTURE=
1270 case "$OS_TEST" in
1271     x86_64|i?86)
1272       INTEL_ARCHITECTURE=1
1273 esac
1275 dnl Configure platform-specific CPU architecture compiler options.
1276 dnl ==============================================================
1277 MOZ_ARCH_OPTS
1279 dnl =================================================================
1280 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1281 dnl which is bad when cross compiling.
1282 dnl =================================================================
1283 if test "$COMPILE_ENVIRONMENT"; then
1284 configure_static_assert_macros='
1285 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1286 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1287 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1290 dnl test that the macros actually work:
1291 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1292 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1293  [AC_LANG_SAVE
1294   AC_LANG_C
1295   ac_cv_static_assertion_macros_work="yes"
1296   AC_TRY_COMPILE([$configure_static_assert_macros],
1297                  [CONFIGURE_STATIC_ASSERT(1)],
1298                  ,
1299                  ac_cv_static_assertion_macros_work="no")
1300   AC_TRY_COMPILE([$configure_static_assert_macros],
1301                  [CONFIGURE_STATIC_ASSERT(0)],
1302                  ac_cv_static_assertion_macros_work="no",
1303                  )
1304   AC_LANG_CPLUSPLUS
1305   AC_TRY_COMPILE([$configure_static_assert_macros],
1306                  [CONFIGURE_STATIC_ASSERT(1)],
1307                  ,
1308                  ac_cv_static_assertion_macros_work="no")
1309   AC_TRY_COMPILE([$configure_static_assert_macros],
1310                  [CONFIGURE_STATIC_ASSERT(0)],
1311                  ac_cv_static_assertion_macros_work="no",
1312                  )
1313   AC_LANG_RESTORE
1314  ])
1315 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1316 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1317     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1319 fi # COMPILE_ENVIRONMENT
1321 dnl ========================================================
1322 dnl Android libstdc++, placed here so it can use MOZ_ARCH
1323 dnl computed above.
1324 dnl ========================================================
1326 MOZ_ANDROID_STLPORT
1328 dnl ========================================================
1329 dnl Suppress Clang Argument Warnings
1330 dnl ========================================================
1331 if test -n "$CLANG_CC"; then
1332     _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
1333     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
1335 if test -n "$CLANG_CXX"; then
1336     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
1339 dnl ========================================================
1340 dnl = Use Address Sanitizer
1341 dnl ========================================================
1342 MOZ_ARG_ENABLE_BOOL(address-sanitizer,
1343 [  --enable-address-sanitizer       Enable Address Sanitizer (default=no)],
1344     MOZ_ASAN=1,
1345     MOZ_ASAN= )
1346 if test -n "$MOZ_ASAN"; then
1347     MOZ_LLVM_HACKS=1
1348     AC_DEFINE(MOZ_ASAN)
1350 AC_SUBST(MOZ_ASAN)
1352 dnl ========================================================
1353 dnl = Enable hacks required for LLVM instrumentations
1354 dnl ========================================================
1355 MOZ_ARG_ENABLE_BOOL(llvm-hacks,
1356 [  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)],
1357     MOZ_LLVM_HACKS=1,
1358     MOZ_LLVM_HACKS= )
1359 if test -n "$MOZ_LLVM_HACKS"; then
1360     MOZ_NO_WLZDEFS=1
1361     MOZ_CFLAGS_NSS=1
1363 AC_SUBST(MOZ_NO_WLZDEFS)
1364 AC_SUBST(MOZ_CFLAGS_NSS)
1366 dnl ========================================================
1367 dnl GNU specific defaults
1368 dnl ========================================================
1369 if test "$GNU_CC"; then
1370     # FIXME: Let us build with strict aliasing. bug 414641.
1371     CFLAGS="$CFLAGS -fno-strict-aliasing"
1372     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1373     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$@ -o $@'
1374     DSO_LDOPTS='-shared'
1375     if test "$GCC_USE_GNU_LD"; then
1376         # Some tools like ASan use a runtime library that is only
1377         # linked against executables, so we must allow undefined
1378         # symbols for shared objects in some cases.
1379         if test -z "$MOZ_NO_WLZDEFS"; then
1380             # Don't allow undefined symbols in libraries
1381             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1382         fi
1383     fi
1384     WARNINGS_AS_ERRORS='-Werror -Wno-error=uninitialized'
1385     DSO_CFLAGS=''
1386     DSO_PIC_CFLAGS='-fPIC'
1387     ASFLAGS="$ASFLAGS -fPIC"
1388     AC_MSG_CHECKING([for --noexecstack option to as])
1389     _SAVE_CFLAGS=$CFLAGS
1390     CFLAGS="$CFLAGS -Wa,--noexecstack"
1391     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
1392                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
1393                      AC_MSG_RESULT([no]))
1394     CFLAGS=$_SAVE_CFLAGS
1395     AC_MSG_CHECKING([for -z noexecstack option to ld])
1396     _SAVE_LDFLAGS=$LDFLAGS
1397     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
1398     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
1399                   AC_MSG_RESULT([no])
1400                   LDFLAGS=$_SAVE_LDFLAGS)
1402     # Check for -mssse3 on $CC
1403     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
1404     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
1405     _SAVE_CFLAGS=$CFLAGS
1406     CFLAGS="$CFLAGS -mssse3"
1407     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
1408                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
1409                      AC_MSG_RESULT([no]))
1410     CFLAGS=$_SAVE_CFLAGS
1411     AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
1413     # Turn on GNU-specific warnings:
1414     # -Wall - turn on a lot of warnings
1415     # -pedantic - this is turned on below
1416     # -Wpointer-arith - enabled with -pedantic, but good to have even if not
1417     # -Wdeclaration-after-statement - MSVC doesn't like these
1418     # -Werror=return-type - catches missing returns, zero false positives
1419     # -Wtype-limits - catches overflow bugs, few false positives
1420     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1421     #
1422     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
1423     MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
1424     MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
1425     MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
1426     
1427     # Turn off the following warnings that -Wall/-pedantic turn on:
1428     # -Wno-unused - lots of violations in third-party code
1429     # -Wno-overlength-strings - we exceed the minimum maximum length frequently
1430     #
1431     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
1432     MOZ_C_SUPPORTS_WARNING(-Wno-, overlength-strings, ac_c_has_wno_overlength_strings)
1434     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
1435        # Don't use -Wcast-align with ICC or clang
1436        case "$CPU_ARCH" in
1437            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1438            hppa | ia64 | sparc | arm)
1439            ;;
1440            *)
1441         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1442            ;;
1443        esac
1444     fi
1446     dnl Turn pedantic on but disable the warnings for long long
1447     _PEDANTIC=1
1449     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1450     _USE_CPP_INCLUDE_FLAG=1
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     # -pedantic - this is turned on below
1483     # -Wpointer-arith - enabled with -pedantic, but good to have even if not
1484     # -Woverloaded-virtual - ???
1485     # -Werror=return-type - catches missing returns, zero false positives
1486     # -Wtype-limits - catches overflow bugs, few false positives
1487     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1488     #
1489     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
1490     MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
1491     MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
1492     MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
1494     # Turn off the following warnings that -Wall/-pedantic turn on:
1495     # -Wno-ctor-dtor-privacy - ???
1496     # -Wno-overlength-strings - we exceed the minimum maximum length frequently 
1497     # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
1498     # -Wno-variadic-macros - ???
1499     #
1500     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-ctor-dtor-privacy"
1501     MOZ_CXX_SUPPORTS_WARNING(-Wno-, overlength-strings, ac_cxx_has_wno_overlength_strings)
1502     MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
1503     MOZ_CXX_SUPPORTS_WARNING(-Wno-, variadic-macros, ac_cxx_has_wno_variadic_macros)
1505     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
1506        # Don't use -Wcast-align with ICC or clang
1507        case "$CPU_ARCH" in
1508            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1509            hppa | ia64 | sparc | arm)
1510            ;;
1511            *)
1512         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1513            ;;
1514        esac
1515     fi
1517     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1518     _USE_CPP_INCLUDE_FLAG=1
1520     # Recent clang and gcc support C++11 deleted functions without warnings if
1521     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
1522     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
1523     # unused.  But clang's warning can be disabled, so when compiling with clang
1524     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
1525     # deleted function syntax.
1526     if test "$CLANG_CXX"; then
1527         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
1528         MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
1529     fi
1531 else
1532     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
1535 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1536 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1537 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1538 dnl normal behavior.
1539 dnl ========================================================
1540 MKSHLIB_FORCE_ALL=
1541 MKSHLIB_UNFORCE_ALL=
1543 if test "$COMPILE_ENVIRONMENT"; then
1544 if test "$GNU_CC"; then
1545   AC_MSG_CHECKING(whether ld has archive extraction flags)
1546   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1547    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1548     ac_cv_mkshlib_force_and_unforce="no"
1549     exec 3<&0 <<LOOP_INPUT
1550         force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1551         force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1552         force="-Wl,-all";              unforce="-Wl,-none"
1553 LOOP_INPUT
1554     while read line
1555     do
1556       eval $line
1557       LDFLAGS=$force
1558       LIBS=$unforce
1559       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1560     done
1561     exec 0<&3 3<&-
1562     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1563    ])
1564   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1565     AC_MSG_RESULT(no)
1566   else
1567     AC_MSG_RESULT(yes)
1568     eval $ac_cv_mkshlib_force_and_unforce
1569     MKSHLIB_FORCE_ALL=$force
1570     MKSHLIB_UNFORCE_ALL=$unforce
1571   fi
1572 fi # GNU_CC
1573 fi # COMPILE_ENVIRONMENT
1575 dnl ========================================================
1576 dnl Checking for 64-bit OS
1577 dnl ========================================================
1578 if test "$COMPILE_ENVIRONMENT"; then
1579 AC_LANG_SAVE
1580 AC_LANG_C
1581 AC_MSG_CHECKING(for 64-bit OS)
1582 AC_TRY_COMPILE([$configure_static_assert_macros],
1583                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1584                result="yes", result="no")
1585 AC_MSG_RESULT("$result")
1586 if test "$result" = "yes"; then
1587     AC_DEFINE(HAVE_64BIT_OS)
1588     HAVE_64BIT_OS=1
1590 AC_SUBST(HAVE_64BIT_OS)
1591 AC_LANG_RESTORE
1592 fi # COMPILE_ENVIRONMENT
1594 dnl ========================================================
1595 dnl Enable high-memory support on OS/2 by default.
1596 dnl ========================================================
1597 MOZ_OS2_HIGH_MEMORY=1
1598 MOZ_ARG_DISABLE_BOOL(os2-high-mem,
1599 [  --disable-os2-high-mem  Disable high-memory support on OS/2],
1600     MOZ_OS2_HIGH_MEMORY=,
1601     MOZ_OS2_HIGH_MEMORY=1 )
1602 AC_SUBST(MOZ_OS2_HIGH_MEMORY)
1604 dnl ========================================================
1605 dnl = Use profiling compile flags
1606 dnl ========================================================
1607 MOZ_ARG_ENABLE_BOOL(profiling,
1608 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1609     MOZ_PROFILING=1,
1610     MOZ_PROFILING= )
1612 # For profiling builds keep the symbol information
1613 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
1614     STRIP_FLAGS="--strip-debug"
1617 dnl ========================================================
1618 dnl = Use incremental GC
1619 dnl ========================================================
1620 JSGC_INCREMENTAL=1
1621 MOZ_ARG_DISABLE_BOOL(gcincremental,
1622 [  --disable-gcincremental Disable incremental GC],
1623     JSGC_INCREMENTAL= )
1624 if test -n "$JSGC_INCREMENTAL"; then
1625     AC_DEFINE(JSGC_INCREMENTAL)
1628 dnl ========================================================
1629 dnl = Use generational GC
1630 dnl ========================================================
1631 MOZ_ARG_ENABLE_BOOL(gcgenerational,
1632 [  --enable-gcgenerational Enable generational GC],
1633     JSGC_GENERATIONAL=1,
1634     JSGC_GENERATIONAL= )
1635 if test -n "$JSGC_GENERATIONAL"; then
1636     AC_DEFINE(JSGC_GENERATIONAL)
1639 dnl ========================================================
1640 dnl = Perform moving GC stack rooting analysis
1641 dnl ========================================================
1642 MOZ_ARG_ENABLE_BOOL(root-analysis,
1643 [  --enable-root-analysis  Enable moving GC stack root analysis],
1644     JSGC_ROOT_ANALYSIS=1,
1645     JSGC_ROOT_ANALYSIS= )
1646 if test -n "$JSGC_ROOT_ANALYSIS"; then
1647     AC_DEFINE(JSGC_ROOT_ANALYSIS)
1650 dnl ========================================================
1651 dnl = Use exact stack rooting for GC
1652 dnl ========================================================
1653 MOZ_ARG_ENABLE_BOOL(exact-rooting,
1654 [  --enable-exact-rooting  Enable use of exact stack roots for GC],
1655     JSGC_USE_EXACT_ROOTING=1,
1656     JSGC_USE_EXACT_ROOTING= )
1657 if test -n "$JSGC_USE_EXACT_ROOTING"; then
1658     AC_DEFINE(JSGC_USE_EXACT_ROOTING)
1661 dnl ========================================================
1662 dnl = Use Valgrind
1663 dnl ========================================================
1664 MOZ_ARG_ENABLE_BOOL(valgrind,
1665 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
1666     MOZ_VALGRIND=1,
1667     MOZ_VALGRIND= )
1668 if test -n "$MOZ_VALGRIND"; then
1669     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1670         AC_MSG_ERROR(
1671             [--enable-valgrind specified but Valgrind is not installed]))
1672     AC_DEFINE(MOZ_VALGRIND)
1674 AC_SUBST(MOZ_VALGRIND)
1676 dnl ========================================================
1677 dnl = Use DMD
1678 dnl ========================================================
1679 MOZ_ARG_ENABLE_BOOL(dmd,
1680 [  --enable-dmd            Enable DMD; also disables jemalloc (default=no)],
1681     MOZ_DMD=1,
1682     MOZ_DMD= )
1683 if test -n "$MOZ_DMD"; then
1684     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1685         AC_MSG_ERROR(
1686             [--enable-dmd specified but Valgrind is not installed]))
1687     AC_DEFINE(MOZ_DMD)
1690 dnl ========================================================
1691 dnl jprof
1692 dnl ========================================================
1693 MOZ_ARG_ENABLE_BOOL(jprof,
1694 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
1695     MOZ_JPROF=1,
1696     MOZ_JPROF= )
1697 if test -n "$MOZ_JPROF"; then
1698     MOZ_PROFILING=1
1699     AC_DEFINE(MOZ_JPROF)
1702 dnl ========================================================
1703 dnl SPS Profiler
1704 dnl ========================================================
1705 MOZ_ENABLE_PROFILER_SPS=1
1707 case "${OS_TARGET}" in
1708 Android)
1709     case "${CPU_ARCH}" in
1710     x86 | arm) ;;
1711     *)
1712         MOZ_ENABLE_PROFILER_SPS=
1713     esac
1714     ;;
1715 Linux)
1716     case "${CPU_ARCH}" in
1717     x86 | x86_64) ;;
1718     *)
1719         MOZ_ENABLE_PROFILER_SPS=
1720     esac
1721     ;;
1722 WINNT|Darwin) ;;
1724     MOZ_ENABLE_PROFILER_SPS=
1725     ;;
1726 esac
1728 if test -n "$MOZ_ENABLE_PROFILER_SPS"; then
1729     AC_DEFINE(MOZ_ENABLE_PROFILER_SPS)
1732 dnl ========================================================
1733 dnl shark
1734 dnl ========================================================
1735 MOZ_ARG_ENABLE_BOOL(shark,
1736 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
1737     MOZ_SHARK=1,
1738     MOZ_SHARK= )
1739 if test -n "$MOZ_SHARK"; then
1740     MOZ_PROFILING=1
1741     AC_DEFINE(MOZ_SHARK)
1744 dnl ========================================================
1745 dnl callgrind
1746 dnl ========================================================
1747 MOZ_ARG_ENABLE_BOOL(callgrind,
1748 [  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.],
1749     MOZ_CALLGRIND=1,
1750     MOZ_CALLGRIND= )
1751 if test -n "$MOZ_CALLGRIND"; then
1752     MOZ_PROFILING=1
1753     AC_DEFINE(MOZ_CALLGRIND)
1756 dnl ========================================================
1757 dnl vtune
1758 dnl ========================================================
1759 MOZ_ARG_ENABLE_BOOL(vtune,
1760 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
1761     MOZ_VTUNE=1,
1762     MOZ_VTUNE= )
1763 if test -n "$MOZ_VTUNE"; then
1764     MOZ_PROFILING=1
1765     AC_DEFINE(MOZ_VTUNE)
1768 dnl ========================================================
1769 dnl Profiling
1770 dnl ========================================================
1771 if test -n "$MOZ_PROFILING"; then
1772     AC_DEFINE(MOZ_PROFILING)
1775 dnl ========================================================
1776 dnl System overrides of the defaults for host
1777 dnl ========================================================
1778 case "$host" in
1779 *mingw*)
1780     if test -n "$_WIN32_MSVC"; then
1781         HOST_AR=lib
1782         HOST_AR_FLAGS='-NOLOGO -OUT:"$@"'
1783         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo -Fd\$(HOST_PDBFILE)"
1784         HOST_RANLIB='echo ranlib'
1785     else
1786         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
1787     fi
1788     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
1789     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1790     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1791     HOST_BIN_SUFFIX=.exe
1792     case "$host" in
1793     *mingw*)
1794         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1795         ;;
1796     esac
1798     case "${host_cpu}" in
1799     i*86)
1800         if test -n "$_WIN32_MSVC"; then
1801             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
1802         fi
1803         ;;
1804     x86_64)
1805         if test -n "$_WIN32_MSVC"; then
1806             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
1807         fi
1808         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1809         ;;
1810     esac
1811     ;;
1813 *-darwin*)
1814     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1815     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1816     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1817     ;;
1819 *-linux*|*-kfreebsd*-gnu|*-gnu*)
1820     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1821     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1822     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1823     ;;
1825 *os2*)
1826     HOST_CFLAGS="$HOST_CFLAGS -DXP_OS2 -DNO_X11 -Zomf"
1827     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
1828     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1829     HOST_BIN_SUFFIX=.exe
1830     MOZ_FIX_LINK_PATHS=
1831     ;;
1834     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1835     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1836     ;;
1837 esac
1839 dnl We require version 2.5 or newer of Python to build.
1840 AC_MSG_CHECKING([for Python version >= $PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR but not 3.x])
1842 changequote(:)
1843 read python_version_major python_version_minor python_version_micro <<EOF
1844 `$PYTHON -c 'import sys; print sys.version_info[0], sys.version_info[1], sys.version_info[2]'`
1846 changequote([,])
1848 if test $python_version_major -ne $PYTHON_VERSION_MAJOR; then
1849     AC_MSG_ERROR([Cannot build on Python $python_version_major.])
1850 else
1851     if test $python_version_minor -lt $PYTHON_VERSION_MINOR; then
1852         AC_MSG_ERROR([Cannot build on Python $python_version_major.$python_version_minor. You need at least $PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR.])
1853     fi
1855 AC_MSG_RESULT([yes])
1857 dnl Check for using a custom <stdint.h> implementation
1858 dnl ========================================================
1859 AC_MSG_CHECKING(for custom <stdint.h> implementation)
1860 if test "$MOZ_CUSTOM_STDINT_H"; then
1861   AC_DEFINE_UNQUOTED(MOZ_CUSTOM_STDINT_H, "$MOZ_CUSTOM_STDINT_H")
1862   AC_MSG_RESULT(using $MOZ_CUSTOM_STDINT_H)
1863 else
1864   AC_MSG_RESULT(none specified)
1867 dnl Get mozilla version from central milestone file
1868 MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
1869 MOZILLA_UAVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -uaversion`
1871 dnl Get version of various core apps from the version files.
1872 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
1874 if test -z "$FIREFOX_VERSION"; then
1875     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
1878 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
1879 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
1880 AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
1882 MOZ_DOING_LTO(lto_is_enabled)
1884 dnl ========================================================
1885 dnl System overrides of the defaults for target
1886 dnl ========================================================
1888 case "$target" in
1889 *-aix*)
1890     AC_DEFINE(AIX)
1891     if test ! "$GNU_CC"; then
1892         if test ! "$HAVE_64BIT_OS"; then
1893             # Compiling with Visual Age C++ object model compat is the
1894             # default. To compile with object model ibm, add
1895             # AIX_OBJMODEL=ibm to .mozconfig.
1896             if test "$AIX_OBJMODEL" = "ibm"; then
1897                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
1898             else
1899                 AIX_OBJMODEL=compat
1900             fi
1901         else
1902             AIX_OBJMODEL=compat
1903         fi
1904         AC_SUBST(AIX_OBJMODEL)
1905         DSO_LDOPTS='-qmkshrobj=1'
1906         DSO_CFLAGS='-qflag=w:w'
1907         DSO_PIC_CFLAGS=
1908         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
1909         MOZ_FIX_LINK_PATHS=
1910         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1911         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1912         if test "$COMPILE_ENVIRONMENT"; then
1913             AC_LANG_SAVE
1914             AC_LANG_CPLUSPLUS
1915             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
1916             AC_TRY_COMPILE([],
1917                 [#if (__IBMCPP__ < 900)
1918                  #error "Bad compiler"
1919                  #endif],
1920                 _BAD_COMPILER=,_BAD_COMPILER=1)
1921             if test -n "$_BAD_COMPILER"; then
1922                 AC_MSG_RESULT([no])
1923                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
1924             else
1925                 AC_MSG_RESULT([yes])
1926             fi
1927             AC_LANG_RESTORE
1928             TARGET_COMPILER_ABI="ibmc"
1929             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
1930             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
1931         fi
1932     fi
1933     case "${target_os}" in
1934     aix4.1*)
1935         DLL_SUFFIX='_shr.a'
1936         ;;
1937     esac
1938     if test "$COMPILE_ENVIRONMENT"; then
1939         MOZ_CHECK_HEADERS(sys/inttypes.h)
1940     fi
1941     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1942     ;;
1944 *-bsdi*)
1945     dnl -pedantic doesn't play well with BSDI's _very_ modified gcc (shlicc2)
1946     _PEDANTIC=
1947     case $OS_RELEASE in
1948         4.*|5.*)
1949             STRIP="$STRIP -d"
1950             ;;
1951         *)
1952             DSO_CFLAGS=''
1953             DSO_LDOPTS='-r'
1954             _WARNINGS_CFLAGS="-Wall"
1955             _WARNINGS_CXXFLAGS="-Wall"
1956             # The test above doesn't work properly, at least on 3.1.
1957             MKSHLIB_FORCE_ALL=''
1958             MKSHLIB_UNFORCE_ALL=''
1959         ;;
1960     esac
1961     ;;
1963 *-darwin*)
1964     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1965     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1966     MOZ_OPTIMIZE_FLAGS="-O3"
1967     _PEDANTIC=
1968     # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
1969     if test "$HAVE_64BIT_OS"; then
1970         MOZ_MEMORY=1
1971     fi
1972     DLL_SUFFIX=".dylib"
1973     DSO_LDOPTS=''
1974     STRIP="$STRIP -x -S"
1975     # Check whether we're targeting OS X or iOS
1976     AC_CACHE_CHECK(for iOS target,
1977                    ac_cv_ios_target,
1978                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
1979 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
1980 #error not iOS
1981 #endif],
1982                                    [],
1983                                    ac_cv_ios_target="yes",
1984                                    ac_cv_ios_target="no")])
1985     if test "$ac_cv_ios_target" = "yes"; then
1986         AC_DEFINE(XP_IOS)
1987         AC_DEFINE(XP_DARWIN)
1988         _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
1989     else
1990         AC_DEFINE(XP_MACOSX)
1991         AC_DEFINE(XP_DARWIN)
1992         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
1993         # The ExceptionHandling framework is needed for Objective-C exception
1994         # logging code in nsObjCExceptions.h. Currently we only use that in debug
1995         # builds.
1996         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
1997     fi
1998     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
2001     if test "x$lto_is_enabled" = "xyes"; then
2002         echo "Skipping -dead_strip because lto is enabled."
2003     dnl DTrace and -dead_strip don't interact well. See bug 403132.
2004     dnl ===================================================================
2005     elif test "x$enable_dtrace" = "xyes"; then
2006         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
2007     else
2008         dnl check for the presence of the -dead_strip linker flag
2009         AC_MSG_CHECKING([for -dead_strip option to ld])
2010         _SAVE_LDFLAGS=$LDFLAGS
2011         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
2012         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
2013         if test -n "$_HAVE_DEAD_STRIP" ; then
2014             AC_MSG_RESULT([yes])
2015             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
2016         else
2017             AC_MSG_RESULT([no])
2018         fi
2020         LDFLAGS=$_SAVE_LDFLAGS
2021     fi
2023     dnl With newer linkers we need to pass -allow_heap_execute because of
2024     dnl Microsoft Silverlight (5.1.10411.0 at least).
2025     AC_MSG_CHECKING([for -allow_heap_execute option to ld])
2026     _SAVE_LDFLAGS=$LDFLAGS
2027     LDFLAGS="$LDFLAGS -Wl,-allow_heap_execute"
2028     AC_TRY_LINK(,[return 0;],_HAVE_ALLOW_HEAP_EXECUTE=1,
2029                 _HAVE_ALLOW_HEAP_EXECUTE=)
2030     if test -n "$_HAVE_ALLOW_HEAP_EXECUTE" ; then
2031         AC_MSG_RESULT([yes])
2032         MOZ_ALLOW_HEAP_EXECUTE_FLAGS="-Wl,-allow_heap_execute"
2033     else
2034         AC_MSG_RESULT([no])
2035     fi
2036     LDFLAGS=$_SAVE_LDFLAGS
2038     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
2039     ;;
2041 ia64*-hpux*)
2042     DLL_SUFFIX=".so"
2043     if test ! "$GNU_CC"; then
2044        DSO_LDOPTS='-b'
2045        DSO_CFLAGS=""
2046        DSO_PIC_CFLAGS=
2047        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
2048        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
2049        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2050     else
2051        DSO_LDOPTS='-b -E'
2052        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2053        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
2054     fi
2055     MOZ_FIX_LINK_PATHS=
2056     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2057     AC_DEFINE(_LARGEFILE64_SOURCE)
2058     ;;
2060 *-hpux*)
2061     DLL_SUFFIX=".sl"
2062     if test ! "$GNU_CC"; then
2063         DSO_LDOPTS='-b -Wl,+s'
2064         DSO_CFLAGS=""
2065         DSO_PIC_CFLAGS="+Z"
2066         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
2067         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
2068         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
2069     else
2070         DSO_LDOPTS='-b -E +s'
2071         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2072         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
2073     fi
2074     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
2075     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2076     ;;
2078 *-android*|*-linuxandroid*)
2079     AC_DEFINE(NO_PW_GECOS)
2080     no_x=yes
2081     if test -n "$gonkdir"; then
2082         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
2083         MOZ_B2G_RIL=1
2084         MOZ_B2G_BT=1
2085         MOZ_B2G_FM=1
2086     else
2087         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
2088         MOZ_LINKER=1
2089     fi
2090     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2092     MOZ_GFX_OPTIMIZE_MOBILE=1
2093     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
2094     ;;
2096 *-*linux*)
2097     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2098     # Similarly for GNU_CXX and INTEL_CXX.
2099     if test "$INTEL_CC" -o "$INTEL_CXX"; then
2100         # -Os has been broken on Intel's C/C++ compilers for quite a
2101         # while; Intel recommends against using it.
2102         MOZ_OPTIMIZE_FLAGS="-O2"
2103         MOZ_DEBUG_FLAGS="-g"
2104     elif test "$GNU_CC" -o "$GNU_CXX"; then
2105         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2106         case $GCC_VERSION in
2107         4.1.*|4.2.*|4.5.*)
2108             # -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
2109             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
2110         esac
2111         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
2112         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
2113         MOZ_DEBUG_FLAGS="-g"
2114     fi
2116     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2118     MOZ_MEMORY=1
2120     case "${target_cpu}" in
2121     alpha*)
2122         CFLAGS="$CFLAGS -mieee"
2123         CXXFLAGS="$CXXFLAGS -mieee"
2124     ;;
2125     i*86)
2126         USE_ELF_DYNSTR_GC=1
2127     ;;
2128     mips*)
2129         MOZ_DEBUG_FLAGS="-g" # We want inlining
2130     ;;
2131     esac
2133     if test -z "$MC"; then
2134         MC=mc.exe
2135     fi
2136     ;;
2137 *-mingw*)
2138     DSO_CFLAGS=
2139     DSO_PIC_CFLAGS=
2140     DLL_SUFFIX=.dll
2141     RC=rc.exe
2142     MC=mc.exe
2143     # certain versions of cygwin's makedepend barf on the
2144     # #include <string> vs -I./dist/include/string issue so don't use it
2145     if test -n "$GNU_CC"; then
2146         CC="$CC -mwindows"
2147         CXX="$CXX -mwindows"
2148         CPP="$CPP -mwindows"
2149         CFLAGS="$CFLAGS -mms-bitfields"
2150         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2151         DSO_LDOPTS='-shared'
2152         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2153         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2154         RC='$(WINDRES)'
2155         # Use temp file for windres (bug 213281)
2156         RCFLAGS='-O coff --use-temp-file'
2157         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2158         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv"
2159         MOZ_FIX_LINK_PATHS=
2160         DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
2161         XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
2162         DLL_PREFIX=
2163         IMPORT_LIB_SUFFIX=dll.a
2164         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
2165     else
2166         TARGET_COMPILER_ABI=msvc
2167         HOST_CC='$(CC)'
2168         HOST_CXX='$(CXX)'
2169         HOST_LD='$(LD)'
2170         if test "$AS_BIN"; then
2171             AS="$(basename "$AS_BIN")"
2172         fi
2173         AR='lib'
2174         AR_FLAGS='-NOLOGO -OUT:"$@"'
2175         AR_EXTRACT=
2176         RANLIB='echo not_ranlib'
2177         STRIP='echo not_strip'
2178         PKG_SKIP_STRIP=1
2179         XARGS=xargs
2180         ZIP=zip
2181         UNZIP=unzip
2182         DOXYGEN=:
2183         ASM_SUFFIX=asm
2184         OBJ_SUFFIX=obj
2185         LIB_SUFFIX=lib
2186         DLL_PREFIX=
2187         LIB_PREFIX=
2188         IMPORT_LIB_SUFFIX=lib
2189         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2190         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2191         MKSHLIB_FORCE_ALL=
2192         MKSHLIB_UNFORCE_ALL=
2193         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2194         _USE_CPP_INCLUDE_FLAG=1
2195         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2196         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2197         CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2198         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
2199         CXXFLAGS="$CXXFLAGS -wd4800" # disable warning "forcing value to bool"
2200         # make 'foo == bar;' error out
2201         CFLAGS="$CFLAGS -we4553"
2202         CXXFLAGS="$CXXFLAGS -we4553"
2203         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
2204         MOZ_DEBUG_FLAGS='-Zi'
2205         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2206         WARNINGS_AS_ERRORS='-WX'
2207         MOZ_OPTIMIZE_FLAGS='-O1'
2208         MOZ_FIX_LINK_PATHS=
2209         DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2210         XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2211         LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2212         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2213         if test $_MSC_VER -ge 1400; then
2214             LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2215             dnl For profile-guided optimization
2216             PROFILE_GEN_CFLAGS="-GL"
2217             PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2218             dnl XXX: PGO builds can fail with warnings treated as errors,
2219             dnl specifically "no profile data available" appears to be
2220             dnl treated as an error sometimes. This might be a consequence
2221             dnl of using WARNINGS_AS_ERRORS in some modules, combined
2222             dnl with the linker doing most of the work in the whole-program
2223             dnl optimization/PGO case. I think it's probably a compiler bug,
2224             dnl but we work around it here.
2225             PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2226             dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2227             dnl Probably also a compiler bug, but what can you do?
2228             PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2229             LDFLAGS="$LDFLAGS -DYNAMICBASE"
2230         fi
2231     fi
2232     AC_DEFINE(HAVE_SNPRINTF)
2233     AC_DEFINE(_WINDOWS)
2234     AC_DEFINE(WIN32)
2235     AC_DEFINE(XP_WIN)
2236     AC_DEFINE(XP_WIN32)
2237     AC_DEFINE(HW_THREADS)
2238     AC_DEFINE(STDC_HEADERS)
2239     AC_DEFINE(NEW_H, <new>)
2240     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2241     TARGET_MD_ARCH=win32
2242     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2243     BIN_SUFFIX='.exe'
2244     MOZ_USER_DIR="Mozilla"
2246     dnl Hardcode to win95 for now - cls
2247     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2249     dnl set NO_X11 defines here as the general check is skipped on win32
2250     no_x=yes
2251     AC_DEFINE(NO_X11)
2253     case "$host" in
2254     *-mingw*)
2255         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2256         L10NBASEDIR=`cd $L10NBASEDIR && pwd -W`
2257         ;;
2258     esac
2260     case "$host" in
2261     *-mingw*)
2262         if test -z "$MOZ_TOOLS"; then
2263             AC_MSG_ERROR([MOZ_TOOLS is not set])
2264         fi
2265         MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2266         if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2267             AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2268         fi
2269         MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2270         if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2271             AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2272         fi
2273         ;;
2274     esac
2276     case "$host_os" in
2277     cygwin*|msvc*|mks*)
2278         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.])
2279         ;;
2280     esac
2282     case "$target" in
2283     i*86-*)
2284         if test "$HAVE_64BIT_OS"; then
2285             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2286         fi
2288         if test $_MSC_VER -ge 1400; then
2289             LDFLAGS="$LDFLAGS -SAFESEH"
2290         fi
2292         if test -n "$GNU_CC"; then
2293             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
2294             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
2295             LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup"
2296         else
2297             AC_DEFINE(HAVE_STDCALL)
2298             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
2299         fi
2301         AC_DEFINE(_X86_)
2302         ;;
2303     x86_64-*)
2304         if test -n "$_WIN32_MSVC"; then
2305             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
2306         fi
2307         AC_DEFINE(_AMD64_)
2308         ;;
2309     *)
2310         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2311         ;;
2312     esac
2314     if test "$HAVE_64BIT_OS"; then
2315         AC_DEFINE(_WIN64)
2316     fi
2317     ;;
2319 *-netbsd*)
2320     DSO_CFLAGS=''
2321     CFLAGS="$CFLAGS -Dunix"
2322     CXXFLAGS="$CXXFLAGS -Dunix"
2323     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2324         DLL_SUFFIX=".so"
2325         DSO_PIC_CFLAGS='-fPIC -DPIC'
2326         DSO_LDOPTS='-shared'
2327         BIN_FLAGS='-Wl,--export-dynamic'
2328     else
2329         DSO_PIC_CFLAGS='-fPIC -DPIC'
2330         DLL_SUFFIX=".so.1.0"
2331         DSO_LDOPTS='-shared'
2332     fi
2333     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2334     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2335     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2336     if test "$LIBRUNPATH"; then
2337         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2338     fi
2339     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2340     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,lib$(LIBRARY_NAME)$(DLL_SUFFIX) -o $@'
2341     ;;
2343 *-openbsd*)
2344     if test "$SO_VERSION"; then
2345         DLL_SUFFIX=".so.$SO_VERSION"
2346     else
2347         DLL_SUFFIX=".so.1.0"
2348     fi
2349     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
2350     DSO_CFLAGS=''
2351     DSO_PIC_CFLAGS='-fPIC'
2352     DSO_LDOPTS='-shared -fPIC'
2353     if test "$LIBRUNPATH"; then
2354         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2355     fi
2356     ;;
2358 *-os2*)
2359     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2360     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
2361     AC_DEFINE(OS2)
2362     AC_DEFINE(XP_OS2)
2363     AC_DEFINE(OS2EMX_PLAIN_CHAR)
2364     AC_DEFINE(TCPV40HDRS)
2365     DLL_PREFIX=
2366     LIB_PREFIX=
2367     LIB_SUFFIX=lib
2368     BIN_SUFFIX=".exe"
2369     DLL_SUFFIX=".dll"
2370     IMPORT_LIB_SUFFIX=lib
2371     DSO_PIC_CFLAGS=
2372     AR=emxomfar
2373     AR_FLAGS='r $@'
2374     CFLAGS="$CFLAGS -Zomf"
2375     CXXFLAGS="$CXXFLAGS -Zomf"
2376     DSO_LDOPTS='-Zdll'
2377     BIN_FLAGS='-Zlinker /ST:0x100000'
2378     IMPLIB='emximp -o'
2379     FILTER='true'
2380     LDFLAGS='-Zmap'
2381     WARNINGS_AS_ERRORS='-Werror'
2382     MOZ_DEBUG_FLAGS="-g -fno-inline"
2383     MOZ_OPTIMIZE_FLAGS="-O2"
2384     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
2385     DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2386     LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
2387     TARGET_MD_ARCH=os2
2388     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
2389     RC=rc.exe
2390     MC=mc.exe
2391     RCFLAGS='-n'
2392     MOZ_USER_DIR="Mozilla"
2393     ZIP="$ZIP -X"
2395     if test "$MOZTOOLS"; then
2396         MOZ_TOOLS_DIR=`echo $MOZTOOLS | sed -e 's|\\\\|/|g'`
2397     else
2398         AC_MSG_ERROR([MOZTOOLS is not set])
2399     fi
2400     if test -n "$MOZ_OS2_HIGH_MEMORY"; then
2401         DSO_LDOPTS="$DSO_LDOPTS -Zhigh-mem"
2402         LDFLAGS="$LDFLAGS -Zhigh-mem"
2403         MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -Zhigh-mem"
2404         AC_DEFINE(MOZ_OS2_HIGH_MEMORY)
2405     fi
2407     # GCC for OS/2 currently predefines these, but we don't want them
2408     _DEFINES_CFLAGS="$_DEFINES_CFLAGS -Uunix -U__unix -U__unix__"
2409     _DEFINES_CXXFLAGS="$_DEFINES_CXXFLAGS -Uunix -U__unix -U__unix__"
2411     AC_CACHE_CHECK(for __declspec(dllexport),
2412         ac_os2_declspec,
2413         [AC_TRY_COMPILE([__declspec(dllexport) void ac_os2_declspec(void) {}],
2414                         [return 0;],
2415                         ac_os2_declspec="yes",
2416                         ac_os2_declspec="no")])
2417     if test "$ac_os2_declspec" != "yes"; then
2418         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
2419     fi
2420     ;;
2422 *-solaris*)
2423     AC_DEFINE(SOLARIS)
2424     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2425     MOZ_FIX_LINK_PATHS=
2426     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2427     # libraries one level up (e.g. libnspr4.so)
2428     if test "$SOLARIS_SUNPRO_CC"; then
2429        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2430        LIBS="-lCrun -lCstd -lc $LIBS"
2431        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2432        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2433        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2434        LDFLAGS="-xildoff $LDFLAGS"
2435        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2436            _SAVE_LDFLAGS=$LDFLAGS
2437            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
2438            AC_TRY_LINK([#include <stdio.h>],
2439                        [printf("Hello World\n");],
2440                        ,
2441                        [LDFLAGS=$_SAVE_LDFLAGS])
2442        fi
2443        MOZ_OPTIMIZE_FLAGS="-xO4"
2444        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2445        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $@ -o $@'
2446        MKSHLIB_FORCE_ALL='-z allextract'
2447        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2448        DSO_LDOPTS='-G'
2449        AR_LIST="$AR t"
2450        AR_EXTRACT="$AR x"
2451        AR_DELETE="$AR d"
2452        AR='$(CXX) -xar'
2453        AR_FLAGS='-o $@'
2454        AS='/usr/ccs/bin/as'
2455        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2456        AS_DASH_C_FLAG=''
2457        TARGET_COMPILER_ABI="sunc"
2458        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2459        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2460        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2461        AC_LANG_SAVE
2462        AC_LANG_CPLUSPLUS
2463        AC_TRY_COMPILE([],
2464            [#if (__SUNPRO_CC < 0x590)
2465            #error "Denied"
2466            #endif],
2467            _BAD_COMPILER=,_BAD_COMPILER=1)
2468        if test -n "$_BAD_COMPILER"; then
2469            _res="no"
2470            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2471        else
2472            _res="yes"
2473        fi
2474        AC_TRY_COMPILE([],
2475            [#if (__SUNPRO_CC >= 0x5100)
2476            #error "Sun C++ 5.10 or above"
2477            #endif],
2478            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2479        if test "$_ABOVE_SS12U1"; then
2480            # disable xannotate
2481            CXXFLAGS="$CXXFLAGS -xannotate=no"
2482        fi
2483        AC_MSG_RESULT([$_res])
2484        AC_LANG_RESTORE
2485     else
2486        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2487        LIBS="-lc $LIBS"
2488        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2489        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2490        ASFLAGS="$ASFLAGS -fPIC"
2491        DSO_LDOPTS='-shared'
2492        WARNINGS_AS_ERRORS='-Werror'
2493        _WARNINGS_CFLAGS=''
2494        _WARNINGS_CXXFLAGS=''
2495        if test "$OS_RELEASE" = "5.3"; then
2496            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2497        fi
2498     fi
2499     if test "$OS_RELEASE" = "5.5.1"; then
2500         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2501     fi
2502     ;;
2504 *-sunos*)
2505     DSO_LDOPTS='-Bdynamic'
2506     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2507     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2508     AC_DEFINE(SUNOS4)
2509     AC_DEFINE(SPRINTF_RETURNS_STRING)
2510     case "$(target_os)" in
2511     sunos4.1*)
2512         DLL_SUFFIX='.so.1.0'
2513         ;;
2514     esac
2515     ;;
2517 *-os2*)
2518     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
2519     ;;
2521 esac
2523 AC_SUBST(MOZ_LINKER)
2524 if test -n "$MOZ_LINKER"; then
2525   AC_DEFINE(MOZ_LINKER)
2527 AC_SUBST(MOZ_ENABLE_SZIP)
2529 dnl Only one oddball right now (QNX), but this gives us flexibility
2530 dnl if any other platforms need to override this in the future.
2531 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2533 dnl ========================================================
2534 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2535 dnl by now will not have any way to link most binaries (tests
2536 dnl as well as viewer, apprunner, etc.), because some symbols
2537 dnl will be left out of the "composite" .so's by ld as unneeded.
2538 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2539 dnl they can link in the static libs that provide the missing
2540 dnl symbols.
2541 dnl ========================================================
2542 NO_LD_ARCHIVE_FLAGS=
2543 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2544     NO_LD_ARCHIVE_FLAGS=1
2546 case "$target" in
2547 *-os2*)
2548     NO_LD_ARCHIVE_FLAGS=
2549     ;;
2550 *-aix4.3*|*-aix5*)
2551     NO_LD_ARCHIVE_FLAGS=
2552     ;;
2553 *-mingw*)
2554     if test -z "$GNU_CC"; then
2555         NO_LD_ARCHIVE_FLAGS=
2556     fi
2557     ;;
2558 esac
2559 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2561 dnl ========================================================
2562 dnl = Flags to strip unused symbols from .so components and
2563 dnl = to export jemalloc symbols when linking a program
2564 dnl ========================================================
2565 case "$target" in
2566     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2567         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2568         ;;
2569     *-solaris*)
2570         if test -z "$GNU_CC"; then
2571          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2572         else
2573          if test -z "$GCC_USE_GNU_LD"; then
2574           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2575          else
2576           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2577          fi
2578         fi
2579         ;;
2580     *-darwin*)
2581         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2582         ;;
2583     *-mingw*)
2584         if test -n "$GNU_CC"; then
2585            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2586         fi
2587         ;;
2588 esac
2590 if test -z "$COMPILE_ENVIRONMENT"; then
2591     SKIP_COMPILER_CHECKS=1
2592     SKIP_LIBRARY_CHECKS=1
2595 MOZ_COMPILER_OPTS
2596 if test -z "$SKIP_COMPILER_CHECKS"; then
2597 dnl Checks for typedefs, structures, and compiler characteristics.
2598 dnl ========================================================
2599 AC_HEADER_STDC
2600 AC_C_CONST
2601 AC_TYPE_MODE_T
2602 AC_TYPE_OFF_T
2603 AC_TYPE_PID_T
2604 AC_TYPE_SIZE_T
2605 AC_LANG_CPLUSPLUS
2606 AC_MSG_CHECKING(for __stdcall)
2607 AC_CACHE_VAL(ac_cv___stdcall,
2608  [AC_TRY_COMPILE([template <typename Method> struct foo;
2609                   template <> struct foo<void (*)()> {};
2610                   template <> struct foo<void (__stdcall*)()> {};],
2611                  [],
2612                  [ac_cv___stdcall=true],
2613                  [ac_cv___stdcall=false])])
2614 if test "$ac_cv___stdcall" = true ; then
2615   AC_DEFINE(HAVE_STDCALL)
2616   AC_MSG_RESULT(yes)
2617 else
2618   AC_MSG_RESULT(no)
2620 AC_LANG_C
2621 AC_MSG_CHECKING(for ssize_t)
2622 AC_CACHE_VAL(ac_cv_type_ssize_t,
2623  [AC_TRY_COMPILE([#include <stdio.h>
2624                   #include <sys/types.h>],
2625                  [ssize_t foo = 0;],
2626                  [ac_cv_type_ssize_t=true],
2627                  [ac_cv_type_ssize_t=false])])
2628 if test "$ac_cv_type_ssize_t" = true ; then
2629   AC_DEFINE(HAVE_SSIZE_T)
2630   AC_MSG_RESULT(yes)
2631 else
2632   AC_MSG_RESULT(no)
2634 AC_STRUCT_ST_BLKSIZE
2635 AC_MSG_CHECKING(for siginfo_t)
2636 AC_CACHE_VAL(ac_cv_siginfo_t,
2637  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
2638                   #include <signal.h>],
2639                  [siginfo_t* info;],
2640                  [ac_cv_siginfo_t=true],
2641                  [ac_cv_siginfo_t=false])])
2642 if test "$ac_cv_siginfo_t" = true ; then
2643   AC_DEFINE(HAVE_SIGINFO_T)
2644   AC_MSG_RESULT(yes)
2645 else
2646   AC_MSG_RESULT(no)
2649 dnl Check for int64, uint, and uint_t.
2650 dnl ========================================================
2651 AC_MSG_CHECKING(for int64)
2652 AC_CACHE_VAL(ac_cv_int64,
2653  [AC_TRY_COMPILE([#include <stdio.h>
2654                   #include <sys/types.h>],
2655                  [int64 foo = 0;],
2656                  [ac_cv_int64=true],
2657                  [ac_cv_int64=false])])
2658 if test "$ac_cv_int64" = true ; then
2659   AC_DEFINE(HAVE_INT64)
2660   AC_MSG_RESULT(yes)
2661 else
2662   AC_MSG_RESULT(no)
2664 AC_MSG_CHECKING(for uint)
2665 AC_CACHE_VAL(ac_cv_uint,
2666  [AC_TRY_COMPILE([#include <stdio.h>
2667                   #include <sys/types.h>],
2668                  [uint foo = 0;],
2669                  [ac_cv_uint=true],
2670                  [ac_cv_uint=false])])
2671 if test "$ac_cv_uint" = true ; then
2672   AC_DEFINE(HAVE_UINT)
2673   AC_MSG_RESULT(yes)
2674 else
2675   AC_MSG_RESULT(no)
2677 AC_MSG_CHECKING(for uint_t)
2678 AC_CACHE_VAL(ac_cv_uint_t,
2679  [AC_TRY_COMPILE([#include <stdio.h>
2680                   #include <sys/types.h>],
2681                  [uint_t foo = 0;],
2682                  [ac_cv_uint_t=true],
2683                  [ac_cv_uint_t=false])])
2684 if test "$ac_cv_uint_t" = true ; then
2685   AC_DEFINE(HAVE_UINT_T)
2686   AC_MSG_RESULT(yes)
2687 else
2688   AC_MSG_RESULT(no)
2691 dnl On the gcc trunk (as of 2001-02-09) _GNU_SOURCE, and thus __USE_GNU,
2692 dnl are defined when compiling C++ but not C.  Since the result of this
2693 dnl test is used only in C++, do it in C++.
2694 AC_LANG_CPLUSPLUS
2696 AC_MSG_CHECKING(for uname.domainname)
2697 AC_CACHE_VAL(ac_cv_have_uname_domainname_field,
2698     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2699         [ struct utsname *res; char *domain;
2700             (void)uname(res);  if (res != 0) { domain = res->domainname; } ],
2701         [ac_cv_have_uname_domainname_field=true],
2702         [ac_cv_have_uname_domainname_field=false])])
2704 if test "$ac_cv_have_uname_domainname_field" = "true"; then
2705     AC_DEFINE(HAVE_UNAME_DOMAINNAME_FIELD)
2706     AC_MSG_RESULT(yes)
2707 else
2708     AC_MSG_RESULT(no)
2711 AC_MSG_CHECKING(for uname.__domainname)
2712 AC_CACHE_VAL(ac_cv_have_uname_us_domainname_field,
2713     [AC_TRY_COMPILE([#include <sys/utsname.h>],
2714         [ struct utsname *res; char *domain;
2715             (void)uname(res);  if (res != 0) { domain = res->__domainname; } ],
2716         [ac_cv_have_uname_us_domainname_field=true],
2717         [ac_cv_have_uname_us_domainname_field=false])])
2719 if test "$ac_cv_have_uname_us_domainname_field" = "true"; then
2720     AC_DEFINE(HAVE_UNAME_US_DOMAINNAME_FIELD)
2721     AC_MSG_RESULT(yes)
2722 else
2723     AC_MSG_RESULT(no)
2726 dnl Check whether we can use gcc's c++0x mode
2727 AC_LANG_CPLUSPLUS
2729 if test "$GNU_CXX"; then
2730     _SAVE_CXXFLAGS=$CXXFLAGS
2731     CXXFLAGS="$CXXFLAGS -std=gnu++0x"
2733     AC_CACHE_CHECK(for gcc c++0x headers bug without rtti,
2734         ac_cv_cxx0x_headers_bug,
2735         [AC_TRY_COMPILE([#include <memory>], [],
2736                         ac_cv_cxx0x_headers_bug="no",
2737                         ac_cv_cxx0x_headers_bug="yes")])
2738     CXXFLAGS="$_SAVE_CXXFLAGS"
2739     if test "$ac_cv_cxx0x_headers_bug" = "no"; then
2740         CXXFLAGS="$CXXFLAGS -std=gnu++0x"
2741     fi
2744 dnl Check for usable char16_t (2 bytes, unsigned)
2745 dnl (we might not need the unsignedness check anymore)
2746 AC_CACHE_CHECK(for usable char16_t (2 bytes, unsigned),
2747     ac_cv_have_usable_char16_t,
2748     [AC_TRY_COMPILE([$configure_static_assert_macros],
2749                     [CONFIGURE_STATIC_ASSERT(sizeof(char16_t) == 2);
2750                      CONFIGURE_STATIC_ASSERT(char16_t(-1) > char16_t(0));
2751                      CONFIGURE_STATIC_ASSERT(sizeof((u"hello")[0]) == 2);
2752                      CONFIGURE_STATIC_ASSERT(sizeof(u'a') == 2);
2753                      CONFIGURE_STATIC_ASSERT(u'\xFFFF' > u'\x0')],
2754                     ac_cv_have_usable_char16_t="yes",
2755                     ac_cv_have_usable_char16_t="no")])
2756 if test "$ac_cv_have_usable_char16_t" = "yes"; then
2757     AC_DEFINE(HAVE_CPP_CHAR16_T)
2758     HAVE_CPP_CHAR16_T=1
2759 elif test "$GNU_CXX"; then
2760     CXXFLAGS="$_SAVE_CXXFLAGS"
2763 dnl Check for usable wchar_t (2 bytes, unsigned)
2764 dnl (we really don't need the unsignedness check anymore)
2765 dnl ========================================================
2767 AC_CACHE_CHECK(for usable wchar_t (2 bytes, unsigned),
2768     ac_cv_have_usable_wchar_v2,
2769     [AC_TRY_COMPILE([#include <stddef.h>
2770                      $configure_static_assert_macros],
2771                     [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
2772                      CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
2773                     ac_cv_have_usable_wchar_v2="yes",
2774                     ac_cv_have_usable_wchar_v2="no")])
2775 if test "$ac_cv_have_usable_wchar_v2" = "yes"; then
2776     AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
2777     HAVE_CPP_2BYTE_WCHAR_T=1
2778 elif test "$ac_cv_have_usable_char16_t" != "yes"; then
2779 dnl This is really gcc-only
2780 dnl Do this test using CXX only since some versions of gcc
2781 dnl 2.95-2.97 have a signed wchar_t in c++ only and some versions
2782 dnl only have short-wchar support for c++.
2783 dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
2785     _SAVE_CXXFLAGS=$CXXFLAGS
2786     CXXFLAGS="$CXXFLAGS -fshort-wchar"
2788     AC_CACHE_CHECK(for compiler -fshort-wchar option,
2789         ac_cv_have_usable_wchar_option_v2,
2790         [AC_TRY_LINK([#include <stddef.h>
2791                       $configure_static_assert_macros],
2792                      [CONFIGURE_STATIC_ASSERT(sizeof(wchar_t) == 2);
2793                       CONFIGURE_STATIC_ASSERT((wchar_t)-1 > (wchar_t) 0)],
2794                      ac_cv_have_usable_wchar_option_v2="yes",
2795                      ac_cv_have_usable_wchar_option_v2="no")])
2797     if test "$ac_cv_have_usable_wchar_option_v2" = "yes"; then
2798         AC_DEFINE(HAVE_CPP_2BYTE_WCHAR_T)
2799         HAVE_CPP_2BYTE_WCHAR_T=1
2800         if test "$OS_TARGET" = Android; then
2801             WCHAR_CFLAGS="-fshort-wchar -Wl,--no-wchar-size-warning"
2802             CXXFLAGS="$CXXFLAGS -Wl,--no-wchar-size-warning"
2803             CFLAGS="$CFLAGS -Wl,--no-wchar-size-warning"
2804             DSO_LDOPTS="$DSO_LDOPTS -Wl,--no-wchar-size-warning"
2805         else
2806             WCHAR_CFLAGS="-fshort-wchar"
2807         fi
2808     else
2809         CXXFLAGS=$_SAVE_CXXFLAGS
2810     fi
2813 AC_LANG_C
2815 dnl Check for .hidden assembler directive and visibility attribute.
2816 dnl Borrowed from glibc configure.in
2817 dnl ===============================================================
2818 if test "$GNU_CC"; then
2819   AC_CACHE_CHECK(for visibility(hidden) attribute,
2820                  ac_cv_visibility_hidden,
2821                  [cat > conftest.c <<EOF
2822                   int foo __attribute__ ((visibility ("hidden"))) = 1;
2824                   ac_cv_visibility_hidden=no
2825                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2826                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2827                       ac_cv_visibility_hidden=yes
2828                     fi
2829                   fi
2830                   rm -f conftest.[cs]
2831                  ])
2832   if test "$ac_cv_visibility_hidden" = "yes"; then
2833     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
2835     AC_CACHE_CHECK(for visibility(default) attribute,
2836                    ac_cv_visibility_default,
2837                    [cat > conftest.c <<EOF
2838                     int foo __attribute__ ((visibility ("default"))) = 1;
2840                     ac_cv_visibility_default=no
2841                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2842                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2843                         ac_cv_visibility_default=yes
2844                       fi
2845                     fi
2846                     rm -f conftest.[cs]
2847                    ])
2848     if test "$ac_cv_visibility_default" = "yes"; then
2849       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
2851       AC_CACHE_CHECK(for visibility pragma support,
2852                      ac_cv_visibility_pragma,
2853                      [cat > conftest.c <<EOF
2854 #pragma GCC visibility push(hidden)
2855                       int foo_hidden = 1;
2856 #pragma GCC visibility push(default)
2857                       int foo_default = 1;
2859                       ac_cv_visibility_pragma=no
2860                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2861                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
2862                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
2863                             ac_cv_visibility_pragma=yes
2864                           fi
2865                         fi
2866                       fi
2867                       rm -f conftest.[cs]
2868                     ])
2869       if test "$ac_cv_visibility_pragma" = "yes"; then
2870         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
2871                        ac_cv_have_visibility_class_bug,
2872                        [cat > conftest.c <<EOF
2873 #pragma GCC visibility push(hidden)
2874 struct __attribute__ ((visibility ("default"))) TestStruct {
2875   static void Init();
2877 __attribute__ ((visibility ("default"))) void TestFunc() {
2878   TestStruct::Init();
2881                        ac_cv_have_visibility_class_bug=no
2882                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2883                          ac_cv_have_visibility_class_bug=yes
2884                        else
2885                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
2886                            ac_cv_have_visibility_class_bug=yes
2887                          fi
2888                        fi
2889                        rm -rf conftest.{c,S}
2890                        ])
2892         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
2893                        ac_cv_have_visibility_builtin_bug,
2894                        [cat > conftest.c <<EOF
2895 #pragma GCC visibility push(hidden)
2896 #pragma GCC visibility push(default)
2897 #include <string.h>
2898 #pragma GCC visibility pop
2900 __attribute__ ((visibility ("default"))) void Func() {
2901   char c[[100]];
2902   memset(c, 0, sizeof(c));
2905                        ac_cv_have_visibility_builtin_bug=no
2906                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2907                          ac_cv_have_visibility_builtin_bug=yes
2908                        else
2909                          if test `grep -c "@PLT" conftest.S` = 0; then
2910                            ac_cv_visibility_builtin_bug=yes
2911                          fi
2912                        fi
2913                        rm -f conftest.{c,S}
2914                        ])
2915         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
2916                 "$ac_cv_have_visibility_class_bug" = "no"; then
2917           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
2918           WRAP_SYSTEM_INCLUDES=1
2919           STL_FLAGS='-I$(DIST)/stl_wrappers'
2920           WRAP_STL_INCLUDES=1
2921         else
2922           VISIBILITY_FLAGS='-fvisibility=hidden'
2923         fi # have visibility pragma bug
2924       fi   # have visibility pragma
2925     fi     # have visibility(default) attribute
2926   fi       # have visibility(hidden) attribute
2927 fi         # GNU_CC
2929 # visibility hidden flag for Sun Studio on Solaris
2930 if test "$SOLARIS_SUNPRO_CC"; then
2931 VISIBILITY_FLAGS='-xldscope=hidden'
2932 fi         # Sun Studio on Solaris
2934 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2935 AC_SUBST(VISIBILITY_FLAGS)
2937 MOZ_GCC_PR49911
2938 MOZ_GCC_PR39608
2939 MOZ_LLVM_PR8927
2941 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
2942 dnl ========================================================
2943 if test "$GNU_CC"; then
2944   CFLAGS_save="${CFLAGS}"
2945   CFLAGS="${CFLAGS} -Werror"
2946   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
2947                  ac_cv_force_align_arg_pointer,
2948                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
2949                                  [],
2950                                  ac_cv_force_align_arg_pointer="yes",
2951                                  ac_cv_force_align_arg_pointer="no")])
2952   CFLAGS="${CFLAGS_save}"
2953   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
2954     HAVE_GCC_ALIGN_ARG_POINTER=1
2955   else
2956     HAVE_GCC_ALIGN_ARG_POINTER=
2957   fi
2959 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
2961 dnl Checks for header files.
2962 dnl ========================================================
2963 AC_HEADER_DIRENT
2964 case "$target_os" in
2965 freebsd*|openbsd*)
2966 # for stuff like -lXshm
2967     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
2968     ;;
2969 esac
2970 MOZ_CHECK_COMMON_HEADERS
2972 dnl These are all the places some variant of statfs can be hiding.
2973 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
2975 dnl Quota support
2976 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
2977 MOZ_CHECK_HEADERS(linux/quota.h)
2979 MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
2981 dnl Check whether the compiler supports the new-style C++ standard
2982 dnl library headers (i.e. <new>) or needs the old "new.h"
2983 AC_LANG_CPLUSPLUS
2984 NEW_H=new.h
2985 MOZ_CHECK_HEADER(new, [NEW_H=new])
2986 AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>)
2987 AC_LANG_C
2989 AC_ARG_ENABLE(dtrace,
2990               [  --enable-dtrace         build with dtrace support if available (default=no)],
2991               [enable_dtrace="yes"],)
2992 if test "x$enable_dtrace" = "xyes"; then
2993   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
2994   if test -n "$HAVE_DTRACE"; then
2995       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
2996   else
2997       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
2998   fi
3000 AC_SUBST(HAVE_DTRACE)
3002 case $target in
3003 *-aix4.3*|*-aix5*)
3004         ;;
3006         MOZ_CHECK_HEADERS(sys/cdefs.h)
3007         ;;
3008 esac
3010 MOZ_LINUX_PERF_EVENT
3012 dnl Checks for libraries.
3013 dnl ========================================================
3014 case $target in
3015 *-hpux11.*)
3016         ;;
3018         AC_CHECK_LIB(c_r, gethostbyname_r)
3019         ;;
3020 esac
3022 dnl We don't want to link with libdl even if it's present on OS X, since
3023 dnl it's not used and not part of the default installation. OS/2 has dlfcn
3024 dnl in libc.
3025 dnl We don't want to link against libm or libpthread on Darwin since
3026 dnl they both are just symlinks to libSystem and explicitly linking
3027 dnl against libSystem causes issues when debugging (see bug 299601).
3028 case $target in
3029 *-darwin*)
3030     ;;
3031 *-os2*)
3032     ;;
3034     AC_SEARCH_LIBS(dlopen, dl,
3035         MOZ_CHECK_HEADER(dlfcn.h,
3036         AC_DEFINE(HAVE_DLOPEN)))
3037     ;;
3038 esac
3040 _SAVE_CFLAGS="$CFLAGS"
3041 CFLAGS="$CFLAGS -D_GNU_SOURCE"
3042 AC_CHECK_FUNCS(dladdr memmem)
3043 CFLAGS="$_SAVE_CFLAGS"
3045 if test ! "$GNU_CXX"; then
3047     case $target in
3048     *-aix*)
3049         AC_CHECK_LIB(C_r, demangle)
3050         ;;
3051      *)
3052         AC_CHECK_LIB(C, demangle)
3053         ;;
3054      esac
3057 dnl OS/2 has socket in libc.
3058 case $target in
3059 *-os2*)
3060     ;;
3062     AC_CHECK_LIB(socket, socket)
3063 esac
3065 XLDFLAGS="$X_LIBS"
3066 XLIBS="$X_EXTRA_LIBS"
3068 dnl ========================================================
3069 dnl Checks for X libraries.
3070 dnl Ordering is important.
3071 dnl Xt is dependent upon SM as of X11R6
3072 dnl ========================================================
3073 if test "$no_x" = "yes"; then
3074     AC_DEFINE(NO_X11)
3075 else
3076     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
3077         XLIBS="-lX11 $XLIBS"
3078         _SAVE_LDFLAGS="$LDFLAGS"
3079         LDFLAGS="$XLDFLAGS $LDFLAGS"
3080         AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
3081                 [MISSING_X="$MISSING_X -lX11"], $XLIBS)
3082         AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
3083                 [MISSING_X="$MISSING_X -lXext"], $XLIBS)
3085         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
3086         unset ac_cv_lib_Xt_XtFree
3087             AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
3088             AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
3089         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
3090                     [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
3091         ])
3093     # AIX needs the motif library linked before libXt to prevent
3094     # crashes in plugins linked against Motif - Bug #98892
3095     case "${target_os}" in
3096     aix*)
3097         XT_LIBS="-lXm $XT_LIBS"
3098         ;;
3099     esac
3101     dnl ========================================================
3102     dnl = Check for XShm
3103     dnl ========================================================
3104     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
3105         $XLIBS $XEXT_LIBS)
3107     dnl ========================================================
3108     dnl = Check for Xss
3109     dnl ========================================================
3110     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
3111         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
3112             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
3113              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
3115         LDFLAGS="$_SAVE_LDFLAGS"
3116 fi # $no_x
3118 AC_SUBST(XCFLAGS)
3119 AC_SUBST(XLDFLAGS)
3120 AC_SUBST(XLIBS)
3121 AC_SUBST(XEXT_LIBS)
3122 AC_SUBST(XT_LIBS)
3123 AC_SUBST(XSS_LIBS)
3125 dnl ========================================================
3126 dnl = pthread support
3127 dnl = Start by checking whether the system support pthreads
3128 dnl ========================================================
3129 case "$target_os" in
3130 darwin*)
3131     USE_PTHREADS=1
3132     ;;
3134     MOZ_CHECK_PTHREADS(pthreads,
3135         USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
3136         MOZ_CHECK_PTHREADS(pthread,
3137             USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
3138             MOZ_CHECK_PTHREADS(c_r,
3139                 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
3140                 MOZ_CHECK_PTHREADS(c,
3141                     USE_PTHREADS=1
3142                 )
3143             )
3144         )
3145     )
3146     ;;
3147 esac
3149 dnl ========================================================
3150 dnl Check the command line for --with-pthreads
3151 dnl ========================================================
3152 MOZ_ARG_WITH_BOOL(pthreads,
3153 [  --with-pthreads         Force use of system pthread library with NSPR ],
3154 [ if test "$USE_PTHREADS"x = x; then
3155     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
3156 fi],
3157     USE_PTHREADS=
3158     _PTHREAD_LDFLAGS=
3161 dnl ========================================================
3162 dnl Do the platform specific pthread hackery
3163 dnl ========================================================
3164 if test "$USE_PTHREADS"x != x
3165 then
3166         dnl
3167         dnl See if -pthread is supported.
3168         dnl
3169         rm -f conftest*
3170         ac_cv_have_dash_pthread=no
3171         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
3172         echo 'int main() { return 0; }' | cat > conftest.c
3173         ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
3174         if test $? -eq 0; then
3175                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3176                         ac_cv_have_dash_pthread=yes
3177                 case "$target_os" in
3178                 freebsd*)
3179 # Freebsd doesn't use -pthread for compiles, it uses them for linking
3180                 ;;
3181                 *)
3182                             CFLAGS="$CFLAGS -pthread"
3183                             CXXFLAGS="$CXXFLAGS -pthread"
3184                 ;;
3185                 esac
3186                 fi
3187         fi
3188         rm -f conftest*
3189     AC_MSG_RESULT($ac_cv_have_dash_pthread)
3191         dnl
3192         dnl See if -pthreads is supported.
3193         dnl
3194     ac_cv_have_dash_pthreads=no
3195     if test "$ac_cv_have_dash_pthread" = "no"; then
3196             AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
3197         echo 'int main() { return 0; }' | cat > conftest.c
3198             ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
3199         if test $? -eq 0; then
3200                 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
3201                             ac_cv_have_dash_pthreads=yes
3202                             CFLAGS="$CFLAGS -pthreads"
3203                             CXXFLAGS="$CXXFLAGS -pthreads"
3204                     fi
3205             fi
3206             rm -f conftest*
3207         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
3208     fi
3210         case "$target" in
3211             *-*-freebsd*)
3212                         AC_DEFINE(_REENTRANT)
3213                         AC_DEFINE(_THREAD_SAFE)
3214                         dnl -pthread links in -lpthread, so don't specify it explicitly.
3215                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3216                                 _PTHREAD_LDFLAGS="-pthread"
3217                         fi
3218                         ;;
3220             *-*-openbsd*|*-*-bsdi*)
3221                         AC_DEFINE(_REENTRANT)
3222                         AC_DEFINE(_THREAD_SAFE)
3223                         dnl -pthread links in -lc_r, so don't specify it explicitly.
3224                         if test "$ac_cv_have_dash_pthread" = "yes"; then
3225                 _PTHREAD_LDFLAGS="-pthread"
3226                         fi
3227                         ;;
3229             *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3230                         AC_DEFINE(_REENTRANT)
3231                         ;;
3233             *-aix4.3*|*-aix5*)
3234                         AC_DEFINE(_REENTRANT)
3235                         ;;
3237             *-hpux11.*)
3238                         AC_DEFINE(_REENTRANT)
3239                         ;;
3241             *-*-solaris*)
3242                         AC_DEFINE(_REENTRANT)
3243                         if test "$SOLARIS_SUNPRO_CC"; then
3244                                 CFLAGS="$CFLAGS -mt"
3245                                 CXXFLAGS="$CXXFLAGS -mt"
3246                         fi
3247                         ;;
3248         esac
3249     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3253 dnl Checks for library functions.
3254 dnl ========================================================
3255 AC_PROG_GCC_TRADITIONAL
3256 AC_FUNC_MEMCMP
3257 AC_CHECK_FUNCS(random strerror lchown fchmod snprintf memmove rint stat64 lstat64 truncate64 setbuf isatty)
3258 AC_CHECK_FUNCS(statvfs64 statvfs statfs64 statfs)
3259 AC_CHECK_FUNCS(flockfile getpagesize)
3260 AC_CHECK_FUNCS(localtime_r strtok_r)
3262 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
3263 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
3264                ac_cv_clock_monotonic,
3265                [for libs in "" -lrt; do
3266                     _SAVE_LIBS="$LIBS"
3267                     LIBS="$LIBS $libs"
3268                     AC_TRY_LINK([#include <time.h>],
3269                                  [ struct timespec ts;
3270                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
3271                                  ac_cv_clock_monotonic=$libs
3272                                  LIBS="$_SAVE_LIBS"
3273                                  break,
3274                                  ac_cv_clock_monotonic=no)
3275                     LIBS="$_SAVE_LIBS"
3276                 done])
3277 if test "$ac_cv_clock_monotonic" != "no"; then
3278     HAVE_CLOCK_MONOTONIC=1
3279     REALTIME_LIBS=$ac_cv_clock_monotonic
3280     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3281     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3282     AC_SUBST(REALTIME_LIBS)
3285 dnl check for wcrtomb/mbrtowc
3286 dnl =======================================================================
3287 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3288 AC_LANG_SAVE
3289 AC_LANG_CPLUSPLUS
3290 AC_CACHE_CHECK(for wcrtomb,
3291     ac_cv_have_wcrtomb,
3292     [AC_TRY_LINK([#include <wchar.h>],
3293                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3294                  ac_cv_have_wcrtomb="yes",
3295                  ac_cv_have_wcrtomb="no")])
3296 if test "$ac_cv_have_wcrtomb" = "yes"; then
3297     AC_DEFINE(HAVE_WCRTOMB)
3299 AC_CACHE_CHECK(for mbrtowc,
3300     ac_cv_have_mbrtowc,
3301     [AC_TRY_LINK([#include <wchar.h>],
3302                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3303                  ac_cv_have_mbrtowc="yes",
3304                  ac_cv_have_mbrtowc="no")])
3305 if test "$ac_cv_have_mbrtowc" = "yes"; then
3306     AC_DEFINE(HAVE_MBRTOWC)
3308 AC_LANG_RESTORE
3311 AC_CACHE_CHECK(
3312     [for res_ninit()],
3313     ac_cv_func_res_ninit,
3314     [AC_TRY_LINK([
3315         #ifdef linux
3316         #define _BSD_SOURCE 1
3317         #endif
3318         #include <resolv.h>
3319         ],
3320         [int foo = res_ninit(&_res);],
3321         [ac_cv_func_res_ninit=yes],
3322         [ac_cv_func_res_ninit=no])
3323     ])
3325 if test "$ac_cv_func_res_ninit" = "yes"; then
3326     AC_DEFINE(HAVE_RES_NINIT)
3327 dnl must add the link line we do something as foolish as this... dougt
3328 dnl else
3329 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3330 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3333 AC_LANG_CPLUSPLUS
3334 AC_CACHE_CHECK(
3335     [for gnu_get_libc_version()],
3336     ac_cv_func_gnu_get_libc_version,
3337     [AC_TRY_LINK([
3338         #ifdef HAVE_GNU_LIBC_VERSION_H
3339         #include <gnu/libc-version.h>
3340         #endif
3341         ],
3342         [const char *glibc_version = gnu_get_libc_version();],
3343         [ac_cv_func_gnu_get_libc_version=yes],
3344         [ac_cv_func_gnu_get_libc_version=no]
3345         )]
3346     )
3348 if test "$ac_cv_func_gnu_get_libc_version" = "yes"; then
3349     AC_DEFINE(HAVE_GNU_GET_LIBC_VERSION)
3352 case $target_os in
3353     darwin*|mingw*|os2*)
3354         ;;
3355     *)
3357 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3358     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3359         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3360 _SAVE_LIBS=$LIBS
3361 LIBS="$LIBS $_ICONV_LIBS"
3362 AC_CACHE_CHECK(
3363     [for iconv()],
3364     ac_cv_func_iconv,
3365     [AC_TRY_LINK([
3366         #include <stdlib.h>
3367         #include <iconv.h>
3368         ],
3369         [
3370             iconv_t h = iconv_open("", "");
3371             iconv(h, NULL, NULL, NULL, NULL);
3372             iconv_close(h);
3373         ],
3374         [ac_cv_func_iconv=yes],
3375         [ac_cv_func_iconv=no]
3376         )]
3377     )
3378 if test "$ac_cv_func_iconv" = "yes"; then
3379     AC_DEFINE(HAVE_ICONV)
3380     DYNAMIC_XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS $_ICONV_LIBS"
3381     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3382     LIBICONV="$_ICONV_LIBS"
3383     AC_CACHE_CHECK(
3384         [for iconv() with const input],
3385         ac_cv_func_const_iconv,
3386         [AC_TRY_COMPILE([
3387             #include <stdlib.h>
3388             #include <iconv.h>
3389             ],
3390             [
3391                 const char *input = "testing";
3392                 iconv_t h = iconv_open("", "");
3393                 iconv(h, &input, NULL, NULL, NULL);
3394                 iconv_close(h);
3395             ],
3396             [ac_cv_func_const_iconv=yes],
3397             [ac_cv_func_const_iconv=no]
3398             )]
3399         )
3400     if test "$ac_cv_func_const_iconv" = "yes"; then
3401         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3402     fi
3404 LIBS=$_SAVE_LIBS
3406     ;;
3407 esac
3409 AM_LANGINFO_CODESET
3411 AC_LANG_C
3413 dnl **********************
3414 dnl *** va_copy checks ***
3415 dnl **********************
3416 dnl we currently check for all three va_copy possibilities, so we get
3417 dnl all results in config.log for bug reports.
3418 AC_MSG_CHECKING(for an implementation of va_copy())
3419 AC_CACHE_VAL(ac_cv_va_copy,[
3420     AC_TRY_RUN([
3421         #include <stdarg.h>
3422         void f (int i, ...) {
3423             va_list args1, args2;
3424             va_start (args1, i);
3425             va_copy (args2, args1);
3426             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3427                 exit (1);
3428             va_end (args1); va_end (args2);
3429         }
3430         int main() { f (0, 42); return 0; }],
3431         ac_cv_va_copy=yes,
3432         ac_cv_va_copy=no,
3433         ac_cv_va_copy=no
3434     )
3436 AC_MSG_RESULT($ac_cv_va_copy)
3437 AC_MSG_CHECKING(for an implementation of __va_copy())
3438 AC_CACHE_VAL(ac_cv___va_copy,[
3439     AC_TRY_RUN([
3440         #include <stdarg.h>
3441         void f (int i, ...) {
3442             va_list args1, args2;
3443             va_start (args1, i);
3444             __va_copy (args2, args1);
3445             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3446                 exit (1);
3447             va_end (args1); va_end (args2);
3448         }
3449         int main() { f (0, 42); return 0; }],
3450         ac_cv___va_copy=yes,
3451         ac_cv___va_copy=no,
3452         ac_cv___va_copy=no
3453     )
3455 AC_MSG_RESULT($ac_cv___va_copy)
3456 AC_MSG_CHECKING(whether va_lists can be copied by value)
3457 AC_CACHE_VAL(ac_cv_va_val_copy,[
3458     AC_TRY_RUN([
3459         #include <stdarg.h>
3460         void f (int i, ...) {
3461             va_list args1, args2;
3462             va_start (args1, i);
3463             args2 = args1;
3464             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3465                 exit (1);
3466             va_end (args1); va_end (args2);
3467         }
3468         int main() { f (0, 42); return 0; }],
3469         ac_cv_va_val_copy=yes,
3470         ac_cv_va_val_copy=no,
3471         ac_cv_va_val_copy=yes
3472     )
3474 if test "x$ac_cv_va_copy" = "xyes"; then
3475     AC_DEFINE(VA_COPY, va_copy)
3476     AC_DEFINE(HAVE_VA_COPY)
3477 elif test "x$ac_cv___va_copy" = "xyes"; then
3478     AC_DEFINE(VA_COPY, __va_copy)
3479     AC_DEFINE(HAVE_VA_COPY)
3482 if test "x$ac_cv_va_val_copy" = "xno"; then
3483    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3485 AC_MSG_RESULT($ac_cv_va_val_copy)
3487 dnl ===================================================================
3488 dnl ========================================================
3489 dnl Put your C++ language/feature checks below
3490 dnl ========================================================
3491 AC_LANG_CPLUSPLUS
3493 ARM_ABI_PREFIX=
3494 if test "$GNU_CC"; then
3495   if test "$CPU_ARCH" = "arm" ; then
3496     AC_CACHE_CHECK(for ARM EABI,
3497         ac_cv_gcc_arm_eabi,
3498         [AC_TRY_COMPILE([],
3499                         [
3500 #if defined(__ARM_EABI__)
3501   return 0;
3502 #else
3503 #error Not ARM EABI.
3504 #endif
3505                         ],
3506                         ac_cv_gcc_arm_eabi="yes",
3507                         ac_cv_gcc_arm_eabi="no")])
3508     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
3509         HAVE_ARM_EABI=1
3510         ARM_ABI_PREFIX=eabi-
3511     else
3512         ARM_ABI_PREFIX=oabi-
3513     fi
3514   fi
3516   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
3519 dnl Check for support of modern template specialization syntax
3520 dnl Test code and requirement from scc@netscape.com.
3521 dnl Autoconf cut-and-paste job by waterson@netscape.com
3522 AC_CACHE_CHECK(for modern C++ template specialization syntax support,
3523                ac_cv_cpp_modern_specialize_template_syntax,
3524                [AC_TRY_COMPILE(template <class T> struct X { int a; };
3525                                class Y {};
3526                                template <> struct X<Y> { double a; };,
3527                                X<int> int_x;
3528                                X<Y> y_x;,
3529                                ac_cv_cpp_modern_specialize_template_syntax=yes,
3530                                ac_cv_cpp_modern_specialize_template_syntax=no)])
3531 if test "$ac_cv_cpp_modern_specialize_template_syntax" = no ; then
3532   AC_MSG_ERROR([The C++ compiler does not support template specialization])
3535 dnl Some compilers support only full specialization, and some don't.
3536 AC_CACHE_CHECK(whether partial template specialization works,
3537                ac_cv_cpp_partial_specialization,
3538                [AC_TRY_COMPILE(template <class T> class Foo {};
3539                                template <class T> class Foo<T*> {};,
3540                                return 0;,
3541                                ac_cv_cpp_partial_specialization=yes,
3542                                ac_cv_cpp_partial_specialization=no)])
3543 if test "$ac_cv_cpp_partial_specialization" = yes ; then
3544   AC_DEFINE(HAVE_CPP_PARTIAL_SPECIALIZATION)
3547 dnl Check to see if we can resolve ambiguity with |using|.
3548 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
3549                ac_cv_cpp_ambiguity_resolving_using,
3550                [AC_TRY_COMPILE(class X {
3551                                  public: int go(const X&) {return 3;}
3552                                          int jo(const X&) {return 3;}
3553                                };
3554                                class Y : public X {
3555                                  public:  int go(int) {return 2;}
3556                                           int jo(int) {return 2;}
3557                                           using X::jo;
3558                                  private: using X::go;
3559                                };,
3560                                X x; Y y; y.jo(x);,
3561                                ac_cv_cpp_ambiguity_resolving_using=yes,
3562                                ac_cv_cpp_ambiguity_resolving_using=no)])
3563 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
3564    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
3567 dnl See if a dynamic_cast to void* gives the most derived object.
3568 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
3569                ac_cv_cpp_dynamic_cast_void_ptr,
3570                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
3571                             class Y { int j; public: virtual ~Y() { } };
3572                             class Z : public X, public Y { int k; };
3574                             int main() {
3575                                  Z mdo;
3576                                  X *subx = (X*)&mdo;
3577                                  Y *suby = (Y*)&mdo;
3578                                  return !((((void*)&mdo != (void*)subx) &&
3579                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
3580                                           (((void*)&mdo != (void*)suby) &&
3581                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
3582                             }],
3583                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
3584                            ac_cv_cpp_dynamic_cast_void_ptr=no,
3585                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
3586 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
3587    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
3591 dnl note that this one is reversed - if the test fails, then
3592 dnl we require implementations of unused virtual methods. Which
3593 dnl really blows because it means we'll have useless vtable
3594 dnl bloat.
3595 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
3596                ac_cv_cpp_unused_required,
3597                [AC_TRY_LINK(class X {private: virtual void never_called();};,
3598                                X x;,
3599                                ac_cv_cpp_unused_required=no,
3600                                ac_cv_cpp_unused_required=yes)])
3601 if test "$ac_cv_cpp_unused_required" = yes ; then
3602    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
3606 dnl Some compilers have trouble comparing a constant reference to a templatized
3607 dnl class to zero, and require an explicit operator==() to be defined that takes
3608 dnl an int. This test separates the strong from the weak.
3610 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
3611                ac_cv_trouble_comparing_to_zero,
3612                [AC_TRY_COMPILE([#include <algorithm>
3613                                 template <class T> class Foo {};
3614                                 class T2;
3615                                 template <class T> int operator==(const T2*, const T&) { return 0; }
3616                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
3617                                [Foo<int> f; return (0 != f);],
3618                                ac_cv_trouble_comparing_to_zero=no,
3619                                ac_cv_trouble_comparing_to_zero=yes)])
3620 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
3621   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
3624 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
3625 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
3626 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
3627 # linking XUL.
3628 _SAVE_LDFLAGS=$LDFLAGS
3629 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
3630 AC_CACHE_CHECK(for __thread keyword for TLS variables,
3631                ac_cv_thread_keyword,
3632                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
3633                             [return tlsIsMainThread;],
3634                             ac_cv_thread_keyword=yes,
3635                             ac_cv_thread_keyword=no)])
3636 LDFLAGS=$_SAVE_LDFLAGS
3637 # The custom dynamic linker doesn't support TLS variables
3638 MOZ_TLS=
3639 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
3640   # mips builds fail with TLS variables because of a binutils bug.
3641   # See bug 528687
3642   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
3643   case "${target}" in
3644     mips*-*)
3645       :
3646       ;;
3647     *-android*|*-linuxandroid*)
3648       :
3649       ;;
3650     *-openbsd*)
3651       :
3652       ;;
3653     *)
3654       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
3655       MOZ_TLS=1
3656       ;;
3657   esac
3660 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
3661 if test -n "$MOZ_LINKER"; then
3662   if test "$CPU_ARCH" = arm; then
3663     dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
3664     ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]]*\).*/\1/p'`
3665     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
3666     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
3667       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000"
3668       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000"
3669     fi
3670   fi
3673 dnl The custom linker doesn't support text relocations, but NDK >= r6b
3674 dnl creates some (http://code.google.com/p/android/issues/detail?id=23203)
3675 dnl We however want to avoid these text relocations, and this can be done
3676 dnl by making gcc not link crtbegin and crtend. In the broken NDKs, crtend
3677 dnl doesn't contain anything at all, beside placeholders for some sections,
3678 dnl and crtbegin only contains a finalizer function that calls
3679 dnl __cxa_finalize. The custom linker actually takes care of calling
3680 dnl __cxa_finalize when the library doesn't call it itself, which makes it
3681 dnl safe not to link crtbegin. Besides, previous versions of the NDK didn't
3682 dnl link crtbegin and crtend at all.
3683 if test -n "$MOZ_LINKER" -a -z "$MOZ_OLD_LINKER" -a "$OS_TARGET" = "Android"; then
3684   AC_CACHE_CHECK([whether the CRT objects have text relocations],
3685     ac_cv_crt_has_text_relocations,
3686     [echo 'int foo() { return 0; }' > conftest.cpp
3687      if AC_TRY_COMMAND(${CXX-g++} -o conftest${DLL_SUFFIX} $CXXFLAGS $DSO_LDOPTS $LDFLAGS conftest.cpp $LIBS 1>&5) &&
3688         test -s conftest${DLL_SUFFIX}; then
3689        if ${TOOLCHAIN_PREFIX}readelf -d conftest${DLL_SUFFIX} | grep TEXTREL > /dev/null; then
3690          ac_cv_crt_has_text_relocations=yes
3691        else
3692          ac_cv_crt_has_text_relocations=no
3693        fi
3694      else
3695        AC_ERROR([couldn't compile a simple C file])
3696      fi
3697      rm -rf conftest*])
3698   if test "$ac_cv_crt_has_text_relocations" = yes; then
3699     dnl While we want libraries to skip the CRT files, we don't want
3700     dnl executables to be treated the same way. We thus set the flag
3701     dnl in DSO_LDOPTS and not LDFLAGS. However, to pass it to nspr,
3702     dnl we need to use LDFLAGS because nspr doesn't inherit DSO_LDOPTS.
3703     dnl Using LDFLAGS in nspr is safe, since we only really build
3704     dnl libraries there.
3705     DSO_LDOPTS="$DSO_LDOPTS -nostartfiles"
3706     NSPR_LDFLAGS=-nostartfiles
3707   fi
3710 dnl Check for the existence of various allocation headers/functions
3712 MALLOC_H=
3713 MOZ_CHECK_HEADER(malloc.h,        [MALLOC_H=malloc.h])
3714 if test "$MALLOC_H" = ""; then
3715   MOZ_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h])
3716   if test "$MALLOC_H" = ""; then
3717     MOZ_CHECK_HEADER(sys/malloc.h,    [MALLOC_H=sys/malloc.h])
3718   fi
3720 if test "$MALLOC_H" != ""; then
3721    AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
3724 MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
3725 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
3727 dnl See if compiler supports some gcc-style attributes
3729 AC_CACHE_CHECK(for __attribute__((always_inline)),
3730                ac_cv_attribute_always_inline,
3731                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
3732                                [],
3733                                ac_cv_attribute_always_inline=yes,
3734                                ac_cv_attribute_always_inline=no)])
3736 AC_CACHE_CHECK(for __attribute__((malloc)),
3737                ac_cv_attribute_malloc,
3738                [AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
3739                                [],
3740                                ac_cv_attribute_malloc=yes,
3741                                ac_cv_attribute_malloc=no)])
3743 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
3744                ac_cv_attribute_warn_unused,
3745                [AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
3746                                [],
3747                                ac_cv_attribute_warn_unused=yes,
3748                                ac_cv_attribute_warn_unused=no)])
3750 dnl End of C++ language/feature checks
3751 AC_LANG_C
3753 dnl ========================================================
3754 dnl =  Internationalization checks
3755 dnl ========================================================
3757 dnl Internationalization and Locale support is different
3758 dnl on various UNIX platforms.  Checks for specific i18n
3759 dnl features go here.
3761 dnl check for LC_MESSAGES
3762 AC_CACHE_CHECK(for LC_MESSAGES,
3763                 ac_cv_i18n_lc_messages,
3764                 [AC_TRY_COMPILE([#include <locale.h>],
3765                                 [int category = LC_MESSAGES;],
3766                                 ac_cv_i18n_lc_messages=yes,
3767                                 ac_cv_i18n_lc_messages=no)])
3768 if test "$ac_cv_i18n_lc_messages" = yes; then
3769    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
3772 AC_HAVE_FUNCS(localeconv)
3773 fi # ! SKIP_COMPILER_CHECKS
3775 TARGET_XPCOM_ABI=
3776 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
3777     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
3780 dnl Mozilla specific options
3781 dnl ========================================================
3782 dnl The macros used for command line options
3783 dnl are defined in build/autoconf/altoptions.m4.
3785 dnl If the compiler supports these attributes, define them as
3786 dnl convenience macros.
3787 if test "$ac_cv_attribute_always_inline" = yes ; then
3788   AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
3789 else
3790   AC_DEFINE(NS_ALWAYS_INLINE,)
3793 if test "$ac_cv_attribute_malloc" = yes ; then
3794   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
3795 else
3796   AC_DEFINE(NS_ATTR_MALLOC,)
3799 if test "$ac_cv_attribute_warn_unused" = yes ; then
3800   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
3801 else
3802   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
3805 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
3806 dnl features that Windows actually does support.
3808 if test -n "$SKIP_COMPILER_CHECKS"; then
3809    dnl Windows has malloc.h
3810    AC_DEFINE(MALLOC_H, [<malloc.h>])
3811    AC_DEFINE(HAVE_FORCEINLINE)
3812    AC_DEFINE(HAVE_LOCALECONV)
3813 fi # SKIP_COMPILER_CHECKS
3815 dnl ========================================================
3816 dnl =
3817 dnl = Check for external package dependencies
3818 dnl =
3819 dnl ========================================================
3820 MOZ_ARG_HEADER(External Packages)
3822 MOZ_ARG_WITH_STRING(libxul-sdk,
3823 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
3824   LIBXUL_SDK_DIR=$withval)
3826 if test "$LIBXUL_SDK_DIR" = "yes"; then
3827     AC_MSG_ERROR([--with-libxul-sdk must specify a path])
3828 elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
3829     LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
3831     if test ! -f "$LIBXUL_SDK/include/xpcom-config.h"; then
3832         AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
3833     fi
3836 AC_SUBST(LIBXUL_SDK)
3838 if test -n "$LIBXUL_SDK"; then
3839     LIBXUL_DIST="$LIBXUL_SDK"
3840 else
3841     LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
3843 AC_SUBST(LIBXUL_DIST)
3845 SYSTEM_LIBXUL=
3847 MOZ_ARG_WITH_BOOL(system-libxul,
3848 [  --with-system-libxul    Use system installed libxul SDK],
3849     SYSTEM_LIBXUL=1)
3851 dnl ========================================================
3852 dnl = If NSPR was not detected in the system,
3853 dnl = use the one in the source tree (mozilla/nsprpub)
3854 dnl ========================================================
3855 MOZ_ARG_WITH_BOOL(system-nspr,
3856 [  --with-system-nspr      Use system installed NSPR],
3857     _USE_SYSTEM_NSPR=1 )
3859 if test -n "$_USE_SYSTEM_NSPR"; then
3860     AM_PATH_NSPR(4.9.2, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])])
3863 if test -n "$MOZ_NATIVE_NSPR"; then
3864     _SAVE_CFLAGS=$CFLAGS
3865     CFLAGS="$CFLAGS $NSPR_CFLAGS"
3866     AC_TRY_COMPILE([#include "prtypes.h"],
3867                 [#ifndef PR_STATIC_ASSERT
3868                  #error PR_STATIC_ASSERT not defined or requires including prtypes.h
3869                  #endif],
3870                 [MOZ_NATIVE_NSPR=1],
3871                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
3872     AC_TRY_COMPILE([#include "prtypes.h"],
3873                 [#ifndef PR_UINT64
3874                  #error PR_UINT64 not defined or requires including prtypes.h
3875                  #endif],
3876                 [MOZ_NATIVE_NSPR=1],
3877                 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
3878     CFLAGS=$_SAVE_CFLAGS
3879 else
3880     if test -z "$LIBXUL_SDK"; then
3881         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
3882         if test -n "$GNU_CC"; then
3883             NSPR_LIBS="-L${LIBXUL_DIST}/lib -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
3884         else
3885             NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
3886         fi
3887     else
3888         NSPR_CFLAGS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --includedir="${LIBXUL_DIST}/include/nspr" --cflags`
3889         NSPR_LIBS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --libdir="${LIBXUL_DIST}"/lib --libs`
3890     fi
3893 dnl system libevent Support
3894 dnl ========================================================
3895 MOZ_ARG_WITH_STRING(system-libevent,
3896 [  --with-system-libevent[=PFX]
3897                           Use system libevent [installed at prefix PFX]],
3898     LIBEVENT_DIR=$withval)
3900 _SAVE_CFLAGS=$CFLAGS
3901 _SAVE_LDFLAGS=$LDFLAGS
3902 _SAVE_LIBS=$LIBS
3903 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
3904     MOZ_NATIVE_LIBEVENT=
3905 elif test "$LIBEVENT_DIR" = yes; then
3906     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
3907         MOZ_NATIVE_LIBEVENT=1,
3908         AC_MSG_ERROR([--with-system-libevent requested but libevent package not found]))
3909 else
3910     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
3911     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
3912     MOZ_CHECK_HEADER(event.h,
3913         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
3914              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
3915          fi],
3916         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
3917     AC_CHECK_LIB(event, event_init,
3918                  [MOZ_NATIVE_LIBEVENT=1
3919                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
3920                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
3921                  [MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
3923 CFLAGS=$_SAVE_CFLAGS
3924 LDFLAGS=$_SAVE_LDFLAGS
3925 LIBS=$_SAVE_LIBS
3927 AC_SUBST(MOZ_NATIVE_LIBEVENT)
3928 AC_SUBST(MOZ_LIBEVENT_CFLAGS)
3929 AC_SUBST(MOZ_LIBEVENT_LIBS)
3931 dnl ========================================================
3932 dnl = If NSS was not detected in the system,
3933 dnl = use the one in the source tree (mozilla/security/nss)
3934 dnl ========================================================
3936 MOZ_ARG_WITH_BOOL(system-nss,
3937 [  --with-system-nss       Use system installed NSS],
3938     _USE_SYSTEM_NSS=1 )
3940 if test -n "$_USE_SYSTEM_NSS"; then
3941     AM_PATH_NSS(3.13.2, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
3944 if test -n "$MOZ_NATIVE_NSS"; then
3945    NSS_LIBS="$NSS_LIBS -lcrmf"
3946 else
3947    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
3948    NSS_DEP_LIBS="\
3949         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
3950         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)smime$NSS_VERSION\$(DLL_SUFFIX) \
3951         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)ssl$NSS_VERSION\$(DLL_SUFFIX) \
3952         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nss$NSS_VERSION\$(DLL_SUFFIX) \
3953         \$(LIBXUL_DIST)/lib/\$(DLL_PREFIX)nssutil$NSS_VERSION\$(DLL_SUFFIX)"
3955    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2"; then
3956        NSS_LIBS="\
3957         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
3958         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
3959         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
3960         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
3961         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
3962    else
3963        NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
3964    fi
3967 dnl ======================
3968 dnl Detect yasm
3969 dnl ======================
3971 AC_MSG_CHECKING([for YASM assembler])
3972 AC_CHECK_PROGS(YASM, yasm, "")
3974 if test -n "$YASM"; then
3975   dnl Pull out yasm's version string
3976   YASM_VERSION=`yasm --version | $AWK '/^yasm/ { print $2 }'`
3977   _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
3978   _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
3979   _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
3980   _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
3983 if test -z "$SKIP_LIBRARY_CHECKS"; then
3984 dnl system JPEG support
3985 dnl ========================================================
3986 MOZ_ARG_WITH_STRING(system-jpeg,
3987 [  --with-system-jpeg[=PFX]
3988                           Use system libjpeg [installed at prefix PFX]],
3989     JPEG_DIR=$withval)
3991 _SAVE_CFLAGS=$CFLAGS
3992 _SAVE_LDFLAGS=$LDFLAGS
3993 _SAVE_LIBS=$LIBS
3994 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
3995     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
3996     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
3998 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
3999     MOZ_NATIVE_JPEG=
4000 else
4001     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_NATIVE_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_NATIVE_JPEG=)
4004 if test "$MOZ_NATIVE_JPEG" = 1; then
4005     AC_TRY_COMPILE([ #include <stdio.h>
4006                      #include <sys/types.h>
4007                      #include <jpeglib.h> ],
4008                    [ #if JPEG_LIB_VERSION < $MOZJPEG
4009                      #error "Insufficient JPEG library version ($MOZJPEG required)."
4010                      #endif
4011                      #ifndef JCS_EXTENSIONS
4012                      #error "libjpeg-turbo JCS_EXTENSIONS required"
4013                      #endif
4014                      ],
4015                    MOZ_NATIVE_JPEG=1,
4016                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
4018 CFLAGS=$_SAVE_CFLAGS
4019 LDFLAGS=$_SAVE_LDFLAGS
4020 LIBS=$_SAVE_LIBS
4022 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
4023     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
4024     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
4026 fi # SKIP_LIBRARY_CHECKS
4028 dnl system ZLIB support
4029 dnl ========================================================
4030 MOZ_ZLIB_CHECK([1.2.3])
4032 if test "$MOZ_NATIVE_ZLIB" != 1; then
4033     MOZ_ZLIB_CFLAGS=
4034     MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,'"$MOZ_BUILD_ROOT"'/modules/zlib/src)'
4037 if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
4038     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
4041 if test -z "$SKIP_LIBRARY_CHECKS"; then
4042 dnl system BZIP2 Support
4043 dnl ========================================================
4044 MOZ_ARG_WITH_STRING(system-bz2,
4045 [  --with-system-bz2[=PFX]
4046                           Use system libbz2 [installed at prefix PFX]],
4047     BZ2_DIR=$withval)
4049 _SAVE_CFLAGS=$CFLAGS
4050 _SAVE_LDFLAGS=$LDFLAGS
4051 _SAVE_LIBS=$LIBS
4052 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
4053     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
4054     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
4056 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
4057     MOZ_NATIVE_BZ2=
4058 else
4059     AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_NATIVE_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
4060         [MOZ_NATIVE_BZ2= MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS=])
4062 CFLAGS=$_SAVE_CFLAGS
4063 LDFLAGS=$_SAVE_LDFLAGS
4064 LIBS=$_SAVE_LIBS
4066 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_NATIVE_BZ2" = 1; then
4067     MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
4068     MOZ_BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
4071 dnl system PNG Support
4072 dnl ========================================================
4073 MOZ_ARG_WITH_STRING(system-png,
4074 [  --with-system-png[=PFX]
4075                           Use system libpng [installed at prefix PFX]],
4076     PNG_DIR=$withval)
4078 _SAVE_CFLAGS=$CFLAGS
4079 _SAVE_LDFLAGS=$LDFLAGS
4080 _SAVE_LIBS=$LIBS
4081 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
4082     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
4083     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
4085 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
4086     MOZ_NATIVE_PNG=
4087 else
4088     AC_CHECK_LIB(png, png_get_valid, [MOZ_NATIVE_PNG=1 MOZ_PNG_LIBS="-lpng"],
4089                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4090     AC_CHECK_LIB(png, png_get_acTL, ,
4091                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
4093 if test "$MOZ_NATIVE_PNG" = 1; then
4094     AC_TRY_COMPILE([ #include <stdio.h>
4095                      #include <sys/types.h>
4096                      #include <png.h> ],
4097                    [ #if PNG_LIBPNG_VER < $MOZPNG
4098                      #error "Insufficient libpng version ($MOZPNG required)."
4099                      #endif
4100                      #ifndef PNG_UINT_31_MAX
4101                      #error "Insufficient libpng version."
4102                      #endif ],
4103                    MOZ_NATIVE_PNG=1,
4104                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
4106 CFLAGS=$_SAVE_CFLAGS
4107 LDFLAGS=$_SAVE_LDFLAGS
4108 LIBS=$_SAVE_LIBS
4110 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_NATIVE_PNG" = 1; then
4111     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
4112     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
4115 fi # SKIP_LIBRARY_CHECKS
4117 dnl system HunSpell Support
4118 dnl ========================================================
4119 MOZ_ARG_ENABLE_BOOL(system-hunspell,
4120 [  --enable-system-hunspell
4121                           Use system hunspell (located with pkgconfig)],
4122     MOZ_NATIVE_HUNSPELL=1 )
4124 if test -n "$MOZ_NATIVE_HUNSPELL"; then
4125     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
4128 AC_SUBST(MOZ_NATIVE_HUNSPELL)
4130 dnl ========================================================
4131 dnl system libffi Support
4132 dnl ========================================================
4133 MOZ_ARG_ENABLE_BOOL(system-ffi,
4134 [  --enable-system-ffi       Use system libffi (located with pkgconfig)],
4135     MOZ_NATIVE_FFI=1 )
4137 if test -n "$MOZ_NATIVE_FFI"; then
4138     # Vanilla libffi 3.0.9 needs a few patches from upcoming version 3.0.10
4139     # for non-GCC compilers.
4140     if test -z "$GNU_CC"; then
4141         PKG_CHECK_MODULES(MOZ_FFI, libffi > 3.0.9)
4142     else
4143         PKG_CHECK_MODULES(MOZ_FFI, libffi >= 3.0.9)
4144     fi
4145     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS"
4148 dnl ========================================================
4149 dnl Java SDK support
4150 dnl ========================================================
4152 JAVA_BIN_PATH=
4153 MOZ_ARG_WITH_STRING(java-bin-path,
4154 [  --with-java-bin-path=dir
4155                           Location of Java binaries (java, javac, jar)],
4156     JAVA_BIN_PATH=$withval)
4158 dnl ========================================================
4159 dnl =
4160 dnl = Application
4161 dnl =
4162 dnl ========================================================
4164 MOZ_ARG_HEADER(Application)
4166 ENABLE_TESTS=1
4167 ENABLE_SYSTEM_EXTENSION_DIRS=1
4168 MOZ_BRANDING_DIRECTORY=
4169 MOZ_OFFICIAL_BRANDING=
4170 MOZ_FEEDS=1
4171 MOZ_FLEXBOX=
4172 MOZ_WEBAPP_RUNTIME=
4173 MOZ_JSDEBUGGER=1
4174 MOZ_AUTH_EXTENSION=1
4175 MOZ_OGG=1
4176 MOZ_RAW=
4177 MOZ_SYDNEYAUDIO=
4178 MOZ_SPEEX_RESAMPLER=1
4179 MOZ_CUBEB=
4180 MOZ_VORBIS=
4181 MOZ_TREMOR=
4182 MOZ_WAVE=1
4183 MOZ_SAMPLE_TYPE_FLOAT32=
4184 MOZ_SAMPLE_TYPE_S16=
4185 MOZ_MEDIA=
4186 MOZ_OPUS=1
4187 MOZ_WEBM=1
4188 MOZ_WEBRTC=1
4189 MOZ_SRTP=
4190 MOZ_WEBRTC_SIGNALING=
4191 MOZ_MEDIA_PLUGINS=
4192 MOZ_MEDIA_NAVIGATOR=
4193 MOZ_OMX_PLUGIN=
4194 MOZ_VP8=
4195 MOZ_VP8_ERROR_CONCEALMENT=
4196 MOZ_VP8_ENCODER=
4197 VPX_AS=
4198 VPX_ASFLAGS=
4199 VPX_AS_DASH_C_FLAG=
4200 VPX_AS_CONVERSION=
4201 VPX_ASM_SUFFIX=
4202 VPX_X86_ASM=
4203 VPX_ARM_ASM=
4204 LIBJPEG_TURBO_AS=
4205 LIBJPEG_TURBO_ASFLAGS=
4206 LIBJPEG_TURBO_X86_ASM=
4207 LIBJPEG_TURBO_X64_ASM=
4208 LIBJPEG_TURBO_ARM_ASM=
4209 MOZ_PANGO=1
4210 MOZ_PERMISSIONS=1
4211 MOZ_PLACES=1
4212 MOZ_PREF_EXTENSIONS=1
4213 MOZ_PROFILELOCKING=1
4214 MOZ_PSM=1
4215 MOZ_REFLOW_PERF=
4216 MOZ_SAFE_BROWSING=
4217 MOZ_HELP_VIEWER=
4218 MOZ_SPELLCHECK=1
4219 MOZ_JAVA_COMPOSITOR=
4220 MOZ_ONLY_TOUCH_EVENTS=
4221 MOZ_TOOLKIT_SEARCH=1
4222 MOZ_UI_LOCALE=en-US
4223 MOZ_UNIVERSALCHARDET=1
4224 MOZ_URL_CLASSIFIER=
4225 MOZ_XTF=1
4226 MOZ_XUL=1
4227 MOZ_ZIPWRITER=1
4228 NS_PRINTING=1
4229 MOZ_PDF_PRINTING=
4230 MOZ_DISABLE_DOMCRYPTO=
4231 NSS_DISABLE_DBM=
4232 NECKO_WIFI=1
4233 NECKO_COOKIES=1
4234 NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg device"
4235 USE_ARM_KUSER=
4236 BUILD_CTYPES=1
4237 MOZ_USE_NATIVE_POPUP_WINDOWS=
4238 MOZ_ANDROID_HISTORY=
4239 MOZ_WEBSMS_BACKEND=
4240 MOZ_GRAPHITE=1
4241 ACCESSIBILITY=1
4242 MOZ_SYS_MSG=
4243 MOZ_PAY=
4245 case "$target_os" in
4246     mingw*)
4247         NS_ENABLE_TSF=1
4248         AC_DEFINE(NS_ENABLE_TSF)
4249         ;;
4250 esac
4252 case "${target}" in
4253     *-android*|*-linuxandroid*)
4254         if test "$CPU_ARCH" = "arm" ; then
4255           USE_ARM_KUSER=1
4256         fi
4258         NSS_DISABLE_DBM=1
4259         NECKO_WIFI=
4260         MOZ_THEME_FASTSTRIPE=1
4261         MOZ_TREE_FREETYPE=1
4262         MOZ_MEMORY=1
4263         MOZ_RAW=1
4264         ;;
4266 esac
4268 MOZ_ARG_ENABLE_STRING(application,
4269 [  --enable-application=APP
4270                           Options include:
4271                             browser (Firefox)
4272                             xulrunner
4273                             tools/update-packaging (AUS-related packaging tools)],
4274 [ MOZ_BUILD_APP=$enableval ] )
4276 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
4277 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
4278   XULRUNNER_STUB_NAME=$withval)
4280 if test -z "$XULRUNNER_STUB_NAME"; then
4281   case "$target_os" in
4282   darwin*)
4283     XULRUNNER_STUB_NAME=xulrunner
4284     ;;
4285   *)
4286     XULRUNNER_STUB_NAME=xulrunner-stub
4287   esac
4289 AC_SUBST(XULRUNNER_STUB_NAME)
4291 AC_MSG_CHECKING([for application to build])
4292 if test -z "$MOZ_BUILD_APP"; then
4293   AC_MSG_RESULT([browser])
4294   MOZ_BUILD_APP=browser
4295 else
4296   # default mobile to be mobile/xul
4297   if test "$MOZ_BUILD_APP" = "mobile" ; then
4298     MOZ_BUILD_APP=mobile/xul
4299   fi
4300   # We have a valid application only if it has a build.mk file in its top
4301   # directory.
4302   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
4303     AC_MSG_RESULT([none])
4304     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
4305   else
4306     AC_MSG_RESULT([$MOZ_BUILD_APP])
4307   fi
4310 # Allow the application to influence configure with a confvars.sh script.
4312 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4313 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4314   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4315   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4316 else
4317   AC_MSG_RESULT([no])
4320 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
4321 MOZ_ARG_WITH_STRING(app-name,
4322 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
4323 WITH_APP_NAME=$withval,
4326 if test -n "$WITH_APP_NAME" ; then
4327     MOZ_APP_NAME="$WITH_APP_NAME"
4330 MOZ_ARG_WITH_STRING(app-basename,
4331 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
4332 WITH_APP_BASENAME=$withval,
4335 if test -n "$WITH_APP_BASENAME" ; then
4336     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
4339 # Now is a good time to test for logic errors, define mismatches, etc.
4340 case "$MOZ_BUILD_APP" in
4341 xulrunner)
4342   if test "$LIBXUL_SDK"; then
4343     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4344   fi
4345   ;;
4346 esac
4348 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4349 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4350 # MOZ_BUILD_APP.
4351 case "$MOZ_BUILD_APP" in
4352 browser)
4353   AC_DEFINE(MOZ_PHOENIX)
4354   ;;
4356 xulrunner)
4357   AC_DEFINE(MOZ_XULRUNNER)
4358   ;;
4359 esac
4361 AC_SUBST(MOZ_BUILD_APP)
4362 AC_SUBST(MOZ_PHOENIX)
4363 AC_SUBST(MOZ_XULRUNNER)
4365 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4367 dnl ========================================================
4368 dnl Check android sdk version depending on mobile target
4369 dnl ========================================================
4371 if test -z "$gonkdir" ; then
4372     # Minimum Android SDK API Level we require.
4373     case "$MOZ_BUILD_APP" in
4374     mobile/xul)
4375         android_min_api_level=13
4376         ;;
4377     mobile/android)
4378         android_min_api_level=16
4379         ;;
4380     esac
4382     MOZ_ANDROID_SDK($android_min_api_level)
4385 dnl ========================================================
4386 dnl =
4387 dnl = Toolkit Options
4388 dnl =
4389 dnl ========================================================
4390 MOZ_ARG_HEADER(Toolkit Options)
4392     dnl ========================================================
4393     dnl = Select the default toolkit
4394     dnl ========================================================
4395         MOZ_ARG_ENABLE_STRING(default-toolkit,
4396         [  --enable-default-toolkit=TK
4397                           Select default toolkit
4398                           Platform specific defaults:
4399                             Mac OS X - cairo-cocoa
4400                             OS/2 - cairo-os2
4401                             Win32 - cairo-windows
4402                             * - cairo-gtk2
4403                             * - cairo-qt],
4404     [ _DEFAULT_TOOLKIT=$enableval ],
4405     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4407     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4408         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4409         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4410         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4411         -o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
4412         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
4413         -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
4414         -o "$_DEFAULT_TOOLKIT" = "cairo-android" \
4415         -o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
4416     then
4417         dnl nglayout only supports building with one toolkit,
4418         dnl so ignore everything after the first comma (",").
4419         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4420     else
4421         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4422     fi
4424 MOZ_ARG_WITHOUT_BOOL(x,
4425 [  --without-x              Build without X11],
4426     WITHOUT_X11=1)
4428 dnl ========================================================
4429 dnl = Enable the toolkit as needed                         =
4430 dnl ========================================================
4432 MOZ_WIDGET_GTK=
4434 case "$MOZ_WIDGET_TOOLKIT" in
4436 cairo-windows)
4437     MOZ_WIDGET_TOOLKIT=windows
4438     MOZ_WEBGL=1
4439     MOZ_PDF_PRINTING=1
4440     MOZ_INSTRUMENT_EVENT_LOOP=1
4441     ;;
4443 cairo-gtk2|cairo-gtk2-x11)
4444     MOZ_WIDGET_TOOLKIT=gtk2
4445     MOZ_ENABLE_GTK2=1
4446     MOZ_ENABLE_XREMOTE=1
4447     MOZ_WEBGL=1
4448     MOZ_GL_DEFAULT_PROVIDER=GLX
4450     AC_DEFINE(MOZ_X11)
4451     MOZ_X11=1
4452     USE_FC_FREETYPE=1
4454     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4455     TK_LIBS='$(MOZ_GTK2_LIBS)'
4456     AC_DEFINE(MOZ_WIDGET_GTK2)
4457     MOZ_WIDGET_GTK=2
4458     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4459     MOZ_PDF_PRINTING=1
4460     MOZ_INSTRUMENT_EVENT_LOOP=1
4461     ;;
4463 cairo-qt)
4464     MOZ_WIDGET_TOOLKIT=qt
4465     MOZ_ENABLE_QT=1
4466     if test -z "$WITHOUT_X11"; then
4467       MOZ_ENABLE_XREMOTE=1
4468       MOZ_GL_DEFAULT_PROVIDER=GLX
4469       MOZ_X11=1
4470       AC_DEFINE(MOZ_X11)
4471       XT_LIBS=
4472     fi
4474     MOZ_WEBGL=1
4475     USE_ELF_DYNSTR_GC=
4476     USE_FC_FREETYPE=1
4477     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4478     TK_LIBS='$(MOZ_QT_LIBS)'
4479     AC_DEFINE(MOZ_WIDGET_QT)
4480     MOZ_PDF_PRINTING=1
4481     ;;
4483 cairo-os2)
4484     MOZ_WIDGET_TOOLKIT=os2
4485     USE_FC_FREETYPE=1
4486     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4487     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4488     MOZ_PDF_PRINTING=1
4489     ;;
4491 cairo-cocoa)
4492     MOZ_WIDGET_TOOLKIT=cocoa
4493     AC_DEFINE(MOZ_WIDGET_COCOA)
4494     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
4495     TK_LIBS='-framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
4496     TK_CFLAGS="-DNO_X11"
4497     CFLAGS="$CFLAGS $TK_CFLAGS"
4498     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4499     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
4500     MOZ_USER_DIR="Mozilla"
4501     MOZ_FS_LAYOUT=bundle
4502     MOZ_WEBGL=1
4503     MOZ_INSTRUMENT_EVENT_LOOP=1
4504     ;;
4506 cairo-uikit)
4507     MOZ_WIDGET_TOOLKIT=uikit
4508     AC_DEFINE(MOZ_WIDGET_UIKIT)
4509     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
4510     TK_CFLAGS="-DNO_X11"
4511     TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
4512     CFLAGS="$CFLAGS $TK_CFLAGS"
4513     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4514     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
4515     MOZ_USER_DIR="Mozilla"
4516     MOZ_FS_LAYOUT=bundle
4517     ;;
4519 cairo-android)
4520     AC_DEFINE(MOZ_WIDGET_ANDROID)
4521     MOZ_WIDGET_TOOLKIT=android
4522     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4523     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4524     MOZ_WEBGL=1
4525     MOZ_PDF_PRINTING=1
4526     MOZ_INSTRUMENT_EVENT_LOOP=1
4527     if test "$MOZ_BUILD_APP" = "mobile/xul"; then
4528         MOZ_OLD_LINKER=1
4529     fi
4530     ;;
4532 cairo-gonk)
4533     AC_DEFINE(MOZ_WIDGET_GONK)
4534     AC_DEFINE(MOZ_TOUCH)
4535     MOZ_WIDGET_TOOLKIT=gonk
4536     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4537     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4538     MOZ_WEBGL=1
4539     MOZ_PDF_PRINTING=1
4540     MOZ_TOUCH=1
4541     ;;
4543 esac
4545 AC_SUBST(MOZ_OLD_LINKER)
4546 AC_SUBST(MOZ_PDF_PRINTING)
4547 if test "$MOZ_PDF_PRINTING"; then
4548    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
4549    AC_DEFINE(MOZ_PDF_PRINTING)
4552 if test "$MOZ_ENABLE_XREMOTE"; then
4553     AC_DEFINE(MOZ_ENABLE_XREMOTE)
4556 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
4557    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
4560 if test "$COMPILE_ENVIRONMENT"; then
4561   if test "$MOZ_ENABLE_GTK2"; then
4562     if test "$MOZ_X11"; then
4563       GDK_PACKAGES=gdk-x11-2.0
4564     fi
4566     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4567   fi
4569 fi # COMPILE_ENVIRONMENT
4571 AC_SUBST(MOZ_FS_LAYOUT)
4573 dnl ========================================================
4574 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4575 dnl their usage and use them in spidermonkey.
4576 dnl ========================================================
4577 MOZ_ARG_WITH_BOOL(arm-kuser,
4578 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4579     USE_ARM_KUSER=1,)
4580 if test -n "$USE_ARM_KUSER"; then
4581    AC_DEFINE(USE_ARM_KUSER)
4584 dnl ========================================================
4585 dnl = startup-notification support module
4586 dnl ========================================================
4588 if test "$MOZ_ENABLE_GTK2"
4589 then
4590     MOZ_ENABLE_STARTUP_NOTIFICATION=
4592     MOZ_ARG_ENABLE_BOOL(startup-notification,
4593     [  --enable-startup-notification
4594                           Enable startup-notification support (default: disabled) ],
4595         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
4596         MOZ_ENABLE_STARTUP_NOTIFICATION=)
4597     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
4598     then
4599         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
4600                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
4601         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
4602             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
4603             then
4604                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
4605             fi
4606             MOZ_ENABLE_STARTUP_NOTIFICATION=
4607         ])
4608     fi
4610     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
4611         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
4612     fi
4614     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
4616 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
4617 AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
4618 AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
4620 dnl ========================================================
4621 dnl = QT support
4622 dnl ========================================================
4623 if test "$MOZ_ENABLE_QT"
4624 then
4625     MOZ_ARG_WITH_STRING(qtdir,
4626     [  --with-qtdir=\$dir       Specify Qt directory ],
4627     [ QTDIR=$withval])
4629     if test -z "$QTDIR"; then
4630         PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore QtOpenGL)
4631         PKG_CHECK_MODULES(MOZ_QT5, QtWidgets QtMultimedia QtPrintSupport,
4632                       MOZ_ENABLE_QT5=1,
4633                       MOZ_ENABLE_QT5=)
4634         if test "$MOZ_ENABLE_QT5"; then
4635             echo "Using qt5"
4636             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $MOZ_QT5_CFLAGS"
4637             MOZ_QT_LIBS="$MOZ_QT_LIBS $MOZ_QT5_LIBS"
4638         fi
4640         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
4641         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
4642     else
4643         MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
4645         MOZ_QT_CFLAGS="-DQT_SHARED"
4646         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
4647         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/Qt"
4648         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
4649         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
4650         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
4651         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
4652         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative"
4653         HOST_MOC="$QTDIR/bin/moc"
4654         HOST_RCC="$QTDIR/bin/rcc"
4656         # QtWidgets was introduced only in Qt5
4657         if test -d $QTDIR/include/QtWidgets; then
4658             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtWidgets"
4659             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport"
4660             MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtWidgets -lQtPrintSupport"
4661         fi
4662     fi
4663     if test -z "$HOST_MOC"; then
4664         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
4665 incorrect])
4666     fi
4667     if test -z "$HOST_RCC"; then
4668         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is
4669 incorrect])
4670     fi
4672     MOC=$HOST_MOC
4673     RCC=$HOST_RCC
4675     MOZ_ENABLE_QMSYSTEM2=
4676     PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
4677                       MOZ_ENABLE_QMSYSTEM2=1,
4678                       MOZ_ENABLE_QMSYSTEM2=)
4680     if test "$MOZ_ENABLE_QMSYSTEM2"; then
4681       MOZ_ENABLE_QMSYSTEM2=1
4682       MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
4683       MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
4684       AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
4685     fi
4687     MOZ_ENABLE_QTNETWORK=
4688     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
4689                       MOZ_ENABLE_QTNETWORK=1,
4690                       MOZ_ENABLE_QTNETWORK=)
4692     if test "$MOZ_ENABLE_QTNETWORK"; then
4693       MOZ_ENABLE_QTNETWORK=1
4694       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
4695     fi
4697     MOZ_ENABLE_QTMOBILITY=
4698     PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
4699                       MOZ_ENABLE_QTMOBILITY=1,
4700                       MOZ_ENABLE_QTMOBILITY=)
4701     if test "$MOZ_ENABLE_QTMOBILITY"; then
4702        MOZ_ENABLE_QTMOBILITY=1
4703        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
4704        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
4705     else
4706        AC_CHECK_LIB(QtSensors, main, [
4707           MOZ_ENABLE_QTMOBILITY=1
4708           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMobility"
4709           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtSensors"
4710           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtFeedback"
4711           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtLocation"
4712           MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
4713        ])
4714     fi
4715     if test "$MOZ_ENABLE_QTMOBILITY"; then
4716        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
4717     fi
4720 AC_SUBST(GTK_CONFIG)
4721 AC_SUBST(TK_CFLAGS)
4722 AC_SUBST(TK_LIBS)
4724 AC_SUBST(MOZ_ENABLE_GTK2)
4725 AC_SUBST(MOZ_ENABLE_QT)
4726 AC_SUBST(MOZ_ENABLE_QTNETWORK)
4727 AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
4728 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4729 AC_SUBST(MOZ_ENABLE_XREMOTE)
4730 AC_SUBST(MOZ_GTK2_CFLAGS)
4731 AC_SUBST(MOZ_GTK2_LIBS)
4732 AC_SUBST(MOZ_WIDGET_GTK)
4733 AC_SUBST(MOZ_QT_CFLAGS)
4734 AC_SUBST(MOZ_QT_LIBS)
4736 AC_SUBST(MOC)
4737 AC_SUBST(RCC)
4739 AC_SUBST(MOZ_X11)
4741 dnl ========================================================
4742 dnl =
4743 dnl = Components & Features
4744 dnl =
4745 dnl ========================================================
4746 MOZ_ARG_HEADER(Components and Features)
4748 dnl ========================================================
4749 dnl = Localization
4750 dnl ========================================================
4751 MOZ_ARG_ENABLE_STRING(ui-locale,
4752 [  --enable-ui-locale=ab-CD
4753                           Select the user interface locale (default: en-US)],
4754     MOZ_UI_LOCALE=$enableval )
4755 AC_SUBST(MOZ_UI_LOCALE)
4757 dnl ========================================================
4758 dnl = Trademarked Branding
4759 dnl ========================================================
4760 MOZ_ARG_ENABLE_BOOL(official-branding,
4761 [  --enable-official-branding
4762                           Enable Official mozilla.org Branding
4763                           Do not distribute builds with
4764                           --enable-official-branding unless you have
4765                           permission to use trademarks per
4766                           http://www.mozilla.org/foundation/trademarks/ .],
4768   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
4769     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
4770   else
4771     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
4772     MOZ_OFFICIAL_BRANDING=1
4773   fi
4774 ], MOZ_OFFICIAL_BRANDING=)
4776 AC_SUBST(MOZ_OFFICIAL_BRANDING)
4777 if test -n "$MOZ_OFFICIAL_BRANDING"; then
4778   AC_DEFINE(MOZ_OFFICIAL_BRANDING)
4781 MOZ_ARG_WITH_STRING(branding,
4782 [  --with-branding=dir     Use branding from the specified directory.],
4783     MOZ_BRANDING_DIRECTORY=$withval)
4785 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
4786 if test -z "$REAL_BRANDING_DIRECTORY"; then
4787   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
4790 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
4791   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
4794 AC_SUBST(MOZ_BRANDING_DIRECTORY)
4796 dnl ========================================================
4797 dnl = Distribution ID
4798 dnl ========================================================
4799 MOZ_ARG_WITH_STRING(distribution-id,
4800 [  --with-distribution-id=ID
4801                           Set distribution-specific id (default=org.mozilla)],
4802 [ val=`echo $withval`
4803     MOZ_DISTRIBUTION_ID="$val"])
4805 if test -z "$MOZ_DISTRIBUTION_ID"; then
4806    MOZ_DISTRIBUTION_ID="org.mozilla"
4809 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
4810 AC_SUBST(MOZ_DISTRIBUTION_ID)
4813 dnl ========================================================
4814 dnl complex text support off by default
4815 dnl ========================================================
4816 MOZ_ARG_DISABLE_BOOL(pango,
4817 [  --disable-pango         Disable usage of Pango ],
4818     MOZ_PANGO=,
4819     MOZ_PANGO=1)
4821 dnl ========================================================
4822 dnl = Pango
4823 dnl ========================================================
4824 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
4825 then
4826     AC_SUBST(MOZ_PANGO)
4828     if test "$MOZ_PANGO"
4829     then
4830         PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
4832         PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
4833         AC_SUBST(MOZ_PANGO_CFLAGS)
4834         AC_SUBST(MOZ_PANGO_LIBS)
4835         AC_DEFINE(MOZ_PANGO)
4836     else
4837         PKG_CHECK_MODULES(FT2, freetype2 > 6.1.0)
4838         AC_SUBST(FT2_CFLAGS)
4839         AC_SUBST(FT2_LIBS)
4840     fi
4843 dnl ========================================================
4844 dnl = GnomeVFS, GIO and GConf support module
4845 dnl ========================================================
4847 if test "$MOZ_X11"
4848 then
4849     dnl build the gnomevfs extension by default only when the
4850     dnl GTK2 toolkit is in use.
4851     if test "$MOZ_ENABLE_GTK2"
4852     then
4853         MOZ_ENABLE_GNOMEVFS=1
4854         MOZ_ENABLE_GCONF=1
4855     fi
4857     dnl ========================================================
4858     dnl = GnomeVFS support module
4859     dnl ========================================================
4860     MOZ_ARG_DISABLE_BOOL(gnomevfs,
4861     [  --disable-gnomevfs      Disable GnomeVFS support ],
4862         MOZ_ENABLE_GNOMEVFS=,
4863         MOZ_ENABLE_GNOMEVFS=force)
4865     if test "$MOZ_ENABLE_GNOMEVFS"
4866     then
4867         PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
4868             MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
4869             MOZ_ENABLE_GNOMEVFS=1
4870             AC_DEFINE(MOZ_ENABLE_GNOMEVFS)
4871         ],[
4872             if test "$MOZ_ENABLE_GNOMEVFS" = "force"
4873             then
4874                 AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
4875             fi
4876             MOZ_ENABLE_GNOMEVFS=
4877         ])
4878     else
4879         if test `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
4880             PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
4881               MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
4882             ])
4883         fi
4884     fi
4886     AC_SUBST(MOZ_ENABLE_GNOMEVFS)
4887     AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
4888     AC_SUBST(MOZ_GNOMEVFS_LIBS)
4890     dnl ========================================================
4891     dnl = GIO support module
4892     dnl ========================================================
4893     MOZ_ARG_ENABLE_BOOL(gio,
4894     [  --enable-gio            Enable GIO support (default: disabled)],
4895         MOZ_ENABLE_GIO=force,
4896         MOZ_ENABLE_GIO=)
4898     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK2"
4899     then
4900         PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
4901                           [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
4902         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
4903             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
4904             MOZ_ENABLE_GIO=1
4905             AC_DEFINE(MOZ_ENABLE_GIO)
4906         ],[
4907             if test "$MOZ_ENABLE_GIO" = "force"
4908             then
4909                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
4910             fi
4911             MOZ_ENABLE_GIO=
4912         ])
4913     fi
4915     AC_SUBST(MOZ_ENABLE_GIO)
4916     AC_SUBST(MOZ_GIO_CFLAGS)
4917     AC_SUBST(MOZ_GIO_LIBS)
4919     dnl ========================================================
4920     dnl = GConf support module
4921     dnl ========================================================
4922     MOZ_ARG_DISABLE_BOOL(gconf,
4923     [  --disable-gconf      Disable Gconf support ],
4924         MOZ_ENABLE_GCONF=,
4925         MOZ_ENABLE_GCONF=force)
4927     if test "$MOZ_ENABLE_GCONF"
4928     then
4929         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
4930             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
4931             MOZ_ENABLE_GCONF=1
4932         ],[
4933             if test "$MOZ_ENABLE_GCONF" = "force"
4934             then
4935                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
4936             fi
4937             MOZ_ENABLE_GCONF=
4938         ])
4939     fi
4941     if test "$MOZ_ENABLE_GCONF"; then
4942         AC_DEFINE(MOZ_ENABLE_GCONF)
4943     fi
4945     AC_SUBST(MOZ_ENABLE_GCONF)
4946     AC_SUBST(MOZ_GCONF_CFLAGS)
4947     AC_SUBST(MOZ_GCONF_LIBS)
4950 dnl ========================================================
4951 dnl = libproxy support
4952 dnl ========================================================
4954 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
4955 then
4956     MOZ_ENABLE_LIBPROXY=
4958     MOZ_ARG_ENABLE_BOOL(libproxy,
4959     [  --enable-libproxy         Enable libproxy support ],
4960     MOZ_ENABLE_LIBPROXY=1,
4961     MOZ_ENABLE_LIBPROXY=)
4963     if test "$MOZ_ENABLE_LIBPROXY"
4964     then
4965         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
4966         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
4967     fi
4969 AC_SUBST(MOZ_ENABLE_LIBPROXY)
4970 AC_SUBST(MOZ_LIBPROXY_CFLAGS)
4971 AC_SUBST(MOZ_LIBPROXY_LIBS)
4973 dnl ========================================================
4974 dnl = GNOME component (mozgnome)
4975 dnl ========================================================
4977 if test "$MOZ_ENABLE_GTK2"
4978 then
4979     MOZ_ENABLE_GNOME_COMPONENT=1
4981 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
4983 dnl ========================================================
4984 dnl = libgnomeui support module
4985 dnl ========================================================
4987 if test "$MOZ_ENABLE_GTK2"
4988 then
4989     MOZ_ENABLE_GNOMEUI=1
4991     MOZ_ARG_DISABLE_BOOL(gnomeui,
4992     [  --disable-gnomeui       Disable libgnomeui support (default: auto, optional at runtime) ],
4993         MOZ_ENABLE_GNOMEUI=,
4994         MOZ_ENABLE_GNOMEUI=force)
4996     if test "$MOZ_ENABLE_GNOMEUI"
4997     then
4998         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
4999         [
5000             MOZ_GNOMEUI_LIBS=`echo $MOZ_GNOMEUI_LIBS | sed 's/-llinc\>//'`
5001             MOZ_ENABLE_GNOMEUI=1
5002         ],[
5003             if test "$MOZ_ENABLE_GNOMEUI" = "force"
5004             then
5005                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
5006             fi
5007             MOZ_ENABLE_GNOMEUI=
5008         ])
5009     fi
5011     if test "$MOZ_ENABLE_GNOMEUI"; then
5012         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
5013     fi
5016 AC_SUBST(MOZ_ENABLE_GNOMEUI)
5017 AC_SUBST(MOZ_GNOMEUI_CFLAGS)
5018 AC_SUBST(MOZ_GNOMEUI_LIBS)
5020 dnl ========================================================
5021 dnl = dbus support
5022 dnl ========================================================
5024 if test "$MOZ_ENABLE_GTK2" -o "$MOZ_ENABLE_QT"
5025 then
5026     MOZ_ENABLE_DBUS=1
5028     MOZ_ARG_DISABLE_BOOL(dbus,
5029     [  --disable-dbus          Disable dbus support ],
5030         MOZ_ENABLE_DBUS=,
5031         MOZ_ENABLE_DBUS=1)
5033     if test "$MOZ_ENABLE_DBUS"
5034     then
5035         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
5036         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
5037         AC_DEFINE(MOZ_ENABLE_DBUS)
5038     fi
5040 AC_SUBST(MOZ_ENABLE_DBUS)
5041 AC_SUBST(MOZ_DBUS_CFLAGS)
5042 AC_SUBST(MOZ_DBUS_LIBS)
5043 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
5044 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
5046 dnl ========================================================
5047 dnl = Enable Android History instead of Places
5048 dnl ========================================================
5049 if test -n "$MOZ_ANDROID_HISTORY"; then
5050      dnl Do this if defined in confvars.sh
5051      AC_DEFINE(MOZ_ANDROID_HISTORY)
5055 dnl ========================================================
5056 dnl = Build with the Android Java compositor
5057 dnl ========================================================
5058 if test -n "$MOZ_JAVA_COMPOSITOR"; then
5059      dnl Do this if defined in confvars.sh
5060      AC_DEFINE(MOZ_JAVA_COMPOSITOR)
5063 dnl ========================================================
5064 dnl = Disable WebSMS backend
5065 dnl ========================================================
5066 MOZ_ARG_DISABLE_BOOL(websms-backend,
5067 [  --disable-websms-backend
5068                            Disable WebSMS backend],
5069     MOZ_WEBSMS_BACKEND=,
5070     MOZ_WEBSMS_BACKEND=1)
5072 if test -n "$MOZ_WEBSMS_BACKEND"; then
5073     AC_DEFINE(MOZ_WEBSMS_BACKEND)
5076 dnl ========================================================
5077 dnl = Build Personal Security Manager
5078 dnl ========================================================
5079 MOZ_ARG_DISABLE_BOOL(crypto,
5080 [  --disable-crypto        Disable crypto support (Personal Security Manager)],
5081     MOZ_PSM=,
5082     MOZ_PSM=1 )
5084 dnl ========================================================
5085 dnl = JS Debugger XPCOM component (js/jsd)
5086 dnl ========================================================
5087 MOZ_ARG_DISABLE_BOOL(jsd,
5088 [  --disable-jsd           Disable JavaScript debug library],
5089     MOZ_JSDEBUGGER=,
5090     MOZ_JSDEBUGGER=1)
5093 dnl ========================================================
5094 dnl = Enable IPDL's "expensive" unit tests
5095 dnl ========================================================
5096 MOZ_IPDL_TESTS=
5098 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
5099 [  --enable-ipdl-tests     Enable expensive IPDL tests],
5100     MOZ_IPDL_TESTS=1,
5101     MOZ_IPDL_TESTS=)
5103 if test -n "$MOZ_IPDL_TESTS"; then
5104     AC_DEFINE(MOZ_IPDL_TESTS)
5107 AC_SUBST(MOZ_IPDL_TESTS)
5109 dnl ========================================================
5110 dnl = Turns off code necessary for e10s compatibility
5111 dnl ========================================================
5112 dnl This is a temporary flag to be removed in bug 662601 when
5113 dnl it's no longer needed
5115 MOZ_E10S_COMPAT=
5117 MOZ_ARG_ENABLE_BOOL(e10s-compat,
5118 [  --enable-e10s-compat     Turns off code for e10s compat],
5119     MOZ_E10S_COMPAT=1,
5120     MOZ_E10S_COMPAT=)
5122 if test -n "$MOZ_E10S_COMPAT"; then
5123     AC_DEFINE(MOZ_E10S_COMPAT)
5126 dnl ========================================================
5127 dnl = Disable building dbm
5128 dnl ========================================================
5129 MOZ_ARG_DISABLE_BOOL(dbm,
5130 [  --disable-dbm           Disable building dbm],
5131     NSS_DISABLE_DBM=1,
5132     NSS_DISABLE_DBM=)
5134 dnl bi-directional support always on
5135 IBMBIDI=1
5136 AC_DEFINE(IBMBIDI)
5138 dnl ========================================================
5139 dnl accessibility support on by default on all platforms
5140 dnl ========================================================
5141 MOZ_ARG_DISABLE_BOOL(accessibility,
5142 [  --disable-accessibility Disable accessibility support],
5143     ACCESSIBILITY=,
5144     ACCESSIBILITY=1 )
5145 if test "$ACCESSIBILITY"; then
5146     AC_DEFINE(ACCESSIBILITY)
5149 dnl ========================================================
5150 dnl Disable printing
5151 dnl ========================================================
5152 MOZ_ARG_DISABLE_BOOL(printing,
5153 [  --disable-printing      Disable printing support],
5154     NS_PRINTING=,
5155     NS_PRINTING=1)
5157 if test "$NS_PRINTING"; then
5158     AC_DEFINE(NS_PRINTING)
5159     AC_DEFINE(NS_PRINT_PREVIEW)
5162 dnl Turn off webrtc for OS's we don't handle yet, but allow 
5163 dnl --enable-webrtc to override.  Can disable for everything in
5164 dnl the master list above.
5165 if test -n "$MOZ_WEBRTC"; then
5166     case "$target" in
5167     *-android*|*-linuxandroid*)
5168         dnl Make sure doesn't get matched by *-linux*
5169         MOZ_WEBRTC=
5170         ;;
5171     *-linux*|*-mingw*|*-darwin*)
5172         dnl Leave enabled
5173         ;;
5174     *)
5175         dnl default to disabled for all others
5176         MOZ_WEBRTC=
5177         ;;
5178     esac
5181 dnl ========================================================
5182 dnl = Disable WebRTC code
5183 dnl ========================================================
5184 MOZ_ARG_DISABLE_BOOL(webrtc,
5185 [  --disable-webrtc        Disable support for WebRTC],
5186     MOZ_WEBRTC=,
5187     MOZ_WEBRTC=1)
5189 if test -n "$MOZ_WEBRTC"; then
5190     AC_DEFINE(MOZ_WEBRTC)
5191     MOZ_MEDIA=1
5192     MOZ_RAW=1
5193     MOZ_VP8=1
5194     MOZ_VP8_ENCODER=1
5195     MOZ_VP8_ERROR_CONCEALMENT=1
5196     MOZ_SRTP=1
5197     AC_DEFINE(MOZ_SRTP)
5200 AC_SUBST(MOZ_WEBRTC)
5201 AC_SUBST(MOZ_SRTP)
5203 case "$target_cpu" in
5204 arm*)
5205     MOZ_SAMPLE_TYPE_S16=1
5206     AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
5207     AC_SUBST(MOZ_SAMPLE_TYPE_S16)
5210     MOZ_SAMPLE_TYPE_FLOAT32=1
5211     AC_DEFINE(MOZ_SAMPLE_TYPE_FLOAT32)
5212     AC_SUBST(MOZ_SAMPLE_TYPE_FLOAT32)
5214 esac
5216 dnl ========================================================
5217 dnl = Enable Raw Codecs
5218 dnl ========================================================
5219 MOZ_ARG_ENABLE_BOOL(raw,
5220 [  --enable-raw           Enable support for RAW media],
5221     MOZ_RAW=1,
5222     MOZ_RAW=)
5224 if test -n "$MOZ_RAW"; then
5225     AC_DEFINE(MOZ_RAW)
5226     MOZ_MEDIA=1
5229 AC_SUBST(MOZ_RAW)
5231 dnl ========================================================
5232 dnl = Disable Ogg Codecs
5233 dnl ========================================================
5234 MOZ_ARG_DISABLE_BOOL(ogg,
5235 [  --disable-ogg           Disable support for OGG media (Theora video and Vorbis audio)],
5236     MOZ_OGG=,
5237     MOZ_OGG=1)
5239 if test -n "$MOZ_OGG"; then
5240     AC_DEFINE(MOZ_OGG)
5241     MOZ_SYDNEYAUDIO=1
5242     MOZ_CUBEB=1
5243     MOZ_MEDIA=1
5245     dnl Checks for __attribute__(aligned()) directive
5246     AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5247         [ac_cv_c_attribute_aligned],
5248         [ac_cv_c_attribute_aligned=0
5249          CFLAGS_save="${CFLAGS}"
5250          CFLAGS="${CFLAGS} -Werror"
5251          for ac_cv_c_attr_align_try in 64 32 16 8; do
5252            echo "trying $ac_cv_c_attr_align_try"
5253            AC_TRY_COMPILE([],
5254                           [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5255                           [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5256            if test "$ac_cv_c_attribute_aligned" != 0; then
5257              break;
5258            fi
5259          done
5260            CFLAGS="${CFLAGS_save}"])
5261     if test "${ac_cv_c_attribute_aligned}" != "0"; then
5262       AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5263                          [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5264     fi
5267 dnl ========================================================
5268 dnl = Disable Opus audio codec support
5269 dnl ========================================================
5270 MOZ_ARG_DISABLE_BOOL(opus,
5271 [  --disable-opus          Disable support for Opus audio],
5272     MOZ_OPUS=,
5273     MOZ_OPUS=1)
5275 dnl ========================================================
5276 dnl = Disable VP8 decoder support
5277 dnl ========================================================
5278 MOZ_ARG_DISABLE_BOOL(webm,
5279 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
5280     MOZ_WEBM=,
5281     MOZ_WEBM=1)
5283 if test -n "$MOZ_WEBM"; then
5284     AC_DEFINE(MOZ_WEBM)
5285     MOZ_VP8=1
5288 dnl ========================================================
5289 dnl = Enable media plugin support
5290 dnl ========================================================
5291 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5292   dnl Enable support on android by default
5293   MOZ_MEDIA_PLUGINS=1
5296 MOZ_ARG_ENABLE_BOOL(media-plugins,
5297 [  --enable-media-plugins  Enable support for media plugins],
5298     MOZ_MEDIA_PLUGINS=1,
5299     MOZ_MEDIA_PLUGINS=)
5301 if test -n "$MOZ_MEDIA_PLUGINS"; then
5302   AC_DEFINE(MOZ_MEDIA_PLUGINS)
5305 dnl ========================================================
5306 dnl = Enable getUserMedia support
5307 dnl ========================================================
5308 MOZ_ARG_ENABLE_BOOL(media-navigator,
5309 [  --enable-media-navigator  Enable support for getUserMedia],
5310     MOZ_MEDIA_NAVIGATOR=1,
5311     MOZ_MEDIA_NAVIGATOR=)
5313 if test -n "$MOZ_MEDIA_NAVIGATOR"; then
5314   AC_DEFINE(MOZ_MEDIA_NAVIGATOR)
5317 dnl ========================================================
5318 dnl = Enable building OMX media plugin (B2G or Android)
5319 dnl ========================================================
5320 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5321   dnl Enable support on android by default
5322   MOZ_OMX_PLUGIN=1
5325 MOZ_ARG_ENABLE_BOOL(omx-plugin,
5326 [  --enable-omx-plugin      Enable building OMX plugin (B2G)],
5327     MOZ_OMX_PLUGIN=1,
5328     MOZ_OMX_PLUGIN=)
5330 if test -n "$MOZ_OMX_PLUGIN"; then
5331     if test "$OS_TARGET" = "Android"; then
5332         dnl Only allow building OMX plugin on Gonk (B2G) or Android
5333         AC_DEFINE(MOZ_OMX_PLUGIN)
5334     else
5335        dnl fail if we're not building on Gonk or Android
5336        AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
5337     fi
5340 dnl system libvpx Support
5341 dnl ========================================================
5342 MOZ_ARG_WITH_BOOL(system-libvpx,
5343 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
5344     MOZ_NATIVE_LIBVPX=1)
5346 MOZ_LIBVPX_CFLAGS=
5347 MOZ_LIBVPX_LIBS=
5349 if test -n "$MOZ_VP8"; then
5350     AC_DEFINE(MOZ_VP8)
5351     if test -n "$MOZ_VP8_ERROR_CONCEALMENT" ; then
5352         AC_DEFINE(MOZ_VP8_ERROR_CONCEALMENT)
5353     fi
5354     if test -n "$MOZ_VP8_ENCODER" ; then
5355         AC_DEFINE(MOZ_VP8_ENCODER)
5356     fi
5358     if test -n "$MOZ_NATIVE_LIBVPX"; then
5359         dnl ============================
5360         dnl === libvpx Version check ===
5361         dnl ============================
5362         dnl Check to see if we have a system libvpx package.
5363         PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.0.0)
5365         MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [], 
5366          [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.])])
5368         _SAVE_LIBS=$LIBS
5369         AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [], 
5370          [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
5371         LIBS=$_SAVE_LIBS
5372     fi
5375 AC_SUBST(MOZ_NATIVE_LIBVPX)
5376 AC_SUBST(MOZ_LIBVPX_CFLAGS)
5377 AC_SUBST(MOZ_LIBVPX_LIBS)
5379 if test "$MOZ_WEBM"; then
5380     MOZ_SYDNEYAUDIO=1
5381     MOZ_CUBEB=1
5382     MOZ_MEDIA=1
5383     if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then
5384         MOZ_VORBIS=1
5385     else
5386         MOZ_TREMOR=1
5387     fi
5390 if test -n "$MOZ_VP8" -a -z "$MOZ_NATIVE_LIBVPX"; then
5392     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
5393     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
5394     dnl We currently require gcc on all arm platforms.
5395     VPX_AS=$YASM
5396     VPX_ASM_SUFFIX=asm
5397     VPX_NEED_OBJ_INT_EXTRACT=
5399     dnl See if we have assembly on this platform.
5400     case "$OS_ARCH:$CPU_ARCH" in
5401     Darwin:x86)
5402       VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
5403       VPX_X86_ASM=1
5404     ;;
5405     Darwin:x86_64)
5406       VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
5407       VPX_X86_ASM=1
5408     ;;
5409     WINNT:x86_64)
5410       VPX_ASFLAGS="-f x64 -rnasm -pnasm"
5411       VPX_X86_ASM=1
5412     ;;
5413     WINNT:x86)
5414       dnl Check for yasm 1.1 or greater.
5415       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
5416         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.])
5417       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5418         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.])
5419       else
5420         VPX_ASFLAGS="-f win32 -rnasm -pnasm -DPIC"
5421         VPX_X86_ASM=1
5422         dnl The encoder needs obj_int_extract to get asm offsets.
5423       fi
5424     ;;
5425     *:arm*)
5426       if test -n "$GNU_AS" ; then
5427         VPX_AS=$AS
5428         dnl These flags are a lie; they're just used to enable the requisite
5429         dnl opcodes; actual arch detection is done at runtime.
5430         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
5431         VPX_DASH_C_FLAG="-c"
5432         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
5433         VPX_ASM_SUFFIX="$ASM_SUFFIX"
5434         VPX_ARM_ASM=1
5435       fi
5436     ;;
5437     *:x86)
5438       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5439         VPX_ASFLAGS="-f elf32 -rnasm -pnasm"
5440         VPX_X86_ASM=1
5441       fi
5442     ;;
5443     *:x86_64)
5444       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5445         VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5446         VPX_X86_ASM=1
5447       fi
5448     ;;
5449     esac
5451     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_X86_ASM" -a -z "$VPX_AS"; then
5452       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.])
5453     fi
5455     if test -n "$MOZ_VP8_ENCODER" -a \
5456             -z "$GNU_CC" -a -z "$INTEL_CC" -a -z "$CLANG_CC" ; then
5457       dnl We prefer to get asm offsets using inline assembler, which the above
5458       dnl compilers can do. When we're not using one of those, we have to fall
5459       dnl back to obj_int_extract, which reads them from a compiled object
5460       dnl file. Unfortunately, that only works if we're compiling on a system
5461       dnl with the header files for the appropriate object file format.
5462       VPX_NEED_OBJ_INT_EXTRACT=1
5463     fi
5465     if test -n "$VPX_X86_ASM"; then
5466       AC_DEFINE(VPX_X86_ASM)
5467     elif test -n "$VPX_ARM_ASM"; then
5468       AC_DEFINE(VPX_ARM_ASM)
5469     else
5470       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
5471     fi
5474 dnl ========================================================
5475 dnl = Disable Wave decoder support
5476 dnl ========================================================
5477 MOZ_ARG_DISABLE_BOOL(wave,
5478 [  --disable-wave          Disable Wave decoder support],
5479     MOZ_WAVE=,
5480     MOZ_WAVE=1)
5482 if test -n "$MOZ_WAVE"; then
5483     AC_DEFINE(MOZ_WAVE)
5484     MOZ_SYDNEYAUDIO=1
5485     MOZ_CUBEB=1
5486     MOZ_MEDIA=1
5489 dnl ========================================================
5490 dnl = Handle dependent SYDNEYAUDIO, CUBEB, and MEDIA defines
5491 dnl ========================================================
5493 if test -n "$MOZ_SYDNEYAUDIO"; then
5494     AC_DEFINE(MOZ_SYDNEYAUDIO)
5497 if test -n "$MOZ_SPEEX_RESAMPLER"; then
5498     AC_DEFINE(MOZ_SPEEX_RESAMPLER)
5501 if test -n "$MOZ_CUBEB"; then
5502     case "$target" in
5503     *-android*|*-linuxandroid*)
5504         if test -n "$gonkdir"; then
5505             AC_DEFINE(MOZ_CUBEB)
5506         fi
5507         dnl No Android implementation of libcubeb yet.
5508         ;;
5509     *-linux*)
5510         AC_DEFINE(MOZ_CUBEB)
5511         ;;
5512     *-mingw*)
5513         AC_DEFINE(MOZ_CUBEB)
5514         ;;
5515     *-darwin*)
5516         AC_DEFINE(MOZ_CUBEB)
5517         ;;
5518     *-openbsd*)
5519         AC_DEFINE(MOZ_CUBEB)
5520         ;;
5521     *)
5522         dnl Other targets will be enabled soon.
5523         ;;
5524     esac
5527 if test -n "$MOZ_MEDIA"; then
5528     AC_DEFINE(MOZ_MEDIA)
5531 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
5532     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/])
5535 if test -n "$MOZ_VORBIS"; then
5536     AC_DEFINE(MOZ_VORBIS)
5539 if test -n "$MOZ_TREMOR"; then
5540     AC_DEFINE(MOZ_TREMOR)
5543 if test -n "$MOZ_OPUS"; then
5544     AC_DEFINE(MOZ_OPUS)
5547 dnl ========================================================
5548 dnl = Check alsa availability on Linux if using sydneyaudio
5549 dnl ========================================================
5551 dnl If using sydneyaudio with Linux, ensure that the alsa library is available
5552 if test -n "$MOZ_SYDNEYAUDIO" -a "$OS_TARGET" = "Linux"; then
5553     PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5554          [echo "$MOZ_ALSA_PKG_ERRORS"
5555           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.)])])
5558 dnl ========================================================
5559 dnl = Enable PulseAudio
5560 dnl ========================================================
5562 MOZ_ARG_ENABLE_BOOL(pulseaudio,
5563 [  --enable-pulseaudio          Enable PulseAudio support (experimental)],
5564 MOZ_PULSEAUDIO=1,
5565 MOZ_PULSEAUDIO=)
5567 if test -n "$MOZ_PULSEAUDIO"; then
5568     AC_DEFINE(MOZ_CUBEB)
5569     PKG_CHECK_MODULES(MOZ_PULSEAUDIO, libpulse, ,
5570          [echo "$MOZ_PULSEAUDIO_PKG_ERRORS"
5571           AC_MSG_ERROR([pulseaudio audio backend requires libpulse package])])
5574 AC_SUBST(MOZ_PULSEAUDIO)
5575 AC_SUBST(MOZ_PULSEAUDIO_CFLAGS)
5576 AC_SUBST(MOZ_PULSEAUDIO_LIBS)
5578 dnl ========================================================
5579 dnl = Enable GStreamer
5580 dnl ========================================================
5581 MOZ_ARG_ENABLE_BOOL(gstreamer,
5582 [  --enable-gstreamer           Enable GStreamer support],
5583 MOZ_GSTREAMER=1,
5584 MOZ_GSTREAMER=)
5586 if test "$MOZ_GSTREAMER"; then
5587     # API version, eg 0.10, 1.0 etc
5588     GST_API_VERSION=0.10
5589     # core/base release number
5590     # depend on >= 0.10.33 as that's when the playbin2 source-setup signal was
5591     # introduced
5592     GST_VERSION=0.10.33
5593     PKG_CHECK_MODULES(GSTREAMER,
5594                       gstreamer-$GST_API_VERSION >= $GST_VERSION
5595                       gstreamer-app-$GST_API_VERSION
5596                       gstreamer-plugins-base-$GST_API_VERSION)
5597     if test -n "$GSTREAMER_LIBS"; then
5598        _SAVE_LDFLAGS=$LDFLAGS
5599        LDFLAGS="$LDFLAGS $GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5600        AC_TRY_LINK(,[return 0;],_HAVE_LIBGSTVIDEO=1,_HAVE_LIBGSTVIDEO=)
5601        if test -n "$_HAVE_LIBGSTVIDEO" ; then
5602           GSTREAMER_LIBS="$GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5603        else
5604           AC_MSG_ERROR([gstreamer video backend requires libgstvideo])
5605        fi
5606        LDFLAGS=$_SAVE_LDFLAGS
5607     else
5608        AC_MSG_ERROR([gstreamer backend requires the gstreamer packages])
5609     fi
5611 AC_SUBST(GSTREAMER_CFLAGS)
5612 AC_SUBST(GSTREAMER_LIBS)
5613 AC_SUBST(MOZ_GSTREAMER)
5615 if test -n "$MOZ_GSTREAMER"; then
5616    AC_DEFINE(MOZ_GSTREAMER)
5617    MOZ_MEDIA=1
5621 dnl ========================================================
5622 dnl Permissions System
5623 dnl ========================================================
5624 MOZ_ARG_DISABLE_BOOL(permissions,
5625 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5626     MOZ_PERMISSIONS=,
5627     MOZ_PERMISSIONS=1
5630 dnl ========================================================
5631 dnl NegotiateAuth
5632 dnl ========================================================
5633 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5634 [  --disable-negotiateauth Disable GSS-API negotiation ],
5635     MOZ_AUTH_EXTENSION=,
5636     MOZ_AUTH_EXTENSION=1 )
5638 dnl ========================================================
5639 dnl XTF
5640 dnl ========================================================
5641 MOZ_ARG_DISABLE_BOOL(xtf,
5642 [  --disable-xtf           Disable XTF (pluggable xml tags) support],
5643     MOZ_XTF=,
5644     MOZ_XTF=1 )
5645 if test "$MOZ_XTF"; then
5646   AC_DEFINE(MOZ_XTF)
5649 dnl ========================================================
5650 dnl Pref extensions (autoconfig)
5651 dnl ========================================================
5652 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5653 [  --disable-pref-extensions
5654                           Disable pref extensions such as autoconfig],
5655   MOZ_PREF_EXTENSIONS=,
5656   MOZ_PREF_EXTENSIONS=1 )
5658 dnl ========================================================
5659 dnl Searching of system directories for extensions.
5660 dnl Note: this switch is meant to be used for test builds
5661 dnl whose behavior should not depend on what happens to be
5662 dnl installed on the local machine.
5663 dnl ========================================================
5664 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
5665 [  --disable-system-extension-dirs
5666                           Disable searching system- and account-global
5667                           directories for extensions of any kind; use
5668                           only profile-specific extension directories],
5669   ENABLE_SYSTEM_EXTENSION_DIRS=,
5670   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
5671 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
5672   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
5675 dnl ========================================================
5676 dnl = Universalchardet
5677 dnl ========================================================
5678 MOZ_ARG_DISABLE_BOOL(universalchardet,
5679 [  --disable-universalchardet
5680                           Disable universal encoding detection],
5681   MOZ_UNIVERSALCHARDET=,
5682   MOZ_UNIVERSALCHARDET=1 )
5684 if test -n "${JAVA_BIN_PATH}"; then
5685   dnl Look for javac and jar in the specified path.
5686   JAVA_PATH="$JAVA_BIN_PATH"
5687 else
5688   dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5689   JAVA_PATH="$JAVA_HOME/bin:$PATH"
5692 MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5693 MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5694 MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5696 if test -n "${JAVA_BIN_PATH}" -o \
5697   \( "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk" \); then
5698   if test -z "$JAVA" -o "$JAVA" = ":" -o -z "$JAVAC" -o "$JAVAC" = ":" -o -z "$JAR" -o "$JAR" = ":"; then
5699     AC_MSG_ERROR([The programs java, javac and jar were not found.  Set \$JAVA_HOME to your java sdk directory or use --with-java-bin-path={java-bin-dir}])
5700   fi
5703 dnl ========================================================
5704 dnl = ANGLE OpenGL->D3D translator for WebGL
5705 dnl = * only applies to win32
5706 dnl = * enabled by default (shipping build); requires explicit --disable to disable
5707 dnl ========================================================
5708 MOZ_ANGLE_RENDERER=
5709 MOZ_DIRECTX_SDK_PATH=
5710 MOZ_DIRECTX_SDK_CPU_SUFFIX=
5711 MOZ_D3DX9_VERSION=
5712 MOZ_D3DX9_CAB=
5713 MOZ_D3DCOMPILER_CAB=
5714 MOZ_D3DX9_DLL=
5715 MOZ_D3DCOMPILER_DLL=
5716 case "$target_os" in
5717 *mingw*)
5718     MOZ_ANGLE_RENDERER=1
5719     ;;
5720 esac
5722 # The DirectX SDK libraries are split into x86 and x64 sub-directories
5723 case "${target_cpu}" in
5724 i*86)
5725   MOZ_DIRECTX_SDK_CPU_SUFFIX=x86
5726   ;;
5727 x86_64)
5728   MOZ_DIRECTX_SDK_CPU_SUFFIX=x64
5729   ;;
5730 esac
5732 MOZ_ARG_DISABLE_BOOL(webgl,
5733 [  --disable-webgl     Disable building of the WebGL implementation],
5734     MOZ_WEBGL_DISABLED=1,
5735     MOZ_WEBGL_DISABLED=)
5737 if test -n "$MOZ_WEBGL_DISABLED"; then
5738   MOZ_WEBGL=
5739   MOZ_ANGLE_RENDERER=
5742 if test -n "$MOZ_ANGLE_RENDERER" -a -z "$CROSS_COMPILE"; then
5743   # Get the SDK path from the registry.
5744   # First try to get the June 2010 SDK
5745   MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK (June 2010)' | head -n 1`
5746   if test -z "$MOZ_DIRECTX_SDK_REG_KEY" ; then
5747     # Otherwise just take whatever comes first
5748     MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK' | head -n 1`
5749   fi
5751   if test -n "`echo $MOZ_DIRECTX_SDK_REG_KEY | grep 'February 2010'`" ; then
5752     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.])
5753   else
5754     MOZ_DIRECTX_SDK_PATH=`reg query "$MOZ_DIRECTX_SDK_REG_KEY" //v InstallPath | grep REG_SZ | sed 's/.*\([[a-zA-Z]]\)\\:\\\\/\\1\\:\\\\/'`
5755   fi
5757   if test -n "$MOZ_DIRECTX_SDK_PATH" &&
5758      test -f "$MOZ_DIRECTX_SDK_PATH"/include/d3dx9.h &&
5759          test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5760     AC_MSG_RESULT([Found DirectX SDK via registry, using $MOZ_DIRECTX_SDK_PATH])
5761   else
5762     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.])
5763   fi
5765   # Get the SDK numeric version (e.g. 43) by looking at the dependencies of d3dx9.lib
5766   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'`
5768   if test -z "$MOZ_D3DX9_VERSION" ; then
5769         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.])
5770   fi
5772   MOZ_D3DX9_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *d3dx9_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
5773   MOZ_D3DCOMPILER_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *D3DCompiler_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
5775   if test -z "$MOZ_D3DX9_CAB" -o -z "$MOZ_D3DCOMPILER_CAB"; then
5776     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.])
5777   fi
5779   MOZ_D3DX9_DLL=d3dx9_$MOZ_D3DX9_VERSION.dll
5780   MOZ_D3DCOMPILER_DLL=D3DCompiler_$MOZ_D3DX9_VERSION.dll
5783 dnl ========================================================
5784 dnl = Breakpad crash reporting (on by default on supported platforms)
5785 dnl ========================================================
5787 case $target in
5788 i?86-*-mingw*|x86_64-*-mingw*)
5789   MOZ_CRASHREPORTER=1
5790   ;;
5791 i?86-apple-darwin*|x86_64-apple-darwin*)
5792   MOZ_CRASHREPORTER=1
5793   ;;
5794 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
5795   if test "$MOZ_ENABLE_GTK2"; then
5796     MOZ_CRASHREPORTER=1
5797   fi
5798   ;;
5799 *-android*|*-linuxandroid*)
5800   MOZ_CRASHREPORTER=1
5801   ;;
5802 *solaris*)
5803   MOZ_CRASHREPORTER=1
5804   ;;
5805 esac
5807 MOZ_ARG_DISABLE_BOOL(crashreporter,
5808 [  --disable-crashreporter Disable breakpad crash reporting],
5809     MOZ_CRASHREPORTER=,
5810     MOZ_CRASHREPORTER=1)
5812 if test -n "$MOZ_CRASHREPORTER"; then
5813    AC_DEFINE(MOZ_CRASHREPORTER)
5815   if test "$OS_TARGET" = "Linux" -o "$OS_ARCH" = "SunOS" && \
5816     test -z "$SKIP_LIBRARY_CHECKS"; then
5817     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
5818     AC_SUBST(MOZ_GTHREAD_CFLAGS)
5819     AC_SUBST(MOZ_GTHREAD_LIBS)
5821     MOZ_CHECK_HEADERS([curl/curl.h], [], [AC_MSG_ERROR([Couldn't find curl/curl.h which is required for the crash reporter.  Use --disable-crashreporter to disable the crash reporter.])])
5822   fi
5824   if test "$OS_ARCH" != "$HOST_OS_ARCH"; then
5825     AC_MSG_ERROR([Breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.  Use --disable-crashreporter.])
5826   fi
5828   if test "$OS_ARCH" = "WINNT" -a -z "$HAVE_64BIT_OS"; then
5829     MOZ_CRASHREPORTER_INJECTOR=1
5830     AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
5831   fi
5834 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
5835 [  --with-crashreporter-enable-percent=NN
5836                           Enable sending crash reports by default on NN% of users. (default=100)],
5837 [ val=`echo $withval | sed 's/[^0-9]//g'`
5838     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
5840 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
5841    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
5843 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
5845 dnl ========================================================
5846 dnl = libjpeg-turbo configuration
5847 dnl ========================================================
5848 MOZ_LIBJPEG_TURBO=
5849 if test -z "$MOZ_NATIVE_JPEG"; then
5850     MOZ_LIBJPEG_TURBO=1
5853 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
5854 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
5855     MOZ_LIBJPEG_TURBO=,
5856     MOZ_LIBJPEG_TURBO=1)
5858 if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
5859     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
5862 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
5863 dnl files.
5865 if test -n "$MOZ_LIBJPEG_TURBO"; then
5867   dnl Do we support libjpeg-turbo on this platform?
5868   case "$OS_ARCH:$OS_TEST" in
5869   Darwin:i?86)
5870     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
5871     LIBJPEG_TURBO_X86_ASM=1
5872   ;;
5873   Darwin:x86_64)
5874     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
5875     LIBJPEG_TURBO_X64_ASM=1
5876   ;;
5877   WINNT:x86|WINNT:i?86)
5878     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
5879     LIBJPEG_TURBO_X86_ASM=1
5880   ;;
5881   WINNT:x86_64)
5882     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
5883     LIBJPEG_TURBO_X64_ASM=1
5884   ;;
5885   *:arm*)
5886     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
5887     LIBJPEG_TURBO_ARM_ASM=1
5888   ;;
5889   *:x86|*:i?86)
5890     if $CC -E -dM -</dev/null | grep -q __ELF__; then
5891       LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
5892       LIBJPEG_TURBO_X86_ASM=1
5893     fi
5894   ;;
5895   *:x86_64)
5896     if $CC -E -dM -</dev/null | grep -q __ELF__; then
5897       LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
5898       LIBJPEG_TURBO_X64_ASM=1
5899     fi
5900   ;;
5901   esac
5905 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
5906 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
5907 dnl it doesn't exist or we have too old of a version.
5908 if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
5909     AC_MSG_CHECKING([for Yasm assembler])
5910     AC_CHECK_PROGS(LIBJPEG_TURBO_AS, yasm, "")
5912     if test -z "$LIBJPEG_TURBO_AS" ; then
5913         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.])
5914     fi
5916     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
5917     dnl on Linux and 1.1 or newer everywhere else.
5918     if test "$OS_ARCH" = "Linux" ; then
5919         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
5920             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.])
5921         fi
5922     else
5923         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5924             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.])
5925         fi
5926     fi
5929 dnl If we're on an ARM system which supports libjpeg-turbo's asm routines and
5930 dnl --disable-libjpeg-turbo wasn't passed, use the C compiler as the assembler.
5931 if test -n "$LIBJPEG_TURBO_ARM_ASM" ; then
5932     echo "Using $AS as the assembler for ARM code."
5933     LIBJPEG_TURBO_AS=$AS
5936 if test -n "$LIBJPEG_TURBO_X86_ASM"; then
5937     AC_DEFINE(LIBJPEG_TURBO_X86_ASM)
5938 elif test -n "$LIBJPEG_TURBO_X64_ASM"; then
5939     AC_DEFINE(LIBJPEG_TURBO_X64_ASM)
5940 elif test -n "$LIBJPEG_TURBO_ARM_ASM"; then
5941     AC_DEFINE(LIBJPEG_TURBO_ARM_ASM)
5942 elif test -n "$MOZ_LIBJPEG_TURBO"; then
5943     dnl Warn if we're not building the optimized routines, even though the user
5944     dnl didn't specify --disable-libjpeg-turbo.
5945     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
5948 dnl ========================================================
5949 dnl = Enable compilation of specific extension modules
5950 dnl ========================================================
5952 MOZ_ARG_ENABLE_STRING(extensions,
5953 [  --enable-extensions     Enable extensions],
5954 [ for option in `echo $enableval | sed 's/,/ /g'`; do
5955     if test "$option" = "yes" -o "$option" = "all"; then
5956         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
5957     elif test "$option" = "no" -o "$option" = "none"; then
5958         MOZ_EXTENSIONS=""
5959     elif test "$option" = "default"; then
5960         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
5961     elif test `echo "$option" | grep -c \^-` != 0; then
5962         option=`echo $option | sed 's/^-//'`
5963         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
5964     else
5965         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
5966     fi
5967 done],
5968     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
5970 if test -z "$MOZ_ENABLE_GNOMEVFS" -a -z "$MOZ_GNOMEVFS_LIBS" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
5971     # Suppress warning on non-X11 platforms
5972     if test -n "$MOZ_X11"; then
5973         AC_MSG_WARN([Cannot build gnomevfs without required libraries. Removing gnomevfs from MOZ_EXTENSIONS.])
5974     fi
5975     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
5978 dnl Do not build gnomevfs with libxul based apps
5979 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
5980     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
5983 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
5984     # Suppress warning on non-X11 platforms
5985     if test -n "$MOZ_X11"; then
5986         AC_MSG_WARN([Cannot build gio without required libraries. Removing gio from MOZ_EXTENSIONS.])
5987     fi
5988     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
5991 dnl Do not build gio with libxul based apps
5992 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
5993     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
5996 if test -z "$MOZ_JSDEBUGGER" -a `echo "$MOZ_EXTENSIONS" | grep -c venkman` -ne 0; then
5997     AC_MSG_WARN([Cannot build venkman without JavaScript debug library. Removing venkman from MOZ_EXTENSIONS.])
5998     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|venkman||'`
6001 dnl xforms requires xtf
6002 if test -z "$MOZ_XTF" -a `echo "$MOZ_EXTENSIONS" | grep -c xforms` -ne 0; then
6003     AC_MSG_WARN([Cannot build XForms without XTF support.  Removing XForms from MOZ_EXTENSIONS.])
6004     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|xforms||g'`
6007 dnl Remove dupes
6008 MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
6010 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6011 dnl when trying to build a nonexistent extension.
6012 for extension in $MOZ_EXTENSIONS; do
6013     if test ! -d "${srcdir}/extensions/${extension}"; then
6014         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6015     fi
6016 done
6018 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
6019   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
6022 dnl ========================================================
6023 dnl CSS3 Flexbox Support
6024 dnl ========================================================
6025 if test -n "$MOZ_FLEXBOX"; then
6026   AC_DEFINE(MOZ_FLEXBOX)
6029 dnl ========================================================
6030 dnl Build Freetype in the tree
6031 dnl ========================================================
6032 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6033 [  --enable-tree-freetype  Enable Tree FreeType],
6034     MOZ_TREE_FREETYPE=1,
6035     MOZ_TREE_FREETYPE= )
6036 if test -n "$MOZ_TREE_FREETYPE"; then
6037    if test -n "$_WIN32_MSVC"; then
6038       AC_ERROR("building with in-tree freetype is not supported on MSVC")
6039    fi
6040    AC_DEFINE(MOZ_TREE_FREETYPE)
6041    AC_SUBST(MOZ_TREE_FREETYPE)
6042    MOZ_ENABLE_CAIRO_FT=1
6043    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6044    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6045    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6046    FT2_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6047    CAIRO_FT_OSLIBS=''
6048    CAIRO_FT_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6049    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6050    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6051    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6052    AC_SUBST(CAIRO_FT_CFLAGS)
6055 dnl ========================================================
6056 dnl Installer
6057 dnl ========================================================
6058 dnl Abort Windows build if the required major version and
6059 dnl minimum minor version of Unicode NSIS isn't in the path
6060 dnl (unless in case of cross compiling, for which Unicode
6061 dnl is not yet sufficient).
6062 if test "$OS_ARCH" = "WINNT"; then
6063     REQ_NSIS_MAJOR_VER=2
6064     MIN_NSIS_MINOR_VER=33
6065     MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensisu-2.46 makensisu makensis)
6066     if test -n "$MAKENSISU" -a "$MAKENSISU" != ":"; then
6067       AC_MSG_RESULT([yes])
6068       changequote(,)
6069       MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\)\-Unicode$/\1/g'`
6070       changequote([,])
6071       if test ! "$MAKENSISU_VER" = ""; then
6072           MAKENSISU_MAJOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $1 }'`
6073           MAKENSISU_MINOR_VER=`echo $MAKENSISU_VER | $AWK -F\. '{ print $2 }'`
6074       fi
6075       AC_MSG_CHECKING([for Unicode NSIS with major version == $REQ_NSIS_MAJOR_VER and minor version >= $MIN_NSIS_MINOR_VER])
6076       if test "$MAKENSISU_VER" = "" || \
6077          test ! "$MAKENSISU_MAJOR_VER" = "$REQ_NSIS_MAJOR_VER" -o \
6078               ! "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER; then
6079           AC_MSG_RESULT([no])
6080           if test -z "$CROSS_COMPILE"; then
6081             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.])
6082           else
6083             MAKENSISU=
6084           fi
6085       fi
6086     elif test -z "$CROSS_COMPILE"; then
6087       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.])
6088     else
6089       MAKENSISU=
6090     fi
6093 dnl ========================================================
6094 dnl Web App Runtime
6095 dnl ========================================================
6096 MOZ_ARG_DISABLE_BOOL(webapp-runtime,
6097 [  --disable-webapp-runtime  Disable Web App Runtime],
6098     MOZ_WEBAPP_RUNTIME=,
6099     MOZ_WEBAPP_RUNTIME=1)
6100 if test "$MOZ_WIDGET_TOOLKIT" != "windows" -a "$MOZ_WIDGET_TOOLKIT" != "cocoa" -a "$MOZ_WIDGET_TOOLKIT" != "gtk2"; then
6101     MOZ_WEBAPP_RUNTIME=
6103 if test "$OS_ARCH" = "WINNT" -a -z "$MAKENSISU" -a -n "$CROSS_COMPILE"; then
6104     MOZ_WEBAPP_RUNTIME=
6106 AC_SUBST(MOZ_WEBAPP_RUNTIME)
6107 if test "$MOZ_WEBAPP_RUNTIME"; then
6108     AC_DEFINE(MOZ_WEBAPP_RUNTIME)
6111 AC_MSG_CHECKING([for tar archiver])
6112 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6113 if test -z "$TAR"; then
6114     AC_MSG_ERROR([no tar archiver found in \$PATH])
6116 AC_MSG_RESULT([$TAR])
6117 AC_SUBST(TAR)
6119 AC_MSG_CHECKING([for wget])
6120 AC_CHECK_PROGS(WGET, wget, "")
6121 AC_MSG_RESULT([$WGET])
6122 AC_SUBST(WGET)
6124 dnl ========================================================
6125 dnl Signing
6126 dnl ========================================================
6128 if test -n "$MOZ_SIGN_CMD"; then
6129     AC_DEFINE(MOZ_SIGNING)
6132 dnl ========================================================
6133 dnl Maintenance Service
6134 dnl ========================================================
6136 MOZ_ARG_ENABLE_BOOL(maintenance-service,
6137 [  --enable-maintenance-service       Enable building of maintenanceservice],
6138     MOZ_MAINTENANCE_SERVICE=1,
6139     MOZ_MAINTENANCE_SERVICE= )
6141 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
6142   if test "$OS_ARCH" = "WINNT"; then
6143     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
6144   else
6145     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
6146   fi
6149 dnl ========================================================
6150 dnl Verify MAR signatures
6151 dnl ========================================================
6153 MOZ_ARG_ENABLE_BOOL(verify-mar,
6154 [  --enable-verify-mar     Enable verifying MAR signatures],
6155     MOZ_VERIFY_MAR_SIGNATURE=1,
6156     MOZ_VERIFY_MAR_SIGNATURE= )
6158 if test -n "$MOZ_VERIFY_MAR_SIGNATURE"; then
6159   if test "$OS_ARCH" = "WINNT"; then
6160     AC_DEFINE(MOZ_VERIFY_MAR_SIGNATURE)
6161   else
6162     AC_MSG_ERROR([Can only build with --enable-verify-mar with a Windows target])
6163   fi
6166 dnl ========================================================
6167 dnl Enable building the signmar program.
6168 dnl This option is much different than the --enable-verify-mar option.
6169 dnl --enable-verify-mar is for enabling the verification check on MAR
6170 dnl files in the updater.  The --enable-signmar option is for building
6171 dnl the signmar program.
6172 dnl ========================================================
6174 MOZ_ARG_ENABLE_BOOL(signmar,
6175 [  --enable-signmar     Enable building the signmar program],
6176     MOZ_ENABLE_SIGNMAR=1,
6177     MOZ_ENABLE_SIGNMAR= )
6179 if test -n "$MOZ_ENABLE_SIGNMAR"; then
6180   AC_DEFINE(MOZ_ENABLE_SIGNMAR)
6183 dnl ========================================================
6184 dnl Updater
6185 dnl ========================================================
6187 MOZ_ARG_DISABLE_BOOL(updater,
6188 [  --disable-updater       Disable building of updater],
6189     MOZ_UPDATER=,
6190     MOZ_UPDATER=1 )
6192 if test -n "$MOZ_UPDATER"; then
6193     AC_DEFINE(MOZ_UPDATER)
6196 # app update channel is 'default' when not supplied.
6197 MOZ_ARG_ENABLE_STRING([update-channel],
6198 [  --enable-update-channel=CHANNEL
6199                           Select application update channel (default=default)],
6200     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
6202 if test -z "$MOZ_UPDATE_CHANNEL"; then
6203     MOZ_UPDATE_CHANNEL=default
6205 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
6206 AC_SUBST(MOZ_UPDATE_CHANNEL)
6208 # tools/update-packaging is not checked out by default.
6209 MOZ_ARG_ENABLE_BOOL(update-packaging,
6210 [  --enable-update-packaging
6211                           Enable tools/update-packaging],
6212     MOZ_UPDATE_PACKAGING=1,
6213     MOZ_UPDATE_PACKAGING= )
6214 AC_SUBST(MOZ_UPDATE_PACKAGING)
6216 dnl ========================================================
6217 dnl build the tests by default
6218 dnl ========================================================
6219 MOZ_ARG_DISABLE_BOOL(tests,
6220 [  --disable-tests         Do not build test libraries & programs],
6221     ENABLE_TESTS=,
6222     ENABLE_TESTS=1 )
6224 dnl ========================================================
6225 dnl parental controls (for Windows Vista)
6226 dnl ========================================================
6227 MOZ_ARG_DISABLE_BOOL(parental-controls,
6228 [  --disable-parental-controls
6229                           Do not build parental controls],
6230    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6231    MOZ_DISABLE_PARENTAL_CONTROLS=)
6232 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6233     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6236 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6238 dnl ========================================================
6239 dnl = Disable DOMCrypto
6240 dnl ========================================================
6241 if test -n "$MOZ_DISABLE_DOMCRYPTO"; then
6242     AC_DEFINE(MOZ_DISABLE_DOMCRYPTO)
6245 dnl ========================================================
6246 dnl =
6247 dnl = Module specific options
6248 dnl =
6249 dnl ========================================================
6250 MOZ_ARG_HEADER(Individual module options)
6252 dnl ========================================================
6253 dnl = Disable feed handling components
6254 dnl ========================================================
6255 MOZ_ARG_DISABLE_BOOL(feeds,
6256 [  --disable-feeds         Disable feed handling and processing components],
6257     MOZ_FEEDS=,
6258     MOZ_FEEDS=1 )
6259 if test -n "$MOZ_FEEDS"; then
6260     AC_DEFINE(MOZ_FEEDS)
6261 else
6262     if test "$MOZ_BUILD_APP" = "browser"; then
6263         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6264     fi
6267 dnl ========================================================
6268 dnl Check for sqlite
6269 dnl ========================================================
6271 MOZ_NATIVE_SQLITE=
6272 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6273 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6274 MOZ_NATIVE_SQLITE=1,
6275 MOZ_NATIVE_SQLITE= )
6277 if test -z "$MOZ_NATIVE_SQLITE"
6278 then
6279     SQLITE_CFLAGS=
6280     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
6281 else
6282     dnl ============================
6283     dnl === SQLite Version check ===
6284     dnl ============================
6285     dnl Check to see if the system SQLite package is new enough.
6286     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6288     dnl ==================================
6289     dnl === SQLITE_SECURE_DELETE check ===
6290     dnl ==================================
6291     dnl Check to see if the system SQLite package is compiled with
6292     dnl SQLITE_SECURE_DELETE enabled.
6293     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
6294     _SAVE_CFLAGS="$CFLAGS"
6295     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6296     _SAVE_LIBS="$LIBS"
6297     LIBS="$LIBS $SQLITE_LIBS"
6298     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6299         AC_TRY_RUN([
6300             #include "sqlite3.h"
6302             int main(int argc, char **argv){
6303               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
6304             }],
6305             ac_cv_sqlite_secure_delete=yes,
6306             ac_cv_sqlite_secure_delete=no,
6307             ac_cv_sqlite_secure_delete=no
6308         )
6309     ])
6310     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6311     CFLAGS="$_SAVE_CFLAGS"
6312     LIBS="$_SAVE_LIBS"
6313     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6314         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
6315     fi
6317     dnl ===============================
6318     dnl === SQLITE_THREADSAFE check ===
6319     dnl ===============================
6320     dnl Check to see if the system SQLite package is compiled with
6321     dnl SQLITE_THREADSAFE enabled.
6322     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
6323     _SAVE_CFLAGS="$CFLAGS"
6324     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6325     _SAVE_LIBS="$LIBS"
6326     LIBS="$LIBS $SQLITE_LIBS"
6327     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
6328         AC_TRY_RUN([
6329             #include "sqlite3.h"
6331             int main(int argc, char **argv){
6332               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
6333             }],
6334             ac_cv_sqlite_threadsafe=yes,
6335             ac_cv_sqlite_threadsafe=no,
6336             ac_cv_sqlite_threadsafe=no
6337         )
6338     ])
6339     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
6340     CFLAGS="$_SAVE_CFLAGS"
6341     LIBS="$_SAVE_LIBS"
6342     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
6343         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
6344     fi
6346     dnl ================================
6347     dnl === SQLITE_ENABLE_FTS3 check ===
6348     dnl ================================
6349     dnl check to see if the system SQLite package is compiled with
6350     dnl SQLITE_ENABLE_FTS3 enabled.
6351     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
6352     _SAVE_CFLAGS="$CFLAGS"
6353     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6354     _SAVE_LIBS="$LIBS"
6355     LIBS="$LIBS $SQLITE_LIBS"
6356     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
6357         AC_TRY_RUN([
6358             #include "sqlite3.h"
6360             int main(int argc, char **argv){
6361               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
6362             }],
6363             ac_cv_sqlite_enable_fts3=yes,
6364             ac_cv_sqlite_enable_fts3=no,
6365             ac_cv_sqlite_enable_fts3=no
6366         )
6367     ])
6368     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
6369     CFLAGS="$_SAVE_CFLAGS"
6370     LIBS="$_SAVE_LIBS"
6371     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
6372         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
6373     fi
6375     dnl =========================================
6376     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
6377     dnl =========================================
6378     dnl check to see if the system SQLite package is compiled with
6379     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
6380     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
6381     _SAVE_CFLAGS="$CFLAGS"
6382     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6383     _SAVE_LIBS="$LIBS"
6384     LIBS="$LIBS $SQLITE_LIBS"
6385     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
6386         AC_TRY_RUN([
6387             #include "sqlite3.h"
6389             int main(int argc, char **argv){
6390               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
6391             }],
6392             ac_cv_sqlite_enable_unlock_notify=yes,
6393             ac_cv_sqlite_enable_unlock_notify=no,
6394             ac_cv_sqlite_enable_unlock_notify=no
6395         )
6396     ])
6397     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
6398     CFLAGS="$_SAVE_CFLAGS"
6399     LIBS="$_SAVE_LIBS"
6400     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
6401         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
6402     fi
6405 if test -n "$MOZ_NATIVE_SQLITE"; then
6406     AC_DEFINE(MOZ_NATIVE_SQLITE)
6408 AC_SUBST(MOZ_NATIVE_SQLITE)
6410 dnl ========================================================
6411 dnl = Enable help viewer (off by default)
6412 dnl ========================================================
6413 if test -n "$MOZ_HELP_VIEWER"; then
6414      dnl Do this if defined in confvars.sh
6415      AC_DEFINE(MOZ_HELP_VIEWER)
6418 dnl ========================================================
6419 dnl = Enable safe browsing (anti-phishing)
6420 dnl ========================================================
6421 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6422 [  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation],
6423     MOZ_SAFE_BROWSING=1,
6424     MOZ_SAFE_BROWSING= )
6425 if test -n "$MOZ_SAFE_BROWSING"; then
6426     AC_DEFINE(MOZ_SAFE_BROWSING)
6428 AC_SUBST(MOZ_SAFE_BROWSING)
6430 dnl ========================================================
6431 dnl = Enable url-classifier
6432 dnl ========================================================
6433 dnl Implicitly enabled by default if building with safe-browsing
6434 if test -n "$MOZ_SAFE_BROWSING"; then
6435     MOZ_URL_CLASSIFIER=1
6437 MOZ_ARG_ENABLE_BOOL(url-classifier,
6438 [  --enable-url-classifier Enable url classifier module],
6439     MOZ_URL_CLASSIFIER=1,
6440     MOZ_URL_CLASSIFIER= )
6441 if test -n "$MOZ_URL_CLASSIFIER"; then
6442     AC_DEFINE(MOZ_URL_CLASSIFIER)
6444 AC_SUBST(MOZ_URL_CLASSIFIER)
6446 dnl ========================================================
6447 dnl = Disable zipwriter
6448 dnl ========================================================
6449 MOZ_ARG_DISABLE_BOOL(zipwriter,
6450 [  --disable-zipwriter     Disable zipwriter component],
6451     MOZ_ZIPWRITER=,
6452     MOZ_ZIPWRITER=1 )
6453 AC_SUBST(MOZ_ZIPWRITER)
6455 dnl ========================================================
6456 dnl = libconic
6457 dnl ========================================================
6458 dnl superseded by QtNetwork starting from 4.7
6459 MOZ_ENABLE_LIBCONIC=1
6461 if test -n "$MOZ_ENABLE_QT"; then
6462   if test "$MOZ_ENABLE_QTNETWORK"; then
6463     MOZ_ENABLE_LIBCONIC=
6464   fi
6467 MOZ_ARG_DISABLE_BOOL(libconic,
6468 [  --disable-libconic      Disable libconic],
6469     MOZ_ENABLE_LIBCONIC=,
6470     MOZ_ENABLE_LIBCONIC=1 )
6472 if test -n "$MOZ_ENABLE_LIBCONIC"; then
6473     PKG_CHECK_MODULES(LIBCONIC, conic,
6474                       MOZ_ENABLE_LIBCONIC=1,
6475                       MOZ_ENABLE_LIBCONIC=)
6477 if test "$MOZ_ENABLE_LIBCONIC"; then
6478     AC_DEFINE(MOZ_ENABLE_LIBCONIC)
6481 AC_SUBST(MOZ_ENABLE_LIBCONIC)
6482 AC_SUBST(LIBCONIC_CFLAGS)
6483 AC_SUBST(LIBCONIC_LIBS)
6485 dnl ========================================================
6486 dnl = Maemo checks
6487 dnl ========================================================
6489 MAEMO_SDK_TARGET_VER=-1
6491 MOZ_ARG_WITH_STRING(maemo-version,
6492 [  --with-maemo-version=MAEMO_SDK_TARGET_VER
6493                           Maemo SDK Version],
6494   MAEMO_SDK_TARGET_VER=$withval)
6496 case "$MAEMO_SDK_TARGET_VER" in
6498     MOZ_PLATFORM_MAEMO=5
6499     ;;
6502     MOZ_PLATFORM_MAEMO=6
6503     ;;
6506     dnl We aren't compiling for Maemo, move on.
6507     ;;
6509     AC_MSG_ERROR([Unknown Maemo Version.  Try setting --with-maemo-version to 5 or 6.])
6510     ;;
6511 esac
6513 if test $MOZ_PLATFORM_MAEMO; then
6514    AC_DEFINE_UNQUOTED([MOZ_PLATFORM_MAEMO], $MOZ_PLATFORM_MAEMO)
6516    if test -z "$MOZ_ENABLE_DBUS"; then
6517        AC_MSG_ERROR([DBus is required when building for Maemo])
6518    fi
6520    MOZ_GFX_OPTIMIZE_MOBILE=1
6521    MOZ_GL_DEFAULT_PROVIDER=EGL
6522    MOZ_MAEMO_LIBLOCATION=
6524    if test $MOZ_PLATFORM_MAEMO = 5; then
6525       dnl if we have Xcomposite we should also have Xdamage and Xfixes
6526       MOZ_CHECK_HEADERS([X11/extensions/Xdamage.h], [],
6527           [AC_MSG_ERROR([Couldn't find X11/extensions/Xdamage.h which is required for composited plugins.])])
6528       AC_CHECK_LIB(Xcomposite, XCompositeRedirectWindow, [XCOMPOSITE_LIBS="-lXcomposite -lXdamage -lXfixes"],
6529                    [MISSING_X="$MISSING_X -lXcomposite"], $XLIBS)
6531       AC_SUBST(XCOMPOSITE_LIBS)
6533       PKG_CHECK_MODULES(LIBHILDONMIME,libhildonmime, _LIB_FOUND=1, _LIB_FOUND=)
6534       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONMIME_LIBS"
6535       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONMIME_CFLAGS"
6536       if test -z "$_LIB_FOUND"; then
6537          AC_MSG_ERROR([Hildon Mime is required when building for Maemo])
6538       fi
6541       PKG_CHECK_MODULES(LIBOSSO,libosso, _LIB_FOUND=1, _LIB_FOUND=)
6542       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBOSSO_LIBS"
6543       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBOSSO_CFLAGS"
6544       if test -z "$_LIB_FOUND"; then
6545          AC_MSG_ERROR([LibOSSO is required when building for Maemo])
6546       fi
6548       PKG_CHECK_MODULES(LIBHILDONFM,hildon-fm-2, _LIB_FOUND=1, _LIB_FOUND=)
6549       MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBHILDONFM_LIBS"
6550       MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBHILDONFM_CFLAGS"
6551       if test -z "$_LIB_FOUND"; then
6552          AC_MSG_ERROR([Hildon FM-2 is required when building for Maemo])
6553       fi
6555    fi
6556    if test $MOZ_PLATFORM_MAEMO = 6; then
6558       PKG_CHECK_MODULES(LIBCONTENTMANAGER, ContentManager QtSparql,
6559                         _LIB_FOUND=1,
6560                         _LIB_FOUND=)
6561       if test "$_LIB_FOUND"; then
6562          MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTMANAGER_LIBS"
6563          MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTMANAGER_CFLAGS"
6564          MOZ_ENABLE_CONTENTMANAGER=1
6565          AC_DEFINE(MOZ_ENABLE_CONTENTMANAGER)
6566       else
6567          AC_MSG_WARN([Cannot find libcontentmanager and or QtSparql building for Maemo 6])
6568       fi
6569       AC_SUBST(MOZ_ENABLE_CONTENTMANAGER)
6571       dnl ========================================================
6572       dnl = Enable meego libcontentaction
6573       dnl ========================================================
6574       MOZ_ARG_ENABLE_BOOL(meegocontentaction,
6575       [  --enable-meegocontentaction           Enable meegocontentaction support],
6576          MOZ_MEEGOCONTENTACTION=1,
6577          MOZ_MEEGOCONTENTACTION=)
6579       if test -n "$MOZ_MEEGOCONTENTACTION"; then
6581          PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
6582          if test "$_LIB_FOUND"; then
6583             MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBCONTENTACTION_LIBS"
6584             MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBCONTENTACTION_CFLAGS"
6585             MOZ_ENABLE_CONTENTACTION=1
6586             AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
6587             AC_SUBST(MOZ_ENABLE_CONTENTACTION)
6588          fi
6589       fi
6591       MOZ_ARG_ENABLE_BOOL(meegotouch,
6592       [  --enable-meegotouch  Enable meegotouch support],
6593          MOZ_MEEGOTOUCHENABLED=1,
6594          MOZ_MEEGOTOUCHENABLED=)
6596       if test -n "$MOZ_MEEGOTOUCHENABLED"; then
6597           PKG_CHECK_MODULES(MOZ_MEEGOTOUCH, meegotouchcore, _LIB_FOUND=1, _LIB_FOUND=)
6598           if test "$_LIB_FOUND"; then
6599               MOZ_QT_CFLAGS="$MOZ_MEEGOTOUCH_CFLAGS $MOZ_QT_CFLAGS"
6600               MOZ_QT_LIBS="$MOZ_MEEGOTOUCH_LIBS $MOZ_QT_LIBS"
6601               AC_DEFINE(MOZ_ENABLE_MEEGOTOUCH)
6602           else
6603               AC_MSG_WARN([Cannot meegotouchcore-dev. Disabling Meegotouch support.])
6604           fi
6605       fi
6606    fi
6608    PKG_CHECK_MODULES(LIBLOCATION,liblocation, _LIB_FOUND=1, _LIB_FOUND=)
6609    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBLOCATION_LIBS"
6610    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBLOCATION_CFLAGS"
6611    if test "$_LIB_FOUND"; then
6612       MOZ_MAEMO_LIBLOCATION=1
6613       AC_DEFINE(MOZ_MAEMO_LIBLOCATION)
6614    else
6615       AC_MSG_WARN([Cannot liblocation-dev. Disabling Maemo geolocation.])
6616    fi
6617    AC_SUBST(MOZ_MAEMO_LIBLOCATION)
6619    PKG_CHECK_MODULES(LIBMEEGOTOUCHSHARE, ShareUiInterface-maemo-meegotouch >= 0.3.31 mdatauri, _LIB_FOUND=1, _LIB_FOUND=)
6620    MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBMEEGOTOUCHSHARE_LIBS"
6621    MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBMEEGOTOUCHSHARE_CFLAGS"
6622    if test "$_LIB_FOUND"; then
6623       MOZ_ENABLE_MEEGOTOUCHSHARE=1
6624       AC_DEFINE(MOZ_ENABLE_MEEGOTOUCHSHARE)
6625    else
6626       AC_MSG_WARN([Cannot find maemo-meegotouch-interfaces-dev or libmdatauri-dev. Disabling meegotouch share ui.])
6627    fi
6628    AC_SUBST(MOZ_ENABLE_MEEGOTOUCHSHARE)
6630    AC_SUBST(MOZ_PLATFORM_MAEMO_LIBS)
6631    AC_SUBST(MOZ_PLATFORM_MAEMO_CFLAGS)
6634 dnl ========================================================
6635 dnl = XRender Composite
6636 dnl ========================================================
6637 MOZ_ARG_ENABLE_BOOL(egl-xrender-composite,
6638 [  --enable-egl-xrender-composite
6639                           Enable EGL xrender composite optimizations],
6640     MOZ_EGL_XRENDER_COMPOSITE=1)
6642 if test -n "$MOZ_EGL_XRENDER_COMPOSITE"; then
6643     AC_DEFINE(MOZ_EGL_XRENDER_COMPOSITE)
6646 AC_SUBST(MOZ_EGL_XRENDER_COMPOSITE)
6648 dnl ========================================================
6649 dnl GL provider
6650 dnl ========================================================
6651 MOZ_GL_PROVIDER=
6652 MOZ_ARG_WITH_STRING(gl-provider,
6653 [  --with-gl-provider=ID
6654                           Set GL provider backend type],
6655 [ val=`echo $withval`
6656     MOZ_GL_PROVIDER="$val"])
6658 if test -n "$MOZ_GL_PROVIDER"; then
6659 MOZ_GL_DEFAULT_PROVIDER=$MOZ_GL_PROVIDER
6660 AC_SUBST(MOZ_GL_PROVIDER)
6661 AC_DEFINE_UNQUOTED(MOZ_GL_PROVIDER, GLContextProvider$MOZ_GL_PROVIDER)
6663 AC_SUBST(MOZ_GL_DEFAULT_PROVIDER)
6665 dnl ========================================================
6666 dnl = faststripe theme
6667 dnl ========================================================
6668 MOZ_ARG_ENABLE_BOOL(faststripe,
6669 [  --enable-faststripe     Use faststripe theme],
6670     MOZ_THEME_FASTSTRIPE=1,
6671     MOZ_THEME_FASTSTRIPE= )
6672 AC_SUBST(MOZ_THEME_FASTSTRIPE)
6674 dnl ========================================================
6675 dnl =
6676 dnl = Feature options that require extra sources to be pulled
6677 dnl =
6678 dnl ========================================================
6679 dnl MOZ_ARG_HEADER(Features that require extra sources)
6681 dnl ========================================================
6682 dnl =
6683 dnl = Debugging Options
6684 dnl =
6685 dnl ========================================================
6686 MOZ_ARG_HEADER(Debugging and Optimizations)
6688 dnl ========================================================
6689 dnl = Disable building with debug info.
6690 dnl = Debugging is OFF by default
6691 dnl ========================================================
6692 if test -z "$MOZ_DEBUG_FLAGS"; then
6693   MOZ_DEBUG_FLAGS="-g"
6696 MOZ_ARG_ENABLE_STRING(debug,
6697 [  --enable-debug[=DBG]    Enable building with developer debug info
6698                            (using compiler flags DBG)],
6699 [ if test "$enableval" != "no"; then
6700     MOZ_DEBUG=1
6701     if test -n "$enableval" -a "$enableval" != "yes"; then
6702         MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6703         _MOZ_DEBUG_FLAGS_SET=1
6704     fi
6705   else
6706     MOZ_DEBUG=
6707   fi ],
6708   MOZ_DEBUG=)
6710 MOZ_DEBUG_ENABLE_DEFS="-DDEBUG -D_DEBUG -DTRACING"
6711 MOZ_ARG_WITH_STRING(debug-label,
6712 [  --with-debug-label=LABELS
6713                           Define DEBUG_<value> for each comma-separated
6714                           value given.],
6715 [ for option in `echo $withval | sed 's/,/ /g'`; do
6716     MOZ_DEBUG_ENABLE_DEFS="$MOZ_DEBUG_ENABLE_DEFS -DDEBUG_${option}"
6717 done])
6719 MOZ_DEBUG_DISABLE_DEFS="-DNDEBUG -DTRIMMED"
6721 if test -n "$MOZ_DEBUG"; then
6722     AC_MSG_CHECKING([for valid debug flags])
6723     _SAVE_CFLAGS=$CFLAGS
6724     CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS"
6725     AC_TRY_COMPILE([#include <stdio.h>],
6726         [printf("Hello World\n");],
6727         _results=yes,
6728         _results=no)
6729     AC_MSG_RESULT([$_results])
6730     if test "$_results" = "no"; then
6731         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_DEBUG_FLAGS])
6732     fi
6733     CFLAGS=$_SAVE_CFLAGS
6736 dnl ========================================================
6737 dnl enable mobile optimizations
6738 dnl ========================================================
6739 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
6740 [  --enable-mobile-optimize
6741                           Enable mobile optimizations],
6742     MOZ_GFX_OPTIMIZE_MOBILE=1)
6744 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
6746 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
6747     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
6750 dnl ========================================================
6751 dnl = Enable code optimization. ON by default.
6752 dnl ========================================================
6753 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
6754         MOZ_OPTIMIZE_FLAGS="-O"
6757 MOZ_ARG_ENABLE_STRING(optimize,
6758 [  --disable-optimize      Disable compiler optimization
6759   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
6760 [ if test "$enableval" != "no"; then
6761     MOZ_OPTIMIZE=1
6762     if test -n "$enableval" -a "$enableval" != "yes"; then
6763         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
6764         MOZ_OPTIMIZE=2
6765     fi
6766 else
6767     MOZ_OPTIMIZE=
6768 fi ], MOZ_OPTIMIZE=1)
6770 MOZ_SET_FRAMEPTR_FLAGS
6772 if test "$COMPILE_ENVIRONMENT"; then
6773 if test -n "$MOZ_OPTIMIZE"; then
6774     AC_MSG_CHECKING([for valid optimization flags])
6775     _SAVE_CFLAGS=$CFLAGS
6776     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
6777     AC_TRY_COMPILE([#include <stdio.h>],
6778         [printf("Hello World\n");],
6779         _results=yes,
6780         _results=no)
6781     AC_MSG_RESULT([$_results])
6782     if test "$_results" = "no"; then
6783         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
6784     fi
6785     CFLAGS=$_SAVE_CFLAGS
6787 fi # COMPILE_ENVIRONMENT
6789 AC_SUBST(MOZ_OPTIMIZE)
6790 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
6791 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
6792 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
6793 AC_SUBST(MOZ_ALLOW_HEAP_EXECUTE_FLAGS)
6794 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
6795 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
6797 dnl ========================================================
6798 dnl = Enable generation of debug symbols
6799 dnl ========================================================
6800 MOZ_ARG_ENABLE_STRING(debug-symbols,
6801 [  --enable-debug-symbols[=DBG]
6802                           Enable debugging symbols (using compiler flags DBG)],
6803 [ if test "$enableval" != "no"; then
6804       MOZ_DEBUG_SYMBOLS=1
6805       if test -n "$enableval" -a "$enableval" != "yes"; then
6806           if test -z "$_MOZ_DEBUG_FLAGS_SET"; then
6807               MOZ_DEBUG_FLAGS=`echo $enableval | sed -e 's|\\\ | |g'`
6808           else
6809               AC_MSG_ERROR([--enable-debug-symbols flags cannot be used with --enable-debug flags])
6810           fi
6811       fi
6812   else
6813       MOZ_DEBUG_SYMBOLS=
6814   fi ],
6815   MOZ_DEBUG_SYMBOLS=1)
6817 if test -n "$MOZ_DEBUG" -o -n "$MOZ_DEBUG_SYMBOLS"; then
6818     AC_DEFINE(MOZ_DEBUG_SYMBOLS)
6819     export MOZ_DEBUG_SYMBOLS
6822 dnl ========================================================
6823 dnl = Enable any treating of compile warnings as errors
6824 dnl ========================================================
6825 MOZ_ARG_ENABLE_BOOL(warnings-as-errors,
6826 [  --enable-warnings-as-errors
6827                           Enable treating of warnings as errors],
6828     MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
6829     MOZ_ENABLE_WARNINGS_AS_ERRORS=)
6830 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
6831    WARNINGS_AS_ERRORS=''
6834 dnl ========================================================
6835 dnl = Disable runtime logging checks
6836 dnl ========================================================
6837 MOZ_ARG_DISABLE_BOOL(logging,
6838 [  --disable-logging       Disable logging facilities],
6839     NS_DISABLE_LOGGING=1,
6840     NS_DISABLE_LOGGING= )
6841 if test "$NS_DISABLE_LOGGING"; then
6842     AC_DEFINE(NS_DISABLE_LOGGING)
6843 else
6844     AC_DEFINE(MOZ_LOGGING)
6847 dnl ========================================================
6848 dnl = This will enable logging of addref, release, ctor, dtor.
6849 dnl ========================================================
6850 _ENABLE_LOGREFCNT=42
6851 MOZ_ARG_ENABLE_BOOL(logrefcnt,
6852 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
6853     _ENABLE_LOGREFCNT=1,
6854     _ENABLE_LOGREFCNT= )
6855 if test "$_ENABLE_LOGREFCNT" = "1"; then
6856     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
6857 elif test -z "$_ENABLE_LOGREFCNT"; then
6858     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
6861 dnl ========================================================
6862 dnl moz_dump_painting
6863 dnl ========================================================
6864 MOZ_ARG_ENABLE_BOOL(dump-painting,
6865 [  --enable-dump-painting          Enable paint debugging.],
6866     MOZ_DUMP_PAINTING=1,
6867     MOZ_DUMP_PAINTING= )
6868 if test -n "$MOZ_DUMP_PAINTING"; then
6869     AC_DEFINE(MOZ_DUMP_PAINTING)
6870     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
6872 if test -n "$MOZ_DEBUG"; then
6873     AC_DEFINE(MOZ_DUMP_PAINTING)
6876 dnl ========================================================
6877 dnl = Enable trace malloc
6878 dnl ========================================================
6879 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
6880 MOZ_ARG_ENABLE_BOOL(trace-malloc,
6881 [  --enable-trace-malloc   Enable malloc tracing; also disables jemalloc],
6882     NS_TRACE_MALLOC=1,
6883     NS_TRACE_MALLOC= )
6884 if test "$NS_TRACE_MALLOC"; then
6885   # Please, Mr. Linker Man, don't take away our symbol names
6886   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
6887   USE_ELF_DYNSTR_GC=
6888   AC_DEFINE(NS_TRACE_MALLOC)
6890 AC_SUBST(NS_TRACE_MALLOC)
6892 dnl ========================================================
6893 dnl = Enable jemalloc
6894 dnl ========================================================
6895 MOZ_ARG_ENABLE_BOOL(jemalloc,
6896 [  --enable-jemalloc       Replace memory allocator with jemalloc],
6897     MOZ_MEMORY=1,
6898     MOZ_MEMORY=)
6900 if test "$NS_TRACE_MALLOC"; then
6901     MOZ_MEMORY=
6903 if test "$MOZ_DMD"; then
6904     MOZ_MEMORY=
6907 if test "${OS_TARGET}" = "Android"; then
6908   dnl On Android, we use WRAP_LDFLAGS to link everything to mozglue
6909   :
6910 elif test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin" -o "${OS_TARGET}" = "OS2"; then
6911   dnl On Windows, OSX and OS2, we want to link all our binaries against mozglue
6912   if test -z "$GNU_CC"; then
6913     MOZ_GLUE_LDFLAGS='$(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
6914   else
6915     MOZ_GLUE_LDFLAGS='-L$(LIBXUL_DIST)/lib $(call EXPAND_LIBNAME,mozglue)'
6916   fi
6917 else
6918   dnl On other Unix systems, we only want to link executables against mozglue
6919   MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
6920   dnl On other Unix systems, where mozglue is a static library, jemalloc is
6921   dnl separated for the SDK, so we need to add it here.
6922   if test "$MOZ_MEMORY" = 1 -o \( "$LIBXUL_SDK" -a -f "$LIBXUL_SDK/lib/${LIB_PREFIX}memory.${LIB_SUFFIX}" \); then
6923     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib)'
6924   fi
6925   MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(MKSHLIB_UNFORCE_ALL)'
6926   if test -n "$GNU_CC"; then
6927     dnl And we need mozglue symbols to be exported.
6928     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
6929   fi
6930   if test "$MOZ_LINKER" = 1; then
6931     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS $ZLIB_LIBS"
6932   fi
6935 if test -z "$MOZ_MEMORY"; then
6936   case "${target}" in
6937     *-mingw*)
6938       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
6939         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.])
6940       fi
6941       ;;
6942   esac
6943 else
6944   dnl Don't try to run compiler tests on Windows
6945   if test "$OS_ARCH" = "WINNT"; then
6946     if test -z "$HAVE_64BIT_OS"; then
6947       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
6948     else
6949       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
6950     fi
6951   else
6952     AC_CHECK_SIZEOF([int *], [4])
6953     case "${ac_cv_sizeof_int_p}" in
6954     4)
6955       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 2)
6956       ;;
6957     8)
6958       AC_DEFINE_UNQUOTED([MOZ_MEMORY_SIZEOF_PTR_2POW], 3)
6959       ;;
6960     *)
6961       AC_MSG_ERROR([Unexpected pointer size])
6962       ;;
6963     esac
6964   fi
6966   AC_DEFINE(MOZ_MEMORY)
6967   if test -n "$MOZ_JEMALLOC"; then
6968     AC_DEFINE(MOZ_JEMALLOC)
6969   fi
6970   if test "x$MOZ_DEBUG" = "x1"; then
6971     AC_DEFINE(MOZ_MEMORY_DEBUG)
6972   fi
6973   dnl The generic feature tests that determine how to compute ncpus are long and
6974   dnl complicated.  Therefore, simply define special cpp variables for the
6975   dnl platforms we have special knowledge of.
6976   case "${target}" in
6977   *-darwin*)
6978     AC_DEFINE(MOZ_MEMORY_DARWIN)
6979     ;;
6980   *-*freebsd*)
6981     AC_DEFINE(MOZ_MEMORY_BSD)
6982     ;;
6983   *-android*|*-linuxandroid*)
6984     AC_DEFINE(MOZ_MEMORY_LINUX)
6985     AC_DEFINE(MOZ_MEMORY_ANDROID)
6986     if test -z "$gonkdir"; then
6987       _WRAP_MALLOC=1
6988     else
6989       AC_DEFINE(MOZ_MEMORY_GONK)
6990     fi
6991     MOZ_GLUE_LDFLAGS=
6992     ;;
6993   *-*linux*)
6994     AC_DEFINE(MOZ_MEMORY_LINUX)
6995     ;;
6996   *-netbsd*)
6997     AC_DEFINE(MOZ_MEMORY_BSD)
6998     ;;
6999   *-solaris*)
7000     AC_DEFINE(MOZ_MEMORY_SOLARIS)
7001     ;;
7002   *-mingw*)
7003     AC_DEFINE(MOZ_MEMORY_WINDOWS)
7004     if test -z "$MOZ_DEBUG"; then
7005       WIN32_CRT_LIBS="msvcrt.lib msvcprt.lib"
7006     else
7007       WIN32_CRT_LIBS="msvcrtd.lib msvcprtd.lib"
7008     fi
7009     dnl Look for a broken crtdll.obj
7010     WIN32_CRTDLL_FULLPATH=`lib -nologo -list $WIN32_CRT_LIBS | grep crtdll\\.obj`
7011     lib -NOLOGO -OUT:crtdll.obj $WIN32_CRT_LIBS -EXTRACT:$WIN32_CRTDLL_FULLPATH
7012     if grep -q '__imp__\{0,1\}free' crtdll.obj; then
7013       MOZ_GLUE_LDFLAGS='-LIBPATH:$(DIST)/lib -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcrtd -NODEFAULTLIB:msvcprt -NODEFAULTLIB:msvcprtd -DEFAULTLIB:mozcrt'
7014       dnl Also pass this to NSPR/NSS
7015       DLLFLAGS="$DLLFLAGS $MOZ_GLUE_LDFLAGS"
7016     else
7017       DLLFLAGS="$DLLFLAGS -LIBPATH:\$(DIST)/lib -DEFAULTLIB:mozglue"
7018     fi
7019     rm crtdll.obj
7021     export DLLFLAGS
7022     ;;
7023   *)
7024     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
7025     ;;
7026   esac
7027 fi # MOZ_MEMORY
7028 AC_SUBST(MOZ_MEMORY)
7029 AC_SUBST(MOZ_JEMALLOC)
7030 AC_SUBST(MOZ_GLUE_LDFLAGS)
7031 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
7032 AC_SUBST(WIN32_CRT_LIBS)
7033 dnl Need to set this for make because NSS doesn't have configure
7034 AC_SUBST(DLLFLAGS)
7036 dnl We need to wrap dlopen and related functions on Android because we use
7037 dnl our own linker.
7038 if test "$OS_TARGET" = Android; then
7039     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
7040     if test -n "$MOZ_OLD_LINKER"; then
7041         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=dlopen,--wrap=dlclose,--wrap=dlerror,--wrap=dlsym,--wrap=dladdr"
7042     fi
7043     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
7044     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork,--wrap=raise,--wrap=PR_GetEnv,--wrap=PR_SetEnv"
7047 dnl ========================================================
7048 dnl = Use malloc wrapper lib
7049 dnl ========================================================
7050 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
7051 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
7052     _WRAP_MALLOC=1,
7053     _WRAP_MALLOC= )
7055 if test -n "$_WRAP_MALLOC"; then
7056     if test -n "$GNU_CC"; then
7057         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
7058         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
7059         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
7060         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
7061         dnl Wrap operator new and operator delete on Android.
7062         if test "$OS_TARGET" = "Android"; then
7063             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_Znwj,--wrap=_Znaj,--wrap=_ZdlPv,--wrap=_ZdaPv"
7064         fi
7065     else
7066         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
7067     fi
7070 dnl ========================================================
7071 dnl = Location of malloc wrapper lib
7072 dnl ========================================================
7073 MOZ_ARG_WITH_STRING(wrap-malloc,
7074 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
7075     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
7077 dnl ========================================================
7078 dnl = Use JS Call tracing
7079 dnl ========================================================
7080 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
7081 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
7082     MOZ_TRACE_JSCALLS=1,
7083     MOZ_TRACE_JSCALLS= )
7084 if test -n "$MOZ_TRACE_JSCALLS"; then
7085     AC_DEFINE(MOZ_TRACE_JSCALLS)
7088 dnl ========================================================
7089 dnl = Use incremental GC
7090 dnl ========================================================
7091 JSGC_INCREMENTAL=1
7092 MOZ_ARG_DISABLE_BOOL(gcincremental,
7093 [  --disable-gcincremental Disable incremental GC],
7094     JSGC_INCREMENTAL= )
7095 if test -n "$JSGC_INCREMENTAL"; then
7096     AC_DEFINE(JSGC_INCREMENTAL)
7099 dnl ========================================================
7100 dnl ETW - Event Tracing for Windows
7101 dnl ========================================================
7102 MOZ_ARG_ENABLE_BOOL(ETW,
7103 [  --enable-ETW            Enable ETW (Event Tracing for Windows) event reporting],
7104     MOZ_ETW=1,
7105     MOZ_ETW= )
7106 if test -n "$MOZ_ETW"; then
7107     AC_DEFINE(MOZ_ETW)
7110 if test -n "$MOZ_ETW"; then
7111     if test -z "$MOZ_WINSDK_TARGETVER"; then
7112         AC_MSG_ERROR([--enable-ETW is only valid on Windows])
7113     fi
7116 dnl ========================================================
7117 dnl Zealous JavaScript GC
7118 dnl ========================================================
7119 MOZ_ARG_ENABLE_BOOL(gczeal,
7120 [  --enable-gczeal         Enable zealous JavaScript GCing],
7121     JS_GC_ZEAL=1,
7122     JS_GC_ZEAL= )
7123 if test -n "$JS_GC_ZEAL"; then
7124     AC_DEFINE(JS_GC_ZEAL)
7127 dnl ========================================================
7128 dnl JS opt-mode assertions and minidump instrumentation
7129 dnl ========================================================
7130 MOZ_ARG_ENABLE_BOOL(js-diagnostics,
7131 [  --enable-js-diagnostics
7132                           Enable JS diagnostic assertions and breakpad data],
7133     JS_CRASH_DIAGNOSTICS=1,
7134     JS_CRASH_DIAGNOSTICS= )
7135 if test -n "$JS_CRASH_DIAGNOSTICS"; then
7136     AC_DEFINE(JS_CRASH_DIAGNOSTICS)
7139 MOZ_CHECK_CCACHE
7141 dnl ========================================================
7142 dnl = Enable static checking using gcc-dehydra
7143 dnl ========================================================
7145 MOZ_ARG_WITH_STRING(static-checking,
7146 [  --with-static-checking=path/to/gcc_dehydra.so
7147                           Enable static checking of code using GCC-dehydra],
7148     DEHYDRA_PATH=$withval,
7149     DEHYDRA_PATH= )
7151 if test -n "$DEHYDRA_PATH"; then
7152     if test ! -f "$DEHYDRA_PATH"; then
7153         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7154     fi
7155     AC_DEFINE(NS_STATIC_CHECKING)
7157 AC_SUBST(DEHYDRA_PATH)
7159 dnl ========================================================
7160 dnl = Enable stripping of libs & executables
7161 dnl ========================================================
7162 MOZ_ARG_ENABLE_BOOL(strip,
7163 [  --enable-strip          Enable stripping of libs & executables ],
7164     ENABLE_STRIP=1,
7165     ENABLE_STRIP= )
7167 dnl ========================================================
7168 dnl = Enable stripping of libs & executables when packaging
7169 dnl ========================================================
7170 MOZ_ARG_ENABLE_BOOL(install-strip,
7171 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7172     PKG_SKIP_STRIP= ,
7173     PKG_SKIP_STRIP=1)
7175 dnl ========================================================
7176 dnl = --enable-elf-dynstr-gc
7177 dnl ========================================================
7178 MOZ_ARG_ENABLE_BOOL(elf-dynstr-gc,
7179 [  --enable-elf-dynstr-gc  Enable elf dynstr garbage collector (opt builds only)],
7180     USE_ELF_DYNSTR_GC=1,
7181     USE_ELF_DYNSTR_GC= )
7183 dnl ========================================================
7184 dnl = --disable-elf-hack
7185 dnl ========================================================
7187 USE_ELF_HACK=1
7188 MOZ_ARG_DISABLE_BOOL(elf-hack,
7189 [  --disable-elf-hack      Disable elf hacks],
7190     USE_ELF_HACK=,
7191     USE_ELF_HACK=1)
7193 # Disable elf hack for profiling because the built in profiler
7194 # doesn't read the segments properly with elf hack. This is
7195 # temporary and should be fixed soon in the profiler.
7196 if test "$MOZ_PROFILING" = 1; then
7197   USE_ELF_HACK=
7200 # Only enable elfhack where supported
7201 if test "$USE_ELF_HACK" = 1; then
7202     case "${HOST_OS_ARCH},${OS_ARCH}" in
7203     Linux,Linux)
7204         case "${CPU_ARCH}" in
7205         arm | x86 | x86_64)
7206             USE_ELF_HACK=1
7207             ;;
7208         *)
7209             USE_ELF_HACK=
7210             ;;
7211         esac
7212         ;;
7213     *)
7214         USE_ELF_HACK=
7215         ;;
7216     esac
7219 if test "$USE_ELF_HACK" = 1; then
7220     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
7221     dnl memory addresses it maps to. The result is that by the time elfhack
7222     dnl kicks in, it is not possible to apply relocations because of that,
7223     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
7224     dnl segment. It makes elfhack mostly useless, so considering the problems
7225     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
7226     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
7227     dnl the linker creates PT_GNU_RELRO segments.
7228     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
7229         LINK_WITH_PT_GNU_RELRO,
7230         [echo "int main() {return 0;}" > conftest.${ac_ext}
7231          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
7232             test -s conftest${ac_exeext}; then
7233             if ${TOOLCHAIN_PREFIX}readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
7234                 LINK_WITH_PT_GNU_RELRO=yes
7235             else
7236                 LINK_WITH_PT_GNU_RELRO=no
7237             fi
7238          else
7239              dnl We really don't expect to get here, but just in case
7240              AC_ERROR([couldn't compile a simple C file])
7241          fi
7242          rm -rf conftest*])
7243     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
7244         AC_MSG_WARN([Disabling elfhack])
7245         USE_ELF_HACK=
7246     fi
7249 dnl ========================================================
7250 dnl = libstdc++ compatibility hacks
7251 dnl ========================================================
7253 STDCXX_COMPAT=
7254 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
7255 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
7256     STDCXX_COMPAT=1)
7258 AC_SUBST(STDCXX_COMPAT)
7260 if test -n "$STDCXX_COMPAT"; then
7261    eval $(CXX="$CXX" $PYTHON $_topsrcdir/build/autoconf/libstdcxx.py)
7262    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
7263    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
7266 dnl ========================================================
7267 dnl =
7268 dnl = Profiling and Instrumenting
7269 dnl =
7270 dnl ========================================================
7271 MOZ_ARG_HEADER(Profiling and Instrumenting)
7273 dnl ========================================================
7274 dnl = Enable runtime visual profiling logger
7275 dnl ========================================================
7276 MOZ_ARG_ENABLE_BOOL(visual-event-tracer,
7277 [  --enable-visual-event-tracer   Enable visual event tracer instrumentation],
7278     MOZ_VISUAL_EVENT_TRACER=1,
7279     MOZ_VISUAL_EVENT_TRACER=)
7280 if test -n "$MOZ_VISUAL_EVENT_TRACER"; then
7281     AC_DEFINE(MOZ_VISUAL_EVENT_TRACER)
7284 dnl ========================================================
7285 dnl Turn on reflow counting
7286 dnl ========================================================
7287 MOZ_ARG_ENABLE_BOOL(reflow-perf,
7288 [  --enable-reflow-perf    Enable reflow performance tracing],
7289     MOZ_REFLOW_PERF=1,
7290     MOZ_REFLOW_PERF= )
7291 if test -n "$MOZ_REFLOW_PERF"; then
7292     AC_DEFINE(MOZ_REFLOW_PERF)
7295 dnl ========================================================
7296 dnl Enable code size metrics.
7297 dnl ========================================================
7298 MOZ_ARG_ENABLE_BOOL(codesighs,
7299 [  --enable-codesighs      Enable code size analysis tools],
7300     _ENABLE_CODESIGHS=1,
7301     _ENABLE_CODESIGHS= )
7302 if test -n "$_ENABLE_CODESIGHS"; then
7303     if test -d $srcdir/tools/codesighs; then
7304         MOZ_MAPINFO=1
7305     else
7306         AC_MSG_ERROR([Codesighs directory $srcdir/tools/codesighs required.])
7307     fi
7310 dnl ========================================================
7311 dnl = Enable Radio Interface for B2G (Gonk usually)
7312 dnl ========================================================
7313 MOZ_ARG_ENABLE_BOOL(b2g-ril,
7314 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
7315     MOZ_B2G_RIL=1,
7316     MOZ_B2G_RIL= )
7317 if test -n "$MOZ_B2G_RIL"; then
7318     AC_DEFINE(MOZ_B2G_RIL)
7320 AC_SUBST(MOZ_B2G_RIL)
7322 dnl ========================================================
7323 dnl = Enable Radio FM for B2G (Gonk usually)
7324 dnl ========================================================
7325 if test -n "$MOZ_B2G_FM"; then
7326     AC_DEFINE(MOZ_B2G_FM)
7328 AC_SUBST(MOZ_B2G_FM)
7330 dnl ========================================================
7331 dnl = Enable Bluetooth Interface for B2G (Gonk usually)
7332 dnl ========================================================
7333 MOZ_ARG_ENABLE_BOOL(b2g-bt,
7334 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
7335     MOZ_B2G_BT=1,
7336     MOZ_B2G_BT= )
7337 if test -n "$MOZ_B2G_BT"; then
7338     AC_DEFINE(MOZ_B2G_BT)
7340 AC_SUBST(MOZ_B2G_BT)
7342 dnl ========================================================
7343 dnl = Enable Support for System Messages API
7344 dnl ========================================================
7345 if test -n "$MOZ_SYS_MSG"; then
7346     AC_DEFINE(MOZ_SYS_MSG)
7348 AC_SUBST(MOZ_SYS_MSG)
7350 dnl ========================================================
7351 dnl = Enable Camera Interface for B2G (Gonk usually)
7352 dnl ========================================================
7353 MOZ_ARG_ENABLE_BOOL(b2g-camera,
7354 [  --enable-b2g-camera      Set compile flags necessary for compiling camera API for B2G ],
7355     MOZ_B2G_CAMERA=1,
7356     MOZ_B2G_CAMERA= )
7357 if test -n "$MOZ_B2G_CAMERA"; then
7358    AC_DEFINE(MOZ_B2G_CAMERA)
7360 AC_SUBST(MOZ_B2G_CAMERA)
7362 dnl ========================================================
7363 dnl = Enable Support for Payment API
7364 dnl ========================================================
7365 if test -n "$MOZ_PAY"; then
7366     AC_DEFINE(MOZ_PAY)
7368 AC_SUBST(MOZ_PAY)
7370 dnl ========================================================
7371 dnl = Support for demangling undefined symbols
7372 dnl ========================================================
7373 if test -z "$SKIP_LIBRARY_CHECKS"; then
7374     AC_LANG_SAVE
7375     AC_LANG_CPLUSPLUS
7376     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7377     AC_LANG_RESTORE
7380 # Demangle only for debug or trace-malloc builds
7381 MOZ_DEMANGLE_SYMBOLS=
7382 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
7383     MOZ_DEMANGLE_SYMBOLS=1
7384     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7386 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7388 dnl ========================================================
7389 dnl = Support for gcc stack unwinding (from gcc 3.3)
7390 dnl ========================================================
7391 if test -z "$SKIP_LIBRARY_CHECKS"; then
7392     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7395 dnl ========================================================
7396 dnl JIT observers
7397 dnl ========================================================
7399 MOZ_ARG_WITH_STRING(jitreport-granularity,
7400 [  --jitreport-granularity=N
7401                            Default granularity at which to report JIT code
7402                            to external tools
7403                              0 - no info
7404                              1 - code ranges for whole functions only
7405                              2 - per-line information
7406                              3 - per-op information],
7407   JITREPORT_GRANULARITY=$withval,
7408   JITREPORT_GRANULARITY=3)
7410 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
7412 dnl ========================================================
7413 dnl =
7414 dnl = Misc. Options
7415 dnl =
7416 dnl ========================================================
7417 MOZ_ARG_HEADER(Misc. Options)
7419 dnl ========================================================
7420 dnl update xterm title
7421 dnl ========================================================
7422 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7423 [  --enable-xterm-updates  Update XTERM titles with current command.],
7424     MOZ_UPDATE_XTERM=1,
7425     MOZ_UPDATE_XTERM= )
7427 dnl =========================================================
7428 dnl = Chrome format
7429 dnl =========================================================
7430 MOZ_ARG_ENABLE_STRING([chrome-format],
7431 [  --enable-chrome-format=jar|flat|both|symlink|omni
7432                           Select FORMAT of chrome files (default=jar)],
7433     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7435 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7436     MOZ_CHROME_FILE_FORMAT=jar
7439 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
7440     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7441     test "$MOZ_CHROME_FILE_FORMAT" != "symlink" &&
7442     test "$MOZ_CHROME_FILE_FORMAT" != "both" &&
7443     test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
7444     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, both, symlink, or omni])
7447 dnl =========================================================
7448 dnl Omnijar packaging (bug 552121)
7449 dnl =========================================================
7450 dnl Omnijar packaging is compatible with flat packaging.
7451 dnl In unpackaged builds, omnijar looks for files as if
7452 dnl things were flat packaged. After packaging, all files
7453 dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
7454 dnl is set to flat since putting files into jars is only
7455 dnl done during packaging with omnijar.
7456 if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
7457     MOZ_OMNIJAR=1
7458     AC_DEFINE(MOZ_OMNIJAR)
7459     if test "$OS_ARCH" = "WINNT" -o "$OS_ARCH" = "OS2" -o "$OS_TARGET" = "Android"; then
7460         MOZ_CHROME_FILE_FORMAT=flat
7461     else
7462         MOZ_CHROME_FILE_FORMAT=symlink
7463     fi
7464 elif test "$MOZ_CHROME_FILE_FORMAT" = "jar"; then
7465     AC_DEFINE(MOZ_CHROME_FILE_FORMAT_JAR)
7468 OMNIJAR_NAME=omni.ja
7469 AC_SUBST(OMNIJAR_NAME)
7470 AC_SUBST(MOZ_OMNIJAR)
7472 dnl ========================================================
7473 dnl = Define default location for MOZILLA_FIVE_HOME
7474 dnl ========================================================
7475 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7476 [  --with-default-mozilla-five-home
7477                           Set the default value for MOZILLA_FIVE_HOME],
7478 [ val=`echo $withval`
7479   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7481 dnl ========================================================
7482 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7483 dnl ========================================================
7484 MOZ_ARG_WITH_STRING(user-appdir,
7485 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7486 [ val=`echo $withval`
7487 if echo "$val" | grep "\/" >/dev/null; then
7488     AC_MSG_ERROR("Homedir must be single relative path.")
7489 else
7490     MOZ_USER_DIR="$val"
7491 fi])
7493 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7495 dnl ========================================================
7496 dnl = Doxygen configuration
7497 dnl ========================================================
7498 dnl Use commas to specify multiple dirs to this arg
7499 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7500 MOZ_ARG_WITH_STRING(doc-input-dirs,
7501 [  --with-doc-input-dirs=DIRS
7502                           Header/idl dirs to create docs from],
7503 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7504 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7506 dnl Use commas to specify multiple dirs to this arg
7507 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7508 MOZ_ARG_WITH_STRING(doc-include-dirs,
7509 [  --with-doc-include-dirs=DIRS
7510                           Include dirs to preprocess doc headers],
7511 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7512 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7514 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7515 MOZ_ARG_WITH_STRING(doc-output-dir,
7516 [  --with-doc-output-dir=DIR
7517                           Dir to generate docs into],
7518 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7519 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7521 if test -z "$SKIP_COMPILER_CHECKS"; then
7522 dnl ========================================================
7523 dnl =
7524 dnl = Compiler Options
7525 dnl =
7526 dnl ========================================================
7527 MOZ_ARG_HEADER(Compiler Options)
7529 dnl ========================================================
7530 dnl Check for gcc -pipe support
7531 dnl ========================================================
7532 AC_MSG_CHECKING([for -pipe support])
7533 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
7534     dnl Any gcc that supports firefox supports -pipe.
7535     CFLAGS="$CFLAGS -pipe"
7536     CXXFLAGS="$CXXFLAGS -pipe"
7537     AC_MSG_RESULT([yes])
7538 else
7539     AC_MSG_RESULT([no])
7542 dnl ========================================================
7543 dnl Profile guided optimization (gcc checks)
7544 dnl ========================================================
7545 dnl Test for profiling options
7546 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7548 _SAVE_CFLAGS="$CFLAGS"
7549 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
7551 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7552 AC_TRY_COMPILE([], [return 0;],
7553                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7554                  result="yes" ], result="no")
7555 AC_MSG_RESULT([$result])
7557 if test $result = "yes"; then
7558   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7559   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
7560   PROFILE_USE_LDFLAGS="-fprofile-use"
7563 CFLAGS="$_SAVE_CFLAGS"
7565 if test -n "$INTEL_CC"; then
7566   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
7567   PROFILE_GEN_LDFLAGS=
7568   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
7569   PROFILE_USE_LDFLAGS=
7572 dnl Sun Studio on Solaris
7573 if test "$SOLARIS_SUNPRO_CC"; then
7574   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
7575   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
7576   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
7577   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
7580 AC_SUBST(PROFILE_GEN_CFLAGS)
7581 AC_SUBST(PROFILE_GEN_LDFLAGS)
7582 AC_SUBST(PROFILE_USE_CFLAGS)
7583 AC_SUBST(PROFILE_USE_LDFLAGS)
7585 AC_LANG_CPLUSPLUS
7587 dnl ========================================================
7588 dnl Test for -pedantic bustage
7589 dnl ========================================================
7590 MOZ_ARG_DISABLE_BOOL(pedantic,
7591 [  --disable-pedantic      Issue all warnings demanded by strict ANSI C ],
7592 _PEDANTIC= )
7593 if test "$_PEDANTIC"; then
7594     _SAVE_CXXFLAGS=$CXXFLAGS
7595     CXXFLAGS="$CXXFLAGS -pedantic ${_WARNINGS_CXXFLAGS} -Wno-long-long"
7596     AC_MSG_CHECKING([whether C++ compiler has -pedantic long long bug])
7597     AC_TRY_COMPILE([$configure_static_assert_macros],
7598                    [CONFIGURE_STATIC_ASSERT(sizeof(long long) == 8)],
7599                    result="no", result="yes" )
7600     AC_MSG_RESULT([$result])
7601     CXXFLAGS="$_SAVE_CXXFLAGS"
7603     case "$result" in
7604     no)
7605         _WARNINGS_CFLAGS="-pedantic ${_WARNINGS_CFLAGS} -Wno-long-long"
7606         _WARNINGS_CXXFLAGS="-pedantic ${_WARNINGS_CXXFLAGS} -Wno-long-long"
7607         ;;
7608     yes)
7609         AC_MSG_ERROR([Your compiler appears to have a known bug where long long is miscompiled when using -pedantic.  Reconfigure using --disable-pedantic. ])
7610         ;;
7611     esac
7614 dnl ========================================================
7615 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
7616 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
7617 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
7618 dnl ========================================================
7619 _SAVE_CXXFLAGS=$CXXFLAGS
7620 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
7621 AC_CACHE_CHECK(for correct overload resolution with const and templates,
7622     ac_nscap_nonconst_opeq_bug,
7623     [AC_TRY_COMPILE([
7624                       template <class T>
7625                       class Pointer
7626                         {
7627                         public:
7628                           T* myPtr;
7629                         };
7631                       template <class T, class U>
7632                       int operator==(const Pointer<T>& rhs, U* lhs)
7633                         {
7634                           return rhs.myPtr == lhs;
7635                         }
7637                       template <class T, class U>
7638                       int operator==(const Pointer<T>& rhs, const U* lhs)
7639                         {
7640                           return rhs.myPtr == lhs;
7641                         }
7642                     ],
7643                     [
7644                       Pointer<int> foo;
7645                       const int* bar;
7646                       return foo == bar;
7647                     ],
7648                     ac_nscap_nonconst_opeq_bug="no",
7649                     ac_nscap_nonconst_opeq_bug="yes")])
7650 CXXFLAGS="$_SAVE_CXXFLAGS"
7652 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
7653     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
7655 fi # ! SKIP_COMPILER_CHECKS
7657 AC_DEFINE(CPP_THROW_NEW, [throw()])
7658 AC_LANG_C
7660 if test "$COMPILE_ENVIRONMENT"; then
7661 MOZ_EXPAND_LIBS
7662 fi # COMPILE_ENVIRONMENT
7664 dnl ========================================================
7665 dnl =
7666 dnl = Build depencency options
7667 dnl =
7668 dnl ========================================================
7669 MOZ_ARG_HEADER(Build dependencies)
7671 if test "$GNU_CC" -a "$GNU_CXX"; then
7672   _DEPEND_CFLAGS='$(filter-out %/.pp,-MD -MF $(MDDEPDIR)/$(@F).pp)'
7673 dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
7674 elif test "$SOLARIS_SUNPRO_CC"; then
7675   _DEPEND_CFLAGS=
7676 else
7677   dnl Don't override this for MSVC
7678   if test -z "$_WIN32_MSVC"; then
7679     _USE_CPP_INCLUDE_FLAG=
7680     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7681     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7682   else
7683     echo '#include <stdio.h>' > dummy-hello.c
7684     changequote(,)
7685     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
7686     changequote([,])
7687     if test -z "$CL_INCLUDES_PREFIX"; then
7688         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
7689     fi
7690     AC_SUBST(CL_INCLUDES_PREFIX)
7691     rm -f dummy-hello.c
7692   fi
7695 dnl ========================================================
7696 dnl =
7697 dnl = Static Build Options
7698 dnl =
7699 dnl ========================================================
7700 MOZ_ARG_HEADER(Static build options)
7702 # split JS out by default to avoid VS2005 PGO crash (bug 591836).
7703 if test "$OS_ARCH" = "WINNT" -a "$CPU_ARCH" != "x86_64" ; then
7704   ENABLE_SHARED_JS=1
7707 MOZ_ARG_ENABLE_BOOL(shared-js,
7708 [  --enable-shared-js
7709                           Create a shared JavaScript library.],
7710     ENABLE_SHARED_JS=1,
7711     ENABLE_SHARED_JS=)
7713 if test -n "$ENABLE_SHARED_JS"; then
7714   JS_SHARED_LIBRARY=1
7715   MOZ_JS_LIBS="$MOZ_JS_SHARED_LIBS"
7716 else
7717   MOZ_JS_LIBS="$MOZ_JS_STATIC_LIBS"
7718   AC_DEFINE(MOZ_STATIC_JS)
7720 AC_SUBST(JS_SHARED_LIBRARY)
7722 AC_SUBST(LIBXUL_LIBS)
7723 XPCOM_LIBS="$LIBXUL_LIBS"
7725 dnl ========================================================
7726 dnl =
7727 dnl = Standalone module options
7728 dnl =
7729 dnl ========================================================
7730 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
7732 dnl Check for GLib.
7733 dnl ========================================================
7735 if test -z "$SKIP_PATH_CHECKS"; then
7736 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
7737     if test "$MOZ_ENABLE_GTK2" -o "$USE_ELF_DYNSTR_GC" ; then
7738         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
7739     fi
7743 if test -z "${GLIB_GMODULE_LIBS}" \
7744    -a -n "${GLIB_CONFIG}"\
7745     -a "${GLIB_CONFIG}" != no\
7746 ; then
7747     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
7750 AC_SUBST(GLIB_CFLAGS)
7751 AC_SUBST(GLIB_LIBS)
7752 AC_SUBST(GLIB_GMODULE_LIBS)
7754 dnl ========================================================
7755 dnl Graphics checks.
7756 dnl ========================================================
7758 if test "${OS_TARGET}" = "WINNT" -o "${OS_ARCH}" = "Darwin" -o "${MOZ_WIDGET_TOOLKIT}" = "android" -o "${MOZ_WIDGET_TOOLKIT}" = "gtk2"; then
7759 MOZ_ENABLE_SKIA=1
7760 else
7761 MOZ_ENABLE_SKIA=
7764 MOZ_ARG_ENABLE_BOOL(skia,
7765 [  --enable-skia   Enable use of Skia],
7766 MOZ_ENABLE_SKIA=1,
7767 MOZ_ENABLE_SKIA=)
7769 if test "$USE_FC_FREETYPE"; then
7770     if test "$COMPILE_ENVIRONMENT"; then
7771         dnl ========================================================
7772         dnl = Check for freetype2 and its functionality
7773         dnl ========================================================
7774         PKG_CHECK_MODULES(FT2, freetype2 >= 6.1.0, _HAVE_FREETYPE2=1, _HAVE_FREETYPE2=)
7776         if test "$_HAVE_FREETYPE2"; then
7777             _SAVE_LIBS="$LIBS"
7778             _SAVE_CFLAGS="$CFLAGS"
7779             LIBS="$LIBS $FT2_LIBS"
7780             CFLAGS="$CFLAGS $FT2_CFLAGS"
7782             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
7783                 ac_cv_member_FT_Bitmap_Size_y_ppem,
7784                 [AC_TRY_COMPILE([#include <ft2build.h>
7785                                  #include FT_FREETYPE_H],
7786                                 [FT_Bitmap_Size s;
7787                                  if (sizeof s.y_ppem) return 0;
7788                                  return 1],
7789                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
7790                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
7791             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
7792                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
7793             else
7794                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
7795             fi
7796             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
7797                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
7798                                [FT_Bitmap_Size structure includes y_ppem field])
7800             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table FT_Select_Size)
7802             LIBS="$_SAVE_LIBS"
7803             CFLAGS="$_SAVE_CFLAGS"
7804         fi
7806         _SAVE_CPPFLAGS="$CPPFLAGS"
7807         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
7808         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
7809             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
7810         CPPFLAGS="$_SAVE_CPPFLAGS"
7811     else
7812         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
7813     fi
7815     PKG_CHECK_MODULES(_FONTCONFIG, fontconfig,
7816     [
7817         if test "$MOZ_PANGO"; then
7818             MOZ_PANGO_CFLAGS="$MOZ_PANGO_CFLAGS $_FONTCONFIG_CFLAGS"
7819             MOZ_PANGO_LIBS="$MOZ_PANGO_LIBS $_FONTCONFIG_LIBS"
7820         else
7821             FT2_CFLAGS="$FT2_CFLAGS $_FONTCONFIG_CFLAGS"
7822             FT2_LIBS="$FT2_LIBS $_FONTCONFIG_LIBS"
7823         fi
7824     ])
7827 dnl ========================================================
7828 dnl Check for pixman and cairo
7829 dnl ========================================================
7831 MOZ_TREE_CAIRO=1
7832 MOZ_ARG_ENABLE_BOOL(system-cairo,
7833 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
7834 MOZ_TREE_CAIRO=,
7835 MOZ_TREE_CAIRO=1 )
7837 MOZ_TREE_PIXMAN=1
7838 MOZ_ARG_ENABLE_BOOL(system-pixman,
7839 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
7840 MOZ_TREE_PIXMAN=,
7841 MOZ_TREE_PIXMAN=force,
7842 MOZ_TREE_PIXMAN=1 )
7844 # System cairo depends on system pixman
7845 if test "$MOZ_TREE_PIXMAN" = "force"; then
7846     if test -z "$MOZ_TREE_CAIRO"; then
7847         AC_MSG_ERROR([--disable-system-pixman is incompatible with --enable-system-cairo.])
7848     else
7849         MOZ_TREE_PIXMAN=1
7850     fi
7851 elif test -z "$MOZ_TREE_CAIRO"; then
7852     MOZ_TREE_PIXMAN=
7855 if test "$MOZ_TREE_PIXMAN"; then
7856     AC_DEFINE(MOZ_TREE_PIXMAN)
7857     MOZ_PIXMAN_CFLAGS=""
7858     MOZ_PIXMAN_LIBS='$(call EXPAND_LIBNAME_PATH,mozlibpixman,$(DEPTH)/gfx/cairo/libpixman/src)'
7859 else
7860     PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.19.2)
7861     MOZ_PIXMAN_CFLAGS="$PIXMAN_CFLAGS"
7862     MOZ_PIXMAN_LIBS="$PIXMAN_LIBS"
7864 AC_SUBST(MOZ_PIXMAN_CFLAGS)
7865 AC_SUBST(MOZ_PIXMAN_LIBS)
7867 # Check for headers defining standard int types.
7868 MOZ_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
7870 if test "$MOZ_TREE_CAIRO"; then
7871     MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
7872     AC_DEFINE(MOZ_TREE_CAIRO)
7874     # For now we assume that we will have a uint64_t available through
7875     # one of the above headers or mozstdint.h.
7876     AC_DEFINE(HAVE_UINT64_T)
7878     # Define macros for cairo-features.h
7879     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
7880     if test "$MOZ_X11"; then
7881         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
7882         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
7883         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
7884         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
7885         MOZ_ENABLE_CAIRO_FT=1
7886         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
7887     fi
7888     case "$MOZ_WIDGET_TOOLKIT" in
7889       qt)
7890         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
7891         ;;
7892       cocoa | uikit)
7893         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
7894         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
7895         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
7896         ;;
7897       windows)
7898         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
7899         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
7900         if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
7901             WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
7902             WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
7903             MOZ_ENABLE_D2D_SURFACE=1
7904             MOZ_ENABLE_DWRITE_FONT=1
7905         else
7906             WIN32_DWRITE_FONT_FEATURE=
7907             WIN32_D2D_SURFACE_FEATURE=
7908         fi
7910         MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
7912         dnl D3D10 Layers depend on D2D Surfaces.
7913         if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
7914           MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
7915         fi
7916         ;;
7917       os2)
7918         OS2_SURFACE_FEATURE="#define CAIRO_HAS_OS2_SURFACE 1"
7919         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
7920         MOZ_ENABLE_CAIRO_FT=1
7921         CAIRO_FT_CFLAGS="-I${MZFTCFGFT2}/include"
7922         CAIRO_FT_OSLIBS="-L${MZFTCFGFT2}/lib -lmozft -lmzfntcfg"
7923         CAIRO_FT_LIBS=""
7924         ;;
7925     esac
7926     if test "$USE_FC_FREETYPE"; then
7927         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
7928     fi
7929     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
7930     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
7931     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
7932     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
7933     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
7934     AC_SUBST(CAIRO_FT_CFLAGS)
7936     AC_SUBST(PS_SURFACE_FEATURE)
7937     AC_SUBST(PDF_SURFACE_FEATURE)
7938     AC_SUBST(SVG_SURFACE_FEATURE)
7939     AC_SUBST(XLIB_SURFACE_FEATURE)
7940     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
7941     AC_SUBST(QUARTZ_SURFACE_FEATURE)
7942     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
7943     AC_SUBST(WIN32_SURFACE_FEATURE)
7944     AC_SUBST(OS2_SURFACE_FEATURE)
7945     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
7946     AC_SUBST(FT_FONT_FEATURE)
7947     AC_SUBST(FC_FONT_FEATURE)
7948     AC_SUBST(WIN32_FONT_FEATURE)
7949     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
7950     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
7951     AC_SUBST(QUARTZ_FONT_FEATURE)
7952     AC_SUBST(PNG_FUNCTIONS_FEATURE)
7953     AC_SUBST(QT_SURFACE_FEATURE)
7954     AC_SUBST(TEE_SURFACE_FEATURE)
7956     MOZ_CAIRO_LIBS='$(call EXPAND_LIBNAME_PATH,mozcairo,$(DEPTH)/gfx/cairo/cairo/src)'" $CAIRO_FT_LIBS"
7957     MOZ_CAIRO_OSLIBS='${CAIRO_FT_OSLIBS}'
7959     if test "$MOZ_X11"; then
7960         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
7961     fi
7963     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
7964 else
7965     PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION)
7966     MOZ_CAIRO_CFLAGS="$CAIRO_CFLAGS"
7967     MOZ_CAIRO_LIBS="$CAIRO_LIBS"
7968     PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
7969     if test "$MOZ_X11"; then
7970         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
7971         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
7972         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_LIBS"
7973         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
7974     fi
7977 AC_SUBST(MOZ_TREE_CAIRO)
7978 AC_SUBST(MOZ_CAIRO_CFLAGS)
7979 AC_SUBST(MOZ_CAIRO_LIBS)
7980 AC_SUBST(MOZ_CAIRO_OSLIBS)
7981 AC_SUBST(MOZ_TREE_PIXMAN)
7983 dnl ========================================================
7984 dnl qcms
7985 dnl ========================================================
7987 QCMS_LIBS='$(DEPTH)/gfx/qcms/$(LIB_PREFIX)mozqcms.$(LIB_SUFFIX)'
7988 AC_SUBST(QCMS_LIBS)
7990 dnl ========================================================
7991 dnl HarfBuzz
7992 dnl ========================================================
7993 MOZ_HARFBUZZ_LIBS='$(DEPTH)/gfx/harfbuzz/src/$(LIB_PREFIX)mozharfbuzz.$(LIB_SUFFIX)'
7994 AC_SUBST(MOZ_HARFBUZZ_LIBS)
7996 dnl ========================================================
7997 dnl SIL Graphite
7998 dnl ========================================================
7999 if test "$MOZ_GRAPHITE"; then
8000   MOZ_GRAPHITE_LIBS='$(DEPTH)/gfx/graphite2/src/$(LIB_PREFIX)mozgraphite2.$(LIB_SUFFIX)'
8001   AC_DEFINE(MOZ_GRAPHITE)
8002 else
8003   MOZ_GRAPHITE_LIBS=
8005 AC_SUBST(MOZ_GRAPHITE)
8006 AC_SUBST(MOZ_GRAPHITE_LIBS)
8008 dnl ========================================================
8009 dnl OTS
8010 dnl ========================================================
8011 MOZ_OTS_LIBS='$(DEPTH)/gfx/ots/src/$(LIB_PREFIX)mozots.$(LIB_SUFFIX)'
8012 AC_SUBST(MOZ_OTS_LIBS)
8014 dnl ========================================================
8015 dnl Skia 
8016 dnl ========================================================
8017 if test "$MOZ_ENABLE_SKIA"; then
8018   MOZ_SKIA_LIBS='$(DEPTH)/gfx/skia/$(LIB_PREFIX)skia.$(LIB_SUFFIX)'
8019   AC_DEFINE(MOZ_ENABLE_SKIA)
8020 else
8021   MOZ_SKIA_LIBS=
8023 AC_SUBST(MOZ_ENABLE_SKIA)
8024 AC_SUBST(MOZ_SKIA_LIBS)
8026 dnl ========================================================
8027 dnl disable xul
8028 dnl ========================================================
8029 MOZ_ARG_DISABLE_BOOL(xul,
8030 [  --disable-xul           Disable XUL],
8031     MOZ_XUL= )
8032 if test "$MOZ_XUL"; then
8033   AC_DEFINE(MOZ_XUL)
8034 else
8035   dnl remove extensions that require XUL
8036   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/venkman//' -e 's/irc//' -e 's/tasks//'`
8039 AC_SUBST(MOZ_XUL)
8041 dnl ========================================================
8042 dnl disable profile locking
8043 dnl   do no use this in applications that can have more than
8044 dnl   one process accessing the profile directory.
8045 dnl ========================================================
8046 MOZ_ARG_DISABLE_BOOL(profilelocking,
8047 [  --disable-profilelocking
8048                           Disable profile locking],
8049     MOZ_PROFILELOCKING=,
8050     MOZ_PROFILELOCKING=1 )
8051 if test "$MOZ_PROFILELOCKING"; then
8052   AC_DEFINE(MOZ_PROFILELOCKING)
8055 dnl ========================================================
8056 dnl necko configuration options
8057 dnl ========================================================
8060 dnl option to disable various necko protocols
8062 MOZ_ARG_ENABLE_STRING(necko-protocols,
8063 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8064                           Enable/disable specific protocol handlers],
8065 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8066     if test "$option" = "yes" -o "$option" = "all"; then
8067         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8068     elif test "$option" = "no" -o "$option" = "none"; then
8069         NECKO_PROTOCOLS=""
8070     elif test "$option" = "default"; then
8071         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8072     elif test `echo "$option" | grep -c \^-` != 0; then
8073         option=`echo $option | sed 's/^-//'`
8074         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8075     else
8076         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8077     fi
8078 done],
8079     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8080 dnl Remove dupes
8081 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
8082 AC_SUBST(NECKO_PROTOCOLS)
8083 for p in $NECKO_PROTOCOLS; do
8084     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8085     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_PROTOCOL_$p"
8086 done
8089 dnl option to disable necko's wifi scanner
8091 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8092 [  --disable-necko-wifi    Disable necko wifi scanner],
8093     NECKO_WIFI=,
8094     NECKO_WIFI=1)
8096 if test "$OS_ARCH" = "OS2"; then
8097   dnl OS/2 implementation of Necko-WiFi support will be added in bug 506566
8098   NECKO_WIFI=
8100 if test "$NECKO_WIFI" -a \
8101         "$OS_ARCH" != "Linux" -a \
8102         "$OS_ARCH" != "Darwin" -a \
8103         "$OS_ARCH" != "SunOS" -a \
8104         "$OS_ARCH" != "WINNT"; then
8105   AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use --disable-necko-wifi])
8108 if test -z "$SKIP_LIBRARY_CHECKS" -a "$NECKO_WIFI" -a "$OS_ARCH" = "Linux"
8109 then
8110   MOZ_CHECK_HEADER([iwlib.h])
8111   if test "$ac_cv_header_iwlib_h" != "yes"; then
8112     AC_MSG_ERROR([Can't find header iwlib.h for Necko WiFi scanning (might be in package libiw-dev (Ubuntu) or wireless-tools-devel (Fedora) or libiw-devel (openSUSE)); use --disable-necko-wifi to disable])
8113   fi
8116 if test "$NECKO_WIFI"; then
8117   AC_DEFINE(NECKO_WIFI)
8118   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
8120 AC_SUBST(NECKO_WIFI)
8123 dnl option to disable cookies
8125 MOZ_ARG_DISABLE_BOOL(cookies,
8126 [  --disable-cookies       Disable cookie support],
8127     NECKO_COOKIES=,
8128     NECKO_COOKIES=1)
8129 AC_SUBST(NECKO_COOKIES)
8130 if test "$NECKO_COOKIES"; then
8131     AC_DEFINE(NECKO_COOKIES)
8132     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
8136 dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
8138 MOZ_ARG_DISABLE_BOOL(ctypes,
8139 [  --disable-ctypes        Disable js-ctypes],
8140     BUILD_CTYPES=,
8141     BUILD_CTYPES=1)
8142 AC_SUBST(BUILD_CTYPES)
8143 if test "$BUILD_CTYPES"; then
8144     AC_DEFINE(BUILD_CTYPES)
8147 dnl Build Places if required
8148 if test "$MOZ_PLACES"; then
8149   AC_DEFINE(MOZ_PLACES)
8152 dnl Build Apps in the Cloud (AITC) if required
8153 AC_SUBST(MOZ_SERVICES_AITC)
8154 if test -n "$MOZ_SERVICES_AITC"; then
8155   AC_DEFINE(MOZ_SERVICES_AITC)
8158 dnl Build Notifications if required
8159 AC_SUBST(MOZ_SERVICES_NOTIFICATIONS)
8160 if test -n "$MOZ_SERVICES_NOTIFICATIONS"; then
8161   AC_DEFINE(MOZ_SERVICES_NOTIFICATIONS)
8164 dnl Build Sync Services if required
8165 AC_SUBST(MOZ_SERVICES_SYNC)
8166 if test -n "$MOZ_SERVICES_SYNC"; then
8167   AC_DEFINE(MOZ_SERVICES_SYNC)
8170 dnl ========================================================
8171 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
8172     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8175 if test "$MOZ_APP_COMPONENT_INCLUDE"; then
8176   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
8179 if test "$MOZ_APP_COMPONENT_MODULES"; then
8180   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_MODULES, $MOZ_APP_COMPONENT_MODULES)
8183 dnl ========================================================
8184 dnl =
8185 dnl = Maintainer debug option (no --enable equivalent)
8186 dnl =
8187 dnl ========================================================
8189 AC_SUBST(AR)
8190 AC_SUBST(AR_FLAGS)
8191 AC_SUBST(AR_LIST)
8192 AC_SUBST(AR_EXTRACT)
8193 AC_SUBST(AR_DELETE)
8194 AC_SUBST(AS)
8195 AC_SUBST(ASFLAGS)
8196 AC_SUBST(AS_DASH_C_FLAG)
8197 AC_SUBST(LD)
8198 AC_SUBST(RC)
8199 AC_SUBST(RCFLAGS)
8200 AC_SUBST(MC)
8201 AC_SUBST(WINDRES)
8202 AC_SUBST(IMPLIB)
8203 AC_SUBST(FILTER)
8204 AC_SUBST(BIN_FLAGS)
8205 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8206 AC_SUBST(MOZ_UPDATE_XTERM)
8207 AC_SUBST(MOZ_PLATFORM_MAEMO)
8208 AC_SUBST(MOZ_AUTH_EXTENSION)
8209 AC_SUBST(MOZ_PERMISSIONS)
8210 AC_SUBST(MOZ_XTF)
8211 AC_SUBST(MOZ_PREF_EXTENSIONS)
8212 AC_SUBST(MOZ_JS_LIBS)
8213 AC_SUBST(MOZ_PSM)
8214 AC_SUBST(MOZ_DEBUG)
8215 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8216 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8217 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8218 AC_SUBST(MOZ_DEBUG_FLAGS)
8219 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8220 AC_SUBST(WARNINGS_AS_ERRORS)
8221 AC_SUBST(MOZ_EXTENSIONS)
8222 AC_SUBST(MOZ_JSDEBUGGER)
8223 AC_SUBST(MOZ_ENABLE_PROFILER_SPS)
8224 AC_SUBST(MOZ_JPROF)
8225 AC_SUBST(MOZ_SHARK)
8226 AC_SUBST(MOZ_CALLGRIND)
8227 AC_SUBST(MOZ_VTUNE)
8228 AC_SUBST(MOZ_ETW)
8229 AC_SUBST(MOZ_PROFILING)
8230 AC_SUBST(LIBICONV)
8231 AC_SUBST(MOZ_PLACES)
8232 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8233 AC_SUBST(MOZ_FEEDS)
8234 AC_SUBST(NS_PRINTING)
8235 AC_SUBST(MOZ_WEBGL)
8236 AC_SUBST(MOZ_HELP_VIEWER)
8237 AC_SUBST(TOOLCHAIN_PREFIX)
8239 AC_SUBST(JAVA)
8240 AC_SUBST(JAVAC)
8241 AC_SUBST(JAR)
8243 AC_SUBST(MOZ_PROFILELOCKING)
8245 AC_SUBST(ENABLE_TESTS)
8246 AC_SUBST(ENABLE_MARIONETTE)
8247 AC_SUBST(IBMBIDI)
8248 AC_SUBST(MOZ_UNIVERSALCHARDET)
8249 AC_SUBST(ACCESSIBILITY)
8250 AC_SUBST(MOZ_SPELLCHECK)
8251 AC_SUBST(MOZ_JAVA_COMPOSITOR)
8252 AC_SUBST(MOZ_ONLY_TOUCH_EVENTS)
8253 AC_SUBST(MOZ_CRASHREPORTER)
8254 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
8255 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
8256 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
8257 AC_SUBST(MOZ_ENABLE_SIGNMAR)
8258 AC_SUBST(MOZ_UPDATER)
8259 AC_SUBST(MOZ_ANGLE_RENDERER)
8260 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
8261 AC_SUBST(MOZ_DIRECTX_SDK_CPU_SUFFIX)
8262 AC_SUBST(MOZ_D3DX9_VERSION)
8263 AC_SUBST(MOZ_D3DX9_CAB)
8264 AC_SUBST(MOZ_D3DCOMPILER_CAB)
8265 AC_SUBST(MOZ_D3DX9_DLL)
8266 AC_SUBST(MOZ_D3DCOMPILER_DLL)
8267 AC_SUBST(MOZ_METRO)
8269 AC_SUBST(MOZ_ANDROID_HISTORY)
8270 AC_SUBST(MOZ_WEBSMS_BACKEND)
8271 AC_SUBST(ENABLE_STRIP)
8272 AC_SUBST(PKG_SKIP_STRIP)
8273 AC_SUBST(STRIP_FLAGS)
8274 AC_SUBST(USE_ELF_DYNSTR_GC)
8275 AC_SUBST(USE_ELF_HACK)
8276 AC_SUBST(INCREMENTAL_LINKER)
8277 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8278 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8280 AC_SUBST(MOZ_FIX_LINK_PATHS)
8281 AC_SUBST(XPCOM_LIBS)
8282 AC_SUBST(XPCOM_FROZEN_LDOPTS)
8283 AC_SUBST(XPCOM_GLUE_LDOPTS)
8284 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
8285 AC_SUBST(XPCOM_STATICRUNTIME_GLUE_LDOPTS)
8286 AC_SUBST(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS)
8288 AC_SUBST(USE_DEPENDENT_LIBS)
8290 AC_SUBST(MOZ_BUILD_ROOT)
8291 AC_SUBST(MOZ_OS2_TOOLS)
8293 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8294 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8295 AC_SUBST(MOZ_LINKER_EXTRACT)
8296 AC_SUBST(MOZ_PER_WINDOW_PRIVATE_BROWSING)
8298 dnl ========================================================
8299 dnl = Mac bundle name prefix
8300 dnl ========================================================
8301 MOZ_ARG_WITH_STRING(macbundlename-prefix,
8302 [  --with-macbundlename-prefix=prefix
8303                           Prefix for MOZ_MACBUNDLE_NAME],
8304 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
8306 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
8307 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
8308   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
8311 if test "$MOZ_DEBUG"; then
8312   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
8313 else
8314   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
8316 AC_SUBST(MOZ_MACBUNDLE_NAME)
8318 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
8319 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr '[A-Z]' '[a-z]'`
8320 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
8321 if test "$MOZ_DEBUG"; then
8322   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
8325 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
8326 AC_SUBST(MOZ_MACBUNDLE_ID)
8328 # The following variables are available to branding and application
8329 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
8330 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
8331 # impacts profile location and user-visible fields.
8332 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
8333 # versions of a given application (e.g. Aurora and Firefox both use
8334 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
8335 # for application.ini's "Name" field, which controls profile location in
8336 # the absence of a "Profile" field (see below), and various system
8337 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
8338 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
8339 # Mac Bundle name, Updater, Installer), it is typically used for nightly
8340 # builds (e.g. Aurora for Firefox).
8341 # - MOZ_APP_VERSION: Defines the application version number.
8342 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
8343 # defaults to a lowercase form of MOZ_APP_BASENAME.
8344 # - MOZ_APP_PROFILE: When set, used for application.ini's
8345 # "Profile" field, which controls profile location.
8346 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
8347 # crash reporter server url.
8348 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
8349 # - MOZ_EXTENSION_MANAGER: When set, enabled extension manager.
8351 if test -z "$MOZ_APP_NAME"; then
8352    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
8355 # For extensions and langpacks, we require a max version that is compatible
8356 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
8357 # 10.0a1 and 10.0a2 aren't affected
8358 # 10.0 becomes 10.0.*
8359 # 10.0.1 becomes 10.0.*
8360 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
8361 if test -z "$IS_ALPHA"; then
8362   changequote(,)
8363   MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*.[0-9]*\).*|\1|"`.*
8364   changequote([,])
8365 else
8366   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
8369 MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"}
8370 AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION")
8372 AC_SUBST(MOZ_APP_NAME)
8373 AC_SUBST(MOZ_APP_DISPLAYNAME)
8374 AC_SUBST(MOZ_APP_BASENAME)
8375 AC_SUBST(MOZ_APP_VENDOR)
8376 AC_SUBST(MOZ_APP_PROFILE)
8377 AC_SUBST(MOZ_APP_ID)
8378 AC_SUBST(MAR_CHANNEL_ID)
8379 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
8380 AC_SUBST(MOZ_PROFILE_MIGRATOR)
8381 AC_SUBST(MOZ_EXTENSION_MANAGER)
8382 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
8383 AC_SUBST(MOZ_APP_UA_NAME)
8384 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
8385 AC_SUBST(MOZ_APP_VERSION)
8386 AC_SUBST(MOZ_APP_MAXVERSION)
8387 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
8388 AC_SUBST(FIREFOX_VERSION)
8389 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
8390 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
8391   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
8394 # We can't use the static application.ini data when building against
8395 # a libxul SDK.
8396 if test -n "$LIBXUL_SDK"; then
8397     MOZ_APP_STATIC_INI=
8399 AC_SUBST(MOZ_APP_STATIC_INI)
8401 AC_SUBST(MOZ_PKG_SPECIAL)
8403 AC_SUBST(MOZILLA_OFFICIAL)
8405 if test "$MOZ_TELEMETRY_REPORTING"; then
8406     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
8409 dnl win32 options
8410 AC_SUBST(MOZ_MAPINFO)
8411 AC_SUBST(MOZ_BROWSE_INFO)
8412 AC_SUBST(MOZ_TOOLS_DIR)
8413 AC_SUBST(WIN32_REDIST_DIR)
8414 AC_SUBST(MAKENSISU)
8416 dnl Echo the CFLAGS to remove extra whitespace.
8417 CFLAGS=`echo \
8418         $_WARNINGS_CFLAGS \
8419         $CFLAGS`
8421 CXXFLAGS=`echo \
8422         $_WARNINGS_CXXFLAGS \
8423         $CXXFLAGS`
8425 COMPILE_CFLAGS=`echo \
8426     $_DEFINES_CFLAGS \
8427         $_DEPEND_CFLAGS \
8428     $COMPILE_CFLAGS`
8430 COMPILE_CXXFLAGS=`echo \
8431     $_DEFINES_CXXFLAGS \
8432         $_DEPEND_CFLAGS \
8433     $COMPILE_CXXFLAGS`
8435 AC_SUBST(SYSTEM_LIBXUL)
8436 AC_SUBST(MOZ_NATIVE_JPEG)
8437 AC_SUBST(MOZ_NATIVE_PNG)
8438 AC_SUBST(MOZ_NATIVE_BZ2)
8440 AC_SUBST(MOZ_FLEXBOX)
8441 AC_SUBST(MOZ_JPEG_CFLAGS)
8442 AC_SUBST(MOZ_JPEG_LIBS)
8443 AC_SUBST(MOZ_BZ2_CFLAGS)
8444 AC_SUBST(MOZ_BZ2_LIBS)
8445 AC_SUBST(MOZ_PNG_CFLAGS)
8446 AC_SUBST(MOZ_PNG_LIBS)
8448 AC_SUBST(NSPR_CFLAGS)
8449 AC_SUBST(NSPR_LIBS)
8450 AC_SUBST(MOZ_NATIVE_NSPR)
8452 AC_SUBST(NSS_CFLAGS)
8453 AC_SUBST(NSS_LIBS)
8454 AC_SUBST(NSS_DEP_LIBS)
8455 AC_SUBST(MOZ_NATIVE_NSS)
8456 AC_SUBST(NSS_DISABLE_DBM)
8458 OS_CFLAGS="$CFLAGS"
8459 OS_CXXFLAGS="$CXXFLAGS"
8460 OS_CPPFLAGS="$CPPFLAGS"
8461 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
8462 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
8463 OS_LDFLAGS="$LDFLAGS"
8464 OS_LIBS="$LIBS"
8465 AC_SUBST(OS_CFLAGS)
8466 AC_SUBST(OS_CXXFLAGS)
8467 AC_SUBST(OS_CPPFLAGS)
8468 AC_SUBST(OS_COMPILE_CFLAGS)
8469 AC_SUBST(OS_COMPILE_CXXFLAGS)
8470 AC_SUBST(OS_LDFLAGS)
8471 AC_SUBST(OS_LIBS)
8472 AC_SUBST(CROSS_COMPILE)
8473 AC_SUBST(WCHAR_CFLAGS)
8475 AC_SUBST(HOST_CC)
8476 AC_SUBST(HOST_CXX)
8477 AC_SUBST(HOST_CFLAGS)
8478 AC_SUBST(HOST_CXXFLAGS)
8479 AC_SUBST(HOST_LDFLAGS)
8480 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8481 AC_SUBST(HOST_AR)
8482 AC_SUBST(HOST_AR_FLAGS)
8483 AC_SUBST(HOST_LD)
8484 AC_SUBST(HOST_RANLIB)
8485 AC_SUBST(HOST_NSPR_MDCPUCFG)
8486 AC_SUBST(HOST_BIN_SUFFIX)
8487 AC_SUBST(HOST_OS_ARCH)
8489 AC_SUBST(TARGET_CPU)
8490 AC_SUBST(TARGET_VENDOR)
8491 AC_SUBST(TARGET_OS)
8492 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8493 AC_SUBST(TARGET_MD_ARCH)
8494 AC_SUBST(TARGET_XPCOM_ABI)
8495 AC_SUBST(OS_TARGET)
8496 AC_SUBST(OS_ARCH)
8497 AC_SUBST(OS_RELEASE)
8498 AC_SUBST(OS_TEST)
8499 AC_SUBST(CPU_ARCH)
8500 AC_SUBST(INTEL_ARCHITECTURE)
8502 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
8504 AC_SUBST(WRAP_LDFLAGS)
8505 AC_SUBST(MKSHLIB)
8506 AC_SUBST(MKCSHLIB)
8507 AC_SUBST(MKSHLIB_FORCE_ALL)
8508 AC_SUBST(MKSHLIB_UNFORCE_ALL)
8509 AC_SUBST(DSO_CFLAGS)
8510 AC_SUBST(DSO_PIC_CFLAGS)
8511 AC_SUBST(DSO_LDOPTS)
8512 AC_SUBST(LIB_PREFIX)
8513 AC_SUBST(DLL_PREFIX)
8514 AC_SUBST(DLL_SUFFIX)
8515 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
8516 AC_SUBST(LIB_SUFFIX)
8517 AC_SUBST(OBJ_SUFFIX)
8518 AC_SUBST(BIN_SUFFIX)
8519 AC_SUBST(ASM_SUFFIX)
8520 AC_SUBST(IMPORT_LIB_SUFFIX)
8521 AC_SUBST(USE_N32)
8522 AC_SUBST(CC_VERSION)
8523 AC_SUBST(CXX_VERSION)
8524 AC_SUBST(MSMANIFEST_TOOL)
8525 AC_SUBST(NS_ENABLE_TSF)
8526 AC_SUBST(MOZ_NSS_PATCH)
8527 AC_SUBST(MOZ_APP_COMPONENT_LIBS)
8528 AC_SUBST(MOZ_APP_EXTRA_LIBS)
8530 AC_SUBST(MOZ_MEDIA)
8531 AC_SUBST(MOZ_SYDNEYAUDIO)
8532 AC_SUBST(MOZ_SPEEX_RESAMPLER)
8533 AC_SUBST(MOZ_CUBEB)
8534 AC_SUBST(MOZ_WAVE)
8535 AC_SUBST(MOZ_VORBIS)
8536 AC_SUBST(MOZ_TREMOR)
8537 AC_SUBST(MOZ_OPUS)
8538 AC_SUBST(MOZ_WEBM)
8539 AC_SUBST(MOZ_MEDIA_PLUGINS)
8540 AC_SUBST(MOZ_OMX_PLUGIN)
8541 AC_SUBST(MOZ_VP8_ERROR_CONCEALMENT)
8542 AC_SUBST(MOZ_VP8_ENCODER)
8543 AC_SUBST(MOZ_VP8)
8544 AC_SUBST(MOZ_OGG)
8545 AC_SUBST(MOZ_ALSA_LIBS)
8546 AC_SUBST(MOZ_ALSA_CFLAGS)
8547 AC_SUBST(VPX_AS)
8548 AC_SUBST(VPX_ASFLAGS)
8549 AC_SUBST(VPX_DASH_C_FLAG)
8550 AC_SUBST(VPX_AS_CONVERSION)
8551 AC_SUBST(VPX_ASM_SUFFIX)
8552 AC_SUBST(VPX_X86_ASM)
8553 AC_SUBST(VPX_ARM_ASM)
8554 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
8555 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
8556 AC_SUBST(LIBJPEG_TURBO_AS)
8557 AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
8558 AC_SUBST(LIBJPEG_TURBO_X86_ASM)
8559 AC_SUBST(LIBJPEG_TURBO_X64_ASM)
8560 AC_SUBST(LIBJPEG_TURBO_ARM_ASM)
8562 AC_SUBST(MOZ_PACKAGE_JSSHELL)
8564 AC_MSG_CHECKING([for posix_fallocate])
8565 AC_TRY_LINK([#define _XOPEN_SOURCE 600
8566   #include <fcntl.h>],
8567                  [posix_fallocate(0, 0, 0);],
8568                  [ac_cv___posix_fallocate=true],
8569                  [ac_cv___posix_fallocate=false])
8571 if test "$ac_cv___posix_fallocate" = true ; then
8572   AC_DEFINE(HAVE_POSIX_FALLOCATE)
8573   AC_MSG_RESULT(yes)
8574 else
8575   AC_MSG_RESULT(no)
8578 dnl Check for missing components
8579 if test "$COMPILE_ENVIRONMENT"; then
8580 if test "$MOZ_X11"; then
8581     if test "$WITHOUT_X11"; then
8582         AC_MSG_ERROR([--without-x specified and MOZ_X11 still defined])
8583     fi
8584     dnl ====================================================
8585     dnl = Check if X headers exist
8586     dnl ====================================================
8587     _SAVE_CFLAGS=$CFLAGS
8588     CFLAGS="$CFLAGS $XCFLAGS"
8589     AC_TRY_COMPILE([
8590         #include <stdio.h>
8591         #include <stdlib.h>
8592         #include <X11/Xlib.h>
8593         #include <X11/Intrinsic.h>
8594         #include <X11/extensions/XShm.h>
8595     ],
8596     [
8597         Display *dpy = 0;
8598         if ((dpy = XOpenDisplay(NULL)) == NULL) {
8599             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
8600             exit(1);
8601         }
8602     ], [],
8603     [ AC_MSG_ERROR([Could not compile basic X program.]) ])
8604     CFLAGS="$_SAVE_CFLAGS"
8606     if test -n "$MISSING_X"; then
8607         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
8608     fi
8610 fi # MOZ_X11
8612 dnl Check for headers, etc. needed by WebGL.
8613 if test "$MOZ_GL_DEFAULT_PROVIDER" = "GLX"; then
8614     MOZ_CHECK_HEADER(GL/glx.h)
8615     if test "$ac_cv_header_GL_glx_h" != "yes"; then
8616         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))])
8617     fi
8618 fi # MOZ_GL_DEFAULT_PROVIDER=GLX
8619 fi # COMPILE_ENVIRONMENT
8621 dnl Set various defines and substitutions
8622 dnl ========================================================
8624 if test "$OS_ARCH" = "Darwin"; then
8625   AC_DEFINE(XP_UNIX)
8626 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2"; then
8627   AC_DEFINE(XP_UNIX)
8630 if test "$MOZ_DEBUG"; then
8631     AC_DEFINE(MOZ_REFLOW_PERF)
8632     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
8635 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then
8636     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
8637     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
8638     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
8639     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
8640     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
8641     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
8642     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
8643     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
8646 AC_SUBST(MOZILLA_VERSION)
8648 AC_SUBST(ac_configure_args)
8650 dnl Spit out some output
8651 dnl ========================================================
8653 dnl The following defines are used by xpcom
8654 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
8655 CPP_THROW_NEW
8656 HAVE_CPP_2BYTE_WCHAR_T
8657 HAVE_CPP_AMBIGUITY_RESOLVING_USING
8658 HAVE_CPP_CHAR16_T
8659 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
8660 HAVE_CPP_PARTIAL_SPECIALIZATION
8661 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
8662 NEED_CPP_UNUSED_IMPLEMENTATIONS
8663 NEW_H
8664 HAVE_GETPAGESIZE
8665 HAVE_ICONV
8666 HAVE_ICONV_WITH_CONST_INPUT
8667 HAVE_MBRTOWC
8668 HAVE_WCRTOMB
8669 HAVE_STATVFS64
8670 HAVE_STATVFS
8671 HAVE_STATFS64
8672 HAVE_STATFS
8673 HAVE_SYS_STATVFS_H
8674 HAVE_SYS_STATFS_H
8675 HAVE_SYS_VFS_H
8676 HAVE_SYS_MOUNT_H
8679 AC_CONFIG_HEADER(
8680 netwerk/necko-config.h
8681 xpcom/xpcom-config.h
8682 xpcom/xpcom-private.h
8685 # Hack around an Apple bug that affects the egrep that comes with OS X 10.7.
8686 # "env ARCHPREFERENCE=i386,x86_64 arch egrep" first tries to use the 32-bit
8687 # Intel part of the egrep fat binary, even on 64-bit systems, and falls back on
8688 # the 64-bit part if it's not a fat binary, as can happen with MacPorts. We
8689 # (apparently) only need this hack when egrep's "pattern" is particularly long
8690 # (as in the following code) and the first egrep on our $PATH is Apple's.  See
8691 # bug 655339.
8692 case "$host" in
8693 *-apple-darwin11*)
8694     FIXED_EGREP="env ARCHPREFERENCE=i386,x86_64 arch egrep"
8695     ;;
8697     FIXED_EGREP="egrep"
8698     ;;
8699 esac
8701 dnl Create a virtualenv where we can install local Python packages
8702 AC_MSG_RESULT([Creating Python virtualenv])
8703 rm -rf _virtualenv
8704 mkdir -p _virtualenv
8705 MACOSX_DEPLOYMENT_TARGET= PYTHONDONTWRITEBYTECODE= $PYTHON $_topsrcdir/python/virtualenv/virtualenv.py --system-site-packages ./_virtualenv
8706 case "$host_os" in
8707 mingw*)
8708     PYTHON=$MOZ_BUILD_ROOT/_virtualenv/Scripts/python.exe
8709     ;;
8711     PYTHON=$MOZ_BUILD_ROOT/_virtualenv/bin/python
8712     ;;
8713 esac
8715 AC_SUBST(PYTHON)
8717 dnl Populate the virtualenv
8719 dnl We always use the version Python was compiled with to ensure that compiled
8720 dnl extensions work properly. This works around a bug in Python. See also
8721 dnl http://bugs.python.org/issue9516 and bug 659881.
8723 dnl Please note that this assumes nothing built during virtualenv population is
8724 dnl shipped as part of a release package. If it does ship, binaries built here
8725 dnl may not be compatible with the minimum supported OS X version.
8726 osx_deployment_target_system=
8728 if test $python_version_major -ne 2; then
8729     AC_MSG_ERROR([Assertion failed: building with Python 2.])
8732 dnl sysconfig is only present on Python 2.7 and above.
8733 if test $python_version_minor -ge 7; then
8734     osx_deployment_target_system=`$PYTHON -c 'import sysconfig; print sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET")'`
8737 AC_MSG_RESULT([Populating Python virtualenv])
8738 MACOSX_DEPLOYMENT_TARGET=$osx_deployment_target_system \
8739   LDFLAGS="${HOST_LDFLAGS}" \
8740   CC="${HOST_CC}" CXX="${HOST_CXX}" \
8741   CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}" \
8742   $PYTHON $_topsrcdir/build/virtualenv/populate_virtualenv.py \
8743     $_topsrcdir $_topsrcdir/build/virtualenv/packages.txt \
8744   || exit 1
8746 dnl Load the list of Makefiles to generate.
8747 dnl   To add new Makefiles, edit allmakefiles.sh.
8748 dnl   allmakefiles.sh sets the variable, MAKEFILES.
8749 . ${srcdir}/allmakefiles.sh
8751 echo $MAKEFILES > unallmakefiles
8753 AC_OUTPUT($MAKEFILES)
8755 # Generate Makefiles for WebRTC directly from .gyp files
8756 if test "${OS_TARGET}" = "WINNT"; then
8757    if test "$HAVE_64BIT_OS"; then
8758       OS_BITS=64
8759    else
8760       OS_BITS=32
8761    fi
8762    EXTRA_GYP_DEFINES="-D MSVS_VERSION=${_MSVS_VERSION} -D MSVS_OS_BITS=${OS_BITS}"
8765 if test -n "$MOZ_WEBRTC"; then
8766    AC_MSG_RESULT("generating WebRTC Makefiles...")
8768    GYP_WEBRTC_OPTIONS="--format=mozmake -D build_with_mozilla=1 -D enable_protobuf=0 -D include_internal_video_render=0 ${EXTRA_GYP_DEFINES} --depth=${srcdir}/media/webrtc/trunk --toplevel-dir=${srcdir} -G OBJDIR=${_objdir}"
8770    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
8771      $GYP_WEBRTC_OPTIONS \
8772      --generator-output=${_objdir}/media/webrtc/trunk \
8773      ${srcdir}/media/webrtc/trunk/peerconnection.gyp
8774    if test "$?" != 0; then
8775       AC_MSG_ERROR([failed to generate WebRTC Makefiles])
8776    fi
8778    # XXX disable until we land the tranche with signaling
8779    if test -n "$MOZ_WEBRTC_SIGNALING"; then
8780      AC_MSG_RESULT("generating WebRTC/Signaling Makefiles...")
8781      $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
8782        $GYP_WEBRTC_OPTIONS \
8783        --generator-output=${_objdir}/media/webrtc/signaling \
8784        ${srcdir}/media/webrtc/signaling/signaling.gyp
8785      if test "$?" != 0; then
8786         AC_MSG_ERROR([failed to generate WebRTC/Signaling Makefiles])
8787      fi
8788    fi
8790    AC_MSG_RESULT("generating gtest Makefiles...")
8791    # Ok to pass some extra -D's that are ignored here
8792    $PYTHON ${srcdir}/media/webrtc/trunk/build/gyp_chromium \
8793      $GYP_WEBRTC_OPTIONS \
8794      --generator-output=${_objdir}/media/webrtc/trunk/testing/ \
8795      ${srcdir}/media/webrtc/trunk/testing/gtest.gyp
8796    if test "$?" != 0; then
8797       AC_MSG_ERROR([failed to generate gtest Makefiles])
8798    fi
8801 # Generate a JSON config file for unittest harnesses etc to read
8802 # build configuration details from in a standardized way.
8803 OS_TARGET=${OS_TARGET} \
8804 TARGET_CPU=${TARGET_CPU} \
8805 MOZ_DEBUG=${MOZ_DEBUG} \
8806 MOZ_WIDGET_TOOLKIT=${MOZ_WIDGET_TOOLKIT} \
8807 UNIVERSAL_BINARY=${UNIVERSAL_BINARY} \
8808 MOZ_CRASHREPORTER=${MOZ_CRASHREPORTER} \
8809   $PYTHON ${_topsrcdir}/config/writemozinfo.py ./mozinfo.json.tmp
8810 if cmp -s ./mozinfo.json.tmp ./mozinfo.json; then
8811   rm ./mozinfo.json.tmp
8812 else
8813   mv -f ./mozinfo.json.tmp ./mozinfo.json
8816 # Run jemalloc configure script
8818 if test "$MOZ_JEMALLOC" -a "$MOZ_MEMORY"; then
8819   ac_configure_args="$_SUBDIR_CONFIG_ARGS --build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
8820   if test "$OS_ARCH" = "Linux"; then
8821     MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
8822     MANGLED=
8823     JEMALLOC_WRAPPER=
8824     if test -n "$_WRAP_MALLOC"; then
8825       JEMALLOC_WRAPPER=__wrap_
8826     fi
8827     for mangle in ${MANGLE}; do
8828       if test -n "$MANGLED"; then
8829         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle,$MANGLED"
8830       else
8831         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle"
8832       fi
8833     done
8834     ac_configure_args="$ac_configure_args --with-mangling=$MANGLED"
8835   fi
8836   unset CONFIG_FILES
8837   if test -z "$MOZ_TLS"; then
8838     ac_configure_args="$ac_configure_args --disable-tls"
8839   fi
8840   EXTRA_CFLAGS="$CFLAGS"
8841   for var in AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS EXTRA_CFLAGS LDFLAGS; do
8842     ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
8843   done
8844   if test "$CROSS_COMPILE"; then
8845     ac_configure_args="$ac_configure_args je_cv_static_page_shift=12"
8846   fi
8847   _save_cache_file="$cache_file"
8848   cache_file=$_objdir/memory/jemalloc/src/config.cache
8849   AC_OUTPUT_SUBDIRS(memory/jemalloc/src)
8850   cache_file="$_save_cache_file"
8851   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
8854 dnl Build libunwind for Android profiling builds
8855 if test "$OS_TARGET" = "Android" -a "$MOZ_PROFILING"; then
8856   old_ac_configure_arg="$ac_configure_args"
8857   ac_configure_args="--build=${build} --host=${target_alias} --disable-shared --enable-block-signals=no"
8858   if test "$MOZ_DEBUG"; then
8859     ac_configure_args="$ac_configure_args --enable-debug"
8860   fi
8861   if test "$DSO_PIC_CFLAGS"; then
8862     ac_configure_args="$ac_configure_args --with-pic"
8863   fi
8864   ac_configure_args="$ac_configure_args \
8865       CC=\"$CC\" \
8866       CXX=\"$CXX\" \
8867       CPP=\"$CPP\" \
8868       CFLAGS=\"$CFLAGS\" \
8869       CXXFLAGS=\"$CXXFLAGS\" \
8870       CPPFLAGS=\"$CPPFLAGS\" \
8871       LD=\"$LD\" \
8872       LDFLAGS=\"$LDFLAGS\" \
8873       AR=\"$AR\" \
8874       RANLIB=\"$RANLIB\" \
8875       STRIP=\"$STRIP\" \
8876       LIBS=\"$LIBS\""
8878   # Use a separate cache file for libunwind, since it does not use caching.
8879   mkdir -p $_objdir/tools/profiler/libunwind/src
8880   old_cache_file=$cache_file
8881   cache_file=$_objdir/tools/profiler/libunwind/src/config.cache
8882   old_config_files=$CONFIG_FILES
8883   unset CONFIG_FILES
8884   AC_OUTPUT_SUBDIRS(tools/profiler/libunwind/src)
8885   cache_file=$old_cache_file
8886   ac_configure_args="$old_ac_configure_args"
8887   CONFIG_FILES=$old_config_files
8890 # Run freetype configure script
8892 if test "$MOZ_TREE_FREETYPE"; then
8893    export CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS -std=c99"
8894    export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS"
8895    export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS"
8896    export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS"
8897    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
8898    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes"
8899    AC_OUTPUT_SUBDIRS(modules/freetype2)
8902 if test -z "$direct_nspr_config"; then
8903     dnl ========================================================
8904     dnl = Setup a nice relatively clean build environment for
8905     dnl = sub-configures.
8906     dnl ========================================================
8907     CC="$_SUBDIR_CC"
8908     CXX="$_SUBDIR_CXX"
8909     CFLAGS="$_SUBDIR_CFLAGS"
8910     CPPFLAGS="$_SUBDIR_CPPFLAGS"
8911     CXXFLAGS="$_SUBDIR_CXXFLAGS"
8912     LDFLAGS="$_SUBDIR_LDFLAGS"
8913     HOST_CC="$_SUBDIR_HOST_CC"
8914     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
8915     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
8916     RC=
8919 unset MAKEFILES
8920 unset CONFIG_FILES
8922 # No need to run subconfigures when building with LIBXUL_SDK_DIR
8923 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
8925 export WRAP_LDFLAGS
8927 if test -n "$_WRAP_MALLOC"; then
8928     # Avoid doubling wrap malloc arguments
8929     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
8932 if test -z "$MOZ_NATIVE_NSPR"; then
8933     ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
8934     if test -z "$MOZ_DEBUG"; then
8935         ac_configure_args="$ac_configure_args --disable-debug"
8936     else
8937         ac_configure_args="$ac_configure_args --enable-debug"
8938     fi
8939     if test "$MOZ_OPTIMIZE" = "1"; then
8940         ac_configure_args="$ac_configure_args --enable-optimize"
8941     elif test -z "$MOZ_OPTIMIZE"; then
8942         ac_configure_args="$ac_configure_args --disable-optimize"
8943     fi
8944     if test -n "$HAVE_64BIT_OS"; then
8945         ac_configure_args="$ac_configure_args --enable-64bit"
8946     fi
8947     if test -n "$USE_ARM_KUSER"; then
8948         ac_configure_args="$ac_configure_args --with-arm-kuser"
8949     fi
8950     ac_configure_args="$ac_configure_args $NSPR_CONFIGURE_ARGS"
8951     if test -n "$MOZ_LINKER" -a -z "$MOZ_OLD_LINKER" -a "$ac_cv_func_dladdr" = no ; then
8952       # dladdr is supported by the new linker, even when the system linker doesn't
8953       # support it. Trick nspr into using dladdr when it's not supported.
8954       _SAVE_CPPFLAGS="$CPPFLAGS"
8955       export CPPFLAGS="-include $_topsrcdir/mozglue/linker/dladdr.h $CPPFLAGS"
8956     fi
8957     _SAVE_LDFLAGS="$LDFLAGS"
8958     export LDFLAGS="$LDFLAGS $NSPR_LDFLAGS"
8959     AC_OUTPUT_SUBDIRS(nsprpub)
8960     LDFLAGS="$_SAVE_LDFLAGS"
8961     if test -n "$MOZ_LINKER" -a -z "$MOZ_OLD_LINKER" -a "$ac_cv_func_dladdr" = no; then
8962       unset CPPFLAGS
8963       CPPFLAGS="$_SAVE_CFLAGS"
8964     fi
8965     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
8968 dnl ========================================================
8969 dnl = Setup a nice relatively clean build environment for
8970 dnl = sub-configures.
8971 dnl ========================================================
8972 CC="$_SUBDIR_CC"
8973 CXX="$_SUBDIR_CXX"
8974 CFLAGS="$_SUBDIR_CFLAGS"
8975 CPPFLAGS="$_SUBDIR_CPPFLAGS"
8976 CXXFLAGS="$_SUBDIR_CXXFLAGS"
8977 LDFLAGS="$_SUBDIR_LDFLAGS"
8978 HOST_CC="$_SUBDIR_HOST_CC"
8979 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
8980 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
8983 # Run the SpiderMonkey 'configure' script.
8984 dist=$MOZ_BUILD_ROOT/dist
8985 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
8986 ac_configure_args="$ac_configure_args --enable-threadsafe"
8987 if test "$BUILD_CTYPES"; then
8988     # Build js-ctypes on the platforms we can.
8989     ac_configure_args="$ac_configure_args --enable-ctypes"
8991 if test -z "$JS_SHARED_LIBRARY" ; then
8992     ac_configure_args="$ac_configure_args --disable-shared-js"
8994 if test -z "$MOZ_NATIVE_NSPR"; then
8995     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
8996     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
8998 ac_configure_args="$ac_configure_args --with-dist-dir=../../dist"
8999 ac_configure_args="$ac_configure_args --prefix=$dist"
9000 if test "$MOZ_MEMORY"; then
9001    ac_configure_args="$ac_configure_args --enable-jemalloc"
9003 if test -n "$MOZ_GLUE_LDFLAGS"; then
9004    export MOZ_GLUE_LDFLAGS
9006 if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
9007    export MOZ_GLUE_PROGRAM_LDFLAGS
9009 if test "$MOZ_NATIVE_ZLIB" != 1 -a "$OS_ARCH" = "WINNT"; then
9010    MOZ_ZLIB_LIBS=
9012 export MOZ_NATIVE_ZLIB
9013 export MOZ_ZLIB_CFLAGS
9014 export MOZ_ZLIB_LIBS
9015 export MOZ_APP_NAME
9016 export STLPORT_CPPFLAGS
9017 export STLPORT_LDFLAGS
9018 export STLPORT_LIBS
9019 AC_OUTPUT_SUBDIRS(js/src)
9020 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9022 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR