Bug 1025824 - Fix mHwcLayerMap handling r=sushil
[gecko.git] / configure.in
blob1ab79d050e8c3a9b58f4e3a6b214957c6ddb40d2
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_MAJOR_VERSION=`echo ${CC_VERSION} | cut -c 1-2`
469         _CC_MINOR_VERSION=`echo ${CC_VERSION} | cut -c 3-4`
470         _MSC_VER=${CC_VERSION}
472         _CXX_MAJOR_VERSION=`echo ${CXX_VERSION} | cut -c 1-2`
474         if test "$_CC_MAJOR_VERSION" != "$_CXX_MAJOR_VERSION"; then
475             AC_MSG_ERROR([The major versions of \$CC and \$CXX do not match.])
476         fi
478         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
479         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
481         if test "$_CC_MAJOR_VERSION" = "16"; then
482             _CC_SUITE=10
483             MSVS_VERSION=2010
484         elif test "$_CC_MAJOR_VERSION" = "17"; then
485             _CC_SUITE=11
486             MSVS_VERSION=2012
487         elif test "$_CC_MAJOR_VERSION" = "18"; then
488             _CC_SUITE=12
489             MSVS_VERSION=2013
490         else
491             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
492         fi
493         AC_SUBST(MSVS_VERSION)
495         # Disable SEH on clang-cl because it doesn't implement them yet.
496         if test -z "$CLANG_CL"; then
497             AC_DEFINE(HAVE_SEH_EXCEPTIONS)
498         fi
500         if test -n "$WIN32_REDIST_DIR"; then
501           if test ! -d "$WIN32_REDIST_DIR"; then
502             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
503           fi
504           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
505         fi
507         dnl Confirm we have the pri tools on win8 builds
508         if test -n "$MOZ_METRO"; then
509           AC_MSG_CHECKING([for makepri])
510           AC_CHECK_PROGS(MAKEPRI, makepri, "")
511           if test -z "MAKEPRI" ; then
512               AC_MSG_ERROR([makepri.exe is required for generating metro browser install components. It should be in the Win8 SDK.])
513           fi
514           AC_SUBST(MAKEPRI)
515         fi
517         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
518         dnl not something else like "magnetic tape manipulation utility".
519         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
520         if test -z "$MSMT_TOOL"; then
521           AC_MSG_ERROR([Microsoft (R) Manifest Tool must be in your \$PATH.])
522         fi
524         changequote(,)
525         _MSMT_VER_FILTER='s|.*[^!-~]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*|\1|p'
526         changequote([,])
527         MSMANIFEST_TOOL_VERSION=`echo ${MSMT_TOOL}|sed -ne "$_MSMT_VER_FILTER"`
528         if test -z "$MSMANIFEST_TOOL_VERSION"; then
529           AC_MSG_WARN([Unknown version of the Microsoft (R) Manifest Tool.])
530         fi
532         MSMANIFEST_TOOL=1
533         unset MSMT_TOOL
535         # Check linker version
536         _LD_FULL_VERSION=`"${LD}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
537         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
538         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
539             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
540         fi
542         INCREMENTAL_LINKER=1
544         # Set midl environment
545         case "$target" in
546         i*86-*)
547             MIDL_FLAGS="${MIDL_FLAGS} -env win32"
548             ;;
549         x86_64-*)
550             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
551             ;;
552         esac
554         unset _MSVC_VER_FILTER
556         AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
557             [
558                 AC_LANG_SAVE
559                 AC_LANG_CPLUSPLUS
560                 _SAVE_CXXFLAGS="$CXXFLAGS"
561                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
562                 AC_TRY_COMPILE([#include <exception>],
563                             [std::_Throw(std::exception()); return 0;],
564                             ac_cv_have_std__Throw="yes",
565                             ac_cv_have_std__Throw="no")
566                 CXXFLAGS="$_SAVE_CXXFLAGS"
567                 AC_LANG_RESTORE
568             ])
570         if test "$ac_cv_have_std__Throw" = "yes"; then
571             AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
572                            ac_cv_have_dllimport_exception_bug,
573                 [
574                     AC_LANG_SAVE
575                     AC_LANG_CPLUSPLUS
576                     _SAVE_CXXFLAGS="$CXXFLAGS"
577                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
578                     AC_TRY_LINK([#include <vector>],
579                                 [std::vector<int> v; return v.at(1);],
580                                 ac_cv_have_dllimport_exception_bug="no",
581                                 ac_cv_have_dllimport_exception_bug="yes")
582                     CXXFLAGS="$_SAVE_CXXFLAGS"
583                     AC_LANG_RESTORE
584                 ])
585             if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
586                 WRAP_STL_INCLUDES=1
587                 MOZ_MSVC_STL_WRAP__Throw=1
588                 AC_DEFINE(MOZ_MSVC_STL_WRAP__Throw)
589             fi
590         else
591             AC_CACHE_CHECK(for overridable _RAISE,
592                            ac_cv_have__RAISE,
593                 [
594                     AC_LANG_SAVE
595                     AC_LANG_CPLUSPLUS
596                     _SAVE_CXXFLAGS="$CXXFLAGS"
597                     CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
598                     AC_TRY_COMPILE([#include <xstddef>
599                                     #undef _RAISE
600                                     #define _RAISE(x) externallyDefinedFunction((x).what())
601                                     #include <vector>
602                                    ],
603                                    [std::vector<int> v; return v.at(1);],
604                                    ac_cv_have__RAISE="no",
605                                    ac_cv_have__RAISE="yes")
606                     CXXFLAGS="$_SAVE_CXXFLAGS"
607                     AC_LANG_RESTORE
608                 ])
609             if test "$ac_cv_have__RAISE" = "yes"; then
610                 WRAP_STL_INCLUDES=1
611                 MOZ_MSVC_STL_WRAP__RAISE=1
612                 AC_DEFINE(MOZ_MSVC_STL_WRAP__RAISE)
613             else
614                 AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
615             fi
616         fi
618         if test "$WRAP_STL_INCLUDES" = "1"; then
619             STL_FLAGS='-I$(DIST)/stl_wrappers'
620         fi
621         CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
622         CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
623     elif test -z "$CLANG_CC"; then
624         # Check w32api version
625         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
626         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
627         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
628         AC_TRY_COMPILE([#include <w32api.h>],
629             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
630                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
631                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
632                 #error "test failed."
633             #endif
634             , [ res=yes ], [ res=no ])
635         AC_MSG_RESULT([$res])
636         if test "$res" != "yes"; then
637             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
638         fi
639         # Check windres version
640         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
641         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
642         AC_MSG_RESULT([$_WINDRES_VERSION])
643         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
644         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
645         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
646         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
647         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
648         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
649         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
650                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
651                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
652                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
653                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
654                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
655         then
656             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
657         fi
659         AC_CHECK_PROGS(MIDL, $target-widl widl)
660         if test -n "$MIDL"; then
661             case "$target" in
662             i*86-*)
663                 MIDL_FLAGS="$MIDL_FLAGS --win32 -m32"
664                 ;;
665             x86_64-*)
666                 MIDL_FLAGS="$MIDL_FLAGS --win64 -m64"
667                 ;;
668             esac
669         fi
671         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
672         # causing problems with local implementations with the same name.
673         AC_DEFINE(STRSAFE_NO_DEPRECATE)
675         MOZ_WINSDK_MAXVER=0x06020000
676     fi # !GNU_CC
678     # If MSVC or clang
679     if test "$GCC" != "yes" -o -n "$CLANG_CC" ; then
680         MOZ_FIND_WINSDK_VERSION
681     fi
683     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
684     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
685     # Require OS features provided by IE 6.0 SP2 (XP SP2)
686     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
688     # If the maximum version supported by this SDK is lower than the target
689     # version, error out
690     AC_MSG_CHECKING([for Windows SDK being recent enough])
691     if $PERL -e "exit(0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER)"; then
692         AC_MSG_RESULT("yes")
693     else
694         AC_MSG_RESULT("no")
695         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.])
696     fi
698     AC_DEFINE_UNQUOTED(MOZ_WINSDK_TARGETVER,0x$MOZ_WINSDK_TARGETVER)
699     # Definitions matching sdkddkver.h
700     AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
701     AC_DEFINE_UNQUOTED(MOZ_WINSDK_MAXVER,$MOZ_WINSDK_MAXVER)
702     AC_SUBST(MOZ_WINSDK_MAXVER)
703     ;;
704 esac
706 AC_PROG_CPP
707 AC_PROG_CXXCPP
709 if test -n "$_WIN32_MSVC"; then
710     SKIP_PATH_CHECKS=1
711     SKIP_COMPILER_CHECKS=1
712     SKIP_LIBRARY_CHECKS=1
714     # Since we're skipping compiler and library checks, hard-code
715     # some facts here.
716     AC_DEFINE(HAVE_IO_H)
717     AC_DEFINE(HAVE_SETBUF)
718     AC_DEFINE(HAVE_ISATTY)
721 fi # COMPILE_ENVIRONMENT
723 AC_SUBST(MIDL_FLAGS)
724 AC_SUBST(_MSC_VER)
726 AC_SUBST(GNU_AS)
727 AC_SUBST(GNU_LD)
728 AC_SUBST(GNU_CC)
729 AC_SUBST(GNU_CXX)
730 AC_SUBST(INTEL_CC)
731 AC_SUBST(INTEL_CXX)
733 AC_SUBST(STL_FLAGS)
734 AC_SUBST(WRAP_STL_INCLUDES)
735 AC_SUBST(MOZ_MSVC_STL_WRAP__Throw)
736 AC_SUBST(MOZ_MSVC_STL_WRAP__RAISE)
738 dnl ========================================================
739 dnl Checks for programs.
740 dnl ========================================================
741 AC_PROG_INSTALL
742 AC_PROG_LN_S
744 if test -z "$TINDERBOX_SKIP_PERL_VERSION_CHECK"; then
745 AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
746 _perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
747 _perl_res=$?
748 AC_MSG_RESULT([$_perl_version])
750 if test "$_perl_res" != 0; then
751     AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
755 AC_MSG_CHECKING([for full perl installation])
756 _perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
757 _perl_res=$?
758 if test "$_perl_res" != 0; then
759     AC_MSG_RESULT([no])
760     AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
761 else
762     AC_MSG_RESULT([yes])
765 if test -z "$COMPILE_ENVIRONMENT"; then
766     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
768 AC_SUBST(NSINSTALL_BIN)
770 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
771 MOZ_PATH_PROG(AUTOCONF, autoconf, :)
772 MOZ_PATH_PROGS(UNZIP, unzip)
773 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
774     AC_MSG_ERROR([unzip not found in \$PATH])
776 MOZ_PATH_PROGS(ZIP, zip)
777 if test -z "$ZIP" -o "$ZIP" = ":"; then
778     AC_MSG_ERROR([zip not found in \$PATH])
780 MOZ_PATH_PROG(XARGS, xargs)
781 if test -z "$XARGS" -o "$XARGS" = ":"; then
782     AC_MSG_ERROR([xargs not found in \$PATH .])
785 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
786 AC_SUBST(RPMBUILD)
788 if test "$COMPILE_ENVIRONMENT"; then
790 dnl ========================================================
791 dnl = Mac OS X toolchain support
792 dnl ========================================================
794 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
795 dnl that a universal binary is being produced and MOZ_CAN_RUN_PROGRAMS
796 dnl when we can run target binaries.
797 AC_SUBST(UNIVERSAL_BINARY)
798 AC_SUBST(MOZ_CAN_RUN_PROGRAMS)
800 MOZ_ARG_WITH_STRING(unify-dist,
801 [  --with-unify-dist=dir   Location of the dist directory to unify with at packaging time (Mac OS X universal build only)],
802     UNIFY_DIST=$withval)
803 if test -n "$UNIVERSAL_BINARY"; then
804     if test -z "$UNIFY_DIST"; then
805         AC_MSG_ERROR([You need to provide the --with-unify-dist=dir argument when performing a universal build])
806     fi
807     case "$UNIFY_DIST" in
808     /*)
809         ;;
810     *)
811         UNIFY_DIST="${MOZ_BUILD_ROOT}/${UNIFY_DIST}"
812         ;;
813     esac
815 AC_SUBST(UNIFY_DIST)
817 dnl ========================================================
818 dnl Check for MacOS deployment target version
819 dnl ========================================================
821 MOZ_ARG_ENABLE_STRING(macos-target,
822                       [  --enable-macos-target=VER (default=10.6)
823                           Set the minimum MacOS version needed at runtime],
824                       [_MACOSX_DEPLOYMENT_TARGET=$enableval])
826 case "$target" in
827 *-darwin*)
828     if test -n "$_MACOSX_DEPLOYMENT_TARGET" ; then
829         dnl Use the specified value
830         export MACOSX_DEPLOYMENT_TARGET=$_MACOSX_DEPLOYMENT_TARGET
831     else
832         dnl No value specified on the command line or in the environment,
833         dnl use architecture minimum.
834         export MACOSX_DEPLOYMENT_TARGET=10.6
835     fi
836     ;;
837 esac
839 AC_SUBST(MACOSX_DEPLOYMENT_TARGET)
841 dnl ========================================================
842 dnl = Mac OS X SDK support
843 dnl ========================================================
844 MACOS_SDK_DIR=
845 MOZ_ARG_WITH_STRING(macos-sdk,
846 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
847     MACOS_SDK_DIR=$withval)
849 MACOS_PRIVATE_FRAMEWORKS_DIR_DEFAULTED=
850 MOZ_ARG_WITH_STRING(macos-private-frameworks,
851 [  --with-macos-private-frameworks=dir    Location of private frameworks to use (Mac OS X only)],
852     MACOS_PRIVATE_FRAMEWORKS_DIR=$withval,
853     MACOS_PRIVATE_FRAMEWORKS_DIR=/System/Library/PrivateFrameworks
854     MACOS_PRIVATE_FRAMEWORKS_DEFAULTED=1)
856 if test -z "${MACOS_PRIVATE_FRAMEWORKS_DEFAULTED}"; then
857   if test -z "$CROSS_COMPILE"; then
858     AC_MSG_WARN([You should only be using --with-macos-private-frameworks when cross-compiling.])
859   fi
860   if test ! -d "$MACOS_PRIVATE_FRAMEWORKS_DIR"; then
861     AC_MSG_ERROR([PrivateFrameworks directory not found.])
862   fi
865 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
866 AC_SUBST(MACOS_SDK_DIR)
867 AC_SUBST(MACOS_PRIVATE_FRAMEWORKS_DIR)
869 if test "$MACOS_SDK_DIR"; then
870   dnl Sync this section with the ones in NSPR and NSS.
871   dnl Changes to the cross environment here need to be accounted for in
872   dnl the libIDL checks (below) and xpidl build.
874   if test ! -d "$MACOS_SDK_DIR"; then
875     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
876 specify a valid SDK.  SDKs are installed when the optional cross-development
877 tools are selected during the Xcode/Developer Tools installation.])
878   fi
880   CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
881   CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
883   dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
884   CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
885   CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
887   AC_LANG_SAVE
888   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
889   AC_LANG_CPLUSPLUS
890   AC_TRY_COMPILE([#include <new>],[],
891    result=yes,
892    result=no)
893   AC_LANG_RESTORE
894   AC_MSG_RESULT($result)
896   if test "$result" = "no" ; then
897     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
898   fi
901 fi # COMPILE_ENVIRONMENT
903 if test -n "$MAKE"; then
904   if test `echo $MAKE | grep -c make.py` != 1; then
905      NOT_PYMAKE=$MAKE
906   fi
909 case "$host_os" in
910 mingw*)
911     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE make gmake, :)
912     ;;
914     MOZ_PATH_PROGS(GMAKE, $GMAKE $NOT_PYMAKE gmake make, :)
915     ;;
916 esac
917 if test "$GMAKE" = ":"; then
918    AC_MSG_ERROR([GNU make not found])
920 AC_SUBST(GMAKE)
922 if test -z "$MAKE"; then
923   MAKE=$GMAKE
926 if test "$COMPILE_ENVIRONMENT"; then
928 AC_PATH_XTRA
930 XCFLAGS="$X_CFLAGS"
932 fi # COMPILE_ENVIRONMENT
934 dnl ========================================================
935 dnl set the defaults first
936 dnl ========================================================
937 AS_BIN=$AS
938 AR_LIST='$(AR) t'
939 AR_EXTRACT='$(AR) x'
940 AR_DELETE='$(AR) d'
941 AS='$(CC)'
942 AS_DASH_C_FLAG='-c'
943 DLL_PREFIX=lib
944 LIB_PREFIX=lib
945 DLL_SUFFIX=.so
946 OBJ_SUFFIX=o
947 LIB_SUFFIX=a
948 ASM_SUFFIX=s
949 IMPORT_LIB_SUFFIX=
950 TARGET_MD_ARCH=unix
951 DIRENT_INO=d_ino
952 MOZ_USER_DIR=".mozilla"
954 MOZ_JPEG_CFLAGS=
955 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)'
956 MOZ_BZ2_CFLAGS=
957 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
958 MOZ_PNG_CFLAGS="-I$_objdir/dist/include" # needed for freetype compilation
959 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
961 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
962 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
963 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
964 XPCOM_FROZEN_LDOPTS='$(call EXPAND_LIBNAME_PATH,xul mozalloc,$(LIBXUL_DIST)/bin)'
965 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS)'
966 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
967 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
969 # These are specially defined on Windows only
970 case "$target" in
971 *-mingw*)
972   XPCOM_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
973   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime.$(LIB_SUFFIX)'
974   ;;
976   XPCOM_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_GLUE_LDOPTS
977   XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_STANDALONE_GLUE_LDOPTS
978   ;;
979 esac
981 MOZ_FS_LAYOUT=unix
983 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
985 USE_DEPENDENT_LIBS=1
987 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
989 if test -n "$CROSS_COMPILE"; then
990     OS_TARGET="${target_os}"
991     OS_ARCH=`echo $target_os | sed -e 's|/|_|g'`
992     OS_RELEASE=
993     case "${target_os}" in
994         linux*)       OS_ARCH=Linux OS_TARGET=Linux ;;
995         kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU/kFreeBSD ;;
996         gnu*)         OS_ARCH=GNU ;;
997         solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
998         mingw*)       OS_ARCH=WINNT OS_TARGET=WINNT ;;
999         darwin*)      OS_ARCH=Darwin OS_TARGET=Darwin ;;
1000         dragonfly*)   OS_ARCH=DragonFly OS_TARGET=DragonFly ;;
1001         freebsd*)     OS_ARCH=FreeBSD OS_TARGET=FreeBSD ;;
1002         netbsd*)      OS_ARCH=NetBSD OS_TARGET=NetBSD ;;
1003         openbsd*)     OS_ARCH=OpenBSD OS_TARGET=OpenBSD ;;
1004     esac
1005     case "${target}" in
1006         *-android*|*-linuxandroid*) OS_ARCH=Linux OS_TARGET=Android ;;
1007     esac
1008 else
1009     OS_TARGET=`uname -s`
1010     OS_ARCH=`uname -s | sed -e 's|/|_|g'`
1011     OS_RELEASE=`uname -r`
1014 # Before this used `uname -m` when not cross compiling
1015 # but that breaks when you have a 64 bit kernel with a 32 bit userland.
1016 OS_TEST="${target_cpu}"
1018 HOST_OS_ARCH=`echo $host_os | sed -e 's|/|_|g'`
1020 #######################################################################
1021 # Master "Core Components" macros for getting the OS target           #
1022 #######################################################################
1025 # If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no
1026 # cross-compilation.
1030 # Define and override various archtecture-specific variables, including
1031 # HOST_OS_ARCH
1032 # OS_ARCH
1033 # OS_TEST
1034 # OS_TARGET
1035 # OS_RELEASE
1036 # OS_MINOR_RELEASE
1039 case "$HOST_OS_ARCH" in
1040 mingw*)
1041     HOST_OS_ARCH=WINNT
1042     ;;
1043 darwin*)
1044     HOST_OS_ARCH=Darwin
1045     ;;
1046 linux*)
1047     HOST_OS_ARCH=Linux
1048     ;;
1049 kfreebsd*-gnu)
1050     HOST_OS_ARCH=GNU_kFreeBSD
1051     ;;
1052 gnu*)
1053     HOST_OS_ARCH=GNU
1054     ;;
1055 dragonfly*)
1056     HOST_OS_ARCH=DragonFly
1057     ;;
1058 freebsd*)
1059     HOST_OS_ARCH=FreeBSD
1060     ;;
1061 netbsd*)
1062     HOST_OS_ARCH=NetBSD
1063     ;;
1064 openbsd*)
1065     HOST_OS_ARCH=OpenBSD
1066     ;;
1067 solaris*)
1068     HOST_OS_ARCH=SunOS
1069     SOLARIS_SUNPRO_CC=
1070     SOLARIS_SUNPRO_CXX=
1071     if test -z "$GNU_CC"; then
1072         if test "`$CC -V 2>&1 | egrep -c 'Sun.*C '`" != "0"; then
1073             SOLARIS_SUNPRO_CC=1
1074        fi
1075     fi
1077     if test -z "$GNU_CXX"; then
1078        if test "`$CXX -V 2>&1 | egrep -c 'Sun.*C\+\+ '`" != "0"; then
1079            SOLARIS_SUNPRO_CXX=1
1080        fi
1081     fi
1082     AC_SUBST(SOLARIS_SUNPRO_CC)
1083     AC_SUBST(SOLARIS_SUNPRO_CXX)
1084     ;;
1085 esac
1087 case "$OS_ARCH" in
1088 WINNT)
1089     if test -z "$CROSS_COMPILE" ; then
1090         OS_TEST=`uname -p`
1091     fi
1092     ;;
1093 Windows_NT)
1095 # If uname -s returns "Windows_NT", we assume that we are using
1096 # the uname.exe in MKS toolkit.
1098 # The -r option of MKS uname only returns the major version number.
1099 # So we need to use its -v option to get the minor version number.
1100 # Moreover, it doesn't have the -p option, so we need to use uname -m.
1102     OS_ARCH=WINNT
1103     OS_TARGET=WINNT
1104     OS_MINOR_RELEASE=`uname -v`
1105     if test "$OS_MINOR_RELEASE" = "00"; then
1106         OS_MINOR_RELEASE=0
1107     fi
1108     OS_RELEASE="${OS_RELEASE}.${OS_MINOR_RELEASE}"
1109     ;;
1110 MINGW*_NT*)
1112 # If uname -s returns MINGW32_NT-5.1, we assume that we are using
1113 # the uname.exe in the MSYS tools.
1115     OS_RELEASE=`expr $OS_ARCH : '.*NT-\(.*\)'`
1116     OS_ARCH=WINNT
1117     OS_TARGET=WINNT
1118     ;;
1119 AIX)
1120     OS_RELEASE=`uname -v`.`uname -r`
1121     OS_TEST=${target_cpu}
1122     ;;
1123 Darwin)
1124     case "${target_cpu}" in
1125     powerpc*)
1126         OS_TEST=ppc
1127         ;;
1128     i*86*)
1129         OS_TEST=i386
1130         ;;
1131     x86_64)
1132         OS_TEST=x86_64
1133         ;;
1134     *)
1135         if test -z "$CROSS_COMPILE" ; then
1136             OS_TEST=`uname -p`
1137         fi
1138         ;;
1139     esac
1140     ;;
1141 esac
1143 # Only set CPU_ARCH if we recognize the value of OS_TEST
1145 case "$OS_TEST" in
1146 *86 | i86pc)
1147     CPU_ARCH=x86
1148     ;;
1150 powerpc64 | ppc64 | powerpc64le | ppc64le)
1151     CPU_ARCH=ppc64
1152     ;;
1154 powerpc | ppc | rs6000)
1155     CPU_ARCH=ppc
1156     ;;
1158 Alpha | alpha | ALPHA)
1159     CPU_ARCH=Alpha
1160     ;;
1162 s390)
1163     CPU_ARCH=s390
1164     ;;
1166 s390x)
1167     CPU_ARCH=s390x
1168     ;;
1170 hppa* | parisc)
1171     CPU_ARCH=hppa
1172     ;;
1174 sun4u | sparc*)
1175     CPU_ARCH=sparc
1176     ;;
1178 x86_64 | ia64)
1179     CPU_ARCH="$OS_TEST"
1180     ;;
1182 arm*)
1183     CPU_ARCH=arm
1184     ;;
1186 mips|mipsel)
1187     CPU_ARCH="mips"
1188     ;;
1190 aarch64*)
1191     CPU_ARCH=aarch64
1192     ;;
1193 esac
1195 if test -z "$OS_TARGET"; then
1196     OS_TARGET=$OS_ARCH
1198 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
1200 dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
1201 dnl ===============================================================
1202 INTEL_ARCHITECTURE=
1203 case "$OS_TEST" in
1204     x86_64|i?86)
1205       INTEL_ARCHITECTURE=1
1206 esac
1208 dnl Configure platform-specific CPU architecture compiler options.
1209 dnl ==============================================================
1210 MOZ_ARCH_OPTS
1212 dnl =================================================================
1213 dnl Set up and test static assertion macros used to avoid AC_TRY_RUN,
1214 dnl which is bad when cross compiling.
1215 dnl =================================================================
1216 if test "$COMPILE_ENVIRONMENT"; then
1217 configure_static_assert_macros='
1218 #define CONFIGURE_STATIC_ASSERT(condition) CONFIGURE_STATIC_ASSERT_IMPL(condition, __LINE__)
1219 #define CONFIGURE_STATIC_ASSERT_IMPL(condition, line) CONFIGURE_STATIC_ASSERT_IMPL2(condition, line)
1220 #define CONFIGURE_STATIC_ASSERT_IMPL2(condition, line) typedef int static_assert_line_##line[(condition) ? 1 : -1]
1223 dnl test that the macros actually work:
1224 AC_MSG_CHECKING(that static assertion macros used in autoconf tests work)
1225 AC_CACHE_VAL(ac_cv_static_assertion_macros_work,
1226  [AC_LANG_SAVE
1227   AC_LANG_C
1228   ac_cv_static_assertion_macros_work="yes"
1229   AC_TRY_COMPILE([$configure_static_assert_macros],
1230                  [CONFIGURE_STATIC_ASSERT(1)],
1231                  ,
1232                  ac_cv_static_assertion_macros_work="no")
1233   AC_TRY_COMPILE([$configure_static_assert_macros],
1234                  [CONFIGURE_STATIC_ASSERT(0)],
1235                  ac_cv_static_assertion_macros_work="no",
1236                  )
1237   AC_LANG_CPLUSPLUS
1238   AC_TRY_COMPILE([$configure_static_assert_macros],
1239                  [CONFIGURE_STATIC_ASSERT(1)],
1240                  ,
1241                  ac_cv_static_assertion_macros_work="no")
1242   AC_TRY_COMPILE([$configure_static_assert_macros],
1243                  [CONFIGURE_STATIC_ASSERT(0)],
1244                  ac_cv_static_assertion_macros_work="no",
1245                  )
1246   AC_LANG_RESTORE
1247  ])
1248 AC_MSG_RESULT("$ac_cv_static_assertion_macros_work")
1249 if test "$ac_cv_static_assertion_macros_work" = "no"; then
1250     AC_MSG_ERROR([Compiler cannot compile macros used in autoconf tests.])
1252 fi # COMPILE_ENVIRONMENT
1254 dnl ========================================================
1255 dnl Android libstdc++, placed here so it can use MOZ_ARCH
1256 dnl computed above.
1257 dnl ========================================================
1259 MOZ_ANDROID_STLPORT
1261 dnl ========================================================
1262 dnl Suppress Clang Argument Warnings
1263 dnl ========================================================
1264 if test -n "$CLANG_CC"; then
1265     _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
1266     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
1268 if test -n "$CLANG_CXX"; then
1269     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
1272 dnl ========================================================
1273 dnl = Use Address Sanitizer
1274 dnl ========================================================
1275 MOZ_ARG_ENABLE_BOOL(address-sanitizer,
1276 [  --enable-address-sanitizer       Enable Address Sanitizer (default=no)],
1277     MOZ_ASAN=1,
1278     MOZ_ASAN= )
1279 if test -n "$MOZ_ASAN"; then
1280     MOZ_LLVM_HACKS=1
1281     AC_DEFINE(MOZ_ASAN)
1282     MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
1284 AC_SUBST(MOZ_ASAN)
1285 AC_SUBST(LLVM_SYMBOLIZER)
1287 dnl ========================================================
1288 dnl = Enable hacks required for LLVM instrumentations
1289 dnl ========================================================
1290 MOZ_ARG_ENABLE_BOOL(llvm-hacks,
1291 [  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)],
1292     MOZ_LLVM_HACKS=1,
1293     MOZ_LLVM_HACKS= )
1294 if test -n "$MOZ_LLVM_HACKS"; then
1295     MOZ_NO_WLZDEFS=1
1296     MOZ_CFLAGS_NSS=1
1298 AC_SUBST(MOZ_NO_WLZDEFS)
1299 AC_SUBST(MOZ_CFLAGS_NSS)
1301 dnl ========================================================
1302 dnl GNU specific defaults
1303 dnl ========================================================
1304 if test "$GNU_CC"; then
1305     MMX_FLAGS="-mmmx"
1306     SSE_FLAGS="-msse"
1307     SSE2_FLAGS="-msse2"
1308     # Per bug 719659 comment 2, some of the headers on ancient build machines
1309     # may require gnu89 inline semantics.  But otherwise, we use C99.
1310     # But on OS X we just use C99 plus GNU extensions, in order to fix
1311     # bug 917526.
1312     CFLAGS="$CFLAGS -std=gnu99"
1313     if test "${OS_ARCH}" != Darwin; then
1314         CFLAGS="$CFLAGS -fgnu89-inline"
1315     fi
1316     # FIXME: Let us build with strict aliasing. bug 414641.
1317     CFLAGS="$CFLAGS -fno-strict-aliasing"
1318     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@'
1319     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@'
1320     WARNINGS_AS_ERRORS='-Werror'
1321     DSO_CFLAGS=''
1322     DSO_PIC_CFLAGS='-fPIC'
1323     ASFLAGS="$ASFLAGS -fPIC"
1324     AC_MSG_CHECKING([for --noexecstack option to as])
1325     _SAVE_CFLAGS=$CFLAGS
1326     CFLAGS="$CFLAGS -Wa,--noexecstack"
1327     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
1328                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
1329                      AC_MSG_RESULT([no]))
1330     CFLAGS=$_SAVE_CFLAGS
1331     AC_MSG_CHECKING([for -z noexecstack option to ld])
1332     _SAVE_LDFLAGS=$LDFLAGS
1333     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
1334     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
1335                   AC_MSG_RESULT([no])
1336                   LDFLAGS=$_SAVE_LDFLAGS)
1338     AC_MSG_CHECKING([for -z text option to ld])
1339     _SAVE_LDFLAGS=$LDFLAGS
1340     LDFLAGS="$LDFLAGS -Wl,-z,text"
1341     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1342                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,text"],
1343                   AC_MSG_RESULT([no])
1344                   LDFLAGS=$_SAVE_LDFLAGS)
1346     AC_MSG_CHECKING([for --build-id option to ld])
1347     _SAVE_LDFLAGS=$LDFLAGS
1348     LDFLAGS="$LDFLAGS -Wl,--build-id"
1349     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1350                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,--build-id"],
1351                   AC_MSG_RESULT([no])
1352                   LDFLAGS=$_SAVE_LDFLAGS)
1354     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
1355     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
1356     _SAVE_LDFLAGS=$LDFLAGS
1357     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
1358     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
1359                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
1360                   AC_MSG_RESULT([no]))
1361     LDFLAGS=$_SAVE_LDFLAGS
1363     # Check for -mssse3 on $CC
1364     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
1365     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
1366     _SAVE_CFLAGS=$CFLAGS
1367     CFLAGS="$CFLAGS -mssse3"
1368     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
1369                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
1370                      AC_MSG_RESULT([no]))
1371     CFLAGS=$_SAVE_CFLAGS
1373     # Check for -msse4.1 on $CC
1374     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
1375     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
1376     _SAVE_CFLAGS=$CFLAGS
1377     CFLAGS="$CFLAGS -msse4.1"
1378     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
1379                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
1380                      AC_MSG_RESULT([no]))
1381     CFLAGS=$_SAVE_CFLAGS
1383     case "${CPU_ARCH}" in
1384     x86 | x86_64)
1385       AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
1386       AC_TRY_COMPILE([],
1387                      [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
1388                      result="yes", result="no")
1389       AC_MSG_RESULT("$result")
1390       if test "$result" = "yes"; then
1391           HAVE_X86_AVX2=1
1392           AC_DEFINE(HAVE_X86_AVX2)
1393           AC_SUBST(HAVE_X86_AVX2)
1394       fi
1395     esac
1397     DSO_LDOPTS='-shared'
1398     if test "$GCC_USE_GNU_LD"; then
1399         # Some tools like ASan use a runtime library that is only
1400         # linked against executables, so we must allow undefined
1401         # symbols for shared objects in some cases.
1402         if test -z "$MOZ_NO_WLZDEFS"; then
1403             # Don't allow undefined symbols in libraries
1404             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
1406             # BSDs need `environ' exposed for posix_spawn (bug 753046)
1407             case "$OS_TARGET" in
1408             DragonFly|FreeBSD|NetBSD|OpenBSD)
1409                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
1410                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
1411                 else
1412                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
1413                 fi
1414                 ;;
1415             esac
1416         fi
1417     fi
1419     # Turn on GNU-specific warnings:
1420     # -Wall - turn on a lot of warnings
1421     # -Wpointer-arith - good to have
1422     # -Wdeclaration-after-statement - MSVC doesn't like these
1423     # -Werror=return-type - catches missing returns, zero false positives
1424     # -Werror=int-to-pointer-cast - catches cast to pointer from integer of different size
1425     # -Wtype-limits - catches overflow bugs, few false positives
1426     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1427     # -Wsign-compare - catches comparison of signed and unsigned types
1428     #
1429     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Wdeclaration-after-statement"
1430     MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
1431     MOZ_C_SUPPORTS_WARNING(-W, error=int-to-pointer-cast, ac_c_has_werror_int_to_pointer_cast)
1432     MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
1433     MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
1434     MOZ_C_SUPPORTS_WARNING(-W, sign-compare, ac_c_has_sign_compare)
1436     # Turn off the following warnings that -Wall turns on:
1437     # -Wno-unused - lots of violations in third-party code
1438     #
1439     _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-unused"
1441     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
1442        # Don't use -Wcast-align with ICC or clang
1443        case "$CPU_ARCH" in
1444            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1445            hppa | ia64 | sparc | arm)
1446            ;;
1447            *)
1448         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
1449            ;;
1450        esac
1451     fi
1453     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
1454     _USE_CPP_INCLUDE_FLAG=1
1455     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
1457 elif test "$SOLARIS_SUNPRO_CC"; then
1458     DSO_CFLAGS=''
1459     if test "$CPU_ARCH" = "sparc"; then
1460         # for Sun Studio on Solaris/SPARC
1461         DSO_PIC_CFLAGS='-xcode=pic32'
1462     else
1463         DSO_PIC_CFLAGS='-KPIC'
1464     fi
1465     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1466 else
1467     MKSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
1468     MKCSHLIB='$(LD) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
1470     DSO_LDOPTS='-shared'
1471     if test "$GNU_LD"; then
1472         # Don't allow undefined symbols in libraries
1473         DSO_LDOPTS="$DSO_LDOPTS -z defs"
1474     fi
1476     DSO_CFLAGS=''
1477     DSO_PIC_CFLAGS='-KPIC'
1478     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
1481 if test "$GNU_CXX"; then
1482     # FIXME: Let us build with strict aliasing. bug 414641.
1483     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
1485     # Turn on GNU-specific warnings:
1486     # -Wall - turn on a lot of warnings
1487     # -Wpointer-arith - good to have
1488     # -Woverloaded-virtual - ???
1489     # -Werror=return-type - catches missing returns, zero false positives
1490     # -Werror=int-to-pointer-cast - catches cast to pointer from integer of different size
1491     # -Wtype-limits - catches overflow bugs, few false positives
1492     # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
1493     # -Wsign-compare - catches comparison of signed and unsigned types
1494     #
1495     _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
1496     MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
1497     MOZ_CXX_SUPPORTS_WARNING(-W, error=int-to-pointer-cast, ac_cxx_has_werror_int_to_pointer_cast)
1498     MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
1499     MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
1500     MOZ_CXX_SUPPORTS_WARNING(-W, sign-compare, ac_cxx_has_sign_compare)
1502     # Turn off the following warnings that -Wall turns on:
1503     # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
1504     # -Wno-inline-new-delete - we inline 'new' and 'delete' in mozalloc
1505     #   for performance reasons, and because GCC and clang accept it (though
1506     #   clang warns about it).
1507     #
1508     MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
1509     MOZ_CXX_SUPPORTS_WARNING(-Wno-, inline-new-delete, ac_cxx_has_wno_inline_new_delete)
1511     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
1512        # Don't use -Wcast-align with ICC or clang
1513        case "$CPU_ARCH" in
1514            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
1515            hppa | ia64 | sparc | arm)
1516            ;;
1517            *)
1518         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
1519            ;;
1520        esac
1521     fi
1523     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
1524     _USE_CPP_INCLUDE_FLAG=1
1526     # Recent clang and gcc support C++11 deleted functions without warnings if
1527     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
1528     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
1529     # unused.  But clang's warning can be disabled, so when compiling with clang
1530     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
1531     # deleted function syntax.
1532     if test "$CLANG_CXX"; then
1533         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
1534         MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
1535     fi
1537 else
1538     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
1541 dnl gcc can come with its own linker so it is better to use the pass-thru calls
1542 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
1543 dnl files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker to
1544 dnl normal behavior.
1545 dnl ========================================================
1546 MKSHLIB_FORCE_ALL=
1547 MKSHLIB_UNFORCE_ALL=
1549 if test "$COMPILE_ENVIRONMENT"; then
1550 if test "$GNU_CC"; then
1551   AC_MSG_CHECKING(whether ld has archive extraction flags)
1552   AC_CACHE_VAL(ac_cv_mkshlib_force_and_unforce,
1553    [_SAVE_LDFLAGS=$LDFLAGS; _SAVE_LIBS=$LIBS
1554     ac_cv_mkshlib_force_and_unforce="no"
1555     exec 3<&0 <<LOOP_INPUT
1556   force="-Wl,--whole-archive";   unforce="-Wl,--no-whole-archive"
1557   force="-Wl,-z -Wl,allextract"; unforce="-Wl,-z -Wl,defaultextract"
1558   force="-Wl,-all";              unforce="-Wl,-none"
1559 LOOP_INPUT
1560     while read line
1561     do
1562       eval $line
1563       LDFLAGS=$force
1564       LIBS=$unforce
1565       AC_TRY_LINK(,, ac_cv_mkshlib_force_and_unforce=$line; break)
1566     done
1567     exec 0<&3 3<&-
1568     LDFLAGS=$_SAVE_LDFLAGS; LIBS=$_SAVE_LIBS
1569    ])
1570   if test "$ac_cv_mkshlib_force_and_unforce" = "no"; then
1571     AC_MSG_RESULT(no)
1572   else
1573     AC_MSG_RESULT(yes)
1574     eval $ac_cv_mkshlib_force_and_unforce
1575     MKSHLIB_FORCE_ALL=$force
1576     MKSHLIB_UNFORCE_ALL=$unforce
1577   fi
1578 fi # GNU_CC
1579 fi # COMPILE_ENVIRONMENT
1581 dnl ========================================================
1582 dnl Checking for 64-bit OS
1583 dnl ========================================================
1584 if test "$COMPILE_ENVIRONMENT"; then
1585 AC_LANG_SAVE
1586 AC_LANG_C
1587 AC_MSG_CHECKING(for 64-bit OS)
1588 AC_TRY_COMPILE([$configure_static_assert_macros],
1589                [CONFIGURE_STATIC_ASSERT(sizeof(void*) == 8)],
1590                result="yes", result="no")
1591 AC_MSG_RESULT("$result")
1592 if test "$result" = "yes"; then
1593     AC_DEFINE(HAVE_64BIT_OS)
1594     HAVE_64BIT_OS=1
1596 AC_SUBST(HAVE_64BIT_OS)
1597 AC_LANG_RESTORE
1598 fi # COMPILE_ENVIRONMENT
1600 dnl ========================================================
1601 dnl = Use profiling compile flags
1602 dnl ========================================================
1603 MOZ_ARG_ENABLE_BOOL(profiling,
1604 [  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1605     MOZ_PROFILING=1,
1606     MOZ_PROFILING= )
1608 dnl ========================================================
1609 dnl = Turn on systrace for android/b2g.
1610 dnl ========================================================
1611 MOZ_ARG_ENABLE_BOOL(systrace,
1612 [  --enable-systrace       Set compile flags necessary for using sampling profilers (e.g. shark, perf)],
1613     MOZ_USE_SYSTRACE=1,
1614     MOZ_USE_SYSTRACE= )
1615 if test -n "$MOZ_USE_SYSTRACE"; then
1616     AC_DEFINE(MOZ_USE_SYSTRACE)
1619 # For profiling builds keep the symbol information
1620 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
1621     case "$OS_TARGET" in
1622     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
1623         STRIP_FLAGS="--strip-debug"
1624         ;;
1625     esac
1628 dnl ========================================================
1629 dnl = Use Valgrind
1630 dnl ========================================================
1631 MOZ_ARG_ENABLE_BOOL(valgrind,
1632 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
1633     MOZ_VALGRIND=1,
1634     MOZ_VALGRIND= )
1635 if test -n "$MOZ_VALGRIND"; then
1636     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
1637         AC_MSG_ERROR(
1638             [--enable-valgrind specified but Valgrind is not installed]))
1639     AC_DEFINE(MOZ_VALGRIND)
1641 AC_SUBST(MOZ_VALGRIND)
1643 dnl ========================================================
1644 dnl jprof
1645 dnl ========================================================
1646 MOZ_ARG_ENABLE_BOOL(jprof,
1647 [  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.],
1648     MOZ_JPROF=1,
1649     MOZ_JPROF= )
1650 if test -n "$MOZ_JPROF"; then
1651     MOZ_PROFILING=1
1652     AC_DEFINE(MOZ_JPROF)
1655 dnl ========================================================
1656 dnl SPS Profiler
1657 dnl ========================================================
1658 MOZ_ENABLE_PROFILER_SPS=1
1660 case "${OS_TARGET}" in
1661 Android)
1662     case "${CPU_ARCH}" in
1663     x86 | arm) ;;
1664     *)
1665         MOZ_ENABLE_PROFILER_SPS=
1666     esac
1667     ;;
1668 Linux)
1669     case "${CPU_ARCH}" in
1670     x86 | x86_64) ;;
1671     *)
1672         MOZ_ENABLE_PROFILER_SPS=
1673     esac
1674     ;;
1675 WINNT|Darwin) ;;
1677     MOZ_ENABLE_PROFILER_SPS=
1678     ;;
1679 esac
1681 if test -n "$MOZ_ENABLE_PROFILER_SPS"; then
1682     AC_DEFINE(MOZ_ENABLE_PROFILER_SPS)
1685 dnl ========================================================
1686 dnl shark
1687 dnl ========================================================
1688 MOZ_ARG_ENABLE_BOOL(shark,
1689 [  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.],
1690     MOZ_SHARK=1,
1691     MOZ_SHARK= )
1692 if test -n "$MOZ_SHARK"; then
1693     MOZ_PROFILING=1
1694     AC_DEFINE(MOZ_SHARK)
1697 dnl ========================================================
1698 dnl instruments
1699 dnl ========================================================
1700 MOZ_ARG_ENABLE_BOOL(instruments,
1701 [  --enable-instruments    Enable instruments remote profiling. Implies --enable-profiling.],
1702     MOZ_INSTRUMENTS=1,
1703     MOZ_INSTRUMENTS= )
1704 if test -n "$MOZ_INSTRUMENTS"; then
1705     MOZ_PROFILING=1
1706     AC_DEFINE(MOZ_INSTRUMENTS)
1709 dnl ========================================================
1710 dnl callgrind
1711 dnl ========================================================
1712 MOZ_ARG_ENABLE_BOOL(callgrind,
1713 [  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.],
1714     MOZ_CALLGRIND=1,
1715     MOZ_CALLGRIND= )
1716 if test -n "$MOZ_CALLGRIND"; then
1717     MOZ_PROFILING=1
1718     AC_DEFINE(MOZ_CALLGRIND)
1721 dnl ========================================================
1722 dnl vtune
1723 dnl ========================================================
1724 MOZ_ARG_ENABLE_BOOL(vtune,
1725 [  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.],
1726     MOZ_VTUNE=1,
1727     MOZ_VTUNE= )
1728 if test -n "$MOZ_VTUNE"; then
1729     MOZ_PROFILING=1
1730     AC_DEFINE(MOZ_VTUNE)
1733 dnl ========================================================
1734 dnl Profiling
1735 dnl ========================================================
1736 if test -n "$MOZ_PROFILING"; then
1737     AC_DEFINE(MOZ_PROFILING)
1740 dnl ========================================================
1741 dnl System overrides of the defaults for host
1742 dnl ========================================================
1743 case "$host" in
1744 *mingw*)
1745     if test -n "$_WIN32_MSVC"; then
1746         HOST_AR=lib
1747         HOST_AR_FLAGS='-NOLOGO -OUT:$@'
1748         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo"
1749         HOST_RANLIB='echo ranlib'
1750     else
1751         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
1752     fi
1753     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
1754     HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
1755     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1756     HOST_BIN_SUFFIX=.exe
1757     case "$host" in
1758     *mingw*)
1759         PERL="/bin/sh ${_topsrcdir}/build/msys-perl-wrapper"
1760         ;;
1761     esac
1763     case "${host_cpu}" in
1764     i*86)
1765         if test -n "$_WIN32_MSVC"; then
1766             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
1767         fi
1768         ;;
1769     x86_64)
1770         if test -n "$_WIN32_MSVC"; then
1771             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
1772         fi
1773         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
1774         ;;
1775     esac
1776     ;;
1778 *-darwin*)
1779     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
1780     HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1781     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1782     ;;
1784 *-linux*|*-kfreebsd*-gnu|*-gnu*)
1785     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1786     HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
1787     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
1788     ;;
1791     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
1792     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
1793     ;;
1794 esac
1796 dnl Check for using a custom <inttypes.h> implementation
1797 dnl ========================================================
1798 AC_MSG_CHECKING(for custom <inttypes.h> implementation)
1799 if test "$MOZ_CUSTOM_INTTYPES_H"; then
1800   AC_DEFINE_UNQUOTED(MOZ_CUSTOM_INTTYPES_H, "$MOZ_CUSTOM_INTTYPES_H")
1801   AC_MSG_RESULT(using $MOZ_CUSTOM_INTTYPES_H)
1802 else
1803   AC_MSG_RESULT(none specified)
1806 dnl Get mozilla version from central milestone file
1807 MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
1808 MOZILLA_UAVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -uaversion`
1809 MOZILLA_SYMBOLVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -symbolversion`
1811 dnl Get version of various core apps from the version files.
1812 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
1814 if test -z "$FIREFOX_VERSION"; then
1815     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
1818 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
1819 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
1820 AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
1821 AC_SUBST(MOZILLA_SYMBOLVERSION)
1823 MOZ_DOING_LTO(lto_is_enabled)
1825 dnl ========================================================
1826 dnl System overrides of the defaults for target
1827 dnl ========================================================
1829 case "$target" in
1830 *-aix*)
1831     AC_DEFINE(AIX)
1832     if test ! "$GNU_CC"; then
1833         if test ! "$HAVE_64BIT_OS"; then
1834             # Compiling with Visual Age C++ object model compat is the
1835             # default. To compile with object model ibm, add
1836             # AIX_OBJMODEL=ibm to .mozconfig.
1837             if test "$AIX_OBJMODEL" = "ibm"; then
1838                 CXXFLAGS="$CXXFLAGS -qobjmodel=ibm"
1839             else
1840                 AIX_OBJMODEL=compat
1841             fi
1842         else
1843             AIX_OBJMODEL=compat
1844         fi
1845         AC_SUBST(AIX_OBJMODEL)
1846         DSO_LDOPTS='-qmkshrobj=1'
1847         DSO_CFLAGS='-qflag=w:w'
1848         DSO_PIC_CFLAGS=
1849         LDFLAGS="$LDFLAGS -Wl,-brtl -blibpath:/usr/lib:/lib"
1850         MOZ_FIX_LINK_PATHS=
1851         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
1852         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
1853         if test "$COMPILE_ENVIRONMENT"; then
1854             AC_LANG_SAVE
1855             AC_LANG_CPLUSPLUS
1856             AC_MSG_CHECKING([for IBM XLC/C++ compiler version >= 9.0.0.7])
1857             AC_TRY_COMPILE([],
1858                 [#if (__IBMCPP__ < 900)
1859                  #error "Bad compiler"
1860                  #endif],
1861                 _BAD_COMPILER=,_BAD_COMPILER=1)
1862             if test -n "$_BAD_COMPILER"; then
1863                 AC_MSG_RESULT([no])
1864                 AC_MSG_ERROR([IBM XLC/C++ 9.0.0.7 or higher is required to build.])
1865             else
1866                 AC_MSG_RESULT([yes])
1867             fi
1868             AC_LANG_RESTORE
1869             TARGET_COMPILER_ABI="ibmc"
1870             CC_VERSION=`lslpp -Lcq vac.C 2>/dev/null | awk -F: '{ print $3 }'`
1871             CXX_VERSION=`lslpp -Lcq vacpp.cmp.core 2>/dev/null | awk -F: '{ print $3 }'`
1872         fi
1873     fi
1874     case "${target_os}" in
1875     aix4.1*)
1876         DLL_SUFFIX='_shr.a'
1877         ;;
1878     esac
1879     if test "$COMPILE_ENVIRONMENT"; then
1880         MOZ_CHECK_HEADERS(sys/inttypes.h)
1881     fi
1882     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1883     ;;
1885 *-darwin*)
1886     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1887     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
1888     MOZ_OPTIMIZE_FLAGS="-O3"
1889     # Statically disable jemalloc on 10.5 and 32-bit 10.6.  See bug 702250.
1890     if test "$HAVE_64BIT_OS"; then
1891         MOZ_MEMORY=1
1892     fi
1893     DLL_SUFFIX=".dylib"
1894     DSO_LDOPTS=''
1895     STRIP_FLAGS="$STRIP_FLAGS -x -S"
1896     # Check whether we're targeting OS X or iOS
1897     AC_CACHE_CHECK(for iOS target,
1898                    ac_cv_ios_target,
1899                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
1900 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
1901 #error not iOS
1902 #endif],
1903                                    [],
1904                                    ac_cv_ios_target="yes",
1905                                    ac_cv_ios_target="no")])
1906     if test "$ac_cv_ios_target" = "yes"; then
1907         AC_DEFINE(XP_IOS)
1908         AC_DEFINE(XP_DARWIN)
1909         _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
1910     else
1911         AC_DEFINE(XP_MACOSX)
1912         AC_DEFINE(XP_DARWIN)
1913         _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
1914         # The ExceptionHandling framework is needed for Objective-C exception
1915         # logging code in nsObjCExceptions.h. Currently we only use that in debug
1916         # builds.
1917         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
1918     fi
1919     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
1921     if test "x$lto_is_enabled" = "xyes"; then
1922         echo "Skipping -dead_strip because lto is enabled."
1923     dnl DTrace and -dead_strip don't interact well. See bug 403132.
1924     dnl ===================================================================
1925     elif test "x$enable_dtrace" = "xyes"; then
1926         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
1927     else
1928         dnl check for the presence of the -dead_strip linker flag
1929         AC_MSG_CHECKING([for -dead_strip option to ld])
1930         _SAVE_LDFLAGS=$LDFLAGS
1931         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
1932         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
1933         if test -n "$_HAVE_DEAD_STRIP" ; then
1934             AC_MSG_RESULT([yes])
1935             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
1936         else
1937             AC_MSG_RESULT([no])
1938         fi
1940         LDFLAGS=$_SAVE_LDFLAGS
1941     fi
1943     dnl With newer linkers we need to pass -allow_heap_execute because of
1944     dnl Microsoft Silverlight (5.1.10411.0 at least).
1945     AC_MSG_CHECKING([for -allow_heap_execute option to ld])
1946     _SAVE_LDFLAGS=$LDFLAGS
1947     LDFLAGS="$LDFLAGS -Wl,-allow_heap_execute"
1948     AC_TRY_LINK(,[return 0;],_HAVE_ALLOW_HEAP_EXECUTE=1,
1949                 _HAVE_ALLOW_HEAP_EXECUTE=)
1950     if test -n "$_HAVE_ALLOW_HEAP_EXECUTE" ; then
1951         AC_MSG_RESULT([yes])
1952         MOZ_ALLOW_HEAP_EXECUTE_FLAGS="-Wl,-allow_heap_execute"
1953     else
1954         AC_MSG_RESULT([no])
1955     fi
1956     LDFLAGS=$_SAVE_LDFLAGS
1958     MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(LIBXUL_DIST)/bin'
1959     ;;
1961 ia64*-hpux*)
1962     DLL_SUFFIX=".so"
1963     if test ! "$GNU_CC"; then
1964        DSO_LDOPTS='-b'
1965        DSO_CFLAGS=""
1966        DSO_PIC_CFLAGS=
1967        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@'
1968        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
1969        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
1970     else
1971        DSO_LDOPTS='-b -E'
1972        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1973        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
1974     fi
1975     MOZ_FIX_LINK_PATHS=
1976     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1977     AC_DEFINE(_LARGEFILE64_SOURCE)
1978     ;;
1980 *-hpux*)
1981     DLL_SUFFIX=".sl"
1982     if test ! "$GNU_CC"; then
1983         DSO_LDOPTS='-b -Wl,+s'
1984         DSO_CFLAGS=""
1985         DSO_PIC_CFLAGS="+Z"
1986         MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -o $@'
1987         MKCSHLIB='$(LD) -b +s -L$(LIBXUL_DIST)/bin -o $@'
1988         CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
1989     else
1990         DSO_LDOPTS='-b -E +s'
1991         MKSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
1992         MKCSHLIB='$(LD) $(DSO_LDOPTS) -L$(LIBXUL_DIST)/bin -L$(LIBXUL_DIST)/lib -o $@'
1993     fi
1994     MOZ_POST_PROGRAM_COMMAND='chatr +s enable'
1995     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
1996     ;;
1998 *-android*|*-linuxandroid*)
1999     AC_DEFINE(NO_PW_GECOS)
2000     no_x=yes
2001     if test -n "$gonkdir"; then
2002         _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
2003         _PLATFORM_HAVE_RIL=1
2004         MOZ_B2G_FM=1
2005         MOZ_SYNTH_PICO=1
2006     else
2007         _PLATFORM_DEFAULT_TOOLKIT=cairo-android
2008         MOZ_LINKER=1
2009     fi
2010     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2012     MOZ_GFX_OPTIMIZE_MOBILE=1
2013     MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions"
2014     ;;
2016 *-*linux*)
2017     # Note: both GNU_CC and INTEL_CC are set when using Intel's C compiler.
2018     # Similarly for GNU_CXX and INTEL_CXX.
2019     if test "$INTEL_CC" -o "$INTEL_CXX"; then
2020         # -Os has been broken on Intel's C/C++ compilers for quite a
2021         # while; Intel recommends against using it.
2022         MOZ_OPTIMIZE_FLAGS="-O2"
2023     elif test "$GNU_CC" -o "$GNU_CXX"; then
2024         case $GCC_VERSION in
2025         4.5.*)
2026             # -Os is broken on gcc 4.5.x we need to tweak it to get good results.
2027             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
2028         esac
2029         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
2030         MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK"
2031     fi
2033     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
2035     MOZ_MEMORY=1
2037     case "${target_cpu}" in
2038     alpha*)
2039         CFLAGS="$CFLAGS -mieee"
2040         CXXFLAGS="$CXXFLAGS -mieee"
2041     ;;
2042     esac
2044     if test -z "$MC"; then
2045         MC=mc.exe
2046     fi
2047     ;;
2048 *-mingw*)
2049     DSO_CFLAGS=
2050     DSO_PIC_CFLAGS=
2051     DLL_SUFFIX=.dll
2052     RC=rc.exe
2053     MC=mc.exe
2054     # certain versions of cygwin's makedepend barf on the
2055     # #include <string> vs -I./dist/include/string issue so don't use it
2056     XPCOM_FROZEN_LDOPTS='$(call EXPAND_LIBNAME_PATH,xul mozalloc,$(LIBXUL_DIST)/lib)'
2057     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
2058         CC="$CC -mwindows"
2059         CXX="$CXX -mwindows"
2060         CPP="$CPP -mwindows"
2061         CFLAGS="$CFLAGS -mms-bitfields"
2062         CXXFLAGS="$CXXFLAGS -mms-bitfields"
2063         DSO_LDOPTS='-shared'
2064         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
2065         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
2066         RC='$(WINDRES)'
2067         # Use static libgcc and libstdc++
2068         LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
2069         NSPR_LDFLAGS="$NSPR_LDFLAGS -static-libgcc"
2070         # Use temp file for windres (bug 213281)
2071         RCFLAGS='-O coff --use-temp-file'
2072         # mingw doesn't require kernel32, user32, and advapi32 explicitly
2073         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32 -lnetapi32"
2074         MOZ_FIX_LINK_PATHS=
2075         DLL_PREFIX=
2076         IMPORT_LIB_SUFFIX=dll.a
2078         # We use mix of both POSIX and Win32 printf format across the tree, so format
2079         # warnings are useless on mingw.
2080         MOZ_C_SUPPORTS_WARNING(-Wno-, format, ac_c_has_wno_format)
2081         MOZ_CXX_SUPPORTS_WARNING(-Wno-, format, ac_cxx_has_wno_format)
2082     else
2083         TARGET_COMPILER_ABI=msvc
2084         HOST_CC='$(CC)'
2085         HOST_CXX='$(CXX)'
2086         HOST_LD='$(LD)'
2087         if test "$AS_BIN"; then
2088             AS="$(basename "$AS_BIN")"
2089         fi
2090         AR='lib'
2091         AR_FLAGS='-NOLOGO -OUT:$@'
2092         AR_EXTRACT=
2093         RANLIB='echo not_ranlib'
2094         STRIP='echo not_strip'
2095         PKG_SKIP_STRIP=1
2096         XARGS=xargs
2097         ZIP=zip
2098         UNZIP=unzip
2099         DOXYGEN=:
2100         ASM_SUFFIX=asm
2101         OBJ_SUFFIX=obj
2102         LIB_SUFFIX=lib
2103         DLL_PREFIX=
2104         LIB_PREFIX=
2105         IMPORT_LIB_SUFFIX=lib
2106         MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2107         MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
2108         MKSHLIB_FORCE_ALL=
2109         MKSHLIB_UNFORCE_ALL=
2110         DSO_LDOPTS=-SUBSYSTEM:WINDOWS
2111         _USE_CPP_INCLUDE_FLAG=1
2112         _DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2113         _DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
2114         CFLAGS="$CFLAGS -W3 -Gy"
2115         CXXFLAGS="$CXXFLAGS -W3 -Gy"
2116         if test "$_CC_SUITE" -ge "12"; then
2117             dnl VS2013+ requires -FS when parallel building by make -jN.
2118             dnl If nothing, compiler sometimes causes C1041 error.
2119             dnl
2120             dnl Visual Studio 2013 supports -Gw flags
2121             dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
2122             CFLAGS="$CFLAGS -FS -Gw"
2123             CXXFLAGS="$CXXFLAGS -FS -Gw"
2124         fi
2125         # khuey says we can safely ignore MSVC warning C4251
2126         # MSVC warning C4244 (implicit type conversion may lose data) warns
2127         # and requires workarounds for perfectly valid code.  Also, GCC/clang
2128         # don't warn about it by default. So for consistency/sanity, we turn
2129         # it off on MSVC, too.
2130         # MSVC warning C4345 warns of newly conformant behavior as of VS2003.
2131         # MSVC warning C4351 warns of newly conformant behavior as of VS2005.
2132         # MSVC warning C4482 warns when an enum value is refered specifing the
2133         # name of the enum itself.  This behavior is allowed in C++11, and the
2134         # warning has been removed in VS2012.
2135         # MSVC warning C4800 warns when a value is implicitly cast to bool,
2136         # because this also forces narrowing to a single byte, which can be a
2137         # perf hit.  But this matters so little in practice (and often we want
2138         # that behavior) that it's better to turn it off.
2139         # MSVC warning C4819 warns some UTF-8 characters (e.g. copyright sign)
2140         # on non-Western system locales even if it is in a comment.
2141         CFLAGS="$CFLAGS -wd4244 -wd4819"
2142         CXXFLAGS="$CXXFLAGS -wd4251 -wd4244 -wd4345 -wd4351 -wd4482 -wd4800 -wd4819"
2143         # make 'foo == bar;' error out
2144         CFLAGS="$CFLAGS -we4553"
2145         CXXFLAGS="$CXXFLAGS -we4553"
2146         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib netapi32.lib"
2147         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
2148         WARNINGS_AS_ERRORS='-WX'
2149         MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
2150         MOZ_FIX_LINK_PATHS=
2151         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
2152         # Disable these flags on clang-cl since it doesn't ignore unknown arguments by default, and
2153         # autoconf insists on passing $LDFLAGS to the compiler.
2154         if test -z "$CLANG_CL"; then
2155             LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
2156         fi
2157         if test -z "$DEVELOPER_OPTIONS"; then
2158             LDFLAGS="$LDFLAGS -RELEASE"
2159         fi
2160         dnl For profile-guided optimization
2161         PROFILE_GEN_CFLAGS="-GL"
2162         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
2163         dnl XXX: PGO builds can fail with warnings treated as errors,
2164         dnl specifically "no profile data available" appears to be
2165         dnl treated as an error sometimes. This might be a consequence
2166         dnl of using WARNINGS_AS_ERRORS in some modules, combined
2167         dnl with the linker doing most of the work in the whole-program
2168         dnl optimization/PGO case. I think it's probably a compiler bug,
2169         dnl but we work around it here.
2170         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
2171         dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
2172         dnl Probably also a compiler bug, but what can you do?
2173         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE"
2174         LDFLAGS="$LDFLAGS -DYNAMICBASE"
2175         dnl Minimum reqiurement of Gecko is VS2010 or later which supports
2176         dnl both SSSE3 and SSE4.1.
2177         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
2178         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
2179         MOZ_MEMORY=1
2180     fi
2181     AC_DEFINE(HAVE_SNPRINTF)
2182     AC_DEFINE(_WINDOWS)
2183     AC_DEFINE(WIN32)
2184     AC_DEFINE(XP_WIN)
2185     AC_DEFINE(XP_WIN32)
2186     AC_DEFINE(HW_THREADS)
2187     AC_DEFINE(STDC_HEADERS)
2188     AC_DEFINE(WIN32_LEAN_AND_MEAN)
2189     TARGET_MD_ARCH=win32
2190     _PLATFORM_DEFAULT_TOOLKIT='cairo-windows'
2191     BIN_SUFFIX='.exe'
2192     MOZ_USER_DIR="Mozilla"
2194     dnl Hardcode to win95 for now - cls
2195     TARGET_NSPR_MDCPUCFG='\"md/_win95.cfg\"'
2197     dnl set NO_X11 defines here as the general check is skipped on win32
2198     no_x=yes
2199     AC_DEFINE(NO_X11)
2201     case "$host" in
2202     *-mingw*)
2203         MOZ_BUILD_ROOT=`cd $MOZ_BUILD_ROOT && pwd -W`
2204         if test -n "$L10NBASEDIR"; then
2205             L10NBASEDIR=`cd $L10NBASEDIR && pwd -W`
2206         fi
2207         ;;
2208     esac
2210     case "$host" in
2211     *-mingw*)
2212         if test -z "$MOZ_TOOLS"; then
2213             AC_MSG_ERROR([MOZ_TOOLS is not set])
2214         fi
2215         MOZ_TOOLS_DIR=`cd $MOZ_TOOLS && pwd -W`
2216         if test "$?" != "0" -o -z "$MOZ_TOOLS_DIR"; then
2217             AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
2218         fi
2219         MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
2220         if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
2221             AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
2222         fi
2223         ;;
2224     esac
2226     case "$host_os" in
2227     cygwin*|msvc*|mks*)
2228         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.])
2229         ;;
2230     esac
2232     case "$target" in
2233     i*86-*)
2234         if test "$HAVE_64BIT_OS"; then
2235             AC_MSG_ERROR([You are targeting i386 but using the 64-bit compiler.])
2236         fi
2238         if test -n "$GNU_CC"; then
2239             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
2240             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
2241             LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup -Wl,--large-address-aware"
2242         else
2243             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
2244             # Disable this flag on clang-cl since it doesn't ignore unknown arguments by default, and
2245             # autoconf insists on passing $LDFLAGS to the compiler.
2246             if test -z "$CLANG_CL"; then
2247                 LDFLAGS="$LDFLAGS -SAFESEH"
2248             fi
2249         fi
2251         AC_DEFINE(_X86_)
2252         ;;
2253     x86_64-*)
2254         if test -n "$_WIN32_MSVC"; then
2255             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
2256         fi
2257         AC_DEFINE(_AMD64_)
2258         ;;
2259     *)
2260         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
2261         ;;
2262     esac
2263     ;;
2265 *-netbsd*)
2266     DSO_CFLAGS=''
2267     CFLAGS="$CFLAGS -Dunix"
2268     CXXFLAGS="$CXXFLAGS -Dunix"
2269     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
2270         DLL_SUFFIX=".so"
2271         DSO_PIC_CFLAGS='-fPIC -DPIC'
2272         DSO_LDOPTS='-shared'
2273         BIN_FLAGS='-Wl,--export-dynamic'
2274     else
2275         DSO_PIC_CFLAGS='-fPIC -DPIC'
2276         DLL_SUFFIX=".so.1.0"
2277         DSO_LDOPTS='-shared'
2278     fi
2279     # This will fail on a.out systems prior to 1.5.1_ALPHA.
2280     MKSHLIB_FORCE_ALL='-Wl,--whole-archive'
2281     MKSHLIB_UNFORCE_ALL='-Wl,--no-whole-archive'
2282     if test "$LIBRUNPATH"; then
2283         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
2284     fi
2285     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@) -o $@'
2286     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(notdir $@)) -o $@'
2287     ;;
2289 *-openbsd*)
2290     if test "$SO_VERSION"; then
2291         DLL_SUFFIX=".so.$SO_VERSION"
2292     else
2293         DLL_SUFFIX=".so.1.0"
2294     fi
2295     MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib -Wl,-rpath-link,$(if $(X11BASE),$(X11BASE),/usr/X11R6)/lib'
2296     DSO_CFLAGS=''
2297     DSO_PIC_CFLAGS='-fPIC'
2298     DSO_LDOPTS='-shared -fPIC'
2299     if test "$LIBRUNPATH"; then
2300         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
2301     fi
2302     ;;
2304 *-solaris*)
2305     AC_DEFINE(SOLARIS)
2306     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
2307     MOZ_FIX_LINK_PATHS=
2308     # $ORIGIN/.. is for shared libraries under components/ to locate shared
2309     # libraries one level up (e.g. libnspr4.so)
2310     if test "$SOLARIS_SUNPRO_CC"; then
2311        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
2312        LIBS="-lCrun -lCstd -lc $LIBS"
2313        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
2314        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
2315        CXXFLAGS="$CXXFLAGS -xlibmieee -xbuiltin=%all -features=tmplife,tmplrefstatic,extensions,no%except -norunpath -D__FUNCTION__=__func__ -template=no%extdef"
2316        LDFLAGS="-xildoff $LDFLAGS"
2317        MMX_FLAGS="-xarch=mmx -xO4"
2318        SSE_FLAGS="-xarch=sse"
2319        SSE2_FLAGS="-xarch=ssei2 -xO4"
2320        if test -z "$CROSS_COMPILE" -a -f /usr/lib/ld/map.noexstk; then
2321            _SAVE_LDFLAGS=$LDFLAGS
2322            LDFLAGS="-M /usr/lib/ld/map.noexstk $LDFLAGS"
2323            AC_TRY_LINK([#include <stdio.h>],
2324                        [printf("Hello World\n");],
2325                        ,
2326                        [LDFLAGS=$_SAVE_LDFLAGS])
2327        fi
2328        MOZ_OPTIMIZE_FLAGS="-xO4"
2329        MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
2330        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_FLAGS) $(DSO_LDOPTS) -h $(notdir $@) -o $@'
2331        MKSHLIB_FORCE_ALL='-z allextract'
2332        MKSHLIB_UNFORCE_ALL='-z defaultextract'
2333        DSO_LDOPTS='-G'
2334        AR_LIST="$AR t"
2335        AR_EXTRACT="$AR x"
2336        AR_DELETE="$AR d"
2337        AR='$(CXX) -xar'
2338        AR_FLAGS='-o $@'
2339        AS='/usr/ccs/bin/as'
2340        ASFLAGS="$ASFLAGS -K PIC -L -P -D_ASM -D__STDC__=0"
2341        AS_DASH_C_FLAG=''
2342        TARGET_COMPILER_ABI="sunc"
2343        CC_VERSION=`$CC -V 2>&1 | grep '^cc:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2344        CXX_VERSION=`$CXX -V 2>&1 | grep '^CC:' 2>/dev/null | $AWK -F\: '{ print $2 }'`
2345        AC_MSG_CHECKING([for Sun C++ compiler version >= 5.9])
2346        AC_LANG_SAVE
2347        AC_LANG_CPLUSPLUS
2348        AC_TRY_COMPILE([],
2349            [#if (__SUNPRO_CC < 0x590)
2350            #error "Denied"
2351            #endif],
2352            _BAD_COMPILER=,_BAD_COMPILER=1)
2353        if test -n "$_BAD_COMPILER"; then
2354            _res="no"
2355            AC_MSG_ERROR([Sun C++ 5.9 (Sun Studio 12) or higher is required to build. Your compiler version is $CXX_VERSION .])
2356        else
2357            _res="yes"
2358        fi
2359        AC_TRY_COMPILE([],
2360            [#if (__SUNPRO_CC >= 0x5100)
2361            #error "Sun C++ 5.10 or above"
2362            #endif],
2363            _ABOVE_SS12U1=,_ABOVE_SS12U1=1)
2364        if test "$_ABOVE_SS12U1"; then
2365            # disable xannotate
2366            CXXFLAGS="$CXXFLAGS -xannotate=no"
2367        fi
2368        AC_MSG_RESULT([$_res])
2369        AC_LANG_RESTORE
2370     else
2371        LDFLAGS="$LDFLAGS -Wl,-z,ignore -Wl,-R,'\$\$ORIGIN:\$\$ORIGIN/..' -Wl,-z,lazyload -Wl,-z,combreloc -Wl,-z,muldefs"
2372        LIBS="-lc $LIBS"
2373        MKSHLIB_FORCE_ALL='-Wl,-z -Wl,allextract'
2374        MKSHLIB_UNFORCE_ALL='-Wl,-z -Wl,defaultextract'
2375        ASFLAGS="$ASFLAGS -fPIC"
2376        DSO_LDOPTS='-shared'
2377        WARNINGS_AS_ERRORS='-Werror'
2378        _WARNINGS_CFLAGS=''
2379        _WARNINGS_CXXFLAGS=''
2380        if test "$OS_RELEASE" = "5.3"; then
2381            AC_DEFINE(MUST_UNDEF_HAVE_BOOLEAN_AFTER_INCLUDES)
2382        fi
2383     fi
2384     if test "$OS_RELEASE" = "5.5.1"; then
2385         AC_DEFINE(NEED_USLEEP_PROTOTYPE)
2386     fi
2387     ;;
2389 *-sunos*)
2390     DSO_LDOPTS='-Bdynamic'
2391     MKSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2392     MKCSHLIB='-$(LD) $(DSO_LDOPTS) -o $@'
2393     AC_DEFINE(SUNOS4)
2394     AC_DEFINE(SPRINTF_RETURNS_STRING)
2395     case "$(target_os)" in
2396     sunos4.1*)
2397         DLL_SUFFIX='.so.1.0'
2398         ;;
2399     esac
2400     ;;
2402 esac
2404 AC_SUBST_LIST(MMX_FLAGS)
2405 AC_SUBST_LIST(SSE_FLAGS)
2406 AC_SUBST_LIST(SSE2_FLAGS)
2408 case "$target" in
2409 *-*linux*)
2410     # Includes linux-android
2411     AC_DEFINE(XP_LINUX)
2412     ;;
2413 esac
2415 AC_SUBST(MOZ_LINKER)
2416 if test -n "$MOZ_LINKER"; then
2417   AC_DEFINE(MOZ_LINKER)
2420 dnl Only one oddball right now (QNX), but this gives us flexibility
2421 dnl if any other platforms need to override this in the future.
2422 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
2424 dnl ========================================================
2425 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
2426 dnl by now will not have any way to link most binaries (tests
2427 dnl as well as viewer, apprunner, etc.), because some symbols
2428 dnl will be left out of the "composite" .so's by ld as unneeded.
2429 dnl So, by defining NO_LD_ARCHIVE_FLAGS for these platforms,
2430 dnl they can link in the static libs that provide the missing
2431 dnl symbols.
2432 dnl ========================================================
2433 NO_LD_ARCHIVE_FLAGS=
2434 if test -z "$MKSHLIB_FORCE_ALL" -o -z "$MKSHLIB_UNFORCE_ALL"; then
2435     NO_LD_ARCHIVE_FLAGS=1
2437 case "$target" in
2438 *-aix4.3*|*-aix5*)
2439     NO_LD_ARCHIVE_FLAGS=
2440     ;;
2441 *-mingw*)
2442     if test -z "$GNU_CC"; then
2443         NO_LD_ARCHIVE_FLAGS=
2444     fi
2445     ;;
2446 esac
2447 AC_SUBST(NO_LD_ARCHIVE_FLAGS)
2449 dnl ========================================================
2450 dnl = Flags to strip unused symbols from .so components and
2451 dnl = to export jemalloc symbols when linking a program
2452 dnl ========================================================
2453 case "$target" in
2454     *-linux*|*-kfreebsd*-gnu|*-gnu*)
2455         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2456         ;;
2457     *-solaris*)
2458         if test -z "$GNU_CC"; then
2459          MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-M $(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2460         else
2461          if test -z "$GCC_USE_GNU_LD"; then
2462           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-M -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-mapfile'
2463          else
2464           MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2465          fi
2466         fi
2467         ;;
2468     *-darwin*)
2469         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
2470         ;;
2471     *-mingw*)
2472         if test -n "$GNU_CC"; then
2473            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
2474         fi
2475         ;;
2476 esac
2478 if test -z "$COMPILE_ENVIRONMENT"; then
2479     SKIP_COMPILER_CHECKS=1
2480     SKIP_LIBRARY_CHECKS=1
2481 else
2482     MOZ_COMPILER_OPTS
2485 if test -z "$SKIP_COMPILER_CHECKS"; then
2486 dnl Checks for typedefs, structures, and compiler characteristics.
2487 dnl ========================================================
2488 AC_HEADER_STDC
2489 AC_C_CONST
2490 AC_TYPE_MODE_T
2491 AC_TYPE_OFF_T
2492 AC_TYPE_PID_T
2493 AC_TYPE_SIZE_T
2494 AC_LANG_CPLUSPLUS
2495 AC_LANG_C
2496 AC_MSG_CHECKING(for ssize_t)
2497 AC_CACHE_VAL(ac_cv_type_ssize_t,
2498  [AC_TRY_COMPILE([#include <stdio.h>
2499                   #include <sys/types.h>],
2500                  [ssize_t foo = 0;],
2501                  [ac_cv_type_ssize_t=true],
2502                  [ac_cv_type_ssize_t=false])])
2503 if test "$ac_cv_type_ssize_t" = true ; then
2504   AC_DEFINE(HAVE_SSIZE_T)
2505   AC_MSG_RESULT(yes)
2506 else
2507   AC_MSG_RESULT(no)
2509 AC_STRUCT_ST_BLKSIZE
2510 AC_MSG_CHECKING(for siginfo_t)
2511 AC_CACHE_VAL(ac_cv_siginfo_t,
2512  [AC_TRY_COMPILE([#define _POSIX_C_SOURCE 199506L
2513                   #include <signal.h>],
2514                  [siginfo_t* info;],
2515                  [ac_cv_siginfo_t=true],
2516                  [ac_cv_siginfo_t=false])])
2517 if test "$ac_cv_siginfo_t" = true ; then
2518   AC_DEFINE(HAVE_SIGINFO_T)
2519   AC_MSG_RESULT(yes)
2520 else
2521   AC_MSG_RESULT(no)
2524 AC_LANG_CPLUSPLUS
2526 MOZ_CXX11
2528 AC_LANG_C
2530 dnl Check for .hidden assembler directive and visibility attribute.
2531 dnl Borrowed from glibc configure.in
2532 dnl ===============================================================
2533 if test "$GNU_CC" -a "$OS_TARGET" != WINNT; then
2534   AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
2535   AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE)
2536   case "$OS_TARGET" in
2537   Darwin)
2538     VISIBILITY_FLAGS='-fvisibility=hidden'
2539     ;;
2540   *)
2541     case $GCC_VERSION in
2542     4.4*|4.6*)
2543       VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden_dso_handle.h'
2544       ;;
2545     *)
2546       VISIBILITY_FLAGS='-I$(DIST)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
2547       ;;
2548     esac
2549     WRAP_SYSTEM_INCLUDES=1
2550     ;;
2551   esac
2552 fi         # GNU_CC
2554 # visibility hidden flag for Sun Studio on Solaris
2555 if test "$SOLARIS_SUNPRO_CC"; then
2556 VISIBILITY_FLAGS='-xldscope=hidden'
2557 fi         # Sun Studio on Solaris
2559 case "${OS_TARGET}" in
2560 WINNT|Darwin|Android)
2561   ;;
2563   STL_FLAGS='-I$(DIST)/stl_wrappers'
2564   WRAP_STL_INCLUDES=1
2565   ;;
2566 esac
2568 AC_SUBST(WRAP_SYSTEM_INCLUDES)
2569 AC_SUBST(VISIBILITY_FLAGS)
2571 MOZ_GCC_PR49911
2572 MOZ_GCC_PR39608
2573 if test "$OS_TARGET" != WINNT; then
2574     # Only run this test with clang on non-Windows platforms, because clang
2575     # cannot do enough code gen for now to make this test work correctly.
2576     MOZ_LLVM_PR8927
2579 dnl Check for __force_align_arg_pointer__ for SSE2 on gcc
2580 dnl ========================================================
2581 if test "$GNU_CC"; then
2582   CFLAGS_save="${CFLAGS}"
2583   CFLAGS="${CFLAGS} -Werror"
2584   AC_CACHE_CHECK(for __force_align_arg_pointer__ attribute,
2585                  ac_cv_force_align_arg_pointer,
2586                  [AC_TRY_COMPILE([__attribute__ ((__force_align_arg_pointer__)) void test() {}],
2587                                  [],
2588                                  ac_cv_force_align_arg_pointer="yes",
2589                                  ac_cv_force_align_arg_pointer="no")])
2590   CFLAGS="${CFLAGS_save}"
2591   if test "$ac_cv_force_align_arg_pointer" = "yes"; then
2592     HAVE_GCC_ALIGN_ARG_POINTER=1
2593   else
2594     HAVE_GCC_ALIGN_ARG_POINTER=
2595   fi
2597 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
2599 dnl Checks for header files.
2600 dnl ========================================================
2601 AC_HEADER_DIRENT
2602 case "$target_os" in
2603 freebsd*|openbsd*)
2604 # for stuff like -lXshm
2605     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
2606     ;;
2607 esac
2608 MOZ_CHECK_COMMON_HEADERS
2610 dnl These are all the places some variant of statfs can be hiding.
2611 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
2613 dnl Quota support
2614 MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
2615 MOZ_CHECK_HEADERS([linux/quota.h],,,[#include <sys/socket.h>])
2617 dnl SCTP support - needs various network include headers
2618 MOZ_CHECK_HEADERS([linux/if_addr.h linux/rtnetlink.h],,,[#include <sys/socket.h>])
2620 MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
2622 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
2623 AC_CACHE_CHECK(for sockaddr_in.sin_len,
2624                    ac_cv_sockaddr_in_sin_len,
2625                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2626                                     #include <sys/types.h>
2627                                     #endif
2628                                     #include <netinet/in.h>
2629                                     struct sockaddr_in x;
2630                                     void *foo = (void*) &x.sin_len;],
2631                                    [],
2632                                    [ac_cv_sockaddr_in_sin_len=true],
2633                                    [ac_cv_sockaddr_in_sin_len=false])])
2634 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
2635   AC_DEFINE(HAVE_SIN_LEN)
2636 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
2637   AC_DEFINE(HAVE_SCONN_LEN)
2640 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
2641                ac_cv_sockaddr_in6_sin6_len,
2642                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2643                                 #include <sys/types.h>
2644                                 #endif
2645                                 #include <netinet/in.h>
2646                                 struct sockaddr_in6 x;
2647                                 void *foo = (void*) &x.sin6_len;],
2648                                [],
2649                                [ac_cv_sockaddr_in6_sin6_len=true],
2650                                [ac_cv_sockaddr_in6_sin6_len=false])])
2651 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
2652   AC_DEFINE(HAVE_SIN6_LEN)
2655 AC_CACHE_CHECK(for sockaddr.sa_len,
2656                ac_cv_sockaddr_sa_len,
2657                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
2658                                 #include <sys/types.h>
2659                                 #endif
2660                                 #include <sys/socket.h>
2661                                 struct sockaddr x;
2662                                 void *foo = (void*) &x.sa_len;],
2663                                [],
2664                                [ac_cv_sockaddr_sa_len=true],
2665                                [ac_cv_sockaddr_sa_len=false])])
2666 if test "$ac_cv_sockaddr_sa_len" = true ; then
2667   AC_DEFINE(HAVE_SA_LEN)
2670 AC_ARG_ENABLE(dtrace,
2671               [  --enable-dtrace         build with dtrace support if available (default=no)],
2672               [enable_dtrace="yes"],)
2673 if test "x$enable_dtrace" = "xyes"; then
2674   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
2675   if test -n "$HAVE_DTRACE"; then
2676       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
2677   else
2678       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
2679   fi
2681 AC_SUBST(HAVE_DTRACE)
2683 case $target in
2684 *-aix4.3*|*-aix5*)
2685     ;;
2687     MOZ_CHECK_HEADERS(sys/cdefs.h)
2688     ;;
2689 esac
2691 MOZ_LINUX_PERF_EVENT
2693 dnl Checks for libraries.
2694 dnl ========================================================
2695 case $target in
2696 *-hpux11.*)
2697     ;;
2699     AC_CHECK_LIB(c_r, gethostbyname_r)
2700     ;;
2701 esac
2703 dnl We don't want to link with libdl even if it's present on OS X, since
2704 dnl it's not used and not part of the default installation. OS/2 has dlfcn
2705 dnl in libc.
2706 dnl We don't want to link against libm or libpthread on Darwin since
2707 dnl they both are just symlinks to libSystem and explicitly linking
2708 dnl against libSystem causes issues when debugging (see bug 299601).
2709 case $target in
2710 *-darwin*)
2711     ;;
2713     AC_SEARCH_LIBS(dlopen, dl,
2714         MOZ_CHECK_HEADER(dlfcn.h,
2715         AC_DEFINE(HAVE_DLOPEN)))
2716     ;;
2717 esac
2719 _SAVE_CFLAGS="$CFLAGS"
2720 CFLAGS="$CFLAGS -D_GNU_SOURCE"
2721 AC_CHECK_FUNCS(dladdr memmem)
2722 CFLAGS="$_SAVE_CFLAGS"
2724 if test ! "$GNU_CXX"; then
2726     case $target in
2727     *-aix*)
2728         AC_CHECK_LIB(C_r, demangle)
2729         ;;
2730      *)
2731         AC_CHECK_LIB(C, demangle)
2732         ;;
2733      esac
2736 AC_CHECK_LIB(socket, socket)
2738 XLDFLAGS="$X_LIBS"
2739 XLIBS="$X_EXTRA_LIBS"
2741 dnl ========================================================
2742 dnl Checks for X libraries.
2743 dnl Ordering is important.
2744 dnl Xt is dependent upon SM as of X11R6
2745 dnl ========================================================
2746 if test "$no_x" = "yes"; then
2747     AC_DEFINE(NO_X11)
2748 else
2749     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
2750     XLIBS="-lX11 $XLIBS"
2751     _SAVE_LDFLAGS="$LDFLAGS"
2752     LDFLAGS="$XLDFLAGS $LDFLAGS"
2753     AC_CHECK_LIB(X11, XDrawLines, [X11_LIBS="-lX11"],
2754         [MISSING_X="$MISSING_X -lX11"], $XLIBS)
2755     AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
2756         [MISSING_X="$MISSING_X -lXext"], $XLIBS)
2758     AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
2759         unset ac_cv_lib_Xt_XtFree
2760         AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
2761         AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
2762         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
2763             [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
2764         ])
2766     # AIX needs the motif library linked before libXt to prevent
2767     # crashes in plugins linked against Motif - Bug #98892
2768     case "${target_os}" in
2769     aix*)
2770         XT_LIBS="-lXm $XT_LIBS"
2771         ;;
2772     esac
2774     dnl ========================================================
2775     dnl = Check for XShm
2776     dnl ========================================================
2777     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
2778         $XLIBS $XEXT_LIBS)
2780     dnl ========================================================
2781     dnl = Check for Xss
2782     dnl ========================================================
2783     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
2784         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
2785             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
2786              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
2788     LDFLAGS="$_SAVE_LDFLAGS"
2789 fi # $no_x
2791 AC_SUBST(XCFLAGS)
2792 AC_SUBST(XLDFLAGS)
2793 AC_SUBST(XLIBS)
2794 AC_SUBST(XEXT_LIBS)
2795 AC_SUBST(XT_LIBS)
2796 AC_SUBST(XSS_LIBS)
2798 dnl ========================================================
2799 dnl = pthread support
2800 dnl = Start by checking whether the system support pthreads
2801 dnl ========================================================
2802 case "$target_os" in
2803 darwin*)
2804     MOZ_USE_PTHREADS=1
2805     ;;
2807     MOZ_CHECK_PTHREADS(pthreads,
2808         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
2809         MOZ_CHECK_PTHREADS(pthread,
2810             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
2811             MOZ_CHECK_PTHREADS(c_r,
2812                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
2813                 MOZ_CHECK_PTHREADS(c,
2814                     MOZ_USE_PTHREADS=1
2815                 )
2816             )
2817         )
2818     )
2819     ;;
2820 esac
2822 dnl ========================================================
2823 dnl Check the command line for --with-pthreads
2824 dnl ========================================================
2825 MOZ_ARG_WITH_BOOL(pthreads,
2826 [  --with-pthreads         Force use of system pthread library with NSPR ],
2827 [ if test "$MOZ_USE_PTHREADS"x = x; then
2828     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
2829 fi],
2830     MOZ_USE_PTHREADS=
2831     _PTHREAD_LDFLAGS=
2834 dnl ========================================================
2835 dnl Do the platform specific pthread hackery
2836 dnl ========================================================
2837 if test "$MOZ_USE_PTHREADS"x != x
2838 then
2839     dnl
2840     dnl See if -pthread is supported.
2841     dnl
2842     rm -f conftest*
2843     ac_cv_have_dash_pthread=no
2844     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
2845     echo 'int main() { return 0; }' | cat > conftest.c
2846     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
2847     if test $? -eq 0; then
2848         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2849             ac_cv_have_dash_pthread=yes
2850             case "$target_os" in
2851             freebsd*)
2852 # Freebsd doesn't use -pthread for compiles, it uses them for linking
2853                 ;;
2854             *)
2855                 CFLAGS="$CFLAGS -pthread"
2856                 CXXFLAGS="$CXXFLAGS -pthread"
2857                 ;;
2858             esac
2859         fi
2860     fi
2861     rm -f conftest*
2862     AC_MSG_RESULT($ac_cv_have_dash_pthread)
2864     dnl
2865     dnl See if -pthreads is supported.
2866     dnl
2867     ac_cv_have_dash_pthreads=no
2868     if test "$ac_cv_have_dash_pthread" = "no"; then
2869         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
2870         echo 'int main() { return 0; }' | cat > conftest.c
2871         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
2872         if test $? -eq 0; then
2873             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
2874                 ac_cv_have_dash_pthreads=yes
2875                 CFLAGS="$CFLAGS -pthreads"
2876                 CXXFLAGS="$CXXFLAGS -pthreads"
2877             fi
2878         fi
2879         rm -f conftest*
2880         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
2881     fi
2883     case "$target" in
2884         *-*-freebsd*)
2885             AC_DEFINE(_REENTRANT)
2886             AC_DEFINE(_THREAD_SAFE)
2887             dnl -pthread links in -lpthread, so don't specify it explicitly.
2888             if test "$ac_cv_have_dash_pthread" = "yes"; then
2889                 _PTHREAD_LDFLAGS="-pthread"
2890             fi
2891             ;;
2893         *-*-openbsd*|*-*-bsdi*)
2894             AC_DEFINE(_REENTRANT)
2895             AC_DEFINE(_THREAD_SAFE)
2896             dnl -pthread links in -lc_r, so don't specify it explicitly.
2897             if test "$ac_cv_have_dash_pthread" = "yes"; then
2898                 _PTHREAD_LDFLAGS="-pthread"
2899             fi
2900             ;;
2902         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
2903             AC_DEFINE(_REENTRANT)
2904             ;;
2906         *-aix4.3*|*-aix5*)
2907             AC_DEFINE(_REENTRANT)
2908             ;;
2910         *-hpux11.*)
2911             AC_DEFINE(_REENTRANT)
2912             ;;
2914         *-*-solaris*)
2915             AC_DEFINE(_REENTRANT)
2916             if test "$SOLARIS_SUNPRO_CC"; then
2917                 CFLAGS="$CFLAGS -mt"
2918                 CXXFLAGS="$CXXFLAGS -mt"
2919             fi
2920             ;;
2921     esac
2922     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
2923     AC_SUBST(MOZ_USE_PTHREADS)
2927 dnl Checks for library functions.
2928 dnl ========================================================
2929 AC_PROG_GCC_TRADITIONAL
2930 AC_FUNC_MEMCMP
2931 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize localtime_r)
2933 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
2934 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
2935                ac_cv_clock_monotonic,
2936                [for libs in "" -lrt; do
2937                     _SAVE_LIBS="$LIBS"
2938                     LIBS="$LIBS $libs"
2939                     AC_TRY_LINK([#include <time.h>],
2940                                  [ struct timespec ts;
2941                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
2942                                  ac_cv_clock_monotonic=$libs
2943                                  LIBS="$_SAVE_LIBS"
2944                                  break,
2945                                  ac_cv_clock_monotonic=no)
2946                     LIBS="$_SAVE_LIBS"
2947                 done])
2948 if test "$ac_cv_clock_monotonic" != "no"; then
2949     HAVE_CLOCK_MONOTONIC=1
2950     REALTIME_LIBS=$ac_cv_clock_monotonic
2951     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
2952     AC_SUBST(HAVE_CLOCK_MONOTONIC)
2953     AC_SUBST(REALTIME_LIBS)
2956 dnl check for wcrtomb/mbrtowc
2957 dnl =======================================================================
2958 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
2959 AC_LANG_SAVE
2960 AC_LANG_CPLUSPLUS
2961 AC_CACHE_CHECK(for wcrtomb,
2962     ac_cv_have_wcrtomb,
2963     [AC_TRY_LINK([#include <wchar.h>],
2964                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
2965                  ac_cv_have_wcrtomb="yes",
2966                  ac_cv_have_wcrtomb="no")])
2967 if test "$ac_cv_have_wcrtomb" = "yes"; then
2968     AC_DEFINE(HAVE_WCRTOMB)
2970 AC_CACHE_CHECK(for mbrtowc,
2971     ac_cv_have_mbrtowc,
2972     [AC_TRY_LINK([#include <wchar.h>],
2973                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
2974                  ac_cv_have_mbrtowc="yes",
2975                  ac_cv_have_mbrtowc="no")])
2976 if test "$ac_cv_have_mbrtowc" = "yes"; then
2977     AC_DEFINE(HAVE_MBRTOWC)
2979 AC_LANG_RESTORE
2982 AC_CACHE_CHECK(
2983     [for res_ninit()],
2984     ac_cv_func_res_ninit,
2985     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
2986         dnl no need for res_ninit() on NetBSD and OpenBSD
2987         ac_cv_func_res_ninit=no
2988      else
2989         AC_TRY_LINK([
2990             #ifdef linux
2991             #define _BSD_SOURCE 1
2992             #endif
2993             #include <sys/types.h>
2994             #include <netinet/in.h>
2995             #include <arpa/nameser.h>
2996             #include <resolv.h>
2997             ],
2998             [int foo = res_ninit(&_res);],
2999             [ac_cv_func_res_ninit=yes],
3000             [ac_cv_func_res_ninit=no])
3001      fi
3002     ])
3004 if test "$ac_cv_func_res_ninit" = "yes"; then
3005     AC_DEFINE(HAVE_RES_NINIT)
3006 dnl must add the link line we do something as foolish as this... dougt
3007 dnl else
3008 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
3009 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
3012 AC_LANG_CPLUSPLUS
3014 case $target_os in
3015     darwin*|mingw*)
3016         ;;
3017     *)
3019 AC_CHECK_LIB(c, iconv, [_ICONV_LIBS="$_ICONV_LIBS"],
3020     AC_CHECK_LIB(iconv, iconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"],
3021         AC_CHECK_LIB(iconv, libiconv, [_ICONV_LIBS="$_ICONV_LIBS -liconv"])))
3022 _SAVE_LIBS=$LIBS
3023 LIBS="$LIBS $_ICONV_LIBS"
3024 AC_CACHE_CHECK(
3025     [for iconv()],
3026     ac_cv_func_iconv,
3027     [AC_TRY_LINK([
3028         #include <stdlib.h>
3029         #include <iconv.h>
3030         ],
3031         [
3032             iconv_t h = iconv_open("", "");
3033             iconv(h, NULL, NULL, NULL, NULL);
3034             iconv_close(h);
3035         ],
3036         [ac_cv_func_iconv=yes],
3037         [ac_cv_func_iconv=no]
3038         )]
3039     )
3040 if test "$ac_cv_func_iconv" = "yes"; then
3041     AC_DEFINE(HAVE_ICONV)
3042     LIBXUL_LIBS="$LIBXUL_LIBS $_ICONV_LIBS"
3043     LIBICONV="$_ICONV_LIBS"
3044     AC_CACHE_CHECK(
3045         [for iconv() with const input],
3046         ac_cv_func_const_iconv,
3047         [AC_TRY_COMPILE([
3048             #include <stdlib.h>
3049             #include <iconv.h>
3050             ],
3051             [
3052                 const char *input = "testing";
3053                 iconv_t h = iconv_open("", "");
3054                 iconv(h, &input, NULL, NULL, NULL);
3055                 iconv_close(h);
3056             ],
3057             [ac_cv_func_const_iconv=yes],
3058             [ac_cv_func_const_iconv=no]
3059             )]
3060         )
3061     if test "$ac_cv_func_const_iconv" = "yes"; then
3062         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
3063     fi
3065 LIBS=$_SAVE_LIBS
3067     ;;
3068 esac
3070 AM_LANGINFO_CODESET
3072 AC_LANG_C
3074 dnl **********************
3075 dnl *** va_copy checks ***
3076 AC_CACHE_CHECK([for an implementation of va_copy()],
3077                ac_cv_va_copy,
3078     [AC_TRY_COMPILE([#include <stdarg.h>
3079                      #include <stdlib.h>
3080         void f (int i, ...) {
3081             va_list args1, args2;
3082             va_start (args1, i);
3083             va_copy (args2, args1);
3084             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3085                 exit (1);
3086             va_end (args1); va_end (args2);
3087         }],
3088         [f(0, 42); return 0],
3089         [ac_cv_va_copy=yes],
3090         [ac_cv_va_copy=no]
3091     )]
3093 AC_CACHE_CHECK([whether va_list can be copied by value],
3094                ac_cv_va_val_copy,
3095     [AC_TRY_COMPILE([#include <stdarg.h>
3096                      #include <stdlib.h>
3097         void f (int i, ...) {
3098             va_list args1, args2;
3099             va_start (args1, i);
3100             args2 = args1;
3101             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
3102                 exit (1);
3103             va_end (args1); va_end (args2);
3104         }],
3105         [f(0, 42); return 0],
3106         [ac_cv_va_val_copy=yes],
3107         [ac_cv_va_val_copy=no],
3108     )]
3110 if test "x$ac_cv_va_copy" = "xyes"; then
3111     AC_DEFINE(VA_COPY, va_copy)
3112     AC_DEFINE(HAVE_VA_COPY)
3115 if test "x$ac_cv_va_val_copy" = "xno"; then
3116    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
3119 dnl ===================================================================
3120 dnl ========================================================
3121 dnl Put your C++ language/feature checks below
3122 dnl ========================================================
3123 AC_LANG_CPLUSPLUS
3125 ARM_ABI_PREFIX=
3126 if test "$GNU_CC"; then
3127   if test "$CPU_ARCH" = "arm" ; then
3128     AC_CACHE_CHECK(for ARM EABI,
3129         ac_cv_gcc_arm_eabi,
3130         [AC_TRY_COMPILE([],
3131                         [
3132 #if defined(__ARM_EABI__)
3133   return 0;
3134 #else
3135 #error Not ARM EABI.
3136 #endif
3137                         ],
3138                         ac_cv_gcc_arm_eabi="yes",
3139                         ac_cv_gcc_arm_eabi="no")])
3140     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
3141         HAVE_ARM_EABI=1
3142         ARM_ABI_PREFIX=eabi-
3143     else
3144         ARM_ABI_PREFIX=oabi-
3145     fi
3146   fi
3148   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
3151 dnl Check to see if we can resolve ambiguity with |using|.
3152 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
3153                ac_cv_cpp_ambiguity_resolving_using,
3154                [AC_TRY_COMPILE(class X {
3155                                  public: int go(const X&) {return 3;}
3156                                          int jo(const X&) {return 3;}
3157                                };
3158                                class Y : public X {
3159                                  public:  int go(int) {return 2;}
3160                                           int jo(int) {return 2;}
3161                                           using X::jo;
3162                                  private: using X::go;
3163                                };,
3164                                X x; Y y; y.jo(x);,
3165                                ac_cv_cpp_ambiguity_resolving_using=yes,
3166                                ac_cv_cpp_ambiguity_resolving_using=no)])
3167 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
3168    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
3171 dnl See if a dynamic_cast to void* gives the most derived object.
3172 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
3173                ac_cv_cpp_dynamic_cast_void_ptr,
3174                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
3175                             class Y { int j; public: virtual ~Y() { } };
3176                             class Z : public X, public Y { int k; };
3178                             int main() {
3179                                  Z mdo;
3180                                  X *subx = (X*)&mdo;
3181                                  Y *suby = (Y*)&mdo;
3182                                  return !((((void*)&mdo != (void*)subx) &&
3183                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
3184                                           (((void*)&mdo != (void*)suby) &&
3185                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
3186                             }],
3187                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
3188                            ac_cv_cpp_dynamic_cast_void_ptr=no,
3189                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
3190 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
3191    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
3194 dnl note that this one is reversed - if the test fails, then
3195 dnl we require implementations of unused virtual methods. Which
3196 dnl really blows because it means we'll have useless vtable
3197 dnl bloat.
3198 AC_CACHE_CHECK(whether C++ requires implementation of unused virtual methods,
3199                ac_cv_cpp_unused_required,
3200                [AC_TRY_LINK(class X {private: virtual void never_called();};,
3201                                X x;,
3202                                ac_cv_cpp_unused_required=no,
3203                                ac_cv_cpp_unused_required=yes)])
3204 if test "$ac_cv_cpp_unused_required" = yes ; then
3205    AC_DEFINE(NEED_CPP_UNUSED_IMPLEMENTATIONS)
3209 dnl Some compilers have trouble comparing a constant reference to a templatized
3210 dnl class to zero, and require an explicit operator==() to be defined that takes
3211 dnl an int. This test separates the strong from the weak.
3213 AC_CACHE_CHECK(for trouble comparing to zero near std::operator!=(),
3214                ac_cv_trouble_comparing_to_zero,
3215                [AC_TRY_COMPILE([#include <algorithm>
3216                                 template <class T> class Foo {};
3217                                 class T2;
3218                                 template <class T> int operator==(const T2*, const T&) { return 0; }
3219                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
3220                                [Foo<int> f; return (0 != f);],
3221                                ac_cv_trouble_comparing_to_zero=no,
3222                                ac_cv_trouble_comparing_to_zero=yes)])
3223 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
3224   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
3227 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
3228 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
3229 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
3230 # linking XUL.
3231 _SAVE_LDFLAGS=$LDFLAGS
3232 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
3233 AC_CACHE_CHECK(for __thread keyword for TLS variables,
3234                ac_cv_thread_keyword,
3235                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
3236                             [return tlsIsMainThread;],
3237                             ac_cv_thread_keyword=yes,
3238                             ac_cv_thread_keyword=no)])
3239 LDFLAGS=$_SAVE_LDFLAGS
3240 # The custom dynamic linker doesn't support TLS variables
3241 MOZ_TLS=
3242 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
3243   # mips builds fail with TLS variables because of a binutils bug.
3244   # See bug 528687
3245   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
3246   case "${target}" in
3247     mips*-*)
3248       :
3249       ;;
3250     *-android*|*-linuxandroid*)
3251       :
3252       ;;
3253     *-openbsd*)
3254       :
3255       ;;
3256     *)
3257       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
3258       MOZ_TLS=1
3259       ;;
3260   esac
3263 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
3264 if test -n "$MOZ_LINKER"; then
3265   if test "$CPU_ARCH" = arm; then
3266     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
3267     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
3268       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3269       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
3270     fi
3271   fi
3274 dnl The custom linker doesn't support text relocations, but NDK >= r6b
3275 dnl creates some (http://code.google.com/p/android/issues/detail?id=23203)
3276 dnl We however want to avoid these text relocations, and this can be done
3277 dnl by making gcc not link crtbegin and crtend. In the broken NDKs, crtend
3278 dnl doesn't contain anything at all, beside placeholders for some sections,
3279 dnl and crtbegin only contains a finalizer function that calls
3280 dnl __cxa_finalize. The custom linker actually takes care of calling
3281 dnl __cxa_finalize when the library doesn't call it itself, which makes it
3282 dnl safe not to link crtbegin. Besides, previous versions of the NDK didn't
3283 dnl link crtbegin and crtend at all.
3284 if test -n "$MOZ_LINKER" -a "$OS_TARGET" = "Android"; then
3285   AC_CACHE_CHECK([whether the CRT objects have text relocations],
3286     ac_cv_crt_has_text_relocations,
3287     [echo 'int foo() { return 0; }' > conftest.cpp
3288      if AC_TRY_COMMAND(${CXX-g++} -o conftest${DLL_SUFFIX} $CXXFLAGS $DSO_LDOPTS $LDFLAGS conftest.cpp $LIBS 1>&5) &&
3289         test -s conftest${DLL_SUFFIX}; then
3290        if ${TOOLCHAIN_PREFIX}readelf -d conftest${DLL_SUFFIX} | grep TEXTREL > /dev/null; then
3291          ac_cv_crt_has_text_relocations=yes
3292        else
3293          ac_cv_crt_has_text_relocations=no
3294        fi
3295      else
3296        AC_ERROR([couldn't compile a simple C file])
3297      fi
3298      rm -rf conftest*])
3299   if test "$ac_cv_crt_has_text_relocations" = yes; then
3300     dnl While we want libraries to skip the CRT files, we don't want
3301     dnl executables to be treated the same way. We thus set the flag
3302     dnl in DSO_LDOPTS and not LDFLAGS. However, to pass it to nspr,
3303     dnl we need to use LDFLAGS because nspr doesn't inherit DSO_LDOPTS.
3304     dnl Using LDFLAGS in nspr is safe, since we only really build
3305     dnl libraries there.
3306     DSO_LDOPTS="$DSO_LDOPTS -nostartfiles"
3307     NSPR_LDFLAGS="$NSPR_LDFLAGS -nostartfiles"
3308   fi
3311 dnl Check for the existence of various allocation headers/functions
3313 MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h"
3314 MALLOC_H=
3316 for file in $MALLOC_HEADERS; do
3317   MOZ_CHECK_HEADER($file, [MALLOC_H=$file])
3318   if test "$MALLOC_H" != ""; then
3319     AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
3320     break
3321   fi
3322 done
3324 AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
3326 AC_CHECK_FUNCS(malloc_usable_size)
3328 dnl See if compiler supports some gcc-style attributes
3330 AC_CACHE_CHECK(for __attribute__((always_inline)),
3331                ac_cv_attribute_always_inline,
3332                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
3333                                [],
3334                                ac_cv_attribute_always_inline=yes,
3335                                ac_cv_attribute_always_inline=no)])
3337 AC_CACHE_CHECK(for __attribute__((malloc)),
3338                ac_cv_attribute_malloc,
3339                [AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
3340                                [],
3341                                ac_cv_attribute_malloc=yes,
3342                                ac_cv_attribute_malloc=no)])
3344 AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
3345                ac_cv_attribute_warn_unused,
3346                [AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
3347                                [],
3348                                ac_cv_attribute_warn_unused=yes,
3349                                ac_cv_attribute_warn_unused=no)])
3351 dnl End of C++ language/feature checks
3352 AC_LANG_C
3354 dnl ========================================================
3355 dnl =  Internationalization checks
3356 dnl ========================================================
3358 dnl Internationalization and Locale support is different
3359 dnl on various UNIX platforms.  Checks for specific i18n
3360 dnl features go here.
3362 dnl check for LC_MESSAGES
3363 AC_CACHE_CHECK(for LC_MESSAGES,
3364                ac_cv_i18n_lc_messages,
3365                [AC_TRY_COMPILE([#include <locale.h>],
3366                                [int category = LC_MESSAGES;],
3367                                ac_cv_i18n_lc_messages=yes,
3368                                ac_cv_i18n_lc_messages=no)])
3369 if test "$ac_cv_i18n_lc_messages" = yes; then
3370    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
3373 AC_HAVE_FUNCS(localeconv)
3374 fi # ! SKIP_COMPILER_CHECKS
3376 TARGET_XPCOM_ABI=
3377 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
3378     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
3381 dnl Mozilla specific options
3382 dnl ========================================================
3383 dnl The macros used for command line options
3384 dnl are defined in build/autoconf/altoptions.m4.
3386 dnl If the compiler supports these attributes, define them as
3387 dnl convenience macros.
3388 if test "$ac_cv_attribute_malloc" = yes ; then
3389   AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
3390 else
3391   AC_DEFINE(NS_ATTR_MALLOC,)
3394 if test "$ac_cv_attribute_warn_unused" = yes ; then
3395   AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
3396 else
3397   AC_DEFINE(NS_WARN_UNUSED_RESULT,)
3400 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
3401 dnl features that Windows actually does support.
3403 if test -n "$SKIP_COMPILER_CHECKS"; then
3404    dnl Windows has malloc.h
3405    AC_DEFINE(MALLOC_H, [<malloc.h>])
3406    AC_DEFINE(HAVE_FORCEINLINE)
3407    AC_DEFINE(HAVE_LOCALECONV)
3408 fi # SKIP_COMPILER_CHECKS
3410 dnl ========================================================
3411 dnl =
3412 dnl = Check for external package dependencies
3413 dnl =
3414 dnl ========================================================
3415 MOZ_ARG_HEADER(External Packages)
3417 MOZ_ARG_WITH_STRING(libxul-sdk,
3418 [  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>],
3419   LIBXUL_SDK_DIR=$withval)
3421 if test "$LIBXUL_SDK_DIR" = "yes"; then
3422     AC_MSG_ERROR([--with-libxul-sdk must specify a path])
3423 elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
3424     LIBXUL_SDK=`cd "$LIBXUL_SDK_DIR" && pwd`
3426     if test ! -f "$LIBXUL_SDK/include/xpcom-config.h"; then
3427         AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
3428     fi
3431 AC_SUBST(LIBXUL_SDK)
3433 if test -n "$LIBXUL_SDK"; then
3434     LIBXUL_DIST="$LIBXUL_SDK"
3435 else
3436     LIBXUL_DIST="$MOZ_BUILD_ROOT/dist"
3438 AC_SUBST(LIBXUL_DIST)
3440 SYSTEM_LIBXUL=
3442 MOZ_ARG_WITH_BOOL(system-libxul,
3443 [  --with-system-libxul    Use system installed libxul SDK],
3444     SYSTEM_LIBXUL=1)
3446 dnl ========================================================
3447 dnl = If NSPR was not detected in the system,
3448 dnl = use the one in the source tree (mozilla/nsprpub)
3449 dnl ========================================================
3450 MOZ_ARG_WITH_BOOL(system-nspr,
3451 [  --with-system-nspr      Use system installed NSPR],
3452     _USE_SYSTEM_NSPR=1 )
3454 if test -n "$_USE_SYSTEM_NSPR"; then
3455     AM_PATH_NSPR(4.10.6, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])])
3458 if test -n "$MOZ_NATIVE_NSPR"; then
3459     _SAVE_CFLAGS=$CFLAGS
3460     CFLAGS="$CFLAGS $NSPR_CFLAGS"
3461     AC_TRY_COMPILE([#include "prtypes.h"],
3462                 [#ifndef PR_STATIC_ASSERT
3463                  #error PR_STATIC_ASSERT not defined or requires including prtypes.h
3464                  #endif],
3465                 [MOZ_NATIVE_NSPR=1],
3466                 AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT or including prtypes.h does not provide it]))
3467     AC_TRY_COMPILE([#include "prtypes.h"],
3468                 [#ifndef PR_UINT64
3469                  #error PR_UINT64 not defined or requires including prtypes.h
3470                  #endif],
3471                 [MOZ_NATIVE_NSPR=1],
3472                 AC_MSG_ERROR([system NSPR does not support PR_UINT64 or including prtypes.h does not provide it]))
3473     CFLAGS=$_SAVE_CFLAGS
3474 else
3475     if test -z "$LIBXUL_SDK"; then
3476         NSPR_CFLAGS="-I${LIBXUL_DIST}/include/nspr"
3477         if test -n "$GNU_CC"; then
3478             NSPR_LIBS="-L${LIBXUL_DIST}/lib -lnspr${NSPR_VERSION} -lplc${NSPR_VERSION} -lplds${NSPR_VERSION}"
3479         else
3480             NSPR_LIBS="${LIBXUL_DIST}/lib/nspr${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plc${NSPR_VERSION}.lib ${LIBXUL_DIST}/lib/plds${NSPR_VERSION}.lib "
3481         fi
3482     else
3483         NSPR_CFLAGS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --includedir="${LIBXUL_DIST}/include/nspr" --cflags`
3484         NSPR_LIBS=`"${LIBXUL_DIST}"/sdk/bin/nspr-config --prefix="${LIBXUL_DIST}" --libdir="${LIBXUL_DIST}"/lib --libs`
3485     fi
3488 dnl set GRE_MILESTONE
3489 dnl ========================================================
3490 if test -n "$LIBXUL_SDK"; then
3491     GRE_MILESTONE=`$PYTHON "$_topsrcdir"/config/printconfigsetting.py "$LIBXUL_DIST"/bin/platform.ini Build Milestone`
3492 else
3493     GRE_MILESTONE=`tail -n 1 "$_topsrcdir"/config/milestone.txt 2>/dev/null || tail -1 "$_topsrcdir"/config/milestone.txt`
3495 AC_SUBST(GRE_MILESTONE)
3497 # set RELEASE_BUILD and NIGHTLY_BUILD variables depending on the cycle we're in
3498 # The logic works like this:
3499 # - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
3500 # - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
3501 # - otherwise, we're building Release/Beta (define RELEASE_BUILD)
3502 case "$GRE_MILESTONE" in
3503   *a1*)
3504       NIGHTLY_BUILD=1
3505       AC_DEFINE(NIGHTLY_BUILD)
3506       ;;
3507   *a*)
3508       ;;
3509   *)
3510       RELEASE_BUILD=1
3511       AC_DEFINE(RELEASE_BUILD)
3512       ;;
3513 esac
3514 AC_SUBST(NIGHTLY_BUILD)
3515 AC_SUBST(RELEASE_BUILD)
3517 dnl ========================================================
3518 dnl Disable compiling sources in unified mode.
3519 dnl ========================================================
3521 if test -z "$NIGHTLY_BUILD"; then
3522     MOZ_DISABLE_UNIFIED_COMPILATION=1
3525 MOZ_ARG_DISABLE_BOOL(unified-compilation,
3526 [  --disable-unified-compilation
3527                           Disable unified compilation of some C/C++ sources],
3528     MOZ_DISABLE_UNIFIED_COMPILATION=1,
3529     MOZ_DISABLE_UNIFIED_COMPILATION=)
3530 AC_SUBST(MOZ_DISABLE_UNIFIED_COMPILATION)
3532 dnl ========================================================
3533 dnl Multiprocess Firefox Nightly Testing UI
3534 dnl To be removed in Bug 1003313
3535 dnl ========================================================
3536 if test -z "$NIGHTLY_BUILD"; then
3537     E10S_TESTING_ONLY=1
3540 AC_SUBST(E10S_TESTING_ONLY)
3542 dnl ========================================================
3543 dnl system libevent Support
3544 dnl ========================================================
3545 MOZ_ARG_WITH_STRING(system-libevent,
3546 [  --with-system-libevent[=PFX]
3547                           Use system libevent [installed at prefix PFX]],
3548     LIBEVENT_DIR=$withval)
3550 _SAVE_CFLAGS=$CFLAGS
3551 _SAVE_LDFLAGS=$LDFLAGS
3552 _SAVE_LIBS=$LIBS
3553 if test "$LIBEVENT_DIR" = yes; then
3554     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
3555         MOZ_NATIVE_LIBEVENT=1,
3556         LIBEVENT_DIR=/usr)
3558 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
3559     MOZ_NATIVE_LIBEVENT=
3560 elif test -z "$MOZ_NATIVE_LIBEVENT"; then
3561     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
3562     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
3563     MOZ_CHECK_HEADER(event.h,
3564         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
3565              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
3566          fi],
3567         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
3568     AC_CHECK_LIB(event, event_init,
3569                  [MOZ_NATIVE_LIBEVENT=1
3570                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
3571                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
3572                  [MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
3574 CFLAGS=$_SAVE_CFLAGS
3575 LDFLAGS=$_SAVE_LDFLAGS
3576 LIBS=$_SAVE_LIBS
3578 AC_SUBST(MOZ_NATIVE_LIBEVENT)
3579 AC_SUBST(MOZ_LIBEVENT_CFLAGS)
3580 AC_SUBST(MOZ_LIBEVENT_LIBS)
3582 dnl ========================================================
3583 dnl = If NSS was not detected in the system,
3584 dnl = use the one in the source tree (mozilla/security/nss)
3585 dnl ========================================================
3587 MOZ_ARG_WITH_BOOL(system-nss,
3588 [  --with-system-nss       Use system installed NSS],
3589     _USE_SYSTEM_NSS=1 )
3591 if test -n "$_USE_SYSTEM_NSS"; then
3592     AM_PATH_NSS(3.16, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
3595 if test -n "$MOZ_NATIVE_NSS"; then
3596    NSS_LIBS="$NSS_LIBS -lcrmf"
3597 else
3598    NSS_CFLAGS='-I$(LIBXUL_DIST)/include/nss'
3600    if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT"; then
3601        NSS_LIBS="\
3602         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)crmf.\$(LIB_SUFFIX) \
3603         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)smime$NSS_VERSION.\$(LIB_SUFFIX) \
3604         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)ssl$NSS_VERSION.\$(LIB_SUFFIX) \
3605         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nss$NSS_VERSION.\$(LIB_SUFFIX) \
3606         \$(LIBXUL_DIST)/lib/\$(LIB_PREFIX)nssutil$NSS_VERSION.\$(LIB_SUFFIX)"
3607    else
3608        NSS_LIBS='$(LIBS_DIR)'" -lcrmf -lsmime$NSS_VERSION -lssl$NSS_VERSION -lnss$NSS_VERSION -lnssutil$NSS_VERSION"
3609    fi
3612 dnl ======================
3613 dnl Detect yasm
3614 dnl ======================
3616 AC_MSG_CHECKING([for YASM assembler])
3617 AC_CHECK_PROGS(YASM, yasm, "")
3619 if test -n "$YASM"; then
3620   dnl Pull out yasm's version string
3621   YASM_VERSION=`yasm --version | $AWK '/^yasm/ { print $2 }'`
3622   _YASM_MAJOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $1 }'`
3623   _YASM_MINOR_VERSION=`echo ${YASM_VERSION} | $AWK -F\. '{ print $2 }'`
3624   _YASM_RELEASE=`      echo ${YASM_VERSION} | $AWK -F\. '{ print $3 }'`
3625   _YASM_BUILD=`        echo ${YASM_VERSION} | $AWK -F\. '{ print $4 }'`
3628 if test -z "$SKIP_LIBRARY_CHECKS"; then
3629 dnl system JPEG support
3630 dnl ========================================================
3631 MOZ_ARG_WITH_STRING(system-jpeg,
3632 [  --with-system-jpeg[=PFX]
3633                           Use system libjpeg [installed at prefix PFX]],
3634     JPEG_DIR=$withval)
3636 _SAVE_CFLAGS=$CFLAGS
3637 _SAVE_LDFLAGS=$LDFLAGS
3638 _SAVE_LIBS=$LIBS
3639 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
3640     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
3641     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
3643 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
3644     MOZ_NATIVE_JPEG=
3645 else
3646     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_NATIVE_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_NATIVE_JPEG=)
3649 if test "$MOZ_NATIVE_JPEG" = 1; then
3650     AC_TRY_COMPILE([ #include <stdio.h>
3651                      #include <sys/types.h>
3652                      #include <jpeglib.h> ],
3653                    [ #if JPEG_LIB_VERSION < $MOZJPEG
3654                      #error "Insufficient JPEG library version ($MOZJPEG required)."
3655                      #endif
3656                      #ifndef JCS_EXTENSIONS
3657                      #error "libjpeg-turbo JCS_EXTENSIONS required"
3658                      #endif
3659                      ],
3660                    MOZ_NATIVE_JPEG=1,
3661                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
3663 CFLAGS=$_SAVE_CFLAGS
3664 LDFLAGS=$_SAVE_LDFLAGS
3665 LIBS=$_SAVE_LIBS
3667 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_NATIVE_JPEG" = 1; then
3668     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
3669     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
3671 fi # SKIP_LIBRARY_CHECKS
3673 dnl system ZLIB support
3674 dnl ========================================================
3675 MOZ_ZLIB_CHECK([1.2.3])
3677 if test "$MOZ_NATIVE_ZLIB" != 1; then
3678     MOZ_ZLIB_CFLAGS="-I${_topsrcdir}/modules/zlib/src"
3679     MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,'"$MOZ_BUILD_ROOT"'/modules/zlib/src)'
3682 if test "$MOZ_LINKER" = 1 -a "$MOZ_NATIVE_ZLIB" != 1; then
3683     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
3686 MOZ_PNG_ARM_NEON=
3688 if test -z "$SKIP_LIBRARY_CHECKS"; then
3689 dnl system BZIP2 Support
3690 dnl ========================================================
3691 MOZ_ARG_WITH_STRING(system-bz2,
3692 [  --with-system-bz2[=PFX]
3693                           Use system libbz2 [installed at prefix PFX]],
3694     BZ2_DIR=$withval)
3696 _SAVE_CFLAGS=$CFLAGS
3697 _SAVE_LDFLAGS=$LDFLAGS
3698 _SAVE_LIBS=$LIBS
3699 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
3700     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
3701     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
3703 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
3704     MOZ_NATIVE_BZ2=
3705 else
3706     AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_NATIVE_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
3707     [MOZ_NATIVE_BZ2= MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS=])
3709 CFLAGS=$_SAVE_CFLAGS
3710 LDFLAGS=$_SAVE_LDFLAGS
3711 LIBS=$_SAVE_LIBS
3713 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_NATIVE_BZ2" = 1; then
3714     MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
3715     MOZ_BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
3718 dnl ========================================================
3719 dnl system PNG Support
3720 dnl ========================================================
3721 MOZ_ARG_WITH_STRING(system-png,
3722 [  --with-system-png[=PFX]
3723                           Use system libpng [installed at prefix PFX]],
3724     PNG_DIR=$withval)
3726 _SAVE_CFLAGS=$CFLAGS
3727 _SAVE_LDFLAGS=$LDFLAGS
3728 _SAVE_LIBS=$LIBS
3729 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
3730     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
3731     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
3733 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
3734     MOZ_NATIVE_PNG=
3735 else
3736     AC_CHECK_LIB(png, png_get_valid, [MOZ_NATIVE_PNG=1 MOZ_PNG_LIBS="-lpng"],
3737                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
3738     AC_CHECK_LIB(png, png_get_acTL, ,
3739                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
3741 if test "$MOZ_NATIVE_PNG" = 1; then
3742     AC_TRY_COMPILE([ #include <stdio.h>
3743                      #include <sys/types.h>
3744                      #include <png.h> ],
3745                    [ #if PNG_LIBPNG_VER < $MOZPNG
3746                      #error "Insufficient libpng version ($MOZPNG required)."
3747                      #endif
3748                      #ifndef PNG_UINT_31_MAX
3749                      #error "Insufficient libpng version."
3750                      #endif ],
3751                    MOZ_NATIVE_PNG=1,
3752                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
3754 CFLAGS=$_SAVE_CFLAGS
3755 LDFLAGS=$_SAVE_LDFLAGS
3756 LIBS=$_SAVE_LIBS
3758 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_NATIVE_PNG" = 1; then
3759     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
3760     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
3763 MOZ_PNG_ARM_NEON_CHECK=
3764 if test "$MOZ_NATIVE_PNG" != 1 -a "$CPU_ARCH" = "arm" ; then
3765     MOZ_ARG_ENABLE_STRING(png-arm-neon-support,
3766         [  --enable-png-arm-neon-support=TYPE
3767              Options include:
3768                  no
3769                  check (default)
3770                  nocheck (faster but unsafe)],
3771         [MOZ_PNG_ARM_NEON_SUPPORT=$enableval ] )
3772     case "$MOZ_PNG_ARM_NEON_SUPPORT" in
3773         no)
3774             # enable-png-arm-neon-support = no
3775             ;;
3776         nocheck)
3777             # enable-png-arm-neon-support = nocheck
3778             MOZ_PNG_ARM_NEON=1
3779             ;;
3780         *)
3781             MOZ_PNG_ARM_NEON=1
3782             MOZ_PNG_ARM_NEON_CHECK=1
3783             ;;
3784     esac
3787 AC_SUBST(MOZ_PNG_ARM_NEON_CHECK)
3789 fi # SKIP_LIBRARY_CHECKS
3791 AC_SUBST(MOZ_PNG_ARM_NEON)
3793 dnl ========================================================
3794 dnl system HunSpell Support
3795 dnl ========================================================
3796 MOZ_ARG_ENABLE_BOOL(system-hunspell,
3797 [  --enable-system-hunspell
3798                           Use system hunspell (located with pkgconfig)],
3799     MOZ_NATIVE_HUNSPELL=1 )
3801 if test -n "$MOZ_NATIVE_HUNSPELL"; then
3802     PKG_CHECK_MODULES(MOZ_HUNSPELL, hunspell)
3805 AC_SUBST(MOZ_NATIVE_HUNSPELL)
3807 dnl ========================================================
3808 dnl system libffi Support
3809 dnl ========================================================
3810 MOZ_CONFIG_FFI()
3812 if test -n "$MOZ_NATIVE_FFI"; then
3813     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS"
3816 # split JS out by default to avoid VS2005 PGO crash (bug 591836).
3817 if test "$OS_ARCH" = "WINNT"; then
3818   JS_SHARED_LIBRARY=1
3821 MOZ_ARG_ENABLE_BOOL(shared-js,
3822 [  --enable-shared-js
3823                           Create a shared JavaScript library.],
3824     JS_SHARED_LIBRARY=1,
3825     JS_SHARED_LIBRARY=)
3827 dnl ========================================================
3828 dnl Java SDK support
3829 dnl ========================================================
3831 JAVA_BIN_PATH=
3832 MOZ_ARG_WITH_STRING(java-bin-path,
3833 [  --with-java-bin-path=dir
3834                           Location of Java binaries (java, javac, jar)],
3835     JAVA_BIN_PATH=$withval)
3837 dnl ========================================================
3838 dnl =
3839 dnl = Application
3840 dnl =
3841 dnl ========================================================
3843 MOZ_ARG_HEADER(Application)
3845 ENABLE_TESTS=1
3846 ENABLE_SYSTEM_EXTENSION_DIRS=1
3847 MOZ_BRANDING_DIRECTORY=
3848 MOZ_OFFICIAL_BRANDING=
3849 MOZ_FEEDS=1
3850 MOZ_WEBAPP_RUNTIME=
3851 MOZ_JSDEBUGGER=1
3852 MOZ_AUTH_EXTENSION=1
3853 MOZ_RAW=
3854 MOZ_VORBIS=
3855 MOZ_TREMOR=
3856 MOZ_WAVE=1
3857 MOZ_SAMPLE_TYPE_FLOAT32=
3858 MOZ_SAMPLE_TYPE_S16=
3859 MOZ_OPUS=1
3860 MOZ_WEBM=1
3861 MOZ_GSTREAMER=
3862 MOZ_DIRECTSHOW=
3863 MOZ_WMF=
3864 MOZ_FMP4=
3865 MOZ_FFMPEG=
3866 MOZ_WEBRTC=1
3867 MOZ_PEERCONNECTION=
3868 MOZ_SRTP=
3869 MOZ_WEBRTC_SIGNALING=
3870 MOZ_WEBRTC_ASSERT_ALWAYS=1
3871 MOZ_SCTP=
3872 MOZ_MEDIA_PLUGINS=
3873 MOZ_MEDIA_NAVIGATOR=
3874 MOZ_OMX_PLUGIN=
3875 MOZ_VPX=
3876 MOZ_VPX_ERROR_CONCEALMENT=
3877 MOZ_WEBSPEECH=1
3878 VPX_AS=
3879 VPX_ASFLAGS=
3880 VPX_AS_DASH_C_FLAG=
3881 VPX_AS_CONVERSION=
3882 VPX_ASM_SUFFIX=
3883 VPX_X86_ASM=
3884 VPX_ARM_ASM=
3885 LIBJPEG_TURBO_AS=
3886 LIBJPEG_TURBO_ASFLAGS=
3887 LIBJPEG_TURBO_X86_ASM=
3888 LIBJPEG_TURBO_X64_ASM=
3889 LIBJPEG_TURBO_ARM_ASM=
3890 MOZ_LOOP=$NIGHTLY_BUILD
3891 MOZ_PERMISSIONS=1
3892 MOZ_PLACES=1
3893 MOZ_SOCIAL=1
3894 MOZ_PREF_EXTENSIONS=1
3895 MOZ_PROFILELOCKING=1
3896 MOZ_REFLOW_PERF=
3897 MOZ_SAFE_BROWSING=
3898 MOZ_HELP_VIEWER=
3899 MOZ_SPELLCHECK=1
3900 MOZ_ANDROID_OMTC=
3901 MOZ_TOOLKIT_SEARCH=1
3902 MOZ_UI_LOCALE=en-US
3903 MOZ_UNIVERSALCHARDET=1
3904 MOZ_URL_CLASSIFIER=
3905 MOZ_XUL=1
3906 MOZ_ZIPWRITER=1
3907 NS_PRINTING=1
3908 MOZ_PDF_PRINTING=
3909 MOZ_DISABLE_CRYPTOLEGACY=
3910 NSS_DISABLE_DBM=
3911 NECKO_COOKIES=1
3912 NECKO_PROTOCOLS_DEFAULT="about app data file ftp http res viewsource websocket wyciwyg device"
3913 if test -n "$MOZ_RTSP"; then
3914   NECKO_PROTOCOLS_DEFAULT="$NECKO_PROTOCOLS_DEFAULT rtsp"
3916 USE_ARM_KUSER=
3917 BUILD_CTYPES=1
3918 MOZ_USE_NATIVE_POPUP_WINDOWS=
3919 MOZ_ANDROID_HISTORY=
3920 MOZ_WEBSMS_BACKEND=
3921 MOZ_ANDROID_BEAM=
3922 MOZ_LOCALE_SWITCHER=
3923 ACCESSIBILITY=1
3924 MOZ_TIME_MANAGER=
3925 MOZ_PAY=
3926 MOZ_AUDIO_CHANNEL_MANAGER=
3927 NSS_NO_LIBPKIX=
3928 MOZ_CONTENT_SANDBOX=
3929 MOZ_CONTENT_SANDBOX_REPORTER=1
3930 JSGC_USE_EXACT_ROOTING=
3931 JSGC_GENERATIONAL=
3933 case "$target_os" in
3934     mingw*)
3935         NS_ENABLE_TSF=1
3936         AC_DEFINE(NS_ENABLE_TSF)
3937         ;;
3938 esac
3940 case "${target}" in
3941     *-android*|*-linuxandroid*)
3942         if test "$CPU_ARCH" = "arm" ; then
3943           USE_ARM_KUSER=1
3944         fi
3946         NSS_DISABLE_DBM=1
3947         MOZ_THEME_FASTSTRIPE=1
3948         MOZ_TREE_FREETYPE=1
3949         MOZ_MEMORY=1
3950         MOZ_RAW=1
3951         ;;
3953 esac
3955 MOZ_ARG_WITH_STRING(external-source-dir,
3956 [  --with-external-source-dir=dir
3957                           External directory containing additional build files.],
3958 [ EXTERNAL_SOURCE_DIR=$withval])
3959 AC_SUBST(EXTERNAL_SOURCE_DIR)
3961 MOZ_ARG_ENABLE_STRING(application,
3962 [  --enable-application=APP
3963                           Options include:
3964                             browser (Firefox)
3965                             xulrunner
3966                             tools/update-packaging (AUS-related packaging tools)],
3967 [ MOZ_BUILD_APP=$enableval ] )
3969 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
3970 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
3971   XULRUNNER_STUB_NAME=$withval)
3973 if test -z "$XULRUNNER_STUB_NAME"; then
3974   case "$target_os" in
3975   darwin*)
3976     XULRUNNER_STUB_NAME=xulrunner
3977     ;;
3978   *)
3979     XULRUNNER_STUB_NAME=xulrunner-stub
3980   esac
3982 AC_SUBST(XULRUNNER_STUB_NAME)
3984 AC_MSG_CHECKING([for application to build])
3985 if test -z "$MOZ_BUILD_APP"; then
3986   AC_MSG_RESULT([browser])
3987   MOZ_BUILD_APP=browser
3988 else
3989   # "mobile" no longer exists.
3990   if test "$MOZ_BUILD_APP" = "mobile" ; then
3991     AC_MSG_RESULT([none])
3992     AC_MSG_ERROR([--enable-application=mobile is no longer supported.])
3993   fi
3994   # We have a valid application only if it has a build.mk file in its top
3995   # directory.
3996   if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
3997     AC_MSG_RESULT([none])
3998     AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
3999   else
4000     AC_MSG_RESULT([$MOZ_BUILD_APP])
4001   fi
4004 # The app update channel is 'default' when not supplied. The value is used in
4005 # the application's confvars.sh so it must be set before confvars.sh is called.
4006 MOZ_ARG_ENABLE_STRING([update-channel],
4007 [  --enable-update-channel=CHANNEL
4008                           Select application update channel (default=default)],
4009     MOZ_UPDATE_CHANNEL=`echo $enableval | tr A-Z a-z`)
4011 if test -z "$MOZ_UPDATE_CHANNEL"; then
4012     MOZ_UPDATE_CHANNEL=default
4014 AC_DEFINE_UNQUOTED(MOZ_UPDATE_CHANNEL, $MOZ_UPDATE_CHANNEL)
4015 AC_SUBST(MOZ_UPDATE_CHANNEL)
4017 # Allow to specify a Mozilla API key file that contains the secret key to be
4018 # used for various Mozilla API requests.
4019 MOZ_ARG_WITH_STRING(mozilla-api-keyfile,
4020 [  --with-mozilla-api-keyfile=file   Use the secret key contained in the given keyfile for Mozilla API requests],
4021   MOZ_MOZILLA_API_KEY=`cat $withval`)
4022 if test -z "$MOZ_MOZILLA_API_KEY"; then
4023     MOZ_MOZILLA_API_KEY=no-mozilla-api-key
4025 AC_SUBST(MOZ_MOZILLA_API_KEY)
4027 # Allow to specify a Google API key file that contains the secret key to be
4028 # used for various Google API requests.
4029 MOZ_ARG_WITH_STRING(google-api-keyfile,
4030 [  --with-google-api-keyfile=file   Use the secret key contained in the given keyfile for Google API requests],
4031   MOZ_GOOGLE_API_KEY=`cat $withval`)
4032 if test -z "$MOZ_GOOGLE_API_KEY"; then
4033     MOZ_GOOGLE_API_KEY=no-google-api-key
4035 AC_SUBST(MOZ_GOOGLE_API_KEY)
4037 # Allow specifying a Bing API key file that contains the client ID and the
4038 # secret key to be used for the Bing Translation API requests.
4039 MOZ_ARG_WITH_STRING(bing-api-keyfile,
4040 [  --with-bing-api-keyfile=file   Use the client id and secret key contained in the given keyfile for Bing API requests],
4041  [MOZ_BING_API_CLIENTID=`cat $withval | cut -f 1 -d " "`
4042   MOZ_BING_API_KEY=`cat $withval | cut -f 2 -d " "`])
4043 if test -z "$MOZ_BING_API_CLIENTID"; then
4044     MOZ_BING_API_CLIENTID=no-bing-api-clientid
4045     MOZ_BING_API_KEY=no-bing-api-key
4047 AC_SUBST(MOZ_BING_API_CLIENTID)
4048 AC_SUBST(MOZ_BING_API_KEY)
4050 # Allow the application to influence configure with a confvars.sh script.
4051 AC_MSG_CHECKING([if app-specific confvars.sh exists])
4052 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
4053   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
4054   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
4055 else
4056   AC_MSG_RESULT([no])
4059 # Allow influencing configure with a defines.sh script.
4060 . "${srcdir}/build/defines.sh"
4062 # If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
4063 # set in defines.sh
4064 if test "$BUILDING_RELEASE"; then
4065   # Override value in defines.sh, if any
4066   EARLY_BETA_OR_EARLIER=
4067 elif test "$EARLY_BETA_OR_EARLIER"; then
4068   AC_DEFINE(EARLY_BETA_OR_EARLIER)
4070 AC_SUBST(EARLY_BETA_OR_EARLIER)
4072 # Allow the application to provide a subconfigure script
4073 if test -f "${srcdir}/${MOZ_BUILD_APP}/configure.in" ; then
4074   do_output_subdirs() {
4075     if test -n "$_subconfigure_subdirs"; then
4076       AC_MSG_ERROR([Cannot specify more than one sub-sub-configure])
4077      fi
4078     _subconfigure_subdir="$1"
4079     _subconfigure_config_args="$ac_configure_args"
4080   }
4081   tmpscript=`$PYTHON -c 'import os, tempfile; print tempfile.mktemp(prefix="subscript.").replace(os.sep, "/")'` || exit 1
4082   m4 "${srcdir}/build/autoconf/subconfigure.m4" \
4083      "${srcdir}/build/autoconf/altoptions.m4" \
4084      "${srcdir}/${MOZ_BUILD_APP}/configure.in" > $tmpscript
4085   . $tmpscript
4086   rm -f $tmpscript
4089 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
4090 MOZ_ARG_WITH_STRING(app-name,
4091 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
4092 WITH_APP_NAME=$withval,
4095 if test -n "$WITH_APP_NAME" ; then
4096     MOZ_APP_NAME="$WITH_APP_NAME"
4099 MOZ_ARG_WITH_STRING(app-basename,
4100 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
4101 WITH_APP_BASENAME=$withval,
4104 if test -n "$WITH_APP_BASENAME" ; then
4105     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
4108 # Now is a good time to test for logic errors, define mismatches, etc.
4109 case "$MOZ_BUILD_APP" in
4110 xulrunner)
4111   if test "$LIBXUL_SDK"; then
4112     AC_MSG_ERROR([Building XULRunner --with-libxul-sdk doesn't make sense; XULRunner provides the libxul SDK.])
4113   fi
4114   ;;
4115 esac
4117 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
4118 # that haven't made a confvars.sh yet. Don't add new stuff here, use
4119 # MOZ_BUILD_APP.
4120 case "$MOZ_BUILD_APP" in
4121 browser)
4122   AC_DEFINE(MOZ_PHOENIX)
4123   ;;
4125 xulrunner)
4126   AC_DEFINE(MOZ_XULRUNNER)
4127   ;;
4128 b2g)
4129   AC_DEFINE(MOZ_B2G)
4130   ;;
4131 b2g/dev)
4132   AC_DEFINE(MOZ_B2G)
4133   AC_DEFINE(MOZ_MULET)
4134   ;;
4135 esac
4137 AC_SUBST(MOZ_BUILD_APP)
4138 AC_SUBST(MOZ_PHOENIX)
4139 AC_SUBST(MOZ_XULRUNNER)
4140 AC_SUBST(MOZ_B2G)
4141 AC_SUBST(MOZ_MULET)
4142 AC_SUBST(MOZ_B2G_VERSION)
4144 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
4146 dnl ========================================================
4147 dnl Check Android SDK version depending on mobile target.
4148 dnl ========================================================
4150 if test -z "$gonkdir" ; then
4151     # Minimum Android SDK API Level we require.
4152     case "$MOZ_BUILD_APP" in
4153     mobile/android)
4154         android_min_api_level=17
4155         case "$target" in
4156         *-android*|*-linuxandroid*)
4157             :
4158             ;;
4159         *)
4160             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])
4161             ;;
4162         esac
4163         ;;
4164     esac
4166     MOZ_ANDROID_SDK($android_min_api_level)
4169 dnl ========================================================
4170 dnl =
4171 dnl = Toolkit Options
4172 dnl =
4173 dnl ========================================================
4174 MOZ_ARG_HEADER(Toolkit Options)
4176     dnl ========================================================
4177     dnl = Select the default toolkit
4178     dnl ========================================================
4179     MOZ_ARG_ENABLE_STRING(default-toolkit,
4180     [  --enable-default-toolkit=TK
4181                           Select default toolkit
4182                           Platform specific defaults:
4183                             Mac OS X - cairo-cocoa
4184                             Win32 - cairo-windows
4185                             * - cairo-gtk2
4186                             * - cairo-gtk3
4187                             * - cairo-qt],
4188     [ _DEFAULT_TOOLKIT=$enableval ],
4189     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
4191     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
4192         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
4193         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
4194         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk3" \
4195         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
4196         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
4197         -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
4198         -o "$_DEFAULT_TOOLKIT" = "cairo-android" \
4199         -o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
4200     then
4201         dnl nglayout only supports building with one toolkit,
4202         dnl so ignore everything after the first comma (",").
4203         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
4204     else
4205         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
4206     fi
4208 MOZ_ARG_WITHOUT_BOOL(x,
4209 [  --without-x              Build without X11],
4210     WITHOUT_X11=1)
4212 dnl ========================================================
4213 dnl = Enable the toolkit as needed                         =
4214 dnl ========================================================
4216 MOZ_WIDGET_GTK=
4218 case "$MOZ_WIDGET_TOOLKIT" in
4220 cairo-windows)
4221     MOZ_WIDGET_TOOLKIT=windows
4222     MOZ_WEBGL=1
4223     MOZ_PDF_PRINTING=1
4224     MOZ_INSTRUMENT_EVENT_LOOP=1
4225     if test -n "$GNU_CC"; then
4226         MOZ_FOLD_LIBS=
4227     fi
4228     ;;
4230 cairo-gtk3)
4231     MOZ_WIDGET_TOOLKIT=gtk3
4232     MOZ_ENABLE_GTK=1
4233     MOZ_ENABLE_GTK3=1
4234     MOZ_ENABLE_XREMOTE=1
4235     MOZ_WEBGL=1
4236     MOZ_GL_DEFAULT_PROVIDER=GLX
4238     AC_DEFINE(MOZ_X11)
4239     MOZ_X11=1
4240     USE_FC_FREETYPE=1
4242     TK_CFLAGS='$(MOZ_GTK3_CFLAGS)'
4243     TK_LIBS='$(MOZ_GTK3_LIBS)'
4244     MOZ_WIDGET_GTK=3
4245     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4246     MOZ_PDF_PRINTING=1
4247     MOZ_INSTRUMENT_EVENT_LOOP=1
4248     ;;
4250 cairo-gtk2|cairo-gtk2-x11)
4251     MOZ_WIDGET_TOOLKIT=gtk2
4252     MOZ_ENABLE_GTK=1
4253     MOZ_ENABLE_GTK2=1
4254     MOZ_ENABLE_XREMOTE=1
4255     MOZ_WEBGL=1
4256     MOZ_GL_DEFAULT_PROVIDER=GLX
4258     AC_DEFINE(MOZ_X11)
4259     MOZ_X11=1
4260     USE_FC_FREETYPE=1
4262     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
4263     TK_LIBS='$(MOZ_GTK2_LIBS)'
4264     AC_DEFINE(MOZ_WIDGET_GTK2)
4265     MOZ_WIDGET_GTK=2
4266     AC_DEFINE_UNQUOTED(MOZ_WIDGET_GTK,$MOZ_WIDGET_GTK)
4267     MOZ_PDF_PRINTING=1
4268     MOZ_INSTRUMENT_EVENT_LOOP=1
4269     ;;
4271 cairo-qt)
4272     MOZ_WIDGET_TOOLKIT=qt
4273     MOZ_ENABLE_QT=1
4274     if test -z "$WITHOUT_X11"; then
4275       MOZ_ENABLE_XREMOTE=1
4276       MOZ_GL_DEFAULT_PROVIDER=GLX
4277       MOZ_X11=1
4278       AC_DEFINE(MOZ_X11)
4279       XT_LIBS=
4280     fi
4282     MOZ_WEBGL=1
4283     USE_FC_FREETYPE=1
4284     TK_CFLAGS='$(MOZ_QT_CFLAGS)'
4285     TK_LIBS='$(MOZ_QT_LIBS)'
4286     AC_DEFINE(MOZ_WIDGET_QT)
4287     MOZ_PDF_PRINTING=1
4288     AC_DEFINE(QT_NO_KEYWORDS)
4289     ;;
4291 cairo-cocoa)
4292     MOZ_WIDGET_TOOLKIT=cocoa
4293     AC_DEFINE(MOZ_WIDGET_COCOA)
4294     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
4295     TK_LIBS='-framework CoreLocation -framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
4296     TK_CFLAGS="-DNO_X11"
4297     CFLAGS="$CFLAGS $TK_CFLAGS"
4298     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4299     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/bin/XUL $(call EXPAND_LIBNAME_PATH,mozalloc,$(LIBXUL_DIST)/bin)'
4300     MOZ_USER_DIR="Mozilla"
4301     MOZ_FS_LAYOUT=bundle
4302     MOZ_WEBGL=1
4303     MOZ_INSTRUMENT_EVENT_LOOP=1
4304     ;;
4306 cairo-uikit)
4307     MOZ_WIDGET_TOOLKIT=uikit
4308     AC_DEFINE(MOZ_WIDGET_UIKIT)
4309     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
4310     TK_CFLAGS="-DNO_X11"
4311     TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
4312     CFLAGS="$CFLAGS $TK_CFLAGS"
4313     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
4314     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/bin/XUL $(call EXPAND_LIBNAME_PATH,mozalloc,$(LIBXUL_DIST)/bin)'
4315     MOZ_USER_DIR="Mozilla"
4316     MOZ_FS_LAYOUT=bundle
4317     ;;
4319 cairo-android)
4320     AC_DEFINE(MOZ_WIDGET_ANDROID)
4321     MOZ_WIDGET_TOOLKIT=android
4322     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4323     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4324     MOZ_WEBGL=1
4325     MOZ_PDF_PRINTING=1
4326     MOZ_INSTRUMENT_EVENT_LOOP=1
4327     ;;
4329 cairo-gonk)
4330     XPCOM_FROZEN_LDOPTS='$(call EXPAND_LIBNAME_PATH,xul mozalloc,$(LIBXUL_DIST)/lib)'
4331     AC_DEFINE(MOZ_WIDGET_GONK)
4332     AC_DEFINE(MOZ_TOUCH)
4333     MOZ_WIDGET_TOOLKIT=gonk
4334     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
4335     TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
4336     MOZ_WEBGL=1
4337     MOZ_PDF_PRINTING=1
4338     MOZ_TOUCH=1
4339     MOZ_INSTRUMENT_EVENT_LOOP=1
4340     ;;
4342 esac
4344 AC_SUBST(MOZ_PDF_PRINTING)
4345 if test "$MOZ_PDF_PRINTING"; then
4346    PDF_SURFACE_FEATURE="#define CAIRO_HAS_PDF_SURFACE 1"
4347    AC_DEFINE(MOZ_PDF_PRINTING)
4350 if test "$MOZ_ENABLE_XREMOTE"; then
4351     AC_DEFINE(MOZ_ENABLE_XREMOTE)
4354 if test "$MOZ_INSTRUMENT_EVENT_LOOP"; then
4355    AC_DEFINE(MOZ_INSTRUMENT_EVENT_LOOP)
4358 if test "$COMPILE_ENVIRONMENT"; then
4359   if test "$MOZ_ENABLE_GTK3"; then
4360     PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4361   fi
4362   if test "$MOZ_ENABLE_GTK"; then
4363     if test "$MOZ_X11"; then
4364       GDK_PACKAGES=gdk-x11-2.0
4365     fi
4367     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
4368   fi
4370 fi # COMPILE_ENVIRONMENT
4372 AC_SUBST(MOZ_FS_LAYOUT)
4374 dnl ========================================================
4375 dnl Use ARM userspace kernel helpers; tell NSPR to enable
4376 dnl their usage and use them in spidermonkey.
4377 dnl ========================================================
4378 MOZ_ARG_WITH_BOOL(arm-kuser,
4379 [  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)],
4380     USE_ARM_KUSER=1,)
4381 if test -n "$USE_ARM_KUSER"; then
4382    AC_DEFINE(USE_ARM_KUSER)
4385 dnl ========================================================
4386 dnl = startup-notification support module
4387 dnl ========================================================
4389 if test "$MOZ_ENABLE_GTK"
4390 then
4391     MOZ_ENABLE_STARTUP_NOTIFICATION=
4393     MOZ_ARG_ENABLE_BOOL(startup-notification,
4394     [  --enable-startup-notification
4395                           Enable startup-notification support (default: disabled) ],
4396         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
4397         MOZ_ENABLE_STARTUP_NOTIFICATION=)
4398     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
4399     then
4400         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
4401                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
4402         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
4403             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
4404             then
4405                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
4406             fi
4407             MOZ_ENABLE_STARTUP_NOTIFICATION=
4408         ])
4409     fi
4411     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
4412         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
4413     fi
4415     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
4417 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
4418 AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
4419 AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
4421 dnl ========================================================
4422 dnl Disable printing
4423 dnl ========================================================
4424 MOZ_ARG_DISABLE_BOOL(printing,
4425 [  --disable-printing      Disable printing support],
4426     NS_PRINTING=,
4427     NS_PRINTING=1)
4429 if test "$NS_PRINTING"; then
4430     AC_DEFINE(NS_PRINTING)
4431     AC_DEFINE(NS_PRINT_PREVIEW)
4434 dnl ========================================================
4435 dnl = QT support
4436 dnl ========================================================
4437 if test "$MOZ_ENABLE_QT"
4438 then
4439     MOZ_ARG_WITH_STRING(qtdir,
4440     [  --with-qtdir=\$dir       Specify Qt directory ],
4441     [ QTDIR=$withval])
4443     if test -z "$QTDIR"; then
4444         AC_CHECK_PROGS(HOST_QMAKE, $HOST_QMAKE qmake, "")
4445     else
4446         HOST_QMAKE="$QTDIR/bin/qmake"
4447     fi
4448     QT_VERSION=`$HOST_QMAKE -v | grep 'Using Qt version' | egrep -o '[[0-9]]+\.[[0-9]]+\.[[0-9]]+'`
4450     if test -z "$QTDIR"; then
4451         case $QT_VERSION in
4452         5.*)
4453             AC_MSG_RESULT("Using qt5: $QT_VERSION")
4454             PKG_CHECK_MODULES(MOZ_QT, Qt5Gui Qt5Network Qt5Core Qt5Quick, ,
4455             [
4456               AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qtbase development packages, (On Ubuntu, you might try installing the packages qtbase5-dev libqt5opengl5-dev.)])
4457             ])
4458             QT5INCDIR=`pkg-config --variable=includedir Qt5Gui`
4459             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QT5INCDIR/QtGui/$QT_VERSION/QtGui"
4460             if test "$NS_PRINTING"; then
4461                 PKG_CHECK_MODULES(MOZ_QT_WIDGETS, Qt5PrintSupport, ,
4462                 [
4463                   AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qtbase widgets development package])
4464                 ])
4465                 MOZ_QT_LIBS="$MOZ_QT_LIBS $MOZ_QT_WIDGETS_LIBS"
4466                 MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $MOZ_QT_WIDGETS_CFLAGS"
4467             fi
4468             ;;
4469         *)
4470             AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION])
4471             ;;
4472         esac
4474         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
4475         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
4476     else
4477         MOZ_QT_CFLAGS="-DQT_SHARED"
4478         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
4479         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
4480         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
4481         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
4482         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
4483         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative"
4484         case $QT_VERSION in
4485         5.*)
4486             AC_MSG_RESULT("Using qt5: $QT_VERSION")
4487             MOZ_QT_LIBS="$MOZ_QT_LIBS -L$QTDIR/lib/ -lQt5Gui -lQt5Network -lQt5Core -lQt5Xml"
4488             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui/$QT_VERSION/QtGui"
4489             if test "$NS_PRINTING"; then
4490                 MOZ_QT_LIBS="$MOZ_QT_LIBS -lQt5Widgets -lQt5PrintSupport"
4491                 MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport"
4492             fi
4493             ;;
4494         *)
4495             AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION])
4496             ;;
4497         esac
4499         HOST_MOC="$QTDIR/bin/moc"
4500         HOST_RCC="$QTDIR/bin/rcc"
4501     fi
4502     if test -z "$HOST_MOC"; then
4503         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is incorrect])
4504     fi
4505     if test -z "$HOST_RCC"; then
4506         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is incorrect])
4507     fi
4509     MOC=$HOST_MOC
4510     RCC=$HOST_RCC
4512     MOZ_ENABLE_QMSYSTEM2=
4513     PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2,
4514                       MOZ_ENABLE_QMSYSTEM2=1,
4515                       MOZ_ENABLE_QMSYSTEM2=)
4517     if test "$MOZ_ENABLE_QMSYSTEM2"; then
4518       MOZ_ENABLE_QMSYSTEM2=1
4519       MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS"
4520       MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS"
4521       AC_DEFINE(MOZ_ENABLE_QMSYSTEM2)
4522     fi
4524     MOZ_ENABLE_QTNETWORK=
4525     PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7,
4526                       MOZ_ENABLE_QTNETWORK=1,
4527                       MOZ_ENABLE_QTNETWORK=)
4529     if test "$MOZ_ENABLE_QTNETWORK"; then
4530       MOZ_ENABLE_QTNETWORK=1
4531       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
4532     fi
4534     MOZ_ENABLE_QTMOBILITY=
4535     PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
4536                       MOZ_ENABLE_QTMOBILITY=1,
4537                       MOZ_ENABLE_QTMOBILITY=)
4538     if test "$MOZ_ENABLE_QTMOBILITY"; then
4539        MOZ_ENABLE_QTMOBILITY=1
4540        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
4541        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
4542        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
4543        AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4544     else
4545        AC_CHECK_LIB(QtSensors, main, [
4546           MOZ_ENABLE_QTMOBILITY=1
4547           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMobility"
4548           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtSensors"
4549           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtFeedback"
4550           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtLocation"
4551           MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
4552        ])
4553     fi
4555     MOZ_ENABLE_QT5FEEDBACK=
4556     PKG_CHECK_MODULES(_QT5FEEDBACK, Qt0Feedback,
4557                       MOZ_ENABLE_QT5FEEDBACK=1,
4558                       MOZ_ENABLE_QT5FEEDBACK=)
4559     if test "$MOZ_ENABLE_QT5FEEDBACK"; then
4560        MOZ_ENABLE_QT5FEEDBACK=1
4561        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QT5FEEDBACK_CFLAGS"
4562        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QT5FEEDBACK_LIBS"
4563        AC_DEFINE(MOZ_ENABLE_QT5FEEDBACK)
4564        AC_SUBST(MOZ_ENABLE_QT5FEEDBACK)
4565     fi
4567     MOZ_ENABLE_QT5GEOPOSITION=
4568     PKG_CHECK_MODULES(_QT5GEOPOSITION, Qt5Positioning,
4569                       MOZ_ENABLE_QT5GEOPOSITION=1,
4570                       MOZ_ENABLE_QT5GEOPOSITION=)
4571     if test "$MOZ_ENABLE_QT5GEOPOSITION"; then
4572        MOZ_ENABLE_QT5GEOPOSITION=1
4573        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QT5GEOPOSITION_CFLAGS"
4574        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QT5GEOPOSITION_LIBS"
4575        AC_DEFINE(MOZ_ENABLE_QT5GEOPOSITION)
4576        AC_SUBST(MOZ_ENABLE_QT5GEOPOSITION)
4577     fi
4579     if test "$MOZ_ENABLE_CONTENTACTION"; then
4580       MOZ_ENABLE_CONTENTACTION=1
4581       AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
4582     fi
4584     MOZ_ENABLE_CONTENTACTION=
4585     PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=)
4586     if test "$MOZ_ENABLE_CONTENTACTION"; then
4587        MOZ_ENABLE_CONTENTACTION=1
4588        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_CONTENTACTION_CFLAGS"
4589        MOZ_QT_LIBS="$MOZ_QT_LIBS $_CONTENTACTION_LIBS"
4590        AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
4591        AC_SUBST(MOZ_ENABLE_CONTENTACTION)
4592     fi
4595 AC_SUBST(GTK_CONFIG)
4596 AC_SUBST(TK_CFLAGS)
4597 AC_SUBST(TK_LIBS)
4599 AC_SUBST(MOZ_ENABLE_GTK2)
4600 AC_SUBST(MOZ_ENABLE_GTK3)
4601 AC_SUBST(MOZ_ENABLE_GTK)
4602 AC_SUBST(MOZ_ENABLE_QT)
4603 AC_SUBST(MOZ_ENABLE_QTNETWORK)
4604 AC_SUBST(MOZ_ENABLE_QMSYSTEM2)
4605 AC_SUBST(MOZ_ENABLE_QTMOBILITY)
4606 AC_SUBST(MOZ_ENABLE_XREMOTE)
4607 AC_SUBST(MOZ_GTK2_CFLAGS)
4608 AC_SUBST(MOZ_GTK2_LIBS)
4609 AC_SUBST(MOZ_GTK3_CFLAGS)
4610 AC_SUBST(MOZ_GTK3_LIBS)
4611 AC_SUBST(MOZ_WIDGET_GTK)
4612 AC_SUBST(MOZ_QT_CFLAGS)
4613 AC_SUBST(MOZ_QT_LIBS)
4615 AC_SUBST(MOC)
4616 AC_SUBST(RCC)
4618 AC_SUBST(MOZ_X11)
4620 dnl ========================================================
4621 dnl =
4622 dnl = Components & Features
4623 dnl =
4624 dnl ========================================================
4625 MOZ_ARG_HEADER(Components and Features)
4627 dnl ========================================================
4628 dnl = Localization
4629 dnl ========================================================
4630 MOZ_ARG_ENABLE_STRING(ui-locale,
4631 [  --enable-ui-locale=ab-CD
4632                           Select the user interface locale (default: en-US)],
4633     MOZ_UI_LOCALE=$enableval )
4634 AC_SUBST(MOZ_UI_LOCALE)
4636 dnl ========================================================
4637 dnl = Trademarked Branding
4638 dnl ========================================================
4639 MOZ_ARG_ENABLE_BOOL(official-branding,
4640 [  --enable-official-branding
4641                           Enable Official mozilla.org Branding
4642                           Do not distribute builds with
4643                           --enable-official-branding unless you have
4644                           permission to use trademarks per
4645                           http://www.mozilla.org/foundation/trademarks/ .],
4647   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
4648     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
4649   else
4650     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
4651     MOZ_OFFICIAL_BRANDING=1
4652   fi
4653 ], MOZ_OFFICIAL_BRANDING=)
4655 AC_SUBST(MOZ_OFFICIAL_BRANDING)
4656 if test -n "$MOZ_OFFICIAL_BRANDING"; then
4657   AC_DEFINE(MOZ_OFFICIAL_BRANDING)
4660 MOZ_ARG_WITH_STRING(branding,
4661 [  --with-branding=dir     Use branding from the specified directory.],
4662     MOZ_BRANDING_DIRECTORY=$withval)
4664 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
4665 if test -z "$REAL_BRANDING_DIRECTORY"; then
4666   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
4669 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
4670   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
4673 AC_SUBST(MOZ_BRANDING_DIRECTORY)
4675 dnl ========================================================
4676 dnl = Distribution ID
4677 dnl ========================================================
4678 MOZ_ARG_WITH_STRING(distribution-id,
4679 [  --with-distribution-id=ID
4680                           Set distribution-specific id (default=org.mozilla)],
4681 [ val=`echo $withval`
4682     MOZ_DISTRIBUTION_ID="$val"])
4684 if test -z "$MOZ_DISTRIBUTION_ID"; then
4685    MOZ_DISTRIBUTION_ID="org.mozilla"
4688 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
4689 AC_SUBST(MOZ_DISTRIBUTION_ID)
4692 dnl ========================================================
4693 dnl = Pango
4694 dnl ========================================================
4695 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4696 then
4697     PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
4699     PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangoft2 >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
4700     AC_SUBST(MOZ_PANGO_CFLAGS)
4701     AC_SUBST(MOZ_PANGO_LIBS)
4704 dnl ========================================================
4705 dnl = GnomeVFS, GIO and GConf support module
4706 dnl ========================================================
4708 if test "$MOZ_X11"
4709 then
4710     dnl build the GIO extension by default only when the
4711     dnl GTK2 toolkit is in use.
4712     if test "$MOZ_ENABLE_GTK"
4713     then
4714         MOZ_ENABLE_GIO=1
4715         MOZ_ENABLE_GCONF=1
4716     fi
4718     dnl ========================================================
4719     dnl = GnomeVFS support module
4720     dnl ========================================================
4721     MOZ_ARG_ENABLE_BOOL(gnomevfs,
4722     [  --enable-gnomevfs       Enable GnomeVFS support (default: disabled)],
4723         MOZ_ENABLE_GNOMEVFS=force,
4724         MOZ_ENABLE_GNOMEVFS=)
4726     if test "$MOZ_ENABLE_GNOMEVFS"
4727     then
4728         PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
4729             MOZ_GNOMEVFS_LIBS=`echo $MOZ_GNOMEVFS_LIBS | sed 's/-llinc\>//'`
4730             MOZ_ENABLE_GNOMEVFS=1
4731             AC_DEFINE(MOZ_ENABLE_GNOMEVFS)
4732         ],[
4733             if test "$MOZ_ENABLE_GNOMEVFS" = "force"
4734             then
4735                 AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
4736             fi
4737             MOZ_ENABLE_GNOMEVFS=
4738         ])
4739     fi
4741     AC_SUBST(MOZ_ENABLE_GNOMEVFS)
4742     AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
4743     AC_SUBST(MOZ_GNOMEVFS_LIBS)
4745     dnl ========================================================
4746     dnl = GIO support module
4747     dnl ========================================================
4748     MOZ_ARG_DISABLE_BOOL(gio,
4749     [  --disable-gio           Disable GIO support],
4750         MOZ_ENABLE_GIO=,
4751         MOZ_ENABLE_GIO=force)
4753     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK"
4754     then
4755         if test "$MOZ_ENABLE_GTK2"
4756         then
4757             PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
4758                               [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
4759         fi
4760         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
4761             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
4762             MOZ_ENABLE_GIO=1
4763             AC_DEFINE(MOZ_ENABLE_GIO)
4764         ],[
4765             if test "$MOZ_ENABLE_GIO" = "force"
4766             then
4767                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
4768             fi
4769             MOZ_ENABLE_GIO=
4770         ])
4771     fi
4773     AC_SUBST(MOZ_ENABLE_GIO)
4774     AC_SUBST(MOZ_GIO_CFLAGS)
4775     AC_SUBST(MOZ_GIO_LIBS)
4777     dnl ========================================================
4778     dnl = GConf support module
4779     dnl ========================================================
4780     MOZ_ARG_DISABLE_BOOL(gconf,
4781     [  --disable-gconf      Disable Gconf support ],
4782         MOZ_ENABLE_GCONF=,
4783         MOZ_ENABLE_GCONF=force)
4785     if test "$MOZ_ENABLE_GCONF"
4786     then
4787         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
4788             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
4789             MOZ_ENABLE_GCONF=1
4790         ],[
4791             if test "$MOZ_ENABLE_GCONF" = "force"
4792             then
4793                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
4794             fi
4795             MOZ_ENABLE_GCONF=
4796         ])
4797     fi
4799     if test "$MOZ_ENABLE_GCONF"; then
4800         AC_DEFINE(MOZ_ENABLE_GCONF)
4801     fi
4803     AC_SUBST(MOZ_ENABLE_GCONF)
4804     AC_SUBST(MOZ_GCONF_CFLAGS)
4805     AC_SUBST(MOZ_GCONF_LIBS)
4808 dnl ========================================================
4809 dnl = libproxy support
4810 dnl ========================================================
4812 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4813 then
4814     MOZ_ENABLE_LIBPROXY=
4816     MOZ_ARG_ENABLE_BOOL(libproxy,
4817     [  --enable-libproxy         Enable libproxy support ],
4818     MOZ_ENABLE_LIBPROXY=1,
4819     MOZ_ENABLE_LIBPROXY=)
4821     if test "$MOZ_ENABLE_LIBPROXY"
4822     then
4823         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
4824         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
4825     fi
4827 AC_SUBST(MOZ_ENABLE_LIBPROXY)
4828 AC_SUBST(MOZ_LIBPROXY_CFLAGS)
4829 AC_SUBST(MOZ_LIBPROXY_LIBS)
4831 dnl ========================================================
4832 dnl = GNOME component (mozgnome)
4833 dnl ========================================================
4835 if test "$MOZ_ENABLE_GTK"
4836 then
4837     MOZ_ENABLE_GNOME_COMPONENT=1
4839 AC_SUBST(MOZ_ENABLE_GNOME_COMPONENT)
4841 dnl ========================================================
4842 dnl = libgnomeui support module
4843 dnl ========================================================
4845 if test "$MOZ_ENABLE_GTK"
4846 then
4847     MOZ_ARG_ENABLE_BOOL(gnomeui,
4848     [  --enable-gnomeui        Enable libgnomeui instead of GIO & GTK for icon theme support ],
4849         MOZ_ENABLE_GNOMEUI=force,
4850         MOZ_ENABLE_GNOMEUI=)
4852     if test "$MOZ_ENABLE_GNOMEUI"
4853     then
4854         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
4855         [
4856             MOZ_ENABLE_GNOMEUI=1
4857         ],[
4858             if test "$MOZ_ENABLE_GNOMEUI" = "force"
4859             then
4860                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
4861             fi
4862             MOZ_ENABLE_GNOMEUI=
4863         ])
4864     fi
4866     if test "$MOZ_ENABLE_GNOMEUI"; then
4867         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
4868     fi
4871 AC_SUBST(MOZ_ENABLE_GNOMEUI)
4872 AC_SUBST(MOZ_GNOMEUI_CFLAGS)
4874 dnl ========================================================
4875 dnl = dbus support
4876 dnl ========================================================
4878 if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT"
4879 then
4880     MOZ_ENABLE_DBUS=1
4882     MOZ_ARG_DISABLE_BOOL(dbus,
4883     [  --disable-dbus          Disable dbus support ],
4884         MOZ_ENABLE_DBUS=,
4885         MOZ_ENABLE_DBUS=1)
4887     if test "$MOZ_ENABLE_DBUS"
4888     then
4889         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
4890         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
4891         AC_DEFINE(MOZ_ENABLE_DBUS)
4892     fi
4894 AC_SUBST(MOZ_ENABLE_DBUS)
4895 AC_SUBST(MOZ_DBUS_CFLAGS)
4896 AC_SUBST(MOZ_DBUS_LIBS)
4897 AC_SUBST(MOZ_DBUS_GLIB_CFLAGS)
4898 AC_SUBST(MOZ_DBUS_GLIB_LIBS)
4900 dnl ========================================================
4901 dnl = Enable Android History instead of Places
4902 dnl ========================================================
4903 if test -n "$MOZ_ANDROID_HISTORY"; then
4904     if test -z "$MOZ_PLACES"; then
4905         AC_DEFINE(MOZ_ANDROID_HISTORY)
4906     else
4907         AC_MSG_ERROR([Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.])
4908     fi
4911 dnl ========================================================
4912 dnl = Build with the Android compositor
4913 dnl ========================================================
4914 if test -n "$MOZ_ANDROID_OMTC"; then
4915      dnl Do this if defined in confvars.sh
4916      AC_DEFINE(MOZ_ANDROID_OMTC)
4919 dnl ========================================================
4920 dnl = Disable WebSMS backend
4921 dnl ========================================================
4922 MOZ_ARG_DISABLE_BOOL(websms-backend,
4923 [  --disable-websms-backend
4924                            Disable WebSMS backend],
4925     MOZ_WEBSMS_BACKEND=,
4926     MOZ_WEBSMS_BACKEND=1)
4928 if test -n "$MOZ_WEBSMS_BACKEND"; then
4929     AC_DEFINE(MOZ_WEBSMS_BACKEND)
4932 dnl ========================================================
4933 dnl = Enable runtime locale switching on Android
4934 dnl ========================================================
4935 if test -n "$MOZ_LOCALE_SWITCHER"; then
4936     AC_DEFINE(MOZ_LOCALE_SWITCHER)
4939 dnl ========================================================
4940 dnl = Enable NFC permission on Android
4941 dnl ========================================================
4942 if test -n "$MOZ_ANDROID_BEAM"; then
4943     AC_DEFINE(MOZ_ANDROID_BEAM)
4946 dnl ========================================================
4947 dnl = JS Debugger XPCOM component (js/jsd)
4948 dnl ========================================================
4949 MOZ_ARG_DISABLE_BOOL(jsd,
4950 [  --disable-jsd           Disable JavaScript debug library],
4951     MOZ_JSDEBUGGER=,
4952     MOZ_JSDEBUGGER=1)
4955 dnl ========================================================
4956 dnl = Enable IPDL's "expensive" unit tests
4957 dnl ========================================================
4958 MOZ_IPDL_TESTS=
4960 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
4961 [  --enable-ipdl-tests     Enable expensive IPDL tests],
4962     MOZ_IPDL_TESTS=1,
4963     MOZ_IPDL_TESTS=)
4965 if test -n "$MOZ_IPDL_TESTS"; then
4966     AC_DEFINE(MOZ_IPDL_TESTS)
4969 AC_SUBST(MOZ_IPDL_TESTS)
4971 dnl ========================================================
4972 dnl = Disable building dbm
4973 dnl ========================================================
4974 MOZ_ARG_DISABLE_BOOL(dbm,
4975 [  --disable-dbm           Disable building dbm],
4976     NSS_DISABLE_DBM=1,
4977     NSS_DISABLE_DBM=)
4979 dnl ========================================================
4980 dnl accessibility support on by default on all platforms
4981 dnl ========================================================
4982 MOZ_ARG_DISABLE_BOOL(accessibility,
4983 [  --disable-accessibility Disable accessibility support],
4984     ACCESSIBILITY=,
4985     ACCESSIBILITY=1 )
4986 if test "$ACCESSIBILITY"; then
4987     case "$target" in
4988     *-mingw*)
4989         if test -z "$MIDL"; then
4990             if test "$GCC" != "yes"; then
4991                 AC_MSG_ERROR([MIDL could not be found. Building accessibility without MIDL is not supported.])
4992             else
4993                 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.])
4994             fi
4995         fi
4996     esac
4997     AC_DEFINE(ACCESSIBILITY)
5000 dnl ========================================================
5001 dnl Accessibility is required for the linuxgl widget
5002 dnl backend
5003 dnl ========================================================
5004 if test "${MOZ_WIDGET_TOOLKIT}" = "linuxgl" -a "$ACCESSIBILITY" != "1"; then
5005     AC_MSG_ERROR(["Accessibility is required for the linuxgl widget backend"])
5008 dnl Turn off webrtc for OS's we don't handle yet, but allow
5009 dnl --enable-webrtc to override.  Can disable for everything in
5010 dnl the master list above.
5011 if test -n "$MOZ_WEBRTC"; then
5012     case "$target" in
5013     *-linux*|*-mingw*|*-darwin*|*-android*|*-linuxandroid*|*-dragonfly*|*-freebsd*|*-netbsd*|*-openbsd*)
5014         dnl Leave enabled
5015         ;;
5016     *)
5017         dnl default to disabled for all others
5018         MOZ_WEBRTC=
5019         ;;
5020     esac
5023 AC_TRY_COMPILE([#include <linux/ethtool.h>],
5024                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
5025                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
5027 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
5029 # target_arch is from {ia32|x64|arm|ppc}
5030 case "$CPU_ARCH" in
5031 x86_64 | arm | x86 | ppc* | ia64)
5032     :
5033     ;;
5035 # unsupported arch for webrtc
5036     MOZ_WEBRTC=
5037     ;;
5039 esac
5041 dnl ========================================================
5042 dnl = Disable WebRTC code
5043 dnl ========================================================
5044 MOZ_ARG_DISABLE_BOOL(webrtc,
5045 [  --disable-webrtc        Disable support for WebRTC],
5046     MOZ_WEBRTC=,
5047     MOZ_WEBRTC=1)
5049 if test -n "$MOZ_WEBRTC"; then
5050     AC_DEFINE(MOZ_WEBRTC)
5051     dnl MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
5052     dnl opt/production builds (via MOZ_CRASH())
5053     AC_DEFINE(MOZ_WEBRTC_ASSERT_ALWAYS)
5054     MOZ_RAW=1
5055     MOZ_VPX=1
5056     MOZ_VPX_ERROR_CONCEALMENT=1
5058 dnl enable once Signaling lands
5059     MOZ_WEBRTC_SIGNALING=1
5060     AC_DEFINE(MOZ_WEBRTC_SIGNALING)
5061 dnl enable once PeerConnection lands
5062     MOZ_PEERCONNECTION=1
5063     AC_DEFINE(MOZ_PEERCONNECTION)
5064     MOZ_SCTP=1
5065     MOZ_SRTP=1
5066     AC_DEFINE(MOZ_SCTP)
5067     AC_DEFINE(MOZ_SRTP)
5068 else
5069     MOZ_SYNTH_PICO=
5072 AC_SUBST(MOZ_WEBRTC)
5073 AC_SUBST(MOZ_WEBRTC_LEAKING_TESTS)
5074 AC_SUBST(MOZ_WEBRTC_SIGNALING)
5075 AC_SUBST(MOZ_PEERCONNECTION)
5076 AC_SUBST(MOZ_WEBRTC_ASSERT_ALWAYS)
5077 AC_SUBST(MOZ_SCTP)
5078 AC_SUBST(MOZ_SRTP)
5080 dnl Use integers over floats for audio on B2G and Android, because audio
5081 dnl backends for those platforms don't support floats.
5082 if test "$OS_TARGET" = "Android"; then
5083     MOZ_SAMPLE_TYPE_S16=1
5084     AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
5085     AC_SUBST(MOZ_SAMPLE_TYPE_S16)
5086 else
5087     MOZ_SAMPLE_TYPE_FLOAT32=1
5088     AC_DEFINE(MOZ_SAMPLE_TYPE_FLOAT32)
5089     AC_SUBST(MOZ_SAMPLE_TYPE_FLOAT32)
5092 dnl ========================================================
5093 dnl = Disable Speech API code
5094 dnl ========================================================
5095 MOZ_ARG_DISABLE_BOOL(webspeech,
5096 [  --disable-webspeech        Disable support for HTML Speech API],
5097     MOZ_WEBSPEECH=,
5098     MOZ_WEBSPEECH=1)
5100 if test -n "$MOZ_WEBSPEECH"; then
5101     AC_DEFINE(MOZ_WEBSPEECH)
5104 AC_SUBST(MOZ_WEBSPEECH)
5106 dnl ========================================================
5107 dnl = Enable Raw Codecs
5108 dnl ========================================================
5109 MOZ_ARG_ENABLE_BOOL(raw,
5110 [  --enable-raw           Enable support for RAW media],
5111     MOZ_RAW=1,
5112     MOZ_RAW=)
5114 if test -n "$MOZ_RAW"; then
5115     AC_DEFINE(MOZ_RAW)
5118 AC_SUBST(MOZ_RAW)
5120 dnl Checks for __attribute__(aligned()) directive need by libogg
5121 AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
5122     [ac_cv_c_attribute_aligned],
5123     [ac_cv_c_attribute_aligned=0
5124      CFLAGS_save="${CFLAGS}"
5125      CFLAGS="${CFLAGS} -Werror"
5126      for ac_cv_c_attr_align_try in 64 32 16 8; do
5127        echo "trying $ac_cv_c_attr_align_try"
5128        AC_TRY_COMPILE([],
5129                       [static char c __attribute__ ((aligned(${ac_cv_c_attr_align_try}))) = 0; return c;],
5130                       [ac_cv_c_attribute_aligned="${ac_cv_c_attr_align_try}"])
5131        if test "$ac_cv_c_attribute_aligned" != 0; then
5132          break;
5133        fi
5134      done
5135        CFLAGS="${CFLAGS_save}"])
5136 if test "${ac_cv_c_attribute_aligned}" != "0"; then
5137   AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
5138                      [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
5141 dnl ========================================================
5142 dnl = Disable Opus audio codec support
5143 dnl ========================================================
5144 MOZ_ARG_DISABLE_BOOL(opus,
5145 [  --disable-opus          Disable support for Opus audio],
5146     MOZ_OPUS=,
5147     MOZ_OPUS=1)
5149 dnl ========================================================
5150 dnl = Disable VP8 decoder support
5151 dnl ========================================================
5152 MOZ_ARG_DISABLE_BOOL(webm,
5153 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
5154     MOZ_WEBM=,
5155     MOZ_WEBM=1)
5157 if test -n "$MOZ_WEBM"; then
5158     AC_DEFINE(MOZ_WEBM)
5159     MOZ_VPX=1
5162 dnl ========================================================
5163 dnl = DirectShow support
5164 dnl ========================================================
5165 if test "$OS_ARCH" = "WINNT"; then
5166     dnl Enable DirectShow support by default.
5167     MOZ_DIRECTSHOW=1
5170 MOZ_ARG_DISABLE_BOOL(directshow,
5171 [  --disable-directshow  Disable support for DirectShow],
5172     MOZ_DIRECTSHOW=,
5173     MOZ_DIRECTSHOW=1)
5175 if test -n "$MOZ_DIRECTSHOW"; then
5176     AC_DEFINE(MOZ_DIRECTSHOW)
5179 dnl ========================================================
5180 dnl = Windows Media Foundation support
5181 dnl ========================================================
5182 if test "$OS_ARCH" = "WINNT"; then
5183     dnl Enable Windows Media Foundation support by default.
5184     dnl Note our minimum SDK version is Windows 7 SDK, so we are (currently)
5185     dnl guaranteed to have a recent-enough SDK to build WMF.
5186     MOZ_WMF=1
5189 MOZ_ARG_DISABLE_BOOL(wmf,
5190 [  --disable-wmf  Disable support for Windows Media Foundation],
5191     MOZ_WMF=,
5192     MOZ_WMF=1)
5194 if test -n "$MOZ_WMF"; then
5195     AC_DEFINE(MOZ_WMF)
5198 dnl ========================================================
5199 dnl FFmpeg H264/AAC Decoding Support
5200 dnl ========================================================
5201 case "$OS_TARGET" in
5202 WINNT|Darwin|Android)
5203     ;;
5205     MOZ_FFMPEG=1
5206     ;;
5207 esac
5209 MOZ_ARG_DISABLE_BOOL(ffmpeg,
5210 [  --disable-ffmpeg         Disable FFmpeg for fragmented H264/AAC decoding],
5211     MOZ_FFMPEG=,
5212     MOZ_FFMPEG=1
5215 if test -n "$MOZ_FFMPEG"; then
5216     AC_DEFINE(MOZ_FFMPEG)
5219 dnl ========================================================
5220 dnl = Built-in fragmented MP4 support.
5221 dnl ========================================================
5222 if test -n "$MOZ_WMF" -o -n "$MOZ_FFMPEG"; then
5223     dnl Enable fragmented MP4 parser on Windows by default.
5224     dnl We will also need to enable it on other platforms as we implement
5225     dnl platform decoder support there too.
5226     MOZ_FMP4=1
5229 MOZ_ARG_DISABLE_BOOL(fmp4,
5230 [  --disable-fmp4  Disable support for in built Fragmented MP4 parsing],
5231     MOZ_FMP4=,
5232     MOZ_FMP4=1)
5234 if test -n "$MOZ_FMP4"; then
5235     AC_DEFINE(MOZ_FMP4)
5239 dnl ========================================================
5240 dnl = Enable media plugin support
5241 dnl ========================================================
5242 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5243   dnl Enable support on android by default
5244   MOZ_MEDIA_PLUGINS=1
5247 MOZ_ARG_ENABLE_BOOL(media-plugins,
5248 [  --enable-media-plugins  Enable support for media plugins],
5249     MOZ_MEDIA_PLUGINS=1,
5250     MOZ_MEDIA_PLUGINS=)
5252 if test -n "$MOZ_MEDIA_PLUGINS"; then
5253   AC_DEFINE(MOZ_MEDIA_PLUGINS)
5256 dnl ========================================================
5257 dnl = Disable platform MP3 decoder on OSX
5258 dnl ========================================================
5259 if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
5260   MOZ_APPLEMEDIA=1
5263 MOZ_ARG_DISABLE_BOOL(apple-media,
5264 [  --disable-apple-media  Disable support for Apple AudioToolbox/VideoToolbox],
5265     MOZ_APPLEMEDIA=,
5266     MOZ_APPLEMEDIA=1)
5268 if test -n "$MOZ_APPLEMEDIA"; then
5269   AC_DEFINE(MOZ_APPLEMEDIA)
5272 dnl ========================================================
5273 dnl = Enable getUserMedia support
5274 dnl ========================================================
5275 MOZ_ARG_ENABLE_BOOL(media-navigator,
5276 [  --enable-media-navigator  Enable support for getUserMedia],
5277     MOZ_MEDIA_NAVIGATOR=1,
5278     MOZ_MEDIA_NAVIGATOR=)
5280 if test -n "$MOZ_MEDIA_NAVIGATOR"; then
5281   AC_DEFINE(MOZ_MEDIA_NAVIGATOR)
5284 dnl ========================================================
5285 dnl = Enable building OMX media plugin (B2G or Android)
5286 dnl ========================================================
5287 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
5288   dnl Enable support on android by default
5289   MOZ_OMX_PLUGIN=1
5292 MOZ_ARG_ENABLE_BOOL(omx-plugin,
5293 [  --enable-omx-plugin      Enable building OMX plugin (B2G)],
5294     MOZ_OMX_PLUGIN=1,
5295     MOZ_OMX_PLUGIN=)
5297 if test -n "$MOZ_OMX_PLUGIN"; then
5298     if test "$OS_TARGET" = "Android"; then
5299         dnl Only allow building OMX plugin on Gonk (B2G) or Android
5300         AC_DEFINE(MOZ_OMX_PLUGIN)
5301     else
5302        dnl fail if we're not building on Gonk or Android
5303        AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
5304     fi
5307 dnl system libvpx Support
5308 dnl ========================================================
5309 MOZ_ARG_WITH_BOOL(system-libvpx,
5310 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
5311     MOZ_NATIVE_LIBVPX=1)
5313 MOZ_LIBVPX_CFLAGS=
5314 MOZ_LIBVPX_LIBS=
5316 if test -n "$MOZ_VPX"; then
5317     AC_DEFINE(MOZ_VPX)
5318     if test -n "$MOZ_VPX_ERROR_CONCEALMENT" ; then
5319         AC_DEFINE(MOZ_VPX_ERROR_CONCEALMENT)
5320     fi
5322     _SAVE_CFLAGS=$CFLAGS
5323     _SAVE_LIBS=$LIBS
5324     if test -n "$MOZ_NATIVE_LIBVPX"; then
5325         dnl ============================
5326         dnl === libvpx Version check ===
5327         dnl ============================
5328         dnl Check to see if we have a system libvpx package.
5329         PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.3.0)
5331         CFLAGS="$CFLAGS $MOZ_LIBVPX_CFLAGS"
5332         LIBS="$LIBS $MOZ_LIBVPX_LIBS"
5334         MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [],
5335          [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.])])
5337         AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [],
5338          [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
5340         MOZ_CHECK_HEADER([vpx_mem/vpx_mem.h],
5341          [AC_CHECK_FUNC(vpx_mem_set_functions)])
5342         if test "$ac_cv_header_vpx_mem_vpx_mem_h" = no -o \
5343                 "$ac_cv_func_vpx_mem_set_functions" = no; then
5344             AC_DEFINE(MOZ_VPX_NO_MEM_REPORTING)
5345         fi
5346     fi
5347     CFLAGS=$_SAVE_CFLAGS
5348     LIBS=$_SAVE_LIBS
5351 AC_SUBST(MOZ_NATIVE_LIBVPX)
5352 AC_SUBST(MOZ_LIBVPX_CFLAGS)
5353 AC_SUBST(MOZ_LIBVPX_LIBS)
5355 if test "$MOZ_WEBM"; then
5356     if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then
5357         MOZ_VORBIS=1
5358     else
5359         MOZ_TREMOR=1
5360     fi
5363 if test -n "$MOZ_VPX" -a -z "$MOZ_NATIVE_LIBVPX"; then
5365     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
5366     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
5367     dnl We currently require gcc on all arm platforms.
5368     VPX_AS=$YASM
5369     VPX_ASM_SUFFIX=asm
5370     VPX_NEED_OBJ_INT_EXTRACT=
5372     dnl See if we have assembly on this platform.
5373     case "$OS_ARCH:$CPU_ARCH" in
5374     Darwin:x86)
5375       VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
5376       VPX_X86_ASM=1
5377     ;;
5378     Darwin:x86_64)
5379       VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
5380       VPX_X86_ASM=1
5381     ;;
5382     WINNT:x86_64)
5383       VPX_ASFLAGS="-f x64 -rnasm -pnasm"
5384       VPX_X86_ASM=1
5385     ;;
5386     WINNT:x86)
5387       dnl Check for yasm 1.1 or greater.
5388       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
5389         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.])
5390       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
5391         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.])
5392       else
5393         VPX_ASFLAGS="-f win32 -rnasm -pnasm -DPIC"
5394         VPX_X86_ASM=1
5395         dnl The encoder needs obj_int_extract to get asm offsets.
5396       fi
5397     ;;
5398     *:arm*)
5399       if test -n "$GNU_AS" ; then
5400         VPX_AS=$AS
5401         dnl These flags are a lie; they're just used to enable the requisite
5402         dnl opcodes; actual arch detection is done at runtime.
5403         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
5404         VPX_DASH_C_FLAG="-c"
5405         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
5406         VPX_ASM_SUFFIX="$ASM_SUFFIX"
5407         VPX_ARM_ASM=1
5408       fi
5409     ;;
5410     *:x86)
5411       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5412         VPX_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC"
5413         VPX_X86_ASM=1
5414       fi
5415     ;;
5416     *:x86_64)
5417       if $CC -E -dM -</dev/null | grep -q __ELF__; then
5418         VPX_ASFLAGS="-f elf64 -rnasm -pnasm -DPIC"
5419         VPX_X86_ASM=1
5420       fi
5421     ;;
5422     esac
5424     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_X86_ASM" -a -z "$VPX_AS"; then
5425       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.])
5426     fi
5428     if test -z "$GNU_CC" -a -z "$INTEL_CC" -a -z "$CLANG_CC" ; then
5429       dnl We prefer to get asm offsets using inline assembler, which the above
5430       dnl compilers can do. When we're not using one of those, we have to fall
5431       dnl back to obj_int_extract, which reads them from a compiled object
5432       dnl file. Unfortunately, that only works if we're compiling on a system
5433       dnl with the header files for the appropriate object file format.
5434       VPX_NEED_OBJ_INT_EXTRACT=1
5435     fi
5437     if test -n "$VPX_X86_ASM"; then
5438       AC_DEFINE(VPX_X86_ASM)
5439     elif test -n "$VPX_ARM_ASM"; then
5440       AC_DEFINE(VPX_ARM_ASM)
5441     else
5442       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
5443     fi
5446 dnl ========================================================
5447 dnl = Disable Wave decoder support
5448 dnl ========================================================
5449 MOZ_ARG_DISABLE_BOOL(wave,
5450 [  --disable-wave          Disable Wave decoder support],
5451     MOZ_WAVE=,
5452     MOZ_WAVE=1)
5454 if test -n "$MOZ_WAVE"; then
5455     AC_DEFINE(MOZ_WAVE)
5458 dnl ========================================================
5459 dnl = Handle dependent MEDIA defines
5460 dnl ========================================================
5462 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
5463     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/])
5466 if test -n "$MOZ_WEBRTC" -a -z "$MOZ_OPUS"; then
5467     AC_MSG_ERROR([MOZ_WEBRTC requires MOZ_OPUS which is disabled.])
5470 if test -n "$MOZ_VORBIS"; then
5471     AC_DEFINE(MOZ_VORBIS)
5474 if test -n "$MOZ_TREMOR"; then
5475     AC_DEFINE(MOZ_TREMOR)
5478 if test -n "$MOZ_OPUS"; then
5479     AC_DEFINE(MOZ_OPUS)
5482 if test -n "$MOZ_WEBM_ENCODER"; then
5483     AC_DEFINE(MOZ_WEBM_ENCODER)
5485 AC_SUBST(MOZ_WEBM_ENCODER)
5487 dnl ==================================
5488 dnl = Check alsa availability on Linux
5489 dnl ==================================
5491 dnl If using Linux, ensure that the alsa library is available
5492 if test "$OS_TARGET" = "Linux"; then
5493     MOZ_ALSA=1
5496 MOZ_ARG_ENABLE_BOOL(alsa,
5497 [  --enable-alsa          Enable Alsa support (default on Linux)],
5498    MOZ_ALSA=1,
5499    MOZ_ALSA=)
5501 if test -n "$MOZ_ALSA"; then
5502     PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
5503          [echo "$MOZ_ALSA_PKG_ERRORS"
5504           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.)])])
5507 AC_SUBST(MOZ_ALSA)
5508 AC_SUBST(MOZ_ALSA_CFLAGS)
5509 AC_SUBST(MOZ_ALSA_LIBS)
5511 dnl ========================================================
5512 dnl = Disable PulseAudio
5513 dnl ========================================================
5515 dnl If using Linux, ensure that the PA library is available
5516 case "$OS_TARGET" in
5517 WINNT|Darwin|Android|OpenBSD)
5518     ;;
5520     if test -z "$MOZ_B2G"; then
5521         MOZ_PULSEAUDIO=1
5522     fi
5523     ;;
5524 esac
5526 MOZ_ARG_DISABLE_BOOL(pulseaudio,
5527 [  --disable-pulseaudio          Disable PulseAudio support],
5528    MOZ_PULSEAUDIO=,
5529    MOZ_PULSEAUDIO=1)
5531 if test -n "$MOZ_PULSEAUDIO"; then
5532     if test -z "$gonkdir"; then
5533         PKG_CHECK_MODULES(MOZ_PULSEAUDIO, libpulse, ,
5534              [echo "$MOZ_PULSEAUDIO_PKG_ERRORS"
5535               AC_MSG_ERROR([pulseaudio audio backend requires libpulse development package])])
5536     else
5537         MOZ_PULSEAUDIO_CFLAGS="-I$gonkdir/external/pulseaudio/pulseaudio/src"
5538     fi
5541 AC_SUBST(MOZ_PULSEAUDIO)
5542 AC_SUBST(MOZ_PULSEAUDIO_CFLAGS)
5544 dnl ========================================================
5545 dnl = Enable GStreamer
5546 dnl ========================================================
5547 case "$OS_TARGET" in
5548 WINNT|Darwin|Android)
5549     ;;
5551     MOZ_GSTREAMER=1
5552     GST_API_VERSION=0.10
5553     ;;
5554 esac
5556 MOZ_ARG_ENABLE_STRING(gstreamer,
5557 [  --enable-gstreamer[=0.10]           Enable GStreamer support],
5558 [ MOZ_GSTREAMER=1
5559   # API version, eg 0.10, 1.0 etc
5560   if test -z "$enableval" -o "$enableval" = "yes"; then
5561     GST_API_VERSION=0.10
5562   elif test "$enableval" = "no"; then
5563     MOZ_GSTREAMER=
5564   else
5565     GST_API_VERSION=$enableval
5566   fi],
5569 if test -n "$MOZ_GSTREAMER"; then
5570     # core/base release number
5571     if test "$GST_API_VERSION" = "1.0"; then
5572       GST_VERSION=1.0
5573     else
5574       GST_VERSION=0.10.25
5575     fi
5577     PKG_CHECK_MODULES(GSTREAMER,
5578                       gstreamer-$GST_API_VERSION >= $GST_VERSION
5579                       gstreamer-app-$GST_API_VERSION
5580                       gstreamer-plugins-base-$GST_API_VERSION,
5581                       [_HAVE_GSTREAMER=1],
5582                       [_HAVE_GSTREAMER=])
5583     if test -z "$_HAVE_GSTREAMER"; then
5584         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])
5585     fi
5587     _SAVE_LDFLAGS=$LDFLAGS
5588     LDFLAGS="$LDFLAGS $GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5589     AC_TRY_LINK(,[return 0;],_HAVE_LIBGSTVIDEO=1,_HAVE_LIBGSTVIDEO=)
5590     if test -n "$_HAVE_LIBGSTVIDEO" ; then
5591         GSTREAMER_LIBS="$GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
5592     else
5593         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.])
5594     fi
5595     LDFLAGS=$_SAVE_LDFLAGS
5597     AC_SUBST(GSTREAMER_CFLAGS)
5598     AC_SUBST(GSTREAMER_LIBS)
5601 AC_SUBST(MOZ_GSTREAMER)
5602 AC_SUBST(GST_API_VERSION)
5604 if test -n "$MOZ_GSTREAMER"; then
5605      AC_DEFINE(MOZ_GSTREAMER)
5606      AC_DEFINE_UNQUOTED(GST_API_VERSION, "$GST_API_VERSION")
5610 dnl ========================================================
5611 dnl Permissions System
5612 dnl ========================================================
5613 MOZ_ARG_DISABLE_BOOL(permissions,
5614 [  --disable-permissions   Disable permissions (popup and cookie blocking)],
5615     MOZ_PERMISSIONS=,
5616     MOZ_PERMISSIONS=1
5619 dnl ========================================================
5620 dnl Child permissions, currently only used for b2g
5621 dnl ========================================================
5622 if test -n "$MOZ_B2G"; then
5623     if test -n "$MOZ_PERMISSIONS"; then
5624         MOZ_CHILD_PERMISSIONS=1
5625     else
5626         AC_MSG_ERROR([You need to enable MOZ_PERMISSIONS for MOZ_CHILD_PERMISSIONS])
5627     fi
5629 AC_SUBST(MOZ_CHILD_PERMISSIONS)
5631 dnl ========================================================
5632 dnl NegotiateAuth
5633 dnl ========================================================
5634 MOZ_ARG_DISABLE_BOOL(negotiateauth,
5635 [  --disable-negotiateauth Disable GSS-API negotiation ],
5636     MOZ_AUTH_EXTENSION=,
5637     MOZ_AUTH_EXTENSION=1 )
5639 dnl ========================================================
5640 dnl Pref extensions (autoconfig)
5641 dnl ========================================================
5642 MOZ_ARG_DISABLE_BOOL(pref-extensions,
5643 [  --disable-pref-extensions
5644                           Disable pref extensions such as autoconfig],
5645   MOZ_PREF_EXTENSIONS=,
5646   MOZ_PREF_EXTENSIONS=1 )
5648 dnl ========================================================
5649 dnl Searching of system directories for extensions.
5650 dnl Note: this switch is meant to be used for test builds
5651 dnl whose behavior should not depend on what happens to be
5652 dnl installed on the local machine.
5653 dnl ========================================================
5654 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
5655 [  --disable-system-extension-dirs
5656                           Disable searching system- and account-global
5657                           directories for extensions of any kind; use
5658                           only profile-specific extension directories],
5659   ENABLE_SYSTEM_EXTENSION_DIRS=,
5660   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
5661 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
5662   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
5665 dnl ========================================================
5666 dnl = Universalchardet
5667 dnl ========================================================
5668 MOZ_ARG_DISABLE_BOOL(universalchardet,
5669 [  --disable-universalchardet
5670                           Disable universal encoding detection],
5671   MOZ_UNIVERSALCHARDET=,
5672   MOZ_UNIVERSALCHARDET=1 )
5674 if test -n "${JAVA_BIN_PATH}"; then
5675   dnl Look for javac and jar in the specified path.
5676   JAVA_PATH="$JAVA_BIN_PATH"
5677 else
5678   dnl No path specified, so look for javac and jar in $JAVA_HOME & $PATH.
5679   JAVA_PATH="$JAVA_HOME/bin:$PATH"
5682 MOZ_PATH_PROG(JAVA, java, :, [$JAVA_PATH])
5683 MOZ_PATH_PROG(JAVAC, javac, :, [$JAVA_PATH])
5684 MOZ_PATH_PROG(JAVAH, javah, :, [$JAVA_PATH])
5685 MOZ_PATH_PROG(JAR, jar, :, [$JAVA_PATH])
5686 MOZ_PATH_PROG(JARSIGNER, jarsigner, :, [$JAVA_PATH])
5687 MOZ_PATH_PROG(KEYTOOL, keytool, :, [$JAVA_PATH])
5689 if test -n "${JAVA_BIN_PATH}" -o \
5690   \( "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk" \); then
5691   if test -z "$JAVA" -o "$JAVA" = ":"; then
5692     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}])
5693   fi
5694   if test -z "$JAVAC" -o "$JAVAC" = ":"; then
5695     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}])
5696   fi
5697   if test -z "$JAVAH" -o "$JAVAH" = ":"; then
5698     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}])
5699   fi
5700   if test -z "$JAR" -o "$JAR" = ":"; then
5701     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}])
5702   fi
5703   if test -z "$JARSIGNER" -o "$JARSIGNER" = ":"; then
5704     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}])
5705   fi
5706   if test -z "$KEYTOOL" -o "$KEYTOOL" = ":"; then
5707     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}])
5708   fi
5711 dnl ========================================================
5712 dnl = ANGLE OpenGL->D3D translator for WebGL
5713 dnl = * only applies to win32
5714 dnl = * enabled by default (shipping build); requires explicit --disable to disable
5715 dnl ========================================================
5717 MOZ_ANGLE_RENDERER=
5718 MOZ_D3D_CPU_SUFFIX=
5719 MOZ_HAS_WINSDK_WITH_D3D=
5720 MOZ_D3DCOMPILER_VISTA_DLL=
5721 MOZ_D3DCOMPILER_VISTA_DLL_PATH=
5722 MOZ_DIRECTX_SDK_PATH=
5723 MOZ_D3DCOMPILER_XP_DLL=
5724 MOZ_D3DCOMPILER_XP_CAB=
5726 case "$target_os" in
5727 *mingw*)
5728     MOZ_ANGLE_RENDERER=1
5729     ;;
5730 esac
5732 # The DirectX SDK libraries are split into x86 and x64 sub-directories
5733 case "${target_cpu}" in
5734 i*86)
5735   MOZ_D3D_CPU_SUFFIX=x86
5736   ;;
5737 x86_64)
5738   MOZ_D3D_CPU_SUFFIX=x64
5739   ;;
5740 esac
5742 MOZ_ARG_DISABLE_BOOL(webgl,
5743 [  --disable-webgl     Disable building of the WebGL implementation],
5744     MOZ_WEBGL_DISABLED=1,
5745     MOZ_WEBGL_DISABLED=)
5747 MOZ_ARG_ENABLE_BOOL(require-all-d3dc-versions,
5748 [  --enable-require-all-d3dc-versions Require all versions of the D3D compiler needed for supported Windows systems.],
5749     MOZ_REQUIRE_ALL_D3DCS=1,
5750     MOZ_REQUIRE_ALL_D3DCS=)
5752 if test -n "$MOZ_WEBGL_DISABLED"; then
5753   MOZ_WEBGL=
5754   MOZ_ANGLE_RENDERER=
5757 if test -n "$MOZ_WEBGL"; then
5758   AC_DEFINE(MOZ_WEBGL)
5761 if test -n "$MOZ_WEBGL_CONFORMANT"; then
5762   AC_DEFINE(MOZ_WEBGL_CONFORMANT)
5765 dnl ========================================================
5766 dnl D3D compiler DLL
5767 dnl ========================================================
5768 MOZ_FOUND_D3D_COMPILERS=
5770 if test -n "$MOZ_ANGLE_RENDERER"; then
5771   if test -z "$MOZ_D3D_CPU_SUFFIX"; then
5772     AC_MSG_ERROR([Couldn't determine MOZ_D3D_CPU_SUFFIX.])
5773   fi
5775   ######################################
5776   # Find _46+ for use by Vista+.
5778   # Find a D3D compiler DLL in a Windows SDK.
5779   MOZ_D3DCOMPILER_VISTA_DLL=
5780   case "$MOZ_WINSDK_MAXVER" in
5781   0x0603*)
5782     MOZ_D3DCOMPILER_VISTA_DLL=d3dcompiler_47.dll
5783     AC_MSG_RESULT([Found D3D compiler in Windows SDK 8.1.])
5784   ;;
5785   0x0602*)
5786     MOZ_D3DCOMPILER_VISTA_DLL=d3dcompiler_46.dll
5787     AC_MSG_RESULT([Found D3D compiler in Windows SDK 8.0.])
5788   ;;
5789   esac
5791   if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
5792     # We have a name, now track down the path.
5793     if test -n "$WINDOWSSDKDIR"; then
5794       MOZ_D3DCOMPILER_VISTA_DLL_PATH="$WINDOWSSDKDIR/Redist/D3D/$MOZ_D3D_CPU_SUFFIX/$MOZ_D3DCOMPILER_VISTA_DLL"
5795       if test -f "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
5796         AC_MSG_RESULT([Found MOZ_D3DCOMPILER_VISTA_DLL_PATH: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
5797         MOZ_HAS_WINSDK_WITH_D3D=1
5798       else
5799         AC_MSG_RESULT([MOZ_D3DCOMPILER_VISTA_DLL_PATH doesn't exist: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
5800         AC_MSG_ERROR([Windows SDK at "$WINDOWSSDKDIR" appears broken. Try updating to MozillaBuild 1.9 final or higher.])
5801         MOZ_D3DCOMPILER_VISTA_DLL_PATH=
5802       fi
5803     else
5804       AC_MSG_RESULT([Windows SDK not found.])
5805     fi
5806   fi
5808   if test -z "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
5809     MOZ_D3DCOMPILER_VISTA_DLL=
5810   fi
5812   # On mingw, check if headers are provided by toolchain.
5813   if test -n "$GNU_CC"; then
5814     MOZ_CHECK_HEADER(d3d10.h, MOZ_HAS_WINSDK_WITH_D3D=1)
5815   fi
5817   ######################################
5818   # Find _43 for use by XP.
5820   # Get the SDK path from the registry.
5821   # First try to get the June 2010 SDK
5822   MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK (June 2010)' | head -n 1`
5823   if test -z "$MOZ_DIRECTX_SDK_REG_KEY" ; then
5824     # Otherwise just take whatever comes first
5825     MOZ_DIRECTX_SDK_REG_KEY=`reg query 'HKLM\Software\Microsoft\DirectX' //s | grep 'Microsoft DirectX SDK' | head -n 1`
5826   fi
5827   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'`
5829   if test -n "$MOZ_DIRECTX_SDK_PATH" &&
5830      test -f "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_D3D_CPU_SUFFIX/dxguid.lib ; then
5831     AC_MSG_RESULT([Found DirectX SDK via registry, using $MOZ_DIRECTX_SDK_PATH])
5832   else
5833     AC_MSG_RESULT([DirectX SDK not found.])
5834     MOZ_DIRECTX_SDK_PATH=
5835   fi
5837   # Check that our DirectX SDK is acceptable.
5838   if test -n "$MOZ_DIRECTX_SDK_PATH"; then
5839     if test -n "`echo $MOZ_DIRECTX_SDK_REG_KEY | grep 'February 2010'`" ; then
5840       AC_MSG_RESULT([Found the February 2010 DirectX SDK, which is unacceptable to ANGLE.])
5841       MOZ_DIRECTX_SDK_PATH=
5842     fi
5843   fi
5845   if test -n "$MOZ_DIRECTX_SDK_PATH"; then
5846     # Find a D3D compiler DLL in the DirectX SDK, if we didn't find one already.
5847     # Get the SDK numeric version (e.g. 43) by looking at the dependencies of d3dx9.lib
5848     MOZ_D3DX9_VERSION=`dumpbin //headers "$MOZ_DIRECTX_SDK_PATH"/lib/$MOZ_D3D_CPU_SUFFIX/d3dx9.lib | egrep d3dx9_[[0-9]][[0-9]]\.dll | head -n1 | sed 's/.*\([[0-9]][[0-9]]\).*/\\1/g'`
5850     if test -n "$MOZ_D3DX9_VERSION" ; then
5851       MOZ_D3DCOMPILER_XP_CAB=`find "$MOZ_DIRECTX_SDK_PATH"/Redist -name *D3DCompiler_${MOZ_D3DX9_VERSION}_${MOZ_D3D_CPU_SUFFIX}.cab | head -n1`
5853       if test -n "$MOZ_D3DCOMPILER_XP_CAB"; then
5854         MOZ_D3DCOMPILER_XP_DLL=D3DCompiler_$MOZ_D3DX9_VERSION.dll
5855       else
5856         AC_MSG_RESULT([Couldn't find a CAB containing the D3D compiler DLL.])
5857         AC_MSG_ERROR([DirectX SDK at "$MOZ_DIRECTX_SDK_PATH" appears broken.])
5858         MOZ_DIRECTX_SDK_PATH=
5859       fi
5860     else
5861       AC_MSG_RESULT([Couldn't determine the D3DX9 version for the DirectX SDK.])
5862       MOZ_DIRECTX_SDK_PATH=
5863     fi
5864   else
5865     AC_MSG_RESULT([Couldn't find an acceptable DirectX SDK for ANGLE, needed for d3dcompiler_43.])
5866     AC_MSG_RESULT([  Either ignore, install DirectX SDK (June 2010 version or newer), or reconfigure with --disable-webgl.])
5867   fi
5869   ######################################
5870   # Check that we found what we needed.
5871   MOZ_FOUND_A_D3D_COMPILER=
5872   MOZ_FOUND_BOTH_D3D_COMPILERS=1
5874   if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
5875     MOZ_FOUND_A_D3D_COMPILER=1
5876     AC_MSG_RESULT([Found d3dcompiler DLL for Vista+: $MOZ_D3DCOMPILER_VISTA_DLL])
5877   else
5878     MOZ_FOUND_BOTH_D3D_COMPILERS=
5879   fi
5881   if test -n "$MOZ_D3DCOMPILER_XP_DLL"; then
5882     MOZ_FOUND_A_D3D_COMPILER=1
5883     AC_MSG_RESULT([Found d3dcompiler DLL for XP: $MOZ_D3DCOMPILER_XP_DLL])
5884   else
5885     MOZ_FOUND_BOTH_D3D_COMPILERS=
5886   fi
5888   if test -z "$CROSS_COMPILE"; then
5889     if test -z "MOZ_FOUND_A_D3D_COMPILER"; then
5890       AC_MSG_ERROR([Couldn't find an acceptable D3D compiler DLL.])
5891       AC_MSG_ERROR([  Either install Windows SDK 8.0+, install DirectX SDK (June 2010 version or newer), or reconfigure with --disable-webgl.])
5892     fi
5894     if test -n "$MOZ_REQUIRE_ALL_D3DCS" -a -z "$MOZ_FOUND_BOTH_D3D_COMPILERS"; then
5895       AC_MSG_ERROR([Both D3D compilers _43 and _46+ are required by --enable-require-d3d-compilers.])
5896       AC_MSG_ERROR([  Install Windows SDK 8.0+, as well as DirectX SDK (June 2010 version or newer), or reconfigure without this flag.])
5897     fi
5898   fi
5902 dnl ========================================================
5903 dnl Gamepad support
5904 dnl ========================================================
5905 MOZ_GAMEPAD=
5906 MOZ_GAMEPAD_BACKEND=stub
5908 # Gamepad DOM is built on supported platforms by default.
5909 case "$OS_TARGET" in
5910      Darwin|WINNT|Linux)
5911        MOZ_GAMEPAD=1
5912        ;;
5913      Android)
5914        if test "$MOZ_WIDGET_TOOLKIT" != "gonk"; then
5915          MOZ_GAMEPAD=1
5916        fi
5917        ;;
5918      *)
5919        ;;
5920 esac
5922 MOZ_ARG_DISABLE_BOOL(gamepad,
5923 [  --disable-gamepad   Disable gamepad support],
5924     MOZ_GAMEPAD=,
5925     MOZ_GAMEPAD=1)
5927 if test "$MOZ_GAMEPAD"; then
5928     case "$OS_TARGET" in
5929     Darwin)
5930         MOZ_GAMEPAD_BACKEND=cocoa
5931         ;;
5932     WINNT)
5933         case "$MOZ_WINSDK_MAXVER" in
5934         # We support building with the Windows 7 SDK otherwise, but
5935         # Gamepad support requires the Windows 8 SDK for some HID headers.
5936         0x0601*)
5937           AC_MSG_ERROR([The Windows 8 SDK or newer is required to build Gamepad support. Please install a newer Windows SDK or reconfigure with --disable-gamepad to disable gamepad support.])
5938           ;;
5939         *)
5940           ;;
5941         esac
5942         MOZ_GAMEPAD_BACKEND=windows
5943         ;;
5944     Linux)
5945         MOZ_CHECK_HEADER([linux/joystick.h])
5946         if test "$ac_cv_header_linux_joystick_h" != "yes"; then
5947           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.])
5948         fi
5949         MOZ_GAMEPAD_BACKEND=linux
5950         ;;
5951     Android)
5952         MOZ_GAMEPAD_BACKEND=android
5953         ;;
5954     *)
5955         ;;
5956    esac
5958   AC_DEFINE(MOZ_GAMEPAD)
5960 AC_SUBST(MOZ_GAMEPAD)
5961 AC_SUBST(MOZ_GAMEPAD_BACKEND)
5963 dnl ========================================================
5964 dnl = Breakpad crash reporting (on by default on supported platforms)
5965 dnl ========================================================
5967 case $target in
5968 i?86-*-mingw*|x86_64-*-mingw*)
5969   MOZ_CRASHREPORTER=1
5970   ;;
5971 i?86-apple-darwin*|x86_64-apple-darwin*)
5972   MOZ_CRASHREPORTER=1
5973   ;;
5974 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
5975   if test "$MOZ_ENABLE_GTK"; then
5976     MOZ_CRASHREPORTER=1
5977   fi
5978   ;;
5979 *-android*|*-linuxandroid*)
5980   MOZ_CRASHREPORTER=1
5981   ;;
5982 *solaris*)
5983   MOZ_CRASHREPORTER=1
5984   ;;
5985 esac
5987 MOZ_ARG_DISABLE_BOOL(crashreporter,
5988 [  --disable-crashreporter Disable breakpad crash reporting],
5989     [MOZ_CRASHREPORTER=],
5990     [MOZ_CRASHREPORTER=F # Force enable breakpad])
5992 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT"; then
5993   if test "$MOZ_CRASHREPORTER" = F; then
5994     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
5995   fi
5996   MOZ_CRASHREPORTER=
5999 if test -n "$MOZ_CRASHREPORTER"; then
6000    AC_DEFINE(MOZ_CRASHREPORTER)
6002   if test "$OS_TARGET" = "Linux" -o "$OS_ARCH" = "SunOS" && \
6003     test -z "$SKIP_LIBRARY_CHECKS"; then
6004     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
6005     AC_SUBST(MOZ_GTHREAD_CFLAGS)
6006     AC_SUBST(MOZ_GTHREAD_LIBS)
6007   fi
6009   if test "$OS_ARCH" = "WINNT"; then
6010     if test -z "$HAVE_64BIT_OS"; then
6011       MOZ_CRASHREPORTER_INJECTOR=1
6012       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
6013     fi
6014   fi
6017 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
6018 [  --with-crashreporter-enable-percent=NN
6019                           Enable sending crash reports by default on NN% of users. (default=100)],
6020 [ val=`echo $withval | sed 's/[^0-9]//g'`
6021     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
6023 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
6024    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
6026 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
6028 dnl ========================================================
6029 dnl = libjpeg-turbo configuration
6030 dnl ========================================================
6031 MOZ_LIBJPEG_TURBO=
6032 if test -z "$MOZ_NATIVE_JPEG"; then
6033     MOZ_LIBJPEG_TURBO=1
6036 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
6037 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
6038     MOZ_LIBJPEG_TURBO=,
6039     MOZ_LIBJPEG_TURBO=1)
6041 if test "$MOZ_NATIVE_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
6042     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
6045 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
6046 dnl files.
6048 if test -n "$MOZ_LIBJPEG_TURBO"; then
6050   dnl Do we support libjpeg-turbo on this platform?
6051   case "$OS_ARCH:$OS_TEST" in
6052   Darwin:i?86)
6053     LIBJPEG_TURBO_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC -DMACHO"
6054     LIBJPEG_TURBO_X86_ASM=1
6055   ;;
6056   Darwin:x86_64)
6057     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
6058     LIBJPEG_TURBO_X64_ASM=1
6059   ;;
6060   WINNT:x86|WINNT:i?86)
6061     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
6062     LIBJPEG_TURBO_X86_ASM=1
6063   ;;
6064   WINNT:x86_64)
6065     LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
6066     LIBJPEG_TURBO_X64_ASM=1
6067   ;;
6068   *:arm*)
6069     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
6070     LIBJPEG_TURBO_ARM_ASM=1
6071   ;;
6072   *:x86|*:i?86)
6073     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6074       LIBJPEG_TURBO_ASFLAGS="-f elf32 -rnasm -pnasm -DPIC -DELF"
6075       LIBJPEG_TURBO_X86_ASM=1
6076     fi
6077   ;;
6078   *:x86_64)
6079     if $CC -E -dM -</dev/null | grep -q __ELF__; then
6080       LIBJPEG_TURBO_ASFLAGS="-f elf64 -rnasm -pnasm -D__x86_64__ -DPIC -DELF"
6081       LIBJPEG_TURBO_X64_ASM=1
6082     fi
6083   ;;
6084   esac
6088 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
6089 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
6090 dnl it doesn't exist or we have too old of a version.
6091 if test -n "$LIBJPEG_TURBO_X86_ASM" -o -n "$LIBJPEG_TURBO_X64_ASM" ; then
6092     LIBJPEG_TURBO_AS=$YASM
6094     if test -z "$LIBJPEG_TURBO_AS" ; then
6095         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.])
6096     fi
6098     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
6099     dnl on Linux and 1.1 or newer everywhere else.
6100     if test "$OS_ARCH" = "Linux" ; then
6101         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
6102             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.])
6103         fi
6104     else
6105         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
6106             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.])
6107         fi
6108     fi
6111 dnl If we're on an ARM system which supports libjpeg-turbo's asm routines and
6112 dnl --disable-libjpeg-turbo wasn't passed, use the C compiler as the assembler.
6113 if test -n "$LIBJPEG_TURBO_ARM_ASM" ; then
6114     echo "Using $AS as the assembler for ARM code."
6115     LIBJPEG_TURBO_AS=$AS
6118 if test -n "$LIBJPEG_TURBO_X86_ASM"; then
6119     AC_DEFINE(LIBJPEG_TURBO_X86_ASM)
6120 elif test -n "$LIBJPEG_TURBO_X64_ASM"; then
6121     AC_DEFINE(LIBJPEG_TURBO_X64_ASM)
6122 elif test -n "$LIBJPEG_TURBO_ARM_ASM"; then
6123     AC_DEFINE(LIBJPEG_TURBO_ARM_ASM)
6124 elif test -n "$MOZ_LIBJPEG_TURBO"; then
6125     dnl Warn if we're not building the optimized routines, even though the user
6126     dnl didn't specify --disable-libjpeg-turbo.
6127     AC_MSG_WARN([No assembler or assembly support for libjpeg-turbo.  Using unoptimized C routines.])
6130 dnl ========================================================
6131 dnl = Enable compilation of specific extension modules
6132 dnl ========================================================
6134 MOZ_ARG_ENABLE_STRING(extensions,
6135 [  --enable-extensions     Enable extensions],
6136 [ for option in `echo $enableval | sed 's/,/ /g'`; do
6137     if test "$option" = "yes" -o "$option" = "all"; then
6138         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
6139     elif test "$option" = "no" -o "$option" = "none"; then
6140         MOZ_EXTENSIONS=""
6141     elif test "$option" = "default"; then
6142         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
6143     elif test `echo "$option" | grep -c \^-` != 0; then
6144         option=`echo $option | sed 's/^-//'`
6145         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
6146     else
6147         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
6148     fi
6149 done],
6150     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
6152 if test -z "$MOZ_ENABLE_GNOMEVFS" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6153     # Suppress warning on non-X11 platforms
6154     if test -n "$MOZ_X11"; then
6155         AC_MSG_WARN([Removing gnomevfs from MOZ_EXTENSIONS due to no --enable-gnomevfs.])
6156     fi
6157     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6160 dnl Do not build gnomevfs with libxul based apps
6161 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` -ne 0; then
6162     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gnomevfs||'`
6165 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6166     # Suppress warning on non-X11 platforms
6167     if test -n "$MOZ_X11"; then
6168         AC_MSG_WARN([Removing gio from MOZ_EXTENSIONS due to --disable-gio.])
6169     fi
6170     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6173 dnl Do not build gio with libxul based apps
6174 if test -n "$LIBXUL_SDK_DIR" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6175     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6178 if test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
6179     MOZ_GIO_COMPONENT=1
6180     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
6182 AC_SUBST(MOZ_GIO_COMPONENT)
6184 if test -z "$MOZ_JSDEBUGGER" -a `echo "$MOZ_EXTENSIONS" | grep -c venkman` -ne 0; then
6185     AC_MSG_WARN([Cannot build venkman without JavaScript debug library. Removing venkman from MOZ_EXTENSIONS.])
6186     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|venkman||'`
6189 dnl Remove dupes
6190 MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}`
6192 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
6193 dnl when trying to build a nonexistent extension.
6194 for extension in $MOZ_EXTENSIONS; do
6195     if test ! -d "${srcdir}/extensions/${extension}"; then
6196         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
6197     fi
6198 done
6200 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
6201   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
6204 dnl ========================================================
6205 dnl Build Freetype in the tree
6206 dnl ========================================================
6207 MOZ_ARG_ENABLE_BOOL(tree-freetype,
6208 [  --enable-tree-freetype  Enable Tree FreeType],
6209     MOZ_TREE_FREETYPE=1,
6210     MOZ_TREE_FREETYPE= )
6211 if test -n "$MOZ_TREE_FREETYPE"; then
6212    if test -n "$_WIN32_MSVC"; then
6213       AC_ERROR("building with in-tree freetype is not supported on MSVC")
6214    fi
6215    AC_DEFINE(MOZ_TREE_FREETYPE)
6216    AC_SUBST(MOZ_TREE_FREETYPE)
6217    MOZ_ENABLE_CAIRO_FT=1
6218    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
6219    FT2_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6220    CAIRO_FT_CFLAGS='-I$(topsrcdir)/modules/freetype2/include'
6221    FT2_LIBS='$(call EXPAND_LIBNAME_PATH,freetype,$(DEPTH)/modules/freetype2/.libs)'
6222    CAIRO_FT_OSLIBS=''
6223    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
6224    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
6225    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
6226    AC_SUBST(CAIRO_FT_CFLAGS)
6229 dnl ========================================================
6230 dnl Installer
6231 dnl ========================================================
6232 dnl Abort Windows build if the required major version and
6233 dnl minimum minor version of Unicode NSIS isn't in the path
6234 dnl (unless in case of cross compiling, for which Unicode
6235 dnl is not yet sufficient).
6236 if test "$OS_ARCH" = "WINNT"; then
6237     MIN_NSIS_MAJOR_VER=2
6238     MIN_NSIS_MINOR_VER=46
6239     MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensisu-3.0a2.exe makensisu-2.46.exe makensis)
6240     if test -n "$MAKENSISU" -a "$MAKENSISU" != ":"; then
6241       AC_MSG_RESULT([yes])
6242       MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null`
6243       changequote(,)
6244       MAKENSISU_PARSED_VER=`echo "$MAKENSISU_VER" | sed -e '/-Unicode/!s/.*//g' -e 's/^v\([0-9]\+\.[0-9]\+\).*\-Unicode$/\1/g'`
6245       changequote([,])
6246       if test "$MAKENSISU_PARSED_VER" = ""; then
6247           changequote(,)
6248           MAKENSISU_PARSED_VER=`echo "$MAKENSISU_VER" | sed -e 's/^v\([0-9]\+\.[0-9]\+\).*$/\1/g'`
6249           changequote([,])
6250       fi
6251       MAKENSISU_MAJOR_VER=0
6252       MAKENSISU_MINOR_VER=0
6253       if test ! "$MAKENSISU_PARSED_VER" = ""; then
6254           MAKENSISU_MAJOR_VER=`echo $MAKENSISU_PARSED_VER | $AWK -F\. '{ print $1 }'`
6255           MAKENSISU_MINOR_VER=`echo $MAKENSISU_PARSED_VER | $AWK -F\. '{ print $2 }'`
6256       fi
6257       AC_MSG_CHECKING([for Unicode NSIS version $MIN_NSIS_MAJOR_VER.$MIN_NSIS_MINOR_VER or greater])
6258       if test "$MAKENSISU_MAJOR_VER" -eq $MIN_NSIS_MAJOR_VER -a \
6259               "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER ||
6260          test "$MAKENSISU_MAJOR_VER" -gt $MIN_NSIS_MAJOR_VER; then
6261           AC_MSG_RESULT([yes])
6262       else
6263           AC_MSG_RESULT([no])
6264           if test -z "$CROSS_COMPILE"; then
6265             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.])
6266           else
6267             MAKENSISU=
6268           fi
6269       fi
6270     elif test -z "$CROSS_COMPILE"; then
6271       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.])
6272     else
6273       MAKENSISU=
6274     fi
6277 dnl ========================================================
6278 dnl Web App Runtime
6279 dnl ========================================================
6280 MOZ_ARG_DISABLE_BOOL(webapp-runtime,
6281 [  --disable-webapp-runtime  Disable Web App Runtime],
6282     MOZ_WEBAPP_RUNTIME=,
6283     MOZ_WEBAPP_RUNTIME=1)
6284 if test "$MOZ_WIDGET_TOOLKIT" != "windows" -a "$MOZ_WIDGET_TOOLKIT" != "cocoa" -a -z "$MOZ_WIDGET_GTK" ; then
6285     MOZ_WEBAPP_RUNTIME=
6287 if test "$OS_ARCH" = "WINNT" -a -z "$MAKENSISU" -a -n "$CROSS_COMPILE"; then
6288     MOZ_WEBAPP_RUNTIME=
6290 AC_SUBST(MOZ_WEBAPP_RUNTIME)
6291 if test "$MOZ_WEBAPP_RUNTIME"; then
6292     AC_DEFINE(MOZ_WEBAPP_RUNTIME)
6295 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
6296 if test -z "$TAR"; then
6297     AC_MSG_ERROR([no tar archiver found in \$PATH])
6299 AC_SUBST(TAR)
6301 AC_CHECK_PROGS(WGET, wget, "")
6302 AC_SUBST(WGET)
6304 dnl ========================================================
6305 dnl Signing
6306 dnl ========================================================
6308 if test -n "$MOZ_SIGN_CMD"; then
6309     AC_DEFINE(MOZ_SIGNING)
6312 dnl ========================================================
6313 dnl Maintenance Service
6314 dnl ========================================================
6316 MOZ_ARG_ENABLE_BOOL(maintenance-service,
6317 [  --enable-maintenance-service       Enable building of maintenanceservice],
6318     MOZ_MAINTENANCE_SERVICE=1,
6319     MOZ_MAINTENANCE_SERVICE= )
6321 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
6322   if test "$OS_ARCH" = "WINNT"; then
6323     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
6324   else
6325     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
6326   fi
6329 dnl ========================================================
6330 dnl Bundled fonts on desktop platforms
6331 dnl ========================================================
6333 MOZ_ARG_ENABLE_BOOL(bundled-fonts,
6334 [  --enable-bundled-fonts  Enable support for bundled fonts on desktop platforms],
6335     MOZ_BUNDLED_FONTS=1,
6336     MOZ_BUNDLED_FONTS=)
6338 if test -n "$MOZ_BUNDLED_FONTS"; then
6339   AC_DEFINE(MOZ_BUNDLED_FONTS)
6342 dnl ========================================================
6343 dnl Verify MAR signatures
6344 dnl ========================================================
6346 MOZ_ARG_ENABLE_BOOL(verify-mar,
6347 [  --enable-verify-mar     Enable verifying MAR signatures],
6348     MOZ_VERIFY_MAR_SIGNATURE=1,
6349     MOZ_VERIFY_MAR_SIGNATURE= )
6351 if test -n "$MOZ_VERIFY_MAR_SIGNATURE"; then
6352   if test "$OS_ARCH" = "WINNT"; then
6353     AC_DEFINE(MOZ_VERIFY_MAR_SIGNATURE)
6354   else
6355     AC_MSG_ERROR([Can only build with --enable-verify-mar with a Windows target])
6356   fi
6359 dnl ========================================================
6360 dnl Enable building the signmar program.
6361 dnl This option is much different than the --enable-verify-mar option.
6362 dnl --enable-verify-mar is for enabling the verification check on MAR
6363 dnl files in the updater.  The --enable-signmar option is for building
6364 dnl the signmar program.
6365 dnl ========================================================
6367 MOZ_ARG_ENABLE_BOOL(signmar,
6368 [  --enable-signmar     Enable building the signmar program],
6369     MOZ_ENABLE_SIGNMAR=1,
6370     MOZ_ENABLE_SIGNMAR= )
6372 if test -n "$MOZ_ENABLE_SIGNMAR"; then
6373   AC_DEFINE(MOZ_ENABLE_SIGNMAR)
6376 dnl ========================================================
6377 dnl Updater
6378 dnl ========================================================
6380 MOZ_ARG_DISABLE_BOOL(updater,
6381 [  --disable-updater       Disable building of updater],
6382     MOZ_UPDATER=,
6383     MOZ_UPDATER=1 )
6385 if test -n "$MOZ_UPDATER"; then
6386     AC_DEFINE(MOZ_UPDATER)
6389 # tools/update-packaging is not checked out by default.
6390 MOZ_ARG_ENABLE_BOOL(update-packaging,
6391 [  --enable-update-packaging
6392                           Enable tools/update-packaging],
6393     MOZ_UPDATE_PACKAGING=1,
6394     MOZ_UPDATE_PACKAGING= )
6395 AC_SUBST(MOZ_UPDATE_PACKAGING)
6397 dnl ========================================================
6398 dnl build the tests by default
6399 dnl ========================================================
6400 MOZ_ARG_DISABLE_BOOL(tests,
6401 [  --disable-tests         Do not build test libraries & programs],
6402     ENABLE_TESTS=,
6403     ENABLE_TESTS=1 )
6405 if test -n "$ENABLE_TESTS"; then
6406     GTEST_HAS_RTTI=0
6407     AC_DEFINE(ENABLE_TESTS)
6408     AC_DEFINE_UNQUOTED(GTEST_HAS_RTTI, 0)
6409     AC_SUBST(GTEST_HAS_RTTI)
6410     if test -n "$_WIN32_MSVC"; then
6411           AC_DEFINE_UNQUOTED(_VARIADIC_MAX, 10)
6412     fi
6413     if test "${OS_TARGET}" = "Android"; then
6414         AC_DEFINE(GTEST_OS_LINUX_ANDROID)
6415         AC_DEFINE(GTEST_USE_OWN_TR1_TUPLE)
6416         AC_DEFINE_UNQUOTED(GTEST_HAS_CLONE, 0)
6417         AC_SUBST(GTEST_OS_LINUX_ANDROID)
6418         AC_SUBST(GTEST_USE_OWN_TR1_TUPLE)
6419         AC_SUBST(GTEST_HAS_CLONE)
6420     fi
6423 dnl ========================================================
6424 dnl parental controls (for Windows Vista)
6425 dnl ========================================================
6426 MOZ_ARG_DISABLE_BOOL(parental-controls,
6427 [  --disable-parental-controls
6428                           Do not build parental controls],
6429    MOZ_DISABLE_PARENTAL_CONTROLS=1,
6430    MOZ_DISABLE_PARENTAL_CONTROLS=)
6431 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
6432     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
6435 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
6437 dnl ========================================================
6438 dnl = Disable DOMCrypto
6439 dnl ========================================================
6440 if test -n "$MOZ_DISABLE_CRYPTOLEGACY"; then
6441     AC_DEFINE(MOZ_DISABLE_CRYPTOLEGACY)
6443 AC_SUBST(MOZ_DISABLE_CRYPTOLEGACY)
6445 dnl ========================================================
6446 dnl = Disable EV certificate verification
6447 dnl ========================================================
6448 if test -n "$MOZ_NO_EV_CERTS"; then
6449     AC_DEFINE(MOZ_NO_EV_CERTS)
6451 AC_SUBST(MOZ_NO_EV_CERTS)
6453 dnl ========================================================
6454 dnl = Disable libpkix
6455 dnl ========================================================
6456 if test -n "$NSS_NO_LIBPKIX"; then
6457     AC_DEFINE(NSS_NO_LIBPKIX)
6459 AC_SUBST(NSS_NO_LIBPKIX)
6461 dnl ========================================================
6462 dnl = Content process sandboxing
6463 dnl ========================================================
6464 if test -n "$gonkdir"; then
6465     MOZ_CONTENT_SANDBOX=1
6468 MOZ_ARG_ENABLE_BOOL(content-sandbox,
6469 [  --enable-content-sandbox        Enable sandboxing support for content-processes],
6470     MOZ_CONTENT_SANDBOX=1,
6471     MOZ_CONTENT_SANDBOX=)
6473 if test -n "$MOZ_CONTENT_SANDBOX"; then
6474     AC_DEFINE(MOZ_CONTENT_SANDBOX)
6477 AC_SUBST(MOZ_CONTENT_SANDBOX)
6479 MOZ_ARG_ENABLE_BOOL(content-sandbox-reporter,
6480 [ --enable-content-sandbox-reporter        Enable syscall reporter to troubleshoot syscalls denied by the content-processes sandbox],
6481     MOZ_CONTENT_SANDBOX_REPORTER=1,
6482     MOZ_CONTENT_SANDBOX_REPORTER=)
6484 if test -n "$MOZ_CONTENT_SANDBOX_REPORTER"; then
6485     AC_DEFINE(MOZ_CONTENT_SANDBOX_REPORTER)
6488 AC_SUBST(MOZ_CONTENT_SANDBOX_REPORTER)
6490 dnl ========================================================
6491 dnl =
6492 dnl = Module specific options
6493 dnl =
6494 dnl ========================================================
6495 MOZ_ARG_HEADER(Individual module options)
6497 dnl ========================================================
6498 dnl = Disable feed handling components
6499 dnl ========================================================
6500 MOZ_ARG_DISABLE_BOOL(feeds,
6501 [  --disable-feeds         Disable feed handling and processing components],
6502     MOZ_FEEDS=,
6503     MOZ_FEEDS=1 )
6504 if test -n "$MOZ_FEEDS"; then
6505     AC_DEFINE(MOZ_FEEDS)
6506 else
6507     if test "$MOZ_BUILD_APP" = "browser"; then
6508         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
6509     fi
6512 dnl ========================================================
6513 dnl Check for sqlite
6514 dnl ========================================================
6516 MOZ_NATIVE_SQLITE=
6517 MOZ_ARG_ENABLE_BOOL(system-sqlite,
6518 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
6519 MOZ_NATIVE_SQLITE=1,
6520 MOZ_NATIVE_SQLITE= )
6522 if test -z "$MOZ_NATIVE_SQLITE"
6523 then
6524     SQLITE_CFLAGS=
6525     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
6526 else
6527     dnl ============================
6528     dnl === SQLite Version check ===
6529     dnl ============================
6530     dnl Check to see if the system SQLite package is new enough.
6531     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
6533     dnl ==================================
6534     dnl === SQLITE_SECURE_DELETE check ===
6535     dnl ==================================
6536     dnl Check to see if the system SQLite package is compiled with
6537     dnl SQLITE_SECURE_DELETE enabled.
6538     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
6539     _SAVE_CFLAGS="$CFLAGS"
6540     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6541     _SAVE_LIBS="$LIBS"
6542     LIBS="$LIBS $SQLITE_LIBS"
6543     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
6544         AC_TRY_RUN([
6545             #include "sqlite3.h"
6547             int main(int argc, char **argv){
6548               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
6549             }],
6550             ac_cv_sqlite_secure_delete=yes,
6551             ac_cv_sqlite_secure_delete=no,
6552             ac_cv_sqlite_secure_delete=no
6553         )
6554     ])
6555     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
6556     CFLAGS="$_SAVE_CFLAGS"
6557     LIBS="$_SAVE_LIBS"
6558     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
6559         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
6560     fi
6562     dnl ===============================
6563     dnl === SQLITE_THREADSAFE check ===
6564     dnl ===============================
6565     dnl Check to see if the system SQLite package is compiled with
6566     dnl SQLITE_THREADSAFE enabled.
6567     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
6568     _SAVE_CFLAGS="$CFLAGS"
6569     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6570     _SAVE_LIBS="$LIBS"
6571     LIBS="$LIBS $SQLITE_LIBS"
6572     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
6573         AC_TRY_RUN([
6574             #include "sqlite3.h"
6576             int main(int argc, char **argv){
6577               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
6578             }],
6579             ac_cv_sqlite_threadsafe=yes,
6580             ac_cv_sqlite_threadsafe=no,
6581             ac_cv_sqlite_threadsafe=no
6582         )
6583     ])
6584     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
6585     CFLAGS="$_SAVE_CFLAGS"
6586     LIBS="$_SAVE_LIBS"
6587     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
6588         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
6589     fi
6591     dnl ================================
6592     dnl === SQLITE_ENABLE_FTS3 check ===
6593     dnl ================================
6594     dnl check to see if the system SQLite package is compiled with
6595     dnl SQLITE_ENABLE_FTS3 enabled.
6596     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
6597     _SAVE_CFLAGS="$CFLAGS"
6598     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6599     _SAVE_LIBS="$LIBS"
6600     LIBS="$LIBS $SQLITE_LIBS"
6601     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
6602         AC_TRY_RUN([
6603             #include "sqlite3.h"
6605             int main(int argc, char **argv){
6606               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
6607             }],
6608             ac_cv_sqlite_enable_fts3=yes,
6609             ac_cv_sqlite_enable_fts3=no,
6610             ac_cv_sqlite_enable_fts3=no
6611         )
6612     ])
6613     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
6614     CFLAGS="$_SAVE_CFLAGS"
6615     LIBS="$_SAVE_LIBS"
6616     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
6617         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
6618     fi
6620     dnl =========================================
6621     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
6622     dnl =========================================
6623     dnl check to see if the system SQLite package is compiled with
6624     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
6625     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
6626     _SAVE_CFLAGS="$CFLAGS"
6627     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
6628     _SAVE_LIBS="$LIBS"
6629     LIBS="$LIBS $SQLITE_LIBS"
6630     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
6631         AC_TRY_RUN([
6632             #include "sqlite3.h"
6634             int main(int argc, char **argv){
6635               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
6636             }],
6637             ac_cv_sqlite_enable_unlock_notify=yes,
6638             ac_cv_sqlite_enable_unlock_notify=no,
6639             ac_cv_sqlite_enable_unlock_notify=no
6640         )
6641     ])
6642     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
6643     CFLAGS="$_SAVE_CFLAGS"
6644     LIBS="$_SAVE_LIBS"
6645     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
6646         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
6647     fi
6650 if test -n "$MOZ_NATIVE_SQLITE"; then
6651     AC_DEFINE(MOZ_NATIVE_SQLITE)
6653 AC_SUBST(MOZ_NATIVE_SQLITE)
6655 dnl ========================================================
6656 dnl = Enable help viewer (off by default)
6657 dnl ========================================================
6658 if test -n "$MOZ_HELP_VIEWER"; then
6659      dnl Do this if defined in confvars.sh
6660      AC_DEFINE(MOZ_HELP_VIEWER)
6663 dnl ========================================================
6664 dnl = Enable safe browsing (anti-phishing)
6665 dnl ========================================================
6666 MOZ_ARG_ENABLE_BOOL(safe-browsing,
6667 [  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation],
6668     MOZ_SAFE_BROWSING=1,
6669     MOZ_SAFE_BROWSING= )
6670 if test -n "$MOZ_SAFE_BROWSING"; then
6671     AC_DEFINE(MOZ_SAFE_BROWSING)
6673 AC_SUBST(MOZ_SAFE_BROWSING)
6675 dnl ========================================================
6676 dnl = Enable url-classifier
6677 dnl ========================================================
6678 dnl Implicitly enabled by default if building with safe-browsing
6679 if test -n "$MOZ_SAFE_BROWSING"; then
6680     MOZ_URL_CLASSIFIER=1
6682 MOZ_ARG_ENABLE_BOOL(url-classifier,
6683 [  --enable-url-classifier Enable url classifier module],
6684     MOZ_URL_CLASSIFIER=1,
6685     MOZ_URL_CLASSIFIER= )
6686 if test -n "$MOZ_URL_CLASSIFIER"; then
6687     AC_DEFINE(MOZ_URL_CLASSIFIER)
6689 AC_SUBST(MOZ_URL_CLASSIFIER)
6691 dnl ========================================================
6692 dnl = Disable zipwriter
6693 dnl ========================================================
6694 MOZ_ARG_DISABLE_BOOL(zipwriter,
6695 [  --disable-zipwriter     Disable zipwriter component],
6696     MOZ_ZIPWRITER=,
6697     MOZ_ZIPWRITER=1 )
6698 AC_SUBST(MOZ_ZIPWRITER)
6700 dnl ========================================================
6701 dnl GL provider
6702 dnl ========================================================
6703 MOZ_GL_PROVIDER=
6704 MOZ_ARG_WITH_STRING(gl-provider,
6705 [  --with-gl-provider=ID
6706                           Set GL provider backend type],
6707 [ val=`echo $withval`
6708     MOZ_GL_PROVIDER="$val"])
6710 if test -n "$MOZ_GL_PROVIDER"; then
6711 MOZ_GL_DEFAULT_PROVIDER=$MOZ_GL_PROVIDER
6712 AC_SUBST(MOZ_GL_PROVIDER)
6713 AC_DEFINE_UNQUOTED(MOZ_GL_PROVIDER, GLContextProvider$MOZ_GL_PROVIDER)
6715 AC_SUBST(MOZ_GL_DEFAULT_PROVIDER)
6716 AC_DEFINE_UNQUOTED(GL_PROVIDER_$MOZ_GL_DEFAULT_PROVIDER)
6718 dnl ========================================================
6719 dnl = faststripe theme
6720 dnl ========================================================
6721 MOZ_ARG_ENABLE_BOOL(faststripe,
6722 [  --enable-faststripe     Use faststripe theme],
6723     MOZ_THEME_FASTSTRIPE=1,
6724     MOZ_THEME_FASTSTRIPE= )
6725 AC_SUBST(MOZ_THEME_FASTSTRIPE)
6727 dnl ========================================================
6728 dnl =
6729 dnl = Feature options that require extra sources to be pulled
6730 dnl =
6731 dnl ========================================================
6732 dnl MOZ_ARG_HEADER(Features that require extra sources)
6734 dnl ========================================================
6735 dnl =
6736 dnl = Runtime debugging and Optimization Options
6737 dnl =
6738 dnl ========================================================
6739 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
6741 dnl ========================================================
6742 dnl enable mobile optimizations
6743 dnl ========================================================
6744 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
6745 [  --enable-mobile-optimize
6746                           Enable mobile optimizations],
6747     MOZ_GFX_OPTIMIZE_MOBILE=1)
6749 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
6751 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
6752     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
6755 dnl ========================================================
6756 dnl = Enable code optimization. ON by default.
6757 dnl ========================================================
6758 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
6759     MOZ_OPTIMIZE_FLAGS="-O"
6762 MOZ_ARG_ENABLE_STRING(optimize,
6763 [  --disable-optimize      Disable compiler optimization
6764   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
6765 [ if test "$enableval" != "no"; then
6766     MOZ_OPTIMIZE=1
6767     if test -n "$enableval" -a "$enableval" != "yes"; then
6768         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
6769         MOZ_OPTIMIZE=2
6770     fi
6771 else
6772     MOZ_OPTIMIZE=
6773 fi ], MOZ_OPTIMIZE=1)
6775 MOZ_SET_FRAMEPTR_FLAGS
6777 if test "$COMPILE_ENVIRONMENT"; then
6778 if test -n "$MOZ_OPTIMIZE"; then
6779     AC_MSG_CHECKING([for valid optimization flags])
6780     _SAVE_CFLAGS=$CFLAGS
6781     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
6782     AC_TRY_COMPILE([#include <stdio.h>],
6783         [printf("Hello World\n");],
6784         _results=yes,
6785         _results=no)
6786     AC_MSG_RESULT([$_results])
6787     if test "$_results" = "no"; then
6788         AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
6789     fi
6790     CFLAGS=$_SAVE_CFLAGS
6792 fi # COMPILE_ENVIRONMENT
6794 AC_SUBST(MOZ_OPTIMIZE)
6795 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
6796 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
6797 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
6798 AC_SUBST(MOZ_ALLOW_HEAP_EXECUTE_FLAGS)
6799 AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
6800 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
6802 dnl ========================================================
6803 dnl = Enable any treating of compile warnings as errors
6804 dnl ========================================================
6805 MOZ_ARG_ENABLE_BOOL(warnings-as-errors,
6806 [  --enable-warnings-as-errors
6807                           Enable treating of warnings as errors],
6808     MOZ_ENABLE_WARNINGS_AS_ERRORS=1,
6809     MOZ_ENABLE_WARNINGS_AS_ERRORS=)
6810 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
6811    WARNINGS_AS_ERRORS=''
6812 elif test "$GNU_CC"; then
6813     # Prevent the following GCC warnings from being treated as errors:
6814     # -Wuninitialized - too many false positives
6815     # -Wmaybe-uninitialized - too many false positives
6816     # -Wdeprecated-declarations - we don't want our builds held hostage when a
6817     #   platform-specific API becomes deprecated.
6818     MOZ_C_SUPPORTS_WARNING(-W, no-error=uninitialized, ac_c_has_noerror_uninitialized)
6819     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=uninitialized, ac_cxx_has_noerror_uninitialized)
6820     MOZ_C_SUPPORTS_WARNING(-W, no-error=maybe-uninitialized, ac_c_has_noerror_maybe_uninitialized)
6821     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=maybe-uninitialized, ac_cxx_has_noerror_maybe_uninitialized)
6822     MOZ_C_SUPPORTS_WARNING(-W, no-error=deprecated-declarations, ac_c_has_noerror_deprecated_declarations)
6823     MOZ_CXX_SUPPORTS_WARNING(-W, no-error=deprecated-declarations, ac_cxx_has_noerror_deprecated_declarations)
6826 dnl ========================================================
6827 dnl = Disable runtime logging checks
6828 dnl ========================================================
6829 MOZ_ARG_DISABLE_BOOL(logging,
6830 [  --disable-logging       Disable logging facilities],
6831     NS_DISABLE_LOGGING=1,
6832     NS_DISABLE_LOGGING= )
6833 if test "$NS_DISABLE_LOGGING"; then
6834     AC_DEFINE(NS_DISABLE_LOGGING)
6835 else
6836     AC_DEFINE(MOZ_LOGGING)
6839 dnl ========================================================
6840 dnl = This will enable logging of addref, release, ctor, dtor.
6841 dnl ========================================================
6842 _ENABLE_LOGREFCNT=42
6843 MOZ_ARG_ENABLE_BOOL(logrefcnt,
6844 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
6845     _ENABLE_LOGREFCNT=1,
6846     _ENABLE_LOGREFCNT= )
6847 if test "$_ENABLE_LOGREFCNT" = "1"; then
6848     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
6849 elif test -z "$_ENABLE_LOGREFCNT"; then
6850     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
6853 dnl ========================================================
6854 dnl moz_dump_painting
6855 dnl ========================================================
6856 MOZ_ARG_ENABLE_BOOL(dump-painting,
6857 [  --enable-dump-painting          Enable paint debugging.],
6858     MOZ_DUMP_PAINTING=1,
6859     MOZ_DUMP_PAINTING= )
6860 if test -n "$MOZ_DUMP_PAINTING"; then
6861     AC_DEFINE(MOZ_DUMP_PAINTING)
6862     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
6864 if test -n "$MOZ_DEBUG"; then
6865     AC_DEFINE(MOZ_DUMP_PAINTING)
6868 dnl ========================================================
6869 dnl = Enable trace malloc
6870 dnl ========================================================
6871 NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
6872 MOZ_ARG_ENABLE_BOOL(trace-malloc,
6873 [  --enable-trace-malloc   Enable malloc tracing; also disables DMD and jemalloc],
6874     NS_TRACE_MALLOC=1,
6875     NS_TRACE_MALLOC= )
6876 if test "$NS_TRACE_MALLOC"; then
6877   # Please, Mr. Linker Man, don't take away our symbol names
6878   MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
6879   AC_DEFINE(NS_TRACE_MALLOC)
6881 AC_SUBST(NS_TRACE_MALLOC)
6883 dnl ========================================================
6884 dnl = Enable DMD
6885 dnl ========================================================
6887 MOZ_ARG_ENABLE_BOOL(dmd,
6888 [  --enable-dmd            Enable DMD; also enables jemalloc and replace-malloc],
6889     MOZ_DMD=1,
6890     MOZ_DMD= )
6892 dnl The two options are conflicting. Fails the configure to alert the user.
6893 if test "$NS_TRACE_MALLOC" -a "$MOZ_DMD"; then
6894     AC_MSG_ERROR([--enable-trace-malloc and --enable-dmd are conflicting options])
6897 if test "$MOZ_DMD"; then
6898     AC_DEFINE(MOZ_DMD)
6900     if test "${CPU_ARCH}" = "arm"; then
6901         CFLAGS="$CFLAGS -funwind-tables"
6902         CXXFLAGS="$CXXFLAGS -funwind-tables"
6903     fi
6905     MOZ_MEMORY=1                        # DMD enables jemalloc
6906     MOZ_REPLACE_MALLOC=1                # DMD enables replace-malloc
6908 AC_SUBST(MOZ_DMD)
6910 dnl ========================================================
6911 dnl = Enable jemalloc
6912 dnl ========================================================
6913 MOZ_ARG_ENABLE_BOOL(jemalloc,
6914 [  --enable-jemalloc       Replace memory allocator with jemalloc],
6915     MOZ_MEMORY=1,
6916     MOZ_MEMORY=)
6918 if test "$NS_TRACE_MALLOC"; then
6919     MOZ_MEMORY=
6922 if test "${OS_TARGET}" = "Android"; then
6923   dnl On Android, we use WRAP_LDFLAGS to link everything to mozglue
6924   :
6925 elif test "${OS_TARGET}" = "WINNT" -o "${OS_TARGET}" = "Darwin"; then
6926   dnl On Windows and OSX, we want to link all our binaries against mozglue
6927   if test -z "$GNU_CC"; then
6928     MOZ_GLUE_LDFLAGS='$(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
6929   else
6930     MOZ_GLUE_LDFLAGS='-L$(LIBXUL_DIST)/lib $(call EXPAND_LIBNAME,mozglue)'
6931   fi
6932 else
6933   dnl On other Unix systems, we only want to link executables against mozglue
6934   MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
6935   dnl On other Unix systems, where mozglue is a static library, jemalloc is
6936   dnl separated for the SDK, so we need to add it here.
6937   if test "$MOZ_MEMORY" = 1 -o \( "$LIBXUL_SDK" -a -f "$LIBXUL_SDK/lib/${LIB_PREFIX}memory.${LIB_SUFFIX}" \); then
6938     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib)'
6939   fi
6940   MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(MKSHLIB_UNFORCE_ALL)'
6941   if test -n "$GNU_CC"; then
6942     dnl And we need mozglue symbols to be exported.
6943     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
6944   fi
6945   if test "$MOZ_LINKER" = 1; then
6946     MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS $MOZ_ZLIB_LIBS"
6947   fi
6950 dnl ========================================================
6951 dnl = Enable dynamic replacement of malloc implementation
6952 dnl ========================================================
6953 if test -n "$NIGHTLY_BUILD" -a -n "$MOZ_MEMORY"; then
6954   # Enable on central for the debugging opportunities it adds.
6955   MOZ_REPLACE_MALLOC=1
6957 MOZ_ARG_ENABLE_BOOL(replace-malloc,
6958 [  --enable-replace-malloc   Enable ability to dynamically replace the malloc implementation],
6959     MOZ_REPLACE_MALLOC=1,
6960     MOZ_REPLACE_MALLOC= )
6962 dnl The two options are conflicting. Fails the configure to alert the user.
6963 if test "$NS_TRACE_MALLOC" -a "$MOZ_REPLACE_MALLOC"; then
6964     AC_MSG_ERROR([--enable-trace-malloc and --enable-replace-malloc are conflicting options])
6967 if test -n "$MOZ_REPLACE_MALLOC" -a -z "$MOZ_MEMORY"; then
6968     dnl We don't want to enable jemalloc unconditionally because it may be a
6969     dnl deliberate choice not to enable it (bug 702250, for instance)
6970     AC_MSG_ERROR([--enable-replace-malloc requires --enable-jemalloc])
6971 elif test -n "$MOZ_REPLACE_MALLOC"; then
6972     MOZ_NATIVE_JEMALLOC=
6974     dnl Replace-malloc Mac linkage quirks
6975     if test -n "$MACOSX_DEPLOYMENT_TARGET"; then
6976         AC_CACHE_CHECK([how to do weak dynamic linking],
6977             ac_cv_weak_dynamic_linking,
6978             [echo 'extern void foo() __attribute__((weak_import));int bar() { if (foo) foo(); return 0; }' > conftest.c
6979              if AC_TRY_COMMAND([${CC-cc} -o conftest${DLL_SUFFIX} $CFLAGS -dynamiclib $LDFLAGS -Wl,-U,_foo conftest.c $LIBS 1>&5]) &&
6980                 test -s conftest${DLL_SUFFIX}; then
6981                  dnl There are several ways the linker can put link edit rules in a binary:
6982                  dnl - classic info only (for OSX < 10.6)
6983                  dnl - dyld info only
6984                  dnl - both
6985                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO_ONLY" > /dev/null; then
6986                      _CLASSIC_INFO=
6987                  else
6988                      _CLASSIC_INFO=1
6989                  fi
6990                  if otool -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO" > /dev/null; then
6991                      _DYLD_INFO=1
6992                  else
6993                      _DYLD_INFO=
6994                  fi
6995                  dnl With classic info, we need to build with -flat_namespace.
6996                  dnl With dyld info, Xcode 4.5 does the right thing without additional flags,
6997                  dnl but Xcode < 4.5 requires a dummy library and -flat_namespace because it
6998                  dnl forgets to set the weak flag in the dyld info.
6999                  dnl See http://glandium.org/blog/?p=2764 for more details.
7000                  dnl
7001                  dnl Values for ac_cv_weak_dynamic_linking, and subsequently
7002                  dnl MOZ_REPLACE_MALLOC_LINKAGE are thus:
7003                  dnl - "flat namespace" when -flat_namespace alone is needed
7004                  dnl - "dummy library" when a dummy library and -flat_namespace are needed
7005                  dnl - "compiler support" when nothing is needed
7006                  if test -n "$_DYLD_INFO" && dyldinfo -bind conftest${DLL_SUFFIX} 2> /dev/null | grep "_foo (weak import)" > /dev/null; then
7007                      if test -n "$_CLASSIC_INFO"; then
7008                          ac_cv_weak_dynamic_linking="flat namespace"
7009                      else
7010                          ac_cv_weak_dynamic_linking="compiler support"
7011                      fi
7012                  else
7013                      if test -n "$_DYLD_INFO"; then
7014                          ac_cv_weak_dynamic_linking="dummy library"
7015                      else
7016                          ac_cv_weak_dynamic_linking="flat namespace"
7017                      fi
7018                  fi
7019              else
7020                  AC_ERROR([couldn't compile a simple C file])
7021              fi
7022              rm -rf conftest*])
7023         MOZ_REPLACE_MALLOC_LINKAGE="$ac_cv_weak_dynamic_linking"
7024     fi
7026 AC_SUBST(MOZ_REPLACE_MALLOC)
7027 AC_SUBST(MOZ_REPLACE_MALLOC_LINKAGE)
7029 dnl ========================================================
7030 dnl = Jemalloc build setup
7031 dnl ========================================================
7032 if test -z "$MOZ_MEMORY"; then
7033   if test -n "$MOZ_JEMALLOC3" -a -z "$MOZ_REPLACE_MALLOC"; then
7034     MOZ_NATIVE_JEMALLOC=1
7035     AC_CHECK_FUNCS(mallctl nallocm,,
7036       [MOZ_NATIVE_JEMALLOC=
7037        break])
7038     if test -n "$MOZ_NATIVE_JEMALLOC"; then
7039       MOZ_MEMORY=1
7040       AC_DEFINE(MOZ_MEMORY)
7041       AC_DEFINE(MOZ_JEMALLOC3)
7042       AC_DEFINE(MOZ_NATIVE_JEMALLOC)
7043     fi
7044   fi
7045   case "${target}" in
7046     *-mingw*)
7047       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
7048         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.])
7049       fi
7050       ;;
7051   esac
7052 else
7053   AC_DEFINE(MOZ_MEMORY)
7054   if test -n "$MOZ_JEMALLOC3"; then
7055     AC_DEFINE(MOZ_JEMALLOC3)
7056   fi
7057   if test "x$MOZ_DEBUG" = "x1"; then
7058     AC_DEFINE(MOZ_MEMORY_DEBUG)
7059   fi
7060   dnl The generic feature tests that determine how to compute ncpus are long and
7061   dnl complicated.  Therefore, simply define special cpp variables for the
7062   dnl platforms we have special knowledge of.
7063   case "${target}" in
7064   *-darwin*)
7065     AC_DEFINE(MOZ_MEMORY_DARWIN)
7066     ;;
7067   *-*freebsd*)
7068     AC_DEFINE(MOZ_MEMORY_BSD)
7069     ;;
7070   *-android*|*-linuxandroid*)
7071     AC_DEFINE(MOZ_MEMORY_LINUX)
7072     AC_DEFINE(MOZ_MEMORY_ANDROID)
7073     if test -z "$gonkdir"; then
7074       _WRAP_MALLOC=1
7075     else
7076       AC_DEFINE(MOZ_MEMORY_GONK)
7077     fi
7078     MOZ_GLUE_LDFLAGS=
7079     ;;
7080   *-*linux*)
7081     AC_DEFINE(MOZ_MEMORY_LINUX)
7082     ;;
7083   *-netbsd*)
7084     AC_DEFINE(MOZ_MEMORY_BSD)
7085     ;;
7086   *-solaris*)
7087     AC_DEFINE(MOZ_MEMORY_SOLARIS)
7088     ;;
7089   *-mingw*)
7090     AC_DEFINE(MOZ_MEMORY_WINDOWS)
7091     export MOZ_NO_DEBUG_RTL=1
7092     WIN32_CRT_LIBS="msvcrt.lib msvcprt.lib"
7093     dnl Look for a broken crtdll.obj
7094     WIN32_CRTDLL_FULLPATH=`lib -nologo -list $WIN32_CRT_LIBS | grep crtdll\\.obj`
7095     lib -NOLOGO -OUT:crtdll.obj $WIN32_CRT_LIBS -EXTRACT:$WIN32_CRTDLL_FULLPATH
7096     if grep -q '__imp__\{0,1\}free' crtdll.obj; then
7097       MOZ_GLUE_LDFLAGS='-LIBPATH:$(DIST)/lib -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcprt -DEFAULTLIB:mozcrt'
7098       dnl Also pass this to NSPR/NSS
7099       DLLFLAGS="$DLLFLAGS $MOZ_GLUE_LDFLAGS"
7100     else
7101       DLLFLAGS="$DLLFLAGS -LIBPATH:\$(DIST)/lib -DEFAULTLIB:mozglue"
7102     fi
7103     rm crtdll.obj
7105     export DLLFLAGS
7106     ;;
7107   *)
7108     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
7109     ;;
7110   esac
7111 fi # MOZ_MEMORY
7112 AC_SUBST(MOZ_MEMORY)
7113 AC_SUBST(MOZ_JEMALLOC3)
7114 AC_SUBST(MOZ_NATIVE_JEMALLOC)
7115 AC_SUBST(MOZ_GLUE_LDFLAGS)
7116 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
7117 AC_SUBST(WIN32_CRT_LIBS)
7118 dnl Need to set this for make because NSS doesn't have configure
7119 AC_SUBST(DLLFLAGS)
7121 dnl We need to wrap dlopen and related functions on Android because we use
7122 dnl our own linker.
7123 if test "$OS_TARGET" = Android; then
7124     WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
7125     WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=PR_GetEnv,--wrap=PR_SetEnv"
7126     if test "$MOZ_WIDGET_TOOLKIT" = android; then
7127         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
7128     fi
7129     if test -z "$gonkdir"; then
7130         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork,--wrap=raise"
7131         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=memccpy,--wrap=memchr,--wrap=memrchr,--wrap=memcmp,--wrap=memcpy,--wrap=memmove,--wrap=memset,--wrap=memmem,--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"
7132     fi
7133     if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_NUWA_PROCESS"; then
7134         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"
7135     fi
7138 dnl ========================================================
7139 dnl = Use malloc wrapper lib
7140 dnl ========================================================
7141 MOZ_ARG_ENABLE_BOOL(wrap-malloc,
7142 [  --enable-wrap-malloc    Wrap malloc calls (gnu linker only)],
7143     _WRAP_MALLOC=1,
7144     _WRAP_MALLOC= )
7146 if test -n "$_WRAP_MALLOC"; then
7147     if test -n "$GNU_CC"; then
7148         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=malloc,--wrap=calloc,--wrap=valloc,--wrap=free,--wrap=realloc,--wrap=memalign"
7149         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=__builtin_new,--wrap=__builtin_vec_new,--wrap=__builtin_delete,--wrap=__builtin_vec_delete"
7150         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=strdup,--wrap=strndup"
7151         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=vasprintf,--wrap=asprintf"
7152         WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=posix_memalign,--wrap=malloc_usable_size"
7153         dnl Wrap operator new and operator delete on Android.
7154         if test "$OS_TARGET" = "Android"; then
7155             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_Znwj,--wrap=_Znaj,--wrap=_ZdlPv,--wrap=_ZdaPv"
7156             dnl Wrap the nothrow variants too.
7157             WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=_ZnwjRKSt9nothrow_t,--wrap=_ZnajRKSt9nothrow_t,--wrap=_ZdlPvRKSt9nothrow_t,--wrap=_ZdaPvRKSt9nothrow_t"
7158         fi
7159     else
7160         AC_MSG_ERROR([--enable-wrap-malloc is not supported for non-GNU toolchains])
7161     fi
7164 dnl ========================================================
7165 dnl = Location of malloc wrapper lib
7166 dnl ========================================================
7167 MOZ_ARG_WITH_STRING(wrap-malloc,
7168 [  --with-wrap-malloc=DIR  Location of malloc wrapper library],
7169     WRAP_LDFLAGS="${WRAP_LDFLAGS} $withval")
7171 dnl ========================================================
7172 dnl = Use JS Call tracing
7173 dnl ========================================================
7174 MOZ_ARG_ENABLE_BOOL(trace-jscalls,
7175 [  --enable-trace-jscalls  Enable JS call enter/exit callback (default=no)],
7176     MOZ_TRACE_JSCALLS=1,
7177     MOZ_TRACE_JSCALLS= )
7178 if test -n "$MOZ_TRACE_JSCALLS"; then
7179     AC_DEFINE(MOZ_TRACE_JSCALLS)
7182 dnl ========================================================
7183 dnl JS opt-mode assertions and minidump instrumentation
7184 dnl ========================================================
7185 MOZ_ARG_ENABLE_BOOL(js-diagnostics,
7186 [  --enable-js-diagnostics
7187                           Enable JS diagnostic assertions and breakpad data],
7188     JS_CRASH_DIAGNOSTICS=1,
7189     JS_CRASH_DIAGNOSTICS= )
7190 if test -n "$JS_CRASH_DIAGNOSTICS"; then
7191     AC_DEFINE(JS_CRASH_DIAGNOSTICS)
7194 dnl ========================================================
7195 dnl = Use incremental GC
7196 dnl ========================================================
7197 JSGC_INCREMENTAL=1
7198 MOZ_ARG_DISABLE_BOOL(gcincremental,
7199 [  --disable-gcincremental Disable incremental GC],
7200     JSGC_INCREMENTAL= )
7201 if test -n "$JSGC_INCREMENTAL"; then
7202     AC_DEFINE(JSGC_INCREMENTAL)
7205 dnl ========================================================
7206 dnl = Use exact stack rooting for GC
7207 dnl ========================================================
7208 MOZ_ARG_DISABLE_BOOL(exact-rooting,
7209 [  --disable-exact-rooting  Enable use of conservative stack scanning for GC],
7210     JSGC_USE_EXACT_ROOTING= ,
7211     JSGC_USE_EXACT_ROOTING=1 )
7212 if test -n "$JSGC_USE_EXACT_ROOTING"; then
7213     AC_DEFINE(JSGC_USE_EXACT_ROOTING)
7216 dnl ========================================================
7217 dnl = Use generational GC
7218 dnl ========================================================
7219 MOZ_ARG_DISABLE_BOOL(gcgenerational,
7220 [  --disable-gcgenerational Disable generational GC],
7221     JSGC_GENERATIONAL= ,
7222     JSGC_GENERATIONAL=1 )
7223 if test -n "$JSGC_GENERATIONAL"; then
7224     AC_DEFINE(JSGC_GENERATIONAL)
7227 dnl ========================================================
7228 dnl Zealous JavaScript GC
7229 dnl ========================================================
7230 MOZ_ARG_ENABLE_BOOL(gczeal,
7231 [  --enable-gczeal         Enable zealous JavaScript GCing],
7232     JS_GC_ZEAL=1,
7233     JS_GC_ZEAL= )
7234 if test -n "$JS_GC_ZEAL" -o -n "$MOZ_DEBUG"; then
7235     AC_DEFINE(JS_GC_ZEAL)
7238 dnl ========================================================
7239 dnl = Perform moving GC stack rooting analysis
7240 dnl ========================================================
7241 MOZ_ARG_ENABLE_BOOL(root-analysis,
7242 [  --enable-root-analysis  Enable moving GC stack root analysis],
7243     JSGC_ROOT_ANALYSIS=1,
7244     JSGC_ROOT_ANALYSIS= )
7245 if test -n "$JSGC_ROOT_ANALYSIS"; then
7246     AC_DEFINE(JSGC_ROOT_ANALYSIS)
7249 MOZ_CHECK_CCACHE
7251 dnl ========================================================
7252 dnl = Enable static checking using gcc-dehydra
7253 dnl ========================================================
7255 MOZ_ARG_WITH_STRING(static-checking,
7256 [  --with-static-checking=path/to/gcc_dehydra.so
7257                           Enable static checking of code using GCC-dehydra],
7258     DEHYDRA_PATH=$withval,
7259     DEHYDRA_PATH= )
7261 if test -n "$DEHYDRA_PATH"; then
7262     if test ! -f "$DEHYDRA_PATH"; then
7263         AC_MSG_ERROR([The dehydra plugin is not at the specified path.])
7264     fi
7265     AC_DEFINE(NS_STATIC_CHECKING)
7267 AC_SUBST(DEHYDRA_PATH)
7269 dnl ========================================================
7270 dnl = Enable using the clang plugin to build
7271 dnl ========================================================
7273 MOZ_ARG_ENABLE_BOOL(clang-plugin,
7274 [  --enable-clang-plugin   Enable building with the mozilla clang plugin ],
7275    ENABLE_CLANG_PLUGIN=1,
7276    ENABLE_CLANG_PLUGIN= )
7277 if test -n "$ENABLE_CLANG_PLUGIN"; then
7278     if test -z "$CLANG_CC"; then
7279         AC_MSG_ERROR([Can't use clang plugin without clang.])
7280     fi
7281     AC_DEFINE(MOZ_CLANG_PLUGIN)
7284 AC_SUBST(ENABLE_CLANG_PLUGIN)
7286 dnl ========================================================
7287 dnl = Enable stripping of libs & executables
7288 dnl ========================================================
7289 MOZ_ARG_ENABLE_BOOL(strip,
7290 [  --enable-strip          Enable stripping of libs & executables ],
7291     ENABLE_STRIP=1,
7292     ENABLE_STRIP= )
7294 dnl ========================================================
7295 dnl = Enable stripping of libs & executables when packaging
7296 dnl ========================================================
7297 MOZ_ARG_ENABLE_BOOL(install-strip,
7298 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
7299     PKG_SKIP_STRIP= ,
7300     PKG_SKIP_STRIP=1)
7302 dnl ========================================================
7303 dnl = --disable-elf-hack
7304 dnl ========================================================
7306 USE_ELF_HACK=1
7307 MOZ_ARG_DISABLE_BOOL(elf-hack,
7308 [  --disable-elf-hack      Disable elf hacks],
7309     [USE_ELF_HACK=],
7310     [USE_ELF_HACK=F # Force enable elf-hack])
7312 # Disable elf hack for profiling because the built in profiler
7313 # doesn't read the segments properly with elf hack. This is
7314 # temporary and should be fixed soon in the profiler.
7315 if test "$MOZ_PROFILING" = 1; then
7316   if test "$USE_ELF_HACK" = F; then
7317     AC_ERROR([--enable-elf-hack is not compatible with --enable-profiling])
7318   fi
7319   USE_ELF_HACK=
7322 # Only enable elfhack where supported
7323 if test "$USE_ELF_HACK" = 1; then
7324     case "${HOST_OS_ARCH},${OS_ARCH}" in
7325     Linux,Linux)
7326         case "${CPU_ARCH}" in
7327         arm | x86 | x86_64)
7328             USE_ELF_HACK=1
7329             ;;
7330         *)
7331             USE_ELF_HACK=
7332             ;;
7333         esac
7334         ;;
7335     *)
7336         USE_ELF_HACK=
7337         ;;
7338     esac
7341 if test -n "$COMPILE_ENVIRONMENT" -a -n "$USE_ELF_HACK"; then
7342     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
7343     dnl memory addresses it maps to. The result is that by the time elfhack
7344     dnl kicks in, it is not possible to apply relocations because of that,
7345     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
7346     dnl segment. It makes elfhack mostly useless, so considering the problems
7347     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
7348     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
7349     dnl the linker creates PT_GNU_RELRO segments. However, when we do want
7350     dnl elfhack enabled, disable PT_GNU_RELRO instead.
7351     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
7352         LINK_WITH_PT_GNU_RELRO,
7353         [echo "int main() {return 0;}" > conftest.${ac_ext}
7354          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
7355             test -s conftest${ac_exeext}; then
7356             if ${TOOLCHAIN_PREFIX}readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
7357                 LINK_WITH_PT_GNU_RELRO=yes
7358             else
7359                 LINK_WITH_PT_GNU_RELRO=no
7360             fi
7361          else
7362              dnl We really don't expect to get here, but just in case
7363              AC_ERROR([couldn't compile a simple C file])
7364          fi
7365          rm -rf conftest*])
7366     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
7367         if test "$USE_ELF_HACK" = F; then
7368             AC_MSG_CHECKING([for -z norelro option to ld])
7369             _SAVE_LDFLAGS=$LDFLAGS
7370             LDFLAGS="$LDFLAGS -Wl,-z,norelro"
7371             AC_TRY_LINK(,,AC_MSG_RESULT([yes])
7372                         [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,norelro"],
7373                         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.]))
7374             USE_ELF_HACK=1
7375         else
7376             AC_MSG_WARN([Disabling elfhack])
7377             USE_ELF_HACK=
7378         fi
7379     fi
7382 dnl ========================================================
7383 dnl = libstdc++ compatibility hacks
7384 dnl ========================================================
7386 STDCXX_COMPAT=
7387 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
7388 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
7389     STDCXX_COMPAT=1)
7391 if test -n "$STDCXX_COMPAT"; then
7392    eval $(CXX="$CXX" HOST_CXX="$HOST_CXX" $PYTHON -m mozbuild.configure.libstdcxx)
7393    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
7394    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
7397 dnl ========================================================
7398 dnl =
7399 dnl = Profiling and Instrumenting
7400 dnl =
7401 dnl ========================================================
7402 MOZ_ARG_HEADER(Profiling and Instrumenting)
7404 dnl ========================================================
7405 dnl = Enable runtime visual profiling logger
7406 dnl ========================================================
7407 MOZ_ARG_ENABLE_BOOL(visual-event-tracer,
7408 [  --enable-visual-event-tracer   Enable visual event tracer instrumentation],
7409     MOZ_VISUAL_EVENT_TRACER=1,
7410     MOZ_VISUAL_EVENT_TRACER=)
7411 if test -n "$MOZ_VISUAL_EVENT_TRACER"; then
7412     AC_DEFINE(MOZ_VISUAL_EVENT_TRACER)
7415 dnl ========================================================
7416 dnl = Enable TaskTracer
7417 dnl ========================================================
7418 MOZ_ARG_ENABLE_BOOL(tasktracer,
7419 [  --enable-tasktracer       Set compile flags necessary for using TaskTracer],
7420     MOZ_TASK_TRACER=1,
7421     MOZ_TASK_TRACER= )
7422 if test "$MOZ_WIDGET_TOOLKIT" = "gonk" -a -n "$MOZ_TASK_TRACER"; then
7423     AC_DEFINE(MOZ_TASK_TRACER)
7424     AC_SUBST(MOZ_TASK_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 = Offer a way to disable the startup cache
7440 dnl ========================================================
7441 MOZ_DISABLE_STARTUPCACHE=
7443 MOZ_ARG_DISABLE_BOOL(startupcache,
7444 [  --disable-startupcache          Disable startup cache ],
7445     MOZ_DISABLE_STARTUPCACHE=1,
7446     MOZ_DISABLE_STARTUPCACHE=)
7448 dnl bug 988880: disable startup cache on b2g
7449 if test -n "$MOZ_B2G"; then
7450   MOZ_DISABLE_STARTUPCACHE=1
7453 AC_SUBST(MOZ_DISABLE_STARTUPCACHE)
7455 dnl ========================================================
7456 dnl = Enable Radio Interface for B2G (Gonk usually)
7457 dnl ========================================================
7458 MOZ_ARG_ENABLE_BOOL(b2g-ril,
7459 [  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ],
7460     MOZ_B2G_RIL=1,
7461     MOZ_B2G_RIL=,
7462     MOZ_B2G_RIL=$_PLATFORM_HAVE_RIL )
7463 if test -n "$MOZ_B2G_RIL"; then
7464     if test -n "$_PLATFORM_HAVE_RIL"; then
7465         AC_DEFINE(MOZ_B2G_RIL)
7466     else
7467         AC_MSG_ERROR([b2g-ril cannot be enabled because target platform doesn't support it.])
7468     fi
7470 AC_SUBST(MOZ_B2G_RIL)
7472 dnl ========================================================
7473 dnl = Enable Radio FM for B2G (Gonk usually)
7474 dnl ========================================================
7475 if test -n "$MOZ_B2G_FM"; then
7476     AC_DEFINE(MOZ_B2G_FM)
7478 AC_SUBST(MOZ_B2G_FM)
7480 dnl ========================================================
7481 dnl = Enable Bluetooth Interface for B2G (Gonk usually)
7482 dnl ========================================================
7483 MOZ_ARG_ENABLE_BOOL(b2g-bt,
7484 [  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G ],
7485     MOZ_B2G_BT=1,
7486     MOZ_B2G_BT= )
7487 if test -n "$MOZ_B2G_BT"; then
7488     AC_DEFINE(MOZ_B2G_BT)
7490 AC_SUBST(MOZ_B2G_BT)
7491 AC_SUBST(MOZ_B2G_BT_BLUEZ)
7492 AC_SUBST(MOZ_B2G_BT_BLUEDROID)
7494 dnl ========================================================
7495 dnl = Enable NFC Interface for B2G (Gonk usually)
7496 dnl ========================================================
7497 MOZ_ARG_ENABLE_BOOL(nfc,
7498 [  --enable-nfc         Set compile flags necessary for compiling NFC API ],
7499     MOZ_NFC=1,
7500     MOZ_NFC= )
7501 if test -n "$MOZ_NFC"; then
7502    AC_DEFINE(MOZ_NFC)
7504 AC_SUBST(MOZ_NFC)
7506 dnl ========================================================
7507 dnl = Enable Pico Speech Synthesis (Gonk usually)
7508 dnl ========================================================
7509 MOZ_ARG_ENABLE_BOOL(synth-pico,
7510 [  --enable-synth-pico  Set compile flags necessary for compiling Pico Web Speech API ],
7511     MOZ_SYNTH_PICO=1,
7512     MOZ_SYNTH_PICO= )
7513 if test -n "$MOZ_SYNTH_PICO"; then
7514     AC_DEFINE(MOZ_SYNTH_PICO)
7516 AC_SUBST(MOZ_SYNTH_PICO)
7518 dnl ========================================================
7519 dnl = Enable Support for Time Manager API
7520 dnl ========================================================
7521 if test -n "$MOZ_TIME_MANAGER"; then
7522     AC_DEFINE(MOZ_TIME_MANAGER)
7524 AC_SUBST(MOZ_TIME_MANAGER)
7526 dnl ========================================================
7527 dnl = Enable Camera Interface for B2G (Gonk usually)
7528 dnl ========================================================
7529 MOZ_ARG_ENABLE_BOOL(b2g-camera,
7530 [  --enable-b2g-camera      Set compile flags necessary for compiling camera API for B2G ],
7531     MOZ_B2G_CAMERA=1,
7532     MOZ_B2G_CAMERA= )
7533 if test -n "$MOZ_B2G_CAMERA"; then
7534    AC_DEFINE(MOZ_B2G_CAMERA)
7536 AC_SUBST(MOZ_B2G_CAMERA)
7538 dnl ========================================================
7539 dnl = Enable Support for Payment API
7540 dnl ========================================================
7541 if test -n "$MOZ_PAY"; then
7542     AC_DEFINE(MOZ_PAY)
7544 AC_SUBST(MOZ_PAY)
7546 dnl ========================================================
7547 dnl = Enable Browser Support for Activities
7548 dnl ========================================================
7549 if test -n "$MOZ_ACTIVITIES"; then
7550     AC_DEFINE(MOZ_ACTIVITIES)
7552 AC_SUBST(MOZ_ACTIVITIES)
7554 dnl ========================================================
7555 dnl = Enable Support for AudioChannelManager API
7556 dnl ========================================================
7557 if test -n "$MOZ_AUDIO_CHANNEL_MANAGER"; then
7558     AC_DEFINE(MOZ_AUDIO_CHANNEL_MANAGER)
7560 AC_SUBST(MOZ_AUDIO_CHANNEL_MANAGER)
7562 dnl ========================================================
7563 dnl = Enable Support for Firefox Accounts (services/fxaccounts)
7564 dnl ========================================================
7565 if test -n "$MOZ_SERVICES_FXACCOUNTS"; then
7566     AC_DEFINE(MOZ_SERVICES_FXACCOUNTS)
7568 AC_SUBST(MOZ_SERVICES_FXACCOUNTS)
7570 dnl ========================================================
7571 dnl = Support for demangling undefined symbols
7572 dnl ========================================================
7573 if test -z "$SKIP_LIBRARY_CHECKS"; then
7574     AC_LANG_SAVE
7575     AC_LANG_CPLUSPLUS
7576     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
7577     AC_LANG_RESTORE
7580 # Demangle only for debug or trace-malloc or DMD builds
7581 MOZ_DEMANGLE_SYMBOLS=
7582 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
7583     MOZ_DEMANGLE_SYMBOLS=1
7584     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
7586 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
7588 dnl ========================================================
7589 dnl = Support for gcc stack unwinding (from gcc 3.3)
7590 dnl ========================================================
7591 if test -z "$SKIP_LIBRARY_CHECKS"; then
7592     AC_LANG_SAVE
7593     AC_LANG_CPLUSPLUS
7594     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
7595     AC_LANG_RESTORE
7598 dnl ========================================================
7599 dnl JIT observers
7600 dnl ========================================================
7602 MOZ_ARG_WITH_STRING(jitreport-granularity,
7603 [  --jitreport-granularity=N
7604                            Default granularity at which to report JIT code
7605                            to external tools
7606                              0 - no info
7607                              1 - code ranges for whole functions only
7608                              2 - per-line information
7609                              3 - per-op information],
7610   JITREPORT_GRANULARITY=$withval,
7611   JITREPORT_GRANULARITY=3)
7613 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
7615 dnl ========================================================
7616 dnl =
7617 dnl = Misc. Options
7618 dnl =
7619 dnl ========================================================
7620 MOZ_ARG_HEADER(Misc. Options)
7622 dnl ========================================================
7623 dnl update xterm title
7624 dnl ========================================================
7625 MOZ_ARG_ENABLE_BOOL(xterm-updates,
7626 [  --enable-xterm-updates  Update XTERM titles with current command.],
7627     MOZ_UPDATE_XTERM=1,
7628     MOZ_UPDATE_XTERM= )
7630 dnl =========================================================
7631 dnl = Chrome format
7632 dnl =========================================================
7633 MOZ_ARG_ENABLE_STRING([chrome-format],
7634 [  --enable-chrome-format=jar|flat|omni
7635                           Select FORMAT of chrome files during packaging],
7636     MOZ_CHROME_FILE_FORMAT=`echo $enableval | tr A-Z a-z`)
7638 if test -z "$MOZ_CHROME_FILE_FORMAT"; then
7639     MOZ_CHROME_FILE_FORMAT=jar
7642 if test "$MOZ_CHROME_FILE_FORMAT" = "symlink"; then
7643     AC_MSG_ERROR([--enable-chrome-format=symlink has been deprecated. It is now used by default in $DIST/bin on platforms that support it])
7646 if test "$MOZ_CHROME_FILE_FORMAT" != "jar" &&
7647     test "$MOZ_CHROME_FILE_FORMAT" != "flat" &&
7648     test "$MOZ_CHROME_FILE_FORMAT" != "omni"; then
7649     AC_MSG_ERROR([--enable-chrome-format must be set to either jar, flat, or omni])
7652 dnl =========================================================
7653 dnl Omnijar packaging (bug 552121)
7654 dnl =========================================================
7655 dnl Omnijar packaging is compatible with flat packaging.
7656 dnl In unpackaged builds, omnijar looks for files as if
7657 dnl things were flat packaged. After packaging, all files
7658 dnl are loaded from a single jar. MOZ_CHROME_FILE_FORMAT
7659 dnl is set to flat since putting files into jars is only
7660 dnl done during packaging with omnijar.
7661 if test "$MOZ_CHROME_FILE_FORMAT" = "omni"; then
7662     MOZ_OMNIJAR=1
7663     AC_DEFINE(MOZ_OMNIJAR)
7665 MOZ_PACKAGER_FORMAT="$MOZ_CHROME_FILE_FORMAT"
7666 if test "$OS_ARCH" = "WINNT" -o "$MOZ_WIDGET_TOOLKIT" = "android"; then
7667     MOZ_CHROME_FILE_FORMAT=flat
7668 else
7669     MOZ_CHROME_FILE_FORMAT=symlink
7672 if test "$MOZ_WIDGET_TOOLKIT" = "android"; then
7673     dnl Fennec's static resources live in the assets/ folder of the
7674     dnl APK.  Adding a path to the name here works because we only
7675     dnl have one omnijar file in the final package (which is not the
7676     dnl case on desktop), and necessitates some contortions during
7677     dnl packaging so that the resources in the omnijar are considered
7678     dnl as rooted at / and not as rooted at assets/ (which again is
7679     dnl not the case on desktop: there are omnijars rooted at webrtc/,
7680     dnl etc). packager.mk handles changing the rooting of the single
7681     dnl omnijar.
7682     OMNIJAR_NAME=assets/omni.ja
7683 else
7684     OMNIJAR_NAME=omni.ja
7687 AC_SUBST(OMNIJAR_NAME)
7688 AC_SUBST(MOZ_OMNIJAR)
7689 AC_SUBST(MOZ_PACKAGER_FORMAT)
7691 dnl ========================================================
7692 dnl = Define default location for MOZILLA_FIVE_HOME
7693 dnl ========================================================
7694 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
7695 [  --with-default-mozilla-five-home
7696                           Set the default value for MOZILLA_FIVE_HOME],
7697 [ val=`echo $withval`
7698   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
7700 dnl ========================================================
7701 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
7702 dnl ========================================================
7703 MOZ_ARG_WITH_STRING(user-appdir,
7704 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
7705 [ val=`echo $withval`
7706 if echo "$val" | grep "\/" >/dev/null; then
7707     AC_MSG_ERROR("Homedir must be single relative path.")
7708 else
7709     MOZ_USER_DIR="$val"
7710 fi])
7712 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
7714 dnl ========================================================
7715 dnl = Doxygen configuration
7716 dnl ========================================================
7717 dnl Use commas to specify multiple dirs to this arg
7718 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
7719 MOZ_ARG_WITH_STRING(doc-input-dirs,
7720 [  --with-doc-input-dirs=DIRS
7721                           Header/idl dirs to create docs from],
7722 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7723 AC_SUBST(MOZ_DOC_INPUT_DIRS)
7725 dnl Use commas to specify multiple dirs to this arg
7726 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
7727 MOZ_ARG_WITH_STRING(doc-include-dirs,
7728 [  --with-doc-include-dirs=DIRS
7729                           Include dirs to preprocess doc headers],
7730 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
7731 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
7733 MOZ_DOC_OUTPUT_DIR='./dist/docs'
7734 MOZ_ARG_WITH_STRING(doc-output-dir,
7735 [  --with-doc-output-dir=DIR
7736                           Dir to generate docs into],
7737 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
7738 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
7740 if test -z "$SKIP_COMPILER_CHECKS"; then
7741 dnl ========================================================
7742 dnl =
7743 dnl = Compiler Options
7744 dnl =
7745 dnl ========================================================
7746 MOZ_ARG_HEADER(Compiler Options)
7748 dnl ========================================================
7749 dnl Check for gcc -pipe support
7750 dnl ========================================================
7751 AC_MSG_CHECKING([for -pipe support])
7752 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
7753     dnl Any gcc that supports firefox supports -pipe.
7754     CFLAGS="$CFLAGS -pipe"
7755     CXXFLAGS="$CXXFLAGS -pipe"
7756     AC_MSG_RESULT([yes])
7757 else
7758     AC_MSG_RESULT([no])
7761 dnl ========================================================
7762 dnl Profile guided optimization (gcc checks)
7763 dnl ========================================================
7764 dnl Test for profiling options
7765 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
7767 _SAVE_CFLAGS="$CFLAGS"
7768 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
7770 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
7771 AC_TRY_COMPILE([], [return 0;],
7772                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
7773                  result="yes" ], result="no")
7774 AC_MSG_RESULT([$result])
7776 if test $result = "yes"; then
7777   PROFILE_GEN_LDFLAGS="-fprofile-generate"
7778   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
7779   PROFILE_USE_LDFLAGS="-fprofile-use"
7782 CFLAGS="$_SAVE_CFLAGS"
7784 if test -n "$INTEL_CC"; then
7785   PROFILE_GEN_CFLAGS="-prof-gen -prof-dir ."
7786   PROFILE_GEN_LDFLAGS=
7787   PROFILE_USE_CFLAGS="-prof-use -prof-dir ."
7788   PROFILE_USE_LDFLAGS=
7791 dnl Sun Studio on Solaris
7792 if test "$SOLARIS_SUNPRO_CC"; then
7793   PROFILE_GEN_CFLAGS="-xprofile=collect:$_objdir/$enable_application"
7794   PROFILE_GEN_LDFLAGS="-xprofile=collect:$_objdir/$enable_application"
7795   PROFILE_USE_CFLAGS="-xprofile=use:$_objdir/$enable_application"
7796   PROFILE_USE_LDFLAGS="-xprofile=use:$_objdir/$enable_application"
7799 AC_SUBST(PROFILE_GEN_CFLAGS)
7800 AC_SUBST(PROFILE_GEN_LDFLAGS)
7801 AC_SUBST(PROFILE_USE_CFLAGS)
7802 AC_SUBST(PROFILE_USE_LDFLAGS)
7804 AC_LANG_CPLUSPLUS
7806 dnl ========================================================
7807 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
7808 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
7809 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
7810 dnl ========================================================
7811 _SAVE_CXXFLAGS=$CXXFLAGS
7812 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
7813 AC_CACHE_CHECK(for correct overload resolution with const and templates,
7814     ac_nscap_nonconst_opeq_bug,
7815     [AC_TRY_COMPILE([
7816                       template <class T>
7817                       class Pointer
7818                         {
7819                         public:
7820                           T* myPtr;
7821                         };
7823                       template <class T, class U>
7824                       int operator==(const Pointer<T>& rhs, U* lhs)
7825                         {
7826                           return rhs.myPtr == lhs;
7827                         }
7829                       template <class T, class U>
7830                       int operator==(const Pointer<T>& rhs, const U* lhs)
7831                         {
7832                           return rhs.myPtr == lhs;
7833                         }
7834                     ],
7835                     [
7836                       Pointer<int> foo;
7837                       const int* bar;
7838                       return foo == bar;
7839                     ],
7840                     ac_nscap_nonconst_opeq_bug="no",
7841                     ac_nscap_nonconst_opeq_bug="yes")])
7842 CXXFLAGS="$_SAVE_CXXFLAGS"
7844 if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
7845     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
7847 fi # ! SKIP_COMPILER_CHECKS
7849 AC_DEFINE(CPP_THROW_NEW, [throw()])
7850 AC_LANG_C
7852 if test "$COMPILE_ENVIRONMENT"; then
7853 MOZ_EXPAND_LIBS
7854 fi # COMPILE_ENVIRONMENT
7856 dnl ========================================================
7857 dnl =
7858 dnl = Build depencency options
7859 dnl =
7860 dnl ========================================================
7861 MOZ_ARG_HEADER(Build dependencies)
7863 if test "$GNU_CC" -a "$GNU_CXX"; then
7864   _DEPEND_CFLAGS='-MD -MP -MF $(MDDEPDIR)/$(@F).pp'
7865 dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
7866 elif test "$SOLARIS_SUNPRO_CC"; then
7867   _DEPEND_CFLAGS=
7868 else
7869   dnl Don't override this for MSVC
7870   if test -z "$_WIN32_MSVC"; then
7871     _USE_CPP_INCLUDE_FLAG=
7872     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7873     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
7874   else
7875     echo '#include <stdio.h>' > dummy-hello.c
7876     changequote(,)
7877     dnl This output is localized, split at the first double space or colon and space.
7878     _CL_PREFIX_REGEX="^\([^:]*:.*[ :] \)\(.*stdio.h\)$"
7879     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\1/p'`
7880     _CL_STDIO_PATH=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\2/p'`
7881     changequote([,])
7882     if ! test -e "$_CL_STDIO_PATH"; then
7883         AC_MSG_ERROR([Unable to parse cl -showIncludes prefix. This compiler's locale has an unsupported formatting.])
7884     fi
7885     if test -z "$CL_INCLUDES_PREFIX"; then
7886         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
7887     fi
7888     AC_SUBST(CL_INCLUDES_PREFIX)
7889     rm -f dummy-hello.c
7891     dnl Make sure that the build system can handle non-ASCII characters
7892     dnl in environment variables to prevent it from breaking silently on
7893     dnl non-English systems.
7894     NONASCII=$'\241\241'
7895     AC_SUBST(NONASCII)
7896   fi
7899 dnl ========================================================
7900 dnl =
7901 dnl = Static Build Options
7902 dnl =
7903 dnl ========================================================
7904 MOZ_ARG_HEADER(Static build options)
7906 AC_SUBST(LIBXUL_LIBS)
7907 XPCOM_LIBS="$LIBXUL_LIBS"
7909 if test "$OS_ARCH" = "WINNT"; then
7910   GKMEDIAS_SHARED_LIBRARY=1
7911   AC_DEFINE(GKMEDIAS_SHARED_LIBRARY)
7913 AC_SUBST(GKMEDIAS_SHARED_LIBRARY)
7915 if test -z "$MOZ_NATIVE_ZLIB"; then
7916 if test -n "$JS_SHARED_LIBRARY" -o "$GKMEDIAS_SHARED_LIBRARY"; then
7917   ZLIB_IN_MOZGLUE=1
7918   AC_DEFINE(ZLIB_IN_MOZGLUE)
7922 AC_SUBST(ZLIB_IN_MOZGLUE)
7924 dnl ========================================================
7925 dnl =
7926 dnl = Standalone module options
7927 dnl =
7928 dnl ========================================================
7929 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
7931 dnl Check for GLib.
7932 dnl ========================================================
7934 if test -z "$SKIP_PATH_CHECKS"; then
7935 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
7936     if test "$MOZ_ENABLE_GTK" ; then
7937         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
7938     fi
7942 if test -z "${GLIB_GMODULE_LIBS}" \
7943    -a -n "${GLIB_CONFIG}"\
7944     -a "${GLIB_CONFIG}" != no\
7945 ; then
7946     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
7949 AC_SUBST(GLIB_CFLAGS)
7950 AC_SUBST(GLIB_LIBS)
7951 AC_SUBST(GLIB_GMODULE_LIBS)
7953 dnl ========================================================
7954 dnl Graphics checks.
7955 dnl ========================================================
7957 if test "${OS_TARGET}" = "WINNT"; then
7958   if $PERL -e "exit($MOZ_WINSDK_MAXVER < 0x06020000)"; then
7959     MOZ_ENABLE_DIRECT2D1_1=1
7960     AC_SUBST(MOZ_ENABLE_DIRECT2D1_1)
7961   fi
7964 if test "${OS_TARGET}" = "WINNT" -o \
7965         "${OS_ARCH}" = "Darwin" -o \
7966         "${MOZ_WIDGET_TOOLKIT}" = "android" -o \
7967         "${MOZ_WIDGET_TOOLKIT}" = "gonk" -o \
7968         "${MOZ_WIDGET_TOOLKIT}" = "gtk2" -o \
7969         "${MOZ_WIDGET_TOOLKIT}" = "gtk3"; then
7970     case "${target_cpu}" in
7971     i*86*|x86_64|arm)
7972         MOZ_ENABLE_SKIA=1
7973         ;;
7974     *)
7975         MOZ_ENABLE_SKIA=
7976         ;;
7977     esac
7978 else
7979 MOZ_ENABLE_SKIA=
7982 MOZ_ARG_ENABLE_BOOL(skia,
7983 [  --enable-skia   Enable use of Skia],
7984 MOZ_ENABLE_SKIA=1,
7985 MOZ_ENABLE_SKIA=)
7987 if test "$USE_FC_FREETYPE"; then
7988     if test "$COMPILE_ENVIRONMENT"; then
7989         dnl ========================================================
7990         dnl = Check for freetype2 and its functionality
7991         dnl ========================================================
7992         PKG_CHECK_MODULES(FT2, freetype2 >= 6.1.0, _HAVE_FREETYPE2=1, _HAVE_FREETYPE2=)
7994         if test "$_HAVE_FREETYPE2"; then
7995             _SAVE_LIBS="$LIBS"
7996             _SAVE_CFLAGS="$CFLAGS"
7997             LIBS="$LIBS $FT2_LIBS"
7998             CFLAGS="$CFLAGS $FT2_CFLAGS"
8000             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
8001                 ac_cv_member_FT_Bitmap_Size_y_ppem,
8002                 [AC_TRY_COMPILE([#include <ft2build.h>
8003                                  #include FT_FREETYPE_H],
8004                                 [FT_Bitmap_Size s;
8005                                  if (sizeof s.y_ppem) return 0;
8006                                  return 1],
8007                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
8008                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
8009             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
8010                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
8011             else
8012                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
8013             fi
8014             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
8015                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
8016                                [FT_Bitmap_Size structure includes y_ppem field])
8018             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table)
8020             LIBS="$_SAVE_LIBS"
8021             CFLAGS="$_SAVE_CFLAGS"
8022         fi
8024         _SAVE_CPPFLAGS="$CPPFLAGS"
8025         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
8026         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
8027             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
8028         CPPFLAGS="$_SAVE_CPPFLAGS"
8029     else
8030         AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H)
8031     fi
8033     PKG_CHECK_MODULES(_FONTCONFIG, fontconfig,
8034     [
8035         if test "$MOZ_PANGO"; then
8036             MOZ_PANGO_CFLAGS="$MOZ_PANGO_CFLAGS $_FONTCONFIG_CFLAGS"
8037             MOZ_PANGO_LIBS="$MOZ_PANGO_LIBS $_FONTCONFIG_LIBS"
8038         else
8039             FT2_CFLAGS="$FT2_CFLAGS $_FONTCONFIG_CFLAGS"
8040             FT2_LIBS="$FT2_LIBS $_FONTCONFIG_LIBS"
8041         fi
8042     ])
8045 dnl ========================================================
8046 dnl Check for pixman and cairo
8047 dnl ========================================================
8049 if test "$MOZ_WIDGET_TOOLKIT" = "gtk3" ; then
8050   # cairo-gtk3 can be build with system-cairo only
8051   MOZ_TREE_CAIRO=
8052 else
8053   MOZ_TREE_CAIRO=1
8056 MOZ_ARG_ENABLE_BOOL(system-cairo,
8057 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
8058 MOZ_TREE_CAIRO=,
8059 MOZ_TREE_CAIRO=1 )
8061 MOZ_TREE_PIXMAN=1
8062 MOZ_ARG_ENABLE_BOOL(system-pixman,
8063 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
8064 MOZ_TREE_PIXMAN=,
8065 MOZ_TREE_PIXMAN=force,
8066 MOZ_TREE_PIXMAN=1 )
8068 # System cairo depends on system pixman
8069 if test "$MOZ_TREE_PIXMAN" = "force"; then
8070     if test -z "$MOZ_TREE_CAIRO"; then
8071         AC_MSG_ERROR([--disable-system-pixman is incompatible with --enable-system-cairo.])
8072     else
8073         MOZ_TREE_PIXMAN=1
8074     fi
8075 elif test -z "$MOZ_TREE_CAIRO"; then
8076     MOZ_TREE_PIXMAN=
8079 if test "$MOZ_TREE_PIXMAN"; then
8080     AC_DEFINE(MOZ_TREE_PIXMAN)
8081     MOZ_PIXMAN_CFLAGS=""
8082     MOZ_PIXMAN_LIBS='$(call EXPAND_LIBNAME_PATH,mozlibpixman,$(DEPTH)/gfx/cairo/libpixman/src)'
8083 else
8084     PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.19.2)
8085     MOZ_PIXMAN_CFLAGS="$PIXMAN_CFLAGS"
8086     MOZ_PIXMAN_LIBS="$PIXMAN_LIBS"
8088 AC_SUBST(MOZ_PIXMAN_CFLAGS)
8089 AC_SUBST(MOZ_PIXMAN_LIBS)
8091 # Check for headers defining standard int types.
8092 if test -n "$COMPILE_ENVIRONMENT"; then
8093     MOZ_CHECK_HEADERS(stdint.h inttypes.h sys/int_types.h)
8095     if test "${ac_cv_header_inttypes_h}" = "yes"; then
8096         HAVE_INTTYPES_H=1
8097     fi
8100 AC_SUBST(HAVE_INTTYPES_H)
8102 if test "$MOZ_TREE_CAIRO"; then
8103     MOZ_CAIRO_CFLAGS='-I$(LIBXUL_DIST)/include/cairo'
8104     AC_DEFINE(MOZ_TREE_CAIRO)
8106     if test "$OS_ARCH" = "WINNT"; then
8107         # For now we assume that we will have a uint64_t available through
8108         # one of the above headers or mozstdint.h.
8109         AC_DEFINE(HAVE_UINT64_T)
8110     fi
8112     # Define macros for cairo-features.h
8113     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
8114     if test "$MOZ_X11"; then
8115         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
8116         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
8117         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
8118         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
8119         MOZ_ENABLE_CAIRO_FT=1
8120         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
8121     fi
8122     case "$MOZ_WIDGET_TOOLKIT" in
8123       qt)
8124         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
8125         ;;
8126       cocoa | uikit)
8127         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
8128         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
8129         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
8130         ;;
8131       windows)
8132         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
8133         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
8134         if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
8135             WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
8136             WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
8137             MOZ_ENABLE_D2D_SURFACE=1
8138             MOZ_ENABLE_DWRITE_FONT=1
8139         else
8140             WIN32_DWRITE_FONT_FEATURE=
8141             WIN32_D2D_SURFACE_FEATURE=
8142         fi
8144         MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
8146         dnl D3D10 Layers depend on D2D Surfaces.
8147         if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
8148           MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
8149         fi
8150         ;;
8151       gtk3)
8152         AC_MSG_ERROR([cairo-gtk3 toolkit is incompatible with in-tree cairo. Please add --enable-system-cairo to your build config.])
8153         ;;
8154     esac
8155     if test "$USE_FC_FREETYPE"; then
8156         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
8157     fi
8158     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
8159     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
8160     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
8161     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
8162     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
8163     AC_SUBST(CAIRO_FT_CFLAGS)
8165     AC_SUBST(PS_SURFACE_FEATURE)
8166     AC_SUBST(PDF_SURFACE_FEATURE)
8167     AC_SUBST(SVG_SURFACE_FEATURE)
8168     AC_SUBST(XLIB_SURFACE_FEATURE)
8169     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
8170     AC_SUBST(QUARTZ_SURFACE_FEATURE)
8171     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
8172     AC_SUBST(WIN32_SURFACE_FEATURE)
8173     AC_SUBST(OS2_SURFACE_FEATURE)
8174     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
8175     AC_SUBST(FT_FONT_FEATURE)
8176     AC_SUBST(FC_FONT_FEATURE)
8177     AC_SUBST(WIN32_FONT_FEATURE)
8178     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
8179     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
8180     AC_SUBST(QUARTZ_FONT_FEATURE)
8181     AC_SUBST(PNG_FUNCTIONS_FEATURE)
8182     AC_SUBST(QT_SURFACE_FEATURE)
8183     AC_SUBST(TEE_SURFACE_FEATURE)
8185     MOZ_CAIRO_OSLIBS='${CAIRO_FT_OSLIBS}'
8187     if test "$MOZ_X11"; then
8188         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
8189     fi
8191     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
8192 else
8193     PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION)
8194     MOZ_CAIRO_CFLAGS="$CAIRO_CFLAGS"
8195     MOZ_CAIRO_LIBS="$CAIRO_LIBS"
8196     PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
8197     if test "$MOZ_X11"; then
8198         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
8199         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
8200         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_LIBS"
8201         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
8202     fi
8205 AC_SUBST(MOZ_TREE_CAIRO)
8206 AC_SUBST(MOZ_CAIRO_CFLAGS)
8207 AC_SUBST(MOZ_CAIRO_LIBS)
8208 AC_SUBST(MOZ_CAIRO_OSLIBS)
8209 AC_SUBST(MOZ_TREE_PIXMAN)
8211 dnl ========================================================
8212 dnl Skia
8213 dnl ========================================================
8214 if test "$MOZ_ENABLE_SKIA"; then
8215   AC_DEFINE(MOZ_ENABLE_SKIA)
8216   AC_DEFINE(USE_SKIA)
8217   if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
8218     AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
8219   fi
8221   if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64" -a "${CPU_ARCH}" != "sparc" ; then
8222     MOZ_ENABLE_SKIA_GPU=1
8223     AC_DEFINE(USE_SKIA_GPU)
8224     AC_SUBST(MOZ_ENABLE_SKIA_GPU)
8225   fi
8227 AC_SUBST(MOZ_ENABLE_SKIA)
8229 dnl ========================================================
8230 dnl disable xul
8231 dnl ========================================================
8232 MOZ_ARG_DISABLE_BOOL(xul,
8233 [  --disable-xul           Disable XUL],
8234     MOZ_XUL= )
8235 if test "$MOZ_XUL"; then
8236   AC_DEFINE(MOZ_XUL)
8237 else
8238   dnl remove extensions that require XUL
8239   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/venkman//' -e 's/irc//' -e 's/tasks//'`
8242 AC_SUBST(MOZ_XUL)
8244 dnl ========================================================
8245 dnl disable profile locking
8246 dnl   do no use this in applications that can have more than
8247 dnl   one process accessing the profile directory.
8248 dnl ========================================================
8249 MOZ_ARG_DISABLE_BOOL(profilelocking,
8250 [  --disable-profilelocking
8251                           Disable profile locking],
8252     MOZ_PROFILELOCKING=,
8253     MOZ_PROFILELOCKING=1 )
8254 if test "$MOZ_PROFILELOCKING"; then
8255   AC_DEFINE(MOZ_PROFILELOCKING)
8258 dnl ========================================================
8259 dnl necko configuration options
8260 dnl ========================================================
8263 dnl option to disable various necko protocols
8265 MOZ_ARG_ENABLE_STRING(necko-protocols,
8266 [  --enable-necko-protocols[={http,ftp,default,all,none}]
8267                           Enable/disable specific protocol handlers],
8268 [ for option in `echo $enableval | sed 's/,/ /g'`; do
8269     if test "$option" = "yes" -o "$option" = "all"; then
8270         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8271     elif test "$option" = "no" -o "$option" = "none"; then
8272         NECKO_PROTOCOLS=""
8273     elif test "$option" = "default"; then
8274         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $NECKO_PROTOCOLS_DEFAULT"
8275     elif test `echo "$option" | grep -c \^-` != 0; then
8276         option=`echo $option | sed 's/^-//'`
8277         NECKO_PROTOCOLS=`echo "$NECKO_PROTOCOLS" | sed "s/ ${option}//"`
8278     else
8279         NECKO_PROTOCOLS="$NECKO_PROTOCOLS $option"
8280     fi
8281 done],
8282     NECKO_PROTOCOLS="$NECKO_PROTOCOLS_DEFAULT")
8283 dnl Remove dupes
8284 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
8285 AC_SUBST_SET(NECKO_PROTOCOLS)
8286 for p in $NECKO_PROTOCOLS; do
8287     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
8288     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_PROTOCOL_$p"
8289 done
8292 dnl option to disable necko's wifi scanner
8295 case "$OS_TARGET" in
8296   Android)
8297     if test -n "$gonkdir"; then
8298       NECKO_WIFI=1
8299     fi
8300     ;;
8301   Darwin|FreeBSD|SunOS|WINNT)
8302     NECKO_WIFI=1
8303     ;;
8304   Linux)
8305     NECKO_WIFI=1
8306     NECKO_WIFI_DBUS=1
8307     ;;
8308 esac
8310 MOZ_ARG_DISABLE_BOOL(necko-wifi,
8311 [  --disable-necko-wifi    Disable necko wifi scanner],
8312     NECKO_WIFI=,
8313     NECKO_WIFI=1)
8315 if test "$NECKO_WIFI"; then
8316   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
8317     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
8318   fi
8319   AC_DEFINE(NECKO_WIFI)
8320   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
8322 AC_SUBST(NECKO_WIFI)
8323 AC_SUBST(NECKO_WIFI_DBUS)
8326 dnl option to disable cookies
8328 MOZ_ARG_DISABLE_BOOL(cookies,
8329 [  --disable-cookies       Disable cookie support],
8330     NECKO_COOKIES=,
8331     NECKO_COOKIES=1)
8332 AC_SUBST(NECKO_COOKIES)
8333 if test "$NECKO_COOKIES"; then
8334     AC_DEFINE(NECKO_COOKIES)
8335     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
8339 dnl Always build Marionette if not Android or B2G
8341 if test "$OS_TARGET" != Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
8342     AC_DEFINE(ENABLE_MARIONETTE)
8344 AC_SUBST(ENABLE_MARIONETTE)
8345 if test "$ENABLE_MARIONETTE"; then
8346     AC_DEFINE(ENABLE_MARIONETTE)
8350 dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
8352 MOZ_ARG_DISABLE_BOOL(ctypes,
8353 [  --disable-ctypes        Disable js-ctypes],
8354     BUILD_CTYPES=,
8355     BUILD_CTYPES=1)
8356 AC_SUBST(BUILD_CTYPES)
8357 if test "$BUILD_CTYPES"; then
8358     AC_DEFINE(BUILD_CTYPES)
8361 dnl Build Loop if required
8362 AC_SUBST(MOZ_LOOP)
8363 if test "$MOZ_LOOP"; then
8364   AC_DEFINE(MOZ_LOOP)
8367 dnl Build Places if required
8368 if test "$MOZ_PLACES"; then
8369   AC_DEFINE(MOZ_PLACES)
8372 dnl Build SocialAPI if required
8373 if test "$MOZ_SOCIAL"; then
8374   AC_DEFINE(MOZ_SOCIAL)
8377 dnl Build Common JS modules provided by services.
8378 AC_SUBST(MOZ_SERVICES_COMMON)
8379 if test -n "$MOZ_SERVICES_COMMON"; then
8380   AC_DEFINE(MOZ_SERVICES_COMMON)
8383 dnl Build Services crypto component (used by Sync)
8384 AC_SUBST(MOZ_SERVICES_CRYPTO)
8385 if test -n "$MOZ_SERVICES_CRYPTO"; then
8386   AC_DEFINE(MOZ_SERVICES_CRYPTO)
8389 dnl Build Firefox Health Reporter Service
8390 AC_SUBST(MOZ_SERVICES_HEALTHREPORT)
8391 if test -n "$MOZ_SERVICES_HEALTHREPORT"; then
8392   AC_DEFINE(MOZ_SERVICES_HEALTHREPORT)
8395 dnl Build Services metrics component
8396 AC_SUBST(MOZ_SERVICES_METRICS)
8397 if test -n "$MOZ_SERVICES_METRICS"; then
8398   AC_DEFINE(MOZ_SERVICES_METRICS)
8401 dnl Build Notifications if required
8402 AC_SUBST(MOZ_SERVICES_NOTIFICATIONS)
8403 if test -n "$MOZ_SERVICES_NOTIFICATIONS"; then
8404   AC_DEFINE(MOZ_SERVICES_NOTIFICATIONS)
8407 dnl Build Sync Services if required
8408 AC_SUBST(MOZ_SERVICES_SYNC)
8409 if test -n "$MOZ_SERVICES_SYNC"; then
8410   AC_DEFINE(MOZ_SERVICES_SYNC)
8413 dnl Build Captive Portal Detector if required
8414 AC_SUBST(MOZ_CAPTIVEDETECT)
8415 if test -n "$MOZ_CAPTIVEDETECT"; then
8416   AC_DEFINE(MOZ_CAPTIVEDETECT)
8419 dnl Build second screen and casting features for external devices if required
8420 AC_SUBST(MOZ_DEVICES)
8421 if test -n "$MOZ_DEVICES"; then
8422   AC_DEFINE(MOZ_DEVICES)
8425 dnl ========================================================
8426 if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
8427     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
8430 if test "$MOZ_APP_COMPONENT_INCLUDE"; then
8431   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_INCLUDE, "$MOZ_APP_COMPONENT_INCLUDE")
8434 if test "$MOZ_APP_COMPONENT_MODULES"; then
8435   AC_DEFINE_UNQUOTED(MOZ_APP_COMPONENT_MODULES, $MOZ_APP_COMPONENT_MODULES)
8438 dnl ========================================================
8439 dnl =
8440 dnl = Maintainer debug option (no --enable equivalent)
8441 dnl =
8442 dnl ========================================================
8444 AC_SUBST(AR)
8445 AC_SUBST(AR_FLAGS)
8446 AC_SUBST(AR_LIST)
8447 AC_SUBST(AR_EXTRACT)
8448 AC_SUBST(AR_DELETE)
8449 AC_SUBST(AS)
8450 AC_SUBST(ASFLAGS)
8451 AC_SUBST(AS_DASH_C_FLAG)
8452 AC_SUBST(LD)
8453 AC_SUBST(RC)
8454 AC_SUBST(RCFLAGS)
8455 AC_SUBST(MC)
8456 AC_SUBST(WINDRES)
8457 AC_SUBST(IMPLIB)
8458 AC_SUBST(FILTER)
8459 AC_SUBST(BIN_FLAGS)
8460 AC_SUBST(MOZ_WIDGET_TOOLKIT)
8461 AC_SUBST(MOZ_UPDATE_XTERM)
8462 AC_SUBST(MOZ_AUTH_EXTENSION)
8463 AC_SUBST(MOZ_PERMISSIONS)
8464 AC_SUBST(MOZ_PREF_EXTENSIONS)
8465 AC_SUBST(MOZ_JS_LIBS)
8466 AC_SUBST(MOZ_DEBUG)
8467 AC_SUBST(MOZ_DEBUG_SYMBOLS)
8468 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
8469 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
8470 AC_SUBST(MOZ_DEBUG_LDFLAGS)
8471 AC_SUBST(WARNINGS_AS_ERRORS)
8472 AC_SUBST(MOZ_EXTENSIONS)
8473 AC_SUBST(MOZ_JSDEBUGGER)
8474 AC_SUBST(MOZ_ENABLE_PROFILER_SPS)
8475 AC_SUBST(MOZ_JPROF)
8476 AC_SUBST(MOZ_SHARK)
8477 AC_SUBST(MOZ_INSTRUMENTS)
8478 AC_SUBST(MOZ_CALLGRIND)
8479 AC_SUBST(MOZ_VTUNE)
8480 AC_SUBST(MOZ_PROFILING)
8481 AC_SUBST(LIBICONV)
8482 AC_SUBST(MOZ_PLACES)
8483 AC_SUBST(MOZ_SOCIAL)
8484 AC_SUBST(MOZ_TOOLKIT_SEARCH)
8485 AC_SUBST(MOZ_FEEDS)
8486 AC_SUBST(NS_PRINTING)
8487 AC_SUBST(MOZ_WEBGL)
8488 AC_SUBST(MOZ_HELP_VIEWER)
8489 AC_SUBST(TOOLCHAIN_PREFIX)
8491 AC_SUBST(JAVA)
8492 AC_SUBST(JAVAC)
8493 AC_SUBST(JAVAH)
8494 AC_SUBST(JAR)
8495 AC_SUBST(JARSIGNER)
8496 AC_SUBST(KEYTOOL)
8498 AC_SUBST(MOZ_PROFILELOCKING)
8500 AC_SUBST(ENABLE_TESTS)
8501 AC_SUBST(MOZ_UNIVERSALCHARDET)
8502 AC_SUBST(ACCESSIBILITY)
8503 AC_SUBST(MOZ_SPELLCHECK)
8504 AC_SUBST(MOZ_ANDROID_OMTC)
8505 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
8506 AC_SUBST(MOZ_CRASHREPORTER)
8507 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
8508 AC_SUBST(MOZ_CRASHREPORTER_UPLOAD_FULL_SYMBOLS)
8509 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
8510 AC_SUBST(MOZ_STUB_INSTALLER)
8511 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
8512 AC_SUBST(MOZ_ENABLE_SIGNMAR)
8513 AC_SUBST(MOZ_UPDATER)
8515 AC_SUBST(MOZ_ANGLE_RENDERER)
8516 AC_SUBST(MOZ_D3D_CPU_SUFFIX)
8517 AC_SUBST(MOZ_HAS_WINSDK_WITH_D3D)
8518 AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL)
8519 AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL_PATH)
8520 AC_SUBST(MOZ_DIRECTX_SDK_PATH)
8521 AC_SUBST(MOZ_D3DCOMPILER_XP_DLL)
8522 AC_SUBST(MOZ_D3DCOMPILER_XP_CAB)
8524 AC_SUBST(MOZ_METRO)
8526 AC_SUBST(MOZ_ANDROID_HISTORY)
8527 AC_SUBST(MOZ_WEBSMS_BACKEND)
8528 AC_SUBST(MOZ_ANDROID_BEAM)
8529 AC_SUBST(MOZ_LOCALE_SWITCHER)
8530 AC_SUBST(MOZ_DISABLE_GECKOVIEW)
8531 AC_SUBST(ENABLE_STRIP)
8532 AC_SUBST(PKG_SKIP_STRIP)
8533 AC_SUBST(STRIP_FLAGS)
8534 AC_SUBST(USE_ELF_HACK)
8535 AC_SUBST(INCREMENTAL_LINKER)
8536 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
8537 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
8539 AC_SUBST(MOZ_FIX_LINK_PATHS)
8540 AC_SUBST(XPCOM_LIBS)
8541 AC_SUBST(XPCOM_FROZEN_LDOPTS)
8542 AC_SUBST(XPCOM_GLUE_LDOPTS)
8543 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
8544 AC_SUBST(XPCOM_STATICRUNTIME_GLUE_LDOPTS)
8545 AC_SUBST(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS)
8547 AC_SUBST(USE_DEPENDENT_LIBS)
8549 AC_SUBST(MOZ_BUILD_ROOT)
8551 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
8552 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
8553 AC_SUBST(MOZ_LINKER_EXTRACT)
8555 AC_SUBST(MOZ_JSDOWNLOADS)
8556 if test -n "$MOZ_JSDOWNLOADS"; then
8557   AC_DEFINE(MOZ_JSDOWNLOADS)
8560 dnl ========================================================
8561 dnl = Mac bundle name prefix
8562 dnl ========================================================
8563 MOZ_ARG_WITH_STRING(macbundlename-prefix,
8564 [  --with-macbundlename-prefix=prefix
8565                           Prefix for MOZ_MACBUNDLE_NAME],
8566 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
8568 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
8569 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
8570   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
8573 if test "$MOZ_DEBUG"; then
8574   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
8575 else
8576   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
8578 AC_SUBST(MOZ_MACBUNDLE_NAME)
8580 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
8581 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr '[A-Z]' '[a-z]'`
8582 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
8583 if test "$MOZ_DEBUG"; then
8584   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
8587 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
8588 AC_SUBST(MOZ_MACBUNDLE_ID)
8590 dnl ========================================================
8591 dnl = Child Process Name for IPC
8592 dnl ========================================================
8593 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
8594   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
8595 else
8596   # We want to let Android unpack the file at install time, but it only does
8597   # so if the file is named libsomething.so. The lib/ path is also required
8598   # because the unpacked file will be under the lib/ subdirectory and will
8599   # need to be executed from that path.
8600   MOZ_CHILD_PROCESS_NAME="lib/libplugin-container.so"
8602 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
8604 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
8605 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
8607 # The following variables are available to branding and application
8608 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
8609 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
8610 # impacts profile location and user-visible fields.
8611 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
8612 # versions of a given application (e.g. Aurora and Firefox both use
8613 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
8614 # for application.ini's "Name" field, which controls profile location in
8615 # the absence of a "Profile" field (see below), and various system
8616 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
8617 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
8618 # Mac Bundle name, Updater, Installer), it is typically used for nightly
8619 # builds (e.g. Aurora for Firefox).
8620 # - MOZ_APP_VERSION: Defines the application version number.
8621 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
8622 # defaults to a lowercase form of MOZ_APP_BASENAME.
8623 # - MOZ_APP_PROFILE: When set, used for application.ini's
8624 # "Profile" field, which controls profile location.
8625 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
8626 # crash reporter server url.
8627 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
8628 # - MOZ_EXTENSION_MANAGER: When set, enabled extension manager.
8630 if test -z "$MOZ_APP_NAME"; then
8631    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
8634 # For extensions and langpacks, we require a max version that is compatible
8635 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
8636 # 24.0a1 and 24.0a2 aren't affected
8637 # 24.0 becomes 24.*
8638 # 24.1.1 becomes 24.*
8639 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
8640 if test -z "$IS_ALPHA"; then
8641   changequote(,)
8642   MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
8643   changequote([,])
8644 else
8645   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
8648 MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"}
8649 AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION")
8650 AC_DEFINE_UNQUOTED(MOZ_B2G_OS_NAME,"$MOZ_B2G_OS_NAME")
8652 AC_SUBST(MOZ_APP_NAME)
8653 AC_SUBST(MOZ_APP_DISPLAYNAME)
8654 AC_SUBST(MOZ_APP_BASENAME)
8655 AC_SUBST(MOZ_APP_VENDOR)
8656 AC_SUBST(MOZ_APP_PROFILE)
8657 AC_SUBST(MOZ_APP_ID)
8658 AC_SUBST(MAR_CHANNEL_ID)
8659 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
8660 AC_SUBST(MOZ_PROFILE_MIGRATOR)
8661 AC_SUBST(MOZ_EXTENSION_MANAGER)
8662 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
8663 AC_SUBST(MOZ_APP_UA_NAME)
8664 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
8665 AC_SUBST(MOZ_APP_VERSION)
8666 AC_SUBST(MOZ_APP_MAXVERSION)
8667 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
8668 AC_SUBST(FIREFOX_VERSION)
8669 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
8670 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
8671   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
8674 AC_SUBST(MOZ_APP_STATIC_INI)
8676 AC_SUBST(MOZ_PKG_SPECIAL)
8678 AC_SUBST(MOZILLA_OFFICIAL)
8680 AC_DEFINE_UNQUOTED(MOZ_TELEMETRY_DISPLAY_REV, 2)
8681 AC_SUBST(MOZ_TELEMETRY_DISPLAY_REV)
8683 if test "$MOZ_TELEMETRY_REPORTING"; then
8684     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
8686     # Enable Telemetry by default for nightly and aurora channels
8687     if test -z "$RELEASE_BUILD"; then
8688       AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
8689     fi
8692 dnl If we have any service that uploads data (and requires data submission
8693 dnl policy alert), set MOZ_DATA_REPORTING.
8694 dnl We need SUBST for build system and DEFINE for xul preprocessor.
8695 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"; then
8696   MOZ_DATA_REPORTING=1
8697   AC_DEFINE(MOZ_DATA_REPORTING)
8698   AC_SUBST(MOZ_DATA_REPORTING)
8701 dnl win32 options
8702 AC_SUBST(MOZ_BROWSE_INFO)
8703 AC_SUBST(MOZ_TOOLS_DIR)
8704 AC_SUBST(WIN32_REDIST_DIR)
8705 AC_SUBST(MAKENSISU)
8707 dnl Echo the CFLAGS to remove extra whitespace.
8708 CFLAGS=`echo \
8709     $_WARNINGS_CFLAGS \
8710     $CFLAGS`
8712 CXXFLAGS=`echo \
8713     $_WARNINGS_CXXFLAGS \
8714     $CXXFLAGS`
8716 COMPILE_CFLAGS=`echo \
8717     $_DEFINES_CFLAGS \
8718     $_DEPEND_CFLAGS \
8719     $COMPILE_CFLAGS`
8721 COMPILE_CXXFLAGS=`echo \
8722     $_DEFINES_CXXFLAGS \
8723     $_DEPEND_CFLAGS \
8724     $COMPILE_CXXFLAGS`
8726 HOST_CFLAGS=`echo \
8727     $HOST_CFLAGS \
8728     $_DEPEND_CFLAGS`
8730 HOST_CXXFLAGS=`echo \
8731     $HOST_CXXFLAGS \
8732     $_DEPEND_CFLAGS`
8734 AC_SUBST(SYSTEM_LIBXUL)
8735 AC_SUBST(MOZ_NATIVE_JPEG)
8736 AC_SUBST(MOZ_NATIVE_PNG)
8737 AC_SUBST(MOZ_NATIVE_BZ2)
8739 AC_SUBST(MOZ_JPEG_CFLAGS)
8740 AC_SUBST(MOZ_JPEG_LIBS)
8741 AC_SUBST(MOZ_BZ2_CFLAGS)
8742 AC_SUBST(MOZ_BZ2_LIBS)
8743 AC_SUBST(MOZ_PNG_CFLAGS)
8744 AC_SUBST(MOZ_PNG_LIBS)
8746 if test "$MOZ_WIDGET_TOOLKIT" = gonk -a -n "$MOZ_NUWA_PROCESS"; then
8747     export MOZ_NUWA_PROCESS
8748     AC_DEFINE(MOZ_NUWA_PROCESS)
8750 AC_SUBST(MOZ_NUWA_PROCESS)
8752 AC_SUBST(NSPR_CFLAGS)
8753 AC_SUBST(NSPR_LIBS)
8754 AC_SUBST(MOZ_NATIVE_NSPR)
8756 AC_SUBST(NSS_CFLAGS)
8757 AC_SUBST(NSS_LIBS)
8758 AC_SUBST(MOZ_NATIVE_NSS)
8759 AC_SUBST(NSS_DISABLE_DBM)
8761 OS_CFLAGS="$CFLAGS"
8762 OS_CXXFLAGS="$CXXFLAGS"
8763 OS_CPPFLAGS="$CPPFLAGS"
8764 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
8765 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
8766 OS_LDFLAGS="$LDFLAGS"
8767 OS_LIBS="$LIBS"
8768 AC_SUBST(OS_CFLAGS)
8769 AC_SUBST(OS_CXXFLAGS)
8770 AC_SUBST(OS_CPPFLAGS)
8771 AC_SUBST(OS_COMPILE_CFLAGS)
8772 AC_SUBST(OS_COMPILE_CXXFLAGS)
8773 AC_SUBST(OS_LDFLAGS)
8774 AC_SUBST(OS_LIBS)
8775 AC_SUBST(CROSS_COMPILE)
8776 AC_SUBST(WCHAR_CFLAGS)
8778 AC_SUBST(HOST_CC)
8779 AC_SUBST(HOST_CXX)
8780 AC_SUBST(HOST_CFLAGS)
8781 AC_SUBST(HOST_CXXFLAGS)
8782 AC_SUBST(HOST_LDFLAGS)
8783 AC_SUBST(HOST_OPTIMIZE_FLAGS)
8784 AC_SUBST(HOST_AR)
8785 AC_SUBST(HOST_AR_FLAGS)
8786 AC_SUBST(HOST_LD)
8787 AC_SUBST(HOST_RANLIB)
8788 AC_SUBST(HOST_NSPR_MDCPUCFG)
8789 AC_SUBST(HOST_BIN_SUFFIX)
8790 AC_SUBST(HOST_OS_ARCH)
8792 AC_SUBST(TARGET_CPU)
8793 AC_SUBST(TARGET_VENDOR)
8794 AC_SUBST(TARGET_OS)
8795 AC_SUBST(TARGET_NSPR_MDCPUCFG)
8796 AC_SUBST(TARGET_MD_ARCH)
8797 AC_SUBST(TARGET_XPCOM_ABI)
8798 AC_SUBST(OS_TARGET)
8799 AC_SUBST(OS_ARCH)
8800 AC_SUBST(OS_RELEASE)
8801 AC_SUBST(OS_TEST)
8802 AC_SUBST(CPU_ARCH)
8803 AC_SUBST(INTEL_ARCHITECTURE)
8804 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
8805 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
8806 AC_SUBST(GCC_USE_GNU_LD)
8808 AC_SUBST(MOZ_CHROME_FILE_FORMAT)
8810 AC_SUBST(WRAP_LDFLAGS)
8811 AC_SUBST(MKSHLIB)
8812 AC_SUBST(MKCSHLIB)
8813 AC_SUBST(MKSHLIB_FORCE_ALL)
8814 AC_SUBST(MKSHLIB_UNFORCE_ALL)
8815 AC_SUBST(DSO_CFLAGS)
8816 AC_SUBST(DSO_PIC_CFLAGS)
8817 AC_SUBST(DSO_LDOPTS)
8818 AC_SUBST(LIB_PREFIX)
8819 AC_SUBST(DLL_PREFIX)
8820 AC_SUBST(DLL_SUFFIX)
8821 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
8822 AC_SUBST(LIB_SUFFIX)
8823 AC_SUBST(OBJ_SUFFIX)
8824 AC_SUBST(BIN_SUFFIX)
8825 AC_SUBST(ASM_SUFFIX)
8826 AC_SUBST(IMPORT_LIB_SUFFIX)
8827 AC_SUBST(USE_N32)
8828 AC_SUBST(CC_VERSION)
8829 AC_SUBST(CXX_VERSION)
8830 AC_SUBST(MSMANIFEST_TOOL)
8831 AC_SUBST(NS_ENABLE_TSF)
8832 AC_SUBST(MOZ_APP_COMPONENT_LIBS)
8833 AC_SUBST(MOZ_APP_EXTRA_LIBS)
8835 AC_SUBST(MOZ_WAVE)
8836 AC_SUBST(MOZ_VORBIS)
8837 AC_SUBST(MOZ_TREMOR)
8838 AC_SUBST(MOZ_OPUS)
8839 AC_SUBST(MOZ_WEBM)
8840 AC_SUBST(MOZ_WMF)
8841 AC_SUBST(MOZ_FFMPEG)
8842 AC_SUBST(MOZ_FMP4)
8843 AC_SUBST(MOZ_DIRECTSHOW)
8844 AC_SUBST(MOZ_MEDIA_PLUGINS)
8845 AC_SUBST(MOZ_APPLEMEDIA)
8846 AC_SUBST(MOZ_OMX_PLUGIN)
8847 AC_SUBST(MOZ_VPX_ERROR_CONCEALMENT)
8848 AC_SUBST(MOZ_VPX)
8849 AC_SUBST(VPX_AS)
8850 AC_SUBST(VPX_ASFLAGS)
8851 AC_SUBST(VPX_DASH_C_FLAG)
8852 AC_SUBST(VPX_AS_CONVERSION)
8853 AC_SUBST(VPX_ASM_SUFFIX)
8854 AC_SUBST(VPX_X86_ASM)
8855 AC_SUBST(VPX_ARM_ASM)
8856 AC_SUBST(VPX_NEED_OBJ_INT_EXTRACT)
8857 AC_SUBST(MOZ_INSTRUMENT_EVENT_LOOP)
8858 AC_SUBST(LIBJPEG_TURBO_AS)
8859 AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
8860 AC_SUBST(LIBJPEG_TURBO_X86_ASM)
8861 AC_SUBST(LIBJPEG_TURBO_X64_ASM)
8862 AC_SUBST(LIBJPEG_TURBO_ARM_ASM)
8864 AC_SUBST(MOZ_PACKAGE_JSSHELL)
8865 AC_SUBST(MOZ_FOLD_LIBS)
8867 AC_SUBST(MOZ_ENABLE_SZIP)
8868 AC_SUBST(MOZ_SZIP_FLAGS)
8870 if test "$MOZ_DEBUG"; then
8871     MOZ_EM_DEBUG=1
8873 AC_SUBST(MOZ_EM_DEBUG)
8875 if test -n "$COMPILE_ENVIRONMENT"; then
8876 AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
8878 dnl Check for missing components
8879 if test "$MOZ_X11"; then
8880     if test "$WITHOUT_X11"; then
8881         AC_MSG_ERROR([--without-x specified and MOZ_X11 still defined])
8882     fi
8883     dnl ====================================================
8884     dnl = Check if X headers exist
8885     dnl ====================================================
8886     _SAVE_CFLAGS=$CFLAGS
8887     CFLAGS="$CFLAGS $XCFLAGS"
8888     AC_TRY_COMPILE([
8889         #include <stdio.h>
8890         #include <stdlib.h>
8891         #include <X11/Xlib.h>
8892         #include <X11/Intrinsic.h>
8893         #include <X11/extensions/XShm.h>
8894     ],
8895     [
8896         Display *dpy = 0;
8897         if ((dpy = XOpenDisplay(NULL)) == NULL) {
8898             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
8899             exit(1);
8900         }
8901     ], [],
8902     [ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
8903     CFLAGS="$_SAVE_CFLAGS"
8905     if test -n "$MISSING_X"; then
8906         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
8907     fi
8909 fi # MOZ_X11
8911 fi # COMPILE_ENVIRONMENT
8913 dnl Set various defines and substitutions
8914 dnl ========================================================
8916 if test "$OS_ARCH" != "WINNT"; then
8917   AC_DEFINE(XP_UNIX)
8920 if test "$MOZ_DEBUG"; then
8921     AC_DEFINE(MOZ_REFLOW_PERF)
8922     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
8925 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
8926     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
8927     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
8928     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
8929     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
8930     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
8931     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
8932     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
8933     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
8936 if test "$MOZ_DEBUG"; then
8937     A11Y_LOG=1
8939 case "$MOZ_UPDATE_CHANNEL" in
8940 aurora|beta|release|esr)
8941     ;;
8943     A11Y_LOG=1
8944     ;;
8945 esac
8946 AC_SUBST(A11Y_LOG)
8947 if test -n "$A11Y_LOG"; then
8948     AC_DEFINE(A11Y_LOG)
8951 AC_SUBST(MOZILLA_VERSION)
8953 AC_SUBST(ac_configure_args)
8955 dnl Spit out some output
8956 dnl ========================================================
8958 dnl The following defines are used by xpcom
8959 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
8960 CPP_THROW_NEW
8961 HAVE_CPP_AMBIGUITY_RESOLVING_USING
8962 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
8963 HAVE_CPP_PARTIAL_SPECIALIZATION
8964 HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
8965 NEED_CPP_UNUSED_IMPLEMENTATIONS
8966 HAVE_GETPAGESIZE
8967 HAVE_ICONV
8968 HAVE_ICONV_WITH_CONST_INPUT
8969 HAVE_MBRTOWC
8970 HAVE_WCRTOMB
8971 HAVE_STATVFS64
8972 HAVE_STATVFS
8973 HAVE_STATFS64
8974 HAVE_STATFS
8975 HAVE_SYS_STATVFS_H
8976 HAVE_SYS_STATFS_H
8977 HAVE_SYS_VFS_H
8978 HAVE_SYS_MOUNT_H
8981 AC_SUBST(STLPORT_LIBS)
8983 dnl ========================================================
8984 dnl ICU Support
8985 dnl ========================================================
8987 # Internationalization isn't built or exposed by default in non-desktop
8988 # builds.  Bugs to enable:
8990 #   Android:  bug 864843
8991 #   B2G:      bug 866301
8993 if test "$MOZ_WIDGET_TOOLKIT" = "android" ||
8994    test "$MOZ_BUILD_APP" = "b2g"; then
8995     _INTL_API=no
8996 else
8997     _INTL_API=yes
9000 MOZ_CONFIG_ICU()
9002 if test -n "$MOZ_NATIVE_ICU"; then
9003     MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_ICU_LIBS"
9006 if test -n "$JS_SHARED_LIBRARY"; then
9007   MOZ_JS_LIBS="$MOZ_JS_SHARED_LIBS"
9008 else
9009   MOZ_JS_LIBS="$MOZ_JS_STATIC_LIBS"
9010   AC_DEFINE(MOZ_STATIC_JS)
9012 AC_SUBST(JS_SHARED_LIBRARY)
9014 AC_SUBST(UPLOAD_EXTRA_FILES)
9016 MOZ_CREATE_CONFIG_STATUS()
9018 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9019 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9020   MOZ_SUBCONFIGURE_ICU()
9021   MOZ_SUBCONFIGURE_FFI()
9024 # Hack around an Apple bug that affects the egrep that comes with OS X 10.7.
9025 # "env ARCHPREFERENCE=i386,x86_64 arch egrep" first tries to use the 32-bit
9026 # Intel part of the egrep fat binary, even on 64-bit systems, and falls back on
9027 # the 64-bit part if it's not a fat binary, as can happen with MacPorts. We
9028 # (apparently) only need this hack when egrep's "pattern" is particularly long
9029 # (as in the following code) and the first egrep on our $PATH is Apple's.  See
9030 # bug 655339.
9031 case "$host" in
9032 *-apple-darwin11*)
9033     FIXED_EGREP="env ARCHPREFERENCE=i386,x86_64 arch egrep"
9034     ;;
9036     FIXED_EGREP="egrep"
9037     ;;
9038 esac
9040 # Run jemalloc configure script
9042 if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC3" -o -n "$MOZ_REPLACE_MALLOC"; then
9043   ac_configure_args="--build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
9044   if test -n "$MOZ_REPLACE_MALLOC"; then
9045     # When using replace_malloc, we always want memalign and valloc exported from jemalloc.
9046     ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
9047     ac_configure_args="$ac_configure_args ac_cv_func_valloc=yes"
9048   fi
9049   if test -n "$MOZ_JEMALLOC3"; then
9050     case "${OS_ARCH}" in
9051       WINNT|Darwin)
9052         # We want jemalloc functions to be kept hidden on both Mac and Windows
9053         # See memory/build/mozmemory_wrap.h for details.
9054         ac_configure_args="$ac_configure_args --without-export"
9055         ;;
9056     esac
9057   elif test "${OS_ARCH}" = Darwin; then
9058     # When building as a replace-malloc lib, disabling the zone allocator
9059     # forces to use pthread_atfork.
9060     ac_configure_args="$ac_configure_args --disable-zone-allocator"
9061   fi
9062   _MANGLE="malloc posix_memalign aligned_alloc calloc realloc free memalign valloc malloc_usable_size"
9063   JEMALLOC_WRAPPER=
9064   if test -z "$MOZ_REPLACE_MALLOC"; then
9065     case "$OS_ARCH" in
9066       Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
9067         MANGLE=$_MANGLE
9068         ;;
9069     esac
9070   elif test -z "$MOZ_JEMALLOC3"; then
9071     MANGLE=$_MANGLE
9072     JEMALLOC_WRAPPER=replace_
9073   fi
9074   if test -n "$MANGLE"; then
9075     MANGLED=
9076     if test -n "$_WRAP_MALLOC" -a -z "$JEMALLOC_WRAPPER"; then
9077       JEMALLOC_WRAPPER=__wrap_
9078     fi
9079     for mangle in ${MANGLE}; do
9080       if test -n "$MANGLED"; then
9081         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle,$MANGLED"
9082       else
9083         MANGLED="$mangle:$JEMALLOC_WRAPPER$mangle"
9084       fi
9085     done
9086     ac_configure_args="$ac_configure_args --with-mangling=$MANGLED"
9087   fi
9088   unset CONFIG_FILES
9089   if test -z "$MOZ_TLS"; then
9090     ac_configure_args="$ac_configure_args --disable-tls"
9091   fi
9092   EXTRA_CFLAGS="$CFLAGS"
9093   for var in AS CC CXX CPP LD AR RANLIB STRIP CPPFLAGS EXTRA_CFLAGS LDFLAGS; do
9094     ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
9095   done
9096   if test "$CROSS_COMPILE"; then
9097     ac_configure_args="$ac_configure_args je_cv_static_page_shift=12"
9098   fi
9099   _save_cache_file="$cache_file"
9100   cache_file=$_objdir/memory/jemalloc/src/config.cache
9102   if ! test -e memory/jemalloc; then
9103     mkdir -p memory/jemalloc
9104   fi
9106   dnl jemalloc's configure uses $srcdir in AC_CONFIG_HEADERS, which syntax uses
9107   dnl colons, conflicting with the windows-style path in $srcdir.
9108   dnl Turn it into a msys path just for jemalloc's configure
9109   _save_srcdir="$srcdir"
9110   srcdir=`cd $srcdir; pwd`
9111   AC_OUTPUT_SUBDIRS(memory/jemalloc/src)
9112   srcdir="$_save_srcdir"
9113   cache_file="$_save_cache_file"
9114   ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9117 # Run freetype configure script
9119 if test "$MOZ_TREE_FREETYPE"; then
9120    export CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS -std=c99"
9121    export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS"
9122    export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS"
9123    export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS"
9124    # Spaces in the *_CFLAGS and *_LIBS variables are intentionally placed
9125    # to force freetype to use our settings rather than autodetecting
9126    export LIBPNG_CFLAGS="$MOZ_PNG_CFLAGS "
9127    export LIBPNG_LIBS="$MOZ_PNG_LIBS "
9128    export ZLIB_CFLAGS="$MOZ_ZLIB_CFLAGS "
9129    export ZLIB_LIBS="$MOZ_ZLIB_LIBS "
9130    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
9131    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes --with-zlib=yes --without-bzip2 --with-png=yes --without-harfbuzz"
9133    if ! test -e modules; then
9134      mkdir modules
9135    fi
9137    AC_OUTPUT_SUBDIRS(modules/freetype2)
9140 if test -z "$direct_nspr_config"; then
9141     dnl ========================================================
9142     dnl = Setup a nice relatively clean build environment for
9143     dnl = sub-configures.
9144     dnl ========================================================
9145     CC="$_SUBDIR_CC"
9146     CXX="$_SUBDIR_CXX"
9147     CFLAGS="$_SUBDIR_CFLAGS"
9148     CPPFLAGS="$_SUBDIR_CPPFLAGS"
9149     CXXFLAGS="$_SUBDIR_CXXFLAGS"
9150     LDFLAGS="$_SUBDIR_LDFLAGS"
9151     HOST_CC="$_SUBDIR_HOST_CC"
9152     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9153     HOST_CXXFLAGS="$_SUBDIR_HOST_CXXFLAGS"
9154     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9155     RC=
9158 unset MAKEFILES
9159 unset CONFIG_FILES
9161 # Run all configure scripts specified by a subconfigure
9162 if test -n "$_subconfigure_subdir"; then
9163   _save_ac_configure_args="$ac_configure_args"
9164   ac_configure_args="$_subconfigure_config_args"
9165   AC_OUTPUT_SUBDIRS("$_subconfigure_subdir")
9166   ac_configure_args="$_save_ac_configure_args"
9169 # No need to run subconfigures when building with LIBXUL_SDK_DIR
9170 if test "$COMPILE_ENVIRONMENT" -a -z "$LIBXUL_SDK_DIR"; then
9172 export WRAP_LDFLAGS
9174 if test -n "$_WRAP_MALLOC"; then
9175     # Avoid doubling wrap malloc arguments
9176     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
9179 if test -z "$MOZ_NATIVE_NSPR"; then
9180     ac_configure_args="$_SUBDIR_CONFIG_ARGS --with-dist-prefix=$MOZ_BUILD_ROOT/dist --with-mozilla"
9181     if test -z "$MOZ_DEBUG"; then
9182         ac_configure_args="$ac_configure_args --disable-debug"
9183     else
9184         ac_configure_args="$ac_configure_args --enable-debug"
9185         if test -n "$MOZ_NO_DEBUG_RTL"; then
9186             ac_configure_args="$ac_configure_args --disable-debug-rtl"
9187         fi
9188     fi
9189     if test "$MOZ_OPTIMIZE" = "1"; then
9190         ac_configure_args="$ac_configure_args --enable-optimize"
9191     elif test -z "$MOZ_OPTIMIZE"; then
9192         ac_configure_args="$ac_configure_args --disable-optimize"
9193     fi
9194     if test -n "$HAVE_64BIT_OS"; then
9195         ac_configure_args="$ac_configure_args --enable-64bit"
9196     fi
9197     if test -n "$USE_ARM_KUSER"; then
9198         ac_configure_args="$ac_configure_args --with-arm-kuser"
9199     fi
9200     # A configure script generated by autoconf 2.68 does not allow the cached
9201     # values of "precious" variables such as CFLAGS and LDFLAGS to differ from
9202     # the values passed to the configure script. Since we modify CFLAGS and
9203     # LDFLAGS before passing them to NSPR's configure script, we cannot share
9204     # config.cache with NSPR. As a result, we cannot pass AS, CC, CXX, etc. to
9205     # NSPR via a shared config.cache file and must pass them to NSPR on the
9206     # configure command line.
9207     for var in AS CC CXX CPP LD AR RANLIB STRIP; do
9208         ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
9209     done
9210     # A configure script generated by autoconf 2.68 warns if --host is
9211     # specified but --build isn't. So we always pass --build to NSPR's
9212     # configure script.
9213     ac_configure_args="$ac_configure_args --build=$build"
9214     ac_configure_args="$ac_configure_args $NSPR_CONFIGURE_ARGS"
9216     # Save these, so we can mess with them for the subconfigure ..
9217     _SAVE_CFLAGS="$CFLAGS"
9218     _SAVE_CPPFLAGS="$CPPFLAGS"
9219     _SAVE_LDFLAGS="$LDFLAGS"
9221     if test -n "$MOZ_LINKER" -a "$ac_cv_func_dladdr" = no ; then
9222       # dladdr is supported by the new linker, even when the system linker doesn't
9223       # support it. Trick nspr into using dladdr when it's not supported.
9224       export CPPFLAGS="-include $_topsrcdir/mozglue/linker/dladdr.h $CPPFLAGS"
9225     fi
9226     export LDFLAGS="$LDFLAGS $NSPR_LDFLAGS"
9227     export CFLAGS="$CFLAGS $MOZ_FRAMEPTR_FLAGS"
9229     # Use a separate cache file for NSPR since it uses autoconf 2.68.
9230     _save_cache_file="$cache_file"
9231     cache_file=$_objdir/nsprpub/config.cache
9233     AC_OUTPUT_SUBDIRS(nsprpub)
9235     # .. and restore them
9236     cache_file="$_save_cache_file"
9237     CFLAGS="$_SAVE_CFLAGS"
9238     CPPFLAGS="$_SAVE_CPPFLAGS"
9239     LDFLAGS="$_SAVE_LDFLAGS"
9241     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9244 dnl ========================================================
9245 dnl = Setup a nice relatively clean build environment for
9246 dnl = sub-configures.
9247 dnl ========================================================
9248 CC="$_SUBDIR_CC"
9249 CXX="$_SUBDIR_CXX"
9250 CFLAGS="$_SUBDIR_CFLAGS"
9251 CPPFLAGS="$_SUBDIR_CPPFLAGS"
9252 CXXFLAGS="$_SUBDIR_CXXFLAGS"
9253 LDFLAGS="$_SUBDIR_LDFLAGS"
9254 HOST_CC="$_SUBDIR_HOST_CC"
9255 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
9256 HOST_CXXFLAGS="$_SUBDIR_HOST_CXXFLAGS"
9257 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
9260 if test -n "$ENABLE_CLANG_PLUGIN"; then
9261     ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9262     AC_OUTPUT_SUBDIRS(build/clang-plugin)
9266 # Run the SpiderMonkey 'configure' script.
9267 dist=$MOZ_BUILD_ROOT/dist
9268 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9269 ac_configure_args="$ac_configure_args --enable-threadsafe"
9271 if test "$_INTL_API" = no; then
9272     ac_configure_args="$ac_configure_args --without-intl-api"
9275 if test "$BUILD_CTYPES"; then
9276     # Build js-ctypes on the platforms we can.
9277     ac_configure_args="$ac_configure_args --enable-ctypes"
9279 if test -z "$JS_SHARED_LIBRARY" ; then
9280     ac_configure_args="$ac_configure_args --disable-shared-js"
9281     if test -n "$MOZ_DISABLE_EXPORT_JS"; then
9282         ac_configure_args="$ac_configure_args --disable-export-js"
9283     fi
9285 if test -z "$JSGC_USE_EXACT_ROOTING" ; then
9286     ac_configure_args="$ac_configure_args --disable-exact-rooting"
9288 if test -z "$JSGC_GENERATIONAL" ; then
9289     ac_configure_args="$ac_configure_args --disable-gcgenerational"
9291 if test -z "$MOZ_NATIVE_NSPR"; then
9292     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
9293     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
9295 ac_configure_args="$ac_configure_args --prefix=$dist"
9296 if test "$MOZ_MEMORY"; then
9297    ac_configure_args="$ac_configure_args --enable-jemalloc"
9299 if test -n "$MOZ_GLUE_LDFLAGS"; then
9300    export MOZ_GLUE_LDFLAGS
9302 if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
9303    export MOZ_GLUE_PROGRAM_LDFLAGS
9305 if test -n "$ZLIB_IN_MOZGLUE"; then
9306    MOZ_ZLIB_LIBS=
9308 export MOZ_NATIVE_ZLIB
9309 export MOZ_ZLIB_CFLAGS
9310 export MOZ_ZLIB_LIBS
9311 export MOZ_APP_NAME
9312 export DONT_POPULATE_VIRTUALENV=1
9313 export PYTHON
9314 export MOZILLA_CENTRAL_PATH=$_topsrcdir
9315 export STLPORT_CPPFLAGS
9316 export STLPORT_LDFLAGS
9317 export STLPORT_LIBS
9318 export JS_STANDALONE=no
9319 export MOZ_LINKER
9320 export ZLIB_IN_MOZGLUE
9322 if ! test -e js; then
9323     mkdir js
9326 AC_OUTPUT_SUBDIRS(js/src)
9327 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
9329 fi # COMPILE_ENVIRONMENT && !LIBXUL_SDK_DIR
9331 export WRITE_MOZINFO=1
9332 dnl we need to run config.status after js/src subconfigure because we're
9333 dnl traversing its moz.build and we need its config.status for that.
9334 dnl However, writing our own config.status needs to happen before
9335 dnl subconfigures because the setup surrounding subconfigures alters
9336 dnl many AC_SUBSTed variables.
9337 MOZ_RUN_CONFIG_STATUS()
9338 unset WRITE_MOZINFO