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