Bug 994903 - Copy mRecycleCallback on top of Release() r=jrmuizel
[gecko.git] / configure.in
blob0d388476e204db061e3da57fc356a8195926de4d
2 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
3 dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4:
4 dnl This Source Code Form is subject to the terms of the Mozilla Public
5 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
6 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 dnl Process this file with autoconf to produce a configure script.
9 dnl ========================================================
11 AC_PREREQ(2.13)
12 AC_INIT(config/config.mk)
13 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
14 AC_CANONICAL_SYSTEM
15 TARGET_CPU="${target_cpu}"
16 TARGET_VENDOR="${target_vendor}"
17 TARGET_OS="${target_os}"
19 dnl ========================================================
20 dnl =
21 dnl = Don't change the following two lines.  Doing so breaks:
22 dnl =
23 dnl = CFLAGS="-foo" ./configure
24 dnl =
25 dnl ========================================================
26 CFLAGS="${CFLAGS=}"
27 CPPFLAGS="${CPPFLAGS=}"
28 CXXFLAGS="${CXXFLAGS=}"
29 LDFLAGS="${LDFLAGS=}"
30 HOST_CFLAGS="${HOST_CFLAGS=}"
31 HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
32 HOST_LDFLAGS="${HOST_LDFLAGS=}"
34 dnl ========================================================
35 dnl = Preserve certain environment flags passed to configure
36 dnl = We want sub projects to receive the same flags
37 dnl = untainted by this configure script
38 dnl ========================================================
39 _SUBDIR_CC="$CC"
40 _SUBDIR_CXX="$CXX"
41 _SUBDIR_CFLAGS="$CFLAGS"
42 _SUBDIR_CPPFLAGS="$CPPFLAGS"
43 _SUBDIR_CXXFLAGS="$CXXFLAGS"
44 _SUBDIR_LDFLAGS="$LDFLAGS"
45 _SUBDIR_HOST_CC="$HOST_CC"
46 _SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
47 _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
48 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
49 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
51 dnl Set the version number of the libs included with mozilla
52 dnl ========================================================
53 MOZJPEG=62
54 MOZPNG=10610
55 NSPR_VERSION=4
56 NSS_VERSION=3
58 dnl Set the minimum version of toolkit libs used by mozilla
59 dnl ========================================================
60 GLIB_VERSION=1.2.0
61 PERL_VERSION=5.006
62 CAIRO_VERSION=1.10
63 PANGO_VERSION=1.22.0
64 GTK2_VERSION=2.10.0
65 GTK3_VERSION=3.0.0
66 WINDRES_VERSION=2.14.90
67 W32API_VERSION=3.14
68 GNOMEVFS_VERSION=2.0
69 GNOMEUI_VERSION=2.2.0
70 GCONF_VERSION=1.2.1
71 GIO_VERSION=2.20
72 STARTUP_NOTIFICATION_VERSION=0.8
73 DBUS_VERSION=0.60
74 SQLITE_VERSION=3.8.4.2
76 MSMANIFEST_TOOL=
78 dnl Set various checks
79 dnl ========================================================
80 MISSING_X=
81 AC_PROG_AWK
83 dnl Initialize the Pthread test variables early so they can be
84 dnl  overridden by each platform.
85 dnl ========================================================
86 MOZ_USE_PTHREADS=
87 _PTHREAD_LDFLAGS=""
89 dnl Do not allow objdir == srcdir builds.
90 dnl ==============================================================
91 _topsrcdir=`cd \`dirname $0\`; pwd`
92 _objdir=`pwd`
95 dnl TODO Don't exempt L10N builds once bug 842760 is resolved.
96 if test "$_topsrcdir" = "$_objdir" -a "${with_l10n_base+set}" != set; then
97   echo "  ***"
98   echo "  * Building directly in the main source directory is not allowed."
99   echo "  *"
100   echo "  * To build, you must run configure from a separate directory"
101   echo "  * (referred to as an object directory)."
102   echo "  *"
103   echo "  * If you are building with a mozconfig, you will need to change your"
104   echo "  * mozconfig to point to a different object directory."
105   echo "  ***"
106   exit 1
109 # Check for a couple representative files in the source tree
110 _conflict_files=
111 for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
112   if test -f $file; then
113     _conflict_files="$_conflict_files $file"
114   fi
115 done
116 if test "$_conflict_files"; then
117   echo "***"
118   echo "*   Your source tree contains these files:"
119   for file in $_conflict_files; do
120     echo "*         $file"
121   done
122   cat 1>&2 <<-EOF
123   *   This indicates that you previously built in the source tree.
124   *   A source tree build can confuse the separate objdir build.
125   *
126   *   To clean up the source tree:
127   *     1. cd $_topsrcdir
128   *     2. gmake distclean
129   ***
131   exit 1
132   break
134 MOZ_BUILD_ROOT=`pwd`
136 MOZ_PYTHON
138 MOZ_DEFAULT_COMPILER
140 COMPILE_ENVIRONMENT=1
141 MOZ_ARG_DISABLE_BOOL(compile-environment,
142 [  --disable-compile-environment
143                           Disable compiler/library checks.],
144     COMPILE_ENVIRONMENT= )
145 AC_SUBST(COMPILE_ENVIRONMENT)
147 MOZ_ARG_WITH_STRING(l10n-base,
148 [  --with-l10n-base=DIR    path to l10n repositories],
149     L10NBASEDIR=$withval)
150 if test -n "$L10NBASEDIR"; then
151     if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
152         AC_MSG_ERROR([--with-l10n-base must specify a path])
153     elif test -d "$L10NBASEDIR"; then
154         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd`
155     else
156         AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
157     fi
159 AC_SUBST(L10NBASEDIR)
161 dnl Check for Perl first -- needed for win32 SDK checks
162 MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
163 if test -z "$PERL" -o "$PERL" = ":"; then
164     AC_MSG_ERROR([perl not found in \$PATH])
167 if test -n "$GAIADIR" -a ! -d "$GAIADIR" ; then
168     AC_MSG_ERROR([GAIADIR '$GAIADIR' isn't a valid directory])
171 AC_SUBST(GAIADIR)
172 if test -n "$GAIADIR" ; then
173     AC_DEFINE(PACKAGE_GAIA)
176 if test -n "$FXOS_SIMULATOR" -a -z "$GAIADIR" ; then
177     AC_MSG_ERROR([FXOS_SIMULATOR=1 requires GAIADIR to be defined])
180 if test -n "$FXOS_SIMULATOR" ; then
181     AC_DEFINE(FXOS_SIMULATOR)
182     AC_SUBST(FXOS_SIMULATOR)
185 MOZ_ARG_WITH_STRING(gonk,
186 [  --with-gonk=DIR
187                location of gonk dir],
188     gonkdir=$withval)
190 MOZ_ARG_WITH_STRING(gonk-toolchain-prefix,
191 [  --with-gonk-toolchain-prefix=DIR
192                           prefix to gonk toolchain commands],
193     gonk_toolchain_prefix=$withval)
195 if test -n "$gonkdir" ; then
196     kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
197     android_source="$gonkdir"
198     ANDROID_SOURCE="$android_source"
199     ANDROID_NDK="${ANDROID_SOURCE}/ndk"
200     dnl Default to ICS
201     ANDROID_VERSION=15
202     if test -n "${PLATFORM_SDK_VERSION}"; then
203         ANDROID_VERSION="${PLATFORM_SDK_VERSION}"
204     fi
206     dnl set up compilers
207     TOOLCHAIN_PREFIX="$gonk_toolchain_prefix"
208     AS="$gonk_toolchain_prefix"as
209     CC="$gonk_toolchain_prefix"gcc
210     CXX="$gonk_toolchain_prefix"g++
211     CPP="$gonk_toolchain_prefix"cpp
212     LD="$gonk_toolchain_prefix"ld
213     AR="$gonk_toolchain_prefix"ar
214     RANLIB="$gonk_toolchain_prefix"ranlib
215     STRIP="$gonk_toolchain_prefix"strip
216     OBJCOPY="$gonk_toolchain_prefix"objcopy
218     if ! test -e "$gonkdir/ndk/sources/cxx-stl/stlport/src/iostream.cpp"; then
219         AC_MSG_ERROR([Couldn't find path to stlport sources in the gonk tree])
220     fi
221     STLPORT_CPPFLAGS="-I$_topsrcdir/build/stlport/stlport -I$gonkdir/ndk/sources/cxx-stl/system/include"
222     STLPORT_LIBS="$_objdir/build/stlport/libstlport_static.a"
224     case "$target_cpu" in
225     arm)
226         ARCH_DIR=arch-arm
227         ;;
228     i?86)
229         ARCH_DIR=arch-x86
230         ;;
231     esac
233     case "$ANDROID_VERSION" in
234     15)
235         GONK_INCLUDES="-I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/frameworks/base/include -I$gonkdir/frameworks/base/services/camera -I$gonkdir/frameworks/base/include/media/ -I$gonkdir/frameworks/base/include/media/stagefright -I$gonkdir/frameworks/base/include/media/stagefright/openmax -I$gonkdir/frameworks/base/media/libstagefright/rtsp -I$gonkdir/frameworks/base/media/libstagefright/include -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib -I$gonkdir/dalvik/libnativehelper/include/nativehelper"
236         MOZ_B2G_BT=1
237         MOZ_B2G_BT_BLUEZ=1
238         MOZ_NFC=1
239         MOZ_B2G_CAMERA=1
240         MOZ_OMX_DECODER=1
241         AC_SUBST(MOZ_OMX_DECODER)
242         MOZ_RTSP=1
243         ;;
244     17|18)
245         GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include"
246         if test -d "$gonkdir/external/bluetooth/bluez"; then
247           GONK_INCLUDES="$GONK_INCLUDES -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib"
248             MOZ_B2G_BT=1
249             MOZ_B2G_BT_BLUEZ=1
250         elif test -d "$gonkdir/external/bluetooth/bluedroid"; then
251             MOZ_B2G_BT=1
252             MOZ_B2G_BT_BLUEDROID=1
253         fi
255         MOZ_RTSP=1
256         MOZ_NFC=1
257         MOZ_B2G_CAMERA=1
258         MOZ_OMX_DECODER=1
259         AC_SUBST(MOZ_OMX_DECODER)
260         MOZ_OMX_ENCODER=1
261         AC_SUBST(MOZ_OMX_ENCODER)
262         AC_DEFINE(MOZ_OMX_ENCODER)
263         ;;
264     19)
265         GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include"
266         MOZ_B2G_CAMERA=1
267         MOZ_B2G_BT=1
268         MOZ_B2G_BT_BLUEDROID=1
269         MOZ_NFC=1
270         MOZ_RTSP=1
271         MOZ_OMX_DECODER=1
272         MOZ_OMX_ENCODER=1
273         AC_DEFINE(MOZ_OMX_ENCODER)
274         MOZ_AUDIO_OFFLOAD=1
275         AC_SUBST(MOZ_AUDIO_OFFLOAD)
276         AC_DEFINE(MOZ_AUDIO_OFFLOAD)
278         ;;
279     *)
280         AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION])
281         ;;
282     esac
283     CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/$ARCH_DIR/include -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/kernel/$ARCH_DIR -isystem $gonkdir/bionic/libm/include -I$gonkdir/system -I$gonkdir/system/core/include -isystem $gonkdir/bionic -I$gonkdir/hardware/libhardware/include -I$gonkdir/external/valgrind/fxos-include $GONK_INCLUDES $CPPFLAGS"
284     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
285     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS $STLPORT_CPPFLAGS"
286     dnl Add -llog by default, since we use it all over the place.
287     LIBS="$LIBS -llog"
289     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"
291     dnl prevent cross compile section from using these flags as host flags
292     if test -z "$HOST_CPPFLAGS" ; then
293         HOST_CPPFLAGS=" "
294     fi
295     if test -z "$HOST_CFLAGS" ; then
296         HOST_CFLAGS=" "
297     fi
298     if test -z "$HOST_CXXFLAGS" ; then
299         HOST_CXXFLAGS=" "
300     fi
301     if test -z "$HOST_LDFLAGS" ; then
302         HOST_LDFLAGS=" "
303     fi
305     AC_DEFINE(ANDROID)
306     AC_DEFINE_UNQUOTED(ANDROID_VERSION, $ANDROID_VERSION)
307     AC_SUBST(ANDROID_VERSION)
308     AC_DEFINE(HAVE_SYS_UIO_H)
309     AC_DEFINE(HAVE_PTHREADS)
310     MOZ_CHROME_FILE_FORMAT=omni
311     direct_nspr_config=1
312 else
313     MOZ_ANDROID_NDK
315     case "$target" in
316     *-android*|*-linuxandroid*)
317         if test -z "$ANDROID_PACKAGE_NAME" ; then
318             ANDROID_PACKAGE_NAME='org.mozilla.$(MOZ_APP_NAME)'
319         fi
320         MOZ_CHROME_FILE_FORMAT=omni
321         ZLIB_DIR=yes
322         ;;
323     *-linux*)
324         AC_PATH_PROG(OBJCOPY,objcopy)
325         ;;
326     esac
329 AC_SUBST(ANDROID_SOURCE)
330 AC_SUBST(ANDROID_PACKAGE_NAME)
331 AC_SUBST(OBJCOPY)
333 dnl ========================================================
334 dnl Checks for compilers.
335 dnl ========================================================
337 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
338 AR_FLAGS='crs $@'
340 if test "$COMPILE_ENVIRONMENT"; then
342 if test "$target" != "$host"; then
343     MOZ_CROSS_COMPILER
344 else
345     AC_PROG_CC
346     case "$target" in
347     *-mingw*)
348       # Work around the conftest.exe access problem on Windows
349       sleep 2
350     esac
351     AC_PROG_CXX
352     AC_PROG_RANLIB
353     MOZ_PATH_PROGS(AS, $AS as, $CC)
354     AC_CHECK_PROGS(AR, ar, :)
355     AC_CHECK_PROGS(LD, ld, :)
356     AC_CHECK_PROGS(STRIP, strip, :)
357     AC_CHECK_PROGS(WINDRES, windres, :)
358     if test -z "$HOST_CC"; then
359         HOST_CC="$CC"
360     fi
361     if test -z "$HOST_CFLAGS"; then
362         HOST_CFLAGS="$CFLAGS"
363     fi
364     if test -z "$HOST_CXX"; then
365         HOST_CXX="$CXX"
366     fi
367     if test -z "$HOST_CXXFLAGS"; then
368         HOST_CXXFLAGS="$CXXFLAGS"
369     fi
370     if test -z "$HOST_LDFLAGS"; then
371         HOST_LDFLAGS="$LDFLAGS"
372     fi
373     if test -z "$HOST_RANLIB"; then
374         HOST_RANLIB="$RANLIB"
375     fi
376     if test -z "$HOST_AR"; then
377         HOST_AR="$AR"
378     fi
379     if test -z "$HOST_AR_FLAGS"; then
380         HOST_AR_FLAGS="$AR_FLAGS"
381     fi
384 if test -n "$MOZ_WINCONSOLE"; then
385     AC_DEFINE(MOZ_WINCONSOLE)
388 MOZ_TOOL_VARIABLES
390 MOZ_CHECK_COMPILER_WRAPPER
392 if test -n "$GNU_CC" -a -z "$CLANG_CC" ; then
393     if test "$GCC_MAJOR_VERSION" -eq 4 -a "$GCC_MINOR_VERSION" -lt 4 ||
394        test "$GCC_MAJOR_VERSION" -lt 4; then
395         AC_MSG_ERROR([Only GCC 4.4 or newer supported])
396     fi
399 dnl ========================================================
400 dnl Special win32 checks
401 dnl ========================================================
403 MOZ_ARG_ENABLE_BOOL(metro,
404 [  --enable-metro           Enable Windows Metro build targets],
405     MOZ_METRO=1,
406     MOZ_METRO=)
407 if test -n "$MOZ_METRO"; then
408     AC_DEFINE(MOZ_METRO)
409     # Target the Windows 8 Kit
410     WINSDK_TARGETVER=602
411     WINVER=502
412     # toolkit/library/makefile.in needs these, see nsDllMain.
413     CRTDLLVERSION=110
414     CRTEXPDLLVERSION=1-1-0
415 else
416     # Target the Windows 7 SDK by default
417     WINSDK_TARGETVER=601
418     WINVER=502
421 AC_SUBST(CRTDLLVERSION)
422 AC_SUBST(CRTEXPDLLVERSION)
424 MOZ_ARG_WITH_STRING(windows-version,
425 [  --with-windows-version=WINSDK_TARGETVER
426                           Windows SDK version to target. Lowest version
427                           currently allowed is 601 (Win7), highest is 602 (Win8)],
428   WINSDK_TARGETVER=$withval)
430 # Currently only two sdk versions allowed, 601 and 602
431 case "$WINSDK_TARGETVER" in
432 601|602)
433     MOZ_WINSDK_TARGETVER=0${WINSDK_TARGETVER}0000
434     ;;
437     AC_MSG_ERROR([Invalid value for --with-windows-version ($WINSDK_TARGETVER)]);
438     ;;
439 esac
441 case "$target" in
442 *-mingw*)
443     if test "$GCC" != "yes" -a -z "$CLANG_CC"; then
444         # Check to see if we are really running in a msvc environemnt
445         _WIN32_MSVC=1
446         AC_CHECK_PROGS(MIDL, midl)
448         # Make sure compilers are valid
449         CFLAGS="$CFLAGS -TC -nologo"
450         CXXFLAGS="$CXXFLAGS -TP -nologo"
451         AC_LANG_SAVE
452         AC_LANG_C
453         AC_TRY_COMPILE([#include <stdio.h>],
454             [ printf("Hello World\n"); ],,
455             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
457         AC_LANG_CPLUSPLUS
458         AC_TRY_COMPILE([#include <new.h>],
459             [ unsigned *test = new unsigned(42); ],,
460             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
461         AC_LANG_RESTORE
463         changequote(,)
464         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
465         changequote([,])
467         # Determine compiler version
468         CC_VERSION=`${CC} -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
469         _CC_MAJOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $1 }'`
470         _CC_MINOR_VERSION=`echo ${CC_VERSION} | $AWK -F\. '{ print $2 }'`
471         _CC_RELEASE=`echo ${CC_VERSION} | $AWK -F\. '{ print $3 }'`
472         _CC_BUILD=`echo ${CC_VERSION} | $AWK -F\. '{ print $4 }'`
473         _MSC_VER=${_CC_MAJOR_VERSION}${_CC_MINOR_VERSION}
475         CXX_VERSION=`${CXX} -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
476         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | $AWK -F\. '{ print $1 }'`
478         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
479             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
480         fi
482         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
483         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
485         if test "$_CC_MAJOR_VERSION" = "16"; then
486             _CC_SUITE=10
487             MSVS_VERSION=2010
488         elif test "$_CC_MAJOR_VERSION" = "17"; then
489             _CC_SUITE=11
490             MSVS_VERSION=2012
491         elif test "$_CC_MAJOR_VERSION" = "18"; then
492             _CC_SUITE=12
493             MSVS_VERSION=2013
494         else
495             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
496         fi
497         AC_SUBST(MSVS_VERSION)
499         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
501         if test -n "$WIN32_REDIST_DIR"; then
502           if test ! -d "$WIN32_REDIST_DIR"; then
503             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
504           fi
505           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
506         fi
508         dnl Confirm we have the pri tools on win8 builds
509         if test -n "$MOZ_METRO"; then
510           AC_MSG_CHECKING([for makepri])
511           AC_CHECK_PROGS(MAKEPRI, makepri, "")
512           if test -z "MAKEPRI" ; then
513               AC_MSG_ERROR([makepri.exe is required for generating metro browser install components. It should be in the Win8 SDK.])
514           fi
515           AC_SUBST(MAKEPRI)
516         fi
518         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
519         dnl not something else like "magnetic tape manipulation utility".
520         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
521         if test -z "$MSMT_TOOL"; then
522           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
523         fi
525         changequote(,)
526         _MSMT_VER_FILTER='s|.*[^!-~]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
527         changequote([,])
528         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
529         if test -z "$MSMANIFEST_TOOL_VERSION"; then
530           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
531         fi
533         MSMANIFEST_TOOL=1
534         unset MSMT_TOOL
536         # Check linker version
537         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
538         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
539         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
540             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
541         fi
543         INCREMENTAL_LINKER=1
545         # Set midl environment
546         case "$target" in
547         i*86-*)
548             MIDL_FLAGS="${MIDL_FLAGS} -env win32"
549             ;;
550         x86_64-*)
551             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
552             ;;
553         esac
555         unset _MSVC_VER_FILTER
557         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
558             [
559                 AC_LANG_SAVE
560                 AC_LANG_CPLUSPLUS
561                 _SAVE_CXXFLAGS="$CXXFLAGS"
562                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
563                 AC_TRY_COMPILE([#include <exception>],
564                             [std::_Throw(std::exception()); return 0;],
565                             ac_cv_have_std__Throw="yes",
566                             ac_cv_have_std__Throw="no")
567                 CXXFLAGS="$_SAVE_CXXFLAGS"
568                 AC_LANG_RESTORE
569             ])
571         if test "$ac_cv_have_std__Throw" = "yes"; then
572             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
573                            ac_cv_have_dllimport_exception_bug,
574                 [
575                     AC_LANG_SAVE
576                     AC_LANG_CPLUSPLUS
577                     _SAVE_CXXFLAGS="$CXXFLAGS"
578                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
579                     AC_TRY_LINK([#include <vector>],
580                                 [std::vector<int> v; return v.at(1);],
581                                 ac_cv_have_dllimport_exception_bug="no",
582                                 ac_cv_have_dllimport_exception_bug="yes")
583                     CXXFLAGS="$_SAVE_CXXFLAGS"
584                     AC_LANG_RESTORE
585                 ])
586             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
587                 WRAP_STL_INCLUDES=1
588                 MOZ_MSVC_STL_WRAP__Throw=1
589                 AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
590             fi
591         else
592             AC_CACHE_CHECK(for overridable _RAISE,
593                            ac_cv_have__RAISE,
594                 [
595                     AC_LANG_SAVE
596                     AC_LANG_CPLUSPLUS
597                     _SAVE_CXXFLAGS="$CXXFLAGS"
598                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
599                     AC_TRY_COMPILE([#include <xstddef>
600                                     #undef _RAISE
601                                     #define _RAISE(x) externallyDefinedFunction((x).what())
602                                     #include <vector>
603                                    ],
604                                    [std::vector<int> v; return v.at(1);],
605                                    ac_cv_have__RAISE="no",
606                                    ac_cv_have__RAISE="yes")
607                     CXXFLAGS="$_SAVE_CXXFLAGS"
608                     AC_LANG_RESTORE
609                 ])
610             if test "$ac_cv_have__RAISE" = "yes"; then
611                 WRAP_STL_INCLUDES=1
612                 MOZ_MSVC_STL_WRAP__RAISE=1
613                 AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
614             else
615                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
616             fi
617         fi
619         if test "$WRAP_STL_INCLUDES" = "1"; then
620             STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
621         fi
622     elif test -z "$CLANG_CC"; then
623         # Check w32api version
624         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
625         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
626         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
627         AC_TRY_COMPILE([#include <w32api.h>],
628             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
629                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
630                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
631                 #error "test failed."
632             #endif
633             , [ res=yes ], [ res=no ])
634         AC_MSG_RESULT([$res])
635         if test "$res" != "yes"; then
636             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
637         fi
638         # Check windres version
639         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
640         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
641         AC_MSG_RESULT([$_WINDRES_VERSION])
642         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
643         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
644         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
645         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
646         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
647         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
648         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
649                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
650                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
651                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
652                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
653                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
654         then
655             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
656         fi
658         AC_CHECK_PROGS(MIDL, $target-widl widl)
659         if test -n "$MIDL"; then
660             case "$target" in
661             i*86-*)
662                 MIDL_FLAGS="$MIDL_FLAGS --win32 -m32"
663                 ;;
664             x86_64-*)
665                 MIDL_FLAGS="$MIDL_FLAGS --win64 -m64"
666                 ;;
667             esac
668         fi
670         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
671         # causing problems with local implementations with the same name.
672         AC_DEFINE(STRSAFE_NO_DEPRECATE)
674         MOZ_WINSDK_MAXVER=0x06020000
675     fi # !GNU_CC
677     # If MSVC or clang
678     if test "$GCC" != "yes" -o -n "$CLANG_CC" ; then
679         MOZ_FIND_WINSDK_VERSION
680     fi
682     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
683     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
684     # Require OS features provided by IE 6.0 SP2 (XP SP2)
685     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
687     # If the maximum version supported by this SDK is lower than the target
688     # version, error out
689     AC_MSG_CHECKING([for Windows SDK being recent enough])
690     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
691         AC_MSG_RESULT("yes")
692     else
693         AC_MSG_RESULT("no")
694         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.])
695     fi
697     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
698     # Definitions matching sdkddkver.h
699     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
700     AC_DEFINE_UNQUOTED(MOZ_WINSDK_MAXVER,$MOZ_WINSDK_MAXVER)
701     AC_SUBST(MOZ_WINSDK_MAXVER)
702     ;;
703 esac
705 AC_PROG_CPP
706 AC_PROG_CXXCPP
708 if test -n "$_WIN32_MSVC"; then
709     SKIP_PATH_CHECKS=1
710     SKIP_COMPILER_CHECKS=1
711     SKIP_LIBRARY_CHECKS=1
713     # Since we're skipping compiler and library checks, hard-code
714     # some facts here.
715     AC_DEFINE(HAVE_IO_H)
716     AC_DEFINE(HAVE_SETBUF)
717     AC_DEFINE(HAVE_ISATTY)
720 fi # COMPILE_ENVIRONMENT
722 AC_SUBST(MIDL_FLAGS)
723 AC_SUBST(_MSC_VER)
725 AC_SUBST(GNU_AS)
726 AC_SUBST(GNU_LD)
727 AC_SUBST(GNU_CC)
728 AC_SUBST(GNU_CXX)
729 AC_SUBST(INTEL_CC)
730 AC_SUBST(INTEL_CXX)
732 AC_SUBST(STL_FLAGS)
733 AC_SUBST(WRAP_STL_INCLUDES)
734 AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
735 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
737 dnl ========================================================
738 dnl Checks for programs.
739 dnl ========================================================
740 AC_PROG_INSTALL
741 AC_PROG_LN_S
743 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
744 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
745 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
746 _perl_res=$?
747 AC_MSG_RESULT([$_perl_version])
749 if test "$_perl_res" != 0; then
750     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
754 AC_MSG_CHECKING([for full perl installation])
755 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
756 _perl_res=$?
757 if test "$_perl_res" != 0; then
758     AC_MSG_RESULT([no])
759     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
760 else
761     AC_MSG_RESULT([yes])
764 if test -z "$COMPILE_ENVIRONMENT"; then
765     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
767 AC_SUBST(NSINSTALL_BIN)
769 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
770 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
771 MOZ_PATH_PROGS(UNZIP, unzip)
772 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
773     AC_MSG_ERROR([unzip not found in \$PATH])
775 MOZ_PATH_PROGS(ZIP, zip)
776 if test -z "$ZIP" -o "$ZIP" = ":"; then
777     AC_MSG_ERROR([zip not found in \$PATH])
779 MOZ_PATH_PROG(XARGS, xargs)
780 if test -z "$XARGS" -o "$XARGS" = ":"; then
781     AC_MSG_ERROR([xargs not found in \$PATH .])
784 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
785 AC_SUBST(RPMBUILD)
787 if test "$COMPILE_ENVIRONMENT"; then
789 dnl ========================================================
790 dnl = Mac OS X toolchain support
791 dnl ========================================================
793 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
794 dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
795 dnl when we can run target binaries.
796 AC_SUBST(UNIVERSAL_BINARY)
797 AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
799 MOZ_ARG_WITH_STRING(unify-dist,
800 [  --with-unify-dist=dir   Location of the dist directory to unify with at packaging time (Mac OS X universal build only)],
801     UNIFY_DIST=$withval)
802 if test -n "$UNIVERSAL_BINARY"; then
803     if test -z "$UNIFY_DIST"; then
804         AC_MSG_ERROR([You need to provide the --with-unify-dist=dir argument when performing a universal build])
805     fi
806     case "$UNIFY_DIST" in
807     /*)
808         ;;
809     *)
810         UNIFY_DIST="${MOZ_BUILD_ROOT}/${UNIFY_DIST}"
811         ;;
812     esac
814 AC_SUBST(UNIFY_DIST)
816 dnl ========================================================
817 dnl Check for MacOS deployment target version
818 dnl ========================================================
820 MOZ_ARG_ENABLE_STRING(macos-target,
821                       [  --enable-macos-target=VER (default=10.6)
822                           Set the minimum MacOS version needed at runtime],
823                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
825 case "$target" in
826 *-darwin*)
827     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
828         dnl Use the specified value
829         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
830     else
831         dnl No value specified on the command line or in the environment,
832         dnl use architecture minimum.
833         export MACOSX_DEPLOYMENT_TARGET=10.6
834     fi
835     ;;
836 esac
838 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
840 dnl ========================================================
841 dnl = Mac OS X SDK support
842 dnl ========================================================
843 MACOS_SDK_DIR=
844 MOZ_ARG_WITH_STRING(macos-sdk,
845 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
846     MACOS_SDK_DIR=$withval)
848 MACOS_PRIVATE_FRAMEWORKS_DIR_DEFAULTED=
849 MOZ_ARG_WITH_STRING(macos-private-frameworks,
850 [  --with-macos-private-frameworks=dir    Location of private frameworks to use (Mac OS X only)],
851     MACOS_PRIVATE_FRAMEWORKS_DIR=$withval,
852     MACOS_PRIVATE_FRAMEWORKS_DIR=/System/Library/PrivateFrameworks
853     MACOS_PRIVATE_FRAMEWORKS_DEFAULTED=1)
855 if test -z "${MACOS_PRIVATE_FRAMEWORKS_DEFAULTED}"; then
856   if test -z "$CROSS_COMPILE"; then
857     AC_MSG_WARN([You should only be using --with-macos-private-frameworks when cross-compiling.])
858   fi
859   if test ! -d "$MACOS_PRIVATE_FRAMEWORKS_DIR"; then
860     AC_MSG_ERROR([PrivateFrameworks directory not found.])
861   fi
864 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
865 AC_SUBST(MACOS_SDK_DIR)
866 AC_SUBST(MACOS_PRIVATE_FRAMEWORKS_DIR)
868 if test "$MACOS_SDK_DIR"; then
869   dnl Sync this section with the ones in NSPR and NSS.
870   dnl Changes to the cross environment here need to be accounted for in
871   dnl the libIDL checks (below) and xpidl build.
873   if test ! -d "$MACOS_SDK_DIR"; then
874     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
875 specify a valid SDK.  SDKs are installed when the optional cross-development
876 tools are selected during the Xcode/Developer Tools installation.])
877   fi
879   CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
880   CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
882   dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
883   CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
884   CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
886   AC_LANG_SAVE
887   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
888   AC_LANG_CPLUSPLUS
889   AC_TRY_COMPILE([#include <new>],[],
890    result=yes,
891    result=no)
892   AC_LANG_RESTORE
893   AC_MSG_RESULT($result)
895   if test "$result" = "no" ; then
896     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
897   fi
900 fi # COMPILE_ENVIRONMENT
902 AC_MSG_CHECKING([compiler version])
903 # Just print it so it shows up in the logs.
904 cc_version=$($CC --version)
905 AC_MSG_RESULT([$cc_version])
907 if test -n "$MAKE"; then
908   if test `echo $MAKE | grep -c make.py` != 1; then
909      NOT_PYMAKE=$MAKE
910   fi
913 case "$host_os" in
914 mingw*)
915     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
916     ;;
918     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
919     ;;
920 esac
921 if test "$GMAKE" = ":"; then
922    AC_MSG_ERROR([GNU make not found])
924 AC_SUBST(GMAKE)
926 if test -z "$MAKE"; then
927   MAKE=$GMAKE
930 if test "$COMPILE_ENVIRONMENT"; then
932 AC_PATH_XTRA
934 XCFLAGS="$X_CFLAGS"
936 fi # COMPILE_ENVIRONMENT
938 dnl ========================================================
939 dnl set the defaults first
940 dnl ========================================================
941 AS_BIN=$AS
942 AR_LIST='$(AR) t'
943 AR_EXTRACT='$(AR) x'
944 AR_DELETE='$(AR) d'
945 AS='$(CC)'
946 AS_DASH_C_FLAG='-c'
947 DLL_PREFIX=lib
948 LIB_PREFIX=lib
949 DLL_SUFFIX=.so
950 OBJ_SUFFIX=o
951 LIB_SUFFIX=a
952 ASM_SUFFIX=s
953 IMPORT_LIB_SUFFIX=
954 TARGET_MD_ARCH=unix
955 DIRENT_INO=d_ino
956 MOZ_USER_DIR=".mozilla"
958 MOZ_JPEG_CFLAGS=
959 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)'
960 MOZ_BZ2_CFLAGS=
961 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
962 MOZ_PNG_CFLAGS="-I$_objdir/dist/include" # needed for freetype compilation
963 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
965 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
966 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
967 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
968 XPCOM_FROZEN_LDOPTS='$(call EXPAND_LIBNAME_PATH,xul mozalloc,$(LIBXUL_DIST)/bin)'
969 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS)'
970 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
971 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
973 # These are specially defined on Windows only
974 case "$target" in
975 *-mingw*)
976   XPCOM_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
977   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime.$(LIB_SUFFIX)'
978   ;;
980   XPCOM_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_GLUE_LDOPTS
981   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_STANDALONE_GLUE_LDOPTS
982   ;;
983 esac
985 MOZ_FS_LAYOUT=unix
987 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
989 USE_DEPENDENT_LIBS=1
991 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
993 if test -n "$CROSS_COMPILE"; then
994     OS_TARGET="${target_os}"
995     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
996     OS_RELEASE=
997     case "${target_os}" in
998         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
999         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU/kFreeBSD ;;
1000         gnu*)         OS_ARCH=GNU ;;
1001         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
1002         mingw*)       OS_ARCH=WINNT OS_TARGET=WINNT ;;
1003         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
1004         dragonfly*)   OS_ARCH=DragonFly OS_TARGET=DragonFly ;;
1005         freebsd*)     OS_ARCH=FreeBSD OS_TARGET=FreeBSD ;;
1006         netbsd*)      OS_ARCH=NetBSD OS_TARGET=NetBSD ;;
1007         openbsd*)     OS_ARCH=OpenBSD OS_TARGET=OpenBSD ;;
1008     esac
1009     case "${target}" in
1010         *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
1011     esac
1012 else
1013     OS_TARGET=`uname -s`
1014     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
1015     OS_RELEASE=`uname -r`
1018 # Before this used `uname -m` when not cross compiling
1019 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
1020 OS_TEST="${target_cpu}"
1022 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
1024 #######################################################################
1025 # Master "Core Components" macros for getting the OS target           #
1026 #######################################################################
1029 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
1030 # cross-compilation.
1034 # Define and override various archtecture-specific variables, including
1035 # HOST_OS_ARCH
1036 # OS_ARCH
1037 # OS_TEST
1038 # OS_TARGET
1039 # OS_RELEASE
1040 # OS_MINOR_RELEASE
1043 case "$HOST_OS_ARCH" in
1044 mingw*)
1045     HOST_OS_ARCH=WINNT
1046     ;;
1047 darwin*)
1048     HOST_OS_ARCH=Darwin
1049     ;;
1050 linux*)
1051     HOST_OS_ARCH=Linux
1052     ;;
1053 kfreebsd*-gnu)
1054     HOST_OS_ARCH=GNU_kFreeBSD
1055     ;;
1056 gnu*)
1057     HOST_OS_ARCH=GNU
1058     ;;
1059 dragonfly*)
1060     HOST_OS_ARCH=DragonFly
1061     ;;
1062 freebsd*)
1063     HOST_OS_ARCH=FreeBSD
1064     ;;
1065 netbsd*)
1066     HOST_OS_ARCH=NetBSD
1067     ;;
1068 openbsd*)
1069     HOST_OS_ARCH=OpenBSD
1070     ;;
1071 solaris*)
1072     HOST_OS_ARCH=SunOS
1073     SOLARIS_SUNPRO_CC=
1074     SOLARIS_SUNPRO_CXX=
1075     if test -z "$GNU_CC"; then
1076         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1077             SOLARIS_SUNPRO_CC=1
1078        fi
1079     fi
1081     if test -z "$GNU_CXX"; then
1082        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1083            SOLARIS_SUNPRO_CXX=1
1084        fi
1085     fi
1086     AC_SUBST(SOLARIS_SUNPRO_CC)
1087     AC_SUBST(SOLARIS_SUNPRO_CXX)
1088     ;;
1089 esac
1091 case "$OS_ARCH" in
1092 WINNT)
1093     if test -z "$CROSS_COMPILE" ; then
1094         OS_TEST=`uname -p`
1095     fi
1096     ;;
1097 Windows_NT)
1099 # If uname -s returns "Windows_NT", we assume that we are using
1100 # the uname.exe in MKS toolkit.
1102 # The -r option of MKS uname only returns the major version number.
1103 # So we need to use its -v option to get the minor version number.
1104 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1106     OS_ARCH=WINNT
1107     OS_TARGET=WINNT
1108     OS_MINOR_RELEASE=`uname -v`
1109     if test "$OS_MINOR_RELEASE" = "00"; then
1110         OS_MINOR_RELEASE=0
1111     fi
1112     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1113     ;;
1114 MINGW*_NT*)
1116 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1117 # the uname.exe in the MSYS tools.
1119     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1120     OS_ARCH=WINNT
1121     OS_TARGET=WINNT
1122     ;;
1123 AIX)
1124     OS_RELEASE=`uname -v`.`uname -r`
1125     OS_TEST=${target_cpu}
1126     ;;
1127 Darwin)
1128     case "${target_cpu}" in
1129     powerpc*)
1130         OS_TEST=ppc
1131         ;;
1132     i*86*)
1133         OS_TEST=i386
1134         ;;
1135     x86_64)
1136         OS_TEST=x86_64
1137         ;;
1138     *)
1139         if test -z "$CROSS_COMPILE" ; then
1140             OS_TEST=`uname -p`
1141         fi
1142         ;;
1143     esac
1144     ;;
1145 esac
1147 # Only set CPU_ARCH if we recognize the value of OS_TEST
1149 case "$OS_TEST" in
1150 *86 | i86pc)
1151     CPU_ARCH=x86
1152     ;;
1154 powerpc64 | ppc64 | powerpc64le | ppc64le)
1155     CPU_ARCH=ppc64
1156     ;;
1158 powerpc | ppc | rs6000)
1159     CPU_ARCH=ppc
1160     ;;
1162 Alpha | alpha | ALPHA)
1163     CPU_ARCH=Alpha
1164     ;;
1166 s390)
1167     CPU_ARCH=s390
1168     ;;
1170 s390x)
1171     CPU_ARCH=s390x
1172     ;;
1174 hppa* | parisc)
1175     CPU_ARCH=hppa
1176     ;;
1178 sun4u | sparc*)
1179     CPU_ARCH=sparc
1180     ;;
1182 x86_64 | ia64)
1183     CPU_ARCH="$OS_TEST"
1184     ;;
1186 arm*)
1187     CPU_ARCH=arm
1188     ;;
1190 mips|mipsel)
1191     CPU_ARCH="mips"
1192     ;;
1194 aarch64*)
1195     CPU_ARCH=aarch64
1196     ;;
1197 esac
1199 if test -z "$OS_TARGET"; then
1200     OS_TARGET=$OS_ARCH
1202 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1204 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1205 dnl ===============================================================
1206 INTEL_ARCHITECTURE=
1207 case "$OS_TEST" in
1208     x86_64|i?86)
1209       INTEL_ARCHITECTURE=1
1210 esac
1212 dnl Configure platform-specific CPU architecture compiler options.
1213 dnl ==============================================================
1214 MOZ_ARCH_OPTS
1216 dnl =================================================================
1217 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1218 dnl which is bad when cross compiling.
1219 dnl =================================================================
1220 if test "$COMPILE_ENVIRONMENT"; then
1221 configure_static_assert_macros='
1222 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1223 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1224 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1227 dnl test that the macros actually work:
1228 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1229 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1230  [AC_LANG_SAVE
1231   AC_LANG_C
1232   ac_cv_static_assertion_macros_work="yes"
1233   AC_TRY_COMPILE([$configure_static_assert_macros],
1234                  [CONFIGURE_STATIC_ASSERT(1)],
1235                  ,
1236                  ac_cv_static_assertion_macros_work="no")
1237   AC_TRY_COMPILE([$configure_static_assert_macros],
1238                  [CONFIGURE_STATIC_ASSERT(0)],
1239                  ac_cv_static_assertion_macros_work="no",
1240                  )
1241   AC_LANG_CPLUSPLUS
1242   AC_TRY_COMPILE([$configure_static_assert_macros],
1243                  [CONFIGURE_STATIC_ASSERT(1)],
1244                  ,
1245                  ac_cv_static_assertion_macros_work="no")
1246   AC_TRY_COMPILE([$configure_static_assert_macros],
1247                  [CONFIGURE_STATIC_ASSERT(0)],
1248                  ac_cv_static_assertion_macros_work="no",
1249                  )
1250   AC_LANG_RESTORE
1251  ])
1252 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1253 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1254     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1256 fi # COMPILE_ENVIRONMENT
1258 dnl ========================================================
1259 dnl Android libstdc++, placed here so it can use MOZ_ARCH
1260 dnl computed above.
1261 dnl ========================================================
1263 MOZ_ANDROID_STLPORT
1265 dnl ========================================================
1266 dnl Suppress Clang Argument Warnings
1267 dnl ========================================================
1268 if test -n "$CLANG_CC"; then
1269     _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
1270     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
1272 if test -n "$CLANG_CXX"; then
1273     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
1276 dnl ========================================================
1277 dnl = Use Address Sanitizer
1278 dnl ========================================================
1279 MOZ_ARG_ENABLE_BOOL(address-sanitizer,
1280 [  --enable-address-sanitizer       Enable Address Sanitizer (default=no)],
1281     MOZ_ASAN=1,
1282     MOZ_ASAN= )
1283 if test -n "$MOZ_ASAN"; then
1284     MOZ_LLVM_HACKS=1
1285     AC_DEFINE(MOZ_ASAN)
1286     MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
1288 AC_SUBST(MOZ_ASAN)
1289 AC_SUBST(LLVM_SYMBOLIZER)
1291 dnl ========================================================
1292 dnl = Enable hacks required for LLVM instrumentations
1293 dnl ========================================================
1294 MOZ_ARG_ENABLE_BOOL(llvm-hacks,
1295 [  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)],
1296     MOZ_LLVM_HACKS=1,
1297     MOZ_LLVM_HACKS= )
1298 if test -n "$MOZ_LLVM_HACKS"; then
1299     MOZ_NO_WLZDEFS=1
1300     MOZ_CFLAGS_NSS=1
1302 AC_SUBST(MOZ_NO_WLZDEFS)
1303 AC_SUBST(MOZ_CFLAGS_NSS)
1305 dnl ========================================================
1306 dnl GNU specific defaults
1307 dnl ========================================================
1308 if test "$GNU_CC"; then
1309     # Per bug 719659 comment 2, some of the headers on ancient build machines
1310     # may require gnu89 inline semantics.  But otherwise, we use C99.
1311     # But on OS X we just use C99 plus GNU extensions, in order to fix
1312     # bug 917526.
1313     CFLAGS="$CFLAGS -std=gnu99"
1314     if test "${OS_ARCH}" != Darwin; then
1315         CFLAGS="$CFLAGS -fgnu89-inline"
1316     fi
1317     # FIXME: Let us build with strict aliasing. bug 414641.
1318     CFLAGS="$CFLAGS -fno-strict-aliasing"
1319     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@'
1320     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@'
1321     WARNINGS_AS_ERRORS='-Werror'
1322     DSO_CFLAGS=''
1323     DSO_PIC_CFLAGS='-fPIC'
1324     ASFLAGS="$ASFLAGS -fPIC"
1325     AC_MSG_CHECKING([for --noexecstack option to as])
1326     _SAVE_CFLAGS=$CFLAGS
1327     CFLAGS="$CFLAGS -Wa,--noexecstack"
1328     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
1329                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
1330                      AC_MSG_RESULT([no]))
1331     CFLAGS=$_SAVE_CFLAGS
1332     AC_MSG_CHECKING([for -z noexecstack option to ld])
1333     _SAVE_LDFLAGS=$LDFLAGS
1334     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
1335     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
1336                   AC_MSG_RESULT([no])
1337                   LDFLAGS=$_SAVE_LDFLAGS)
1339     AC_MSG_CHECKING([for -z text option to ld])
1340     _SAVE_LDFLAGS=$LDFLAGS
1341     LDFLAGS="$LDFLAGS -Wl,-z,text"
1342     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1343                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,text"],
1344                   AC_MSG_RESULT([no])
1345                   LDFLAGS=$_SAVE_LDFLAGS)
1347     AC_MSG_CHECKING([for --build-id option to ld])
1348     _SAVE_LDFLAGS=$LDFLAGS
1349     LDFLAGS="$LDFLAGS -Wl,--build-id"
1350     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1351                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,--build-id"],
1352                   AC_MSG_RESULT([no])
1353                   LDFLAGS=$_SAVE_LDFLAGS)
1355     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
1356     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
1357     _SAVE_LDFLAGS=$LDFLAGS
1358     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
1359     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1360                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
1361                   AC_MSG_RESULT([no]))
1362     LDFLAGS=$_SAVE_LDFLAGS
1364     # Check for -mssse3 on $CC
1365     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
1366     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
1367     _SAVE_CFLAGS=$CFLAGS
1368     CFLAGS="$CFLAGS -mssse3"
1369     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
1370                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
1371                      AC_MSG_RESULT([no]))
1372     CFLAGS=$_SAVE_CFLAGS
1374     # Check for -msse4.1 on $CC
1375     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
1376     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
1377     _SAVE_CFLAGS=$CFLAGS
1378     CFLAGS="$CFLAGS -msse4.1"
1379     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
1380                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
1381                      AC_MSG_RESULT([no]))
1382     CFLAGS=$_SAVE_CFLAGS
1384     case "${CPU_ARCH}" in
1385     x86 | x86_64)
1386       AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
1387       AC_TRY_COMPILE([],
1388                      [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
1389                      result="yes", result="no")
1390       AC_MSG_RESULT("$result")
1391       if test "$result" = "yes"; then
1392           HAVE_X86_AVX2=1
1393           AC_DEFINE(HAVE_X86_AVX2)
1394           AC_SUBST(HAVE_X86_AVX2)
1395       fi
1396     esac
1398     DSO_LDOPTS='-shared'
1399     if test "$GCC_USE_GNU_LD"; then
1400         # Some tools like ASan use a runtime library that is only
1401         # linked against executables, so we must allow undefined
1402         # symbols for shared objects in some cases.
1403         if test -z "$MOZ_NO_WLZDEFS"; then
1404             # Don't allow undefined symbols in libraries
1405             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1407             # BSDs need `environ' exposed for posix_spawn (bug 753046)
1408             case "$OS_TARGET" in
1409             DragonFly|FreeBSD|NetBSD|OpenBSD)
1410                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
1411                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
1412                 else
1413                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
1414                 fi
1415                 ;;
1416             esac
1417         fi
1418     fi
1420     # Turn on GNU-specific warnings:
1421     # -Wall - turn on a lot of warnings
1422     # -Wpointer-arith - good to have
1423     # -Wdeclaration-after-statement - MSVC doesn't like these
1424     # -Werror=return-type - catches missing returns, zero false positives
1425     # -Werror=int-to-pointer-cast - catches cast to pointer from integer of different size
1426     # -Wtype-limits - catches overflow bugs, few false positives
1427     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1428     # -Wsign-compare - catches comparison of signed and unsigned types
1429     #
1430     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
1431     MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
1432     MOZ_C_SUPPORTS_WARNING(-W, error=int-to-pointer-cast, ac_c_has_werror_int_to_pointer_cast)
1433     MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
1434     MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
1435     MOZ_C_SUPPORTS_WARNING(-W, sign-compare, ac_c_has_sign_compare)
1437     # Turn off the following warnings that -Wall turns on:
1438     # -Wno-unused - lots of violations in third-party code
1439     #
1440     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
1442     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
1443        # Don't use -Wcast-align with ICC or clang
1444        case "$CPU_ARCH" in
1445            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1446            hppa | ia64 | sparc | arm)
1447            ;;
1448            *)
1449         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1450            ;;
1451        esac
1452     fi
1454     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1455     _USE_CPP_INCLUDE_FLAG=1
1456     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
1458 elif test "$SOLARIS_SUNPRO_CC"; then
1459     DSO_CFLAGS=''
1460     if test "$CPU_ARCH" = "sparc"; then
1461         # for Sun Studio on Solaris/SPARC
1462         DSO_PIC_CFLAGS='-xcode=pic32'
1463     else
1464         DSO_PIC_CFLAGS='-KPIC'
1465     fi
1466     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1467 else
1468     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
1469     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
1471     DSO_LDOPTS='-shared'
1472     if test "$GNU_LD"; then
1473         # Don't allow undefined symbols in libraries
1474         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1475     fi
1477     DSO_CFLAGS=''
1478     DSO_PIC_CFLAGS='-KPIC'
1479     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1482 if test "$GNU_CXX"; then
1483     # FIXME: Let us build with strict aliasing. bug 414641.
1484     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
1486     # Turn on GNU-specific warnings:
1487     # -Wall - turn on a lot of warnings
1488     # -Wpointer-arith - good to have
1489     # -Woverloaded-virtual - ???
1490     # -Werror=return-type - catches missing returns, zero false positives
1491     # -Werror=int-to-pointer-cast - catches cast to pointer from integer of different size
1492     # -Wtype-limits - catches overflow bugs, few false positives
1493     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1494     # -Wsign-compare - catches comparison of signed and unsigned types
1495     #
1496     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
1497     MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
1498     MOZ_CXX_SUPPORTS_WARNING(-W, error=int-to-pointer-cast, ac_cxx_has_werror_int_to_pointer_cast)
1499     MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
1500     MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
1501     MOZ_CXX_SUPPORTS_WARNING(-W, sign-compare, ac_cxx_has_sign_compare)
1503     # Turn off the following warnings that -Wall turns on:
1504     # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
1505     # -Wno-inline-new-delete - we inline 'new' and 'delete' in mozalloc
1506     #   for performance reasons, and because GCC and clang accept it (though
1507     #   clang warns about it).
1508     #
1509     MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
1510     MOZ_CXX_SUPPORTS_WARNING(-Wno-, inline-new-delete, ac_cxx_has_wno_inline_new_delete)
1512     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
1513        # Don't use -Wcast-align with ICC or clang
1514        case "$CPU_ARCH" in
1515            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1516            hppa | ia64 | sparc | arm)
1517            ;;
1518            *)
1519         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1520            ;;
1521        esac
1522     fi
1524     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1525     _USE_CPP_INCLUDE_FLAG=1
1527     # Recent clang and gcc support C++11 deleted functions without warnings if
1528     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
1529     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
1530     # unused.  But clang's warning can be disabled, so when compiling with clang
1531     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
1532     # deleted function syntax.
1533     if test "$CLANG_CXX"; then
1534         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
1535         MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
1536     fi
1538 else
1539     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
1542 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1543 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1544 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1545 dnl normal behavior.
1546 dnl ========================================================
1547 MKSHLIB_FORCE_ALL=
1548 MKSHLIB_UNFORCE_ALL=
1550 if test "$COMPILE_ENVIRONMENT"; then
1551 if test "$GNU_CC"; then
1552   AC_MSG_CHECKING(whether ld has archive extraction flags)
1553   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1554    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1555     ac_cv_mkshlib_force_and_unforce="no"
1556     exec 3<&0 <<LOOP_INPUT
1557   force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1558   force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1559   force="-Wl,-all";              unforce="-Wl,-none"
1560 LOOP_INPUT
1561     while read line
1562     do
1563       eval $line
1564       LDFLAGS=$force
1565       LIBS=$unforce
1566       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1567     done
1568     exec 0<&3 3<&-
1569     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1570    ])
1571   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1572     AC_MSG_RESULT(no)
1573   else
1574     AC_MSG_RESULT(yes)
1575     eval $ac_cv_mkshlib_force_and_unforce
1576     MKSHLIB_FORCE_ALL=$force
1577     MKSHLIB_UNFORCE_ALL=$unforce
1578   fi
1579 fi # GNU_CC
1580 fi # COMPILE_ENVIRONMENT
1582 dnl ========================================================
1583 dnl Checking for 64-bit OS
1584 dnl ========================================================
1585 if test "$COMPILE_ENVIRONMENT"; then
1586 AC_LANG_SAVE
1587 AC_LANG_C
1588 AC_MSG_CHECKING(for 64-bit OS)
1589 AC_TRY_COMPILE([$configure_static_assert_macros],
1590                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1591                result="yes", result="no")
1592 AC_MSG_RESULT("$result")
1593 if test "$result" = "yes"; then
1594     AC_DEFINE(HAVE_64BIT_OS)
1595     HAVE_64BIT_OS=1
1597 AC_SUBST(HAVE_64BIT_OS)
1598 AC_LANG_RESTORE
1599 fi # COMPILE_ENVIRONMENT
1601 dnl ========================================================
1602 dnl = Use profiling compile flags
1603 dnl ========================================================
1604 MOZ_ARG_ENABLE_BOOL(profiling,
1605 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1606     MOZ_PROFILING=1,
1607     MOZ_PROFILING= )
1609 dnl ========================================================
1610 dnl = Turn on systrace for android/b2g.
1611 dnl ========================================================
1612 MOZ_ARG_ENABLE_BOOL(systrace,
1613 [  --enable-systrace       Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1614     MOZ_USE_SYSTRACE=1,
1615     MOZ_USE_SYSTRACE= )
1616 if test -n "$MOZ_USE_SYSTRACE"; then
1617     AC_DEFINE(MOZ_USE_SYSTRACE)
1620 # For profiling builds keep the symbol information
1621 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
1622     case "$OS_TARGET" in
1623     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
1624         STRIP_FLAGS="--strip-debug"
1625         ;;
1626     esac
1629 dnl ========================================================
1630 dnl = Use Valgrind
1631 dnl ========================================================
1632 MOZ_ARG_ENABLE_BOOL(valgrind,
1633 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
1634     MOZ_VALGRIND=1,
1635     MOZ_VALGRIND= )
1636 if test -n "$MOZ_VALGRIND"; then
1637     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1638         AC_MSG_ERROR(
1639             [--enable-valgrind specified but Valgrind is not installed]))
1640     AC_DEFINE(MOZ_VALGRIND)
1642 AC_SUBST(MOZ_VALGRIND)
1644 dnl ========================================================
1645 dnl jprof
1646 dnl ========================================================
1647 MOZ_ARG_ENABLE_BOOL(jprof,
1648 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
1649     MOZ_JPROF=1,
1650     MOZ_JPROF= )
1651 if test -n "$MOZ_JPROF"; then
1652     MOZ_PROFILING=1
1653     AC_DEFINE(MOZ_JPROF)
1656 dnl ========================================================
1657 dnl SPS Profiler
1658 dnl ========================================================
1659 MOZ_ENABLE_PROFILER_SPS=1
1661 case "${OS_TARGET}" in
1662 Android)
1663     case "${CPU_ARCH}" in
1664     x86 | arm) ;;
1665     *)
1666         MOZ_ENABLE_PROFILER_SPS=
1667     esac
1668     ;;
1669 Linux)
1670     case "${CPU_ARCH}" in
1671     x86 | x86_64) ;;
1672     *)
1673         MOZ_ENABLE_PROFILER_SPS=
1674     esac
1675     ;;
1676 WINNT|Darwin) ;;
1678     MOZ_ENABLE_PROFILER_SPS=
1679     ;;
1680 esac
1682 if test -n "$MOZ_ENABLE_PROFILER_SPS"; then
1683     AC_DEFINE(MOZ_ENABLE_PROFILER_SPS)
1686 dnl ========================================================
1687 dnl shark
1688 dnl ========================================================
1689 MOZ_ARG_ENABLE_BOOL(shark,
1690 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
1691     MOZ_SHARK=1,
1692     MOZ_SHARK= )
1693 if test -n "$MOZ_SHARK"; then
1694     MOZ_PROFILING=1
1695     AC_DEFINE(MOZ_SHARK)
1698 dnl ========================================================
1699 dnl instruments
1700 dnl ========================================================
1701 MOZ_ARG_ENABLE_BOOL(instruments,
1702 [  --enable-instruments    Enable instruments remote profiling. Implies --enable-profiling.],
1703     MOZ_INSTRUMENTS=1,
1704     MOZ_INSTRUMENTS= )
1705 if test -n "$MOZ_INSTRUMENTS"; then
1706     MOZ_PROFILING=1
1707     AC_DEFINE(MOZ_INSTRUMENTS)
1710 dnl ========================================================
1711 dnl callgrind
1712 dnl ========================================================
1713 MOZ_ARG_ENABLE_BOOL(callgrind,
1714 [  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.],
1715     MOZ_CALLGRIND=1,
1716     MOZ_CALLGRIND= )
1717 if test -n "$MOZ_CALLGRIND"; then
1718     MOZ_PROFILING=1
1719     AC_DEFINE(MOZ_CALLGRIND)
1722 dnl ========================================================
1723 dnl vtune
1724 dnl ========================================================
1725 MOZ_ARG_ENABLE_BOOL(vtune,
1726 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
1727     MOZ_VTUNE=1,
1728     MOZ_VTUNE= )
1729 if test -n "$MOZ_VTUNE"; then
1730     MOZ_PROFILING=1
1731     AC_DEFINE(MOZ_VTUNE)
1734 dnl ========================================================
1735 dnl Profiling
1736 dnl ========================================================
1737 if test -n "$MOZ_PROFILING"; then
1738     AC_DEFINE(MOZ_PROFILING)
1741 dnl ========================================================
1742 dnl System overrides of the defaults for host
1743 dnl ========================================================
1744 case "$host" in
1745 *mingw*)
1746     if test -n "$_WIN32_MSVC"; then
1747         HOST_AR=lib
1748         HOST_AR_FLAGS='-NOLOGO -OUT:$@'
1749         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo"
1750         HOST_RANLIB='echo ranlib'
1751     else
1752         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
1753     fi
1754     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
1755     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1756     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1757     HOST_BIN_SUFFIX=.exe
1758     case "$host" in
1759     *mingw*)
1760         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1761         ;;
1762     esac
1764     case "${host_cpu}" in
1765     i*86)
1766         if test -n "$_WIN32_MSVC"; then
1767             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
1768         fi
1769         ;;
1770     x86_64)
1771         if test -n "$_WIN32_MSVC"; then
1772             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
1773         fi
1774         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1775         ;;
1776     esac
1777     ;;
1779 *-darwin*)
1780     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1781     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1782     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1783     ;;
1785 *-linux*|*-kfreebsd*-gnu|*-gnu*)
1786     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1787     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1788     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1789     ;;
1792     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1793     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1794     ;;
1795 esac
1797 dnl Check for using a custom <inttypes.h> implementation
1798 dnl ========================================================
1799 AC_MSG_CHECKING(for custom <inttypes.h> implementation)
1800 if test "$MOZ_CUSTOM_INTTYPES_H"; then
1801   AC_DEFINE_UNQUOTED(MOZ_CUSTOM_INTTYPES_H, "$MOZ_CUSTOM_INTTYPES_H")
1802   AC_MSG_RESULT(using $MOZ_CUSTOM_INTTYPES_H)
1803 else
1804   AC_MSG_RESULT(none specified)
1807 dnl Get mozilla version from central milestone file
1808 MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
1809 MOZILLA_UAVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -uaversion`
1810 MOZILLA_SYMBOLVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -symbolversion`
1812 dnl Get version of various core apps from the version files.
1813 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
1815 if test -z "$FIREFOX_VERSION"; then
1816     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
1819 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
1820 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
1821 AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
1822 AC_SUBST(MOZILLA_SYMBOLVERSION)
1824 MOZ_DOING_LTO(lto_is_enabled)
1826 dnl ========================================================
1827 dnl System overrides of the defaults for target
1828 dnl ========================================================
1830 case "$target" in
1831 *-aix*)
1832     AC_DEFINE(AIX)
1833     if test ! "$GNU_CC"; then
1834         if test ! "$HAVE_64BIT_OS"; then
1835             # Compiling with Visual Age C++ object model compat is the
1836             # default. To compile with object model ibm, add
1837             # AIX_OBJMODEL=ibm to .mozconfig.
1838             if test "$AIX_OBJMODEL" = "ibm"; then
1839                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
1840             else
1841                 AIX_OBJMODEL=compat
1842             fi
1843         else
1844             AIX_OBJMODEL=compat
1845         fi
1846         AC_SUBST(AIX_OBJMODEL)
1847         DSO_LDOPTS='-qmkshrobj=1'
1848         DSO_CFLAGS='-qflag=w:w'
1849         DSO_PIC_CFLAGS=
1850         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
1851         MOZ_FIX_LINK_PATHS=
1852         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1853         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1854         if test "$COMPILE_ENVIRONMENT"; then
1855             AC_LANG_SAVE
1856             AC_LANG_CPLUSPLUS
1857             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
1858             AC_TRY_COMPILE([],
1859                 [#if (__IBMCPP__ < 900)
1860                  #error "Bad compiler"
1861                  #endif],
1862                 _BAD_COMPILER=,_BAD_COMPILER=1)
1863             if test -n "$_BAD_COMPILER"; then
1864                 AC_MSG_RESULT([no])
1865                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
1866             else
1867                 AC_MSG_RESULT([yes])
1868             fi
1869             AC_LANG_RESTORE
1870             TARGET_COMPILER_ABI="ibmc"
1871             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
1872             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
1873         fi
1874     fi
1875     case "${target_os}" in
1876     aix4.1*)
1877         DLL_SUFFIX='_shr.a'
1878         ;;
1879     esac
1880     if test "$COMPILE_ENVIRONMENT"; then
1881         MOZ_CHECK_HEADERS(sys/inttypes.h)
1882     fi
1883     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1884     ;;
1886 *-darwin*)
1887     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1888     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1889     MOZ_OPTIMIZE_FLAGS="-O3"
1890     # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
1891     if test "$HAVE_64BIT_OS"; then
1892         MOZ_MEMORY=1
1893     fi
1894     DLL_SUFFIX=".dylib"
1895     DSO_LDOPTS=''
1896     STRIP_FLAGS="$STRIP_FLAGS -x -S"
1897     # Check whether we're targeting OS X or iOS
1898     AC_CACHE_CHECK(for iOS target,
1899                    ac_cv_ios_target,
1900                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
1901 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
1902 #error not iOS
1903 #endif],
1904                                    [],
1905                                    ac_cv_ios_target="yes",
1906                                    ac_cv_ios_target="no")])
1907     if test "$ac_cv_ios_target" = "yes"; then
1908         AC_DEFINE(XP_IOS)
1909         AC_DEFINE(XP_DARWIN)
1910         _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
1911     else
1912         AC_DEFINE(XP_MACOSX)
1913         AC_DEFINE(XP_DARWIN)
1914         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
1915         # The ExceptionHandling framework is needed for Objective-C exception
1916         # logging code in nsObjCExceptions.h. Currently we only use that in debug
1917         # builds.
1918         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
1919     fi
1920     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1922     MMX_FLAGS="-mmmx"
1923     SSE_FLAGS="-msse"
1924     SSE2_FLAGS="-msse2"
1926     if test "x$lto_is_enabled" = "xyes"; then
1927         echo "Skipping -dead_strip because lto is enabled."
1928     dnl DTrace and -dead_strip don't interact well. See bug 403132.
1929     dnl ===================================================================
1930     elif test "x$enable_dtrace" = "xyes"; then
1931         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
1932     else
1933         dnl check for the presence of the -dead_strip linker flag
1934         AC_MSG_CHECKING([for -dead_strip option to ld])
1935         _SAVE_LDFLAGS=$LDFLAGS
1936         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
1937         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
1938         if test -n "$_HAVE_DEAD_STRIP" ; then
1939             AC_MSG_RESULT([yes])
1940             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
1941         else
1942             AC_MSG_RESULT([no])
1943         fi
1945         LDFLAGS=$_SAVE_LDFLAGS
1946     fi
1948     dnl With newer linkers we need to pass -allow_heap_execute because of
1949     dnl Microsoft Silverlight (5.1.10411.0 at least).
1950     AC_MSG_CHECKING([for -allow_heap_execute option to ld])
1951     _SAVE_LDFLAGS=$LDFLAGS
1952     LDFLAGS="$LDFLAGS -Wl,-allow_heap_execute"
1953     AC_TRY_LINK(,[return 0;],_HAVE_ALLOW_HEAP_EXECUTE=1,
1954                 _HAVE_ALLOW_HEAP_EXECUTE=)
1955     if test -n "$_HAVE_ALLOW_HEAP_EXECUTE" ; then
1956         AC_MSG_RESULT([yes])
1957         MOZ_ALLOW_HEAP_EXECUTE_FLAGS="-Wl,-allow_heap_execute"
1958     else
1959         AC_MSG_RESULT([no])
1960     fi
1961     LDFLAGS=$_SAVE_LDFLAGS
1963     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
1964     ;;
1966 ia64*-hpux*)
1967     DLL_SUFFIX=".so"
1968     if test ! "$GNU_CC"; then
1969        DSO_LDOPTS='-b'
1970        DSO_CFLAGS=""
1971        DSO_PIC_CFLAGS=
1972        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
1973        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
1974        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
1975     else
1976        DSO_LDOPTS='-b -E'
1977        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1978        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1979     fi
1980     MOZ_FIX_LINK_PATHS=
1981     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1982     AC_DEFINE(_LARGEFILE64_SOURCE)
1983     ;;
1985 *-hpux*)
1986     DLL_SUFFIX=".sl"
1987     if test ! "$GNU_CC"; then
1988         DSO_LDOPTS='-b -Wl,+s'
1989         DSO_CFLAGS=""
1990         DSO_PIC_CFLAGS="+Z"
1991         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
1992         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
1993         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
1994     else
1995         DSO_LDOPTS='-b -E +s'
1996         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
1997         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
1998     fi
1999     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
2000     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2001     ;;
2003 *-android*|*-linuxandroid*)
2004     AC_DEFINE(NO_PW_GECOS)
2005     no_x=yes
2006     if test -n "$gonkdir"; then
2007         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
2008         _PLATFORM_HAVE_RIL=1
2009         MOZ_B2G_FM=1
2010         MOZ_SYNTH_PICO=1
2011     else
2012         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
2013         MOZ_LINKER=1
2014     fi
2015     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2017     MMX_FLAGS="-mmmx"
2018     SSE_FLAGS="-msse"
2019     SSE2_FLAGS="-msse2"
2021     MOZ_GFX_OPTIMIZE_MOBILE=1
2022     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
2023     ;;
2025 *-*linux*)
2026     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2027     # Similarly for GNU_CXX and INTEL_CXX.
2028     if test "$INTEL_CC" -o "$INTEL_CXX"; then
2029         # -Os has been broken on Intel's C/C++ compilers for quite a
2030         # while; Intel recommends against using it.
2031         MOZ_OPTIMIZE_FLAGS="-O2"
2032     elif test "$GNU_CC" -o "$GNU_CXX"; then
2033         case $GCC_VERSION in
2034         4.5.*)
2035             # -Os is broken on gcc 4.5.x we need to tweak it to get good results.
2036             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
2037         esac
2038         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
2039         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
2040     fi
2042     MMX_FLAGS="-mmmx"
2043     SSE_FLAGS="-msse"
2044     SSE2_FLAGS="-msse2"
2046     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2048     MOZ_MEMORY=1
2050     case "${target_cpu}" in
2051     alpha*)
2052         CFLAGS="$CFLAGS -mieee"
2053         CXXFLAGS="$CXXFLAGS -mieee"
2054     ;;
2055     esac
2057     if test -z "$MC"; then
2058         MC=mc.exe
2059     fi
2060     ;;
2061 *-mingw*)
2062     DSO_CFLAGS=
2063     DSO_PIC_CFLAGS=
2064     DLL_SUFFIX=.dll
2065     RC=rc.exe
2066     MC=mc.exe
2067     # certain versions of cygwin's makedepend barf on the
2068     # #include <string> vs -I./dist/include/string issue so don't use it
2069     XPCOM_FROZEN_LDOPTS='$(call EXPAND_LIBNAME_PATH,xul mozalloc,$(LIBXUL_DIST)/lib)'
2070     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
2071         CC="$CC -mwindows"
2072         CXX="$CXX -mwindows"
2073         CPP="$CPP -mwindows"
2074         CFLAGS="$CFLAGS -mms-bitfields"
2075         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2076         DSO_LDOPTS='-shared'
2077         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2078         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2079         RC='$(WINDRES)'
2080         # Use static libgcc and libstdc++
2081         LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
2082         NSPR_LDFLAGS="$NSPR_LDFLAGS -static-libgcc"
2083         # Use temp file for windres (bug 213281)
2084         RCFLAGS='-O coff --use-temp-file'
2085         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2086         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32 -lnetapi32"
2087         MOZ_FIX_LINK_PATHS=
2088         DLL_PREFIX=
2089         IMPORT_LIB_SUFFIX=dll.a
2091         MMX_FLAGS="-mmmx"
2092         SSE_FLAGS="-msse"
2093         SSE2_FLAGS="-msse2"
2095         # We use mix of both POSIX and Win32 printf format across the tree, so format
2096         # warnings are useless on mingw.
2097         MOZ_C_SUPPORTS_WARNING(-Wno-, format, ac_c_has_wno_format)
2098         MOZ_CXX_SUPPORTS_WARNING(-Wno-, format, ac_cxx_has_wno_format)
2099     else
2100         TARGET_COMPILER_ABI=msvc
2101         HOST_CC='$(CC)'
2102         HOST_CXX='$(CXX)'
2103         HOST_LD='$(LD)'
2104         if test "$AS_BIN"; then
2105             AS="$(basename "$AS_BIN")"
2106         fi
2107         AR='lib'
2108         AR_FLAGS='-NOLOGO -OUT:$@'
2109         AR_EXTRACT=
2110         RANLIB='echo not_ranlib'
2111         STRIP='echo not_strip'
2112         PKG_SKIP_STRIP=1
2113         XARGS=xargs
2114         ZIP=zip
2115         UNZIP=unzip
2116         DOXYGEN=:
2117         ASM_SUFFIX=asm
2118         OBJ_SUFFIX=obj
2119         LIB_SUFFIX=lib
2120         DLL_PREFIX=
2121         LIB_PREFIX=
2122         IMPORT_LIB_SUFFIX=lib
2123         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2124         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2125         MKSHLIB_FORCE_ALL=
2126         MKSHLIB_UNFORCE_ALL=
2127         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2128         _USE_CPP_INCLUDE_FLAG=1
2129         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2130         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2131         CFLAGS="$CFLAGS -W3 -Gy"
2132         CXXFLAGS="$CXXFLAGS -W3 -Gy"
2133         if test "$_CC_SUITE" -ge "12"; then
2134             dnl VS2013+ requires -FS when parallel building by make -jN.
2135             dnl If nothing, compiler sometimes causes C1041 error.
2136             dnl
2137             dnl Visual Studio 2013 supports -Gw flags
2138             dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
2139             CFLAGS="$CFLAGS -FS -Gw"
2140             CXXFLAGS="$CXXFLAGS -FS -Gw"
2141         fi
2142         # khuey says we can safely ignore MSVC warning C4251
2143         # MSVC warning C4244 (implicit type conversion may lose data) warns
2144         # and requires workarounds for perfectly valid code.  Also, GCC/clang
2145         # don't warn about it by default. So for consistency/sanity, we turn
2146         # it off on MSVC, too.
2147         # MSVC warning C4345 warns of newly conformant behavior as of VS2003.
2148         # MSVC warning C4351 warns of newly conformant behavior as of VS2005.
2149         # MSVC warning C4482 warns when an enum value is refered specifing the
2150         # name of the enum itself.  This behavior is allowed in C++11, and the
2151         # warning has been removed in VS2012.
2152         # MSVC warning C4800 warns when a value is implicitly cast to bool,
2153         # because this also forces narrowing to a single byte, which can be a
2154         # perf hit.  But this matters so little in practice (and often we want
2155         # that behavior) that it's better to turn it off.
2156         # MSVC warning C4819 warns some UTF-8 characters (e.g. copyright sign)
2157         # on non-Western system locales even if it is in a comment.
2158         CFLAGS="$CFLAGS -wd4244 -wd4819"
2159         CXXFLAGS="$CXXFLAGS -wd4251 -wd4244 -wd4345 -wd4351 -wd4482 -wd4800 -wd4819"
2160         # make 'foo == bar;' error out
2161         CFLAGS="$CFLAGS -we4553"
2162         CXXFLAGS="$CXXFLAGS -we4553"
2163         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib netapi32.lib"
2164         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2165         WARNINGS_AS_ERRORS='-WX'
2166         MOZ_OPTIMIZE_FLAGS='-O1'
2167         MOZ_FIX_LINK_PATHS=
2168         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2169         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2170         if test -z "$DEVELOPER_OPTIONS"; then
2171             LDFLAGS="$LDFLAGS -RELEASE"
2172         fi
2173         dnl For profile-guided optimization
2174         PROFILE_GEN_CFLAGS="-GL"
2175         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2176         dnl XXX: PGO builds can fail with warnings treated as errors,
2177         dnl specifically "no profile data available" appears to be
2178         dnl treated as an error sometimes. This might be a consequence
2179         dnl of using WARNINGS_AS_ERRORS in some modules, combined
2180         dnl with the linker doing most of the work in the whole-program
2181         dnl optimization/PGO case. I think it's probably a compiler bug,
2182         dnl but we work around it here.
2183         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2184         dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2185         dnl Probably also a compiler bug, but what can you do?
2186         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2187         LDFLAGS="$LDFLAGS -DYNAMICBASE"
2188         dnl Minimum reqiurement of Gecko is VS2010 or later which supports
2189         dnl both SSSE3 and SSE4.1.
2190         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
2191         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
2192     fi
2193     AC_DEFINE(HAVE_SNPRINTF)
2194     AC_DEFINE(_WINDOWS)
2195     AC_DEFINE(WIN32)
2196     AC_DEFINE(XP_WIN)
2197     AC_DEFINE(XP_WIN32)
2198     AC_DEFINE(HW_THREADS)
2199     AC_DEFINE(STDC_HEADERS)
2200     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2201     TARGET_MD_ARCH=win32
2202     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2203     BIN_SUFFIX='.exe'
2204     MOZ_USER_DIR="Mozilla"
2206     dnl Hardcode to win95 for now - cls
2207     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2209     dnl set NO_X11 defines here as the general check is skipped on win32
2210     no_x=yes
2211     AC_DEFINE(NO_X11)
2213     case "$host" in
2214     *-mingw*)
2215         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2216         if test -n "$L10NBASEDIR"; then
2217             L10NBASEDIR=`cd $L10NBASEDIR && pwd -W`
2218         fi
2219         ;;
2220     esac
2222     case "$host" in
2223     *-mingw*)
2224         if test -z "$MOZ_TOOLS"; then
2225             AC_MSG_ERROR([MOZ_TOOLS is not set])
2226         fi
2227         MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2228         if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2229             AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2230         fi
2231         MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2232         if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2233             AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2234         fi
2235         ;;
2236     esac
2238     case "$host_os" in
2239     cygwin*|msvc*|mks*)
2240         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.])
2241         ;;
2242     esac
2244     case "$target" in
2245     i*86-*)
2246         if test "$HAVE_64BIT_OS"; then
2247             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2248         fi
2250         if test -n "$GNU_CC"; then
2251             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
2252             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
2253             LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup -Wl,--large-address-aware"
2254         else
2255             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
2256             LDFLAGS="$LDFLAGS -SAFESEH"
2257         fi
2259         AC_DEFINE(_X86_)
2260         ;;
2261     x86_64-*)
2262         if test -n "$_WIN32_MSVC"; then
2263             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
2264         fi
2265         AC_DEFINE(_AMD64_)
2266         ;;
2267     *)
2268         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2269         ;;
2270     esac
2271     ;;
2273 *-netbsd*)
2274     DSO_CFLAGS=''
2275     CFLAGS="$CFLAGS -Dunix"
2276     CXXFLAGS="$CXXFLAGS -Dunix"
2277     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2278         DLL_SUFFIX=".so"
2279         DSO_PIC_CFLAGS='-fPIC -DPIC'
2280         DSO_LDOPTS='-shared'
2281         BIN_FLAGS='-Wl,--export-dynamic'
2282     else
2283         DSO_PIC_CFLAGS='-fPIC -DPIC'
2284         DLL_SUFFIX=".so.1.0"
2285         DSO_LDOPTS='-shared'
2286     fi
2287     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2288     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2289     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2290     if test "$LIBRUNPATH"; then
2291         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2292     fi
2293     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@) -o $@'
2294     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@)) -o $@'
2295     MMX_FLAGS="-mmmx"
2296     SSE_FLAGS="-msse"
2297     SSE2_FLAGS="-msse2"
2298     ;;
2300 *-openbsd*)
2301     if test "$SO_VERSION"; then
2302         DLL_SUFFIX=".so.$SO_VERSION"
2303     else
2304         DLL_SUFFIX=".so.1.0"
2305     fi
2306     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
2307     DSO_CFLAGS=''
2308     DSO_PIC_CFLAGS='-fPIC'
2309     DSO_LDOPTS='-shared -fPIC'
2310     if test "$LIBRUNPATH"; then
2311         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2312     fi
2313     MMX_FLAGS="-mmmx"
2314     SSE_FLAGS="-msse"
2315     SSE2_FLAGS="-msse2"
2316     ;;
2318 *-solaris*)
2319     AC_DEFINE(SOLARIS)
2320     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2321     MOZ_FIX_LINK_PATHS=
2322     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2323     # libraries one level up (e.g. libnspr4.so)
2324     if test "$SOLARIS_SUNPRO_CC"; then
2325        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2326        LIBS="-lCrun -lCstd -lc $LIBS"
2327        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2328        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2329        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2330        LDFLAGS="-xildoff $LDFLAGS"
2331        MMX_FLAGS="-xarch=mmx -xO4"
2332        SSE_FLAGS="-xarch=sse"
2333        SSE2_FLAGS="-xarch=ssei2 -xO4"
2334        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2335            _SAVE_LDFLAGS=$LDFLAGS
2336            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
2337            AC_TRY_LINK([#include <stdio.h>],
2338                        [printf("Hello World\n");],
2339                        ,
2340                        [LDFLAGS=$_SAVE_LDFLAGS])
2341        fi
2342        MOZ_OPTIMIZE_FLAGS="-xO4"
2343        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
2344        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
2345        MKSHLIB_FORCE_ALL='-z allextract'
2346        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2347        DSO_LDOPTS='-G'
2348        AR_LIST="$AR t"
2349        AR_EXTRACT="$AR x"
2350        AR_DELETE="$AR d"
2351        AR='$(CXX) -xar'
2352        AR_FLAGS='-o $@'
2353        AS='/usr/ccs/bin/as'
2354        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2355        AS_DASH_C_FLAG=''
2356        TARGET_COMPILER_ABI="sunc"
2357        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2358        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2359        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2360        AC_LANG_SAVE
2361        AC_LANG_CPLUSPLUS
2362        AC_TRY_COMPILE([],
2363            [#if (__SUNPRO_CC < 0x590)
2364            #error "Denied"
2365            #endif],
2366            _BAD_COMPILER=,_BAD_COMPILER=1)
2367        if test -n "$_BAD_COMPILER"; then
2368            _res="no"
2369            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2370        else
2371            _res="yes"
2372        fi
2373        AC_TRY_COMPILE([],
2374            [#if (__SUNPRO_CC >= 0x5100)
2375            #error "Sun C++ 5.10 or above"
2376            #endif],
2377            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2378        if test "$_ABOVE_SS12U1"; then
2379            # disable xannotate
2380            CXXFLAGS="$CXXFLAGS -xannotate=no"
2381        fi
2382        AC_MSG_RESULT([$_res])
2383        AC_LANG_RESTORE
2384     else
2385        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2386        LIBS="-lc $LIBS"
2387        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2388        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2389        ASFLAGS="$ASFLAGS -fPIC"
2390        DSO_LDOPTS='-shared'
2391        WARNINGS_AS_ERRORS='-Werror'
2392        _WARNINGS_CFLAGS=''
2393        _WARNINGS_CXXFLAGS=''
2394        if test "$OS_RELEASE" = "5.3"; then
2395            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2396        fi
2397        MMX_FLAGS="-mmmx"
2398        SSE_FLAGS="-msse"
2399        SSE2_FLAGS="-msse2"
2400     fi
2401     if test "$OS_RELEASE" = "5.5.1"; then
2402         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2403     fi
2404     ;;
2406 *-sunos*)
2407     DSO_LDOPTS='-Bdynamic'
2408     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2409     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2410     AC_DEFINE(SUNOS4)
2411     AC_DEFINE(SPRINTF_RETURNS_STRING)
2412     case "$(target_os)" in
2413     sunos4.1*)
2414         DLL_SUFFIX='.so.1.0'
2415         ;;
2416     esac
2417     ;;
2419 esac
2421 AC_SUBST_LIST(MMX_FLAGS)
2422 AC_SUBST_LIST(SSE_FLAGS)
2423 AC_SUBST_LIST(SSE2_FLAGS)
2425 case "$target" in
2426 *-*linux*)
2427     # Includes linux-android
2428     AC_DEFINE(XP_LINUX)
2429     ;;
2430 esac
2432 AC_SUBST(MOZ_LINKER)
2433 if test -n "$MOZ_LINKER"; then
2434   AC_DEFINE(MOZ_LINKER)
2437 dnl Only one oddball right now (QNX), but this gives us flexibility
2438 dnl if any other platforms need to override this in the future.
2439 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2441 dnl ========================================================
2442 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2443 dnl by now will not have any way to link most binaries (tests
2444 dnl as well as viewer, apprunner, etc.), because some symbols
2445 dnl will be left out of the "composite" .so's by ld as unneeded.
2446 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2447 dnl they can link in the static libs that provide the missing
2448 dnl symbols.
2449 dnl ========================================================
2450 NO_LD_ARCHIVE_FLAGS=
2451 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2452     NO_LD_ARCHIVE_FLAGS=1
2454 case "$target" in
2455 *-aix4.3*|*-aix5*)
2456     NO_LD_ARCHIVE_FLAGS=
2457     ;;
2458 *-mingw*)
2459     if test -z "$GNU_CC"; then
2460         NO_LD_ARCHIVE_FLAGS=
2461     fi
2462     ;;
2463 esac
2464 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2466 dnl ========================================================
2467 dnl = Flags to strip unused symbols from .so components and
2468 dnl = to export jemalloc symbols when linking a program
2469 dnl ========================================================
2470 case "$target" in
2471     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2472         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2473         ;;
2474     *-solaris*)
2475         if test -z "$GNU_CC"; then
2476          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2477         else
2478          if test -z "$GCC_USE_GNU_LD"; then
2479           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2480          else
2481           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2482          fi
2483         fi
2484         ;;
2485     *-darwin*)
2486         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2487         ;;
2488     *-mingw*)
2489         if test -n "$GNU_CC"; then
2490            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2491         fi
2492         ;;
2493 esac
2495 if test -z "$COMPILE_ENVIRONMENT"; then
2496     SKIP_COMPILER_CHECKS=1
2497     SKIP_LIBRARY_CHECKS=1
2498 else
2499     MOZ_COMPILER_OPTS
2502 if test -z "$SKIP_COMPILER_CHECKS"; then
2503 dnl Checks for typedefs, structures, and compiler characteristics.
2504 dnl ========================================================
2505 AC_HEADER_STDC
2506 AC_C_CONST
2507 AC_TYPE_MODE_T
2508 AC_TYPE_OFF_T
2509 AC_TYPE_PID_T
2510 AC_TYPE_SIZE_T
2511 AC_LANG_CPLUSPLUS
2512 AC_LANG_C
2513 AC_MSG_CHECKING(for ssize_t)
2514 AC_CACHE_VAL(ac_cv_type_ssize_t,
2515  [AC_TRY_COMPILE([#include <stdio.h>
2516                   #include <sys/types.h>],
2517                  [ssize_t foo = 0;],
2518                  [ac_cv_type_ssize_t=true],
2519                  [ac_cv_type_ssize_t=false])])
2520 if test "$ac_cv_type_ssize_t" = true ; then
2521   AC_DEFINE(HAVE_SSIZE_T)
2522   AC_MSG_RESULT(yes)
2523 else
2524   AC_MSG_RESULT(no)
2526 AC_STRUCT_ST_BLKSIZE
2527 AC_MSG_CHECKING(for siginfo_t)
2528 AC_CACHE_VAL(ac_cv_siginfo_t,
2529  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
2530                   #include <signal.h>],
2531                  [siginfo_t* info;],
2532                  [ac_cv_siginfo_t=true],
2533                  [ac_cv_siginfo_t=false])])
2534 if test "$ac_cv_siginfo_t" = true ; then
2535   AC_DEFINE(HAVE_SIGINFO_T)
2536   AC_MSG_RESULT(yes)
2537 else
2538   AC_MSG_RESULT(no)
2541 AC_LANG_CPLUSPLUS
2543 MOZ_CXX11
2545 AC_LANG_C
2547 dnl Check for .hidden assembler directive and visibility attribute.
2548 dnl Borrowed from glibc configure.in
2549 dnl ===============================================================
2550 if test "$GNU_CC"; then
2551   AC_CACHE_CHECK(for visibility(hidden) attribute,
2552                  ac_cv_visibility_hidden,
2553                  [cat > conftest.c <<EOF
2554                   int foo __attribute__ ((visibility ("hidden"))) = 1;
2556                   ac_cv_visibility_hidden=no
2557                   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2558                     if egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2559                       ac_cv_visibility_hidden=yes
2560                     fi
2561                   fi
2562                   rm -f conftest.[cs]
2563                  ])
2564   if test "$ac_cv_visibility_hidden" = "yes"; then
2565     AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
2567     AC_CACHE_CHECK(for visibility(default) attribute,
2568                    ac_cv_visibility_default,
2569                    [cat > conftest.c <<EOF
2570                     int foo __attribute__ ((visibility ("default"))) = 1;
2572                     ac_cv_visibility_default=no
2573                     if ${CC-cc} -fvisibility=hidden -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2574                       if ! egrep '\.(hidden|private_extern).*foo' conftest.s >/dev/null; then
2575                         ac_cv_visibility_default=yes
2576                       fi
2577                     fi
2578                     rm -f conftest.[cs]
2579                    ])
2580     if test "$ac_cv_visibility_default" = "yes"; then
2581       AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
2583       AC_CACHE_CHECK(for visibility pragma support,
2584                      ac_cv_visibility_pragma,
2585                      [cat > conftest.c <<EOF
2586 #pragma GCC visibility push(hidden)
2587                       int foo_hidden = 1;
2588 #pragma GCC visibility push(default)
2589                       int foo_default = 1;
2591                       ac_cv_visibility_pragma=no
2592                       if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
2593                         if egrep '\.(hidden|private_extern).*foo_hidden' conftest.s >/dev/null; then
2594                           if ! egrep '\.(hidden|private_extern).*foo_default' conftest.s > /dev/null; then
2595                             ac_cv_visibility_pragma=yes
2596                           fi
2597                         fi
2598                       fi
2599                       rm -f conftest.[cs]
2600                     ])
2601       if test "$ac_cv_visibility_pragma" = "yes"; then
2602         AC_CACHE_CHECK(For gcc visibility bug with class-level attributes (GCC bug 26905),
2603                        ac_cv_have_visibility_class_bug,
2604                        [cat > conftest.c <<EOF
2605 #pragma GCC visibility push(hidden)
2606 struct __attribute__ ((visibility ("default"))) TestStruct {
2607   static void Init();
2609 __attribute__ ((visibility ("default"))) void TestFunc() {
2610   TestStruct::Init();
2613                        ac_cv_have_visibility_class_bug=no
2614                        if ! ${CXX-g++} ${CXXFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2615                          ac_cv_have_visibility_class_bug=yes
2616                        else
2617                          if test `egrep -c '@PLT|\\$stub' conftest.S` = 0; then
2618                            ac_cv_have_visibility_class_bug=yes
2619                          fi
2620                        fi
2621                        rm -rf conftest.{c,S}
2622                        ])
2624         AC_CACHE_CHECK(For x86_64 gcc visibility bug with builtins (GCC bug 20297),
2625                        ac_cv_have_visibility_builtin_bug,
2626                        [cat > conftest.c <<EOF
2627 #pragma GCC visibility push(hidden)
2628 #pragma GCC visibility push(default)
2629 #include <string.h>
2630 #pragma GCC visibility pop
2632 __attribute__ ((visibility ("default"))) void Func() {
2633   char c[[100]];
2634   memset(c, 0, sizeof(c));
2637                        ac_cv_have_visibility_builtin_bug=no
2638                        if ! ${CC-cc} ${CFLAGS} ${DSO_PIC_CFLAGS} ${DSO_LDOPTS} -O2 -S -o conftest.S conftest.c > /dev/null 2>&1 ; then
2639                          ac_cv_have_visibility_builtin_bug=yes
2640                        else
2641                          if test `grep -c "@PLT" conftest.S` = 0; then
2642                            ac_cv_visibility_builtin_bug=yes
2643                          fi
2644                        fi
2645                        rm -f conftest.{c,S}
2646                        ])
2647         if test "$ac_cv_have_visibility_builtin_bug" = "no" -a \
2648                 "$ac_cv_have_visibility_class_bug" = "no"; then
2649           VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
2650           WRAP_SYSTEM_INCLUDES=1
2651           STL_FLAGS='-I$(DIST)/stl_wrappers'
2652           WRAP_STL_INCLUDES=1
2653         else
2654           VISIBILITY_FLAGS='-fvisibility=hidden'
2655         fi # have visibility pragma bug
2656       fi   # have visibility pragma
2657     fi     # have visibility(default) attribute
2658   fi       # have visibility(hidden) attribute
2659 fi         # GNU_CC
2661 # visibility hidden flag for Sun Studio on Solaris
2662 if test "$SOLARIS_SUNPRO_CC"; then
2663 VISIBILITY_FLAGS='-xldscope=hidden'
2664 fi         # Sun Studio on Solaris
2666 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2667 AC_SUBST(VISIBILITY_FLAGS)
2669 MOZ_GCC_PR49911
2670 MOZ_GCC_PR39608
2671 if test "$OS_TARGET" != WINNT; then
2672     # Only run this test with clang on non-Windows platforms, because clang
2673     # cannot do enough code gen for now to make this test work correctly.
2674     MOZ_LLVM_PR8927
2677 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
2678 dnl ========================================================
2679 if test "$GNU_CC"; then
2680   CFLAGS_save="${CFLAGS}"
2681   CFLAGS="${CFLAGS} -Werror"
2682   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
2683                  ac_cv_force_align_arg_pointer,
2684                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
2685                                  [],
2686                                  ac_cv_force_align_arg_pointer="yes",
2687                                  ac_cv_force_align_arg_pointer="no")])
2688   CFLAGS="${CFLAGS_save}"
2689   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
2690     HAVE_GCC_ALIGN_ARG_POINTER=1
2691   else
2692     HAVE_GCC_ALIGN_ARG_POINTER=
2693   fi
2695 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
2697 dnl Checks for header files.
2698 dnl ========================================================
2699 AC_HEADER_DIRENT
2700 case "$target_os" in
2701 freebsd*|openbsd*)
2702 # for stuff like -lXshm
2703     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
2704     ;;
2705 esac
2706 MOZ_CHECK_COMMON_HEADERS
2708 dnl These are all the places some variant of statfs can be hiding.
2709 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
2711 dnl Quota support
2712 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
2713 MOZ_CHECK_HEADERS([linux/quota.h],,,[#include <sys/socket.h>])
2715 dnl SCTP support - needs various network include headers
2716 MOZ_CHECK_HEADERS([linux/if_addr.h linux/rtnetlink.h],,,[#include <sys/socket.h>])
2718 MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
2720 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
2721 AC_CACHE_CHECK(for sockaddr_in.sin_len,
2722                    ac_cv_sockaddr_in_sin_len,
2723                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2724                                     #include <sys/types.h>
2725                                     #endif
2726                                     #include <netinet/in.h>
2727                                     struct sockaddr_in x;
2728                                     void *foo = (void*) &x.sin_len;],
2729                                    [],
2730                                    [ac_cv_sockaddr_in_sin_len=true],
2731                                    [ac_cv_sockaddr_in_sin_len=false])])
2732 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
2733   AC_DEFINE(HAVE_SIN_LEN)
2734 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
2735   AC_DEFINE(HAVE_SCONN_LEN)
2738 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
2739                ac_cv_sockaddr_in6_sin6_len,
2740                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2741                                 #include <sys/types.h>
2742                                 #endif
2743                                 #include <netinet/in.h>
2744                                 struct sockaddr_in6 x;
2745                                 void *foo = (void*) &x.sin6_len;],
2746                                [],
2747                                [ac_cv_sockaddr_in6_sin6_len=true],
2748                                [ac_cv_sockaddr_in6_sin6_len=false])])
2749 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
2750   AC_DEFINE(HAVE_SIN6_LEN)
2753 AC_CACHE_CHECK(for sockaddr.sa_len,
2754                ac_cv_sockaddr_sa_len,
2755                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2756                                 #include <sys/types.h>
2757                                 #endif
2758                                 #include <sys/socket.h>
2759                                 struct sockaddr x;
2760                                 void *foo = (void*) &x.sa_len;],
2761                                [],
2762                                [ac_cv_sockaddr_sa_len=true],
2763                                [ac_cv_sockaddr_sa_len=false])])
2764 if test "$ac_cv_sockaddr_sa_len" = true ; then
2765   AC_DEFINE(HAVE_SA_LEN)
2768 AC_ARG_ENABLE(dtrace,
2769               [  --enable-dtrace         build with dtrace support if available (default=no)],
2770               [enable_dtrace="yes"],)
2771 if test "x$enable_dtrace" = "xyes"; then
2772   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
2773   if test -n "$HAVE_DTRACE"; then
2774       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
2775   else
2776       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
2777   fi
2779 AC_SUBST(HAVE_DTRACE)
2781 case $target in
2782 *-aix4.3*|*-aix5*)
2783     ;;
2785     MOZ_CHECK_HEADERS(sys/cdefs.h)
2786     ;;
2787 esac
2789 MOZ_LINUX_PERF_EVENT
2791 dnl Checks for libraries.
2792 dnl ========================================================
2793 case $target in
2794 *-hpux11.*)
2795     ;;
2797     AC_CHECK_LIB(c_r, gethostbyname_r)
2798     ;;
2799 esac
2801 dnl We don't want to link with libdl even if it's present on OS X, since
2802 dnl it's not used and not part of the default installation. OS/2 has dlfcn
2803 dnl in libc.
2804 dnl We don't want to link against libm or libpthread on Darwin since
2805 dnl they both are just symlinks to libSystem and explicitly linking
2806 dnl against libSystem causes issues when debugging (see bug 299601).
2807 case $target in
2808 *-darwin*)
2809     ;;
2811     AC_SEARCH_LIBS(dlopen, dl,
2812         MOZ_CHECK_HEADER(dlfcn.h,
2813         AC_DEFINE(HAVE_DLOPEN)))
2814     ;;
2815 esac
2817 _SAVE_CFLAGS="$CFLAGS"
2818 CFLAGS="$CFLAGS -D_GNU_SOURCE"
2819 AC_CHECK_FUNCS(dladdr memmem)
2820 CFLAGS="$_SAVE_CFLAGS"
2822 if test ! "$GNU_CXX"; then
2824     case $target in
2825     *-aix*)
2826         AC_CHECK_LIB(C_r, demangle)
2827         ;;
2828      *)
2829         AC_CHECK_LIB(C, demangle)
2830         ;;
2831      esac
2834 AC_CHECK_LIB(socket, socket)
2836 XLDFLAGS="$X_LIBS"
2837 XLIBS="$X_EXTRA_LIBS"
2839 dnl ========================================================
2840 dnl Checks for X libraries.
2841 dnl Ordering is important.
2842 dnl Xt is dependent upon SM as of X11R6
2843 dnl ========================================================
2844 if test "$no_x" = "yes"; then
2845     AC_DEFINE(NO_X11)
2846 else
2847     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
2848     XLIBS="-lX11 $XLIBS"
2849     _SAVE_LDFLAGS="$LDFLAGS"
2850     LDFLAGS="$XLDFLAGS $LDFLAGS"
2851     AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
2852         [MISSING_X="$MISSING_X -lX11"], $XLIBS)
2853     AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
2854         [MISSING_X="$MISSING_X -lXext"], $XLIBS)
2856     AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
2857         unset ac_cv_lib_Xt_XtFree
2858         AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
2859         AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
2860         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
2861             [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
2862         ])
2864     # AIX needs the motif library linked before libXt to prevent
2865     # crashes in plugins linked against Motif - Bug #98892
2866     case "${target_os}" in
2867     aix*)
2868         XT_LIBS="-lXm $XT_LIBS"
2869         ;;
2870     esac
2872     dnl ========================================================
2873     dnl = Check for XShm
2874     dnl ========================================================
2875     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
2876         $XLIBS $XEXT_LIBS)
2878     dnl ========================================================
2879     dnl = Check for Xss
2880     dnl ========================================================
2881     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
2882         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
2883             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
2884              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
2886     LDFLAGS="$_SAVE_LDFLAGS"
2887 fi # $no_x
2889 AC_SUBST(XCFLAGS)
2890 AC_SUBST(XLDFLAGS)
2891 AC_SUBST(XLIBS)
2892 AC_SUBST(XEXT_LIBS)
2893 AC_SUBST(XT_LIBS)
2894 AC_SUBST(XSS_LIBS)
2896 dnl ========================================================
2897 dnl = pthread support
2898 dnl = Start by checking whether the system support pthreads
2899 dnl ========================================================
2900 case "$target_os" in
2901 darwin*)
2902     MOZ_USE_PTHREADS=1
2903     ;;
2905     MOZ_CHECK_PTHREADS(pthreads,
2906         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2907         MOZ_CHECK_PTHREADS(pthread,
2908             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2909             MOZ_CHECK_PTHREADS(c_r,
2910                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2911                 MOZ_CHECK_PTHREADS(c,
2912                     MOZ_USE_PTHREADS=1
2913                 )
2914             )
2915         )
2916     )
2917     ;;
2918 esac
2920 dnl ========================================================
2921 dnl Check the command line for --with-pthreads
2922 dnl ========================================================
2923 MOZ_ARG_WITH_BOOL(pthreads,
2924 [  --with-pthreads         Force use of system pthread library with NSPR ],
2925 [ if test "$MOZ_USE_PTHREADS"x = x; then
2926     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2927 fi],
2928     MOZ_USE_PTHREADS=
2929     _PTHREAD_LDFLAGS=
2932 dnl ========================================================
2933 dnl Do the platform specific pthread hackery
2934 dnl ========================================================
2935 if test "$MOZ_USE_PTHREADS"x != x
2936 then
2937     dnl
2938     dnl See if -pthread is supported.
2939     dnl
2940     rm -f conftest*
2941     ac_cv_have_dash_pthread=no
2942     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2943     echo 'int main() { return 0; }' | cat > conftest.c
2944     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2945     if test $? -eq 0; then
2946         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2947             ac_cv_have_dash_pthread=yes
2948             case "$target_os" in
2949             freebsd*)
2950 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2951                 ;;
2952             *)
2953                 CFLAGS="$CFLAGS -pthread"
2954                 CXXFLAGS="$CXXFLAGS -pthread"
2955                 ;;
2956             esac
2957         fi
2958     fi
2959     rm -f conftest*
2960     AC_MSG_RESULT($ac_cv_have_dash_pthread)
2962     dnl
2963     dnl See if -pthreads is supported.
2964     dnl
2965     ac_cv_have_dash_pthreads=no
2966     if test "$ac_cv_have_dash_pthread" = "no"; then
2967         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
2968         echo 'int main() { return 0; }' | cat > conftest.c
2969         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
2970         if test $? -eq 0; then
2971             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2972                 ac_cv_have_dash_pthreads=yes
2973                 CFLAGS="$CFLAGS -pthreads"
2974                 CXXFLAGS="$CXXFLAGS -pthreads"
2975             fi
2976         fi
2977         rm -f conftest*
2978         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
2979     fi
2981     case "$target" in
2982         *-*-freebsd*)
2983             AC_DEFINE(_REENTRANT)
2984             AC_DEFINE(_THREAD_SAFE)
2985             dnl -pthread links in -lpthread, so don't specify it explicitly.
2986             if test "$ac_cv_have_dash_pthread" = "yes"; then
2987                 _PTHREAD_LDFLAGS="-pthread"
2988             fi
2989             ;;
2991         *-*-openbsd*|*-*-bsdi*)
2992             AC_DEFINE(_REENTRANT)
2993             AC_DEFINE(_THREAD_SAFE)
2994             dnl -pthread links in -lc_r, so don't specify it explicitly.
2995             if test "$ac_cv_have_dash_pthread" = "yes"; then
2996                 _PTHREAD_LDFLAGS="-pthread"
2997             fi
2998             ;;
3000         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
3001             AC_DEFINE(_REENTRANT)
3002             ;;
3004         *-aix4.3*|*-aix5*)
3005             AC_DEFINE(_REENTRANT)
3006             ;;
3008         *-hpux11.*)
3009             AC_DEFINE(_REENTRANT)
3010             ;;
3012         *-*-solaris*)
3013             AC_DEFINE(_REENTRANT)
3014             if test "$SOLARIS_SUNPRO_CC"; then
3015                 CFLAGS="$CFLAGS -mt"
3016                 CXXFLAGS="$CXXFLAGS -mt"
3017             fi
3018             ;;
3019     esac
3020     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
3021     AC_SUBST(MOZ_USE_PTHREADS)
3025 dnl Checks for library functions.
3026 dnl ========================================================
3027 AC_PROG_GCC_TRADITIONAL
3028 AC_FUNC_MEMCMP
3029 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize localtime_r)
3031 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
3032 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
3033                ac_cv_clock_monotonic,
3034                [for libs in "" -lrt; do
3035                     _SAVE_LIBS="$LIBS"
3036                     LIBS="$LIBS $libs"
3037                     AC_TRY_LINK([#include <time.h>],
3038                                  [ struct timespec ts;
3039                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
3040                                  ac_cv_clock_monotonic=$libs
3041                                  LIBS="$_SAVE_LIBS"
3042                                  break,
3043                                  ac_cv_clock_monotonic=no)
3044                     LIBS="$_SAVE_LIBS"
3045                 done])
3046 if test "$ac_cv_clock_monotonic" != "no"; then
3047     HAVE_CLOCK_MONOTONIC=1
3048     REALTIME_LIBS=$ac_cv_clock_monotonic
3049     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
3050     AC_SUBST(HAVE_CLOCK_MONOTONIC)
3051     AC_SUBST(REALTIME_LIBS)
3054 dnl check for wcrtomb/mbrtowc
3055 dnl =======================================================================
3056 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
3057 AC_LANG_SAVE
3058 AC_LANG_CPLUSPLUS
3059 AC_CACHE_CHECK(for wcrtomb,
3060     ac_cv_have_wcrtomb,
3061     [AC_TRY_LINK([#include <wchar.h>],
3062                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
3063                  ac_cv_have_wcrtomb="yes",
3064                  ac_cv_have_wcrtomb="no")])
3065 if test "$ac_cv_have_wcrtomb" = "yes"; then
3066     AC_DEFINE(HAVE_WCRTOMB)
3068 AC_CACHE_CHECK(for mbrtowc,
3069     ac_cv_have_mbrtowc,
3070     [AC_TRY_LINK([#include <wchar.h>],
3071                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
3072                  ac_cv_have_mbrtowc="yes",
3073                  ac_cv_have_mbrtowc="no")])
3074 if test "$ac_cv_have_mbrtowc" = "yes"; then
3075     AC_DEFINE(HAVE_MBRTOWC)
3077 AC_LANG_RESTORE
3080 AC_CACHE_CHECK(
3081     [for res_ninit()],
3082     ac_cv_func_res_ninit,
3083     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
3084         dnl no need for res_ninit() on NetBSD and OpenBSD
3085         ac_cv_func_res_ninit=no
3086      else
3087         AC_TRY_LINK([
3088             #ifdef linux
3089             #define _BSD_SOURCE 1
3090             #endif
3091             #include <sys/types.h>
3092             #include <netinet/in.h>
3093             #include <arpa/nameser.h>
3094             #include <resolv.h>
3095             ],
3096             [int foo = res_ninit(&_res);],
3097             [ac_cv_func_res_ninit=yes],
3098             [ac_cv_func_res_ninit=no])
3099      fi
3100     ])
3102 if test "$ac_cv_func_res_ninit" = "yes"; then
3103     AC_DEFINE(HAVE_RES_NINIT)
3104 dnl must add the link line we do something as foolish as this... dougt
3105 dnl else
3106 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3107 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3110 AC_LANG_CPLUSPLUS
3112 case $target_os in
3113     darwin*|mingw*)
3114         ;;
3115     *)
3117 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3118     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3119         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3120 _SAVE_LIBS=$LIBS
3121 LIBS="$LIBS $_ICONV_LIBS"
3122 AC_CACHE_CHECK(
3123     [for iconv()],
3124     ac_cv_func_iconv,
3125     [AC_TRY_LINK([
3126         #include <stdlib.h>
3127         #include <iconv.h>
3128         ],
3129         [
3130             iconv_t h = iconv_open("", "");
3131             iconv(h, NULL, NULL, NULL, NULL);
3132             iconv_close(h);
3133         ],
3134         [ac_cv_func_iconv=yes],
3135         [ac_cv_func_iconv=no]
3136         )]
3137     )
3138 if test "$ac_cv_func_iconv" = "yes"; then
3139     AC_DEFINE(HAVE_ICONV)
3140     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3141     LIBICONV="$_ICONV_LIBS"
3142     AC_CACHE_CHECK(
3143         [for iconv() with const input],
3144         ac_cv_func_const_iconv,
3145         [AC_TRY_COMPILE([
3146             #include <stdlib.h>
3147             #include <iconv.h>
3148             ],
3149             [
3150                 const char *input = "testing";
3151                 iconv_t h = iconv_open("", "");
3152                 iconv(h, &input, NULL, NULL, NULL);
3153                 iconv_close(h);
3154             ],
3155             [ac_cv_func_const_iconv=yes],
3156             [ac_cv_func_const_iconv=no]
3157             )]
3158         )
3159     if test "$ac_cv_func_const_iconv" = "yes"; then
3160         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3161     fi
3163 LIBS=$_SAVE_LIBS
3165     ;;
3166 esac
3168 AM_LANGINFO_CODESET
3170 AC_LANG_C
3172 dnl **********************
3173 dnl *** va_copy checks ***
3174 AC_CACHE_CHECK([for an implementation of va_copy()],
3175                ac_cv_va_copy,
3176     [AC_TRY_COMPILE([#include <stdarg.h>
3177                      #include <stdlib.h>
3178         void f (int i, ...) {
3179             va_list args1, args2;
3180             va_start (args1, i);
3181             va_copy (args2, args1);
3182             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3183                 exit (1);
3184             va_end (args1); va_end (args2);
3185         }],
3186         [f(0, 42); return 0],
3187         [ac_cv_va_copy=yes],
3188         [ac_cv_va_copy=no]
3189     )]
3191 AC_CACHE_CHECK([whether va_list can be copied by value],
3192                ac_cv_va_val_copy,
3193     [AC_TRY_COMPILE([#include <stdarg.h>
3194                      #include <stdlib.h>
3195         void f (int i, ...) {
3196             va_list args1, args2;
3197             va_start (args1, i);
3198             args2 = args1;
3199             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3200                 exit (1);
3201             va_end (args1); va_end (args2);
3202         }],
3203         [f(0, 42); return 0],
3204         [ac_cv_va_val_copy=yes],
3205         [ac_cv_va_val_copy=no],
3206     )]
3208 if test "x$ac_cv_va_copy" = "xyes"; then
3209     AC_DEFINE(VA_COPY, va_copy)
3210     AC_DEFINE(HAVE_VA_COPY)
3213 if test "x$ac_cv_va_val_copy" = "xno"; then
3214    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3217 dnl ===================================================================
3218 dnl ========================================================
3219 dnl Put your C++ language/feature checks below
3220 dnl ========================================================
3221 AC_LANG_CPLUSPLUS
3223 ARM_ABI_PREFIX=
3224 if test "$GNU_CC"; then
3225   if test "$CPU_ARCH" = "arm" ; then
3226     AC_CACHE_CHECK(for ARM EABI,
3227         ac_cv_gcc_arm_eabi,
3228         [AC_TRY_COMPILE([],
3229                         [
3230 #if defined(__ARM_EABI__)
3231   return 0;
3232 #else
3233 #error Not ARM EABI.
3234 #endif
3235                         ],
3236                         ac_cv_gcc_arm_eabi="yes",
3237                         ac_cv_gcc_arm_eabi="no")])
3238     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
3239         HAVE_ARM_EABI=1
3240         ARM_ABI_PREFIX=eabi-
3241     else
3242         ARM_ABI_PREFIX=oabi-
3243     fi
3244   fi
3246   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
3249 dnl Check to see if we can resolve ambiguity with |using|.
3250 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
3251                ac_cv_cpp_ambiguity_resolving_using,
3252                [AC_TRY_COMPILE(class X {
3253                                  public: int go(const X&) {return 3;}
3254                                          int jo(const X&) {return 3;}
3255                                };
3256                                class Y : public X {
3257                                  public:  int go(int) {return 2;}
3258                                           int jo(int) {return 2;}
3259                                           using X::jo;
3260                                  private: using X::go;
3261                                };,
3262                                X x; Y y; y.jo(x);,
3263                                ac_cv_cpp_ambiguity_resolving_using=yes,
3264                                ac_cv_cpp_ambiguity_resolving_using=no)])
3265 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
3266    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
3269 dnl See if a dynamic_cast to void* gives the most derived object.
3270 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
3271                ac_cv_cpp_dynamic_cast_void_ptr,
3272                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
3273                             class Y { int j; public: virtual ~Y() { } };
3274                             class Z : public X, public Y { int k; };
3276                             int main() {
3277                                  Z mdo;
3278                                  X *subx = (X*)&mdo;
3279                                  Y *suby = (Y*)&mdo;
3280                                  return !((((void*)&mdo != (void*)subx) &&
3281                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
3282                                           (((void*)&mdo != (void*)suby) &&
3283                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
3284                             }],
3285                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
3286                            ac_cv_cpp_dynamic_cast_void_ptr=no,
3287                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
3288 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
3289    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
3293 dnl note that this one is reversed - if the test fails, then
3294 dnl we require implementations of unused virtual methods. Which
3295 dnl really blows because it means we'll have useless vtable
3296 dnl bloat.
3297 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
3298                ac_cv_cpp_unused_required,
3299                [AC_TRY_LINK(class X {private: virtual void never_called();};,
3300                                X x;,
3301                                ac_cv_cpp_unused_required=no,
3302                                ac_cv_cpp_unused_required=yes)])
3303 if test "$ac_cv_cpp_unused_required" = yes ; then
3304    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
3308 dnl Some compilers have trouble comparing a constant reference to a templatized
3309 dnl class to zero, and require an explicit operator==() to be defined that takes
3310 dnl an int. This test separates the strong from the weak.
3312 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
3313                ac_cv_trouble_comparing_to_zero,
3314                [AC_TRY_COMPILE([#include <algorithm>
3315                                 template <class T> class Foo {};
3316                                 class T2;
3317                                 template <class T> int operator==(const T2*, const T&) { return 0; }
3318                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
3319                                [Foo<int> f; return (0 != f);],
3320                                ac_cv_trouble_comparing_to_zero=no,
3321                                ac_cv_trouble_comparing_to_zero=yes)])
3322 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
3323   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
3326 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
3327 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
3328 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
3329 # linking XUL.
3330 _SAVE_LDFLAGS=$LDFLAGS
3331 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
3332 AC_CACHE_CHECK(for __thread keyword for TLS variables,
3333                ac_cv_thread_keyword,
3334                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
3335                             [return tlsIsMainThread;],
3336                             ac_cv_thread_keyword=yes,
3337                             ac_cv_thread_keyword=no)])
3338 LDFLAGS=$_SAVE_LDFLAGS
3339 # The custom dynamic linker doesn't support TLS variables
3340 MOZ_TLS=
3341 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
3342   # mips builds fail with TLS variables because of a binutils bug.
3343   # See bug 528687
3344   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
3345   case "${target}" in
3346     mips*-*)
3347       :
3348       ;;
3349     *-android*|*-linuxandroid*)
3350       :
3351       ;;
3352     *-openbsd*)
3353       :
3354       ;;
3355     *)
3356       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
3357       MOZ_TLS=1
3358       ;;
3359   esac
3362 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
3363 if test -n "$MOZ_LINKER"; then
3364   if test "$CPU_ARCH" = arm; then
3365     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
3366     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
3367       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3368       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3369     fi
3370   fi
3373 dnl The custom linker doesn't support text relocations, but NDK >= r6b
3374 dnl creates some (http://code.google.com/p/android/issues/detail?id=23203)
3375 dnl We however want to avoid these text relocations, and this can be done
3376 dnl by making gcc not link crtbegin and crtend. In the broken NDKs, crtend
3377 dnl doesn't contain anything at all, beside placeholders for some sections,
3378 dnl and crtbegin only contains a finalizer function that calls
3379 dnl __cxa_finalize. The custom linker actually takes care of calling
3380 dnl __cxa_finalize when the library doesn't call it itself, which makes it
3381 dnl safe not to link crtbegin. Besides, previous versions of the NDK didn't
3382 dnl link crtbegin and crtend at all.
3383 if test -n "$MOZ_LINKER" -a "$OS_TARGET" = "Android"; then
3384   AC_CACHE_CHECK([whether the CRT objects have text relocations],
3385     ac_cv_crt_has_text_relocations,
3386     [echo 'int foo() { return 0; }' > conftest.cpp
3387      if AC_TRY_COMMAND(${CXX-g++} -o conftest${DLL_SUFFIX} $CXXFLAGS $DSO_LDOPTS $LDFLAGS conftest.cpp $LIBS 1>&5) &&
3388         test -s conftest${DLL_SUFFIX}; then
3389        if ${TOOLCHAIN_PREFIX}readelf -d conftest${DLL_SUFFIX} | grep TEXTREL > /dev/null; then
3390          ac_cv_crt_has_text_relocations=yes
3391        else
3392          ac_cv_crt_has_text_relocations=no
3393        fi
3394      else
3395        AC_ERROR([couldn't compile a simple C file])
3396      fi
3397      rm -rf conftest*])
3398   if test "$ac_cv_crt_has_text_relocations" = yes; then
3399     dnl While we want libraries to skip the CRT files, we don't want
3400     dnl executables to be treated the same way. We thus set the flag
3401     dnl in DSO_LDOPTS and not LDFLAGS. However, to pass it to nspr,
3402     dnl we need to use LDFLAGS because nspr doesn't inherit DSO_LDOPTS.
3403     dnl Using LDFLAGS in nspr is safe, since we only really build
3404     dnl libraries there.
3405     DSO_LDOPTS="$DSO_LDOPTS -nostartfiles"
3406     NSPR_LDFLAGS="$NSPR_LDFLAGS -nostartfiles"
3407   fi
3410 dnl Check for the existence of various allocation headers/functions
3412 MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h"
3413 MALLOC_H=
3415 for file in $MALLOC_HEADERS; do
3416   MOZ_CHECK_HEADER($file, [MALLOC_H=$file])
3417   if test "$MALLOC_H" != ""; then
3418     AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
3419     break
3420   fi
3421 done
3423 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
3425 AC_CHECK_FUNCS(malloc_usable_size)
3427 dnl See if compiler supports some gcc-style attributes
3429 AC_CACHE_CHECK(for __attribute__((always_inline)),
3430                ac_cv_attribute_always_inline,
3431                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
3432                                [],
3433                                ac_cv_attribute_always_inline=yes,
3434                                ac_cv_attribute_always_inline=no)])
3436 AC_CACHE_CHECK(for __attribute__((malloc)),
3437                ac_cv_attribute_malloc,
3438                [AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
3439                                [],
3440                                ac_cv_attribute_malloc=yes,
3441                                ac_cv_attribute_malloc=no)])
3443 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
3444                ac_cv_attribute_warn_unused,
3445                [AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
3446                                [],
3447                                ac_cv_attribute_warn_unused=yes,
3448                                ac_cv_attribute_warn_unused=no)])
3450 dnl End of C++ language/feature checks
3451 AC_LANG_C
3453 dnl ========================================================
3454 dnl =  Internationalization checks
3455 dnl ========================================================
3457 dnl Internationalization and Locale support is different
3458 dnl on various UNIX platforms.  Checks for specific i18n
3459 dnl features go here.
3461 dnl check for LC_MESSAGES
3462 AC_CACHE_CHECK(for LC_MESSAGES,
3463                ac_cv_i18n_lc_messages,
3464                [AC_TRY_COMPILE([#include <locale.h>],
3465                                [int category = LC_MESSAGES;],
3466                                ac_cv_i18n_lc_messages=yes,
3467                                ac_cv_i18n_lc_messages=no)])
3468 if test "$ac_cv_i18n_lc_messages" = yes; then
3469    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
3472 AC_HAVE_FUNCS(localeconv)
3473 fi # ! SKIP_COMPILER_CHECKS
3475 TARGET_XPCOM_ABI=
3476 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
3477     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
3480 dnl Mozilla specific options
3481 dnl ========================================================
3482 dnl The macros used for command line options
3483 dnl are defined in build/autoconf/altoptions.m4.
3485 dnl If the compiler supports these attributes, define them as
3486 dnl convenience macros.
3487 if test "$ac_cv_attribute_malloc" = yes ; then
3488   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
3489 else
3490   AC_DEFINE(NS_ATTR_MALLOC,)
3493 if test "$ac_cv_attribute_warn_unused" = yes ; then
3494   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
3495 else
3496   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
3499 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
3500 dnl features that Windows actually does support.
3502 if test -n "$SKIP_COMPILER_CHECKS"; then
3503    dnl Windows has malloc.h
3504    AC_DEFINE(MALLOC_H, [<malloc.h>])
3505    AC_DEFINE(HAVE_FORCEINLINE)
3506    AC_DEFINE(HAVE_LOCALECONV)
3507 fi # SKIP_COMPILER_CHECKS
3509 dnl ========================================================
3510 dnl =
3511 dnl = Check for external package dependencies
3512 dnl =
3513 dnl ========================================================
3514 MOZ_ARG_HEADER(External Packages)
3516 MOZ_ARG_WITH_STRING(libxul-sdk,
3517 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
3518   LIBXUL_SDK_DIR=$withval)
3520 if test "$LIBXUL_SDK_DIR" = "yes"; then
3521     AC_MSG_ERROR([--with-libxul-sdk must specify a path])
3522 elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
3523     LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
3525     if test ! -f "$LIBXUL_SDK/include/xpcom-config.h"; then
3526         AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
3527     fi
3530 AC_SUBST(LIBXUL_SDK)
3532 if test -n "$LIBXUL_SDK"; then
3533     LIBXUL_DIST="$LIBXUL_SDK"
3534 else
3535     LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
3537 AC_SUBST(LIBXUL_DIST)
3539 SYSTEM_LIBXUL=
3541 MOZ_ARG_WITH_BOOL(system-libxul,
3542 [  --with-system-libxul    Use system installed libxul SDK],
3543     SYSTEM_LIBXUL=1)
3545 dnl ========================================================
3546 dnl = If NSPR was not detected in the system,
3547 dnl = use the one in the source tree (mozilla/nsprpub)
3548 dnl ========================================================
3549 MOZ_ARG_WITH_BOOL(system-nspr,
3550 [  --with-system-nspr      Use system installed NSPR],
3551     _USE_SYSTEM_NSPR=1 )
3553 if test -n "$_USE_SYSTEM_NSPR"; then
3554     AM_PATH_NSPR(4.10.3, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])])
3557 if test -n "$MOZ_NATIVE_NSPR"; then
3558     _SAVE_CFLAGS=$CFLAGS
3559     CFLAGS="$CFLAGS $NSPR_CFLAGS"
3560     AC_TRY_COMPILE([#include "prtypes.h"],
3561                 [#ifndef PR_STATIC_ASSERT
3562                  #error PR_STATIC_ASSERT not defined or requires including prtypes.h
3563                  #endif],
3564                 [MOZ_NATIVE_NSPR=1],
3565                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
3566     AC_TRY_COMPILE([#include "prtypes.h"],
3567                 [#ifndef PR_UINT64
3568                  #error PR_UINT64 not defined or requires including prtypes.h
3569                  #endif],
3570                 [MOZ_NATIVE_NSPR=1],
3571                 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
3572     CFLAGS=$_SAVE_CFLAGS
3573 else
3574     if test -z "$LIBXUL_SDK"; then
3575         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
3576         if test -n "$GNU_CC"; then
3577             NSPR_LIBS="-L${LIBXUL_DIST}/lib -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
3578         else
3579             NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
3580         fi
3581     else
3582         NSPR_CFLAGS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --includedir="${LIBXUL_DIST}/include/nspr" --cflags`
3583         NSPR_LIBS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --libdir="${LIBXUL_DIST}"/lib --libs`
3584     fi
3587 dnl set GRE_MILESTONE
3588 dnl ========================================================
3589 if test -n "$LIBXUL_SDK"; then
3590     GRE_MILESTONE=`$PYTHON "$_topsrcdir"/config/printconfigsetting.py "$LIBXUL_DIST"/bin/platform.ini Build Milestone`
3591 else
3592     GRE_MILESTONE=`tail -n 1 "$_topsrcdir"/config/milestone.txt 2>/dev/null || tail -1 "$_topsrcdir"/config/milestone.txt`
3594 AC_SUBST(GRE_MILESTONE)
3596 # set RELEASE_BUILD and NIGHTLY_BUILD variables depending on the cycle we're in
3597 # The logic works like this:
3598 # - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
3599 # - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
3600 # - otherwise, we're building Release/Beta (define RELEASE_BUILD)
3601 case "$GRE_MILESTONE" in
3602   *a1*)
3603       NIGHTLY_BUILD=1
3604       AC_DEFINE(NIGHTLY_BUILD)
3605       ;;
3606   *a*)
3607       ;;
3608   *)
3609       RELEASE_BUILD=1
3610       AC_DEFINE(RELEASE_BUILD)
3611       ;;
3612 esac
3613 AC_SUBST(NIGHTLY_BUILD)
3614 AC_SUBST(RELEASE_BUILD)
3616 dnl ========================================================
3617 dnl Disable compiling sources in unified mode.
3618 dnl ========================================================
3620 if test -z "$NIGHTLY_BUILD"; then
3621     MOZ_DISABLE_UNIFIED_COMPILATION=1
3624 MOZ_ARG_DISABLE_BOOL(unified-compilation,
3625 [  --disable-unified-compilation
3626                           Disable unified compilation of some C/C++ sources],
3627     MOZ_DISABLE_UNIFIED_COMPILATION=1,
3628     MOZ_DISABLE_UNIFIED_COMPILATION=)
3629 AC_SUBST(MOZ_DISABLE_UNIFIED_COMPILATION)
3631 dnl system libevent Support
3632 dnl ========================================================
3633 MOZ_ARG_WITH_STRING(system-libevent,
3634 [  --with-system-libevent[=PFX]
3635                           Use system libevent [installed at prefix PFX]],
3636     LIBEVENT_DIR=$withval)
3638 _SAVE_CFLAGS=$CFLAGS
3639 _SAVE_LDFLAGS=$LDFLAGS
3640 _SAVE_LIBS=$LIBS
3641 if test "$LIBEVENT_DIR" = yes; then
3642     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
3643         MOZ_NATIVE_LIBEVENT=1,
3644         LIBEVENT_DIR=/usr)
3646 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
3647     MOZ_NATIVE_LIBEVENT=
3648 elif test -z "$MOZ_NATIVE_LIBEVENT"; then
3649     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
3650     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
3651     MOZ_CHECK_HEADER(event.h,
3652         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
3653              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
3654          fi],
3655         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
3656     AC_CHECK_LIB(event, event_init,
3657                  [MOZ_NATIVE_LIBEVENT=1
3658                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
3659                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
3660                  [MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
3662 CFLAGS=$_SAVE_CFLAGS
3663 LDFLAGS=$_SAVE_LDFLAGS
3664 LIBS=$_SAVE_LIBS
3666 AC_SUBST(MOZ_NATIVE_LIBEVENT)
3667 AC_SUBST(MOZ_LIBEVENT_CFLAGS)
3668 AC_SUBST(MOZ_LIBEVENT_LIBS)
3670 dnl ========================================================
3671 dnl = If NSS was not detected in the system,
3672 dnl = use the one in the source tree (mozilla/security/nss)
3673 dnl ========================================================
3675 MOZ_ARG_WITH_BOOL(system-nss,
3676 [  --with-system-nss       Use system installed NSS],
3677     _USE_SYSTEM_NSS=1 )
3679 if test -n "$_USE_SYSTEM_NSS"; then
3680     AM_PATH_NSS(3.16, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
3683 if test -n "$MOZ_NATIVE_NSS"; then
3684    NSS_LIBS="$NSS_LIBS -lcrmf"
3685 else
3686    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
3688    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT"; then
3689        NSS_LIBS="\
3690         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
3691         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
3692         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
3693         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
3694         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
3695    else
3696        NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
3697    fi
3700 dnl ======================
3701 dnl Detect yasm
3702 dnl ======================
3704 AC_MSG_CHECKING([for YASM assembler])
3705 AC_CHECK_PROGS(YASM, yasm, "")
3707 if test -n "$YASM"; then
3708   dnl Pull out yasm's version string
3709   YASM_VERSION=`yasm --version | $AWK '/^yasm/ { print $2 }'`
3710   _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
3711   _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
3712   _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
3713   _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
3716 if test -z "$SKIP_LIBRARY_CHECKS"; then
3717 dnl system JPEG support
3718 dnl ========================================================
3719 MOZ_ARG_WITH_STRING(system-jpeg,
3720 [  --with-system-jpeg[=PFX]
3721                           Use system libjpeg [installed at prefix PFX]],
3722     JPEG_DIR=$withval)
3724 _SAVE_CFLAGS=$CFLAGS
3725 _SAVE_LDFLAGS=$LDFLAGS
3726 _SAVE_LIBS=$LIBS
3727 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
3728     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
3729     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
3731 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
3732     MOZ_NATIVE_JPEG=
3733 else
3734     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_NATIVE_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_NATIVE_JPEG=)
3737 if test "$MOZ_NATIVE_JPEG" = 1; then
3738     AC_TRY_COMPILE([ #include <stdio.h>
3739                      #include <sys/types.h>
3740                      #include <jpeglib.h> ],
3741                    [ #if JPEG_LIB_VERSION < $MOZJPEG
3742                      #error "Insufficient JPEG library version ($MOZJPEG required)."
3743                      #endif
3744                      #ifndef JCS_EXTENSIONS
3745                      #error "libjpeg-turbo JCS_EXTENSIONS required"
3746                      #endif
3747                      ],
3748                    MOZ_NATIVE_JPEG=1,
3749                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
3751 CFLAGS=$_SAVE_CFLAGS
3752 LDFLAGS=$_SAVE_LDFLAGS
3753 LIBS=$_SAVE_LIBS
3755 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
3756     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
3757     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
3759 fi # SKIP_LIBRARY_CHECKS
3761 dnl system ZLIB support
3762 dnl ========================================================
3763 MOZ_ZLIB_CHECK([1.2.3])
3765 if test "$MOZ_NATIVE_ZLIB" != 1; then
3766     MOZ_ZLIB_CFLAGS="-I${_topsrcdir}/modules/zlib/src"
3767     MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,'"$MOZ_BUILD_ROOT"'/modules/zlib/src)'
3770 if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
3771     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
3774 MOZ_PNG_ARM_NEON=
3776 if test -z "$SKIP_LIBRARY_CHECKS"; then
3777 dnl system BZIP2 Support
3778 dnl ========================================================
3779 MOZ_ARG_WITH_STRING(system-bz2,
3780 [  --with-system-bz2[=PFX]
3781                           Use system libbz2 [installed at prefix PFX]],
3782     BZ2_DIR=$withval)
3784 _SAVE_CFLAGS=$CFLAGS
3785 _SAVE_LDFLAGS=$LDFLAGS
3786 _SAVE_LIBS=$LIBS
3787 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
3788     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
3789     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
3791 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
3792     MOZ_NATIVE_BZ2=
3793 else
3794     AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_NATIVE_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
3795     [MOZ_NATIVE_BZ2= MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS=])
3797 CFLAGS=$_SAVE_CFLAGS
3798 LDFLAGS=$_SAVE_LDFLAGS
3799 LIBS=$_SAVE_LIBS
3801 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_NATIVE_BZ2" = 1; then
3802     MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
3803     MOZ_BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
3806 dnl ========================================================
3807 dnl system PNG Support
3808 dnl ========================================================
3809 MOZ_ARG_WITH_STRING(system-png,
3810 [  --with-system-png[=PFX]
3811                           Use system libpng [installed at prefix PFX]],
3812     PNG_DIR=$withval)
3814 _SAVE_CFLAGS=$CFLAGS
3815 _SAVE_LDFLAGS=$LDFLAGS
3816 _SAVE_LIBS=$LIBS
3817 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
3818     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
3819     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
3821 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
3822     MOZ_NATIVE_PNG=
3823 else
3824     AC_CHECK_LIB(png, png_get_valid, [MOZ_NATIVE_PNG=1 MOZ_PNG_LIBS="-lpng"],
3825                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
3826     AC_CHECK_LIB(png, png_get_acTL, ,
3827                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
3829 if test "$MOZ_NATIVE_PNG" = 1; then
3830     AC_TRY_COMPILE([ #include <stdio.h>
3831                      #include <sys/types.h>
3832                      #include <png.h> ],
3833                    [ #if PNG_LIBPNG_VER < $MOZPNG
3834                      #error "Insufficient libpng version ($MOZPNG required)."
3835                      #endif
3836                      #ifndef PNG_UINT_31_MAX
3837                      #error "Insufficient libpng version."
3838                      #endif ],
3839                    MOZ_NATIVE_PNG=1,
3840                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
3842 CFLAGS=$_SAVE_CFLAGS
3843 LDFLAGS=$_SAVE_LDFLAGS
3844 LIBS=$_SAVE_LIBS
3846 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_NATIVE_PNG" = 1; then
3847     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
3848     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
3851 MOZ_PNG_ARM_NEON_CHECK=
3852 if test "$MOZ_NATIVE_PNG" != 1 -a "$CPU_ARCH" = "arm" ; then
3853     MOZ_ARG_ENABLE_STRING(png-arm-neon-support,
3854         [  --enable-png-arm-neon-support=TYPE
3855              Options include:
3856                  no
3857                  check (default)
3858                  nocheck (faster but unsafe)],
3859         [MOZ_PNG_ARM_NEON_SUPPORT=$enableval ] )
3860     case "$MOZ_PNG_ARM_NEON_SUPPORT" in
3861         no)
3862             # enable-png-arm-neon-support = no
3863             ;;
3864         nocheck)
3865             # enable-png-arm-neon-support = nocheck
3866             MOZ_PNG_ARM_NEON=1
3867             ;;
3868         *)
3869             MOZ_PNG_ARM_NEON=1
3870             MOZ_PNG_ARM_NEON_CHECK=1
3871             ;;
3872     esac
3875 AC_SUBST(MOZ_PNG_ARM_NEON_CHECK)
3877 fi # SKIP_LIBRARY_CHECKS
3879 AC_SUBST(MOZ_PNG_ARM_NEON)
3881 dnl ========================================================
3882 dnl system HunSpell Support
3883 dnl ========================================================
3884 MOZ_ARG_ENABLE_BOOL(system-hunspell,
3885 [  --enable-system-hunspell
3886                           Use system hunspell (located with pkgconfig)],
3887     MOZ_NATIVE_HUNSPELL=1 )
3889 if test -n "$MOZ_NATIVE_HUNSPELL"; then
3890     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
3893 AC_SUBST(MOZ_NATIVE_HUNSPELL)
3895 dnl ========================================================
3896 dnl system libffi Support
3897 dnl ========================================================
3898 MOZ_CONFIG_FFI()
3900 if test -n "$MOZ_NATIVE_FFI"; then
3901     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS"
3904 # split JS out by default to avoid VS2005 PGO crash (bug 591836).
3905 if test "$OS_ARCH" = "WINNT"; then
3906   JS_SHARED_LIBRARY=1
3909 MOZ_ARG_ENABLE_BOOL(shared-js,
3910 [  --enable-shared-js
3911                           Create a shared JavaScript library.],
3912     JS_SHARED_LIBRARY=1,
3913     JS_SHARED_LIBRARY=)
3915 dnl ========================================================
3916 dnl Java SDK support
3917 dnl ========================================================
3919 JAVA_BIN_PATH=
3920 MOZ_ARG_WITH_STRING(java-bin-path,
3921 [  --with-java-bin-path=dir
3922                           Location of Java binaries (java, javac, jar)],
3923     JAVA_BIN_PATH=$withval)
3925 dnl ========================================================
3926 dnl =
3927 dnl = Application
3928 dnl =
3929 dnl ========================================================
3931 MOZ_ARG_HEADER(Application)
3933 ENABLE_TESTS=1
3934 ENABLE_SYSTEM_EXTENSION_DIRS=1
3935 MOZ_BRANDING_DIRECTORY=
3936 MOZ_OFFICIAL_BRANDING=
3937 MOZ_FEEDS=1
3938 MOZ_WEBAPP_RUNTIME=
3939 MOZ_JSDEBUGGER=1
3940 MOZ_AUTH_EXTENSION=1
3941 MOZ_RAW=
3942 MOZ_VORBIS=
3943 MOZ_TREMOR=
3944 MOZ_WAVE=1
3945 MOZ_SAMPLE_TYPE_FLOAT32=
3946 MOZ_SAMPLE_TYPE_S16=
3947 MOZ_OPUS=1
3948 MOZ_WEBM=1
3949 MOZ_GSTREAMER=
3950 MOZ_DIRECTSHOW=
3951 MOZ_WMF=
3952 MOZ_FMP4=
3953 MOZ_FFMPEG=
3954 MOZ_WEBRTC=1
3955 MOZ_PEERCONNECTION=
3956 MOZ_SRTP=
3957 MOZ_WEBRTC_SIGNALING=
3958 MOZ_WEBRTC_ASSERT_ALWAYS=1
3959 MOZ_SCTP=
3960 MOZ_MEDIA_PLUGINS=
3961 MOZ_MEDIA_NAVIGATOR=
3962 MOZ_OMX_PLUGIN=
3963 MOZ_VPX=
3964 MOZ_VPX_ERROR_CONCEALMENT=
3965 MOZ_WEBSPEECH=1
3966 VPX_AS=
3967 VPX_ASFLAGS=
3968 VPX_AS_DASH_C_FLAG=
3969 VPX_AS_CONVERSION=
3970 VPX_ASM_SUFFIX=
3971 VPX_X86_ASM=
3972 VPX_ARM_ASM=
3973 LIBJPEG_TURBO_AS=
3974 LIBJPEG_TURBO_ASFLAGS=
3975 LIBJPEG_TURBO_X86_ASM=
3976 LIBJPEG_TURBO_X64_ASM=
3977 LIBJPEG_TURBO_ARM_ASM=
3978 MOZ_PERMISSIONS=1
3979 MOZ_PLACES=1
3980 MOZ_SOCIAL=1
3981 MOZ_PREF_EXTENSIONS=1
3982 MOZ_PROFILELOCKING=1
3983 MOZ_REFLOW_PERF=
3984 MOZ_SAFE_BROWSING=
3985 MOZ_HELP_VIEWER=
3986 MOZ_SPELLCHECK=1
3987 MOZ_ANDROID_OMTC=
3988 MOZ_TOOLKIT_SEARCH=1
3989 MOZ_UI_LOCALE=en-US
3990 MOZ_UNIVERSALCHARDET=1
3991 MOZ_URL_CLASSIFIER=
3992 MOZ_XUL=1
3993 MOZ_ZIPWRITER=1
3994 NS_PRINTING=1
3995 MOZ_PDF_PRINTING=
3996 MOZ_DISABLE_CRYPTOLEGACY=
3997 NSS_DISABLE_DBM=
3998 NECKO_COOKIES=1
3999 NECKO_PROTOCOLS_DEFAULT="about app data file ftp http res viewsource websocket wyciwyg device"
4000 if test -n "$MOZ_RTSP"; then
4001   NECKO_PROTOCOLS_DEFAULT="$NECKO_PROTOCOLS_DEFAULT rtsp"
4003 USE_ARM_KUSER=
4004 BUILD_CTYPES=1
4005 MOZ_USE_NATIVE_POPUP_WINDOWS=
4006 MOZ_ANDROID_HISTORY=
4007 MOZ_WEBSMS_BACKEND=
4008 MOZ_ANDROID_BEAM=
4009 MOZ_ANDROID_SYNTHAPKS=
4010 ACCESSIBILITY=1
4011 MOZ_TIME_MANAGER=
4012 MOZ_PAY=
4013 MOZ_AUDIO_CHANNEL_MANAGER=
4014 NSS_NO_LIBPKIX=
4015 MOZ_CONTENT_SANDBOX=
4016 MOZ_CONTENT_SANDBOX_REPORTER=1
4017 JSGC_USE_EXACT_ROOTING=
4018 JSGC_GENERATIONAL=
4020 case "$target_os" in
4021     mingw*)
4022         NS_ENABLE_TSF=1
4023         AC_DEFINE(NS_ENABLE_TSF)
4024         ;;
4025 esac
4027 case "${target}" in
4028     *-android*|*-linuxandroid*)
4029         if test "$CPU_ARCH" = "arm" ; then
4030           USE_ARM_KUSER=1
4031         fi
4033         NSS_DISABLE_DBM=1
4034         MOZ_THEME_FASTSTRIPE=1
4035         MOZ_TREE_FREETYPE=1
4036         MOZ_MEMORY=1
4037         MOZ_RAW=1
4038         ;;
4040 esac
4042 MOZ_ARG_WITH_STRING(external-source-dir,
4043 [  --with-external-source-dir=dir
4044                           External directory containing additional build files.],
4045 [ EXTERNAL_SOURCE_DIR=$withval])
4046 AC_SUBST(EXTERNAL_SOURCE_DIR)
4048 MOZ_ARG_ENABLE_STRING(application,
4049 [  --enable-application=APP
4050                           Options include:
4051                             browser (Firefox)
4052                             xulrunner
4053                             tools/update-packaging (AUS-related packaging tools)],
4054 [ MOZ_BUILD_APP=$enableval ] )
4056 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
4057 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
4058   XULRUNNER_STUB_NAME=$withval)
4060 if test -z "$XULRUNNER_STUB_NAME"; then
4061   case "$target_os" in
4062   darwin*)
4063     XULRUNNER_STUB_NAME=xulrunner
4064     ;;
4065   *)
4066     XULRUNNER_STUB_NAME=xulrunner-stub
4067   esac
4069 AC_SUBST(XULRUNNER_STUB_NAME)
4071 AC_MSG_CHECKING([for application to build])
4072 if test -z "$MOZ_BUILD_APP"; then
4073   AC_MSG_RESULT([browser])
4074   MOZ_BUILD_APP=browser
4075 else
4076   # "mobile" no longer exists.
4077   if test "$MOZ_BUILD_APP" = "mobile" ; then
4078     AC_MSG_RESULT([none])
4079     AC_MSG_ERROR([--enable-application=mobile is no longer supported.])
4080   fi
4081   # We have a valid application only if it has a build.mk file in its top
4082   # directory.
4083   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
4084     AC_MSG_RESULT([none])
4085     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
4086   else
4087     AC_MSG_RESULT([$MOZ_BUILD_APP])
4088   fi
4091 # The app update channel is 'default' when not supplied. The value is used in
4092 # the application's confvars.sh so it must be set before confvars.sh is called.
4093 MOZ_ARG_ENABLE_STRING([update-channel],
4094 [  --enable-update-channel=CHANNEL
4095                           Select application update channel (default=default)],
4096     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
4098 if test -z "$MOZ_UPDATE_CHANNEL"; then
4099     MOZ_UPDATE_CHANNEL=default
4101 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
4102 AC_SUBST(MOZ_UPDATE_CHANNEL)
4104 # Allow to specify a Mozilla API key file that contains the secret key to be
4105 # used for various Mozilla API requests.
4106 MOZ_ARG_WITH_STRING(mozilla-api-keyfile,
4107 [  --with-mozilla-api-keyfile=file   Use the secret key contained in the given keyfile for Mozilla API requests],
4108   MOZ_MOZILLA_API_KEY=`cat $withval`)
4109 if test -z "$MOZ_MOZILLA_API_KEY"; then
4110     MOZ_MOZILLA_API_KEY=no-mozilla-api-key
4112 AC_SUBST(MOZ_MOZILLA_API_KEY)
4114 # Allow to specify a Google API key file that contains the secret key to be
4115 # used for various Google API requests.
4116 MOZ_ARG_WITH_STRING(google-api-keyfile,
4117 [  --with-google-api-keyfile=file   Use the secret key contained in the given keyfile for Google API requests],
4118   MOZ_GOOGLE_API_KEY=`cat $withval`)
4119 if test -z "$MOZ_GOOGLE_API_KEY"; then
4120     MOZ_GOOGLE_API_KEY=no-google-api-key
4122 AC_SUBST(MOZ_GOOGLE_API_KEY)
4124 # Allow the application to influence configure with a confvars.sh script.
4125 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4126 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4127   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4128   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4129 else
4130   AC_MSG_RESULT([no])
4133 # Allow influencing configure with a defines.sh script.
4134 . "${srcdir}/build/defines.sh"
4136 # If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
4137 # set in defines.sh
4138 if test "$BUILDING_RELEASE"; then
4139   # Override value in defines.sh, if any
4140   EARLY_BETA_OR_EARLIER=
4141 elif test "$EARLY_BETA_OR_EARLIER"; then
4142   AC_DEFINE(EARLY_BETA_OR_EARLIER)
4144 AC_SUBST(EARLY_BETA_OR_EARLIER)
4146 # Allow the application to provide a subconfigure script
4147 if test -f "${srcdir}/${MOZ_BUILD_APP}/configure.in" ; then
4148   do_output_subdirs() {
4149     if test -n "$_subconfigure_subdirs"; then
4150       AC_MSG_ERROR([Cannot specify more than one sub-sub-configure])
4151      fi
4152     _subconfigure_subdir="$1"
4153     _subconfigure_config_args="$ac_configure_args"
4154   }
4155   tmpscript=`$PYTHON -c 'import os, tempfile; print tempfile.mktemp(prefix="subscript.").replace(os.sep, "/")'` || exit 1
4156   m4 "${srcdir}/build/autoconf/subconfigure.m4" \
4157      "${srcdir}/build/autoconf/altoptions.m4" \
4158      "${srcdir}/${MOZ_BUILD_APP}/configure.in" > $tmpscript
4159   . $tmpscript
4160   rm -f $tmpscript
4163 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
4164 MOZ_ARG_WITH_STRING(app-name,
4165 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
4166 WITH_APP_NAME=$withval,
4169 if test -n "$WITH_APP_NAME" ; then
4170     MOZ_APP_NAME="$WITH_APP_NAME"
4173 MOZ_ARG_WITH_STRING(app-basename,
4174 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
4175 WITH_APP_BASENAME=$withval,
4178 if test -n "$WITH_APP_BASENAME" ; then
4179     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
4182 # Now is a good time to test for logic errors, define mismatches, etc.
4183 case "$MOZ_BUILD_APP" in
4184 xulrunner)
4185   if test "$LIBXUL_SDK"; then
4186     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4187   fi
4188   ;;
4189 esac
4191 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4192 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4193 # MOZ_BUILD_APP.
4194 case "$MOZ_BUILD_APP" in
4195 browser)
4196   AC_DEFINE(MOZ_PHOENIX)
4197   ;;
4199 xulrunner)
4200   AC_DEFINE(MOZ_XULRUNNER)
4201   ;;
4202 b2g)
4203   AC_DEFINE(MOZ_B2G)
4204   ;;
4205 esac
4207 AC_SUBST(MOZ_BUILD_APP)
4208 AC_SUBST(MOZ_PHOENIX)
4209 AC_SUBST(MOZ_XULRUNNER)
4210 AC_SUBST(MOZ_B2G)
4211 AC_SUBST(MOZ_B2G_VERSION)
4213 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4215 dnl ========================================================
4216 dnl Check android sdk version depending on mobile target
4217 dnl ========================================================
4219 if test -z "$gonkdir" ; then
4220     # Minimum Android SDK API Level we require.
4221     case "$MOZ_BUILD_APP" in
4222     mobile/android)
4223         android_min_api_level=16
4224         case "$target" in
4225         *-android*|*-linuxandroid*)
4226             :
4227             ;;
4228         *)
4229             AC_MSG_ERROR([You must specify --target=arm-linux-androideabi (or some other valid android target) when building with --enable-application=mobile/android. See https://wiki.mozilla.org/Mobile/Fennec/Android#Setup_Fennec_mozconfig for more information about the necessary options])
4230             ;;
4231         esac
4232         ;;
4233     esac
4235     MOZ_ANDROID_SDK($android_min_api_level)
4238 dnl ========================================================
4239 dnl =
4240 dnl = Toolkit Options
4241 dnl =
4242 dnl ========================================================
4243 MOZ_ARG_HEADER(Toolkit Options)
4245     dnl ========================================================
4246     dnl = Select the default toolkit
4247     dnl ========================================================
4248     MOZ_ARG_ENABLE_STRING(default-toolkit,
4249     [  --enable-default-toolkit=TK
4250                           Select default toolkit
4251                           Platform specific defaults:
4252                             Mac OS X - cairo-cocoa
4253                             Win32 - cairo-windows
4254                             * - cairo-gtk2
4255                             * - cairo-gtk3
4256                             * - cairo-qt],
4257     [ _DEFAULT_TOOLKIT=$enableval ],
4258     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4260     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4261         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4262         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4263         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk3" \
4264         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4265         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
4266         -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
4267         -o "$_DEFAULT_TOOLKIT" = "cairo-android" \
4268         -o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
4269     then
4270         dnl nglayout only supports building with one toolkit,
4271         dnl so ignore everything after the first comma (",").
4272         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4273     else
4274         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4275     fi
4277 MOZ_ARG_WITHOUT_BOOL(x,
4278 [  --without-x              Build without X11],
4279     WITHOUT_X11=1)
4281 dnl ========================================================
4282 dnl = Enable the toolkit as needed                         =
4283 dnl ========================================================
4285 MOZ_WIDGET_GTK=
4287 case "$MOZ_WIDGET_TOOLKIT" in
4289 cairo-windows)
4290     MOZ_WIDGET_TOOLKIT=windows
4291     MOZ_WEBGL=1
4292     MOZ_PDF_PRINTING=1
4293     MOZ_INSTRUMENT_EVENT_LOOP=1
4294     if test -n "$GNU_CC"; then
4295         MOZ_FOLD_LIBS=
4296     fi
4297     ;;
4299 cairo-gtk3)
4300     MOZ_WIDGET_TOOLKIT=gtk3
4301     MOZ_ENABLE_GTK=1
4302     MOZ_ENABLE_GTK3=1
4303     MOZ_ENABLE_XREMOTE=1
4304     MOZ_WEBGL=1
4305     MOZ_GL_DEFAULT_PROVIDER=GLX
4307     AC_DEFINE(MOZ_X11)
4308     MOZ_X11=1
4309     USE_FC_FREETYPE=1
4311     TK_CFLAGS='$(MOZ_GTK3_CFLAGS)'
4312     TK_LIBS='$(MOZ_GTK3_LIBS)'
4313     MOZ_WIDGET_GTK=3
4314     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4315     MOZ_PDF_PRINTING=1
4316     MOZ_INSTRUMENT_EVENT_LOOP=1
4317     ;;
4319 cairo-gtk2|cairo-gtk2-x11)
4320     MOZ_WIDGET_TOOLKIT=gtk2
4321     MOZ_ENABLE_GTK=1
4322     MOZ_ENABLE_GTK2=1
4323     MOZ_ENABLE_XREMOTE=1
4324     MOZ_WEBGL=1
4325     MOZ_GL_DEFAULT_PROVIDER=GLX
4327     AC_DEFINE(MOZ_X11)
4328     MOZ_X11=1
4329     USE_FC_FREETYPE=1
4331     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4332     TK_LIBS='$(MOZ_GTK2_LIBS)'
4333     AC_DEFINE(MOZ_WIDGET_GTK2)
4334     MOZ_WIDGET_GTK=2
4335     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4336     MOZ_PDF_PRINTING=1
4337     MOZ_INSTRUMENT_EVENT_LOOP=1
4338     ;;
4340 cairo-qt)
4341     MOZ_WIDGET_TOOLKIT=qt
4342     MOZ_ENABLE_QT=1
4343     if test -z "$WITHOUT_X11"; then
4344       MOZ_ENABLE_XREMOTE=1
4345       MOZ_GL_DEFAULT_PROVIDER=GLX
4346       MOZ_X11=1
4347       AC_DEFINE(MOZ_X11)
4348       XT_LIBS=
4349     fi
4351     MOZ_WEBGL=1
4352     USE_FC_FREETYPE=1
4353     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4354     TK_LIBS='$(MOZ_QT_LIBS)'
4355     AC_DEFINE(MOZ_WIDGET_QT)
4356     MOZ_PDF_PRINTING=1
4357     AC_DEFINE(QT_NO_KEYWORDS)
4358     ;;
4360 cairo-cocoa)
4361     MOZ_WIDGET_TOOLKIT=cocoa
4362     AC_DEFINE(MOZ_WIDGET_COCOA)
4363     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
4364     TK_LIBS='-framework CoreLocation -framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
4365     TK_CFLAGS="-DNO_X11"
4366     CFLAGS="$CFLAGS $TK_CFLAGS"
4367     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4368     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/bin/XUL $(call EXPAND_LIBNAME_PATH,mozalloc,$(LIBXUL_DIST)/bin)'
4369     MOZ_USER_DIR="Mozilla"
4370     MOZ_FS_LAYOUT=bundle
4371     MOZ_WEBGL=1
4372     MOZ_INSTRUMENT_EVENT_LOOP=1
4373     ;;
4375 cairo-uikit)
4376     MOZ_WIDGET_TOOLKIT=uikit
4377     AC_DEFINE(MOZ_WIDGET_UIKIT)
4378     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
4379     TK_CFLAGS="-DNO_X11"
4380     TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
4381     CFLAGS="$CFLAGS $TK_CFLAGS"
4382     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4383     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/bin/XUL $(call EXPAND_LIBNAME_PATH,mozalloc,$(LIBXUL_DIST)/bin)'
4384     MOZ_USER_DIR="Mozilla"
4385     MOZ_FS_LAYOUT=bundle
4386     ;;
4388 cairo-android)
4389     AC_DEFINE(MOZ_WIDGET_ANDROID)
4390     MOZ_WIDGET_TOOLKIT=android
4391     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4392     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4393     MOZ_WEBGL=1
4394     MOZ_PDF_PRINTING=1
4395     MOZ_INSTRUMENT_EVENT_LOOP=1
4396     ;;
4398 cairo-gonk)
4399     XPCOM_FROZEN_LDOPTS='$(call EXPAND_LIBNAME_PATH,xul mozalloc,$(LIBXUL_DIST)/lib)'
4400     AC_DEFINE(MOZ_WIDGET_GONK)
4401     AC_DEFINE(MOZ_TOUCH)
4402     MOZ_WIDGET_TOOLKIT=gonk
4403     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4404     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4405     MOZ_WEBGL=1
4406     MOZ_PDF_PRINTING=1
4407     MOZ_TOUCH=1
4408     MOZ_INSTRUMENT_EVENT_LOOP=1
4409     ;;
4411 esac
4413 AC_SUBST(MOZ_PDF_PRINTING)
4414 if test "$MOZ_PDF_PRINTING"; then
4415    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
4416    AC_DEFINE(MOZ_PDF_PRINTING)
4419 if test "$MOZ_ENABLE_XREMOTE"; then
4420     AC_DEFINE(MOZ_ENABLE_XREMOTE)
4423 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
4424    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
4427 if test "$COMPILE_ENVIRONMENT"; then
4428   if test "$MOZ_ENABLE_GTK3"; then
4429     PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4430   fi
4431   if test "$MOZ_ENABLE_GTK2"; then
4432     if test "$MOZ_X11"; then
4433       GDK_PACKAGES=gdk-x11-2.0
4434     fi
4436     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4437   fi
4439 fi # COMPILE_ENVIRONMENT
4441 AC_SUBST(MOZ_FS_LAYOUT)
4443 dnl ========================================================
4444 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4445 dnl their usage and use them in spidermonkey.
4446 dnl ========================================================
4447 MOZ_ARG_WITH_BOOL(arm-kuser,
4448 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4449     USE_ARM_KUSER=1,)
4450 if test -n "$USE_ARM_KUSER"; then
4451    AC_DEFINE(USE_ARM_KUSER)
4454 dnl ========================================================
4455 dnl = startup-notification support module
4456 dnl ========================================================
4458 if test "$MOZ_ENABLE_GTK"
4459 then
4460     MOZ_ENABLE_STARTUP_NOTIFICATION=
4462     MOZ_ARG_ENABLE_BOOL(startup-notification,
4463     [  --enable-startup-notification
4464                           Enable startup-notification support (default: disabled) ],
4465         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
4466         MOZ_ENABLE_STARTUP_NOTIFICATION=)
4467     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
4468     then
4469         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
4470                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
4471         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
4472             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
4473             then
4474                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
4475             fi
4476             MOZ_ENABLE_STARTUP_NOTIFICATION=
4477         ])
4478     fi
4480     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
4481         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
4482     fi
4484     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
4486 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
4487 AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
4488 AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
4490 dnl ========================================================
4491 dnl Disable printing
4492 dnl ========================================================
4493 MOZ_ARG_DISABLE_BOOL(printing,
4494 [  --disable-printing      Disable printing support],
4495     NS_PRINTING=,
4496     NS_PRINTING=1)
4498 if test "$NS_PRINTING"; then
4499     AC_DEFINE(NS_PRINTING)
4500     AC_DEFINE(NS_PRINT_PREVIEW)
4503 dnl ========================================================
4504 dnl = QT support
4505 dnl ========================================================
4506 if test "$MOZ_ENABLE_QT"
4507 then
4508     MOZ_ARG_WITH_STRING(qtdir,
4509     [  --with-qtdir=\$dir       Specify Qt directory ],
4510     [ QTDIR=$withval])
4512     if test -z "$QTDIR"; then
4513         AC_CHECK_PROGS(HOST_QMAKE, $HOST_QMAKE qmake, "")
4514     else
4515         HOST_QMAKE="$QTDIR/bin/qmake"
4516     fi
4517     QT_VERSION=`$HOST_QMAKE -v | grep 'Using Qt version' | egrep -o '[[0-9]]+\.[[0-9]]+\.[[0-9]]+'`
4519     if test -z "$QTDIR"; then
4520         case $QT_VERSION in
4521         5.*)
4522             AC_MSG_RESULT("Using qt5: $QT_VERSION")
4523             PKG_CHECK_MODULES(MOZ_QT, Qt5Gui Qt5Network Qt5Core Qt5Quick, ,
4524             [
4525               AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qtbase development packages, (On Ubuntu, you might try installing the packages qtbase5-dev libqt5opengl5-dev.)])
4526             ])
4527             QT5INCDIR=`pkg-config --variable=includedir Qt5Gui`
4528             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QT5INCDIR/QtGui/$QT_VERSION/QtGui"
4529             if test "$NS_PRINTING"; then
4530                 PKG_CHECK_MODULES(MOZ_QT_WIDGETS, Qt5PrintSupport, ,
4531                 [
4532                   AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qtbase widgets development package])
4533                 ])
4534                 MOZ_QT_LIBS="$MOZ_QT_LIBS $MOZ_QT_WIDGETS_LIBS"
4535                 MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $MOZ_QT_WIDGETS_CFLAGS"
4536             fi
4537             ;;
4538         *)
4539             AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION])
4540             ;;
4541         esac
4543         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
4544         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
4545     else
4546         MOZ_QT_CFLAGS="-DQT_SHARED"
4547         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
4548         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
4549         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
4550         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
4551         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
4552         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative"
4553         case $QT_VERSION in
4554         5.*)
4555             AC_MSG_RESULT("Using qt5: $QT_VERSION")
4556             MOZ_QT_LIBS="$MOZ_QT_LIBS -L$QTDIR/lib/ -lQt5Gui -lQt5Network -lQt5Core -lQt5Xml"
4557             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui/$QT_VERSION/QtGui"
4558             if test "$NS_PRINTING"; then
4559                 MOZ_QT_LIBS="$MOZ_QT_LIBS -lQt5Widgets -lQt5PrintSupport"
4560                 MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport"
4561             fi
4562             ;;
4563         *)
4564             AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION])
4565             ;;
4566         esac
4568         HOST_MOC="$QTDIR/bin/moc"
4569         HOST_RCC="$QTDIR/bin/rcc"
4570     fi
4571     if test -z "$HOST_MOC"; then
4572         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is incorrect])
4573     fi
4574     if test -z "$HOST_RCC"; then
4575         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is incorrect])
4576     fi
4578     MOC=$HOST_MOC
4579     RCC=$HOST_RCC
4581     MOZ_ENABLE_QMSYSTEM2=
4582     PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
4583                       MOZ_ENABLE_QMSYSTEM2=1,
4584                       MOZ_ENABLE_QMSYSTEM2=)
4586     if test "$MOZ_ENABLE_QMSYSTEM2"; then
4587       MOZ_ENABLE_QMSYSTEM2=1
4588       MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
4589       MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
4590       AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
4591     fi
4593     MOZ_ENABLE_QTNETWORK=
4594     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
4595                       MOZ_ENABLE_QTNETWORK=1,
4596                       MOZ_ENABLE_QTNETWORK=)
4598     if test "$MOZ_ENABLE_QTNETWORK"; then
4599       MOZ_ENABLE_QTNETWORK=1
4600       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
4601     fi
4603     MOZ_ENABLE_QTMOBILITY=
4604     PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
4605                       MOZ_ENABLE_QTMOBILITY=1,
4606                       MOZ_ENABLE_QTMOBILITY=)
4607     if test "$MOZ_ENABLE_QTMOBILITY"; then
4608        MOZ_ENABLE_QTMOBILITY=1
4609        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
4610        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
4611        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
4612        AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4613     else
4614        AC_CHECK_LIB(QtSensors, main, [
4615           MOZ_ENABLE_QTMOBILITY=1
4616           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMobility"
4617           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtSensors"
4618           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtFeedback"
4619           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtLocation"
4620           MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
4621        ])
4622     fi
4624     MOZ_ENABLE_QT5FEEDBACK=
4625     PKG_CHECK_MODULES(_QT5FEEDBACK, Qt0Feedback,
4626                       MOZ_ENABLE_QT5FEEDBACK=1,
4627                       MOZ_ENABLE_QT5FEEDBACK=)
4628     if test "$MOZ_ENABLE_QT5FEEDBACK"; then
4629        MOZ_ENABLE_QT5FEEDBACK=1
4630        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QT5FEEDBACK_CFLAGS"
4631        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QT5FEEDBACK_LIBS"
4632        AC_DEFINE(MOZ_ENABLE_QT5FEEDBACK)
4633        AC_SUBST(MOZ_ENABLE_QT5FEEDBACK)
4634     fi
4636     MOZ_ENABLE_QT5GEOPOSITION=
4637     PKG_CHECK_MODULES(_QT5GEOPOSITION, Qt5Positioning,
4638                       MOZ_ENABLE_QT5GEOPOSITION=1,
4639                       MOZ_ENABLE_QT5GEOPOSITION=)
4640     if test "$MOZ_ENABLE_QT5GEOPOSITION"; then
4641        MOZ_ENABLE_QT5GEOPOSITION=1
4642        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QT5GEOPOSITION_CFLAGS"
4643        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QT5GEOPOSITION_LIBS"
4644        AC_DEFINE(MOZ_ENABLE_QT5GEOPOSITION)
4645        AC_SUBST(MOZ_ENABLE_QT5GEOPOSITION)
4646     fi
4648     if test "$MOZ_ENABLE_CONTENTACTION"; then
4649       MOZ_ENABLE_CONTENTACTION=1
4650       AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
4651     fi
4653     MOZ_ENABLE_CONTENTACTION=
4654     PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
4655     if test "$MOZ_ENABLE_CONTENTACTION"; then
4656        MOZ_ENABLE_CONTENTACTION=1
4657        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_CONTENTACTION_CFLAGS"
4658        MOZ_QT_LIBS="$MOZ_QT_LIBS $_CONTENTACTION_LIBS"
4659        AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
4660        AC_SUBST(MOZ_ENABLE_CONTENTACTION)
4661     fi
4664 AC_SUBST(GTK_CONFIG)
4665 AC_SUBST(TK_CFLAGS)
4666 AC_SUBST(TK_LIBS)
4668 AC_SUBST(MOZ_ENABLE_GTK2)
4669 AC_SUBST(MOZ_ENABLE_GTK3)
4670 AC_SUBST(MOZ_ENABLE_GTK)
4671 AC_SUBST(MOZ_ENABLE_QT)
4672 AC_SUBST(MOZ_ENABLE_QTNETWORK)
4673 AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
4674 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4675 AC_SUBST(MOZ_ENABLE_XREMOTE)
4676 AC_SUBST(MOZ_GTK2_CFLAGS)
4677 AC_SUBST(MOZ_GTK2_LIBS)
4678 AC_SUBST(MOZ_GTK3_CFLAGS)
4679 AC_SUBST(MOZ_GTK3_LIBS)
4680 AC_SUBST(MOZ_WIDGET_GTK)
4681 AC_SUBST(MOZ_QT_CFLAGS)
4682 AC_SUBST(MOZ_QT_LIBS)
4684 AC_SUBST(MOC)
4685 AC_SUBST(RCC)
4687 AC_SUBST(MOZ_X11)
4689 dnl ========================================================
4690 dnl =
4691 dnl = Components & Features
4692 dnl =
4693 dnl ========================================================
4694 MOZ_ARG_HEADER(Components and Features)
4696 dnl ========================================================
4697 dnl = Localization
4698 dnl ========================================================
4699 MOZ_ARG_ENABLE_STRING(ui-locale,
4700 [  --enable-ui-locale=ab-CD
4701                           Select the user interface locale (default: en-US)],
4702     MOZ_UI_LOCALE=$enableval )
4703 AC_SUBST(MOZ_UI_LOCALE)
4705 dnl ========================================================
4706 dnl = Trademarked Branding
4707 dnl ========================================================
4708 MOZ_ARG_ENABLE_BOOL(official-branding,
4709 [  --enable-official-branding
4710                           Enable Official mozilla.org Branding
4711                           Do not distribute builds with
4712                           --enable-official-branding unless you have
4713                           permission to use trademarks per
4714                           http://www.mozilla.org/foundation/trademarks/ .],
4716   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
4717     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
4718   else
4719     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
4720     MOZ_OFFICIAL_BRANDING=1
4721   fi
4722 ], MOZ_OFFICIAL_BRANDING=)
4724 AC_SUBST(MOZ_OFFICIAL_BRANDING)
4725 if test -n "$MOZ_OFFICIAL_BRANDING"; then
4726   AC_DEFINE(MOZ_OFFICIAL_BRANDING)
4729 MOZ_ARG_WITH_STRING(branding,
4730 [  --with-branding=dir     Use branding from the specified directory.],
4731     MOZ_BRANDING_DIRECTORY=$withval)
4733 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
4734 if test -z "$REAL_BRANDING_DIRECTORY"; then
4735   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
4738 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
4739   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
4742 AC_SUBST(MOZ_BRANDING_DIRECTORY)
4744 dnl ========================================================
4745 dnl = Distribution ID
4746 dnl ========================================================
4747 MOZ_ARG_WITH_STRING(distribution-id,
4748 [  --with-distribution-id=ID
4749                           Set distribution-specific id (default=org.mozilla)],
4750 [ val=`echo $withval`
4751     MOZ_DISTRIBUTION_ID="$val"])
4753 if test -z "$MOZ_DISTRIBUTION_ID"; then
4754    MOZ_DISTRIBUTION_ID="org.mozilla"
4757 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
4758 AC_SUBST(MOZ_DISTRIBUTION_ID)
4761 dnl ========================================================
4762 dnl = Pango
4763 dnl ========================================================
4764 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4765 then
4766     PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
4768     PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
4769     AC_SUBST(MOZ_PANGO_CFLAGS)
4770     AC_SUBST(MOZ_PANGO_LIBS)
4773 dnl ========================================================
4774 dnl = GnomeVFS, GIO and GConf support module
4775 dnl ========================================================
4777 if test "$MOZ_X11"
4778 then
4779     dnl build the GIO extension by default only when the
4780     dnl GTK2 toolkit is in use.
4781     if test "$MOZ_ENABLE_GTK"
4782     then
4783         MOZ_ENABLE_GIO=1
4784         MOZ_ENABLE_GCONF=1
4785     fi
4787     dnl ========================================================
4788     dnl = GnomeVFS support module
4789     dnl ========================================================
4790     MOZ_ARG_ENABLE_BOOL(gnomevfs,
4791     [  --enable-gnomevfs       Enable GnomeVFS support (default: disabled)],
4792         MOZ_ENABLE_GNOMEVFS=force,
4793         MOZ_ENABLE_GNOMEVFS=)
4795     if test "$MOZ_ENABLE_GNOMEVFS"
4796     then
4797         PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
4798             MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
4799             MOZ_ENABLE_GNOMEVFS=1
4800             AC_DEFINE(MOZ_ENABLE_GNOMEVFS)
4801         ],[
4802             if test "$MOZ_ENABLE_GNOMEVFS" = "force"
4803             then
4804                 AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
4805             fi
4806             MOZ_ENABLE_GNOMEVFS=
4807         ])
4808     fi
4810     AC_SUBST(MOZ_ENABLE_GNOMEVFS)
4811     AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
4812     AC_SUBST(MOZ_GNOMEVFS_LIBS)
4814     dnl ========================================================
4815     dnl = GIO support module
4816     dnl ========================================================
4817     MOZ_ARG_DISABLE_BOOL(gio,
4818     [  --disable-gio           Disable GIO support],
4819         MOZ_ENABLE_GIO=,
4820         MOZ_ENABLE_GIO=force)
4822     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK"
4823     then
4824         PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
4825                           [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
4826         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
4827             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
4828             MOZ_ENABLE_GIO=1
4829             AC_DEFINE(MOZ_ENABLE_GIO)
4830         ],[
4831             if test "$MOZ_ENABLE_GIO" = "force"
4832             then
4833                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
4834             fi
4835             MOZ_ENABLE_GIO=
4836         ])
4837     fi
4839     AC_SUBST(MOZ_ENABLE_GIO)
4840     AC_SUBST(MOZ_GIO_CFLAGS)
4841     AC_SUBST(MOZ_GIO_LIBS)
4843     dnl ========================================================
4844     dnl = GConf support module
4845     dnl ========================================================
4846     MOZ_ARG_DISABLE_BOOL(gconf,
4847     [  --disable-gconf      Disable Gconf support ],
4848         MOZ_ENABLE_GCONF=,
4849         MOZ_ENABLE_GCONF=force)
4851     if test "$MOZ_ENABLE_GCONF"
4852     then
4853         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
4854             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
4855             MOZ_ENABLE_GCONF=1
4856         ],[
4857             if test "$MOZ_ENABLE_GCONF" = "force"
4858             then
4859                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
4860             fi
4861             MOZ_ENABLE_GCONF=
4862         ])
4863     fi
4865     if test "$MOZ_ENABLE_GCONF"; then
4866         AC_DEFINE(MOZ_ENABLE_GCONF)
4867     fi
4869     AC_SUBST(MOZ_ENABLE_GCONF)
4870     AC_SUBST(MOZ_GCONF_CFLAGS)
4871     AC_SUBST(MOZ_GCONF_LIBS)
4874 dnl ========================================================
4875 dnl = libproxy support
4876 dnl ========================================================
4878 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4879 then
4880     MOZ_ENABLE_LIBPROXY=
4882     MOZ_ARG_ENABLE_BOOL(libproxy,
4883     [  --enable-libproxy         Enable libproxy support ],
4884     MOZ_ENABLE_LIBPROXY=1,
4885     MOZ_ENABLE_LIBPROXY=)
4887     if test "$MOZ_ENABLE_LIBPROXY"
4888     then
4889         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
4890         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
4891     fi
4893 AC_SUBST(MOZ_ENABLE_LIBPROXY)
4894 AC_SUBST(MOZ_LIBPROXY_CFLAGS)
4895 AC_SUBST(MOZ_LIBPROXY_LIBS)
4897 dnl ========================================================
4898 dnl = GNOME component (mozgnome)
4899 dnl ========================================================
4901 if test "$MOZ_ENABLE_GTK"
4902 then
4903     MOZ_ENABLE_GNOME_COMPONENT=1
4905 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
4907 dnl ========================================================
4908 dnl = libgnomeui support module
4909 dnl ========================================================
4911 if test "$MOZ_ENABLE_GTK"
4912 then
4913     MOZ_ARG_ENABLE_BOOL(gnomeui,
4914     [  --enable-gnomeui        Enable libgnomeui instead of GIO & GTK for icon theme support ],
4915         MOZ_ENABLE_GNOMEUI=force,
4916         MOZ_ENABLE_GNOMEUI=)
4918     if test "$MOZ_ENABLE_GNOMEUI"
4919     then
4920         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
4921         [
4922             MOZ_ENABLE_GNOMEUI=1
4923         ],[
4924             if test "$MOZ_ENABLE_GNOMEUI" = "force"
4925             then
4926                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
4927             fi
4928             MOZ_ENABLE_GNOMEUI=
4929         ])
4930     fi
4932     if test "$MOZ_ENABLE_GNOMEUI"; then
4933         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
4934     fi
4937 AC_SUBST(MOZ_ENABLE_GNOMEUI)
4938 AC_SUBST(MOZ_GNOMEUI_CFLAGS)
4940 dnl ========================================================
4941 dnl = dbus support
4942 dnl ========================================================
4944 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4945 then
4946     MOZ_ENABLE_DBUS=1
4948     MOZ_ARG_DISABLE_BOOL(dbus,
4949     [  --disable-dbus          Disable dbus support ],
4950         MOZ_ENABLE_DBUS=,
4951         MOZ_ENABLE_DBUS=1)
4953     if test "$MOZ_ENABLE_DBUS"
4954     then
4955         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
4956         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
4957         AC_DEFINE(MOZ_ENABLE_DBUS)
4958     fi
4960 AC_SUBST(MOZ_ENABLE_DBUS)
4961 AC_SUBST(MOZ_DBUS_CFLAGS)
4962 AC_SUBST(MOZ_DBUS_LIBS)
4963 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
4964 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
4966 dnl ========================================================
4967 dnl = Enable Android History instead of Places
4968 dnl ========================================================
4969 if test -n "$MOZ_ANDROID_HISTORY"; then
4970     if test -z "$MOZ_PLACES"; then
4971         AC_DEFINE(MOZ_ANDROID_HISTORY)
4972     else
4973         AC_MSG_ERROR([Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.])
4974     fi
4977 dnl ========================================================
4978 dnl = Build with the Android compositor
4979 dnl ========================================================
4980 if test -n "$MOZ_ANDROID_OMTC"; then
4981      dnl Do this if defined in confvars.sh
4982      AC_DEFINE(MOZ_ANDROID_OMTC)
4985 dnl ========================================================
4986 dnl = Disable WebSMS backend
4987 dnl ========================================================
4988 MOZ_ARG_DISABLE_BOOL(websms-backend,
4989 [  --disable-websms-backend
4990                            Disable WebSMS backend],
4991     MOZ_WEBSMS_BACKEND=,
4992     MOZ_WEBSMS_BACKEND=1)
4994 if test -n "$MOZ_WEBSMS_BACKEND"; then
4995     AC_DEFINE(MOZ_WEBSMS_BACKEND)
4998 dnl ========================================================
4999 dnl = Enable NFC permission on Android
5000 dnl ========================================================
5001 if test -n "$MOZ_ANDROID_BEAM"; then
5002     AC_DEFINE(MOZ_ANDROID_BEAM)
5005 dnl ========================================================
5006 dnl = Synthesized Webapp APKs on Android
5007 dnl ========================================================
5008 MOZ_ARG_ENABLE_BOOL(android-synthapks,
5009 [  --enable-android-synthapks       Enable synthesized APKs],
5010     MOZ_ANDROID_SYNTHAPKS=1,
5011     MOZ_ANDROID_SYNTHAPKS=)
5013 if test -n "$MOZ_ANDROID_SYNTHAPKS"; then
5014     AC_DEFINE(MOZ_ANDROID_SYNTHAPKS)
5017 dnl ========================================================
5018 dnl = JS Debugger XPCOM component (js/jsd)
5019 dnl ========================================================
5020 MOZ_ARG_DISABLE_BOOL(jsd,
5021 [  --disable-jsd           Disable JavaScript debug library],
5022     MOZ_JSDEBUGGER=,
5023     MOZ_JSDEBUGGER=1)
5026 dnl ========================================================
5027 dnl = Enable IPDL's "expensive" unit tests
5028 dnl ========================================================
5029 MOZ_IPDL_TESTS=
5031 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
5032 [  --enable-ipdl-tests     Enable expensive IPDL tests],
5033     MOZ_IPDL_TESTS=1,
5034     MOZ_IPDL_TESTS=)
5036 if test -n "$MOZ_IPDL_TESTS"; then
5037     AC_DEFINE(MOZ_IPDL_TESTS)
5040 AC_SUBST(MOZ_IPDL_TESTS)
5042 dnl ========================================================
5043 dnl = Disable building dbm
5044 dnl ========================================================
5045 MOZ_ARG_DISABLE_BOOL(dbm,
5046 [  --disable-dbm           Disable building dbm],
5047     NSS_DISABLE_DBM=1,
5048     NSS_DISABLE_DBM=)
5050 dnl bi-directional support always on
5051 IBMBIDI=1
5052 AC_DEFINE(IBMBIDI)
5054 dnl ========================================================
5055 dnl accessibility support on by default on all platforms
5056 dnl ========================================================
5057 MOZ_ARG_DISABLE_BOOL(accessibility,
5058 [  --disable-accessibility Disable accessibility support],
5059     ACCESSIBILITY=,
5060     ACCESSIBILITY=1 )
5061 if test "$ACCESSIBILITY"; then
5062     case "$target" in
5063     *-mingw*)
5064         if test -z "$MIDL"; then
5065             if test "$GCC" != "yes"; then
5066                 AC_MSG_ERROR([MIDL could not be found. Building accessibility without MIDL is not supported.])
5067             else
5068                 AC_MSG_ERROR([You have accessibility enabled, but widl could not be found. Add --disable-accessibility to your mozconfig or install widl. See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details.])
5069             fi
5070         fi
5071     esac
5072     AC_DEFINE(ACCESSIBILITY)
5075 dnl ========================================================
5076 dnl Accessibility is required for the linuxgl widget
5077 dnl backend
5078 dnl ========================================================
5079 if test "${MOZ_WIDGET_TOOLKIT}" = "linuxgl" -a "$ACCESSIBILITY" != "1"; then
5080     AC_MSG_ERROR(["Accessibility is required for the linuxgl widget backend"])
5083 dnl Turn off webrtc for OS's we don't handle yet, but allow
5084 dnl --enable-webrtc to override.  Can disable for everything in
5085 dnl the master list above.
5086 if test -n "$MOZ_WEBRTC"; then
5087     case "$target" in
5088     *-linux*|*-mingw*|*-darwin*|*-android*|*-linuxandroid*|*-dragonfly*|*-freebsd*|*-netbsd*|*-openbsd*)
5089         dnl Leave enabled
5090         ;;
5091     *)
5092         dnl default to disabled for all others
5093         MOZ_WEBRTC=
5094         ;;
5095     esac
5098 AC_TRY_COMPILE([#include <linux/ethtool.h>],
5099                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
5100                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
5102 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
5104 # target_arch is from {ia32|x64|arm|ppc}
5105 case "$CPU_ARCH" in
5106 x86_64 | arm | x86 | ppc* | ia64)
5107     :
5108     ;;
5110 # unsupported arch for webrtc
5111     MOZ_WEBRTC=
5112     ;;
5114 esac
5116 dnl ========================================================
5117 dnl = Disable WebRTC code
5118 dnl ========================================================
5119 MOZ_ARG_DISABLE_BOOL(webrtc,
5120 [  --disable-webrtc        Disable support for WebRTC],
5121     MOZ_WEBRTC=,
5122     MOZ_WEBRTC=1)
5124 if test -n "$MOZ_WEBRTC"; then
5125     AC_DEFINE(MOZ_WEBRTC)
5126     dnl MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
5127     dnl opt/production builds (via MOZ_CRASH())
5128     AC_DEFINE(MOZ_WEBRTC_ASSERT_ALWAYS)
5129     MOZ_RAW=1
5130     MOZ_VPX=1
5131     MOZ_VPX_ERROR_CONCEALMENT=1
5133 dnl enable once Signaling lands
5134     MOZ_WEBRTC_SIGNALING=1
5135     AC_DEFINE(MOZ_WEBRTC_SIGNALING)
5136 dnl enable once PeerConnection lands
5137     MOZ_PEERCONNECTION=1
5138     AC_DEFINE(MOZ_PEERCONNECTION)
5139     MOZ_SCTP=1
5140     MOZ_SRTP=1
5141     AC_DEFINE(MOZ_SCTP)
5142     AC_DEFINE(MOZ_SRTP)
5143 else
5144     MOZ_SYNTH_PICO=
5147 AC_SUBST(MOZ_WEBRTC)
5148 AC_SUBST(MOZ_WEBRTC_LEAKING_TESTS)
5149 AC_SUBST(MOZ_WEBRTC_SIGNALING)
5150 AC_SUBST(MOZ_PEERCONNECTION)
5151 AC_SUBST(MOZ_WEBRTC_ASSERT_ALWAYS)
5152 AC_SUBST(MOZ_SCTP)
5153 AC_SUBST(MOZ_SRTP)
5155 dnl Use integers over floats for audio on B2G and Android, because audio
5156 dnl backends for those platforms don't support floats.
5157 if test "$OS_TARGET" = "Android"; then
5158     MOZ_SAMPLE_TYPE_S16=1
5159     AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
5160     AC_SUBST(MOZ_SAMPLE_TYPE_S16)
5161 else
5162     MOZ_SAMPLE_TYPE_FLOAT32=1
5163     AC_DEFINE(MOZ_SAMPLE_TYPE_FLOAT32)
5164     AC_SUBST(MOZ_SAMPLE_TYPE_FLOAT32)
5167 dnl ========================================================
5168 dnl = Disable Speech API code
5169 dnl ========================================================
5170 MOZ_ARG_DISABLE_BOOL(webspeech,
5171 [  --disable-webspeech        Disable support for HTML Speech API],
5172     MOZ_WEBSPEECH=,
5173     MOZ_WEBSPEECH=1)
5175 if test -n "$MOZ_WEBSPEECH"; then
5176     AC_DEFINE(MOZ_WEBSPEECH)
5179 AC_SUBST(MOZ_WEBSPEECH)
5181 dnl ========================================================
5182 dnl = Enable Raw Codecs
5183 dnl ========================================================
5184 MOZ_ARG_ENABLE_BOOL(raw,
5185 [  --enable-raw           Enable support for RAW media],
5186     MOZ_RAW=1,
5187     MOZ_RAW=)
5189 if test -n "$MOZ_RAW"; then
5190     AC_DEFINE(MOZ_RAW)
5193 AC_SUBST(MOZ_RAW)
5195 dnl Checks for __attribute__(aligned()) directive need by libogg
5196 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5197     [ac_cv_c_attribute_aligned],
5198     [ac_cv_c_attribute_aligned=0
5199      CFLAGS_save="${CFLAGS}"
5200      CFLAGS="${CFLAGS} -Werror"
5201      for ac_cv_c_attr_align_try in 64 32 16 8; do
5202        echo "trying $ac_cv_c_attr_align_try"
5203        AC_TRY_COMPILE([],
5204                       [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5205                       [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5206        if test "$ac_cv_c_attribute_aligned" != 0; then
5207          break;
5208        fi
5209      done
5210        CFLAGS="${CFLAGS_save}"])
5211 if test "${ac_cv_c_attribute_aligned}" != "0"; then
5212   AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5213                      [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5216 dnl ========================================================
5217 dnl = Disable Opus audio codec support
5218 dnl ========================================================
5219 MOZ_ARG_DISABLE_BOOL(opus,
5220 [  --disable-opus          Disable support for Opus audio],
5221     MOZ_OPUS=,
5222     MOZ_OPUS=1)
5224 dnl ========================================================
5225 dnl = Disable VP8 decoder support
5226 dnl ========================================================
5227 MOZ_ARG_DISABLE_BOOL(webm,
5228 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
5229     MOZ_WEBM=,
5230     MOZ_WEBM=1)
5232 if test -n "$MOZ_WEBM"; then
5233     AC_DEFINE(MOZ_WEBM)
5234     MOZ_VPX=1
5237 dnl ========================================================
5238 dnl = DirectShow support
5239 dnl ========================================================
5240 if test "$OS_ARCH" = "WINNT"; then
5241     dnl Enable DirectShow support by default.
5242     MOZ_DIRECTSHOW=1
5245 MOZ_ARG_DISABLE_BOOL(directshow,
5246 [  --disable-directshow  Disable support for DirectShow],
5247     MOZ_DIRECTSHOW=,
5248     MOZ_DIRECTSHOW=1)
5250 if test -n "$MOZ_DIRECTSHOW"; then
5251     AC_DEFINE(MOZ_DIRECTSHOW)
5254 dnl ========================================================
5255 dnl = Windows Media Foundation support
5256 dnl ========================================================
5257 if test "$OS_ARCH" = "WINNT"; then
5258     dnl Enable Windows Media Foundation support by default.
5259     dnl Note our minimum SDK version is Windows 7 SDK, so we are (currently)
5260     dnl guaranteed to have a recent-enough SDK to build WMF.
5261     MOZ_WMF=1
5264 MOZ_ARG_DISABLE_BOOL(wmf,
5265 [  --disable-wmf  Disable support for Windows Media Foundation],
5266     MOZ_WMF=,
5267     MOZ_WMF=1)
5269 if test -n "$MOZ_WMF"; then
5270     AC_DEFINE(MOZ_WMF)
5273 dnl ========================================================
5274 dnl FFmpeg H264/AAC Decoding Support
5275 dnl ========================================================
5276 case "$OS_TARGET" in
5277 WINNT|Darwin|Android)
5278     ;;
5280     MOZ_FFMPEG=1
5281     ;;
5282 esac
5284 MOZ_ARG_DISABLE_BOOL(ffmpeg,
5285 [  --disable-ffmpeg         Disable FFmpeg for fragmented H264/AAC decoding],
5286     MOZ_FFMPEG=,
5287     MOZ_FFMPEG=1
5290 if test -n "$MOZ_FFMPEG"; then
5291     AC_DEFINE(MOZ_FFMPEG)
5294 dnl ========================================================
5295 dnl = Built-in fragmented MP4 support.
5296 dnl ========================================================
5297 if test -n "$MOZ_WMF" -o -n "$MOZ_FFMPEG"; then
5298     dnl Enable fragmented MP4 parser on Windows by default.
5299     dnl We will also need to enable it on other platforms as we implement
5300     dnl platform decoder support there too.
5301     MOZ_FMP4=1
5304 MOZ_ARG_DISABLE_BOOL(fmp4,
5305 [  --disable-fmp4  Disable support for in built Fragmented MP4 parsing],
5306     MOZ_FMP4=,
5307     MOZ_FMP4=1)
5309 if test -n "$MOZ_FMP4"; then
5310     AC_DEFINE(MOZ_FMP4)
5314 dnl ========================================================
5315 dnl = Enable media plugin support
5316 dnl ========================================================
5317 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5318   dnl Enable support on android by default
5319   MOZ_MEDIA_PLUGINS=1
5322 MOZ_ARG_ENABLE_BOOL(media-plugins,
5323 [  --enable-media-plugins  Enable support for media plugins],
5324     MOZ_MEDIA_PLUGINS=1,
5325     MOZ_MEDIA_PLUGINS=)
5327 if test -n "$MOZ_MEDIA_PLUGINS"; then
5328   AC_DEFINE(MOZ_MEDIA_PLUGINS)
5331 dnl ========================================================
5332 dnl = Disable platform MP3 decoder on OSX
5333 dnl ========================================================
5334 if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
5335   MOZ_APPLEMEDIA=1
5338 MOZ_ARG_DISABLE_BOOL(apple-media,
5339 [  --disable-apple-media  Disable support for Apple AudioToolbox/VideoToolbox],
5340     MOZ_APPLEMEDIA=,
5341     MOZ_APPLEMEDIA=1)
5343 if test -n "$MOZ_APPLEMEDIA"; then
5344   AC_DEFINE(MOZ_APPLEMEDIA)
5347 dnl ========================================================
5348 dnl = Enable getUserMedia support
5349 dnl ========================================================
5350 MOZ_ARG_ENABLE_BOOL(media-navigator,
5351 [  --enable-media-navigator  Enable support for getUserMedia],
5352     MOZ_MEDIA_NAVIGATOR=1,
5353     MOZ_MEDIA_NAVIGATOR=)
5355 if test -n "$MOZ_MEDIA_NAVIGATOR"; then
5356   AC_DEFINE(MOZ_MEDIA_NAVIGATOR)
5359 dnl ========================================================
5360 dnl = Enable building OMX media plugin (B2G or Android)
5361 dnl ========================================================
5362 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5363   dnl Enable support on android by default
5364   MOZ_OMX_PLUGIN=1
5367 MOZ_ARG_ENABLE_BOOL(omx-plugin,
5368 [  --enable-omx-plugin      Enable building OMX plugin (B2G)],
5369     MOZ_OMX_PLUGIN=1,
5370     MOZ_OMX_PLUGIN=)
5372 if test -n "$MOZ_OMX_PLUGIN"; then
5373     if test "$OS_TARGET" = "Android"; then
5374         dnl Only allow building OMX plugin on Gonk (B2G) or Android
5375         AC_DEFINE(MOZ_OMX_PLUGIN)
5376     else
5377        dnl fail if we're not building on Gonk or Android
5378        AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
5379     fi
5382 dnl system libvpx Support
5383 dnl ========================================================
5384 MOZ_ARG_WITH_BOOL(system-libvpx,
5385 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
5386     MOZ_NATIVE_LIBVPX=1)
5388 MOZ_LIBVPX_CFLAGS=
5389 MOZ_LIBVPX_LIBS=
5391 if test -n "$MOZ_VPX"; then
5392     AC_DEFINE(MOZ_VPX)
5393     if test -n "$MOZ_VPX_ERROR_CONCEALMENT" ; then
5394         AC_DEFINE(MOZ_VPX_ERROR_CONCEALMENT)
5395     fi
5397     if test -n "$MOZ_NATIVE_LIBVPX"; then
5398         dnl ============================
5399         dnl === libvpx Version check ===
5400         dnl ============================
5401         dnl Check to see if we have a system libvpx package.
5402         PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.3.0)
5404         MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [],
5405          [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.])])
5407         _SAVE_LIBS=$LIBS
5408         AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [],
5409          [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
5410         LIBS=$_SAVE_LIBS
5411     fi
5414 AC_SUBST(MOZ_NATIVE_LIBVPX)
5415 AC_SUBST(MOZ_LIBVPX_CFLAGS)
5416 AC_SUBST(MOZ_LIBVPX_LIBS)
5418 if test "$MOZ_WEBM"; then
5419     if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then
5420         MOZ_VORBIS=1
5421     else
5422         MOZ_TREMOR=1
5423     fi
5426 if test -n "$MOZ_VPX" -a -z "$MOZ_NATIVE_LIBVPX"; then
5428     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
5429     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
5430     dnl We currently require gcc on all arm platforms.
5431     VPX_AS=$YASM
5432     VPX_ASM_SUFFIX=asm
5433     VPX_NEED_OBJ_INT_EXTRACT=
5435     dnl See if we have assembly on this platform.
5436     case "$OS_ARCH:$CPU_ARCH" in
5437     Darwin:x86)
5438       VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
5439       VPX_X86_ASM=1
5440     ;;
5441     Darwin:x86_64)
5442       VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
5443       VPX_X86_ASM=1
5444     ;;
5445     WINNT:x86_64)
5446       VPX_ASFLAGS="-f x64 -rnasm -pnasm"
5447       VPX_X86_ASM=1
5448     ;;
5449     WINNT:x86)
5450       dnl Check for yasm 1.1 or greater.
5451       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
5452         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.])
5453       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5454         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.])
5455       else
5456         VPX_ASFLAGS="-f win32 -rnasm -pnasm -DPIC"
5457         VPX_X86_ASM=1
5458         dnl The encoder needs obj_int_extract to get asm offsets.
5459       fi
5460     ;;
5461     *:arm*)
5462       if test -n "$GNU_AS" ; then
5463         VPX_AS=$AS
5464         dnl These flags are a lie; they're just used to enable the requisite
5465         dnl opcodes; actual arch detection is done at runtime.
5466         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
5467         VPX_DASH_C_FLAG="-c"
5468         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
5469         VPX_ASM_SUFFIX="$ASM_SUFFIX"
5470         VPX_ARM_ASM=1
5471       fi
5472     ;;
5473     *:x86)
5474       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5475         VPX_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC"
5476         VPX_X86_ASM=1
5477       fi
5478     ;;
5479     *:x86_64)
5480       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5481         VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5482         VPX_X86_ASM=1
5483       fi
5484     ;;
5485     esac
5487     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_X86_ASM" -a -z "$VPX_AS"; then
5488       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.])
5489     fi
5491     if test -z "$GNU_CC" -a -z "$INTEL_CC" -a -z "$CLANG_CC" ; then
5492       dnl We prefer to get asm offsets using inline assembler, which the above
5493       dnl compilers can do. When we're not using one of those, we have to fall
5494       dnl back to obj_int_extract, which reads them from a compiled object
5495       dnl file. Unfortunately, that only works if we're compiling on a system
5496       dnl with the header files for the appropriate object file format.
5497       VPX_NEED_OBJ_INT_EXTRACT=1
5498     fi
5500     if test -n "$VPX_X86_ASM"; then
5501       AC_DEFINE(VPX_X86_ASM)
5502     elif test -n "$VPX_ARM_ASM"; then
5503       AC_DEFINE(VPX_ARM_ASM)
5504     else
5505       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
5506     fi
5509 dnl ========================================================
5510 dnl = Disable Wave decoder support
5511 dnl ========================================================
5512 MOZ_ARG_DISABLE_BOOL(wave,
5513 [  --disable-wave          Disable Wave decoder support],
5514     MOZ_WAVE=,
5515     MOZ_WAVE=1)
5517 if test -n "$MOZ_WAVE"; then
5518     AC_DEFINE(MOZ_WAVE)
5521 dnl ========================================================
5522 dnl = Handle dependent MEDIA defines
5523 dnl ========================================================
5525 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
5526     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/])
5529 if test -n "$MOZ_WEBRTC" -a -z "$MOZ_OPUS"; then
5530     AC_MSG_ERROR([MOZ_WEBRTC requires MOZ_OPUS which is disabled.])
5533 if test -n "$MOZ_VORBIS"; then
5534     AC_DEFINE(MOZ_VORBIS)
5537 if test -n "$MOZ_TREMOR"; then
5538     AC_DEFINE(MOZ_TREMOR)
5541 if test -n "$MOZ_OPUS"; then
5542     AC_DEFINE(MOZ_OPUS)
5545 if test -n "$MOZ_WEBM_ENCODER"; then
5546     AC_DEFINE(MOZ_WEBM_ENCODER)
5548 AC_SUBST(MOZ_WEBM_ENCODER)
5550 dnl ==================================
5551 dnl = Check alsa availability on Linux
5552 dnl ==================================
5554 dnl If using Linux, ensure that the alsa library is available
5555 if test "$OS_TARGET" = "Linux"; then
5556     MOZ_ALSA=1
5559 MOZ_ARG_ENABLE_BOOL(alsa,
5560 [  --enable-alsa          Enable Alsa support (default on Linux)],
5561    MOZ_ALSA=1,
5562    MOZ_ALSA=)
5564 if test -n "$MOZ_ALSA"; then
5565     PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5566          [echo "$MOZ_ALSA_PKG_ERRORS"
5567           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.)])])
5570 AC_SUBST(MOZ_ALSA)
5571 AC_SUBST(MOZ_ALSA_CFLAGS)
5572 AC_SUBST(MOZ_ALSA_LIBS)
5574 dnl ========================================================
5575 dnl = Disable PulseAudio
5576 dnl ========================================================
5578 dnl If using Linux, ensure that the PA library is available
5579 case "$OS_TARGET" in
5580 WINNT|Darwin|Android|OpenBSD)
5581     ;;
5583     if test -z "$MOZ_B2G"; then
5584         MOZ_PULSEAUDIO=1
5585     fi
5586     ;;
5587 esac
5589 MOZ_ARG_DISABLE_BOOL(pulseaudio,
5590 [  --disable-pulseaudio          Disable PulseAudio support],
5591    MOZ_PULSEAUDIO=,
5592    MOZ_PULSEAUDIO=1)
5594 if test -n "$MOZ_PULSEAUDIO"; then
5595     if test -z "$gonkdir"; then
5596         PKG_CHECK_MODULES(MOZ_PULSEAUDIO, libpulse, ,
5597              [echo "$MOZ_PULSEAUDIO_PKG_ERRORS"
5598               AC_MSG_ERROR([pulseaudio audio backend requires libpulse development package])])
5599     else
5600         MOZ_PULSEAUDIO_CFLAGS="-I$gonkdir/external/pulseaudio/pulseaudio/src"
5601     fi
5604 AC_SUBST(MOZ_PULSEAUDIO)
5605 AC_SUBST(MOZ_PULSEAUDIO_CFLAGS)
5607 dnl ========================================================
5608 dnl = Enable GStreamer
5609 dnl ========================================================
5610 case "$OS_TARGET" in
5611 WINNT|Darwin|Android)
5612     ;;
5614     MOZ_GSTREAMER=1
5615     GST_API_VERSION=0.10
5616     ;;
5617 esac
5619 MOZ_ARG_ENABLE_STRING(gstreamer,
5620 [  --enable-gstreamer[=0.10]           Enable GStreamer support],
5621 [ MOZ_GSTREAMER=1
5622   # API version, eg 0.10, 1.0 etc
5623   if test -z "$enableval" -o "$enableval" = "yes"; then
5624     GST_API_VERSION=0.10
5625   elif test "$enableval" = "no"; then
5626     MOZ_GSTREAMER=
5627   else
5628     GST_API_VERSION=$enableval
5629   fi],
5632 if test -n "$MOZ_GSTREAMER"; then
5633     # core/base release number
5634     if test "$GST_API_VERSION" = "1.0"; then
5635       GST_VERSION=1.0
5636     else
5637       GST_VERSION=0.10.25
5638     fi
5640     PKG_CHECK_MODULES(GSTREAMER,
5641                       gstreamer-$GST_API_VERSION >= $GST_VERSION
5642                       gstreamer-app-$GST_API_VERSION
5643                       gstreamer-plugins-base-$GST_API_VERSION,
5644                       [_HAVE_GSTREAMER=1],
5645                       [_HAVE_GSTREAMER=])
5646     if test -z "$_HAVE_GSTREAMER"; then
5647         AC_MSG_ERROR([gstreamer and gstreamer-plugins-base development packages are needed to build gstreamer backend. Install them or disable gstreamer support with --disable-gstreamer])
5648     fi
5650     _SAVE_LDFLAGS=$LDFLAGS
5651     LDFLAGS="$LDFLAGS $GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5652     AC_TRY_LINK(,[return 0;],_HAVE_LIBGSTVIDEO=1,_HAVE_LIBGSTVIDEO=)
5653     if test -n "$_HAVE_LIBGSTVIDEO" ; then
5654         GSTREAMER_LIBS="$GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5655     else
5656         AC_MSG_ERROR([gstreamer-plugins-base found, but no libgstvideo. Something has gone terribly wrong. Try reinstalling gstreamer-plugins-base; failing that, disable the gstreamer backend with --disable-gstreamer.])
5657     fi
5658     LDFLAGS=$_SAVE_LDFLAGS
5660     AC_SUBST(GSTREAMER_CFLAGS)
5661     AC_SUBST(GSTREAMER_LIBS)
5664 AC_SUBST(MOZ_GSTREAMER)
5665 AC_SUBST(GST_API_VERSION)
5667 if test -n "$MOZ_GSTREAMER"; then
5668      AC_DEFINE(MOZ_GSTREAMER)
5669      AC_DEFINE_UNQUOTED(GST_API_VERSION, "$GST_API_VERSION")
5673 dnl ========================================================
5674 dnl Permissions System
5675 dnl ========================================================
5676 MOZ_ARG_DISABLE_BOOL(permissions,
5677 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5678     MOZ_PERMISSIONS=,
5679     MOZ_PERMISSIONS=1
5682 dnl ========================================================
5683 dnl Child permissions, currently only used for b2g
5684 dnl ========================================================
5685 if test -n "$MOZ_B2G"; then
5686     if test -n "$MOZ_PERMISSIONS"; then
5687         MOZ_CHILD_PERMISSIONS=1
5688     else
5689         AC_MSG_ERROR([You need to enable MOZ_PERMISSIONS for MOZ_CHILD_PERMISSIONS])
5690     fi
5692 AC_SUBST(MOZ_CHILD_PERMISSIONS)
5694 dnl ========================================================
5695 dnl NegotiateAuth
5696 dnl ========================================================
5697 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5698 [  --disable-negotiateauth Disable GSS-API negotiation ],
5699     MOZ_AUTH_EXTENSION=,
5700     MOZ_AUTH_EXTENSION=1 )
5702 dnl ========================================================
5703 dnl Pref extensions (autoconfig)
5704 dnl ========================================================
5705 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5706 [  --disable-pref-extensions
5707                           Disable pref extensions such as autoconfig],
5708   MOZ_PREF_EXTENSIONS=,
5709   MOZ_PREF_EXTENSIONS=1 )
5711 dnl ========================================================
5712 dnl Searching of system directories for extensions.
5713 dnl Note: this switch is meant to be used for test builds
5714 dnl whose behavior should not depend on what happens to be
5715 dnl installed on the local machine.
5716 dnl ========================================================
5717 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
5718 [  --disable-system-extension-dirs
5719                           Disable searching system- and account-global
5720                           directories for extensions of any kind; use
5721                           only profile-specific extension directories],
5722   ENABLE_SYSTEM_EXTENSION_DIRS=,
5723   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
5724 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
5725   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
5728 dnl ========================================================
5729 dnl = Universalchardet
5730 dnl ========================================================
5731 MOZ_ARG_DISABLE_BOOL(universalchardet,
5732 [  --disable-universalchardet
5733                           Disable universal encoding detection],
5734   MOZ_UNIVERSALCHARDET=,
5735   MOZ_UNIVERSALCHARDET=1 )
5737 if test -n "${JAVA_BIN_PATH}"; then
5738   dnl Look for javac and jar in the specified path.
5739   JAVA_PATH="$JAVA_BIN_PATH"
5740 else
5741   dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5742   JAVA_PATH="$JAVA_HOME/bin:$PATH"
5745 MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5746 MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5747 MOZ_PATH_PROG(JAVAH, javah, :, [$JAVA_PATH])
5748 MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5749 MOZ_PATH_PROG(JARSIGNER, jarsigner, :, [$JAVA_PATH])
5750 MOZ_PATH_PROG(KEYTOOL, keytool, :, [$JAVA_PATH])
5752 if test -n "${JAVA_BIN_PATH}" -o \
5753   \( "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk" \); then
5754   if test -z "$JAVA" -o "$JAVA" = ":"; then
5755     AC_MSG_ERROR([The program java was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5756   fi
5757   if test -z "$JAVAC" -o "$JAVAC" = ":"; then
5758     AC_MSG_ERROR([The program javac was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5759   fi
5760   if test -z "$JAVAH" -o "$JAVAH" = ":"; then
5761     AC_MSG_ERROR([The program javah was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5762   fi
5763   if test -z "$JAR" -o "$JAR" = ":"; then
5764     AC_MSG_ERROR([The program jar was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5765   fi
5766   if test -z "$JARSIGNER" -o "$JARSIGNER" = ":"; then
5767     AC_MSG_ERROR([The program jarsigner was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5768   fi
5769   if test -z "$KEYTOOL" -o "$KEYTOOL" = ":"; then
5770     AC_MSG_ERROR([The program keytool was not found.  Set \$JAVA_HOME to your Java SDK directory or use --with-java-bin-path={java-bin-dir}])
5771   fi
5774 dnl ========================================================
5775 dnl = ANGLE OpenGL->D3D translator for WebGL
5776 dnl = * only applies to win32
5777 dnl = * enabled by default (shipping build); requires explicit --disable to disable
5778 dnl ========================================================
5779 MOZ_ANGLE_RENDERER=
5780 MOZ_DIRECTX_SDK_CPU_SUFFIX=
5781 MOZ_DIRECTX_SDK_PATH=
5782 MOZ_D3DCOMPILER_DLL=
5783 MOZ_HAS_WINSDK_WITH_D3D=
5784 MOZ_D3DCOMPILER_DLL_PATH=
5785 MOZ_D3DCOMPILER_CAB=
5786 case "$target_os" in
5787 *mingw*)
5788     MOZ_ANGLE_RENDERER=1
5789     ;;
5790 esac
5792 # The DirectX SDK libraries are split into x86 and x64 sub-directories
5793 case "${target_cpu}" in
5794 i*86)
5795   MOZ_DIRECTX_SDK_CPU_SUFFIX=x86
5796   ;;
5797 x86_64)
5798   MOZ_DIRECTX_SDK_CPU_SUFFIX=x64
5799   ;;
5800 esac
5802 MOZ_ARG_DISABLE_BOOL(webgl,
5803 [  --disable-webgl     Disable building of the WebGL implementation],
5804     MOZ_WEBGL_DISABLED=1,
5805     MOZ_WEBGL_DISABLED=)
5807 MOZ_ARG_ENABLE_BOOL(winsdk-directx,
5808 [  --enable-winsdk-directx use DirectX SDK in Windows SDK],
5809     MOZ_WINSDK_DIRECTX=1,
5810     MOZ_WINSDK_DIRECTX=)
5812 if test -n "$MOZ_WEBGL_DISABLED"; then
5813   MOZ_WEBGL=
5814   MOZ_ANGLE_RENDERER=
5817 if test -n "$MOZ_WEBGL"; then
5818   AC_DEFINE(MOZ_WEBGL)
5821 if test -n "$MOZ_WEBGL_CONFORMANT"; then
5822   AC_DEFINE(MOZ_WEBGL_CONFORMANT)
5826 # Locate a DirectX SDK here so we can use it for both ANGLE and
5827 # Joystick support.
5828 if test "$OS_TARGET" = "WINNT" -a -z "$CROSS_COMPILE"; then
5829   # Get the SDK path from the registry.
5830   # First try to get the June 2010 SDK
5831   MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK (June 2010)' | head -n 1`
5832   if test -z "$MOZ_DIRECTX_SDK_REG_KEY" ; then
5833     # Otherwise just take whatever comes first
5834     MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK' | head -n 1`
5835   fi
5836   MOZ_DIRECTX_SDK_PATH=`reg query "$MOZ_DIRECTX_SDK_REG_KEY" //v InstallPath | grep REG_SZ | sed 's/.*\([[a-zA-Z]]\)\\:\\\\/\\1\\:\\\\/' | sed 's,\\\\,/,g'`
5838   if test -n "$MOZ_DIRECTX_SDK_PATH" &&
5839      test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5840     AC_MSG_RESULT([Found DirectX SDK via registry, using $MOZ_DIRECTX_SDK_PATH])
5841   else
5842     AC_MSG_RESULT([Couldn't find the DirectX SDK.])
5843   fi
5846 # On mingw, check if headers are provided by toolchain.
5847 if test "$OS_TARGET" = "WINNT" -a -n "$GNU_CC"; then
5848   MOZ_CHECK_HEADER(d3d10.h, MOZ_HAS_WINSDK_WITH_D3D=1)
5851 dnl ========================================================
5852 dnl D3D compiler DLL
5853 dnl ========================================================
5855 if test -n "$MOZ_ANGLE_RENDERER"; then
5856   # Check that our DirectX SDK is acceptable.
5857   if test -n "$MOZ_DIRECTX_SDK_PATH"; then
5858     if test -n "`echo $MOZ_DIRECTX_SDK_REG_KEY | grep 'February 2010'`" ; then
5859       AC_MSG_RESULT([Found the February 2010 DirectX SDK, which is unacceptable to ANGLE.])
5860       MOZ_DIRECTX_SDK_PATH_BAD=1
5861     fi
5863     if test -n "$MOZ_DIRECTX_SDK_PATH" &&
5864        test -f "$MOZ_DIRECTX_SDK_PATH"/include/d3dx9.h &&
5865        test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5866       AC_MSG_RESULT([Found acceptable DirectX SDK for ANGLE.])
5867     else
5868       AC_MSG_RESULT([Found DirectX SDK is unacceptable for ANGLE.])
5869       MOZ_DIRECTX_SDK_PATH_BAD=1
5870     fi
5871   fi
5873   if test -n "$MOZ_DIRECTX_SDK_PATH_BAD"; then
5874     AC_MSG_ERROR([Couldn't find an acceptable DirectX SDK for ANGLE. Either install DirectX SDK (June 2010 version or newer), or reconfigure with --disable-webgl.])
5875   fi
5877   # Find a D3D compiler DLL in a Windows SDK.
5878   MOZ_D3DCOMPILER_DLL=
5879   if test -n "$MOZ_WINSDK_DIRECTX"; then
5880     case "$MOZ_WINSDK_MAXVER" in
5881     0x0603*)
5882       MOZ_D3DCOMPILER_DLL=d3dcompiler_47.dll
5883       AC_MSG_RESULT([Found D3D compiler in Windows SDK 8.1.])
5884     ;;
5885     0x0602*)
5886       MOZ_D3DCOMPILER_DLL=d3dcompiler_46.dll
5887       AC_MSG_RESULT([Found D3D compiler in Windows SDK 8.0.])
5888     ;;
5889     esac
5890   fi
5892   if test -n "$MOZ_D3DCOMPILER_DLL"; then
5893     # We have a name, now track down the path.
5894     if test -n "$WINDOWSSDKDIR"; then
5895       MOZ_D3DCOMPILER_DLL_PATH="$WINDOWSSDKDIR/Redist/D3D/$MOZ_DIRECTX_SDK_CPU_SUFFIX/$MOZ_D3DCOMPILER_DLL"
5896       if test -f "$MOZ_D3DCOMPILER_DLL_PATH"; then
5897         MOZ_HAS_WINSDK_WITH_D3D=1
5898         AC_MSG_RESULT([Found MOZ_D3DCOMPILER_DLL_PATH: $MOZ_D3DCOMPILER_DLL_PATH])
5899       else
5900         AC_MSG_RESULT([MOZ_D3DCOMPILER_DLL_PATH doesn't exist: $MOZ_D3DCOMPILER_DLL_PATH])
5901       fi
5902     else
5903       AC_MSG_RESULT([WINDOWSSDKDIR is missing.])
5904     fi
5905   fi
5907   # Find a D3D compiler DLL in the DirectX SDK, if we didn't find one already.
5908   # Get the SDK numeric version (e.g. 43) by looking at the dependencies of d3dx9.lib
5909   if test -z "$MOZ_HAS_WINSDK_WITH_D3D"; then
5910     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'`
5912     if test -n "$MOZ_D3DX9_VERSION" ; then
5913       MOZ_D3DCOMPILER_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *D3DCompiler_${MOZ_D3DX9_VERSION}_${MOZ_DIRECTX_SDK_CPU_SUFFIX}.cab | head -n1`
5914       MOZ_D3DCOMPILER_DLL=D3DCompiler_$MOZ_D3DX9_VERSION.dll
5915     else
5916       AC_MSG_RESULT([Couldn't determine the D3DX9 version for the DirectX SDK.])
5917     fi
5919     if test -z "$MOZ_D3DCOMPILER_CAB"; then
5920       AC_MSG_RESULT([Couldn't find a CAB containing the D3D compiler DLL.])
5921     fi
5922   fi
5924   if test -z "$MOZ_D3DCOMPILER_DLL_PATH" -a -z "$MOZ_D3DCOMPILER_CAB" -a -z "$CROSS_COMPILE"; then
5925     AC_MSG_ERROR([Couldn't find an acceptable D3D compiler DLL. Either install Windows SDK 8.0+ and reconfigure with --enable-winsdk-directx, install DirectX SDK (June 2010 version or newer), or reconfigure with --disable-webgl.])
5926   fi
5930 dnl ========================================================
5931 dnl Gamepad support
5932 dnl ========================================================
5933 MOZ_GAMEPAD=
5934 MOZ_GAMEPAD_BACKEND=stub
5936 # Gamepad DOM is built on supported platforms by default.
5937 case "$OS_TARGET" in
5938      Darwin|WINNT|Linux)
5939        MOZ_GAMEPAD=1
5940        ;;
5941      *)
5942        ;;
5943 esac
5945 MOZ_ARG_DISABLE_BOOL(gamepad,
5946 [  --disable-gamepad   Disable gamepad support],
5947     MOZ_GAMEPAD=,
5948     MOZ_GAMEPAD=1)
5950 if test "$MOZ_GAMEPAD"; then
5951     case "$OS_TARGET" in
5952     Darwin)
5953         MOZ_GAMEPAD_BACKEND=cocoa
5954         ;;
5955     WINNT)
5956         if test -z "$MOZ_HAS_WINSDK_WITH_D3D"; then
5957             if test -n "$MOZ_DIRECTX_SDK_PATH" ; then
5958                 if ! test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_DIRECTX_SDK_CPU_SUFFIX/dxguid.lib ; then
5959                    MOZ_GAMEPAD=
5960                 fi
5961             elif test "$GCC" != "yes"; then
5962                 MOZ_GAMEPAD=
5963             fi
5964         fi
5965         if test -z "$MOZ_GAMEPAD"; then
5966            AC_MSG_ERROR([Couldn't find the DirectX SDK, needed for gamepad support. Please install it or, reconfigure with --disable-gamepad to disable gamepad support.])
5967         fi
5968         MOZ_GAMEPAD_BACKEND=windows
5969         ;;
5970     Linux)
5971         MOZ_CHECK_HEADER([linux/joystick.h])
5972         if test "$ac_cv_header_linux_joystick_h" != "yes"; then
5973           AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers or reconfigure with --disable-gamepad to disable gamepad support.])
5974         fi
5975         MOZ_GAMEPAD_BACKEND=linux
5976         ;;
5977     *)
5978         ;;
5979    esac
5981   AC_DEFINE(MOZ_GAMEPAD)
5983 AC_SUBST(MOZ_GAMEPAD)
5984 AC_SUBST(MOZ_GAMEPAD_BACKEND)
5986 dnl ========================================================
5987 dnl = Breakpad crash reporting (on by default on supported platforms)
5988 dnl ========================================================
5990 case $target in
5991 i?86-*-mingw*|x86_64-*-mingw*)
5992   MOZ_CRASHREPORTER=1
5993   ;;
5994 i?86-apple-darwin*|x86_64-apple-darwin*)
5995   MOZ_CRASHREPORTER=1
5996   ;;
5997 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
5998   if test "$MOZ_ENABLE_GTK"; then
5999     MOZ_CRASHREPORTER=1
6000   fi
6001   ;;
6002 *-android*|*-linuxandroid*)
6003   MOZ_CRASHREPORTER=1
6004   ;;
6005 *solaris*)
6006   MOZ_CRASHREPORTER=1
6007   ;;
6008 esac
6010 MOZ_ARG_DISABLE_BOOL(crashreporter,
6011 [  --disable-crashreporter Disable breakpad crash reporting],
6012     [MOZ_CRASHREPORTER=],
6013     [MOZ_CRASHREPORTER=F # Force enable breakpad])
6015 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT"; then
6016   if test "$MOZ_CRASHREPORTER" = F; then
6017     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
6018   fi
6019   MOZ_CRASHREPORTER=
6022 if test -n "$MOZ_CRASHREPORTER"; then
6023    AC_DEFINE(MOZ_CRASHREPORTER)
6025   if test "$OS_TARGET" = "Linux" -o "$OS_ARCH" = "SunOS" && \
6026     test -z "$SKIP_LIBRARY_CHECKS"; then
6027     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
6028     AC_SUBST(MOZ_GTHREAD_CFLAGS)
6029     AC_SUBST(MOZ_GTHREAD_LIBS)
6030   fi
6032   if test "$OS_ARCH" = "WINNT"; then
6033     if test -z "$HAVE_64BIT_OS"; then
6034       MOZ_CRASHREPORTER_INJECTOR=1
6035       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
6036     fi
6037   fi
6040 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
6041 [  --with-crashreporter-enable-percent=NN
6042                           Enable sending crash reports by default on NN% of users. (default=100)],
6043 [ val=`echo $withval | sed 's/[^0-9]//g'`
6044     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
6046 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
6047    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
6049 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
6051 dnl ========================================================
6052 dnl = libjpeg-turbo configuration
6053 dnl ========================================================
6054 MOZ_LIBJPEG_TURBO=
6055 if test -z "$MOZ_NATIVE_JPEG"; then
6056     MOZ_LIBJPEG_TURBO=1
6059 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
6060 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
6061     MOZ_LIBJPEG_TURBO=,
6062     MOZ_LIBJPEG_TURBO=1)
6064 if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
6065     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
6068 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
6069 dnl files.
6071 if test -n "$MOZ_LIBJPEG_TURBO"; then
6073   dnl Do we support libjpeg-turbo on this platform?
6074   case "$OS_ARCH:$OS_TEST" in
6075   Darwin:i?86)
6076     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
6077     LIBJPEG_TURBO_X86_ASM=1
6078   ;;
6079   Darwin:x86_64)
6080     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
6081     LIBJPEG_TURBO_X64_ASM=1
6082   ;;
6083   WINNT:x86|WINNT:i?86)
6084     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
6085     LIBJPEG_TURBO_X86_ASM=1
6086   ;;
6087   WINNT:x86_64)
6088     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
6089     LIBJPEG_TURBO_X64_ASM=1
6090   ;;
6091   *:arm*)
6092     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
6093     LIBJPEG_TURBO_ARM_ASM=1
6094   ;;
6095   *:x86|*:i?86)
6096     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6097       LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6098       LIBJPEG_TURBO_X86_ASM=1
6099     fi
6100   ;;
6101   *:x86_64)
6102     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6103       LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6104       LIBJPEG_TURBO_X64_ASM=1
6105     fi
6106   ;;
6107   esac
6111 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
6112 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
6113 dnl it doesn't exist or we have too old of a version.
6114 if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
6115     LIBJPEG_TURBO_AS=$YASM
6117     if test -z "$LIBJPEG_TURBO_AS" ; then
6118         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.])
6119     fi
6121     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
6122     dnl on Linux and 1.1 or newer everywhere else.
6123     if test "$OS_ARCH" = "Linux" ; then
6124         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
6125             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.])
6126         fi
6127     else
6128         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
6129             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.])
6130         fi
6131     fi
6134 dnl If we're on an ARM system which supports libjpeg-turbo's asm routines and
6135 dnl --disable-libjpeg-turbo wasn't passed, use the C compiler as the assembler.
6136 if test -n "$LIBJPEG_TURBO_ARM_ASM" ; then
6137     echo "Using $AS as the assembler for ARM code."
6138     LIBJPEG_TURBO_AS=$AS
6141 if test -n "$LIBJPEG_TURBO_X86_ASM"; then
6142     AC_DEFINE(LIBJPEG_TURBO_X86_ASM)
6143 elif test -n "$LIBJPEG_TURBO_X64_ASM"; then
6144     AC_DEFINE(LIBJPEG_TURBO_X64_ASM)
6145 elif test -n "$LIBJPEG_TURBO_ARM_ASM"; then
6146     AC_DEFINE(LIBJPEG_TURBO_ARM_ASM)
6147 elif test -n "$MOZ_LIBJPEG_TURBO"; then
6148     dnl Warn if we're not building the optimized routines, even though the user
6149     dnl didn't specify --disable-libjpeg-turbo.
6150     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
6153 dnl ========================================================
6154 dnl = Enable compilation of specific extension modules
6155 dnl ========================================================
6157 MOZ_ARG_ENABLE_STRING(extensions,
6158 [  --enable-extensions     Enable extensions],
6159 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6160     if test "$option" = "yes" -o "$option" = "all"; then
6161         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
6162     elif test "$option" = "no" -o "$option" = "none"; then
6163         MOZ_EXTENSIONS=""
6164     elif test "$option" = "default"; then
6165         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
6166     elif test `echo "$option" | grep -c \^-` != 0; then
6167         option=`echo $option | sed 's/^-//'`
6168         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
6169     else
6170         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
6171     fi
6172 done],
6173     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
6175 if test -z "$MOZ_ENABLE_GNOMEVFS" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6176     # Suppress warning on non-X11 platforms
6177     if test -n "$MOZ_X11"; then
6178         AC_MSG_WARN([Removing gnomevfs from MOZ_EXTENSIONS due to no --enable-gnomevfs.])
6179     fi
6180     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6183 dnl Do not build gnomevfs with libxul based apps
6184 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6185     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6188 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6189     # Suppress warning on non-X11 platforms
6190     if test -n "$MOZ_X11"; then
6191         AC_MSG_WARN([Removing gio from MOZ_EXTENSIONS due to --disable-gio.])
6192     fi
6193     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6196 dnl Do not build gio with libxul based apps
6197 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6198     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6201 if test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6202     MOZ_GIO_COMPONENT=1
6203     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6205 AC_SUBST(MOZ_GIO_COMPONENT)
6207 if test -z "$MOZ_JSDEBUGGER" -a `echo "$MOZ_EXTENSIONS" | grep -c venkman` -ne 0; then
6208     AC_MSG_WARN([Cannot build venkman without JavaScript debug library. Removing venkman from MOZ_EXTENSIONS.])
6209     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|venkman||'`
6212 dnl Remove dupes
6213 MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
6215 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6216 dnl when trying to build a nonexistent extension.
6217 for extension in $MOZ_EXTENSIONS; do
6218     if test ! -d "${srcdir}/extensions/${extension}"; then
6219         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6220     fi
6221 done
6223 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
6224   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
6227 dnl ========================================================
6228 dnl Build Freetype in the tree
6229 dnl ========================================================
6230 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6231 [  --enable-tree-freetype  Enable Tree FreeType],
6232     MOZ_TREE_FREETYPE=1,
6233     MOZ_TREE_FREETYPE= )
6234 if test -n "$MOZ_TREE_FREETYPE"; then
6235    if test -n "$_WIN32_MSVC"; then
6236       AC_ERROR("building with in-tree freetype is not supported on MSVC")
6237    fi
6238    AC_DEFINE(MOZ_TREE_FREETYPE)
6239    AC_SUBST(MOZ_TREE_FREETYPE)
6240    MOZ_ENABLE_CAIRO_FT=1
6241    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6242    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6243    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6244    FT2_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6245    CAIRO_FT_OSLIBS=''
6246    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6247    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6248    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6249    AC_SUBST(CAIRO_FT_CFLAGS)
6252 dnl ========================================================
6253 dnl Installer
6254 dnl ========================================================
6255 dnl Abort Windows build if the required major version and
6256 dnl minimum minor version of Unicode NSIS isn't in the path
6257 dnl (unless in case of cross compiling, for which Unicode
6258 dnl is not yet sufficient).
6259 if test "$OS_ARCH" = "WINNT"; then
6260     MIN_NSIS_MAJOR_VER=2
6261     MIN_NSIS_MINOR_VER=46
6262     MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensisu-3.0a2.exe makensisu-2.46.exe makensis)
6263     if test -n "$MAKENSISU" -a "$MAKENSISU" != ":"; then
6264       AC_MSG_RESULT([yes])
6265       MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null`
6266       changequote(,)
6267       MAKENSISU_PARSED_VER=`echo "$MAKENSISU_VER" | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\).*\-Unicode$/\1/g'`
6268       changequote([,])
6269       if test "$MAKENSISU_PARSED_VER" = ""; then
6270           changequote(,)
6271           MAKENSISU_PARSED_VER=`echo "$MAKENSISU_VER" | sed -e 's/^v\([0-9]\+\.[0-9]\+\).*$/\1/g'`
6272           changequote([,])
6273       fi
6274       MAKENSISU_MAJOR_VER=0
6275       MAKENSISU_MINOR_VER=0
6276       if test ! "$MAKENSISU_PARSED_VER" = ""; then
6277           MAKENSISU_MAJOR_VER=`echo $MAKENSISU_PARSED_VER | $AWK -F\. '{ print $1 }'`
6278           MAKENSISU_MINOR_VER=`echo $MAKENSISU_PARSED_VER | $AWK -F\. '{ print $2 }'`
6279       fi
6280       AC_MSG_CHECKING([for Unicode NSIS version $MIN_NSIS_MAJOR_VER.$MIN_NSIS_MINOR_VER or greater])
6281       if test "$MAKENSISU_MAJOR_VER" -eq $MIN_NSIS_MAJOR_VER -a \
6282               "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER ||
6283          test "$MAKENSISU_MAJOR_VER" -gt $MIN_NSIS_MAJOR_VER; then
6284           AC_MSG_RESULT([yes])
6285       else
6286           AC_MSG_RESULT([no])
6287           if test -z "$CROSS_COMPILE"; then
6288             AC_MSG_ERROR([To build the installer you must have the latest MozillaBuild or Unicode NSIS version $REQ_NSIS_MAJOR_VER.$MIN_NSIS_MINOR_VER or greater in your path.])
6289           else
6290             MAKENSISU=
6291           fi
6292       fi
6293     elif test -z "$CROSS_COMPILE"; then
6294       AC_MSG_ERROR([To build the installer you must have the latest MozillaBuild or Unicode NSIS version $REQ_NSIS_MAJOR_VER.$MIN_NSIS_MINOR_VER or greater in your path.])
6295     else
6296       MAKENSISU=
6297     fi
6300 dnl ========================================================
6301 dnl Web App Runtime
6302 dnl ========================================================
6303 MOZ_ARG_DISABLE_BOOL(webapp-runtime,
6304 [  --disable-webapp-runtime  Disable Web App Runtime],
6305     MOZ_WEBAPP_RUNTIME=,
6306     MOZ_WEBAPP_RUNTIME=1)
6307 if test "$MOZ_WIDGET_TOOLKIT" != "windows" -a "$MOZ_WIDGET_TOOLKIT" != "cocoa" -a "$MOZ_WIDGET_TOOLKIT" != "gtk2"; then
6308     MOZ_WEBAPP_RUNTIME=
6310 if test "$OS_ARCH" = "WINNT" -a -z "$MAKENSISU" -a -n "$CROSS_COMPILE"; then
6311     MOZ_WEBAPP_RUNTIME=
6313 AC_SUBST(MOZ_WEBAPP_RUNTIME)
6314 if test "$MOZ_WEBAPP_RUNTIME"; then
6315     AC_DEFINE(MOZ_WEBAPP_RUNTIME)
6318 AC_MSG_CHECKING([for tar archiver])
6319 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6320 if test -z "$TAR"; then
6321     AC_MSG_ERROR([no tar archiver found in \$PATH])
6323 AC_MSG_RESULT([$TAR])
6324 AC_SUBST(TAR)
6326 AC_MSG_CHECKING([for wget])
6327 AC_CHECK_PROGS(WGET, wget, "")
6328 AC_MSG_RESULT([$WGET])
6329 AC_SUBST(WGET)
6331 dnl ========================================================
6332 dnl Signing
6333 dnl ========================================================
6335 if test -n "$MOZ_SIGN_CMD"; then
6336     AC_DEFINE(MOZ_SIGNING)
6339 dnl ========================================================
6340 dnl Maintenance Service
6341 dnl ========================================================
6343 MOZ_ARG_ENABLE_BOOL(maintenance-service,
6344 [  --enable-maintenance-service       Enable building of maintenanceservice],
6345     MOZ_MAINTENANCE_SERVICE=1,
6346     MOZ_MAINTENANCE_SERVICE= )
6348 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
6349   if test "$OS_ARCH" = "WINNT"; then
6350     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
6351   else
6352     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
6353   fi
6356 dnl ========================================================
6357 dnl Verify MAR signatures
6358 dnl ========================================================
6360 MOZ_ARG_ENABLE_BOOL(verify-mar,
6361 [  --enable-verify-mar     Enable verifying MAR signatures],
6362     MOZ_VERIFY_MAR_SIGNATURE=1,
6363     MOZ_VERIFY_MAR_SIGNATURE= )
6365 if test -n "$MOZ_VERIFY_MAR_SIGNATURE"; then
6366   if test "$OS_ARCH" = "WINNT"; then
6367     AC_DEFINE(MOZ_VERIFY_MAR_SIGNATURE)
6368   else
6369     AC_MSG_ERROR([Can only build with --enable-verify-mar with a Windows target])
6370   fi
6373 dnl ========================================================
6374 dnl Enable building the signmar program.
6375 dnl This option is much different than the --enable-verify-mar option.
6376 dnl --enable-verify-mar is for enabling the verification check on MAR
6377 dnl files in the updater.  The --enable-signmar option is for building
6378 dnl the signmar program.
6379 dnl ========================================================
6381 MOZ_ARG_ENABLE_BOOL(signmar,
6382 [  --enable-signmar     Enable building the signmar program],
6383     MOZ_ENABLE_SIGNMAR=1,
6384     MOZ_ENABLE_SIGNMAR= )
6386 if test -n "$MOZ_ENABLE_SIGNMAR"; then
6387   AC_DEFINE(MOZ_ENABLE_SIGNMAR)
6390 dnl ========================================================
6391 dnl Updater
6392 dnl ========================================================
6394 MOZ_ARG_DISABLE_BOOL(updater,
6395 [  --disable-updater       Disable building of updater],
6396     MOZ_UPDATER=,
6397     MOZ_UPDATER=1 )
6399 if test -n "$MOZ_UPDATER"; then
6400     AC_DEFINE(MOZ_UPDATER)
6403 # tools/update-packaging is not checked out by default.
6404 MOZ_ARG_ENABLE_BOOL(update-packaging,
6405 [  --enable-update-packaging
6406                           Enable tools/update-packaging],
6407     MOZ_UPDATE_PACKAGING=1,
6408     MOZ_UPDATE_PACKAGING= )
6409 AC_SUBST(MOZ_UPDATE_PACKAGING)
6411 dnl ========================================================
6412 dnl build the tests by default
6413 dnl ========================================================
6414 MOZ_ARG_DISABLE_BOOL(tests,
6415 [  --disable-tests         Do not build test libraries & programs],
6416     ENABLE_TESTS=,
6417     ENABLE_TESTS=1 )
6419 if test -n "$ENABLE_TESTS"; then
6420     GTEST_HAS_RTTI=0
6421     AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0)
6422     AC_SUBST(GTEST_HAS_RTTI)
6423     if test -n "$_WIN32_MSVC"; then
6424           AC_DEFINE_UNQUOTED(_VARIADIC_MAX, 10)
6425     fi
6426     if test "${OS_TARGET}" = "Android"; then
6427         AC_DEFINE(GTEST_OS_LINUX_ANDROID)
6428         AC_DEFINE(GTEST_USE_OWN_TR1_TUPLE)
6429         AC_DEFINE_UNQUOTED(GTEST_HAS_CLONE, 0)
6430         AC_SUBST(GTEST_OS_LINUX_ANDROID)
6431         AC_SUBST(GTEST_USE_OWN_TR1_TUPLE)
6432         AC_SUBST(GTEST_HAS_CLONE)
6433     fi
6436 dnl ========================================================
6437 dnl parental controls (for Windows Vista)
6438 dnl ========================================================
6439 MOZ_ARG_DISABLE_BOOL(parental-controls,
6440 [  --disable-parental-controls
6441                           Do not build parental controls],
6442    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6443    MOZ_DISABLE_PARENTAL_CONTROLS=)
6444 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6445     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6448 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6450 dnl ========================================================
6451 dnl = Disable DOMCrypto
6452 dnl ========================================================
6453 if test -n "$MOZ_DISABLE_CRYPTOLEGACY"; then
6454     AC_DEFINE(MOZ_DISABLE_CRYPTOLEGACY)
6456 AC_SUBST(MOZ_DISABLE_CRYPTOLEGACY)
6458 dnl ========================================================
6459 dnl = Disable EV certificate verification
6460 dnl ========================================================
6461 if test -n "$MOZ_NO_EV_CERTS"; then
6462     AC_DEFINE(MOZ_NO_EV_CERTS)
6464 AC_SUBST(MOZ_NO_EV_CERTS)
6466 dnl ========================================================
6467 dnl = Disable libpkix
6468 dnl ========================================================
6469 if test -n "$NSS_NO_LIBPKIX"; then
6470     AC_DEFINE(NSS_NO_LIBPKIX)
6472 AC_SUBST(NSS_NO_LIBPKIX)
6474 dnl ========================================================
6475 dnl = Content process sandboxing
6476 dnl ========================================================
6477 if test -n "$gonkdir"; then
6478     MOZ_CONTENT_SANDBOX=1
6481 MOZ_ARG_ENABLE_BOOL(content-sandbox,
6482 [  --enable-content-sandbox        Enable sandboxing support for content-processes],
6483     MOZ_CONTENT_SANDBOX=1,
6484     MOZ_CONTENT_SANDBOX=)
6486 if test -n "$MOZ_CONTENT_SANDBOX"; then
6487     AC_DEFINE(MOZ_CONTENT_SANDBOX)
6490 AC_SUBST(MOZ_CONTENT_SANDBOX)
6492 MOZ_ARG_ENABLE_BOOL(content-sandbox-reporter,
6493 [ --enable-content-sandbox-reporter        Enable syscall reporter to troubleshoot syscalls denied by the content-processes sandbox],
6494     MOZ_CONTENT_SANDBOX_REPORTER=1,
6495     MOZ_CONTENT_SANDBOX_REPORTER=)
6497 if test -n "$MOZ_CONTENT_SANDBOX_REPORTER"; then
6498     AC_DEFINE(MOZ_CONTENT_SANDBOX_REPORTER)
6501 AC_SUBST(MOZ_CONTENT_SANDBOX_REPORTER)
6503 dnl ========================================================
6504 dnl =
6505 dnl = Module specific options
6506 dnl =
6507 dnl ========================================================
6508 MOZ_ARG_HEADER(Individual module options)
6510 dnl ========================================================
6511 dnl = Disable feed handling components
6512 dnl ========================================================
6513 MOZ_ARG_DISABLE_BOOL(feeds,
6514 [  --disable-feeds         Disable feed handling and processing components],
6515     MOZ_FEEDS=,
6516     MOZ_FEEDS=1 )
6517 if test -n "$MOZ_FEEDS"; then
6518     AC_DEFINE(MOZ_FEEDS)
6519 else
6520     if test "$MOZ_BUILD_APP" = "browser"; then
6521         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6522     fi
6525 dnl ========================================================
6526 dnl Check for sqlite
6527 dnl ========================================================
6529 MOZ_NATIVE_SQLITE=
6530 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6531 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6532 MOZ_NATIVE_SQLITE=1,
6533 MOZ_NATIVE_SQLITE= )
6535 if test -z "$MOZ_NATIVE_SQLITE"
6536 then
6537     SQLITE_CFLAGS=
6538     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
6539 else
6540     dnl ============================
6541     dnl === SQLite Version check ===
6542     dnl ============================
6543     dnl Check to see if the system SQLite package is new enough.
6544     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6546     dnl ==================================
6547     dnl === SQLITE_SECURE_DELETE check ===
6548     dnl ==================================
6549     dnl Check to see if the system SQLite package is compiled with
6550     dnl SQLITE_SECURE_DELETE enabled.
6551     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
6552     _SAVE_CFLAGS="$CFLAGS"
6553     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6554     _SAVE_LIBS="$LIBS"
6555     LIBS="$LIBS $SQLITE_LIBS"
6556     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6557         AC_TRY_RUN([
6558             #include "sqlite3.h"
6560             int main(int argc, char **argv){
6561               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
6562             }],
6563             ac_cv_sqlite_secure_delete=yes,
6564             ac_cv_sqlite_secure_delete=no,
6565             ac_cv_sqlite_secure_delete=no
6566         )
6567     ])
6568     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6569     CFLAGS="$_SAVE_CFLAGS"
6570     LIBS="$_SAVE_LIBS"
6571     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6572         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
6573     fi
6575     dnl ===============================
6576     dnl === SQLITE_THREADSAFE check ===
6577     dnl ===============================
6578     dnl Check to see if the system SQLite package is compiled with
6579     dnl SQLITE_THREADSAFE enabled.
6580     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
6581     _SAVE_CFLAGS="$CFLAGS"
6582     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6583     _SAVE_LIBS="$LIBS"
6584     LIBS="$LIBS $SQLITE_LIBS"
6585     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
6586         AC_TRY_RUN([
6587             #include "sqlite3.h"
6589             int main(int argc, char **argv){
6590               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
6591             }],
6592             ac_cv_sqlite_threadsafe=yes,
6593             ac_cv_sqlite_threadsafe=no,
6594             ac_cv_sqlite_threadsafe=no
6595         )
6596     ])
6597     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
6598     CFLAGS="$_SAVE_CFLAGS"
6599     LIBS="$_SAVE_LIBS"
6600     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
6601         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
6602     fi
6604     dnl ================================
6605     dnl === SQLITE_ENABLE_FTS3 check ===
6606     dnl ================================
6607     dnl check to see if the system SQLite package is compiled with
6608     dnl SQLITE_ENABLE_FTS3 enabled.
6609     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
6610     _SAVE_CFLAGS="$CFLAGS"
6611     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6612     _SAVE_LIBS="$LIBS"
6613     LIBS="$LIBS $SQLITE_LIBS"
6614     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
6615         AC_TRY_RUN([
6616             #include "sqlite3.h"
6618             int main(int argc, char **argv){
6619               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
6620             }],
6621             ac_cv_sqlite_enable_fts3=yes,
6622             ac_cv_sqlite_enable_fts3=no,
6623             ac_cv_sqlite_enable_fts3=no
6624         )
6625     ])
6626     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
6627     CFLAGS="$_SAVE_CFLAGS"
6628     LIBS="$_SAVE_LIBS"
6629     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
6630         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
6631     fi
6633     dnl =========================================
6634     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
6635     dnl =========================================
6636     dnl check to see if the system SQLite package is compiled with
6637     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
6638     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
6639     _SAVE_CFLAGS="$CFLAGS"
6640     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6641     _SAVE_LIBS="$LIBS"
6642     LIBS="$LIBS $SQLITE_LIBS"
6643     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
6644         AC_TRY_RUN([
6645             #include "sqlite3.h"
6647             int main(int argc, char **argv){
6648               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
6649             }],
6650             ac_cv_sqlite_enable_unlock_notify=yes,
6651             ac_cv_sqlite_enable_unlock_notify=no,
6652             ac_cv_sqlite_enable_unlock_notify=no
6653         )
6654     ])
6655     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
6656     CFLAGS="$_SAVE_CFLAGS"
6657     LIBS="$_SAVE_LIBS"
6658     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
6659         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
6660     fi
6663 if test -n "$MOZ_NATIVE_SQLITE"; then
6664     AC_DEFINE(MOZ_NATIVE_SQLITE)
6666 AC_SUBST(MOZ_NATIVE_SQLITE)
6668 dnl ========================================================
6669 dnl = Enable help viewer (off by default)
6670 dnl ========================================================
6671 if test -n "$MOZ_HELP_VIEWER"; then
6672      dnl Do this if defined in confvars.sh
6673      AC_DEFINE(MOZ_HELP_VIEWER)
6676 dnl ========================================================
6677 dnl = Enable safe browsing (anti-phishing)
6678 dnl ========================================================
6679 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6680 [  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation],
6681     MOZ_SAFE_BROWSING=1,
6682     MOZ_SAFE_BROWSING= )
6683 if test -n "$MOZ_SAFE_BROWSING"; then
6684     AC_DEFINE(MOZ_SAFE_BROWSING)
6686 AC_SUBST(MOZ_SAFE_BROWSING)
6688 dnl ========================================================
6689 dnl = Enable url-classifier
6690 dnl ========================================================
6691 dnl Implicitly enabled by default if building with safe-browsing
6692 if test -n "$MOZ_SAFE_BROWSING"; then
6693     MOZ_URL_CLASSIFIER=1
6695 MOZ_ARG_ENABLE_BOOL(url-classifier,
6696 [  --enable-url-classifier Enable url classifier module],
6697     MOZ_URL_CLASSIFIER=1,
6698     MOZ_URL_CLASSIFIER= )
6699 if test -n "$MOZ_URL_CLASSIFIER"; then
6700     AC_DEFINE(MOZ_URL_CLASSIFIER)
6702 AC_SUBST(MOZ_URL_CLASSIFIER)
6704 dnl ========================================================
6705 dnl = Disable zipwriter
6706 dnl ========================================================
6707 MOZ_ARG_DISABLE_BOOL(zipwriter,
6708 [  --disable-zipwriter     Disable zipwriter component],
6709     MOZ_ZIPWRITER=,
6710     MOZ_ZIPWRITER=1 )
6711 AC_SUBST(MOZ_ZIPWRITER)
6713 dnl ========================================================
6714 dnl GL provider
6715 dnl ========================================================
6716 MOZ_GL_PROVIDER=
6717 MOZ_ARG_WITH_STRING(gl-provider,
6718 [  --with-gl-provider=ID
6719                           Set GL provider backend type],
6720 [ val=`echo $withval`
6721     MOZ_GL_PROVIDER="$val"])
6723 if test -n "$MOZ_GL_PROVIDER"; then
6724 MOZ_GL_DEFAULT_PROVIDER=$MOZ_GL_PROVIDER
6725 AC_SUBST(MOZ_GL_PROVIDER)
6726 AC_DEFINE_UNQUOTED(MOZ_GL_PROVIDER, GLContextProvider$MOZ_GL_PROVIDER)
6728 AC_SUBST(MOZ_GL_DEFAULT_PROVIDER)
6729 AC_DEFINE_UNQUOTED(GL_PROVIDER_$MOZ_GL_DEFAULT_PROVIDER)
6731 dnl ========================================================
6732 dnl = faststripe theme
6733 dnl ========================================================
6734 MOZ_ARG_ENABLE_BOOL(faststripe,
6735 [  --enable-faststripe     Use faststripe theme],
6736     MOZ_THEME_FASTSTRIPE=1,
6737     MOZ_THEME_FASTSTRIPE= )
6738 AC_SUBST(MOZ_THEME_FASTSTRIPE)
6740 dnl ========================================================
6741 dnl =
6742 dnl = Feature options that require extra sources to be pulled
6743 dnl =
6744 dnl ========================================================
6745 dnl MOZ_ARG_HEADER(Features that require extra sources)
6747 dnl ========================================================
6748 dnl =
6749 dnl = Runtime debugging and Optimization Options
6750 dnl =
6751 dnl ========================================================
6752 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
6754 dnl ========================================================
6755 dnl enable mobile optimizations
6756 dnl ========================================================
6757 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
6758 [  --enable-mobile-optimize
6759                           Enable mobile optimizations],
6760     MOZ_GFX_OPTIMIZE_MOBILE=1)
6762 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
6764 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
6765     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
6768 dnl ========================================================
6769 dnl = Enable code optimization. ON by default.
6770 dnl ========================================================
6771 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
6772     MOZ_OPTIMIZE_FLAGS="-O"
6775 MOZ_ARG_ENABLE_STRING(optimize,
6776 [  --disable-optimize      Disable compiler optimization
6777   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
6778 [ if test "$enableval" != "no"; then
6779     MOZ_OPTIMIZE=1
6780     if test -n "$enableval" -a "$enableval" != "yes"; then
6781         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
6782         MOZ_OPTIMIZE=2
6783     fi
6784 else
6785     MOZ_OPTIMIZE=
6786 fi ], MOZ_OPTIMIZE=1)
6788 MOZ_SET_FRAMEPTR_FLAGS
6790 if test "$COMPILE_ENVIRONMENT"; then
6791 if test -n "$MOZ_OPTIMIZE"; then
6792     AC_MSG_CHECKING([for valid optimization flags])
6793     _SAVE_CFLAGS=$CFLAGS
6794     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
6795     AC_TRY_COMPILE([#include <stdio.h>],
6796         [printf("Hello World\n");],
6797         _results=yes,
6798         _results=no)
6799     AC_MSG_RESULT([$_results])
6800     if test "$_results" = "no"; then
6801         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
6802     fi
6803     CFLAGS=$_SAVE_CFLAGS
6805 fi # COMPILE_ENVIRONMENT
6807 AC_SUBST(MOZ_OPTIMIZE)
6808 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
6809 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
6810 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
6811 AC_SUBST(MOZ_ALLOW_HEAP_EXECUTE_FLAGS)
6812 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
6813 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
6815 dnl ========================================================
6816 dnl = Enable any treating of compile warnings as errors
6817 dnl ========================================================
6818 MOZ_ARG_ENABLE_BOOL(warnings-as-errors,
6819 [  --enable-warnings-as-errors
6820                           Enable treating of warnings as errors],
6821     MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
6822     MOZ_ENABLE_WARNINGS_AS_ERRORS=)
6823 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
6824    WARNINGS_AS_ERRORS=''
6825 elif test "$GNU_CC"; then
6826     # Prevent the following GCC warnings from being treated as errors:
6827     # -Wuninitialized - too many false positives
6828     # -Wmaybe-uninitialized - too many false positives
6829     # -Wdeprecated-declarations - we don't want our builds held hostage when a
6830     #   platform-specific API becomes deprecated.
6831     MOZ_C_SUPPORTS_WARNING(-W, no-error=uninitialized, ac_c_has_noerror_uninitialized)
6832     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=uninitialized, ac_cxx_has_noerror_uninitialized)
6833     MOZ_C_SUPPORTS_WARNING(-W, no-error=maybe-uninitialized, ac_c_has_noerror_maybe_uninitialized)
6834     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=maybe-uninitialized, ac_cxx_has_noerror_maybe_uninitialized)
6835     MOZ_C_SUPPORTS_WARNING(-W, no-error=deprecated-declarations, ac_c_has_noerror_deprecated_declarations)
6836     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=deprecated-declarations, ac_cxx_has_noerror_deprecated_declarations)
6839 dnl ========================================================
6840 dnl = Disable runtime logging checks
6841 dnl ========================================================
6842 MOZ_ARG_DISABLE_BOOL(logging,
6843 [  --disable-logging       Disable logging facilities],
6844     NS_DISABLE_LOGGING=1,
6845     NS_DISABLE_LOGGING= )
6846 if test "$NS_DISABLE_LOGGING"; then
6847     AC_DEFINE(NS_DISABLE_LOGGING)
6848 else
6849     AC_DEFINE(MOZ_LOGGING)
6852 dnl ========================================================
6853 dnl = This will enable logging of addref, release, ctor, dtor.
6854 dnl ========================================================
6855 _ENABLE_LOGREFCNT=42
6856 MOZ_ARG_ENABLE_BOOL(logrefcnt,
6857 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
6858     _ENABLE_LOGREFCNT=1,
6859     _ENABLE_LOGREFCNT= )
6860 if test "$_ENABLE_LOGREFCNT" = "1"; then
6861     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
6862 elif test -z "$_ENABLE_LOGREFCNT"; then
6863     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
6866 dnl ========================================================
6867 dnl moz_dump_painting
6868 dnl ========================================================
6869 MOZ_ARG_ENABLE_BOOL(dump-painting,
6870 [  --enable-dump-painting          Enable paint debugging.],
6871     MOZ_DUMP_PAINTING=1,
6872     MOZ_DUMP_PAINTING= )
6873 if test -n "$MOZ_DUMP_PAINTING"; then
6874     AC_DEFINE(MOZ_DUMP_PAINTING)
6875     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
6877 if test -n "$MOZ_DEBUG"; then
6878     AC_DEFINE(MOZ_DUMP_PAINTING)
6881 dnl ========================================================
6882 dnl = Enable trace malloc
6883 dnl ========================================================
6884 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
6885 MOZ_ARG_ENABLE_BOOL(trace-malloc,
6886 [  --enable-trace-malloc   Enable malloc tracing; also disables DMD and jemalloc],
6887     NS_TRACE_MALLOC=1,
6888     NS_TRACE_MALLOC= )
6889 if test "$NS_TRACE_MALLOC"; then
6890   # Please, Mr. Linker Man, don't take away our symbol names
6891   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
6892   AC_DEFINE(NS_TRACE_MALLOC)
6894 AC_SUBST(NS_TRACE_MALLOC)
6896 dnl ========================================================
6897 dnl = Enable DMD
6898 dnl ========================================================
6900 MOZ_ARG_ENABLE_BOOL(dmd,
6901 [  --enable-dmd            Enable DMD; also enables jemalloc and replace-malloc],
6902     MOZ_DMD=1,
6903     MOZ_DMD= )
6905 dnl The two options are conflicting. Fails the configure to alert the user.
6906 if test "$NS_TRACE_MALLOC" -a "$MOZ_DMD"; then
6907     AC_MSG_ERROR([--enable-trace-malloc and --enable-dmd are conflicting options])
6910 if test "$MOZ_DMD"; then
6911     AC_DEFINE(MOZ_DMD)
6913     if test "${CPU_ARCH}" = "arm"; then
6914         CFLAGS="$CFLAGS -funwind-tables"
6915         CXXFLAGS="$CXXFLAGS -funwind-tables"
6916     fi
6918     MOZ_MEMORY=1                        # DMD enables jemalloc
6919     MOZ_REPLACE_MALLOC=1                # DMD enables replace-malloc
6921 AC_SUBST(MOZ_DMD)
6923 dnl ========================================================
6924 dnl = Enable jemalloc
6925 dnl ========================================================
6926 MOZ_ARG_ENABLE_BOOL(jemalloc,
6927 [  --enable-jemalloc       Replace memory allocator with jemalloc],
6928     MOZ_MEMORY=1,
6929     MOZ_MEMORY=)
6931 if test "$NS_TRACE_MALLOC"; then
6932     MOZ_MEMORY=
6935 if test "${OS_TARGET}" = "Android"; then
6936   dnl On Android, we use WRAP_LDFLAGS to link everything to mozglue
6937   :
6938 elif test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin"; then
6939   dnl On Windows and OSX, we want to link all our binaries against mozglue
6940   if test -z "$GNU_CC"; then
6941     MOZ_GLUE_LDFLAGS='$(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
6942   else
6943     MOZ_GLUE_LDFLAGS='-L$(LIBXUL_DIST)/lib $(call EXPAND_LIBNAME,mozglue)'
6944   fi
6945 else
6946   dnl On other Unix systems, we only want to link executables against mozglue
6947   MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
6948   dnl On other Unix systems, where mozglue is a static library, jemalloc is
6949   dnl separated for the SDK, so we need to add it here.
6950   if test "$MOZ_MEMORY" = 1 -o \( "$LIBXUL_SDK" -a -f "$LIBXUL_SDK/lib/${LIB_PREFIX}memory.${LIB_SUFFIX}" \); then
6951     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib)'
6952   fi
6953   MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(MKSHLIB_UNFORCE_ALL)'
6954   if test -n "$GNU_CC"; then
6955     dnl And we need mozglue symbols to be exported.
6956     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
6957   fi
6958   if test "$MOZ_LINKER" = 1; then
6959     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS $MOZ_ZLIB_LIBS"
6960   fi
6963 dnl ========================================================
6964 dnl = Enable dynamic replacement of malloc implementation
6965 dnl ========================================================
6966 MOZ_ARG_ENABLE_BOOL(replace-malloc,
6967 [  --enable-replace-malloc   Enable ability to dynamically replace the malloc implementation],
6968     MOZ_REPLACE_MALLOC=1,
6969     MOZ_REPLACE_MALLOC= )
6971 dnl The two options are conflicting. Fails the configure to alert the user.
6972 if test "$NS_TRACE_MALLOC" -a "$MOZ_REPLACE_MALLOC"; then
6973     AC_MSG_ERROR([--enable-trace-malloc and --enable-replace-malloc are conflicting options])
6976 if test -n "$MOZ_REPLACE_MALLOC" -a -z "$MOZ_MEMORY"; then
6977     dnl We don't want to enable jemalloc unconditionally because it may be a
6978     dnl deliberate choice not to enable it (bug 702250, for instance)
6979     AC_MSG_ERROR([--enable-replace-malloc requires --enable-jemalloc])
6980 elif test -n "$MOZ_REPLACE_MALLOC"; then
6981     MOZ_NATIVE_JEMALLOC=
6983     dnl Replace-malloc Mac linkage quirks
6984     if test -n "$MACOSX_DEPLOYMENT_TARGET"; then
6985         AC_CACHE_CHECK([how to do weak dynamic linking],
6986             ac_cv_weak_dynamic_linking,
6987             [echo 'extern void foo() __attribute__((weak_import));int bar() { if (foo) foo(); return 0; }' > conftest.c
6988              if AC_TRY_COMMAND([${CC-cc} -o conftest${DLL_SUFFIX} $CFLAGS -dynamiclib $LDFLAGS -Wl,-U,_foo conftest.c $LIBS 1>&5]) &&
6989                 test -s conftest${DLL_SUFFIX}; then
6990                  dnl There are several ways the linker can put link edit rules in a binary:
6991                  dnl - classic info only (for OSX < 10.6)
6992                  dnl - dyld info only
6993                  dnl - both
6994                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO_ONLY" > /dev/null; then
6995                      _CLASSIC_INFO=
6996                  else
6997                      _CLASSIC_INFO=1
6998                  fi
6999                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO" > /dev/null; then
7000                      _DYLD_INFO=1
7001                  else
7002                      _DYLD_INFO=
7003                  fi
7004                  dnl With classic info, we need to build with -flat_namespace.
7005                  dnl With dyld info, Xcode 4.5 does the right thing without additional flags,
7006                  dnl but Xcode < 4.5 requires a dummy library and -flat_namespace because it
7007                  dnl forgets to set the weak flag in the dyld info.
7008                  dnl See http://glandium.org/blog/?p=2764 for more details.
7009                  dnl
7010                  dnl Values for ac_cv_weak_dynamic_linking, and subsequently
7011                  dnl MOZ_REPLACE_MALLOC_LINKAGE are thus:
7012                  dnl - "flat namespace" when -flat_namespace alone is needed
7013                  dnl - "dummy library" when a dummy library and -flat_namespace are needed
7014                  dnl - "compiler support" when nothing is needed
7015                  if test -n "$_DYLD_INFO" && dyldinfo -bind conftest${DLL_SUFFIX} 2> /dev/null | grep "_foo (weak import)" > /dev/null; then
7016                      if test -n "$_CLASSIC_INFO"; then
7017                          ac_cv_weak_dynamic_linking="flat namespace"
7018                      else
7019                          ac_cv_weak_dynamic_linking="compiler support"
7020                      fi
7021                  else
7022                      if test -n "$_DYLD_INFO"; then
7023                          ac_cv_weak_dynamic_linking="dummy library"
7024                      else
7025                          ac_cv_weak_dynamic_linking="flat namespace"
7026                      fi
7027                  fi
7028              else
7029                  AC_ERROR([couldn't compile a simple C file])
7030              fi
7031              rm -rf conftest*])
7032         MOZ_REPLACE_MALLOC_LINKAGE="$ac_cv_weak_dynamic_linking"
7033     fi
7035 AC_SUBST(MOZ_REPLACE_MALLOC)
7036 AC_SUBST(MOZ_REPLACE_MALLOC_LINKAGE)
7038 dnl ========================================================
7039 dnl = Jemalloc build setup
7040 dnl ========================================================
7041 if test -z "$MOZ_MEMORY"; then
7042   if test -n "$MOZ_JEMALLOC3" -a -z "$MOZ_REPLACE_MALLOC"; then
7043     MOZ_NATIVE_JEMALLOC=1
7044     AC_CHECK_FUNCS(mallctl nallocm,,
7045       [MOZ_NATIVE_JEMALLOC=
7046        break])
7047     if test -n "$MOZ_NATIVE_JEMALLOC"; then
7048       MOZ_MEMORY=1
7049       AC_DEFINE(MOZ_MEMORY)
7050       AC_DEFINE(MOZ_JEMALLOC3)
7051       AC_DEFINE(MOZ_NATIVE_JEMALLOC)
7052     fi
7053   fi
7054   case "${target}" in
7055     *-mingw*)
7056       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
7057         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.])
7058       fi
7059       ;;
7060   esac
7061 else
7062   AC_DEFINE(MOZ_MEMORY)
7063   if test -n "$MOZ_JEMALLOC3"; then
7064     AC_DEFINE(MOZ_JEMALLOC3)
7065   fi
7066   if test "x$MOZ_DEBUG" = "x1"; then
7067     AC_DEFINE(MOZ_MEMORY_DEBUG)
7068   fi
7069   dnl The generic feature tests that determine how to compute ncpus are long and
7070   dnl complicated.  Therefore, simply define special cpp variables for the
7071   dnl platforms we have special knowledge of.
7072   case "${target}" in
7073   *-darwin*)
7074     AC_DEFINE(MOZ_MEMORY_DARWIN)
7075     ;;
7076   *-*freebsd*)
7077     AC_DEFINE(MOZ_MEMORY_BSD)
7078     ;;
7079   *-android*|*-linuxandroid*)
7080     AC_DEFINE(MOZ_MEMORY_LINUX)
7081     AC_DEFINE(MOZ_MEMORY_ANDROID)
7082     if test -z "$gonkdir"; then
7083       _WRAP_MALLOC=1
7084     else
7085       AC_DEFINE(MOZ_MEMORY_GONK)
7086     fi
7087     MOZ_GLUE_LDFLAGS=
7088     ;;
7089   *-*linux*)
7090     AC_DEFINE(MOZ_MEMORY_LINUX)
7091     ;;
7092   *-netbsd*)
7093     AC_DEFINE(MOZ_MEMORY_BSD)
7094     ;;
7095   *-solaris*)
7096     AC_DEFINE(MOZ_MEMORY_SOLARIS)
7097     ;;
7098   *-mingw*)
7099     AC_DEFINE(MOZ_MEMORY_WINDOWS)
7100     if test -z "$MOZ_DEBUG"; then
7101       WIN32_CRT_LIBS="msvcrt.lib msvcprt.lib"
7102     else
7103       WIN32_CRT_LIBS="msvcrtd.lib msvcprtd.lib"
7104     fi
7105     dnl Look for a broken crtdll.obj
7106     WIN32_CRTDLL_FULLPATH=`lib -nologo -list $WIN32_CRT_LIBS | grep crtdll\\.obj`
7107     lib -NOLOGO -OUT:crtdll.obj $WIN32_CRT_LIBS -EXTRACT:$WIN32_CRTDLL_FULLPATH
7108     if grep -q '__imp__\{0,1\}free' crtdll.obj; then
7109       MOZ_GLUE_LDFLAGS='-LIBPATH:$(DIST)/lib -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcrtd -NODEFAULTLIB:msvcprt -NODEFAULTLIB:msvcprtd -DEFAULTLIB:mozcrt'
7110       dnl Also pass this to NSPR/NSS
7111       DLLFLAGS="$DLLFLAGS $MOZ_GLUE_LDFLAGS"
7112     else
7113       DLLFLAGS="$DLLFLAGS -LIBPATH:\$(DIST)/lib -DEFAULTLIB:mozglue"
7114     fi
7115     rm crtdll.obj
7117     export DLLFLAGS
7118     ;;
7119   *)
7120     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
7121     ;;
7122   esac
7123 fi # MOZ_MEMORY
7124 AC_SUBST(MOZ_MEMORY)
7125 AC_SUBST(MOZ_JEMALLOC3)
7126 AC_SUBST(MOZ_NATIVE_JEMALLOC)
7127 AC_SUBST(MOZ_GLUE_LDFLAGS)
7128 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
7129 AC_SUBST(WIN32_CRT_LIBS)
7130 dnl Need to set this for make because NSS doesn't have configure
7131 AC_SUBST(DLLFLAGS)
7133 dnl We need to wrap dlopen and related functions on Android because we use
7134 dnl our own linker.
7135 if test "$OS_TARGET" = Android; then
7136     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
7137     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_GetEnv,--wrap=PR_SetEnv"
7138     if test "$MOZ_WIDGET_TOOLKIT" = android; then
7139         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
7140     fi
7141     if test -z "$gonkdir"; then
7142         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork,--wrap=raise"
7143         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=memccpy,--wrap=memchr,--wrap=memrchr,--wrap=memcmp,--wrap=memcpy,--wrap=memmove,--wrap=memset,--wrap=memmem,--wrap=memswap,--wrap=index,--wrap=strchr,--wrap=strrchr,--wrap=strlen,--wrap=strcmp,--wrap=strcpy,--wrap=strcat,--wrap=strcasecmp,--wrap=strncasecmp,--wrap=strstr,--wrap=strcasestr,--wrap=strtok,--wrap=strtok_r,--wrap=strerror,--wrap=strerror_r,--wrap=strnlen,--wrap=strncat,--wrap=strncmp,--wrap=strncpy,--wrap=strlcat,--wrap=strlcpy,--wrap=strcspn,--wrap=strpbrk,--wrap=strsep,--wrap=strspn,--wrap=strcoll,--wrap=strxfrm"
7144     fi
7145     if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_NUWA_PROCESS"; then
7146         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=pthread_create,--wrap=epoll_wait,--wrap=poll,--wrap=pthread_cond_timedwait,--wrap=__pthread_cond_timedwait,--wrap=pthread_cond_wait,--wrap=epoll_create,--wrap=epoll_ctl,--wrap=close,--wrap=pthread_key_create,--wrap=pthread_key_delete,--wrap=socketpair,--wrap=pthread_self,--wrap=pthread_mutex_lock,--wrap=pthread_join,--wrap=pipe,--wrap=pipe2,--wrap=tgkill"
7147     fi
7150 dnl ========================================================
7151 dnl = Use malloc wrapper lib
7152 dnl ========================================================
7153 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
7154 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
7155     _WRAP_MALLOC=1,
7156     _WRAP_MALLOC= )
7158 if test -n "$_WRAP_MALLOC"; then
7159     if test -n "$GNU_CC"; then
7160         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
7161         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
7162         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
7163         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=vasprintf,--wrap=asprintf"
7164         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
7165         dnl Wrap operator new and operator delete on Android.
7166         if test "$OS_TARGET" = "Android"; then
7167             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_Znwj,--wrap=_Znaj,--wrap=_ZdlPv,--wrap=_ZdaPv"
7168             dnl Wrap the nothrow variants too.
7169             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_ZnwjRKSt9nothrow_t,--wrap=_ZnajRKSt9nothrow_t,--wrap=_ZdlPvRKSt9nothrow_t,--wrap=_ZdaPvRKSt9nothrow_t"
7170         fi
7171     else
7172         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
7173     fi
7176 dnl ========================================================
7177 dnl = Location of malloc wrapper lib
7178 dnl ========================================================
7179 MOZ_ARG_WITH_STRING(wrap-malloc,
7180 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
7181     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
7183 dnl ========================================================
7184 dnl = Use JS Call tracing
7185 dnl ========================================================
7186 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
7187 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
7188     MOZ_TRACE_JSCALLS=1,
7189     MOZ_TRACE_JSCALLS= )
7190 if test -n "$MOZ_TRACE_JSCALLS"; then
7191     AC_DEFINE(MOZ_TRACE_JSCALLS)
7194 dnl ========================================================
7195 dnl JS opt-mode assertions and minidump instrumentation
7196 dnl ========================================================
7197 MOZ_ARG_ENABLE_BOOL(js-diagnostics,
7198 [  --enable-js-diagnostics
7199                           Enable JS diagnostic assertions and breakpad data],
7200     JS_CRASH_DIAGNOSTICS=1,
7201     JS_CRASH_DIAGNOSTICS= )
7202 if test -n "$JS_CRASH_DIAGNOSTICS"; then
7203     AC_DEFINE(JS_CRASH_DIAGNOSTICS)
7206 dnl ========================================================
7207 dnl = Use incremental GC
7208 dnl ========================================================
7209 JSGC_INCREMENTAL=1
7210 MOZ_ARG_DISABLE_BOOL(gcincremental,
7211 [  --disable-gcincremental Disable incremental GC],
7212     JSGC_INCREMENTAL= )
7213 if test -n "$JSGC_INCREMENTAL"; then
7214     AC_DEFINE(JSGC_INCREMENTAL)
7217 dnl ========================================================
7218 dnl = Use exact stack rooting for GC
7219 dnl ========================================================
7220 MOZ_ARG_DISABLE_BOOL(exact-rooting,
7221 [  --disable-exact-rooting  Enable use of conservative stack scanning for GC],
7222     JSGC_USE_EXACT_ROOTING= ,
7223     JSGC_USE_EXACT_ROOTING=1 )
7224 if test -n "$JSGC_USE_EXACT_ROOTING"; then
7225     AC_DEFINE(JSGC_USE_EXACT_ROOTING)
7228 dnl ========================================================
7229 dnl = Use generational GC
7230 dnl ========================================================
7231 MOZ_ARG_DISABLE_BOOL(gcgenerational,
7232 [  --disable-gcgenerational Disable generational GC],
7233     JSGC_GENERATIONAL= ,
7234     JSGC_GENERATIONAL=1 )
7235 if test -n "$JSGC_GENERATIONAL"; then
7236     AC_DEFINE(JSGC_GENERATIONAL)
7239 dnl ========================================================
7240 dnl Zealous JavaScript GC
7241 dnl ========================================================
7242 MOZ_ARG_ENABLE_BOOL(gczeal,
7243 [  --enable-gczeal         Enable zealous JavaScript GCing],
7244     JS_GC_ZEAL=1,
7245     JS_GC_ZEAL= )
7246 if test -n "$JS_GC_ZEAL" -o -n "$MOZ_DEBUG"; then
7247     AC_DEFINE(JS_GC_ZEAL)
7250 dnl ========================================================
7251 dnl = Perform moving GC stack rooting analysis
7252 dnl ========================================================
7253 MOZ_ARG_ENABLE_BOOL(root-analysis,
7254 [  --enable-root-analysis  Enable moving GC stack root analysis],
7255     JSGC_ROOT_ANALYSIS=1,
7256     JSGC_ROOT_ANALYSIS= )
7257 if test -n "$JSGC_ROOT_ANALYSIS"; then
7258     AC_DEFINE(JSGC_ROOT_ANALYSIS)
7261 MOZ_CHECK_CCACHE
7263 dnl ========================================================
7264 dnl = Enable static checking using gcc-dehydra
7265 dnl ========================================================
7267 MOZ_ARG_WITH_STRING(static-checking,
7268 [  --with-static-checking=path/to/gcc_dehydra.so
7269                           Enable static checking of code using GCC-dehydra],
7270     DEHYDRA_PATH=$withval,
7271     DEHYDRA_PATH= )
7273 if test -n "$DEHYDRA_PATH"; then
7274     if test ! -f "$DEHYDRA_PATH"; then
7275         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7276     fi
7277     AC_DEFINE(NS_STATIC_CHECKING)
7279 AC_SUBST(DEHYDRA_PATH)
7281 dnl ========================================================
7282 dnl = Enable using the clang plugin to build
7283 dnl ========================================================
7285 MOZ_ARG_ENABLE_BOOL(clang-plugin,
7286 [  --enable-clang-plugin   Enable building with the mozilla clang plugin ],
7287    ENABLE_CLANG_PLUGIN=1,
7288    ENABLE_CLANG_PLUGIN= )
7289 if test -n "$ENABLE_CLANG_PLUGIN"; then
7290     if test -z "$CLANG_CC"; then
7291         AC_MSG_ERROR([Can't use clang plugin without clang.])
7292     fi
7293     AC_DEFINE(MOZ_CLANG_PLUGIN)
7296 AC_SUBST(ENABLE_CLANG_PLUGIN)
7298 dnl ========================================================
7299 dnl = Enable stripping of libs & executables
7300 dnl ========================================================
7301 MOZ_ARG_ENABLE_BOOL(strip,
7302 [  --enable-strip          Enable stripping of libs & executables ],
7303     ENABLE_STRIP=1,
7304     ENABLE_STRIP= )
7306 dnl ========================================================
7307 dnl = Enable stripping of libs & executables when packaging
7308 dnl ========================================================
7309 MOZ_ARG_ENABLE_BOOL(install-strip,
7310 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7311     PKG_SKIP_STRIP= ,
7312     PKG_SKIP_STRIP=1)
7314 dnl ========================================================
7315 dnl = --disable-elf-hack
7316 dnl ========================================================
7318 USE_ELF_HACK=1
7319 MOZ_ARG_DISABLE_BOOL(elf-hack,
7320 [  --disable-elf-hack      Disable elf hacks],
7321     [USE_ELF_HACK=],
7322     [USE_ELF_HACK=F # Force enable elf-hack])
7324 # Disable elf hack for profiling because the built in profiler
7325 # doesn't read the segments properly with elf hack. This is
7326 # temporary and should be fixed soon in the profiler.
7327 if test "$MOZ_PROFILING" = 1; then
7328   if test "$USE_ELF_HACK" = F; then
7329     AC_ERROR([--enable-elf-hack is not compatible with --enable-profiling])
7330   fi
7331   USE_ELF_HACK=
7334 # Only enable elfhack where supported
7335 if test "$USE_ELF_HACK" = 1; then
7336     case "${HOST_OS_ARCH},${OS_ARCH}" in
7337     Linux,Linux)
7338         case "${CPU_ARCH}" in
7339         arm | x86 | x86_64)
7340             USE_ELF_HACK=1
7341             ;;
7342         *)
7343             USE_ELF_HACK=
7344             ;;
7345         esac
7346         ;;
7347     *)
7348         USE_ELF_HACK=
7349         ;;
7350     esac
7353 if test -n "$COMPILE_ENVIRONMENT" -a -n "$USE_ELF_HACK"; then
7354     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
7355     dnl memory addresses it maps to. The result is that by the time elfhack
7356     dnl kicks in, it is not possible to apply relocations because of that,
7357     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
7358     dnl segment. It makes elfhack mostly useless, so considering the problems
7359     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
7360     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
7361     dnl the linker creates PT_GNU_RELRO segments. However, when we do want
7362     dnl elfhack enabled, disable PT_GNU_RELRO instead.
7363     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
7364         LINK_WITH_PT_GNU_RELRO,
7365         [echo "int main() {return 0;}" > conftest.${ac_ext}
7366          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
7367             test -s conftest${ac_exeext}; then
7368             if ${TOOLCHAIN_PREFIX}readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
7369                 LINK_WITH_PT_GNU_RELRO=yes
7370             else
7371                 LINK_WITH_PT_GNU_RELRO=no
7372             fi
7373          else
7374              dnl We really don't expect to get here, but just in case
7375              AC_ERROR([couldn't compile a simple C file])
7376          fi
7377          rm -rf conftest*])
7378     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
7379         if test "$USE_ELF_HACK" = F; then
7380             AC_MSG_CHECKING([for -z norelro option to ld])
7381             _SAVE_LDFLAGS=$LDFLAGS
7382             LDFLAGS="$LDFLAGS -Wl,-z,norelro"
7383             AC_TRY_LINK(,,AC_MSG_RESULT([yes])
7384                         [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,norelro"],
7385                         AC_ERROR([--enable-elf-hack is not compatible with a linker creating a PT_GNU_RELRO segment and that doesn't support the "-z norelro" option.]))
7386             USE_ELF_HACK=1
7387         else
7388             AC_MSG_WARN([Disabling elfhack])
7389             USE_ELF_HACK=
7390         fi
7391     fi
7394 dnl ========================================================
7395 dnl = libstdc++ compatibility hacks
7396 dnl ========================================================
7398 STDCXX_COMPAT=
7399 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
7400 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
7401     STDCXX_COMPAT=1)
7403 if test -n "$STDCXX_COMPAT"; then
7404    eval $(CXX="$CXX" HOST_CXX="$HOST_CXX" $PYTHON -m mozbuild.configure.libstdcxx)
7405    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
7406    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
7409 dnl ========================================================
7410 dnl =
7411 dnl = Profiling and Instrumenting
7412 dnl =
7413 dnl ========================================================
7414 MOZ_ARG_HEADER(Profiling and Instrumenting)
7416 dnl ========================================================
7417 dnl = Enable runtime visual profiling logger
7418 dnl ========================================================
7419 MOZ_ARG_ENABLE_BOOL(visual-event-tracer,
7420 [  --enable-visual-event-tracer   Enable visual event tracer instrumentation],
7421     MOZ_VISUAL_EVENT_TRACER=1,
7422     MOZ_VISUAL_EVENT_TRACER=)
7423 if test -n "$MOZ_VISUAL_EVENT_TRACER"; then
7424     AC_DEFINE(MOZ_VISUAL_EVENT_TRACER)
7427 dnl ========================================================
7428 dnl Turn on reflow counting
7429 dnl ========================================================
7430 MOZ_ARG_ENABLE_BOOL(reflow-perf,
7431 [  --enable-reflow-perf    Enable reflow performance tracing],
7432     MOZ_REFLOW_PERF=1,
7433     MOZ_REFLOW_PERF= )
7434 if test -n "$MOZ_REFLOW_PERF"; then
7435     AC_DEFINE(MOZ_REFLOW_PERF)
7438 dnl ========================================================
7439 dnl = Enable Radio Interface for B2G (Gonk usually)
7440 dnl ========================================================
7441 MOZ_ARG_ENABLE_BOOL(b2g-ril,
7442 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
7443     MOZ_B2G_RIL=1,
7444     MOZ_B2G_RIL=,
7445     MOZ_B2G_RIL=$_PLATFORM_HAVE_RIL )
7446 if test -n "$MOZ_B2G_RIL"; then
7447     if test -n "$_PLATFORM_HAVE_RIL"; then
7448         AC_DEFINE(MOZ_B2G_RIL)
7449     else
7450         AC_MSG_ERROR([b2g-ril cannot be enabled because target platform doesn't support it.])
7451     fi
7453 AC_SUBST(MOZ_B2G_RIL)
7455 dnl ========================================================
7456 dnl = Enable Radio FM for B2G (Gonk usually)
7457 dnl ========================================================
7458 if test -n "$MOZ_B2G_FM"; then
7459     AC_DEFINE(MOZ_B2G_FM)
7461 AC_SUBST(MOZ_B2G_FM)
7463 dnl ========================================================
7464 dnl = Enable Bluetooth Interface for B2G (Gonk usually)
7465 dnl ========================================================
7466 MOZ_ARG_ENABLE_BOOL(b2g-bt,
7467 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
7468     MOZ_B2G_BT=1,
7469     MOZ_B2G_BT= )
7470 if test -n "$MOZ_B2G_BT"; then
7471     AC_DEFINE(MOZ_B2G_BT)
7473 AC_SUBST(MOZ_B2G_BT)
7474 AC_SUBST(MOZ_B2G_BT_BLUEZ)
7475 AC_SUBST(MOZ_B2G_BT_BLUEDROID)
7477 dnl ========================================================
7478 dnl = Enable NFC Interface for B2G (Gonk usually)
7479 dnl ========================================================
7480 MOZ_ARG_ENABLE_BOOL(nfc,
7481 [  --enable-nfc         Set compile flags necessary for compiling NFC API ],
7482     MOZ_NFC=1,
7483     MOZ_NFC= )
7484 if test -n "$MOZ_NFC"; then
7485    AC_DEFINE(MOZ_NFC)
7487 AC_SUBST(MOZ_NFC)
7489 dnl ========================================================
7490 dnl = Enable Pico Speech Synthesis (Gonk usually)
7491 dnl ========================================================
7492 MOZ_ARG_ENABLE_BOOL(synth-pico,
7493 [  --enable-synth-pico  Set compile flags necessary for compiling Pico Web Speech API ],
7494     MOZ_SYNTH_PICO=1,
7495     MOZ_SYNTH_PICO= )
7496 if test -n "$MOZ_SYNTH_PICO"; then
7497     AC_DEFINE(MOZ_SYNTH_PICO)
7499 AC_SUBST(MOZ_SYNTH_PICO)
7501 dnl ========================================================
7502 dnl = Enable Support for Time Manager API
7503 dnl ========================================================
7504 if test -n "$MOZ_TIME_MANAGER"; then
7505     AC_DEFINE(MOZ_TIME_MANAGER)
7507 AC_SUBST(MOZ_TIME_MANAGER)
7509 dnl ========================================================
7510 dnl = Enable Camera Interface for B2G (Gonk usually)
7511 dnl ========================================================
7512 MOZ_ARG_ENABLE_BOOL(b2g-camera,
7513 [  --enable-b2g-camera      Set compile flags necessary for compiling camera API for B2G ],
7514     MOZ_B2G_CAMERA=1,
7515     MOZ_B2G_CAMERA= )
7516 if test -n "$MOZ_B2G_CAMERA"; then
7517    AC_DEFINE(MOZ_B2G_CAMERA)
7519 AC_SUBST(MOZ_B2G_CAMERA)
7521 dnl ========================================================
7522 dnl = Enable Support B2G-specific changes to the NSS
7523 dnl = certificate trust database.
7524 dnl ========================================================
7525 if test -n "$MOZ_B2G_CERTDATA"; then
7526     AC_DEFINE(MOZ_B2G_CERTDATA)
7528 AC_SUBST(MOZ_B2G_CERTDATA)
7530 dnl ========================================================
7531 dnl = Enable Support for Payment API
7532 dnl ========================================================
7533 if test -n "$MOZ_PAY"; then
7534     AC_DEFINE(MOZ_PAY)
7536 AC_SUBST(MOZ_PAY)
7538 dnl ========================================================
7539 dnl = Enable Browser Support for Activities
7540 dnl ========================================================
7541 if test -n "$MOZ_ACTIVITIES"; then
7542     AC_DEFINE(MOZ_ACTIVITIES)
7544 AC_SUBST(MOZ_ACTIVITIES)
7546 dnl ========================================================
7547 dnl = Enable Support for AudioChannelManager API
7548 dnl ========================================================
7549 if test -n "$MOZ_AUDIO_CHANNEL_MANAGER"; then
7550     AC_DEFINE(MOZ_AUDIO_CHANNEL_MANAGER)
7552 AC_SUBST(MOZ_AUDIO_CHANNEL_MANAGER)
7554 dnl ========================================================
7555 dnl = Enable Support for Firefox Accounts (services/fxaccounts)
7556 dnl ========================================================
7557 if test -n "$MOZ_SERVICES_FXACCOUNTS"; then
7558     AC_DEFINE(MOZ_SERVICES_FXACCOUNTS)
7560 AC_SUBST(MOZ_SERVICES_FXACCOUNTS)
7562 dnl ========================================================
7563 dnl = Support for demangling undefined symbols
7564 dnl ========================================================
7565 if test -z "$SKIP_LIBRARY_CHECKS"; then
7566     AC_LANG_SAVE
7567     AC_LANG_CPLUSPLUS
7568     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7569     AC_LANG_RESTORE
7572 # Demangle only for debug or trace-malloc or DMD builds
7573 MOZ_DEMANGLE_SYMBOLS=
7574 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
7575     MOZ_DEMANGLE_SYMBOLS=1
7576     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7578 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7580 dnl ========================================================
7581 dnl = Support for gcc stack unwinding (from gcc 3.3)
7582 dnl ========================================================
7583 if test -z "$SKIP_LIBRARY_CHECKS"; then
7584     AC_LANG_SAVE
7585     AC_LANG_CPLUSPLUS
7586     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7587     AC_LANG_RESTORE
7590 dnl ========================================================
7591 dnl JIT observers
7592 dnl ========================================================
7594 MOZ_ARG_WITH_STRING(jitreport-granularity,
7595 [  --jitreport-granularity=N
7596                            Default granularity at which to report JIT code
7597                            to external tools
7598                              0 - no info
7599                              1 - code ranges for whole functions only
7600                              2 - per-line information
7601                              3 - per-op information],
7602   JITREPORT_GRANULARITY=$withval,
7603   JITREPORT_GRANULARITY=3)
7605 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
7607 dnl ========================================================
7608 dnl =
7609 dnl = Misc. Options
7610 dnl =
7611 dnl ========================================================
7612 MOZ_ARG_HEADER(Misc. Options)
7614 dnl ========================================================
7615 dnl update xterm title
7616 dnl ========================================================
7617 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7618 [  --enable-xterm-updates  Update XTERM titles with current command.],
7619     MOZ_UPDATE_XTERM=1,
7620     MOZ_UPDATE_XTERM= )
7622 dnl =========================================================
7623 dnl = Chrome format
7624 dnl =========================================================
7625 MOZ_ARG_ENABLE_STRING([chrome-format],
7626 [  --enable-chrome-format=jar|flat|omni
7627                           Select FORMAT of chrome files during packaging],
7628     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7630 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7631     MOZ_CHROME_FILE_FORMAT=jar
7634 if test "$MOZ_CHROME_FILE_FORMAT" = "symlink"; then
7635     AC_MSG_ERROR([--enable-chrome-format=symlink has been deprecated. It is now used by default in $DIST/bin on platforms that support it])
7638 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
7639     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7640     test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
7641     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, or omni])
7644 dnl =========================================================
7645 dnl Omnijar packaging (bug 552121)
7646 dnl =========================================================
7647 dnl Omnijar packaging is compatible with flat packaging.
7648 dnl In unpackaged builds, omnijar looks for files as if
7649 dnl things were flat packaged. After packaging, all files
7650 dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
7651 dnl is set to flat since putting files into jars is only
7652 dnl done during packaging with omnijar.
7653 if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
7654     MOZ_OMNIJAR=1
7655     AC_DEFINE(MOZ_OMNIJAR)
7657 MOZ_PACKAGER_FORMAT="$MOZ_CHROME_FILE_FORMAT"
7658 if test "$OS_ARCH" = "WINNT" -o "$MOZ_WIDGET_TOOLKIT" = "android"; then
7659     MOZ_CHROME_FILE_FORMAT=flat
7660 else
7661     MOZ_CHROME_FILE_FORMAT=symlink
7664 if test "$MOZ_WIDGET_TOOLKIT" = "android"; then
7665     dnl Fennec's static resources live in the assets/ folder of the
7666     dnl APK.  Adding a path to the name here works because we only
7667     dnl have one omnijar file in the final package (which is not the
7668     dnl case on desktop), and necessitates some contortions during
7669     dnl packaging so that the resources in the omnijar are considered
7670     dnl as rooted at / and not as rooted at assets/ (which again is
7671     dnl not the case on desktop: there are omnijars rooted at webrtc/,
7672     dnl etc). packager.mk handles changing the rooting of the single
7673     dnl omnijar.
7674     OMNIJAR_NAME=assets/omni.ja
7675 else
7676     OMNIJAR_NAME=omni.ja
7679 AC_SUBST(OMNIJAR_NAME)
7680 AC_SUBST(MOZ_OMNIJAR)
7681 AC_SUBST(MOZ_PACKAGER_FORMAT)
7683 dnl ========================================================
7684 dnl = Define default location for MOZILLA_FIVE_HOME
7685 dnl ========================================================
7686 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7687 [  --with-default-mozilla-five-home
7688                           Set the default value for MOZILLA_FIVE_HOME],
7689 [ val=`echo $withval`
7690   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7692 dnl ========================================================
7693 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7694 dnl ========================================================
7695 MOZ_ARG_WITH_STRING(user-appdir,
7696 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7697 [ val=`echo $withval`
7698 if echo "$val" | grep "\/" >/dev/null; then
7699     AC_MSG_ERROR("Homedir must be single relative path.")
7700 else
7701     MOZ_USER_DIR="$val"
7702 fi])
7704 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7706 dnl ========================================================
7707 dnl = Doxygen configuration
7708 dnl ========================================================
7709 dnl Use commas to specify multiple dirs to this arg
7710 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7711 MOZ_ARG_WITH_STRING(doc-input-dirs,
7712 [  --with-doc-input-dirs=DIRS
7713                           Header/idl dirs to create docs from],
7714 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7715 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7717 dnl Use commas to specify multiple dirs to this arg
7718 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7719 MOZ_ARG_WITH_STRING(doc-include-dirs,
7720 [  --with-doc-include-dirs=DIRS
7721                           Include dirs to preprocess doc headers],
7722 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7723 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7725 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7726 MOZ_ARG_WITH_STRING(doc-output-dir,
7727 [  --with-doc-output-dir=DIR
7728                           Dir to generate docs into],
7729 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7730 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7732 if test -z "$SKIP_COMPILER_CHECKS"; then
7733 dnl ========================================================
7734 dnl =
7735 dnl = Compiler Options
7736 dnl =
7737 dnl ========================================================
7738 MOZ_ARG_HEADER(Compiler Options)
7740 dnl ========================================================
7741 dnl Check for gcc -pipe support
7742 dnl ========================================================
7743 AC_MSG_CHECKING([for -pipe support])
7744 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
7745     dnl Any gcc that supports firefox supports -pipe.
7746     CFLAGS="$CFLAGS -pipe"
7747     CXXFLAGS="$CXXFLAGS -pipe"
7748     AC_MSG_RESULT([yes])
7749 else
7750     AC_MSG_RESULT([no])
7753 dnl ========================================================
7754 dnl Profile guided optimization (gcc checks)
7755 dnl ========================================================
7756 dnl Test for profiling options
7757 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7759 _SAVE_CFLAGS="$CFLAGS"
7760 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
7762 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7763 AC_TRY_COMPILE([], [return 0;],
7764                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7765                  result="yes" ], result="no")
7766 AC_MSG_RESULT([$result])
7768 if test $result = "yes"; then
7769   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7770   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
7771   PROFILE_USE_LDFLAGS="-fprofile-use"
7774 CFLAGS="$_SAVE_CFLAGS"
7776 if test -n "$INTEL_CC"; then
7777   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
7778   PROFILE_GEN_LDFLAGS=
7779   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
7780   PROFILE_USE_LDFLAGS=
7783 dnl Sun Studio on Solaris
7784 if test "$SOLARIS_SUNPRO_CC"; then
7785   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
7786   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
7787   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
7788   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
7791 AC_SUBST(PROFILE_GEN_CFLAGS)
7792 AC_SUBST(PROFILE_GEN_LDFLAGS)
7793 AC_SUBST(PROFILE_USE_CFLAGS)
7794 AC_SUBST(PROFILE_USE_LDFLAGS)
7796 AC_LANG_CPLUSPLUS
7798 dnl ========================================================
7799 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
7800 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
7801 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
7802 dnl ========================================================
7803 _SAVE_CXXFLAGS=$CXXFLAGS
7804 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
7805 AC_CACHE_CHECK(for correct overload resolution with const and templates,
7806     ac_nscap_nonconst_opeq_bug,
7807     [AC_TRY_COMPILE([
7808                       template <class T>
7809                       class Pointer
7810                         {
7811                         public:
7812                           T* myPtr;
7813                         };
7815                       template <class T, class U>
7816                       int operator==(const Pointer<T>& rhs, U* lhs)
7817                         {
7818                           return rhs.myPtr == lhs;
7819                         }
7821                       template <class T, class U>
7822                       int operator==(const Pointer<T>& rhs, const U* lhs)
7823                         {
7824                           return rhs.myPtr == lhs;
7825                         }
7826                     ],
7827                     [
7828                       Pointer<int> foo;
7829                       const int* bar;
7830                       return foo == bar;
7831                     ],
7832                     ac_nscap_nonconst_opeq_bug="no",
7833                     ac_nscap_nonconst_opeq_bug="yes")])
7834 CXXFLAGS="$_SAVE_CXXFLAGS"
7836 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
7837     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
7839 fi # ! SKIP_COMPILER_CHECKS
7841 AC_DEFINE(CPP_THROW_NEW, [throw()])
7842 AC_LANG_C
7844 if test "$COMPILE_ENVIRONMENT"; then
7845 MOZ_EXPAND_LIBS
7846 fi # COMPILE_ENVIRONMENT
7848 dnl ========================================================
7849 dnl =
7850 dnl = Build depencency options
7851 dnl =
7852 dnl ========================================================
7853 MOZ_ARG_HEADER(Build dependencies)
7855 if test "$GNU_CC" -a "$GNU_CXX"; then
7856   _DEPEND_CFLAGS='-MD -MP -MF $(MDDEPDIR)/$(@F).pp'
7857 dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
7858 elif test "$SOLARIS_SUNPRO_CC"; then
7859   _DEPEND_CFLAGS=
7860 else
7861   dnl Don't override this for MSVC
7862   if test -z "$_WIN32_MSVC"; then
7863     _USE_CPP_INCLUDE_FLAG=
7864     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7865     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7866   else
7867     echo '#include <stdio.h>' > dummy-hello.c
7868     changequote(,)
7869     dnl This output is localized, split at the first double space or colon and space.
7870     _CL_PREFIX_REGEX="^\([^:]*:.*[ :] \)\(.*stdio.h\)$"
7871     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\1/p'`
7872     _CL_STDIO_PATH=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\2/p'`
7873     changequote([,])
7874     if ! test -e "$_CL_STDIO_PATH"; then
7875         AC_MSG_ERROR([Unable to parse cl -showIncludes prefix. This compiler's locale has an unsupported formatting.])
7876     fi
7877     if test -z "$CL_INCLUDES_PREFIX"; then
7878         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
7879     fi
7880     AC_SUBST(CL_INCLUDES_PREFIX)
7881     rm -f dummy-hello.c
7882   fi
7885 dnl Make sure that the build system can handle non-ASCII characters
7886 dnl in environment variables to prevent it from breking silently on
7887 dnl non-English systems.
7888 NONASCII=$'\241\241'
7889 AC_SUBST(NONASCII)
7891 dnl ========================================================
7892 dnl =
7893 dnl = Static Build Options
7894 dnl =
7895 dnl ========================================================
7896 MOZ_ARG_HEADER(Static build options)
7898 AC_SUBST(LIBXUL_LIBS)
7899 XPCOM_LIBS="$LIBXUL_LIBS"
7901 if test "$OS_ARCH" = "WINNT"; then
7902   GKMEDIAS_SHARED_LIBRARY=1
7903   AC_DEFINE(GKMEDIAS_SHARED_LIBRARY)
7905 AC_SUBST(GKMEDIAS_SHARED_LIBRARY)
7907 if test -z "$MOZ_NATIVE_ZLIB"; then
7908 if test -n "$JS_SHARED_LIBRARY" -o "$GKMEDIAS_SHARED_LIBRARY"; then
7909   ZLIB_IN_MOZGLUE=1
7910   AC_DEFINE(ZLIB_IN_MOZGLUE)
7914 AC_SUBST(ZLIB_IN_MOZGLUE)
7916 dnl ========================================================
7917 dnl =
7918 dnl = Standalone module options
7919 dnl =
7920 dnl ========================================================
7921 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
7923 dnl Check for GLib.
7924 dnl ========================================================
7926 if test -z "$SKIP_PATH_CHECKS"; then
7927 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
7928     if test "$MOZ_ENABLE_GTK" ; then
7929         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
7930     fi
7934 if test -z "${GLIB_GMODULE_LIBS}" \
7935    -a -n "${GLIB_CONFIG}"\
7936     -a "${GLIB_CONFIG}" != no\
7937 ; then
7938     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
7941 AC_SUBST(GLIB_CFLAGS)
7942 AC_SUBST(GLIB_LIBS)
7943 AC_SUBST(GLIB_GMODULE_LIBS)
7945 dnl ========================================================
7946 dnl Graphics checks.
7947 dnl ========================================================
7949 if test "${OS_TARGET}" = "WINNT"; then
7950   if $PERL -e "exit($MOZ_WINSDK_MAXVER < 0x06020000)"; then
7951     MOZ_ENABLE_DIRECT2D1_1=1
7952     AC_SUBST(MOZ_ENABLE_DIRECT2D1_1)
7953   fi
7956 if test "${OS_TARGET}" = "WINNT" -o \
7957         "${OS_ARCH}" = "Darwin" -o \
7958         "${MOZ_WIDGET_TOOLKIT}" = "android" -o \
7959         "${MOZ_WIDGET_TOOLKIT}" = "gonk" -o \
7960         "${MOZ_WIDGET_TOOLKIT}" = "gtk2" -o \
7961         "${MOZ_WIDGET_TOOLKIT}" = "gtk3"; then
7962     case "${target_cpu}" in
7963     i*86*|x86_64|arm)
7964         MOZ_ENABLE_SKIA=1
7965         ;;
7966     *)
7967         MOZ_ENABLE_SKIA=
7968         ;;
7969     esac
7970 else
7971 MOZ_ENABLE_SKIA=
7974 MOZ_ARG_ENABLE_BOOL(skia,
7975 [  --enable-skia   Enable use of Skia],
7976 MOZ_ENABLE_SKIA=1,
7977 MOZ_ENABLE_SKIA=)
7979 if test "$USE_FC_FREETYPE"; then
7980     if test "$COMPILE_ENVIRONMENT"; then
7981         dnl ========================================================
7982         dnl = Check for freetype2 and its functionality
7983         dnl ========================================================
7984         PKG_CHECK_MODULES(FT2, freetype2 >= 6.1.0, _HAVE_FREETYPE2=1, _HAVE_FREETYPE2=)
7986         if test "$_HAVE_FREETYPE2"; then
7987             _SAVE_LIBS="$LIBS"
7988             _SAVE_CFLAGS="$CFLAGS"
7989             LIBS="$LIBS $FT2_LIBS"
7990             CFLAGS="$CFLAGS $FT2_CFLAGS"
7992             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
7993                 ac_cv_member_FT_Bitmap_Size_y_ppem,
7994                 [AC_TRY_COMPILE([#include <ft2build.h>
7995                                  #include FT_FREETYPE_H],
7996                                 [FT_Bitmap_Size s;
7997                                  if (sizeof s.y_ppem) return 0;
7998                                  return 1],
7999                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
8000                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
8001             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
8002                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
8003             else
8004                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
8005             fi
8006             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
8007                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
8008                                [FT_Bitmap_Size structure includes y_ppem field])
8010             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table)
8012             LIBS="$_SAVE_LIBS"
8013             CFLAGS="$_SAVE_CFLAGS"
8014         fi
8016         _SAVE_CPPFLAGS="$CPPFLAGS"
8017         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
8018         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
8019             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
8020         CPPFLAGS="$_SAVE_CPPFLAGS"
8021     else
8022         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
8023     fi
8025     PKG_CHECK_MODULES(_FONTCONFIG, fontconfig,
8026     [
8027         if test "$MOZ_PANGO"; then
8028             MOZ_PANGO_CFLAGS="$MOZ_PANGO_CFLAGS $_FONTCONFIG_CFLAGS"
8029             MOZ_PANGO_LIBS="$MOZ_PANGO_LIBS $_FONTCONFIG_LIBS"
8030         else
8031             FT2_CFLAGS="$FT2_CFLAGS $_FONTCONFIG_CFLAGS"
8032             FT2_LIBS="$FT2_LIBS $_FONTCONFIG_LIBS"
8033         fi
8034     ])
8037 dnl ========================================================
8038 dnl Check for pixman and cairo
8039 dnl ========================================================
8041 if test "$MOZ_WIDGET_TOOLKIT" = "gtk3" ; then
8042   # cairo-gtk3 can be build with system-cairo only
8043   MOZ_TREE_CAIRO=
8044 else
8045   MOZ_TREE_CAIRO=1
8048 MOZ_ARG_ENABLE_BOOL(system-cairo,
8049 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
8050 MOZ_TREE_CAIRO=,
8051 MOZ_TREE_CAIRO=1 )
8053 MOZ_TREE_PIXMAN=1
8054 MOZ_ARG_ENABLE_BOOL(system-pixman,
8055 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
8056 MOZ_TREE_PIXMAN=,
8057 MOZ_TREE_PIXMAN=force,
8058 MOZ_TREE_PIXMAN=1 )
8060 # System cairo depends on system pixman
8061 if test "$MOZ_TREE_PIXMAN" = "force"; then
8062     if test -z "$MOZ_TREE_CAIRO"; then
8063         AC_MSG_ERROR([--disable-system-pixman is incompatible with --enable-system-cairo.])
8064     else
8065         MOZ_TREE_PIXMAN=1
8066     fi
8067 elif test -z "$MOZ_TREE_CAIRO"; then
8068     MOZ_TREE_PIXMAN=
8071 if test "$MOZ_TREE_PIXMAN"; then
8072     AC_DEFINE(MOZ_TREE_PIXMAN)
8073     MOZ_PIXMAN_CFLAGS=""
8074     MOZ_PIXMAN_LIBS='$(call EXPAND_LIBNAME_PATH,mozlibpixman,$(DEPTH)/gfx/cairo/libpixman/src)'
8075 else
8076     PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.19.2)
8077     MOZ_PIXMAN_CFLAGS="$PIXMAN_CFLAGS"
8078     MOZ_PIXMAN_LIBS="$PIXMAN_LIBS"
8080 AC_SUBST(MOZ_PIXMAN_CFLAGS)
8081 AC_SUBST(MOZ_PIXMAN_LIBS)
8083 # Check for headers defining standard int types.
8084 if test -n "$COMPILE_ENVIRONMENT"; then
8085     MOZ_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
8088 if test "$MOZ_TREE_CAIRO"; then
8089     MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
8090     AC_DEFINE(MOZ_TREE_CAIRO)
8092     if test "$OS_ARCH" = "WINNT"; then
8093         # For now we assume that we will have a uint64_t available through
8094         # one of the above headers or mozstdint.h.
8095         AC_DEFINE(HAVE_UINT64_T)
8096     fi
8098     # Define macros for cairo-features.h
8099     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
8100     if test "$MOZ_X11"; then
8101         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
8102         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
8103         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
8104         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8105         MOZ_ENABLE_CAIRO_FT=1
8106         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
8107     fi
8108     case "$MOZ_WIDGET_TOOLKIT" in
8109       qt)
8110         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
8111         ;;
8112       cocoa | uikit)
8113         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
8114         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
8115         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
8116         ;;
8117       windows)
8118         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
8119         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
8120         if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
8121             WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
8122             WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
8123             MOZ_ENABLE_D2D_SURFACE=1
8124             MOZ_ENABLE_DWRITE_FONT=1
8125         else
8126             WIN32_DWRITE_FONT_FEATURE=
8127             WIN32_D2D_SURFACE_FEATURE=
8128         fi
8130         MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
8132         dnl D3D10 Layers depend on D2D Surfaces.
8133         if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
8134           MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
8135         fi
8136         ;;
8137       gtk3)
8138         AC_MSG_ERROR([cairo-gtk3 toolkit is incompatible with in-tree cairo. Please add --enable-system-cairo to your build config.])
8139         ;;
8140     esac
8141     if test "$USE_FC_FREETYPE"; then
8142         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
8143     fi
8144     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
8145     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
8146     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
8147     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
8148     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
8149     AC_SUBST(CAIRO_FT_CFLAGS)
8151     AC_SUBST(PS_SURFACE_FEATURE)
8152     AC_SUBST(PDF_SURFACE_FEATURE)
8153     AC_SUBST(SVG_SURFACE_FEATURE)
8154     AC_SUBST(XLIB_SURFACE_FEATURE)
8155     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
8156     AC_SUBST(QUARTZ_SURFACE_FEATURE)
8157     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
8158     AC_SUBST(WIN32_SURFACE_FEATURE)
8159     AC_SUBST(OS2_SURFACE_FEATURE)
8160     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
8161     AC_SUBST(FT_FONT_FEATURE)
8162     AC_SUBST(FC_FONT_FEATURE)
8163     AC_SUBST(WIN32_FONT_FEATURE)
8164     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
8165     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
8166     AC_SUBST(QUARTZ_FONT_FEATURE)
8167     AC_SUBST(PNG_FUNCTIONS_FEATURE)
8168     AC_SUBST(QT_SURFACE_FEATURE)
8169     AC_SUBST(TEE_SURFACE_FEATURE)
8171     MOZ_CAIRO_OSLIBS='${CAIRO_FT_OSLIBS}'
8173     if test "$MOZ_X11"; then
8174         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
8175     fi
8177     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
8178 else
8179     PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION)
8180     MOZ_CAIRO_CFLAGS="$CAIRO_CFLAGS"
8181     MOZ_CAIRO_LIBS="$CAIRO_LIBS"
8182     PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
8183     if test "$MOZ_X11"; then
8184         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
8185         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
8186         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_LIBS"
8187         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
8188     fi
8191 AC_SUBST(MOZ_TREE_CAIRO)
8192 AC_SUBST(MOZ_CAIRO_CFLAGS)
8193 AC_SUBST(MOZ_CAIRO_LIBS)
8194 AC_SUBST(MOZ_CAIRO_OSLIBS)
8195 AC_SUBST(MOZ_TREE_PIXMAN)
8197 dnl ========================================================
8198 dnl Skia
8199 dnl ========================================================
8200 if test "$MOZ_ENABLE_SKIA"; then
8201   AC_DEFINE(MOZ_ENABLE_SKIA)
8202   AC_DEFINE(USE_SKIA)
8203   if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
8204     AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
8205   fi
8207   if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64" -a "${CPU_ARCH}" != "sparc" ; then
8208     MOZ_ENABLE_SKIA_GPU=1
8209     AC_DEFINE(USE_SKIA_GPU)
8210     AC_SUBST(MOZ_ENABLE_SKIA_GPU)
8211   fi
8213 AC_SUBST(MOZ_ENABLE_SKIA)
8215 dnl ========================================================
8216 dnl disable xul
8217 dnl ========================================================
8218 MOZ_ARG_DISABLE_BOOL(xul,
8219 [  --disable-xul           Disable XUL],
8220     MOZ_XUL= )
8221 if test "$MOZ_XUL"; then
8222   AC_DEFINE(MOZ_XUL)
8223 else
8224   dnl remove extensions that require XUL
8225   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/venkman//' -e 's/irc//' -e 's/tasks//'`
8228 AC_SUBST(MOZ_XUL)
8230 dnl ========================================================
8231 dnl disable profile locking
8232 dnl   do no use this in applications that can have more than
8233 dnl   one process accessing the profile directory.
8234 dnl ========================================================
8235 MOZ_ARG_DISABLE_BOOL(profilelocking,
8236 [  --disable-profilelocking
8237                           Disable profile locking],
8238     MOZ_PROFILELOCKING=,
8239     MOZ_PROFILELOCKING=1 )
8240 if test "$MOZ_PROFILELOCKING"; then
8241   AC_DEFINE(MOZ_PROFILELOCKING)
8244 dnl ========================================================
8245 dnl necko configuration options
8246 dnl ========================================================
8249 dnl option to disable various necko protocols
8251 MOZ_ARG_ENABLE_STRING(necko-protocols,
8252 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8253                           Enable/disable specific protocol handlers],
8254 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8255     if test "$option" = "yes" -o "$option" = "all"; then
8256         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8257     elif test "$option" = "no" -o "$option" = "none"; then
8258         NECKO_PROTOCOLS=""
8259     elif test "$option" = "default"; then
8260         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8261     elif test `echo "$option" | grep -c \^-` != 0; then
8262         option=`echo $option | sed 's/^-//'`
8263         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8264     else
8265         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8266     fi
8267 done],
8268     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8269 dnl Remove dupes
8270 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
8271 AC_SUBST_SET(NECKO_PROTOCOLS)
8272 for p in $NECKO_PROTOCOLS; do
8273     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8274     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_PROTOCOL_$p"
8275 done
8278 dnl option to disable necko's wifi scanner
8281 case "$OS_TARGET" in
8282   Android)
8283     if test -n "$gonkdir"; then
8284       NECKO_WIFI=1
8285     fi
8286     ;;
8287   Darwin|FreeBSD|SunOS|WINNT)
8288     NECKO_WIFI=1
8289     ;;
8290   Linux)
8291     NECKO_WIFI=1
8292     NECKO_WIFI_DBUS=1
8293     ;;
8294 esac
8296 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8297 [  --disable-necko-wifi    Disable necko wifi scanner],
8298     NECKO_WIFI=,
8299     NECKO_WIFI=1)
8301 if test "$NECKO_WIFI"; then
8302   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
8303     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
8304   fi
8305   AC_DEFINE(NECKO_WIFI)
8306   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
8308 AC_SUBST(NECKO_WIFI)
8309 AC_SUBST(NECKO_WIFI_DBUS)
8312 dnl option to disable cookies
8314 MOZ_ARG_DISABLE_BOOL(cookies,
8315 [  --disable-cookies       Disable cookie support],
8316     NECKO_COOKIES=,
8317     NECKO_COOKIES=1)
8318 AC_SUBST(NECKO_COOKIES)
8319 if test "$NECKO_COOKIES"; then
8320     AC_DEFINE(NECKO_COOKIES)
8321     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
8325 dnl Always build Marionette if not Android or B2G
8327 if test "$OS_TARGET" != Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
8328     AC_DEFINE(ENABLE_MARIONETTE)
8330 AC_SUBST(ENABLE_MARIONETTE)
8331 if test "$ENABLE_MARIONETTE"; then
8332     AC_DEFINE(ENABLE_MARIONETTE)
8336 dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
8338 MOZ_ARG_DISABLE_BOOL(ctypes,
8339 [  --disable-ctypes        Disable js-ctypes],
8340     BUILD_CTYPES=,
8341     BUILD_CTYPES=1)
8342 AC_SUBST(BUILD_CTYPES)
8343 if test "$BUILD_CTYPES"; then
8344     AC_DEFINE(BUILD_CTYPES)
8347 dnl Build Places if required
8348 if test "$MOZ_PLACES"; then
8349   AC_DEFINE(MOZ_PLACES)
8352 dnl Build SocialAPI if required
8353 if test "$MOZ_SOCIAL"; then
8354   AC_DEFINE(MOZ_SOCIAL)
8357 dnl Build Common JS modules provided by services.
8358 AC_SUBST(MOZ_SERVICES_COMMON)
8359 if test -n "$MOZ_SERVICES_COMMON"; then
8360   AC_DEFINE(MOZ_SERVICES_COMMON)
8363 dnl Build Services crypto component (used by Sync)
8364 AC_SUBST(MOZ_SERVICES_CRYPTO)
8365 if test -n "$MOZ_SERVICES_CRYPTO"; then
8366   AC_DEFINE(MOZ_SERVICES_CRYPTO)
8369 dnl Build Firefox Health Reporter Service
8370 AC_SUBST(MOZ_SERVICES_HEALTHREPORT)
8371 if test -n "$MOZ_SERVICES_HEALTHREPORT"; then
8372   AC_DEFINE(MOZ_SERVICES_HEALTHREPORT)
8375 dnl Build Services metrics component
8376 AC_SUBST(MOZ_SERVICES_METRICS)
8377 if test -n "$MOZ_SERVICES_METRICS"; then
8378   AC_DEFINE(MOZ_SERVICES_METRICS)
8381 dnl Build Notifications if required
8382 AC_SUBST(MOZ_SERVICES_NOTIFICATIONS)
8383 if test -n "$MOZ_SERVICES_NOTIFICATIONS"; then
8384   AC_DEFINE(MOZ_SERVICES_NOTIFICATIONS)
8387 dnl Build Sync Services if required
8388 AC_SUBST(MOZ_SERVICES_SYNC)
8389 if test -n "$MOZ_SERVICES_SYNC"; then
8390   AC_DEFINE(MOZ_SERVICES_SYNC)
8393 dnl Build Captive Portal Detector if required
8394 AC_SUBST(MOZ_CAPTIVEDETECT)
8395 if test -n "$MOZ_CAPTIVEDETECT"; then
8396   AC_DEFINE(MOZ_CAPTIVEDETECT)
8399 dnl ========================================================
8400 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
8401     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8404 if test "$MOZ_APP_COMPONENT_INCLUDE"; then
8405   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
8408 if test "$MOZ_APP_COMPONENT_MODULES"; then
8409   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_MODULES, $MOZ_APP_COMPONENT_MODULES)
8412 dnl ========================================================
8413 dnl =
8414 dnl = Maintainer debug option (no --enable equivalent)
8415 dnl =
8416 dnl ========================================================
8418 AC_SUBST(AR)
8419 AC_SUBST(AR_FLAGS)
8420 AC_SUBST(AR_LIST)
8421 AC_SUBST(AR_EXTRACT)
8422 AC_SUBST(AR_DELETE)
8423 AC_SUBST(AS)
8424 AC_SUBST(ASFLAGS)
8425 AC_SUBST(AS_DASH_C_FLAG)
8426 AC_SUBST(LD)
8427 AC_SUBST(RC)
8428 AC_SUBST(RCFLAGS)
8429 AC_SUBST(MC)
8430 AC_SUBST(WINDRES)
8431 AC_SUBST(IMPLIB)
8432 AC_SUBST(FILTER)
8433 AC_SUBST(BIN_FLAGS)
8434 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8435 AC_SUBST(MOZ_UPDATE_XTERM)
8436 AC_SUBST(MOZ_AUTH_EXTENSION)
8437 AC_SUBST(MOZ_PERMISSIONS)
8438 AC_SUBST(MOZ_PREF_EXTENSIONS)
8439 AC_SUBST(MOZ_JS_LIBS)
8440 AC_SUBST(MOZ_DEBUG)
8441 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8442 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8443 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8444 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8445 AC_SUBST(WARNINGS_AS_ERRORS)
8446 AC_SUBST(MOZ_EXTENSIONS)
8447 AC_SUBST(MOZ_JSDEBUGGER)
8448 AC_SUBST(MOZ_ENABLE_PROFILER_SPS)
8449 AC_SUBST(MOZ_JPROF)
8450 AC_SUBST(MOZ_SHARK)
8451 AC_SUBST(MOZ_INSTRUMENTS)
8452 AC_SUBST(MOZ_CALLGRIND)
8453 AC_SUBST(MOZ_VTUNE)
8454 AC_SUBST(MOZ_PROFILING)
8455 AC_SUBST(LIBICONV)
8456 AC_SUBST(MOZ_PLACES)
8457 AC_SUBST(MOZ_SOCIAL)
8458 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8459 AC_SUBST(MOZ_FEEDS)
8460 AC_SUBST(NS_PRINTING)
8461 AC_SUBST(MOZ_WEBGL)
8462 AC_SUBST(MOZ_HELP_VIEWER)
8463 AC_SUBST(TOOLCHAIN_PREFIX)
8465 AC_SUBST(JAVA)
8466 AC_SUBST(JAVAC)
8467 AC_SUBST(JAVAH)
8468 AC_SUBST(JAR)
8469 AC_SUBST(JARSIGNER)
8470 AC_SUBST(KEYTOOL)
8472 AC_SUBST(MOZ_PROFILELOCKING)
8474 AC_SUBST(ENABLE_TESTS)
8475 AC_SUBST(IBMBIDI)
8476 AC_SUBST(MOZ_UNIVERSALCHARDET)
8477 AC_SUBST(ACCESSIBILITY)
8478 AC_SUBST(MOZ_SPELLCHECK)
8479 AC_SUBST(MOZ_ANDROID_OMTC)
8480 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
8481 AC_SUBST(MOZ_CRASHREPORTER)
8482 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
8483 AC_SUBST(MOZ_CRASHREPORTER_UPLOAD_FULL_SYMBOLS)
8484 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
8485 AC_SUBST(MOZ_STUB_INSTALLER)
8486 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
8487 AC_SUBST(MOZ_ENABLE_SIGNMAR)
8488 AC_SUBST(MOZ_UPDATER)
8490 AC_SUBST(MOZ_ANGLE_RENDERER)
8491 AC_SUBST(MOZ_DIRECTX_SDK_CPU_SUFFIX)
8492 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
8493 AC_SUBST(MOZ_D3DCOMPILER_DLL)
8494 AC_SUBST(MOZ_HAS_WINSDK_WITH_D3D)
8495 AC_SUBST(MOZ_D3DCOMPILER_DLL_PATH)
8496 AC_SUBST(MOZ_D3DCOMPILER_CAB)
8498 AC_SUBST(MOZ_METRO)
8500 AC_SUBST(MOZ_ANDROID_HISTORY)
8501 AC_SUBST(MOZ_WEBSMS_BACKEND)
8502 AC_SUBST(MOZ_ANDROID_BEAM)
8503 AC_SUBST(MOZ_ANDROID_SYNTHAPKS)
8504 AC_SUBST(MOZ_DISABLE_GECKOVIEW)
8505 AC_SUBST(ENABLE_STRIP)
8506 AC_SUBST(PKG_SKIP_STRIP)
8507 AC_SUBST(STRIP_FLAGS)
8508 AC_SUBST(USE_ELF_HACK)
8509 AC_SUBST(INCREMENTAL_LINKER)
8510 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8511 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8513 AC_SUBST(MOZ_FIX_LINK_PATHS)
8514 AC_SUBST(XPCOM_LIBS)
8515 AC_SUBST(XPCOM_FROZEN_LDOPTS)
8516 AC_SUBST(XPCOM_GLUE_LDOPTS)
8517 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
8518 AC_SUBST(XPCOM_STATICRUNTIME_GLUE_LDOPTS)
8519 AC_SUBST(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS)
8521 AC_SUBST(USE_DEPENDENT_LIBS)
8523 AC_SUBST(MOZ_BUILD_ROOT)
8525 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8526 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8527 AC_SUBST(MOZ_LINKER_EXTRACT)
8529 AC_SUBST(MOZ_JSDOWNLOADS)
8530 if test -n "$MOZ_JSDOWNLOADS"; then
8531   AC_DEFINE(MOZ_JSDOWNLOADS)
8534 dnl ========================================================
8535 dnl = Mac bundle name prefix
8536 dnl ========================================================
8537 MOZ_ARG_WITH_STRING(macbundlename-prefix,
8538 [  --with-macbundlename-prefix=prefix
8539                           Prefix for MOZ_MACBUNDLE_NAME],
8540 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
8542 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
8543 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
8544   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
8547 if test "$MOZ_DEBUG"; then
8548   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
8549 else
8550   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
8552 AC_SUBST(MOZ_MACBUNDLE_NAME)
8554 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
8555 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr '[A-Z]' '[a-z]'`
8556 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
8557 if test "$MOZ_DEBUG"; then
8558   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
8561 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
8562 AC_SUBST(MOZ_MACBUNDLE_ID)
8564 dnl ========================================================
8565 dnl = Child Process Name for IPC
8566 dnl ========================================================
8567 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
8568   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
8569 else
8570   # We want to let Android unpack the file at install time, but it only does
8571   # so if the file is named libsomething.so. The lib/ path is also required
8572   # because the unpacked file will be under the lib/ subdirectory and will
8573   # need to be executed from that path.
8574   MOZ_CHILD_PROCESS_NAME="lib/libplugin-container.so"
8576 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
8578 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
8579 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
8581 # The following variables are available to branding and application
8582 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
8583 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
8584 # impacts profile location and user-visible fields.
8585 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
8586 # versions of a given application (e.g. Aurora and Firefox both use
8587 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
8588 # for application.ini's "Name" field, which controls profile location in
8589 # the absence of a "Profile" field (see below), and various system
8590 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
8591 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
8592 # Mac Bundle name, Updater, Installer), it is typically used for nightly
8593 # builds (e.g. Aurora for Firefox).
8594 # - MOZ_APP_VERSION: Defines the application version number.
8595 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
8596 # defaults to a lowercase form of MOZ_APP_BASENAME.
8597 # - MOZ_APP_PROFILE: When set, used for application.ini's
8598 # "Profile" field, which controls profile location.
8599 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
8600 # crash reporter server url.
8601 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
8602 # - MOZ_EXTENSION_MANAGER: When set, enabled extension manager.
8604 if test -z "$MOZ_APP_NAME"; then
8605    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
8608 # For extensions and langpacks, we require a max version that is compatible
8609 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
8610 # 24.0a1 and 24.0a2 aren't affected
8611 # 24.0 becomes 24.*
8612 # 24.1.1 becomes 24.*
8613 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
8614 if test -z "$IS_ALPHA"; then
8615   changequote(,)
8616   MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
8617   changequote([,])
8618 else
8619   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
8622 MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"}
8623 AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION")
8624 AC_DEFINE_UNQUOTED(MOZ_B2G_OS_NAME,"$MOZ_B2G_OS_NAME")
8626 AC_SUBST(MOZ_APP_NAME)
8627 AC_SUBST(MOZ_APP_DISPLAYNAME)
8628 AC_SUBST(MOZ_APP_BASENAME)
8629 AC_SUBST(MOZ_APP_VENDOR)
8630 AC_SUBST(MOZ_APP_PROFILE)
8631 AC_SUBST(MOZ_APP_ID)
8632 AC_SUBST(MAR_CHANNEL_ID)
8633 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
8634 AC_SUBST(MOZ_PROFILE_MIGRATOR)
8635 AC_SUBST(MOZ_EXTENSION_MANAGER)
8636 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
8637 AC_SUBST(MOZ_APP_UA_NAME)
8638 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
8639 AC_SUBST(MOZ_APP_VERSION)
8640 AC_SUBST(MOZ_APP_MAXVERSION)
8641 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
8642 AC_SUBST(FIREFOX_VERSION)
8643 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
8644 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
8645   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
8648 AC_SUBST(MOZ_APP_STATIC_INI)
8650 AC_SUBST(MOZ_PKG_SPECIAL)
8652 AC_SUBST(MOZILLA_OFFICIAL)
8654 AC_DEFINE_UNQUOTED(MOZ_TELEMETRY_DISPLAY_REV, 2)
8655 AC_SUBST(MOZ_TELEMETRY_DISPLAY_REV)
8657 if test "$MOZ_TELEMETRY_REPORTING"; then
8658     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
8660     # Enable Telemetry by default for nightly and aurora channels
8661     if test -z "$RELEASE_BUILD"; then
8662       AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
8663     fi
8666 dnl If we have any service that uploads data (and requires data submission
8667 dnl policy alert), set MOZ_DATA_REPORTING.
8668 dnl We need SUBST for build system and DEFINE for xul preprocessor.
8669 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"; then
8670   MOZ_DATA_REPORTING=1
8671   AC_DEFINE(MOZ_DATA_REPORTING)
8672   AC_SUBST(MOZ_DATA_REPORTING)
8675 dnl win32 options
8676 AC_SUBST(MOZ_BROWSE_INFO)
8677 AC_SUBST(MOZ_TOOLS_DIR)
8678 AC_SUBST(WIN32_REDIST_DIR)
8679 AC_SUBST(MAKENSISU)
8681 dnl Echo the CFLAGS to remove extra whitespace.
8682 CFLAGS=`echo \
8683     $_WARNINGS_CFLAGS \
8684     $CFLAGS`
8686 CXXFLAGS=`echo \
8687     $_WARNINGS_CXXFLAGS \
8688     $CXXFLAGS`
8690 COMPILE_CFLAGS=`echo \
8691     $_DEFINES_CFLAGS \
8692     $_DEPEND_CFLAGS \
8693     $COMPILE_CFLAGS`
8695 COMPILE_CXXFLAGS=`echo \
8696     $_DEFINES_CXXFLAGS \
8697     $_DEPEND_CFLAGS \
8698     $COMPILE_CXXFLAGS`
8700 HOST_CFLAGS=`echo \
8701     $HOST_CFLAGS \
8702     $_DEPEND_CFLAGS`
8704 HOST_CXXFLAGS=`echo \
8705     $HOST_CXXFLAGS \
8706     $_DEPEND_CFLAGS`
8708 AC_SUBST(SYSTEM_LIBXUL)
8709 AC_SUBST(MOZ_NATIVE_JPEG)
8710 AC_SUBST(MOZ_NATIVE_PNG)
8711 AC_SUBST(MOZ_NATIVE_BZ2)
8713 AC_SUBST(MOZ_JPEG_CFLAGS)
8714 AC_SUBST(MOZ_JPEG_LIBS)
8715 AC_SUBST(MOZ_BZ2_CFLAGS)
8716 AC_SUBST(MOZ_BZ2_LIBS)
8717 AC_SUBST(MOZ_PNG_CFLAGS)
8718 AC_SUBST(MOZ_PNG_LIBS)
8720 if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_NUWA_PROCESS"; then
8721     export MOZ_NUWA_PROCESS
8722     AC_DEFINE(MOZ_NUWA_PROCESS)
8724 AC_SUBST(MOZ_NUWA_PROCESS)
8726 AC_SUBST(NSPR_CFLAGS)
8727 AC_SUBST(NSPR_LIBS)
8728 AC_SUBST(MOZ_NATIVE_NSPR)
8730 AC_SUBST(NSS_CFLAGS)
8731 AC_SUBST(NSS_LIBS)
8732 AC_SUBST(MOZ_NATIVE_NSS)
8733 AC_SUBST(NSS_DISABLE_DBM)
8735 OS_CFLAGS="$CFLAGS"
8736 OS_CXXFLAGS="$CXXFLAGS"
8737 OS_CPPFLAGS="$CPPFLAGS"
8738 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
8739 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
8740 OS_LDFLAGS="$LDFLAGS"
8741 OS_LIBS="$LIBS"
8742 AC_SUBST(OS_CFLAGS)
8743 AC_SUBST(OS_CXXFLAGS)
8744 AC_SUBST(OS_CPPFLAGS)
8745 AC_SUBST(OS_COMPILE_CFLAGS)
8746 AC_SUBST(OS_COMPILE_CXXFLAGS)
8747 AC_SUBST(OS_LDFLAGS)
8748 AC_SUBST(OS_LIBS)
8749 AC_SUBST(CROSS_COMPILE)
8750 AC_SUBST(WCHAR_CFLAGS)
8752 AC_SUBST(HOST_CC)
8753 AC_SUBST(HOST_CXX)
8754 AC_SUBST(HOST_CFLAGS)
8755 AC_SUBST(HOST_CXXFLAGS)
8756 AC_SUBST(HOST_LDFLAGS)
8757 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8758 AC_SUBST(HOST_AR)
8759 AC_SUBST(HOST_AR_FLAGS)
8760 AC_SUBST(HOST_LD)
8761 AC_SUBST(HOST_RANLIB)
8762 AC_SUBST(HOST_NSPR_MDCPUCFG)
8763 AC_SUBST(HOST_BIN_SUFFIX)
8764 AC_SUBST(HOST_OS_ARCH)
8766 AC_SUBST(TARGET_CPU)
8767 AC_SUBST(TARGET_VENDOR)
8768 AC_SUBST(TARGET_OS)
8769 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8770 AC_SUBST(TARGET_MD_ARCH)
8771 AC_SUBST(TARGET_XPCOM_ABI)
8772 AC_SUBST(OS_TARGET)
8773 AC_SUBST(OS_ARCH)
8774 AC_SUBST(OS_RELEASE)
8775 AC_SUBST(OS_TEST)
8776 AC_SUBST(CPU_ARCH)
8777 AC_SUBST(INTEL_ARCHITECTURE)
8778 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
8779 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
8781 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
8783 AC_SUBST(WRAP_LDFLAGS)
8784 AC_SUBST(MKSHLIB)
8785 AC_SUBST(MKCSHLIB)
8786 AC_SUBST(MKSHLIB_FORCE_ALL)
8787 AC_SUBST(MKSHLIB_UNFORCE_ALL)
8788 AC_SUBST(DSO_CFLAGS)
8789 AC_SUBST(DSO_PIC_CFLAGS)
8790 AC_SUBST(DSO_LDOPTS)
8791 AC_SUBST(LIB_PREFIX)
8792 AC_SUBST(DLL_PREFIX)
8793 AC_SUBST(DLL_SUFFIX)
8794 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
8795 AC_SUBST(LIB_SUFFIX)
8796 AC_SUBST(OBJ_SUFFIX)
8797 AC_SUBST(BIN_SUFFIX)
8798 AC_SUBST(ASM_SUFFIX)
8799 AC_SUBST(IMPORT_LIB_SUFFIX)
8800 AC_SUBST(USE_N32)
8801 AC_SUBST(CC_VERSION)
8802 AC_SUBST(CXX_VERSION)
8803 AC_SUBST(MSMANIFEST_TOOL)
8804 AC_SUBST(NS_ENABLE_TSF)
8805 AC_SUBST(MOZ_NSS_PATCH)
8806 AC_SUBST(MOZ_APP_COMPONENT_LIBS)
8807 AC_SUBST(MOZ_APP_EXTRA_LIBS)
8809 AC_SUBST(MOZ_WAVE)
8810 AC_SUBST(MOZ_VORBIS)
8811 AC_SUBST(MOZ_TREMOR)
8812 AC_SUBST(MOZ_OPUS)
8813 AC_SUBST(MOZ_WEBM)
8814 AC_SUBST(MOZ_WMF)
8815 AC_SUBST(MOZ_FFMPEG)
8816 AC_SUBST(MOZ_FMP4)
8817 AC_SUBST(MOZ_DIRECTSHOW)
8818 AC_SUBST(MOZ_MEDIA_PLUGINS)
8819 AC_SUBST(MOZ_APPLEMEDIA)
8820 AC_SUBST(MOZ_OMX_PLUGIN)
8821 AC_SUBST(MOZ_VPX_ERROR_CONCEALMENT)
8822 AC_SUBST(MOZ_VPX)
8823 AC_SUBST(VPX_AS)
8824 AC_SUBST(VPX_ASFLAGS)
8825 AC_SUBST(VPX_DASH_C_FLAG)
8826 AC_SUBST(VPX_AS_CONVERSION)
8827 AC_SUBST(VPX_ASM_SUFFIX)
8828 AC_SUBST(VPX_X86_ASM)
8829 AC_SUBST(VPX_ARM_ASM)
8830 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
8831 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
8832 AC_SUBST(LIBJPEG_TURBO_AS)
8833 AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
8834 AC_SUBST(LIBJPEG_TURBO_X86_ASM)
8835 AC_SUBST(LIBJPEG_TURBO_X64_ASM)
8836 AC_SUBST(LIBJPEG_TURBO_ARM_ASM)
8838 AC_SUBST(MOZ_PACKAGE_JSSHELL)
8839 AC_SUBST(MOZ_FOLD_LIBS)
8841 AC_SUBST(MOZ_ENABLE_SZIP)
8842 AC_SUBST(MOZ_SZIP_FLAGS)
8844 if test "$MOZ_DEBUG"; then
8845     MOZ_EM_DEBUG=1
8847 AC_SUBST(MOZ_EM_DEBUG)
8849 if test -n "$COMPILE_ENVIRONMENT"; then
8850 AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
8852 dnl Check for missing components
8853 if test "$MOZ_X11"; then
8854     if test "$WITHOUT_X11"; then
8855         AC_MSG_ERROR([--without-x specified and MOZ_X11 still defined])
8856     fi
8857     dnl ====================================================
8858     dnl = Check if X headers exist
8859     dnl ====================================================
8860     _SAVE_CFLAGS=$CFLAGS
8861     CFLAGS="$CFLAGS $XCFLAGS"
8862     AC_TRY_COMPILE([
8863         #include <stdio.h>
8864         #include <stdlib.h>
8865         #include <X11/Xlib.h>
8866         #include <X11/Intrinsic.h>
8867         #include <X11/extensions/XShm.h>
8868     ],
8869     [
8870         Display *dpy = 0;
8871         if ((dpy = XOpenDisplay(NULL)) == NULL) {
8872             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
8873             exit(1);
8874         }
8875     ], [],
8876     [ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
8877     CFLAGS="$_SAVE_CFLAGS"
8879     if test -n "$MISSING_X"; then
8880         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
8881     fi
8883 fi # MOZ_X11
8885 fi # COMPILE_ENVIRONMENT
8887 dnl Set various defines and substitutions
8888 dnl ========================================================
8890 if test "$OS_ARCH" = "Darwin"; then
8891   AC_DEFINE(XP_UNIX)
8892 elif test "$OS_ARCH" != "WINNT"; then
8893   AC_DEFINE(XP_UNIX)
8896 if test "$MOZ_DEBUG"; then
8897     AC_DEFINE(MOZ_REFLOW_PERF)
8898     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
8901 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
8902     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
8903     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
8904     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
8905     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
8906     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
8907     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
8908     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
8909     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
8912 if test "$MOZ_DEBUG"; then
8913     A11Y_LOG=1
8915 case "$MOZ_UPDATE_CHANNEL" in
8916 aurora|beta|release|esr)
8917     ;;
8919     A11Y_LOG=1
8920     ;;
8921 esac
8922 AC_SUBST(A11Y_LOG)
8923 if test -n "$A11Y_LOG"; then
8924     AC_DEFINE(A11Y_LOG)
8927 AC_SUBST(MOZILLA_VERSION)
8929 AC_SUBST(ac_configure_args)
8931 dnl Spit out some output
8932 dnl ========================================================
8934 dnl The following defines are used by xpcom
8935 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
8936 CPP_THROW_NEW
8937 HAVE_CPP_AMBIGUITY_RESOLVING_USING
8938 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
8939 HAVE_CPP_PARTIAL_SPECIALIZATION
8940 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
8941 NEED_CPP_UNUSED_IMPLEMENTATIONS
8942 HAVE_GETPAGESIZE
8943 HAVE_ICONV
8944 HAVE_ICONV_WITH_CONST_INPUT
8945 HAVE_MBRTOWC
8946 HAVE_WCRTOMB
8947 HAVE_STATVFS64
8948 HAVE_STATVFS
8949 HAVE_STATFS64
8950 HAVE_STATFS
8951 HAVE_SYS_STATVFS_H
8952 HAVE_SYS_STATFS_H
8953 HAVE_SYS_VFS_H
8954 HAVE_SYS_MOUNT_H
8957 AC_SUBST(STLPORT_LIBS)
8959 dnl ========================================================
8960 dnl ICU Support
8961 dnl ========================================================
8963 if test "$MOZ_BUILD_APP" = "browser"; then
8964     _INTL_API=yes
8965 else
8966     # Internationalization isn't built or exposed by default in non-desktop
8967     # builds.  Bugs to enable:
8968     #
8969     #   Android:  bug 864843
8970     #   B2G:      bug 866301
8971     _INTL_API=no
8974 MOZ_CONFIG_ICU()
8976 if test -n "$MOZ_NATIVE_ICU"; then
8977     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_ICU_LIBS"
8980 if test -n "$JS_SHARED_LIBRARY"; then
8981   MOZ_JS_LIBS="$MOZ_JS_SHARED_LIBS"
8982 else
8983   MOZ_JS_LIBS="$MOZ_JS_STATIC_LIBS"
8984   AC_DEFINE(MOZ_STATIC_JS)
8986 AC_SUBST(JS_SHARED_LIBRARY)
8988 MOZ_CREATE_CONFIG_STATUS()
8990 # No need to run subconfigures when building with LIBXUL_SDK_DIR
8991 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
8992   MOZ_SUBCONFIGURE_ICU()
8993   MOZ_SUBCONFIGURE_FFI()
8996 # Hack around an Apple bug that affects the egrep that comes with OS X 10.7.
8997 # "env ARCHPREFERENCE=i386,x86_64 arch egrep" first tries to use the 32-bit
8998 # Intel part of the egrep fat binary, even on 64-bit systems, and falls back on
8999 # the 64-bit part if it's not a fat binary, as can happen with MacPorts. We
9000 # (apparently) only need this hack when egrep's "pattern" is particularly long
9001 # (as in the following code) and the first egrep on our $PATH is Apple's.  See
9002 # bug 655339.
9003 case "$host" in
9004 *-apple-darwin11*)
9005     FIXED_EGREP="env ARCHPREFERENCE=i386,x86_64 arch egrep"
9006     ;;
9008     FIXED_EGREP="egrep"
9009     ;;
9010 esac
9012 # Run jemalloc configure script
9014 if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC3" -o -n "$MOZ_REPLACE_MALLOC"; then
9015   ac_configure_args="--build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
9016   if test -n "$MOZ_REPLACE_MALLOC"; then
9017     # When using replace_malloc, we always want memalign and valloc exported from jemalloc.
9018     ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
9019     ac_configure_args="$ac_configure_args ac_cv_func_valloc=yes"
9020   fi
9021   if test -n "$MOZ_JEMALLOC3"; then
9022     case "${OS_ARCH}" in
9023       WINNT|Darwin)
9024         # We want jemalloc functions to be kept hidden on both Mac and Windows
9025         # See memory/build/mozmemory_wrap.h for details.
9026         ac_configure_args="$ac_configure_args --without-export"
9027         ;;
9028     esac
9029   elif test "${OS_ARCH}" = Darwin; then
9030     # When building as a replace-malloc lib, disabling the zone allocator
9031     # forces to use pthread_atfork.
9032     ac_configure_args="$ac_configure_args --disable-zone-allocator"
9033   fi
9034   _MANGLE="malloc posix_memalign aligned_alloc calloc realloc free memalign valloc malloc_usable_size"
9035   JEMALLOC_WRAPPER=
9036   if test -z "$MOZ_REPLACE_MALLOC"; then
9037     case "$OS_ARCH" in
9038       Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
9039         MANGLE=$_MANGLE
9040         ;;
9041     esac
9042   elif test -z "$MOZ_JEMALLOC3"; then
9043     MANGLE=$_MANGLE
9044     JEMALLOC_WRAPPER=replace_
9045   fi
9046   if test -n "$MANGLE"; then
9047     MANGLED=
9048     if test -n "$_WRAP_MALLOC" -a -z "$JEMALLOC_WRAPPER"; then
9049       JEMALLOC_WRAPPER=__wrap_
9050     fi
9051     for mangle in ${MANGLE}; do
9052       if test -n "$MANGLED"; then
9053         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle,$MANGLED"
9054       else
9055         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle"
9056       fi
9057     done
9058     ac_configure_args="$ac_configure_args --with-mangling=$MANGLED"
9059   fi
9060   unset CONFIG_FILES
9061   if test -z "$MOZ_TLS"; then
9062     ac_configure_args="$ac_configure_args --disable-tls"
9063   fi
9064   EXTRA_CFLAGS="$CFLAGS"
9065   for var in AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS EXTRA_CFLAGS LDFLAGS; do
9066     ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
9067   done
9068   if test "$CROSS_COMPILE"; then
9069     ac_configure_args="$ac_configure_args je_cv_static_page_shift=12"
9070   fi
9071   _save_cache_file="$cache_file"
9072   cache_file=$_objdir/memory/jemalloc/src/config.cache
9074   if ! test -e memory/jemalloc; then
9075     mkdir -p memory/jemalloc
9076   fi
9078   AC_OUTPUT_SUBDIRS(memory/jemalloc/src)
9079   cache_file="$_save_cache_file"
9080   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9083 # Run freetype configure script
9085 if test "$MOZ_TREE_FREETYPE"; then
9086    export CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS -std=c99"
9087    export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS"
9088    export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS"
9089    export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS"
9090    # Spaces in the *_CFLAGS and *_LIBS variables are intentionally placed
9091    # to force freetype to use our settings rather than autodetecting
9092    export LIBPNG_CFLAGS="$MOZ_PNG_CFLAGS "
9093    export LIBPNG_LIBS="$MOZ_PNG_LIBS "
9094    export ZLIB_CFLAGS="$MOZ_ZLIB_CFLAGS "
9095    export ZLIB_LIBS="$MOZ_ZLIB_LIBS "
9096    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
9097    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes --with-zlib=yes --without-bzip2 --with-png=yes --without-harfbuzz"
9099    if ! test -e modules; then
9100      mkdir modules
9101    fi
9103    AC_OUTPUT_SUBDIRS(modules/freetype2)
9106 if test -z "$direct_nspr_config"; then
9107     dnl ========================================================
9108     dnl = Setup a nice relatively clean build environment for
9109     dnl = sub-configures.
9110     dnl ========================================================
9111     CC="$_SUBDIR_CC"
9112     CXX="$_SUBDIR_CXX"
9113     CFLAGS="$_SUBDIR_CFLAGS"
9114     CPPFLAGS="$_SUBDIR_CPPFLAGS"
9115     CXXFLAGS="$_SUBDIR_CXXFLAGS"
9116     LDFLAGS="$_SUBDIR_LDFLAGS"
9117     HOST_CC="$_SUBDIR_HOST_CC"
9118     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9119     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9120     RC=
9123 unset MAKEFILES
9124 unset CONFIG_FILES
9126 # Run all configure scripts specified by a subconfigure
9127 if test -n "$_subconfigure_subdir"; then
9128   _save_ac_configure_args="$ac_configure_args"
9129   ac_configure_args="$_subconfigure_config_args"
9130   AC_OUTPUT_SUBDIRS("$_subconfigure_subdir")
9131   ac_configure_args="$_save_ac_configure_args"
9134 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9135 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9137 export WRAP_LDFLAGS
9139 if test -n "$_WRAP_MALLOC"; then
9140     # Avoid doubling wrap malloc arguments
9141     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
9144 if test -z "$MOZ_NATIVE_NSPR"; then
9145     ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
9146     if test -z "$MOZ_DEBUG"; then
9147         ac_configure_args="$ac_configure_args --disable-debug"
9148     else
9149         ac_configure_args="$ac_configure_args --enable-debug"
9150     fi
9151     if test "$MOZ_OPTIMIZE" = "1"; then
9152         ac_configure_args="$ac_configure_args --enable-optimize"
9153     elif test -z "$MOZ_OPTIMIZE"; then
9154         ac_configure_args="$ac_configure_args --disable-optimize"
9155     fi
9156     if test -n "$HAVE_64BIT_OS"; then
9157         ac_configure_args="$ac_configure_args --enable-64bit"
9158     fi
9159     if test -n "$USE_ARM_KUSER"; then
9160         ac_configure_args="$ac_configure_args --with-arm-kuser"
9161     fi
9162     # A configure script generated by autoconf 2.68 does not allow the cached
9163     # values of "precious" variables such as CFLAGS and LDFLAGS to differ from
9164     # the values passed to the configure script. Since we modify CFLAGS and
9165     # LDFLAGS before passing them to NSPR's configure script, we cannot share
9166     # config.cache with NSPR. As a result, we cannot pass AS, CC, CXX, etc. to
9167     # NSPR via a shared config.cache file and must pass them to NSPR on the
9168     # configure command line.
9169     for var in AS CC CXX CPP LD AR RANLIB STRIP; do
9170         ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
9171     done
9172     # A configure script generated by autoconf 2.68 warns if --host is
9173     # specified but --build isn't. So we always pass --build to NSPR's
9174     # configure script.
9175     ac_configure_args="$ac_configure_args --build=$build"
9176     ac_configure_args="$ac_configure_args $NSPR_CONFIGURE_ARGS"
9178     # Save these, so we can mess with them for the subconfigure ..
9179     _SAVE_CFLAGS="$CFLAGS"
9180     _SAVE_CPPFLAGS="$CPPFLAGS"
9181     _SAVE_LDFLAGS="$LDFLAGS"
9183     if test -n "$MOZ_LINKER" -a "$ac_cv_func_dladdr" = no ; then
9184       # dladdr is supported by the new linker, even when the system linker doesn't
9185       # support it. Trick nspr into using dladdr when it's not supported.
9186       export CPPFLAGS="-include $_topsrcdir/mozglue/linker/dladdr.h $CPPFLAGS"
9187     fi
9188     export LDFLAGS="$LDFLAGS $NSPR_LDFLAGS"
9189     export CFLAGS="$CFLAGS $MOZ_FRAMEPTR_FLAGS"
9191     # Use a separate cache file for NSPR since it uses autoconf 2.68.
9192     _save_cache_file="$cache_file"
9193     cache_file=$_objdir/nsprpub/config.cache
9195     AC_OUTPUT_SUBDIRS(nsprpub)
9197     # .. and restore them
9198     cache_file="$_save_cache_file"
9199     CFLAGS="$_SAVE_CFLAGS"
9200     CPPFLAGS="$_SAVE_CPPFLAGS"
9201     LDFLAGS="$_SAVE_LDFLAGS"
9203     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9206 dnl ========================================================
9207 dnl = Setup a nice relatively clean build environment for
9208 dnl = sub-configures.
9209 dnl ========================================================
9210 CC="$_SUBDIR_CC"
9211 CXX="$_SUBDIR_CXX"
9212 CFLAGS="$_SUBDIR_CFLAGS"
9213 CPPFLAGS="$_SUBDIR_CPPFLAGS"
9214 CXXFLAGS="$_SUBDIR_CXXFLAGS"
9215 LDFLAGS="$_SUBDIR_LDFLAGS"
9216 HOST_CC="$_SUBDIR_HOST_CC"
9217 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9218 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9221 if test -n "$ENABLE_CLANG_PLUGIN"; then
9222     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9223     AC_OUTPUT_SUBDIRS(build/clang-plugin)
9227 # Run the SpiderMonkey 'configure' script.
9228 dist=$MOZ_BUILD_ROOT/dist
9229 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9230 ac_configure_args="$ac_configure_args --enable-threadsafe"
9232 if test "$_INTL_API" = no; then
9233     ac_configure_args="$ac_configure_args --without-intl-api"
9236 if test "$BUILD_CTYPES"; then
9237     # Build js-ctypes on the platforms we can.
9238     ac_configure_args="$ac_configure_args --enable-ctypes"
9240 if test -z "$JS_SHARED_LIBRARY" ; then
9241     ac_configure_args="$ac_configure_args --disable-shared-js"
9242     if test -n "$MOZ_DISABLE_EXPORT_JS"; then
9243         ac_configure_args="$ac_configure_args --disable-export-js"
9244     fi
9246 if test -z "$JSGC_USE_EXACT_ROOTING" ; then
9247     ac_configure_args="$ac_configure_args --disable-exact-rooting"
9249 if test -z "$JSGC_GENERATIONAL" ; then
9250     ac_configure_args="$ac_configure_args --disable-gcgenerational"
9252 if test -z "$MOZ_NATIVE_NSPR"; then
9253     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
9254     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
9256 ac_configure_args="$ac_configure_args --prefix=$dist"
9257 if test "$MOZ_MEMORY"; then
9258    ac_configure_args="$ac_configure_args --enable-jemalloc"
9260 if test -n "$MOZ_GLUE_LDFLAGS"; then
9261    export MOZ_GLUE_LDFLAGS
9263 if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
9264    export MOZ_GLUE_PROGRAM_LDFLAGS
9266 if test -n "$ZLIB_IN_MOZGLUE"; then
9267    MOZ_ZLIB_LIBS=
9269 export MOZ_NATIVE_ZLIB
9270 export MOZ_ZLIB_CFLAGS
9271 export MOZ_ZLIB_LIBS
9272 export MOZ_APP_NAME
9273 export DONT_POPULATE_VIRTUALENV=1
9274 export PYTHON
9275 export MOZILLA_CENTRAL_PATH=$_topsrcdir
9276 export STLPORT_CPPFLAGS
9277 export STLPORT_LDFLAGS
9278 export STLPORT_LIBS
9279 export JS_STANDALONE=no
9280 export MOZ_LINKER
9281 export ZLIB_IN_MOZGLUE
9283 if ! test -e js; then
9284     mkdir js
9287 AC_OUTPUT_SUBDIRS(js/src)
9288 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9290 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR
9292 export WRITE_MOZINFO=1
9293 dnl we need to run config.status after js/src subconfigure because we're
9294 dnl traversing its moz.build and we need its config.status for that.
9295 dnl However, writing our own config.status needs to happen before
9296 dnl subconfigures because the setup surrounding subconfigures alters
9297 dnl many AC_SUBSTed variables.
9298 MOZ_RUN_CONFIG_STATUS()
9299 unset WRITE_MOZINFO