Bug 1328416. Add src param to track where compat reports are coming from. r=sebastian
[gecko.git] / old-configure.in
blobf27f84dad994bc2ce027e3ae0f3d2b2a2871898c
1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2 dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4:
3 dnl This Source Code Form is subject to the terms of the Mozilla Public
4 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
5 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 dnl Process this file with autoconf to produce a configure script.
8 dnl ========================================================
9 AC_PREREQ(2.13)
10 AC_INIT(config/config.mk)
11 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
12 AC_CANONICAL_SYSTEM
14 dnl ========================================================
15 dnl =
16 dnl = Don't change the following two lines.  Doing so breaks:
17 dnl =
18 dnl = CFLAGS="-foo" ./configure
19 dnl =
20 dnl ========================================================
21 CFLAGS="${CFLAGS=}"
22 CPPFLAGS="${CPPFLAGS=}"
23 CXXFLAGS="${CXXFLAGS=}"
24 LDFLAGS="${LDFLAGS=}"
25 HOST_CFLAGS="${HOST_CFLAGS=}"
26 HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
27 HOST_LDFLAGS="${HOST_LDFLAGS=}"
29 dnl ========================================================
30 dnl = Preserve certain environment flags passed to configure
31 dnl = We want sub projects to receive the same flags
32 dnl = untainted by this configure script
33 dnl ========================================================
34 _SUBDIR_CC="$CC"
35 _SUBDIR_CXX="$CXX"
36 _SUBDIR_CFLAGS="$CFLAGS"
37 _SUBDIR_CPPFLAGS="$CPPFLAGS"
38 _SUBDIR_CXXFLAGS="$CXXFLAGS"
39 _SUBDIR_LDFLAGS="$LDFLAGS"
40 _SUBDIR_HOST_CC="$HOST_CC"
41 _SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
42 _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
43 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
44 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
46 dnl Set the version number of the libs included with mozilla
47 dnl ========================================================
48 MOZJPEG=62
49 MOZPNG=10627
50 NSPR_VERSION=4
51 NSPR_MINVER=4.13.1
52 NSS_VERSION=3
54 dnl Set the minimum version of toolkit libs used by mozilla
55 dnl ========================================================
56 GLIB_VERSION=2.22
57 # 2_26 is the earliest version we can set GLIB_VERSION_MIN_REQUIRED.
58 # The macro won't be used when compiling with earlier versions anyway.
59 GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26
60 GIO_VERSION=2.22
61 CAIRO_VERSION=1.10
62 GTK2_VERSION=2.18.0
63 GTK3_VERSION=3.4.0
64 GDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4
65 WINDRES_VERSION=2.14.90
66 W32API_VERSION=3.14
67 GNOMEUI_VERSION=2.2.0
68 GCONF_VERSION=1.2.1
69 STARTUP_NOTIFICATION_VERSION=0.8
70 DBUS_VERSION=0.60
71 SQLITE_VERSION=3.15.2
73 dnl Set various checks
74 dnl ========================================================
75 MISSING_X=
77 dnl Initialize the Pthread test variables early so they can be
78 dnl  overridden by each platform.
79 dnl ========================================================
80 MOZ_USE_PTHREADS=
81 _PTHREAD_LDFLAGS=""
83 MOZ_DEFAULT_COMPILER
85 if test "$COMPILE_ENVIRONMENT"; then
86     MOZ_ANDROID_NDK
87 fi # COMPILE_ENVIRONMENT
89 if test -n "$gonkdir"; then
90     dnl export for js/src/configure. We can't pass the option down normally,
91     dnl because it's a `--enable-project=b2g`-only option.
92     export gonkdir
93     kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
94     android_source="$gonkdir"
95     ANDROID_SOURCE="$android_source"
97     case "$android_version" in
98     15)
99         CPPFLAGS="-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/dalvik/libnativehelper/include/nativehelper $CPPFLAGS"
100         MOZ_SECUREELEMENT=1
101         ;;
102     17|18)
103         CPPFLAGS="-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 $CPPFLAGS"
104         MOZ_SECUREELEMENT=1
105         ;;
106     19)
107         CPPFLAGS="-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 $CPPFLAGS"
108         MOZ_AUDIO_OFFLOAD=1
109         MOZ_SECUREELEMENT=1
110         AC_SUBST(MOZ_AUDIO_OFFLOAD)
111         AC_DEFINE(MOZ_AUDIO_OFFLOAD)
112         ;;
113     21|22)
114         CPPFLAGS="-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 $CPPFLAGS"
115         MOZ_AUDIO_OFFLOAD=1
116         AC_SUBST(MOZ_AUDIO_OFFLOAD)
117         AC_DEFINE(MOZ_AUDIO_OFFLOAD)
118         ;;
119     *)
120         AC_MSG_ERROR([Unsupported platform version: $android_version])
121         ;;
122     esac
124     CPPFLAGS="-I$gonkdir/system -I$gonkdir/system/core/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/external/valgrind/fxos-include $CPPFLAGS"
125     LDFLAGS="-L$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib -Wl,-rpath-link=$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib $LDFLAGS"
127     AC_DEFINE(ANDROID)
128     AC_DEFINE_UNQUOTED(ANDROID_VERSION, $android_version)
129     AC_DEFINE(HAVE_SYS_UIO_H)
130     AC_DEFINE(HAVE_PTHREADS)
132     dnl ANDROID_VERSION is only required for the AC_SUBST below
133     ANDROID_VERSION=$android_version
134     AC_SUBST(ANDROID_VERSION)
136     direct_nspr_config=1
138 else
139     case "$target" in
140     *-android*|*-linuxandroid*)
141         ZLIB_DIR=yes
142         AC_DEFINE(ANDROID)
143         ;;
144     *-linux*)
145         AC_PATH_PROG(OBJCOPY,objcopy)
146         ;;
147     esac
150 case "$target" in
151 *-apple-darwin*)
152     MOZ_IOS_SDK
153     ;;
154 esac
156 AC_SUBST(ANDROID_SOURCE)
157 AC_SUBST(ANDROID_PACKAGE_NAME)
158 AC_SUBST(OBJCOPY)
160 dnl ========================================================
161 dnl Checks for compilers.
162 dnl ========================================================
164 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
165 AR_FLAGS='crs $@'
167 if test "$COMPILE_ENVIRONMENT"; then
169 if test "$target" != "$host"; then
170     MOZ_CROSS_COMPILER
171 else
172     AC_PROG_CC
173     case "$target" in
174     *-mingw*)
175       # Work around the conftest.exe access problem on Windows
176       sleep 2
177     esac
178     AC_PROG_CXX
179     AC_PROG_RANLIB
180     MOZ_PATH_PROGS(AS, $AS as, $CC)
181     AC_CHECK_PROGS(AR, ar, :)
182     AC_CHECK_PROGS(STRIP, strip, :)
183     AC_CHECK_PROGS(WINDRES, windres, :)
184     AC_CHECK_PROGS(OTOOL, otool, :)
185     if test -z "$HOST_RANLIB"; then
186         HOST_RANLIB="$RANLIB"
187     fi
188     if test -z "$HOST_AR"; then
189         HOST_AR="$AR"
190     fi
191     if test -z "$HOST_AR_FLAGS"; then
192         HOST_AR_FLAGS="$AR_FLAGS"
193     fi
196 if test -n "$MOZ_WINCONSOLE"; then
197     AC_DEFINE(MOZ_WINCONSOLE)
200 MOZ_TOOL_VARIABLES
202 dnl ========================================================
203 dnl Special win32 checks
204 dnl ========================================================
206 WINVER=502
208 case "$target" in
209 *-mingw*)
210     if test "$GCC" != "yes"; then
211         # Check to see if we are really running in a msvc environemnt
212         _WIN32_MSVC=1
213         AC_CHECK_PROGS(MIDL, midl)
215         # Make sure compilers are valid
216         CFLAGS="$CFLAGS -TC -nologo"
217         CXXFLAGS="$CXXFLAGS -TP -nologo"
218         AC_LANG_SAVE
219         AC_LANG_C
220         AC_TRY_COMPILE([#include <stdio.h>],
221             [ printf("Hello World\n"); ],,
222             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
224         AC_LANG_CPLUSPLUS
225         AC_TRY_COMPILE([#include <new.h>],
226             [ unsigned *test = new unsigned(42); ],,
227             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
228         AC_LANG_RESTORE
230         changequote(,)
231         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
232         changequote([,])
234         _MSC_VER=`echo ${CC_VERSION} | cut -c 1-2,4-5`
236         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
237         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
238         AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
240         case "$CC_VERSION" in
241         19*)
242             _CC_SUITE=14
243             MSVS_VERSION=2015
244             MSVC_C_RUNTIME_DLL=vcruntime140.dll
245             MSVC_CXX_RUNTIME_DLL=msvcp140.dll
247             MOZ_CHECK_HEADER(dia2.h, MSVC_HAS_DIA_SDK=1)
248             if test -n "$MSVC_HAS_DIA_SDK"; then
249                 AC_DEFINE(MSVC_HAS_DIA_SDK)
250             fi
252             # C5026: move constructor was implicitly defined as deleted
253             CXXFLAGS="$CXXFLAGS -wd5026"
255             # C5027: move assignment operator was implicitly defined as deleted
256             CXXFLAGS="$CXXFLAGS -wd5027"
258             # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
259             CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
261             # https://connect.microsoft.com/VisualStudio/feedback/details/888527/warnings-on-dbghelp-h
262             # for dbghelp.h, imagehlp.h, and shobj.h
263             # C4091: 'typedef ': ignored on left of '' when no variable is declared
264             CFLAGS="$CFLAGS -wd4091"
265             CXXFLAGS="$CXXFLAGS -wd4091"
267             # This is intended as a temporary hack to support building with VS2015.
268             # 'noexcept' used with no exception handling mode specified;
269             # termination on exception is not guaranteed. Specify /EHsc
270             CXXFLAGS="$CXXFLAGS -wd4577"
272             if test -n "$WIN_UCRT_REDIST_DIR"; then
273               if test ! -d "$WIN_UCRT_REDIST_DIR"; then
274                 AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
275               fi
276               WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && pwd -W`
277             fi
278             ;;
279         esac
280         AC_SUBST(MSVS_VERSION)
281         AC_SUBST(MSVC_HAS_DIA_SDK)
282         AC_SUBST(MSVC_C_RUNTIME_DLL)
283         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
285         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
287         if test -n "$WIN32_REDIST_DIR"; then
288           if test ! -d "$WIN32_REDIST_DIR"; then
289             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
290           fi
291           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd -W`
292         fi
294         # Check linker version
295         _LD_FULL_VERSION=`"${LINK}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
296         _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
297         if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
298             AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
299         fi
301         INCREMENTAL_LINKER=1
303         # Set midl environment
304         case "$target" in
305         i*86-*)
306             MIDL_FLAGS="${MIDL_FLAGS} -env win32"
307             ;;
308         x86_64-*)
309             MIDL_FLAGS="${MIDL_FLAGS} -env x64"
310             ;;
311         esac
313         unset _MSVC_VER_FILTER
315         AC_CACHE_CHECK(for overridable _RAISE,
316                        ac_cv_have__RAISE,
317             [
318                 AC_LANG_SAVE
319                 AC_LANG_CPLUSPLUS
320                 _SAVE_CXXFLAGS="$CXXFLAGS"
321                 CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
322                 AC_TRY_COMPILE([#include <xstddef>
323                                 #undef _RAISE
324                                 #define _RAISE(x) externallyDefinedFunction((x).what())
325                                 #include <vector>
326                                ],
327                                [std::vector<int> v; return v.at(1);],
328                                ac_cv_have__RAISE="no",
329                                ac_cv_have__RAISE="yes")
330                 CXXFLAGS="$_SAVE_CXXFLAGS"
331                 AC_LANG_RESTORE
332             ])
333         if test "$ac_cv_have__RAISE" = "yes"; then
334             WRAP_STL_INCLUDES=1
335             MOZ_MSVC_STL_WRAP_RAISE=1
336             AC_DEFINE(MOZ_MSVC_STL_WRAP_RAISE)
337         else
338             AC_MSG_ERROR([Gecko exception wrapping doesn't understand your your MSVC/SDK.  Please file a bug describing this error and your build configuration.])
339         fi
341         if test "$WRAP_STL_INCLUDES" = "1"; then
342             STL_FLAGS="-I${DIST}/stl_wrappers"
343         fi
344         CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
345         CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
346     else
347         # Check w32api version
348         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
349         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
350         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
351         AC_TRY_COMPILE([#include <w32api.h>],
352             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
353                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
354                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
355                 #error "test failed."
356             #endif
357             , [ res=yes ], [ res=no ])
358         AC_MSG_RESULT([$res])
359         if test "$res" != "yes"; then
360             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
361         fi
362         # Check windres version
363         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
364         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
365         AC_MSG_RESULT([$_WINDRES_VERSION])
366         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
367         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
368         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
369         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
370         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
371         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
372         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
373                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
374                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
375                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
376                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
377                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
378         then
379             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
380         fi
382         AC_CHECK_PROGS(MIDL, $target-widl widl)
383         if test -n "$MIDL"; then
384             case "$target" in
385             i*86-*)
386                 MIDL_FLAGS="$MIDL_FLAGS --win32 -m32"
387                 ;;
388             x86_64-*)
389                 MIDL_FLAGS="$MIDL_FLAGS --win64 -m64"
390                 ;;
391             esac
392         fi
394         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
395         # causing problems with local implementations with the same name.
396         AC_DEFINE(STRSAFE_NO_DEPRECATE)
397     fi # !GNU_CC
399     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
400     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
401     # Require OS features provided by IE 6.0 SP2 (XP SP2)
402     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0603)
404     ;;
405 esac
407 if test -n "$_WIN32_MSVC"; then
408     SKIP_PATH_CHECKS=1
409     SKIP_COMPILER_CHECKS=1
410     SKIP_LIBRARY_CHECKS=1
412     # Since we're skipping compiler and library checks, hard-code
413     # some facts here.
414     AC_DEFINE(HAVE_IO_H)
415     AC_DEFINE(HAVE_ISATTY)
418 fi # COMPILE_ENVIRONMENT
420 AC_SUBST(MIDL_FLAGS)
421 AC_SUBST(_MSC_VER)
423 AC_SUBST(GNU_AS)
424 AC_SUBST(GNU_CC)
425 AC_SUBST(GNU_CXX)
427 AC_SUBST(STL_FLAGS)
428 AC_SUBST(WRAP_STL_INCLUDES)
429 AC_SUBST(MOZ_MSVC_STL_WRAP_RAISE)
431 dnl ========================================================
432 dnl Checks for programs.
433 dnl ========================================================
434 if test "$COMPILE_ENVIRONMENT"; then
436 dnl ========================================================
437 dnl = Mac OS X toolchain support
438 dnl ========================================================
440 dnl The universal machinery sets UNIVERSAL_BINARY to inform packager.mk
441 dnl that a universal binary is being produced.
442 AC_SUBST(UNIVERSAL_BINARY)
444 MOZ_ARG_WITH_STRING(unify-dist,
445 [  --with-unify-dist=dir   Location of the dist directory to unify with at packaging time (Mac OS X universal build only)],
446     UNIFY_DIST=$withval)
447 if test -n "$UNIVERSAL_BINARY"; then
448     if test -z "$UNIFY_DIST"; then
449         AC_MSG_ERROR([You need to provide the --with-unify-dist=dir argument when performing a universal build])
450     fi
451     case "$UNIFY_DIST" in
452     /*)
453         ;;
454     *)
455         UNIFY_DIST="${MOZ_BUILD_ROOT}/${UNIFY_DIST}"
456         ;;
457     esac
459 AC_SUBST(UNIFY_DIST)
461 dnl ========================================================
462 dnl = Mac OS X SDK support
463 dnl ========================================================
464 MACOS_SDK_DIR=
465 MOZ_ARG_WITH_STRING(macos-sdk,
466 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
467     MACOS_SDK_DIR=$withval)
469 MACOS_PRIVATE_FRAMEWORKS_DIR_DEFAULTED=
470 MOZ_ARG_WITH_STRING(macos-private-frameworks,
471 [  --with-macos-private-frameworks=dir    Location of private frameworks to use (Mac OS X only)],
472     MACOS_PRIVATE_FRAMEWORKS_DIR=$withval,
473     MACOS_PRIVATE_FRAMEWORKS_DIR=/System/Library/PrivateFrameworks
474     MACOS_PRIVATE_FRAMEWORKS_DEFAULTED=1)
476 if test -z "${MACOS_PRIVATE_FRAMEWORKS_DEFAULTED}"; then
477   if test -z "$CROSS_COMPILE"; then
478     AC_MSG_WARN([You should only be using --with-macos-private-frameworks when cross-compiling.])
479   fi
480   if test ! -d "$MACOS_PRIVATE_FRAMEWORKS_DIR"; then
481     AC_MSG_ERROR([PrivateFrameworks directory not found.])
482   fi
485 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
486 AC_SUBST(MACOS_SDK_DIR)
487 AC_SUBST(MACOS_PRIVATE_FRAMEWORKS_DIR)
489 if test "$MACOS_SDK_DIR"; then
490   dnl Sync this section with the ones in NSPR and NSS.
491   dnl Changes to the cross environment here need to be accounted for in
492   dnl the libIDL checks (below) and xpidl build.
494   if test ! -d "$MACOS_SDK_DIR"; then
495     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
496 specify a valid SDK.  SDKs are installed when the optional cross-development
497 tools are selected during the Xcode/Developer Tools installation.])
498   fi
500   CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
501   CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
503   dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
504   CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
505   CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
507   AC_LANG_SAVE
508   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
509   AC_LANG_CPLUSPLUS
510   AC_TRY_COMPILE([#include <new>],[],
511    result=yes,
512    result=no)
513   AC_LANG_RESTORE
514   AC_MSG_RESULT($result)
516   if test "$result" = "no" ; then
517     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
518   fi
521 AC_PATH_XTRA
523 XCFLAGS="$X_CFLAGS"
525 fi # COMPILE_ENVIRONMENT
527 dnl ========================================================
528 dnl set the defaults first
529 dnl ========================================================
530 AS_BIN=$AS
531 AR_EXTRACT='$(AR) x'
532 AS='$(CC)'
533 AS_DASH_C_FLAG='-c'
534 DLL_PREFIX=lib
535 LIB_PREFIX=lib
536 DLL_SUFFIX=.so
537 OBJ_SUFFIX=o
538 LIB_SUFFIX=a
539 IMPORT_LIB_SUFFIX=
540 DIRENT_INO=d_ino
541 MOZ_USER_DIR=".mozilla"
543 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
545 MOZ_FS_LAYOUT=unix
547 dnl Configure platform-specific CPU architecture compiler options.
548 dnl ==============================================================
549 if test "$COMPILE_ENVIRONMENT"; then
550     MOZ_ARCH_OPTS
551 else
552     if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
553         dnl Default Android builds to ARMv7.
554         MOZ_ARCH=armv7-a
555     fi
556 fi # COMPILE_ENVIRONMENT
558 dnl ========================================================
559 dnl Android libstdc++, placed here so it can use MOZ_ARCH
560 dnl computed above.
561 dnl ========================================================
563 MOZ_ANDROID_CPU_ARCH
564 if test "$COMPILE_ENVIRONMENT"; then
565     MOZ_ANDROID_STLPORT
566 fi # COMPILE_ENVIRONMENT
568 dnl ========================================================
569 dnl Suppress Clang Argument Warnings
570 dnl ========================================================
571 if test -n "${CLANG_CC}${CLANG_CL}"; then
572     _WARNINGS_CFLAGS="-Qunused-arguments ${_WARNINGS_CFLAGS}"
573     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
575 if test -n "${CLANG_CXX}${CLANG_CL}"; then
576     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
579 if test -n "$COMPILE_ENVIRONMENT"; then
580    MOZ_CONFIG_SANITIZE
583 dnl ========================================================
584 dnl GNU specific defaults
585 dnl ========================================================
586 if test "$GNU_CC"; then
587     MMX_FLAGS="-mmmx"
588     SSE_FLAGS="-msse"
589     SSE2_FLAGS="-msse2"
590     SSSE3_FLAGS="-mssse3"
591     # FIXME: Let us build with strict aliasing. bug 414641.
592     CFLAGS="$CFLAGS -fno-strict-aliasing"
593     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@'
594     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@'
595     WARNINGS_AS_ERRORS='-Werror'
596     DSO_CFLAGS=''
597     DSO_PIC_CFLAGS='-fPIC'
598     ASFLAGS="$ASFLAGS -fPIC"
599     AC_MSG_CHECKING([for --noexecstack option to as])
600     _SAVE_CFLAGS=$CFLAGS
601     CFLAGS="$CFLAGS -Wa,--noexecstack"
602     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
603                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
604                      AC_MSG_RESULT([no]))
605     CFLAGS=$_SAVE_CFLAGS
606     AC_MSG_CHECKING([for -z noexecstack option to ld])
607     _SAVE_LDFLAGS=$LDFLAGS
608     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
609     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
610                   AC_MSG_RESULT([no])
611                   LDFLAGS=$_SAVE_LDFLAGS)
613     AC_MSG_CHECKING([for -z text option to ld])
614     _SAVE_LDFLAGS=$LDFLAGS
615     LDFLAGS="$LDFLAGS -Wl,-z,text"
616     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
617                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,text"],
618                   AC_MSG_RESULT([no])
619                   LDFLAGS=$_SAVE_LDFLAGS)
621     AC_MSG_CHECKING([for --build-id option to ld])
622     _SAVE_LDFLAGS=$LDFLAGS
623     LDFLAGS="$LDFLAGS -Wl,--build-id"
624     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
625                   [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,--build-id"],
626                   AC_MSG_RESULT([no])
627                   LDFLAGS=$_SAVE_LDFLAGS)
629     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
630     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
631     _SAVE_LDFLAGS=$LDFLAGS
632     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
633     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
634                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
635                   AC_MSG_RESULT([no]))
636     LDFLAGS=$_SAVE_LDFLAGS
638     # Check for -mssse3 on $CC
639     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
640     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
641     _SAVE_CFLAGS=$CFLAGS
642     CFLAGS="$CFLAGS -mssse3"
643     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
644                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
645                      AC_MSG_RESULT([no]))
646     CFLAGS=$_SAVE_CFLAGS
648     # Check for -msse4.1 on $CC
649     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
650     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
651     _SAVE_CFLAGS=$CFLAGS
652     CFLAGS="$CFLAGS -msse4.1"
653     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
654                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
655                      AC_MSG_RESULT([no]))
656     CFLAGS=$_SAVE_CFLAGS
658     case "${CPU_ARCH}" in
659     x86 | x86_64)
660       AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
661       AC_TRY_COMPILE([],
662                      [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
663                      result="yes", result="no")
664       AC_MSG_RESULT("$result")
665       if test "$result" = "yes"; then
666           HAVE_X86_AVX2=1
667       fi
668       ;;
670     ppc*)
671       AC_MSG_CHECKING([whether we can enable AltiVec support])
672       HAVE_ALTIVEC=
673       _SAVE_CFLAGS=$CFLAGS
674       CFLAGS="$CFLAGS -maltivec"
675       AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
676                        [HAVE_ALTIVEC=1],
677                        AC_MSG_RESULT([no]))
678       CFLAGS=$_SAVE_CFLAGS
679       ;;
680     esac
682     DSO_LDOPTS='-shared'
683     if test "$GCC_USE_GNU_LD"; then
684         # Some tools like ASan use a runtime library that is only
685         # linked against executables, so we must allow undefined
686         # symbols for shared objects in some cases.
687         if test -z "$MOZ_NO_WLZDEFS"; then
688             # Don't allow undefined symbols in libraries
689             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
691             # BSDs need `environ' exposed for posix_spawn (bug 753046)
692             case "$OS_TARGET" in
693             DragonFly|FreeBSD|NetBSD|OpenBSD)
694                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
695                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
696                 else
697                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
698                 fi
699                 ;;
700             esac
701         fi
702     fi
704     _DEFINES_CFLAGS='-include $(topobjdir)/mozilla-config.h -DMOZILLA_CLIENT'
705     _USE_CPP_INCLUDE_FLAG=1
707     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
710 if test "$GNU_CXX"; then
711     # FIXME: Let us build with strict aliasing. bug 414641.
712     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
714     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(topobjdir)/mozilla-config.h'
715     _USE_CPP_INCLUDE_FLAG=1
718 dnl ========================================================
719 dnl = Use Valgrind
720 dnl ========================================================
721 MOZ_ARG_ENABLE_BOOL(valgrind,
722 [  --enable-valgrind       Enable Valgrind integration hooks (default=no)],
723     MOZ_VALGRIND=1,
724     MOZ_VALGRIND= )
725 if test -n "$MOZ_VALGRIND"; then
726     MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
727         AC_MSG_ERROR(
728             [--enable-valgrind specified but Valgrind is not installed]))
729     AC_DEFINE(MOZ_VALGRIND)
731 AC_SUBST(MOZ_VALGRIND)
733 # For profiling builds keep the symbol information
734 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
735     case "$OS_TARGET" in
736     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
737         STRIP_FLAGS="--strip-debug"
738         ;;
739     esac
742 dnl ========================================================
743 dnl = Enable DMD
744 dnl ========================================================
746 if test "$MOZ_DMD"; then
747     if test "${CPU_ARCH}" = "arm"; then
748         CFLAGS="$CFLAGS -funwind-tables"
749         CXXFLAGS="$CXXFLAGS -funwind-tables"
750     fi
753 dnl ========================================================
754 dnl System overrides of the defaults for host
755 dnl ========================================================
756 case "$host" in
757 *mingw*)
758     if test -n "$_WIN32_MSVC"; then
759         HOST_AR=lib
760         HOST_AR_FLAGS='-NOLOGO -OUT:$@'
761         HOST_CFLAGS="$HOST_CFLAGS -TC -nologo"
762         HOST_RANLIB='echo ranlib'
763     else
764         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
765     fi
766     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
767     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
768     HOST_BIN_SUFFIX=.exe
770     case "${host_cpu}" in
771     i*86)
772         if test -n "$_WIN32_MSVC"; then
773             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
774         fi
775         ;;
776     x86_64)
777         if test -n "$_WIN32_MSVC"; then
778             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
779         fi
780         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
781         ;;
782     esac
783     ;;
785 *-darwin*)
786     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
787     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
788     ;;
790 *-linux*|*-kfreebsd*-gnu|*-gnu*)
791     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
792     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
793     ;;
796     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
797     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
798     ;;
799 esac
801 dnl ==============================================================
802 dnl Get mozilla version from central milestone file
803 dnl ==============================================================
804 MOZILLA_VERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir`
805 MOZILLA_UAVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --uaversion`
806 MOZILLA_SYMBOLVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --symbolversion`
807 if test -z "$MOZILLA_VERSION"; then
808   AC_MSG_ERROR([failed to read version info from milestone file])
811 dnl Get version of various core apps from the version files.
812 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
813 FIREFOX_VERSION_DISPLAY=`cat $_topsrcdir/browser/config/version_display.txt`
815 if test -z "$FIREFOX_VERSION"; then
816     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
819 if test -z "$FIREFOX_VERSION_DISPLAY"; then
820     AC_MSG_ERROR([FIREFOX_VERSION_DISPLAY is unexpectedly blank.])
823 AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
824 AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
825 AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
826 AC_SUBST(MOZILLA_SYMBOLVERSION)
828 MOZ_DOING_LTO(lto_is_enabled)
830 dnl ========================================================
831 dnl System overrides of the defaults for target
832 dnl ========================================================
834 case "$target" in
835 *-darwin*)
836     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
837     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@'
838     MOZ_OPTIMIZE_FLAGS="-O3"
839     CXXFLAGS="$CXXFLAGS -stdlib=libc++"
840     DLL_SUFFIX=".dylib"
841     DSO_LDOPTS=''
842     STRIP_FLAGS="$STRIP_FLAGS -x -S"
843     # Ensure that if we're targeting iOS an SDK was provided.
844     AC_CACHE_CHECK(for iOS target,
845                    ac_cv_ios_target,
846                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
847 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
848 #error not iOS
849 #endif],
850                                    [],
851                                    ac_cv_ios_target="yes",
852                                    ac_cv_ios_target="no")])
853     if test "$ac_cv_ios_target" = "yes" -a -z $MOZ_IOS; then
854        AC_MSG_ERROR([targeting iOS but not using an iOS SDK?])
855     fi
856     if test -n "$MOZ_IOS"; then
857         direct_nspr_config=1
858     else
859         # The ExceptionHandling framework is needed for Objective-C exception
860         # logging code in nsObjCExceptions.h. Currently we only use that in debug
861         # builds.
862         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
863     fi
865     if test "x$lto_is_enabled" = "xyes"; then
866         echo "Skipping -dead_strip because lto is enabled."
867     dnl DTrace and -dead_strip don't interact well. See bug 403132.
868     dnl ===================================================================
869     elif test "x$enable_dtrace" = "xyes"; then
870         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
871     else
872         dnl check for the presence of the -dead_strip linker flag
873         AC_MSG_CHECKING([for -dead_strip option to ld])
874         _SAVE_LDFLAGS=$LDFLAGS
875         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
876         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
877         if test -n "$_HAVE_DEAD_STRIP" ; then
878             AC_MSG_RESULT([yes])
879             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
880         else
881             AC_MSG_RESULT([no])
882         fi
884         LDFLAGS=$_SAVE_LDFLAGS
885     fi
887     MOZ_FIX_LINK_PATHS="-Wl,-executable_path,${DIST}/bin"
888     ;;
890 *-android*|*-linuxandroid*)
891     AC_DEFINE(NO_PW_GECOS)
892     if test -n "$gonkdir"; then
893         _PLATFORM_HAVE_RIL=1
894         MOZ_SYNTH_PICO=1
895     else
896         if test "$COMPILE_ENVIRONMENT"; then
897             MOZ_LINKER=1
898         fi
899     fi
901     MOZ_GFX_OPTIMIZE_MOBILE=1
902     MOZ_OPTIMIZE_FLAGS="-Os"
903     if test -z "$CLANG_CC"; then
904        MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions $MOZ_OPTIMIZE_FLAGS"
905     fi
906     ;;
908 *-*linux*)
909     if test "$GNU_CC" -o "$GNU_CXX"; then
910         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
911         MOZ_OPTIMIZE_FLAGS="-Os"
912         if test -z "$CLANG_CC"; then
913            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
914         fi
915     fi
917     case "${target_cpu}" in
918     alpha*)
919         CFLAGS="$CFLAGS -mieee"
920         CXXFLAGS="$CXXFLAGS -mieee"
921     ;;
922     esac
923     ;;
924 *-mingw*)
925     DSO_CFLAGS=
926     DSO_PIC_CFLAGS=
927     DLL_SUFFIX=.dll
928     RC=rc.exe
929     # certain versions of cygwin's makedepend barf on the
930     # #include <string> vs -I./dist/include/string issue so don't use it
931     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
932         CC="$CC -mwindows"
933         CXX="$CXX -mwindows"
934         CPP="$CPP -mwindows"
935         CFLAGS="$CFLAGS -mms-bitfields"
936         CXXFLAGS="$CXXFLAGS -mms-bitfields"
937         DSO_LDOPTS='-shared'
938         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
939         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
940         RC='$(WINDRES)'
941         # Use static libgcc and libstdc++
942         LDFLAGS="$LDFLAGS -static"
943         NSPR_LDFLAGS="$NSPR_LDFLAGS -static-libgcc"
944         # Use temp file for windres (bug 213281)
945         RCFLAGS='-O coff --use-temp-file'
946         # mingw doesn't require kernel32, user32, and advapi32 explicitly
947         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32"
948         MOZ_FIX_LINK_PATHS=
949         DLL_PREFIX=
950         IMPORT_LIB_SUFFIX=a
952         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
953         WIN32_GUI_EXE_LDFLAGS=-mwindows
955         # GCC/binutils can't link to a function if we try to include dllexport function
956         # in the same library as dllimport caller. To work around it, we build NSPR
957         # and NSS with -mnop-fun-dllimport flag. The drawback of this solution is that
958         # function thunks need to be generated for cross-DLL calls.
959         MOZ_FOLD_LIBS_FLAGS=-mnop-fun-dllimport
960     else
961         TARGET_COMPILER_ABI=msvc
962         if test "$AS_BIN"; then
963             AS="$(basename "$AS_BIN")"
964         fi
965         AR='lib'
966         AR_FLAGS='-NOLOGO -OUT:$@'
967         AR_EXTRACT=
968         RANLIB='echo not_ranlib'
969         STRIP='echo not_strip'
970         PKG_SKIP_STRIP=1
971         OBJ_SUFFIX=obj
972         LIB_SUFFIX=lib
973         DLL_PREFIX=
974         LIB_PREFIX=
975         IMPORT_LIB_SUFFIX=lib
976         MKSHLIB='$(LINK) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
977         MKCSHLIB='$(LINK) -NOLOGO -DLL -OUT:$@ -PDB:$(LINK_PDBFILE) $(DSO_LDOPTS)'
978         WIN32_SUBSYSTEM_VERSION=6.01
979         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
980         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
981         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
982         _USE_CPP_INCLUDE_FLAG=1
983         _DEFINES_CFLAGS='-FI $(topobjdir)/mozilla-config.h -DMOZILLA_CLIENT'
984         _DEFINES_CXXFLAGS='-FI $(topobjdir)/mozilla-config.h -DMOZILLA_CLIENT'
985         CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
986         CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
987         if test -z "$CLANG_CL"; then
988             CFLAGS="$CFLAGS -utf-8"
989             CXXFLAGS="$CXXFLAGS -utf-8"
990         fi
991         if test "$CPU_ARCH" = "x86"; then
992             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
993             dnl more recent, so set that explicitly here unless another
994             dnl target arch has already been set.
995             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
996               CFLAGS="$CFLAGS -arch:SSE2"
997             fi
998             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
999               CXXFLAGS="$CXXFLAGS -arch:SSE2"
1000             fi
1001             SSE_FLAGS="-arch:SSE"
1002             SSE2_FLAGS="-arch:SSE2"
1003             dnl MSVC allows the use of intrinsics without any flags
1004             dnl and doesn't have a separate arch for SSSE3
1005             SSSE3_FLAGS="-arch:SSE2"
1006         fi
1007         dnl clang-cl requires appropriate flags to enable SSSE3 support
1008         dnl on all architectures.
1009         if test -n "$CLANG_CL"; then
1010             SSSE3_FLAGS="-mssse3"
1011         fi
1012         dnl VS2013+ requires -FS when parallel building by make -jN.
1013         dnl If nothing, compiler sometimes causes C1041 error.
1014         CFLAGS="$CFLAGS -FS"
1015         CXXFLAGS="$CXXFLAGS -FS"
1016         dnl VS2013+ supports -Gw for better linker optimizations.
1017         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
1018         dnl Disabled on ASan because it causes false-positive ODR violations.
1019         if test -z "$MOZ_ASAN"; then
1020             CFLAGS="$CFLAGS -Gw"
1021             CXXFLAGS="$CXXFLAGS -Gw"
1022         fi
1023         # khuey says we can safely ignore MSVC warning C4251
1024         # MSVC warning C4244 (implicit type conversion may lose data) warns
1025         # and requires workarounds for perfectly valid code.  Also, GCC/clang
1026         # don't warn about it by default. So for consistency/sanity, we turn
1027         # it off on MSVC, too.
1028         # MSVC warning C4267 warns for narrowing type conversions from size_t
1029         # to 32-bit integer types on 64-bit platforms.  Since this is virtually
1030         # the same thing as C4244, we disable C4267, too.
1031         # MSVC warning C4800 warns when a value is implicitly cast to bool,
1032         # because this also forces narrowing to a single byte, which can be a
1033         # perf hit.  But this matters so little in practice (and often we want
1034         # that behavior) that it's better to turn it off.
1035         # MSVC warning C4595 warns non-member operator new or delete functions
1036         # may not be declared inline, as of VS2015 Update 2.
1037         CFLAGS="$CFLAGS -wd4244 -wd4267"
1038         CXXFLAGS="$CXXFLAGS -wd4251 -wd4244 -wd4267 -wd4800 -wd4595"
1039         if test -n "$CLANG_CL"; then
1040             # XXX We should combine some of these with our generic GCC-style
1041             # warning checks.
1042             #
1043             # Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
1044             CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
1045             # We use offsetof on non-POD objects all the time.
1046             # We also suppress this warning on other platforms.
1047             CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
1048             # MFBT thinks clang-cl supports constexpr, which it does, but
1049             # not everything in Windows C++ headers supports constexpr
1050             # as we might expect until MSVC 2015, so turn off this warning
1051             # for now.
1052             CXXFLAGS="$CXXFLAGS -Wno-invalid-constexpr"
1053             # This warns for reasonable things like:
1054             #   enum { X = 0xffffffffU };
1055             # which is annoying for IDL headers.
1056             CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
1057             # This warns for cases that would be reached by the Microsoft
1058             # #include rules, but also currently warns on cases that would
1059             # *also* be reached by standard C++ include rules.  That
1060             # behavior doesn't seem useful, so we turn it off.
1061             CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
1062             # We normally error out on unknown pragmas, but since clang-cl
1063             # claims to be MSVC, it would be difficult to add
1064             # #if defined(_MSC_VER) && !defined(__clang__) everywhere we
1065             # use such pragmas, so just ignore them.
1066             CFLAGS="$CFLAGS -Wno-unknown-pragmas"
1067             CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
1068             # We get errors about various #pragma intrinsic directives from
1069             # clang-cl, and we don't need to hear about those.
1070             CFLAGS="$CFLAGS -Wno-ignored-pragmas"
1071             CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
1072             # clang-cl's Intrin.h marks things like _ReadWriteBarrier
1073             # as __attribute((__deprecated__)).  This is nice to know,
1074             # but since we don't get the equivalent warning from MSVC,
1075             # let's just ignore it.
1076             CFLAGS="$CFLAGS -Wno-deprecated-declarations"
1077             CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
1078             # We use a function like:
1079             #   __declspec(noreturn) __inline void f() {}
1080             # which -Winvalid-noreturn complains about.  Again, MSVC seems
1081             # OK with it, so let's silence the warning.
1082             CFLAGS="$CFLAGS -Wno-invalid-noreturn"
1083             CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
1084             # Missing |override| on virtual function declarations isn't
1085             # something that MSVC currently warns about.
1086             CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
1087             # We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
1088             # declaration on |operator delete(void*)|.  However, clang-cl
1089             # must internally declare |operator delete(void*)| differently,
1090             # which causes this warning for virtually every file in the
1091             # tree.  clang-cl doesn't support -fno-exceptions or equivalent,
1092             # so there doesn't seem to be any way to convince clang-cl to
1093             # declare |delete| differently.  Therefore, suppress this
1094             # warning.
1095             CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
1096             # At least one MSVC header and several headers in-tree have
1097             # unused typedefs, so turn this on.
1098             CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
1099             # Several JS engine header files use __declspec(dllimport) on
1100             # classes, and clang-cl helpfully warns about its non-support
1101             # for such cases.  We're not particularly worried about that,
1102             # so ignore that warning.
1103             CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
1104         fi
1105         # make 'foo == bar;' error out
1106         CFLAGS="$CFLAGS -we4553"
1107         CXXFLAGS="$CXXFLAGS -we4553"
1108         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib"
1109         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
1110         WARNINGS_AS_ERRORS='-WX'
1111         MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
1112         MOZ_FIX_LINK_PATHS=
1113         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE -NXCOMPAT"
1114         if test -z "$DEVELOPER_OPTIONS"; then
1115             LDFLAGS="$LDFLAGS -RELEASE"
1116         fi
1117         dnl For profile-guided optimization
1118         PROFILE_GEN_CFLAGS="-GL"
1119         num_cores=$($PYTHON -c 'import multiprocessing; print(min(8,multiprocessing.cpu_count()))')
1120         cgthreads="-CGTHREADS:${num_cores}"
1121         PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT -PogoSafeMode $cgthreads"
1122         dnl XXX: PGO builds can fail with warnings treated as errors,
1123         dnl specifically "no profile data available" appears to be
1124         dnl treated as an error sometimes. This might be a consequence
1125         dnl of using WARNINGS_AS_ERRORS in some modules, combined
1126         dnl with the linker doing most of the work in the whole-program
1127         dnl optimization/PGO case. I think it's probably a compiler bug,
1128         dnl but we work around it here.
1129         PROFILE_USE_CFLAGS="-GL -wd4624 -wd4952"
1130         dnl XXX: should be -LTCG:PGOPTIMIZE, but that fails on libxul.
1131         dnl Probably also a compiler bug, but what can you do?
1132         PROFILE_USE_LDFLAGS="-LTCG:PGUPDATE $cgthreads"
1133         LDFLAGS="$LDFLAGS -DYNAMICBASE"
1134         RCFLAGS="-nologo"
1135         if test "$CC_VERSION" = "18.00.31101"; then
1136             dnl Use MaxILKSize as a workaround for LNK1248 in VS2013update4
1137             dnl See https://connect.microsoft.com/VisualStudio/feedback/details/1044914/fatal-error-lnk1248
1138             LDFLAGS="$LDFLAGS -MaxILKSize:0x7FF00000"
1139         fi
1140         dnl Minimum reqiurement of Gecko is VS2010 or later which supports
1141         dnl both SSSE3 and SSE4.1.
1142         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
1143         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
1144         dnl allow AVX2 code from VS2012
1145         HAVE_X86_AVX2=1
1146     fi
1147     AC_DEFINE(WIN32_LEAN_AND_MEAN)
1148     dnl See http://support.microsoft.com/kb/143208 to use STL
1149     AC_DEFINE(NOMINMAX)
1150     BIN_SUFFIX='.exe'
1151     MOZ_USER_DIR="Mozilla"
1153     case "$host_os" in
1154     cygwin*|msvc*|mks*)
1155         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.])
1156         ;;
1157     esac
1159     case "$target" in
1160     i*86-*)
1161         if test -n "$GNU_CC"; then
1162             CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
1163             CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"
1164             LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup -Wl,--large-address-aware"
1165         else
1166             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
1167             LDFLAGS="$LDFLAGS -SAFESEH"
1168         fi
1170         AC_DEFINE(_X86_)
1171         ;;
1172     x86_64-*)
1173         if test -n "$_WIN32_MSVC"; then
1174             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
1175         fi
1176         AC_DEFINE(_AMD64_)
1177         ;;
1178     *)
1179         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
1180         ;;
1181     esac
1182     ;;
1184 *-netbsd*)
1185     DSO_CFLAGS=''
1186     CFLAGS="$CFLAGS -Dunix"
1187     CXXFLAGS="$CXXFLAGS -Dunix"
1188     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
1189         DLL_SUFFIX=".so"
1190         DSO_PIC_CFLAGS='-fPIC -DPIC'
1191         DSO_LDOPTS='-shared'
1192         BIN_FLAGS='-Wl,--export-dynamic'
1193     else
1194         DSO_PIC_CFLAGS='-fPIC -DPIC'
1195         DLL_SUFFIX=".so.1.0"
1196         DSO_LDOPTS='-shared'
1197     fi
1198     # This will fail on a.out systems prior to 1.5.1_ALPHA.
1199     if test "$LIBRUNPATH"; then
1200         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
1201     fi
1202     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(DSO_SONAME) -o $@'
1203     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-soname,$(DSO_SONAME) -o $@'
1204     ;;
1206 *-openbsd*)
1207     if test "$SO_VERSION"; then
1208         DLL_SUFFIX=".so.$SO_VERSION"
1209     else
1210         DLL_SUFFIX=".so.1.0"
1211     fi
1212     if test -z "$X11BASE"; then
1213         X11BASE=/usr/X11R6
1214     fi
1215     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
1216     DSO_CFLAGS=''
1217     DSO_PIC_CFLAGS='-fPIC'
1218     DSO_LDOPTS='-shared -fPIC'
1219     if test "$LIBRUNPATH"; then
1220         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
1221     fi
1222     ;;
1224 esac
1226 AC_SUBST_LIST(MMX_FLAGS)
1227 AC_SUBST_LIST(SSE_FLAGS)
1228 AC_SUBST_LIST(SSE2_FLAGS)
1229 AC_SUBST_LIST(SSSE3_FLAGS)
1231 AC_SUBST(MOZ_LINKER)
1232 if test -n "$MOZ_LINKER"; then
1233   AC_DEFINE(MOZ_LINKER)
1234   MOZ_LINKER_EXTRACT=1
1235   AC_CHECK_PROGS(XZ, xz)
1238 dnl Only one oddball right now (QNX), but this gives us flexibility
1239 dnl if any other platforms need to override this in the future.
1240 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
1242 dnl ========================================================
1243 dnl = Flags to strip unused symbols from .so components and
1244 dnl = to export jemalloc symbols when linking a program
1245 dnl ========================================================
1246 case "$target" in
1247     *-linux*|*-kfreebsd*-gnu|*-gnu*)
1248         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
1249         ;;
1250     *-darwin*)
1251         MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,-exported_symbols_list -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-export-list'
1252         ;;
1253     *-mingw*)
1254         if test -n "$GNU_CC"; then
1255            MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
1256         fi
1257         ;;
1258 esac
1260 if test -z "$COMPILE_ENVIRONMENT"; then
1261     SKIP_COMPILER_CHECKS=1
1262     SKIP_LIBRARY_CHECKS=1
1263     PKG_SKIP_STRIP=1
1264     MOZ_DEBUGGING_OPTS
1265 else
1266     MOZ_COMPILER_OPTS
1267 fi # COMPILE_ENVIRONMENT
1269 if test -z "$SKIP_COMPILER_CHECKS"; then
1270 dnl Checks for typedefs, structures, and compiler characteristics.
1271 dnl ========================================================
1272 AC_C_CONST
1273 AC_TYPE_MODE_T
1274 AC_TYPE_OFF_T
1275 AC_TYPE_PID_T
1276 AC_TYPE_SIZE_T
1277 AC_LANG_CPLUSPLUS
1278 AC_LANG_C
1280 AC_LANG_CPLUSPLUS
1282 MOZ_CXX11
1284 AC_LANG_C
1286 case "${OS_TARGET}" in
1287 Darwin)
1288   ;;
1290   STL_FLAGS="-I${DIST}/stl_wrappers"
1291   WRAP_STL_INCLUDES=1
1292   ;;
1293 esac
1295 dnl Checks for header files.
1296 dnl ========================================================
1297 AC_HEADER_DIRENT
1298 case "$target_os" in
1299 bitrig*|dragonfly*|freebsd*|openbsd*)
1300 # for stuff like -lXshm
1301     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
1302     ;;
1303 esac
1305 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
1306 AC_CACHE_CHECK(for sockaddr_in.sin_len,
1307                    ac_cv_sockaddr_in_sin_len,
1308                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
1309                                     #include <sys/types.h>
1310                                     #endif
1311                                     #include <netinet/in.h>
1312                                     struct sockaddr_in x;
1313                                     void *foo = (void*) &x.sin_len;],
1314                                    [],
1315                                    [ac_cv_sockaddr_in_sin_len=true],
1316                                    [ac_cv_sockaddr_in_sin_len=false])])
1317 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
1318   AC_DEFINE(HAVE_SIN_LEN)
1319 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
1320   AC_DEFINE(HAVE_SCONN_LEN)
1323 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
1324                ac_cv_sockaddr_in6_sin6_len,
1325                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
1326                                 #include <sys/types.h>
1327                                 #endif
1328                                 #include <netinet/in.h>
1329                                 struct sockaddr_in6 x;
1330                                 void *foo = (void*) &x.sin6_len;],
1331                                [],
1332                                [ac_cv_sockaddr_in6_sin6_len=true],
1333                                [ac_cv_sockaddr_in6_sin6_len=false])])
1334 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
1335   AC_DEFINE(HAVE_SIN6_LEN)
1338 AC_CACHE_CHECK(for sockaddr.sa_len,
1339                ac_cv_sockaddr_sa_len,
1340                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
1341                                 #include <sys/types.h>
1342                                 #endif
1343                                 #include <sys/socket.h>
1344                                 struct sockaddr x;
1345                                 void *foo = (void*) &x.sa_len;],
1346                                [],
1347                                [ac_cv_sockaddr_sa_len=true],
1348                                [ac_cv_sockaddr_sa_len=false])])
1349 if test "$ac_cv_sockaddr_sa_len" = true ; then
1350   AC_DEFINE(HAVE_SA_LEN)
1353 MOZ_ARG_ENABLE_BOOL(dtrace,
1354               [  --enable-dtrace         build with dtrace support if available (default=no)],
1355               [enable_dtrace="yes"],)
1356 if test "x$enable_dtrace" = "xyes"; then
1357   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
1358   if test -n "$HAVE_DTRACE"; then
1359       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
1360   else
1361       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
1362   fi
1364 AC_SUBST(HAVE_DTRACE)
1366 dnl Checks for libraries.
1367 dnl ========================================================
1368 AC_CHECK_LIB(c_r, gethostbyname_r)
1370 dnl We don't want to link with libdl even if it's present on OS X, since
1371 dnl it's not used and not part of the default installation. OS/2 has dlfcn
1372 dnl in libc.
1373 dnl We don't want to link against libm or libpthread on Darwin since
1374 dnl they both are just symlinks to libSystem and explicitly linking
1375 dnl against libSystem causes issues when debugging (see bug 299601).
1376 case $target in
1377 *-darwin*)
1378     ;;
1380     AC_SEARCH_LIBS(dlopen, dl,
1381         MOZ_CHECK_HEADER(dlfcn.h,
1382         AC_DEFINE(HAVE_DLOPEN)))
1383     ;;
1384 esac
1386 _SAVE_CFLAGS="$CFLAGS"
1387 CFLAGS="$CFLAGS -D_GNU_SOURCE"
1388 AC_CHECK_FUNCS(dladdr memmem)
1389 CFLAGS="$_SAVE_CFLAGS"
1391 if test ! "$GNU_CXX"; then
1392     AC_CHECK_LIB(C, demangle)
1395 AC_CHECK_LIB(socket, socket)
1397 XLDFLAGS="$X_LIBS"
1398 XLIBS="$X_EXTRA_LIBS"
1400 dnl ========================================================
1401 dnl Checks for X libraries.
1402 dnl Ordering is important.
1403 dnl Xt is dependent upon SM as of X11R6
1404 dnl ========================================================
1405 if test -n "$MOZ_X11"; then
1406     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
1407     _SAVE_LDFLAGS="$LDFLAGS"
1408     _SAVE_LIBS="$LIBS"
1409     LDFLAGS="$XLDFLAGS $LDFLAGS"
1410     AC_CHECK_LIB(X11, XDrawLines, [XLIBS="-lX11 $XLIBS"],
1411         [MISSING_X="$MISSING_X -lX11"], $XLIBS)
1412     AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
1413         [MISSING_X="$MISSING_X -lXext"], $XLIBS)
1415     AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
1416         unset ac_cv_lib_Xt_XtFree
1417         AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
1418         AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
1419         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
1420             [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
1421         ])
1423     dnl ========================================================
1424     dnl = Check for xcb
1425     dnl ========================================================
1426     AC_CHECK_LIB(xcb, xcb_connect, [XLIBS="-lxcb $XLIBS"],
1427         [MISSING_X="$MISSING_X -lxcb"], $XLIBS)
1428     AC_CHECK_LIB(xcb-shm, xcb_shm_query_version, [XLIBS="-lxcb-shm $XLIBS"],
1429         [MISSING_X="$MISSING_X -lxcb-shm"], $XLIBS)
1430     AC_CHECK_LIB(X11-xcb, XGetXCBConnection, [XLIBS="-lX11-xcb $XLIBS"],
1431         [MISSING_X="$MISSING_X -lX11-xcb"], $XLIBS)
1433     dnl ========================================================
1434     dnl = Check for Xss
1435     dnl ========================================================
1436     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
1437         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
1438             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
1439              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
1441     LDFLAGS="$_SAVE_LDFLAGS"
1442     LIBS="$_SAVE_LIBS"
1443 fi # $MOZ_X11
1445 AC_SUBST_LIST(XCFLAGS)
1446 AC_SUBST_LIST(XLDFLAGS)
1447 AC_SUBST_LIST(XLIBS)
1448 AC_SUBST_LIST(XEXT_LIBS)
1449 AC_SUBST_LIST(XT_LIBS)
1450 AC_SUBST_LIST(XSS_LIBS)
1452 dnl ========================================================
1453 dnl = pthread support
1454 dnl = Start by checking whether the system support pthreads
1455 dnl ========================================================
1456 case "$target_os" in
1457 darwin*)
1458     MOZ_USE_PTHREADS=1
1459     ;;
1461     AC_CHECK_LIB(pthreads, pthread_create,
1462         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
1463         AC_CHECK_LIB(pthread, pthread_create,
1464             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
1465             AC_CHECK_LIB(c_r, pthread_create,
1466                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
1467                 AC_CHECK_LIB(c, pthread_create,
1468                     MOZ_USE_PTHREADS=1
1469                 )
1470             )
1471         )
1472     )
1473     ;;
1474 esac
1476 dnl ========================================================
1477 dnl Check the command line for --with-pthreads
1478 dnl ========================================================
1479 MOZ_ARG_WITH_BOOL(pthreads,
1480 [  --with-pthreads         Force use of system pthread library with NSPR ],
1481 [ if test "$MOZ_USE_PTHREADS"x = x; then
1482     AC_MSG_ERROR([ --with-pthreads specified for a system without pthread support ]);
1483 fi],
1484     MOZ_USE_PTHREADS=
1485     _PTHREAD_LDFLAGS=
1488 dnl ========================================================
1489 dnl Do the platform specific pthread hackery
1490 dnl ========================================================
1491 if test "$MOZ_USE_PTHREADS"x != x
1492 then
1493     dnl
1494     dnl See if -pthread is supported.
1495     dnl
1496     rm -f conftest*
1497     ac_cv_have_dash_pthread=no
1498     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
1499     echo 'int main() { return 0; }' | cat > conftest.c
1500     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
1501     if test $? -eq 0; then
1502         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1503             ac_cv_have_dash_pthread=yes
1504             case "$target_os" in
1505             freebsd*)
1506 # Freebsd doesn't use -pthread for compiles, it uses them for linking
1507                 ;;
1508             *)
1509                 CFLAGS="$CFLAGS -pthread"
1510                 CXXFLAGS="$CXXFLAGS -pthread"
1511                 ;;
1512             esac
1513         fi
1514     fi
1515     rm -f conftest*
1516     AC_MSG_RESULT($ac_cv_have_dash_pthread)
1518     dnl
1519     dnl See if -pthreads is supported.
1520     dnl
1521     ac_cv_have_dash_pthreads=no
1522     if test "$ac_cv_have_dash_pthread" = "no"; then
1523         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
1524         echo 'int main() { return 0; }' | cat > conftest.c
1525         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
1526         if test $? -eq 0; then
1527             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1528                 ac_cv_have_dash_pthreads=yes
1529                 CFLAGS="$CFLAGS -pthreads"
1530                 CXXFLAGS="$CXXFLAGS -pthreads"
1531             fi
1532         fi
1533         rm -f conftest*
1534         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
1535     fi
1537     case "$target" in
1538         *-*-freebsd*)
1539             AC_DEFINE(_REENTRANT)
1540             AC_DEFINE(_THREAD_SAFE)
1541             dnl -pthread links in -lpthread, so don't specify it explicitly.
1542             if test "$ac_cv_have_dash_pthread" = "yes"; then
1543                 _PTHREAD_LDFLAGS="-pthread"
1544             fi
1545             ;;
1547         *-*-openbsd*|*-*-bsdi*)
1548             AC_DEFINE(_REENTRANT)
1549             AC_DEFINE(_THREAD_SAFE)
1550             dnl -pthread links in -lc_r, so don't specify it explicitly.
1551             if test "$ac_cv_have_dash_pthread" = "yes"; then
1552                 _PTHREAD_LDFLAGS="-pthread"
1553             fi
1554             ;;
1556         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
1557             AC_DEFINE(_REENTRANT)
1558             ;;
1560     esac
1561     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
1562     AC_SUBST(MOZ_USE_PTHREADS)
1563     MOZ_CHECK_HEADERS(pthread.h)
1567 dnl Checks for library functions.
1568 dnl ========================================================
1569 AC_PROG_GCC_TRADITIONAL
1570 AC_FUNC_MEMCMP
1571 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall)
1573 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
1574 dnl avoid this on Darwin, since depending on your system config, we may think
1575 dnl it exists but it really doesn't
1576 case "$OS_TARGET" in
1577 Darwin)
1578   ;;
1580   AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
1581                  ac_cv_clock_monotonic,
1582                  [for libs in "" -lrt; do
1583                       _SAVE_LIBS="$LIBS"
1584                       LIBS="$LIBS $libs"
1585                       AC_TRY_LINK([#include <time.h>],
1586                                    [ struct timespec ts;
1587                                      clock_gettime(CLOCK_MONOTONIC, &ts); ],
1588                                    ac_cv_clock_monotonic=$libs
1589                                    LIBS="$_SAVE_LIBS"
1590                                    break,
1591                                    ac_cv_clock_monotonic=no)
1592                       LIBS="$_SAVE_LIBS"
1593                   done])
1594   if test "$ac_cv_clock_monotonic" != "no"; then
1595       HAVE_CLOCK_MONOTONIC=1
1596       REALTIME_LIBS=$ac_cv_clock_monotonic
1597       AC_DEFINE(HAVE_CLOCK_MONOTONIC)
1598       AC_SUBST(HAVE_CLOCK_MONOTONIC)
1599       AC_SUBST_LIST(REALTIME_LIBS)
1600   fi
1601   ;;
1602 esac
1604 AC_CACHE_CHECK(for pthread_cond_timedwait_monotonic_np,
1605                ac_cv_pthread_cond_timedwait_monotonic_np,
1606                AC_TRY_LINK([#include <pthread.h>],
1607                            [pthread_cond_timedwait_monotonic_np(0, 0, 0);],
1608                            ac_cv_pthread_cond_timewait_monotonic_np=yes,
1609                            ac_cv_pthread_cond_timewait_monotonic_np=no))
1610 if test "$ac_cv_pthread_cond_timewait_monotonic_np" != "no"; then
1611     AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
1614 dnl check for wcrtomb/mbrtowc
1615 dnl =======================================================================
1616 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
1617 AC_LANG_SAVE
1618 AC_LANG_CPLUSPLUS
1619 AC_CACHE_CHECK(for wcrtomb,
1620     ac_cv_have_wcrtomb,
1621     [AC_TRY_LINK([#include <wchar.h>],
1622                  [mbstate_t ps={0};wcrtomb(0,'f',&ps);],
1623                  ac_cv_have_wcrtomb="yes",
1624                  ac_cv_have_wcrtomb="no")])
1625 if test "$ac_cv_have_wcrtomb" = "yes"; then
1626     AC_DEFINE(HAVE_WCRTOMB)
1628 AC_CACHE_CHECK(for mbrtowc,
1629     ac_cv_have_mbrtowc,
1630     [AC_TRY_LINK([#include <wchar.h>],
1631                  [mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
1632                  ac_cv_have_mbrtowc="yes",
1633                  ac_cv_have_mbrtowc="no")])
1634 if test "$ac_cv_have_mbrtowc" = "yes"; then
1635     AC_DEFINE(HAVE_MBRTOWC)
1637 AC_LANG_RESTORE
1640 AC_CACHE_CHECK(
1641     [for res_ninit()],
1642     ac_cv_func_res_ninit,
1643     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
1644         dnl no need for res_ninit() on NetBSD and OpenBSD
1645         ac_cv_func_res_ninit=no
1646      else
1647         AC_TRY_LINK([
1648             #ifdef linux
1649             #define _BSD_SOURCE 1
1650             #endif
1651             #include <sys/types.h>
1652             #include <netinet/in.h>
1653             #include <arpa/nameser.h>
1654             #include <resolv.h>
1655             ],
1656             [int foo = res_ninit(&_res);],
1657             [ac_cv_func_res_ninit=yes],
1658             [ac_cv_func_res_ninit=no])
1659      fi
1660     ])
1662 if test "$ac_cv_func_res_ninit" = "yes"; then
1663     AC_DEFINE(HAVE_RES_NINIT)
1664 dnl must add the link line we do something as foolish as this... dougt
1665 dnl else
1666 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
1667 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
1670 AC_LANG_CPLUSPLUS
1672 ICONV_LIBS=
1674 case $target_os in
1675     darwin*|mingw*)
1676         ;;
1677     *)
1679 AC_CHECK_LIB(c, iconv, [ICONV_LIBS=],
1680     AC_CHECK_LIB(iconv, iconv, [ICONV_LIBS="-liconv"],
1681         AC_CHECK_LIB(iconv, libiconv, [ICONV_LIBS="-liconv"])))
1682 _SAVE_LIBS=$LIBS
1683 LIBS="$LIBS $ICONV_LIBS"
1684 AC_CACHE_CHECK(
1685     [for iconv()],
1686     ac_cv_func_iconv,
1687     [AC_TRY_LINK([
1688         #include <stdlib.h>
1689         #include <iconv.h>
1690         ],
1691         [
1692             iconv_t h = iconv_open("", "");
1693             iconv(h, NULL, NULL, NULL, NULL);
1694             iconv_close(h);
1695         ],
1696         [ac_cv_func_iconv=yes],
1697         [ac_cv_func_iconv=no]
1698         )]
1699     )
1700 if test "$ac_cv_func_iconv" = "yes"; then
1701     AC_DEFINE(HAVE_ICONV)
1702     LIBICONV="$ICONV_LIBS"
1703     AC_CACHE_CHECK(
1704         [for iconv() with const input],
1705         ac_cv_func_const_iconv,
1706         [AC_TRY_COMPILE([
1707             #include <stdlib.h>
1708             #include <iconv.h>
1709             ],
1710             [
1711                 const char *input = "testing";
1712                 iconv_t h = iconv_open("", "");
1713                 iconv(h, &input, NULL, NULL, NULL);
1714                 iconv_close(h);
1715             ],
1716             [ac_cv_func_const_iconv=yes],
1717             [ac_cv_func_const_iconv=no]
1718             )]
1719         )
1720     if test "$ac_cv_func_const_iconv" = "yes"; then
1721         AC_DEFINE(HAVE_ICONV_WITH_CONST_INPUT)
1722     fi
1724 LIBS=$_SAVE_LIBS
1726     ;;
1727 esac
1729 AC_SUBST_LIST(ICONV_LIBS)
1731 AM_LANGINFO_CODESET
1733 AC_LANG_C
1735 dnl **********************
1736 dnl *** va_copy checks ***
1737 AC_CACHE_CHECK([for an implementation of va_copy()],
1738                ac_cv_va_copy,
1739     [AC_TRY_COMPILE([#include <stdarg.h>
1740                      #include <stdlib.h>
1741         void f (int i, ...) {
1742             va_list args1, args2;
1743             va_start (args1, i);
1744             va_copy (args2, args1);
1745             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1746                 exit (1);
1747             va_end (args1); va_end (args2);
1748         }],
1749         [f(0, 42); return 0],
1750         [ac_cv_va_copy=yes],
1751         [ac_cv_va_copy=no]
1752     )]
1754 AC_CACHE_CHECK([whether va_list can be copied by value],
1755                ac_cv_va_val_copy,
1756     [AC_TRY_COMPILE([#include <stdarg.h>
1757                      #include <stdlib.h>
1758         void f (int i, ...) {
1759             va_list args1, args2;
1760             va_start (args1, i);
1761             args2 = args1;
1762             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1763                 exit (1);
1764             va_end (args1); va_end (args2);
1765         }],
1766         [f(0, 42); return 0],
1767         [ac_cv_va_val_copy=yes],
1768         [ac_cv_va_val_copy=no],
1769     )]
1771 if test "x$ac_cv_va_copy" = "xyes"; then
1772     AC_DEFINE(VA_COPY, va_copy)
1773     AC_DEFINE(HAVE_VA_COPY)
1776 if test "x$ac_cv_va_val_copy" = "xno"; then
1777    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
1780 dnl ===================================================================
1781 dnl ========================================================
1782 dnl Put your C++ language/feature checks below
1783 dnl ========================================================
1784 AC_LANG_CPLUSPLUS
1786 ARM_ABI_PREFIX=
1787 if test "$GNU_CC"; then
1788   if test "$CPU_ARCH" = "arm" ; then
1789     AC_CACHE_CHECK(for ARM EABI,
1790         ac_cv_gcc_arm_eabi,
1791         [AC_TRY_COMPILE([],
1792                         [
1793 #if defined(__ARM_EABI__)
1794   return 0;
1795 #else
1796 #error Not ARM EABI.
1797 #endif
1798                         ],
1799                         ac_cv_gcc_arm_eabi="yes",
1800                         ac_cv_gcc_arm_eabi="no")])
1801     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
1802         HAVE_ARM_EABI=1
1803         ARM_ABI_PREFIX=eabi-
1804     else
1805         ARM_ABI_PREFIX=oabi-
1806     fi
1807   fi
1809   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
1812 dnl Check to see if we can resolve ambiguity with |using|.
1813 AC_CACHE_CHECK(whether the C++ \"using\" keyword resolves ambiguity,
1814                ac_cv_cpp_ambiguity_resolving_using,
1815                [AC_TRY_COMPILE(class X {
1816                                  public: int go(const X&) {return 3;}
1817                                          int jo(const X&) {return 3;}
1818                                };
1819                                class Y : public X {
1820                                  public:  int go(int) {return 2;}
1821                                           int jo(int) {return 2;}
1822                                           using X::jo;
1823                                  private: using X::go;
1824                                };,
1825                                X x; Y y; y.jo(x);,
1826                                ac_cv_cpp_ambiguity_resolving_using=yes,
1827                                ac_cv_cpp_ambiguity_resolving_using=no)])
1828 if test "$ac_cv_cpp_ambiguity_resolving_using" = yes ; then
1829    AC_DEFINE(HAVE_CPP_AMBIGUITY_RESOLVING_USING)
1832 dnl See if a dynamic_cast to void* gives the most derived object.
1833 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
1834                ac_cv_cpp_dynamic_cast_void_ptr,
1835                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
1836                             class Y { int j; public: virtual ~Y() { } };
1837                             class Z : public X, public Y { int k; };
1839                             int main() {
1840                                  Z mdo;
1841                                  X *subx = (X*)&mdo;
1842                                  Y *suby = (Y*)&mdo;
1843                                  return !((((void*)&mdo != (void*)subx) &&
1844                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
1845                                           (((void*)&mdo != (void*)suby) &&
1846                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
1847                             }],
1848                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
1849                            ac_cv_cpp_dynamic_cast_void_ptr=no,
1850                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
1851 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
1852    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
1856 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
1857 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
1858 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
1859 # linking XUL.
1860 _SAVE_LDFLAGS=$LDFLAGS
1861 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
1862 AC_CACHE_CHECK(for __thread keyword for TLS variables,
1863                ac_cv_thread_keyword,
1864                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
1865                             [return tlsIsMainThread;],
1866                             ac_cv_thread_keyword=yes,
1867                             ac_cv_thread_keyword=no)])
1868 LDFLAGS=$_SAVE_LDFLAGS
1869 # The custom dynamic linker doesn't support TLS variables
1870 MOZ_TLS=
1871 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
1872   # mips builds fail with TLS variables because of a binutils bug.
1873   # See bug 528687
1874   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
1875   case "${target}" in
1876     mips*-*)
1877       :
1878       ;;
1879     *-android*|*-linuxandroid*)
1880       :
1881       ;;
1882     *-openbsd*)
1883       :
1884       ;;
1885     *)
1886       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
1887       MOZ_TLS=1
1888       ;;
1889   esac
1892 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
1893 if test -n "$MOZ_LINKER"; then
1894   if test "$CPU_ARCH" = arm; then
1895     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
1896     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
1897       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1898       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1899     fi
1900   fi
1902 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
1903 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
1904 dnl Since the linker only understands the sysv ones, no need to build the
1905 dnl gnu style tables anyways.
1906   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
1909 dnl The custom linker doesn't support text relocations, but NDK >= r6b
1910 dnl creates some (http://code.google.com/p/android/issues/detail?id=23203)
1911 dnl We however want to avoid these text relocations, and this can be done
1912 dnl by making gcc not link crtbegin and crtend. In the broken NDKs, crtend
1913 dnl doesn't contain anything at all, beside placeholders for some sections,
1914 dnl and crtbegin only contains a finalizer function that calls
1915 dnl __cxa_finalize. The custom linker actually takes care of calling
1916 dnl __cxa_finalize when the library doesn't call it itself, which makes it
1917 dnl safe not to link crtbegin. Besides, previous versions of the NDK didn't
1918 dnl link crtbegin and crtend at all.
1919 if test -n "$MOZ_LINKER" -a "$OS_TARGET" = "Android"; then
1920   AC_CACHE_CHECK([whether the CRT objects have text relocations],
1921     ac_cv_crt_has_text_relocations,
1922     [echo 'int foo() { return 0; }' > conftest.cpp
1923      if AC_TRY_COMMAND(${CXX-g++} -o conftest${DLL_SUFFIX} $CXXFLAGS $DSO_LDOPTS $LDFLAGS conftest.cpp $LIBS 1>&5) &&
1924         test -s conftest${DLL_SUFFIX}; then
1925        if ${TOOLCHAIN_PREFIX}readelf -d conftest${DLL_SUFFIX} | grep TEXTREL > /dev/null; then
1926          ac_cv_crt_has_text_relocations=yes
1927        else
1928          ac_cv_crt_has_text_relocations=no
1929        fi
1930      else
1931        AC_ERROR([couldn't compile a simple C file])
1932      fi
1933      rm -rf conftest*])
1934   if test "$ac_cv_crt_has_text_relocations" = yes; then
1935     dnl While we want libraries to skip the CRT files, we don't want
1936     dnl executables to be treated the same way. We thus set the flag
1937     dnl in DSO_LDOPTS and not LDFLAGS. However, to pass it to nspr,
1938     dnl we need to use LDFLAGS because nspr doesn't inherit DSO_LDOPTS.
1939     dnl Using LDFLAGS in nspr is safe, since we only really build
1940     dnl libraries there.
1941     DSO_LDOPTS="$DSO_LDOPTS -nostartfiles"
1942     NSPR_LDFLAGS="$NSPR_LDFLAGS -nostartfiles"
1943   fi
1946 dnl See if compiler supports some gcc-style attributes
1948 AC_CACHE_CHECK(for __attribute__((always_inline)),
1949                ac_cv_attribute_always_inline,
1950                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
1951                                [],
1952                                ac_cv_attribute_always_inline=yes,
1953                                ac_cv_attribute_always_inline=no)])
1955 dnl End of C++ language/feature checks
1956 AC_LANG_C
1958 dnl ========================================================
1959 dnl =  Internationalization checks
1960 dnl ========================================================
1962 dnl Internationalization and Locale support is different
1963 dnl on various UNIX platforms.  Checks for specific i18n
1964 dnl features go here.
1966 dnl check for LC_MESSAGES
1967 AC_CACHE_CHECK(for LC_MESSAGES,
1968                ac_cv_i18n_lc_messages,
1969                [AC_TRY_COMPILE([#include <locale.h>],
1970                                [int category = LC_MESSAGES;],
1971                                ac_cv_i18n_lc_messages=yes,
1972                                ac_cv_i18n_lc_messages=no)])
1973 if test "$ac_cv_i18n_lc_messages" = yes; then
1974    AC_DEFINE(HAVE_I18N_LC_MESSAGES)
1977 AC_HAVE_FUNCS(localeconv)
1979 fi # ! SKIP_COMPILER_CHECKS
1981 if test -n "${COMPILE_ENVIRONMENT}"; then
1982   MOZ_CHECK_ALLOCATOR
1985 TARGET_XPCOM_ABI=
1986 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1987     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1988     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
1991 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1992 dnl features that Windows actually does support.
1994 if test -n "$SKIP_COMPILER_CHECKS"; then
1995    dnl Windows has malloc.h
1996    AC_DEFINE(MALLOC_H, [<malloc.h>])
1997    AC_DEFINE(HAVE_FORCEINLINE)
1998    AC_DEFINE(HAVE_LOCALECONV)
1999 fi # SKIP_COMPILER_CHECKS
2001 dnl Mozilla specific options
2002 dnl ========================================================
2003 dnl The macros used for command line options
2004 dnl are defined in build/autoconf/altoptions.m4.
2006 dnl ========================================================
2007 dnl =
2008 dnl = Check for external package dependencies
2009 dnl =
2010 dnl ========================================================
2011 MOZ_ARG_HEADER(External Packages)
2013 case "$OS_TARGET" in
2014 WINNT|Darwin|Android)
2015   MOZ_FOLD_LIBS=1
2016   ;;
2018   MOZ_FOLD_LIBS=
2019   ;;
2020 esac
2022 MOZ_CONFIG_NSPR()
2024 dnl ========================================================
2025 dnl system libevent Support
2026 dnl ========================================================
2027 MOZ_ARG_WITH_STRING(system-libevent,
2028 [  --with-system-libevent[=PFX]
2029                           Use system libevent [installed at prefix PFX]],
2030     LIBEVENT_DIR=$withval)
2032 _SAVE_CFLAGS=$CFLAGS
2033 _SAVE_LDFLAGS=$LDFLAGS
2034 _SAVE_LIBS=$LIBS
2035 if test "$LIBEVENT_DIR" = yes; then
2036     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
2037         MOZ_SYSTEM_LIBEVENT=1,
2038         LIBEVENT_DIR=/usr)
2040 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
2041     MOZ_SYSTEM_LIBEVENT=
2042 elif test -z "$MOZ_SYSTEM_LIBEVENT"; then
2043     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
2044     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
2045     MOZ_CHECK_HEADER(event.h,
2046         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
2047              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
2048          fi],
2049         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
2050     AC_CHECK_LIB(event, event_init,
2051                  [MOZ_SYSTEM_LIBEVENT=1
2052                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
2053                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
2054                  [MOZ_SYSTEM_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
2056 CFLAGS=$_SAVE_CFLAGS
2057 LDFLAGS=$_SAVE_LDFLAGS
2058 LIBS=$_SAVE_LIBS
2060 AC_SUBST(MOZ_SYSTEM_LIBEVENT)
2062 dnl ========================================================
2063 dnl = If NSS was not detected in the system,
2064 dnl = use the one in the source tree (mozilla/security/nss)
2065 dnl ========================================================
2067 MOZ_ARG_WITH_BOOL(system-nss,
2068 [  --with-system-nss       Use system installed NSS],
2069     _USE_SYSTEM_NSS=1 )
2071 if test -n "$_USE_SYSTEM_NSS"; then
2072     AM_PATH_NSS(3.28, [MOZ_SYSTEM_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
2075 if test -n "$MOZ_SYSTEM_NSS"; then
2076    NSS_LIBS="$NSS_LIBS -lcrmf"
2077 else
2078    NSS_CFLAGS="-I${DIST}/include/nss"
2079    case "${OS_ARCH}" in
2080         # Only few platforms have been tested with GYP
2081         WINNT|Darwin|Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
2082             ;;
2083         *)
2084             AC_MSG_ERROR([building in-tree NSS is not supported on this platform. Use --with-system-nss])
2085             ;;
2086    esac
2089 if test -z "$SKIP_LIBRARY_CHECKS"; then
2090 dnl system JPEG support
2091 dnl ========================================================
2092 MOZ_ARG_WITH_STRING(system-jpeg,
2093 [  --with-system-jpeg[=PFX]
2094                           Use system libjpeg [installed at prefix PFX]],
2095     JPEG_DIR=$withval)
2097 _SAVE_CFLAGS=$CFLAGS
2098 _SAVE_LDFLAGS=$LDFLAGS
2099 _SAVE_LIBS=$LIBS
2100 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
2101     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
2102     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
2104 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
2105     MOZ_SYSTEM_JPEG=
2106 else
2107     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_SYSTEM_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_SYSTEM_JPEG=)
2110 if test "$MOZ_SYSTEM_JPEG" = 1; then
2111     AC_TRY_COMPILE([ #include <stdio.h>
2112                      #include <sys/types.h>
2113                      #include <jpeglib.h> ],
2114                    [ #if JPEG_LIB_VERSION < $MOZJPEG
2115                      #error "Insufficient JPEG library version ($MOZJPEG required)."
2116                      #endif
2117                      #ifndef JCS_EXTENSIONS
2118                      #error "libjpeg-turbo JCS_EXTENSIONS required"
2119                      #endif
2120                      ],
2121                    MOZ_SYSTEM_JPEG=1,
2122                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
2124 CFLAGS=$_SAVE_CFLAGS
2125 LDFLAGS=$_SAVE_LDFLAGS
2126 LIBS=$_SAVE_LIBS
2128 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_SYSTEM_JPEG" = 1; then
2129     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
2130     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
2132 fi # SKIP_LIBRARY_CHECKS
2134 dnl system ZLIB support
2135 dnl ========================================================
2136 MOZ_ZLIB_CHECK([1.2.3])
2138 if test "$MOZ_LINKER" = 1 -a "$MOZ_SYSTEM_ZLIB" != 1; then
2139     AC_MSG_ERROR([Custom dynamic linker requires --with-system-zlib])
2142 if test -z "$SKIP_LIBRARY_CHECKS"; then
2143 dnl system BZIP2 Support
2144 dnl ========================================================
2145 MOZ_ARG_WITH_STRING(system-bz2,
2146 [  --with-system-bz2[=PFX]
2147                           Use system libbz2 [installed at prefix PFX]],
2148     BZ2_DIR=$withval)
2150 _SAVE_CFLAGS=$CFLAGS
2151 _SAVE_LDFLAGS=$LDFLAGS
2152 _SAVE_LIBS=$LIBS
2153 if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
2154     CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
2155     LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
2157 if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
2158     MOZ_SYSTEM_BZ2=
2159 else
2160     AC_CHECK_LIB(bz2, BZ2_bzread, [MOZ_SYSTEM_BZ2=1 MOZ_BZ2_LIBS="-lbz2"],
2161     [MOZ_SYSTEM_BZ2= MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS=])
2163 CFLAGS=$_SAVE_CFLAGS
2164 LDFLAGS=$_SAVE_LDFLAGS
2165 LIBS=$_SAVE_LIBS
2167 if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$MOZ_SYSTEM_BZ2" = 1; then
2168     MOZ_BZ2_CFLAGS="-I${BZ2_DIR}/include"
2169     MOZ_BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
2172 dnl ========================================================
2173 dnl system PNG Support
2174 dnl ========================================================
2175 MOZ_ARG_WITH_STRING(system-png,
2176 [  --with-system-png[=PFX]
2177                           Use system libpng [installed at prefix PFX]],
2178     PNG_DIR=$withval)
2180 _SAVE_CFLAGS=$CFLAGS
2181 _SAVE_LDFLAGS=$LDFLAGS
2182 _SAVE_LIBS=$LIBS
2183 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
2184     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
2185     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
2187 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
2188     MOZ_SYSTEM_PNG=
2189 else
2190     AC_CHECK_LIB(png, png_get_valid, [MOZ_SYSTEM_PNG=1 MOZ_PNG_LIBS="-lpng"],
2191                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
2192     AC_CHECK_LIB(png, png_get_acTL, ,
2193                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
2195 if test "$MOZ_SYSTEM_PNG" = 1; then
2196     AC_TRY_COMPILE([ #include <stdio.h>
2197                      #include <sys/types.h>
2198                      #include <png.h> ],
2199                    [ #if PNG_LIBPNG_VER < $MOZPNG
2200                      #error "Insufficient libpng version ($MOZPNG required)."
2201                      #endif
2202                      #ifndef PNG_UINT_31_MAX
2203                      #error "Insufficient libpng version."
2204                      #endif ],
2205                    MOZ_SYSTEM_PNG=1,
2206                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
2208 CFLAGS=$_SAVE_CFLAGS
2209 LDFLAGS=$_SAVE_LDFLAGS
2210 LIBS=$_SAVE_LIBS
2212 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_SYSTEM_PNG" = 1; then
2213     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
2214     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
2217 fi # SKIP_LIBRARY_CHECKS
2219 dnl ========================================================
2220 dnl =
2221 dnl = Application
2222 dnl =
2223 dnl ========================================================
2225 MOZ_ARG_HEADER(Application)
2227 ENABLE_SYSTEM_EXTENSION_DIRS=1
2228 MOZ_BRANDING_DIRECTORY=
2229 MOZ_OFFICIAL_BRANDING=
2230 MOZ_FEEDS=1
2231 MOZ_AUTH_EXTENSION=1
2232 if test "$MOZ_IOS"; then
2233    MOZ_AUTH_EXTENSION=
2235 MOZ_RAW=
2236 MOZ_VORBIS=
2237 MOZ_TREMOR=
2238 MOZ_SAMPLE_TYPE_FLOAT32=
2239 MOZ_SAMPLE_TYPE_S16=
2240 MOZ_DIRECTSHOW=
2241 MOZ_WEBRTC=1
2242 MOZ_PEERCONNECTION=
2243 MOZ_SRTP=
2244 MOZ_WEBRTC_SIGNALING=
2245 MOZ_WEBRTC_ASSERT_ALWAYS=1
2246 MOZ_WEBRTC_HARDWARE_AEC_NS=
2247 MOZ_SCTP=
2248 MOZ_ANDROID_OMX=
2249 MOZ_OMX_PLUGIN=
2250 MOZ_VPX_ERROR_CONCEALMENT=
2251 VPX_USE_YASM=
2252 VPX_ASFLAGS=
2253 VPX_AS_CONVERSION=
2254 VPX_X86_ASM=
2255 VPX_ARM_ASM=
2256 LIBJPEG_TURBO_AS=
2257 LIBJPEG_TURBO_ASFLAGS=
2258 MOZ_PREF_EXTENSIONS=1
2259 MOZ_REFLOW_PERF=
2260 MOZ_SPELLCHECK=1
2261 MOZ_TOOLKIT_SEARCH=1
2262 MOZ_UI_LOCALE=en-US
2263 MOZ_UNIVERSALCHARDET=1
2264 MOZ_URL_CLASSIFIER=
2265 MOZ_XUL=1
2266 MOZ_ZIPWRITER=1
2267 MOZ_NO_SMART_CARDS=
2268 NECKO_COOKIES=1
2269 MOZ_USE_NATIVE_POPUP_WINDOWS=
2270 MOZ_EXCLUDE_HYPHENATION_DICTIONARIES=
2271 MOZ_INSTALL_TRACKING=
2272 ACCESSIBILITY=1
2273 MOZ_TIME_MANAGER=
2274 MOZ_AUDIO_CHANNEL_MANAGER=
2275 MOZ_CONTENT_SANDBOX=
2276 MOZ_GMP_SANDBOX=
2277 MOZ_SANDBOX=1
2278 MOZ_BINARY_EXTENSIONS=
2279 MOZ_DEVTOOLS=server
2281 case "$target_os" in
2282     mingw*)
2283         NS_ENABLE_TSF=1
2284         AC_DEFINE(NS_ENABLE_TSF)
2285         ;;
2286 esac
2288 case "${target}" in
2289     *-android*|*-linuxandroid*)
2290         MOZ_THEME_FASTSTRIPE=1
2291         MOZ_RAW=1
2292         ;;
2294 esac
2296 # Optional Firefox for Android partner distribution directory.
2297 MOZ_ARG_WITH_STRING(android-distribution-directory,
2298 [  --with-android-distribution-directory=dir
2299                           Optional Firefox for Android partner distribution directory.],
2300   MOZ_ANDROID_DISTRIBUTION_DIRECTORY=$withval)
2302 if test -n "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY"; then
2303   # A distribution directory must have an assets/distribution directory.
2304   # See https://wiki.mozilla.org/Mobile/Distribution_Files.
2305   if test ! -d "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY/assets/distribution" ; then
2306     AC_MSG_ERROR([--with-android-distribution-directory does not contain assets/distribution;
2307                   (looked for ${MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets/distribution).])
2308   fi
2310 AC_SUBST(MOZ_ANDROID_DISTRIBUTION_DIRECTORY)
2312 dnl ========================================================
2313 dnl = Trademarked Branding
2314 dnl ========================================================
2315 MOZ_ARG_ENABLE_BOOL(official-branding,
2316 [  --enable-official-branding
2317                           Enable Official mozilla.org Branding
2318                           Do not distribute builds with
2319                           --enable-official-branding unless you have
2320                           permission to use trademarks per
2321                           http://www.mozilla.org/foundation/trademarks/ .],
2322     MOZ_OFFICIAL_BRANDING=1,
2323     MOZ_OFFICIAL_BRANDING=)
2325 # Allow the application to influence configure with a confvars.sh script.
2326 AC_MSG_CHECKING([if app-specific confvars.sh exists])
2327 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
2328   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
2329   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
2330 else
2331   AC_MSG_RESULT([no])
2334 # Allow influencing configure with a defines.sh script.
2335 . "${srcdir}/build/defines.sh"
2337 # If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
2338 # set in defines.sh
2339 if test "$BUILDING_RELEASE"; then
2340   # Override value in defines.sh, if any
2341   EARLY_BETA_OR_EARLIER=
2342 elif test "$EARLY_BETA_OR_EARLIER"; then
2343   AC_DEFINE(EARLY_BETA_OR_EARLIER)
2345 AC_SUBST(EARLY_BETA_OR_EARLIER)
2347 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
2348 MOZ_ARG_WITH_STRING(app-name,
2349 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
2350 WITH_APP_NAME=$withval,
2353 if test -n "$WITH_APP_NAME" ; then
2354     MOZ_APP_NAME="$WITH_APP_NAME"
2357 MOZ_ARG_WITH_STRING(app-basename,
2358 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
2359 WITH_APP_BASENAME=$withval,
2362 if test -n "$WITH_APP_BASENAME" ; then
2363     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
2366 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
2367 # that haven't made a confvars.sh yet. Don't add new stuff here, use
2368 # MOZ_BUILD_APP.
2369 case "$MOZ_BUILD_APP" in
2370 browser)
2371   AC_DEFINE(MOZ_PHOENIX)
2372   ;;
2374 xulrunner)
2375   AC_DEFINE(MOZ_XULRUNNER)
2376   ;;
2377 esac
2379 if test -n "$MOZ_B2G"; then
2380     AC_DEFINE(MOZ_B2G)
2383 # Graphene is a desktop runtime for running applications with a HTML UI.
2384 if test -n "$MOZ_GRAPHENE"; then
2385     AC_DEFINE(MOZ_GRAPHENE)
2388 if test -n "$MOZ_MULET"; then
2389     AC_DEFINE(MOZ_MULET)
2392 # Propagate feature switches for code written in rust from confvars.sh
2393 if test -n "$MOZ_RUST"; then
2394     if test -n "$MOZ_RUST_MP4PARSE"; then
2395         AC_DEFINE(MOZ_RUST_MP4PARSE)
2396     fi
2397     if test -n "$MOZ_RUST_URLPARSE"; then
2398         AC_DEFINE(MOZ_RUST_URLPARSE)
2399         AC_SUBST(MOZ_RUST_URLPARSE)
2400     fi
2403 AC_SUBST(MOZ_PHOENIX)
2404 AC_SUBST(MOZ_XULRUNNER)
2405 AC_SUBST(MOZ_B2G)
2406 AC_SUBST(MOZ_MULET)
2407 AC_SUBST(MOZ_B2G_VERSION)
2409 dnl ========================================================
2410 dnl Ensure Android SDK and build-tools versions depending on
2411 dnl mobile target.
2412 dnl ========================================================
2414 if test -z "$gonkdir" ; then
2415     case "$MOZ_BUILD_APP" in
2416     mobile/android)
2417         MOZ_ANDROID_SDK(23, 23.0.3 23.0.1)
2418         ;;
2419     esac
2422 dnl ========================================================
2423 dnl =
2424 dnl = Toolkit Options
2425 dnl =
2426 dnl ========================================================
2427 MOZ_ARG_HEADER(Toolkit Options)
2429 dnl ========================================================
2430 dnl = Enable the toolkit as needed                         =
2431 dnl ========================================================
2433 case "$MOZ_WIDGET_TOOLKIT" in
2435 cocoa)
2436     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
2437     # Use -Wl as a trick to avoid -framework and framework names from
2438     # being separated by AC_SUBST_LIST.
2439     TK_LIBS='-Wl,-framework,CoreLocation -Wl,-framework,QuartzCore -Wl,-framework,Carbon -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,AddressBook -Wl,-framework,OpenGL -Wl,-framework,Security -Wl,-framework,ServiceManagement'
2440     TK_CFLAGS=""
2441     CFLAGS="$CFLAGS $TK_CFLAGS"
2442     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
2443     MOZ_USER_DIR="Mozilla"
2444     MOZ_FS_LAYOUT=bundle
2445     ;;
2447 uikit)
2448     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
2449     TK_CFLAGS=""
2450     TK_LIBS='-Wl,-framework,Foundation -Wl,-framework,CoreFoundation -Wl,-framework,CoreGraphics -Wl,-framework,CoreText -Wl,-framework,AVFoundation -Wl,-framework,AudioToolbox -Wl,-framework,CoreMedia -Wl,-framework,CoreVideo -Wl,-framework,OpenGLES -Wl,-framework,QuartzCore'
2451     CFLAGS="$CFLAGS $TK_CFLAGS"
2452     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
2453     MOZ_USER_DIR="Mozilla"
2454     MOZ_FS_LAYOUT=bundle
2455     ;;
2457 esac
2459 dnl there are a lot of tests on MOZ_ENABLE_GTK below, that are more convenient
2460 dnl to keep that way than testing against MOZ_WIDGET_TOOLKIT
2461 case "$MOZ_WIDGET_TOOLKIT" in
2462 gtk*)
2463     MOZ_ENABLE_GTK=1
2464     ;;
2465 esac
2467 if test "$COMPILE_ENVIRONMENT"; then
2468   if test "$MOZ_WIDGET_TOOLKIT" = gtk3; then
2469     PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
2470     MOZ_GTK3_CFLAGS="-I${_topsrcdir}/widget/gtk/compat-gtk3 $MOZ_GTK3_CFLAGS"
2471     TK_CFLAGS=$MOZ_GTK3_CFLAGS
2472     TK_LIBS=$MOZ_GTK3_LIBS
2473     dnl GDK_VERSION_MIN_REQUIRED is not set here as GDK3 deprecated warnings
2474     dnl are suppressed by widget/gtk/compat-gtk3/gdk/gdkversionmacros.h.
2475     AC_DEFINE_UNQUOTED(GDK_VERSION_MAX_ALLOWED,$GDK_VERSION_MAX_ALLOWED)
2476     GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32
2477   fi
2478   if test "$MOZ_WIDGET_TOOLKIT" = gtk2; then
2479     GLIB_VERSION_MAX_ALLOWED=$GLIB_VERSION_MIN_REQUIRED
2480   fi
2481   if test "$MOZ_ENABLE_GTK"; then
2482     if test "$MOZ_X11"; then
2483       GDK_PACKAGES=gdk-x11-2.0
2484     fi
2485     AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
2486     AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)
2488     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 >= $GLIB_VERSION gobject-2.0 $GDK_PACKAGES)
2489     MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
2490   fi
2491   if test "$MOZ_WIDGET_TOOLKIT" = gtk2; then
2492     TK_CFLAGS=$MOZ_GTK2_CFLAGS
2493     TK_LIBS=$MOZ_GTK2_LIBS
2494   fi
2495 fi # COMPILE_ENVIRONMENT
2497 AC_SUBST(MOZ_FS_LAYOUT)
2499 dnl ========================================================
2500 dnl = startup-notification support module
2501 dnl ========================================================
2503 if test "$MOZ_ENABLE_GTK"
2504 then
2505     MOZ_ENABLE_STARTUP_NOTIFICATION=
2507     MOZ_ARG_ENABLE_BOOL(startup-notification,
2508     [  --enable-startup-notification
2509                           Enable startup-notification support (default: disabled) ],
2510         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
2511         MOZ_ENABLE_STARTUP_NOTIFICATION=)
2512     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
2513     then
2514         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
2515                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
2516         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
2517             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
2518             then
2519                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
2520             fi
2521             MOZ_ENABLE_STARTUP_NOTIFICATION=
2522         ])
2523     fi
2525     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
2526         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
2527     fi
2529     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
2531 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
2533 AC_SUBST_LIST(TK_CFLAGS)
2534 AC_SUBST_LIST(TK_LIBS)
2536 AC_SUBST(MOC)
2537 AC_SUBST(RCC)
2539 dnl ========================================================
2540 dnl =
2541 dnl = Components & Features
2542 dnl =
2543 dnl ========================================================
2544 MOZ_ARG_HEADER(Components and Features)
2546 dnl ========================================================
2547 dnl = Localization
2548 dnl ========================================================
2549 MOZ_ARG_ENABLE_STRING(ui-locale,
2550 [  --enable-ui-locale=ab-CD
2551                           Select the user interface locale (default: en-US)],
2552     MOZ_UI_LOCALE=$enableval )
2553 AC_SUBST(MOZ_UI_LOCALE)
2555 AC_SUBST(MOZ_OFFICIAL_BRANDING)
2556 if test -n "$MOZ_OFFICIAL_BRANDING"; then
2557   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
2558     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
2559   else
2560     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
2561     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
2562   fi
2565 MOZ_ARG_WITH_STRING(branding,
2566 [  --with-branding=dir     Use branding from the specified directory.],
2567     MOZ_BRANDING_DIRECTORY=$withval)
2569 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
2570 if test -z "$REAL_BRANDING_DIRECTORY"; then
2571   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
2574 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
2575   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
2576 elif test -f "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
2577   . "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"
2580 AC_SUBST(MOZ_BRANDING_DIRECTORY)
2582 dnl ========================================================
2583 dnl = Distribution ID
2584 dnl ========================================================
2585 MOZ_ARG_WITH_STRING(distribution-id,
2586 [  --with-distribution-id=ID
2587                           Set distribution-specific id (default=org.mozilla)],
2588 [ val=`echo $withval`
2589     MOZ_DISTRIBUTION_ID="$val"])
2591 if test -z "$MOZ_DISTRIBUTION_ID"; then
2592    MOZ_DISTRIBUTION_ID="org.mozilla"
2595 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
2596 AC_SUBST(MOZ_DISTRIBUTION_ID)
2599 dnl ========================================================
2600 dnl Google Play Services, placed here so it can depend on
2601 dnl values set by configure.sh above.
2602 dnl ========================================================
2604 MOZ_ANDROID_GOOGLE_PLAY_SERVICES
2605 MOZ_ANDROID_GOOGLE_CLOUD_MESSAGING
2606 MOZ_ANDROID_INSTALL_TRACKING
2609 dnl ========================================================
2610 dnl = GIO and GConf support module
2611 dnl ========================================================
2613 if test "$MOZ_X11"
2614 then
2615     dnl build the GIO extension by default only when the
2616     dnl GTK2 toolkit is in use.
2617     if test "$MOZ_ENABLE_GTK"
2618     then
2619         MOZ_ENABLE_GIO=1
2620         MOZ_ENABLE_GCONF=1
2621     fi
2623     dnl ========================================================
2624     dnl = GIO support module
2625     dnl ========================================================
2626     MOZ_ARG_DISABLE_BOOL(gio,
2627     [  --disable-gio           Disable GIO support],
2628         MOZ_ENABLE_GIO=,
2629         MOZ_ENABLE_GIO=force)
2631     if test "$MOZ_ENABLE_GIO" -a "$MOZ_ENABLE_GTK"
2632     then
2633         if test "$MOZ_WIDGET_TOOLKIT" = gtk2
2634         then
2635             PKG_CHECK_MODULES(_GTKCHECK, gtk+-2.0 >= 2.14, ,
2636                               [AC_MSG_ERROR([* * * Could not find gtk+-2.0 > 2.14. Required for build with gio.])])
2637         fi
2638         PKG_CHECK_MODULES(MOZ_GIO, gio-2.0 >= $GIO_VERSION,[
2639             MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
2640             MOZ_ENABLE_GIO=1
2641             AC_DEFINE(MOZ_ENABLE_GIO)
2642         ],[
2643             if test "$MOZ_ENABLE_GIO" = "force"
2644             then
2645                 AC_MSG_ERROR([* * * Could not find gio-2.0 >= $GIO_VERSION])
2646             fi
2647             MOZ_ENABLE_GIO=
2648         ])
2649     fi
2651     AC_SUBST(MOZ_ENABLE_GIO)
2653     dnl ========================================================
2654     dnl = GConf support module
2655     dnl ========================================================
2656     MOZ_ARG_DISABLE_BOOL(gconf,
2657     [  --disable-gconf      Disable Gconf support ],
2658         MOZ_ENABLE_GCONF=,
2659         MOZ_ENABLE_GCONF=1)
2661     if test "$MOZ_ENABLE_GCONF"
2662     then
2663         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
2664             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
2665             MOZ_ENABLE_GCONF=1
2666         ],[
2667             if test -n "$MOZ_ENABLE_GCONF";
2668             then
2669                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
2670             else
2671                 AC_MSG_WARN([Many automated tests will fail with --disable-gconf. See bug 1167201.])
2672             fi
2673         ])
2674     fi
2676     if test "$MOZ_ENABLE_GCONF"; then
2677         AC_DEFINE(MOZ_ENABLE_GCONF)
2678     fi
2680     AC_SUBST(MOZ_ENABLE_GCONF)
2683 dnl ========================================================
2684 dnl = libproxy support
2685 dnl ========================================================
2687 if test "$MOZ_ENABLE_GTK"
2688 then
2689     MOZ_ENABLE_LIBPROXY=
2691     MOZ_ARG_ENABLE_BOOL(libproxy,
2692     [  --enable-libproxy         Enable libproxy support ],
2693     MOZ_ENABLE_LIBPROXY=1,
2694     MOZ_ENABLE_LIBPROXY=)
2696     if test "$MOZ_ENABLE_LIBPROXY"
2697     then
2698         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
2699         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
2700     fi
2702 AC_SUBST(MOZ_ENABLE_LIBPROXY)
2704 dnl ========================================================
2705 dnl = libgnomeui support module
2706 dnl ========================================================
2708 if test "$MOZ_ENABLE_GTK"
2709 then
2710     MOZ_ARG_ENABLE_BOOL(gnomeui,
2711     [  --enable-gnomeui        Enable libgnomeui instead of GIO & GTK for icon theme support ],
2712         MOZ_ENABLE_GNOMEUI=force,
2713         MOZ_ENABLE_GNOMEUI=)
2715     if test "$MOZ_ENABLE_GNOMEUI"
2716     then
2717         PKG_CHECK_MODULES(MOZ_GNOMEUI, libgnomeui-2.0 >= $GNOMEUI_VERSION,
2718         [
2719             MOZ_ENABLE_GNOMEUI=1
2720         ],[
2721             if test "$MOZ_ENABLE_GNOMEUI" = "force"
2722             then
2723                 AC_MSG_ERROR([* * * Could not find libgnomeui-2.0 >= $GNOMEUI_VERSION])
2724             fi
2725             MOZ_ENABLE_GNOMEUI=
2726         ])
2727     fi
2729     if test "$MOZ_ENABLE_GNOMEUI"; then
2730         AC_DEFINE(MOZ_ENABLE_GNOMEUI)
2731     fi
2734 AC_SUBST(MOZ_ENABLE_GNOMEUI)
2736 dnl ========================================================
2737 dnl = dbus support
2738 dnl ========================================================
2740 if test "$MOZ_ENABLE_GTK"
2741 then
2742     MOZ_ENABLE_DBUS=1
2744     MOZ_ARG_DISABLE_BOOL(dbus,
2745     [  --disable-dbus          Disable dbus support ],
2746         MOZ_ENABLE_DBUS=,
2747         MOZ_ENABLE_DBUS=1)
2749     if test "$MOZ_ENABLE_DBUS"
2750     then
2751         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
2752         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
2753         AC_DEFINE(MOZ_ENABLE_DBUS)
2754     fi
2756 AC_SUBST(MOZ_ENABLE_DBUS)
2758 dnl =========================================================
2759 dnl = Whether to exclude hyphenations files in the build
2760 dnl =========================================================
2761 if test -n "$MOZ_EXCLUDE_HYPHENATION_DICTIONARIES"; then
2762     AC_DEFINE(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
2765 dnl ========================================================
2766 dnl = Include install tracking on Android
2767 dnl ========================================================
2768 if test -n "$MOZ_INSTALL_TRACKING"; then
2769     if test -z "$MOZ_ADJUST_SDK_KEY"; then
2770         AC_MSG_ERROR([Must specify --with-adjust-sdk-keyfile when MOZ_INSTALL_TRACKING is defined!])
2771     fi
2774 dnl ========================================================
2775 dnl accessibility support on by default on all platforms
2776 dnl ========================================================
2777 MOZ_ARG_DISABLE_BOOL(accessibility,
2778 [  --disable-accessibility Disable accessibility support],
2779     ACCESSIBILITY=,
2780     ACCESSIBILITY=1 )
2781 if test "$ACCESSIBILITY"; then
2782     case "$target" in
2783     *-mingw*)
2784         if test -z "$MIDL"; then
2785             if test "$GCC" != "yes"; then
2786                 AC_MSG_ERROR([MIDL could not be found. Building accessibility without MIDL is not supported.])
2787             else
2788                 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.])
2789             fi
2790         fi
2791     esac
2792     AC_DEFINE(ACCESSIBILITY)
2795 dnl ========================================================
2796 dnl Accessibility is required for the linuxgl widget
2797 dnl backend
2798 dnl ========================================================
2799 if test "${MOZ_WIDGET_TOOLKIT}" = "linuxgl" -a "$ACCESSIBILITY" != "1"; then
2800     AC_MSG_ERROR(["Accessibility is required for the linuxgl widget backend"])
2803 dnl Turn off webrtc for OS's we don't handle yet, but allow
2804 dnl --enable-webrtc to override.  Can disable for everything in
2805 dnl the master list above.
2806 if test -n "$MOZ_WEBRTC"; then
2807     case "$target" in
2808     *-linux*|*-mingw*|*-darwin*|*-android*|*-linuxandroid*|*-dragonfly*|*-freebsd*|*-netbsd*|*-openbsd*)
2809         dnl Leave enabled
2810         ;;
2811     *)
2812         dnl default to disabled for all others
2813         MOZ_WEBRTC=
2814         ;;
2815     esac
2818 AC_TRY_COMPILE([#include <linux/ethtool.h>],
2819                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
2820                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
2822 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
2824 # target_arch is from {ia32|x64|arm|ppc}
2825 case "$CPU_ARCH" in
2826 x86_64 | arm | aarch64 | x86 | ppc* | ia64)
2827     :
2828     ;;
2830 # unsupported arch for webrtc
2831     MOZ_WEBRTC=
2832     ;;
2834 esac
2836 dnl ========================================================
2837 dnl = Disable WebRTC code
2838 dnl ========================================================
2839 MOZ_ARG_DISABLE_BOOL(webrtc,
2840 [  --disable-webrtc        Disable support for WebRTC],
2841     MOZ_WEBRTC=,
2842     MOZ_WEBRTC=1)
2844 if test -n "$MOZ_WEBRTC"; then
2845     AC_DEFINE(MOZ_WEBRTC)
2846     dnl MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
2847     dnl opt/production builds (via MOZ_CRASH())
2848     AC_DEFINE(MOZ_WEBRTC_ASSERT_ALWAYS)
2849     MOZ_RAW=1
2850     MOZ_VPX_ERROR_CONCEALMENT=1
2852 dnl enable once Signaling lands
2853     MOZ_WEBRTC_SIGNALING=1
2854     AC_DEFINE(MOZ_WEBRTC_SIGNALING)
2855 dnl enable once PeerConnection lands
2856     MOZ_PEERCONNECTION=1
2857     AC_DEFINE(MOZ_PEERCONNECTION)
2858     MOZ_SCTP=1
2859     MOZ_SRTP=1
2860     AC_DEFINE(MOZ_SCTP)
2861     AC_DEFINE(MOZ_SRTP)
2862     if test -n "$MOZ_X11"; then
2863       MOZ_WEBRTC_X11_LIBS="-lXext -lXdamage -lXfixes -lXcomposite"
2864     fi
2865 else
2866     MOZ_SYNTH_PICO=
2869 dnl ========================================================
2870 dnl = Force hardware AEC, disable webrtc.org AEC
2871 dnl ========================================================
2872 MOZ_ARG_ENABLE_BOOL(hardware-aec-ns,
2873 [  --enable-hardware-aec-ns   Enable support for hardware AEC and noise suppression],
2874     MOZ_WEBRTC_HARDWARE_AEC_NS=1,
2875     MOZ_WEBRTC_HARDWARE_AEC_NS=)
2877 if test -n "$MOZ_WEBRTC_HARDWARE_AEC_NS"; then
2878     AC_DEFINE(MOZ_WEBRTC_HARDWARE_AEC_NS)
2881 AC_SUBST(MOZ_WEBRTC)
2882 AC_SUBST(MOZ_WEBRTC_SIGNALING)
2883 AC_SUBST(MOZ_PEERCONNECTION)
2884 AC_SUBST(MOZ_WEBRTC_ASSERT_ALWAYS)
2885 AC_SUBST(MOZ_WEBRTC_HARDWARE_AEC_NS)
2886 AC_SUBST(MOZ_SCTP)
2887 AC_SUBST(MOZ_SRTP)
2888 AC_SUBST_LIST(MOZ_WEBRTC_X11_LIBS)
2890 dnl Use integers over floats for audio on B2G and Android
2891 dnl (regarless of the CPU architecture, because audio
2892 dnl backends for those platforms don't support floats. We also
2893 dnl use integers on ARM with other OS, because it's more efficient.
2894 if test "$OS_TARGET" = "Android" -o "$CPU_ARCH" = "arm"; then
2895     MOZ_SAMPLE_TYPE_S16=1
2896     AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
2897     AC_SUBST(MOZ_SAMPLE_TYPE_S16)
2898 else
2899     MOZ_SAMPLE_TYPE_FLOAT32=1
2900     AC_DEFINE(MOZ_SAMPLE_TYPE_FLOAT32)
2901     AC_SUBST(MOZ_SAMPLE_TYPE_FLOAT32)
2904 dnl ========================================================
2905 dnl = Enable Raw Codecs
2906 dnl ========================================================
2907 MOZ_ARG_ENABLE_BOOL(raw,
2908 [  --enable-raw           Enable support for RAW media],
2909     MOZ_RAW=1,
2910     MOZ_RAW=)
2912 if test -n "$MOZ_RAW"; then
2913     AC_DEFINE(MOZ_RAW)
2916 AC_SUBST(MOZ_RAW)
2918 dnl ========================================================
2919 dnl = Apple platform decoder support
2920 dnl ========================================================
2921 if test "$COMPILE_ENVIRONMENT"; then
2922 if test -n "$MOZ_APPLEMEDIA"; then
2923   # hack in frameworks for fmp4 - see bug 1029974
2924   # We load VideoToolbox and CoreMedia dynamically, so they don't appear here.
2925   LDFLAGS="$LDFLAGS -framework AudioToolbox"
2926   dnl Verify CoreMedia is available.
2927   AC_CHECK_HEADER([CoreMedia/CoreMedia.h], [],
2928     [AC_MSG_ERROR([MacOS X 10.7 SDK or later is required])])
2930 fi # COMPILE_ENVIRONMENT
2932 dnl ========================================================
2933 dnl = DirectShow support
2934 dnl ========================================================
2935 if test "$OS_ARCH" = "WINNT"; then
2936     dnl Enable DirectShow support by default.
2937     MOZ_DIRECTSHOW=1
2940 MOZ_ARG_DISABLE_BOOL(directshow,
2941 [  --disable-directshow  Disable support for DirectShow],
2942     MOZ_DIRECTSHOW=,
2943     MOZ_DIRECTSHOW=1)
2945 if test -n "$MOZ_DIRECTSHOW"; then
2946     AC_DEFINE(MOZ_DIRECTSHOW)
2949 dnl ========================================================
2950 dnl = Built-in fragmented MP4 support.
2951 dnl ========================================================
2953 if test x"$MOZ_WIDGET_TOOLKIT" = x"gonk" -a -n "$MOZ_FMP4" -a -n "$android_version"; then
2954     # we now know for sure that $android_version is not an empty string!
2955     if test "$android_version" -ge "18"; then
2956         MOZ_GONK_MEDIACODEC=1
2957         AC_SUBST(MOZ_GONK_MEDIACODEC)
2958     fi
2962 dnl ========================================================
2963 dnl = Enable media plugin support
2964 dnl ========================================================
2965 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
2966   dnl Enable support on android by default
2967   MOZ_ANDROID_OMX=1
2970 MOZ_ARG_ENABLE_BOOL(android-omx,
2971 [  --enable-android-omx  Enable support for Android OMX media backend],
2972     MOZ_ANDROID_OMX=1,
2973     MOZ_ANDROID_OMX=)
2975 if test -n "$MOZ_ANDROID_OMX"; then
2976   AC_DEFINE(MOZ_ANDROID_OMX)
2979 dnl ========================================================
2980 dnl = Enable building OMX media plugin (B2G or Android)
2981 dnl ========================================================
2982 if test "$OS_TARGET" = Android -a x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
2983   dnl Enable support on android by default
2984   MOZ_OMX_PLUGIN=1
2987 MOZ_ARG_ENABLE_BOOL(omx-plugin,
2988 [  --enable-omx-plugin      Enable building OMX plugin (B2G)],
2989     MOZ_OMX_PLUGIN=1,
2990     MOZ_OMX_PLUGIN=)
2992 if test -n "$MOZ_OMX_PLUGIN"; then
2993     if test "$OS_TARGET" = "Android"; then
2994         dnl Only allow building OMX plugin on Gonk (B2G) or Android
2995         AC_DEFINE(MOZ_OMX_PLUGIN)
2996     else
2997         dnl fail if we're not building on Gonk or Android
2998         AC_MSG_ERROR([OMX media plugin can only be built on B2G or Android])
2999     fi
3002 dnl system libvpx Support
3003 dnl ========================================================
3004 MOZ_ARG_WITH_BOOL(system-libvpx,
3005 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
3006     MOZ_SYSTEM_LIBVPX=1)
3008 MOZ_LIBVPX_CFLAGS=
3009 MOZ_LIBVPX_LIBS=
3011 if test -n "$MOZ_VPX_ERROR_CONCEALMENT" ; then
3012     AC_DEFINE(MOZ_VPX_ERROR_CONCEALMENT)
3015 _SAVE_CFLAGS=$CFLAGS
3016 _SAVE_LIBS=$LIBS
3017 if test -n "$MOZ_SYSTEM_LIBVPX"; then
3018     dnl ============================
3019     dnl === libvpx Version check ===
3020     dnl ============================
3021     dnl Check to see if we have a system libvpx package.
3022     PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.5.0)
3024     CFLAGS="$CFLAGS $MOZ_LIBVPX_CFLAGS"
3025     LIBS="$LIBS $MOZ_LIBVPX_LIBS"
3027     MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [],
3028      [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.])])
3030     AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [],
3031      [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
3033     MOZ_CHECK_HEADER([vpx_mem/vpx_mem.h],
3034      [AC_CHECK_FUNC(vpx_mem_set_functions)])
3035     if test "$ac_cv_header_vpx_mem_vpx_mem_h" = no -o \
3036             "$ac_cv_func_vpx_mem_set_functions" = no; then
3037         AC_DEFINE(MOZ_VPX_NO_MEM_REPORTING)
3038     fi
3040 CFLAGS=$_SAVE_CFLAGS
3041 LIBS=$_SAVE_LIBS
3043 AC_SUBST(MOZ_SYSTEM_LIBVPX)
3044 AC_SUBST_LIST(MOZ_LIBVPX_CFLAGS)
3045 AC_SUBST_LIST(MOZ_LIBVPX_LIBS)
3047 if test "$MOZ_SAMPLE_TYPE_FLOAT32"; then
3048     MOZ_VORBIS=1
3049 else
3050     MOZ_TREMOR=1
3053 if test -z "$MOZ_SYSTEM_LIBVPX"; then
3055     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
3056     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
3057     dnl We currently require gcc on all arm platforms.
3059     dnl See if we have assembly on this platform.
3060     case "$OS_ARCH:$CPU_ARCH" in
3061     Darwin:x86)
3062       VPX_USE_YASM=1
3063       VPX_X86_ASM=1
3064     ;;
3065     Darwin:x86_64)
3066       VPX_USE_YASM=1
3067       VPX_X86_ASM=1
3068     ;;
3069     WINNT:x86_64)
3070       VPX_USE_YASM=1
3071       VPX_X86_ASM=1
3072     ;;
3073     WINNT:x86)
3074       dnl Check for yasm 1.1 or greater.
3075       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
3076         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.])
3077       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
3078         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.])
3079       else
3080         VPX_USE_YASM=1
3081         VPX_X86_ASM=1
3082         dnl The encoder needs obj_int_extract to get asm offsets.
3083       fi # COMPILE_ENVIRONMENT and others
3084     ;;
3085     *:arm*)
3086       if test -n "$GNU_AS" ; then
3087         dnl These flags are a lie; they're just used to enable the requisite
3088         dnl opcodes; actual arch detection is done at runtime.
3089         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
3090         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/build/make/ads2gas.pl'
3091         VPX_ARM_ASM=1
3092         dnl Building with -mfpu=neon requires either the "softfp" or the
3093         dnl "hardfp" ABI. Depending on the compiler's default target, and the
3094         dnl CFLAGS, the default ABI might be neither, in which case it is the
3095         dnl "softfloat" ABI.
3096         dnl The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
3097         dnl we can safely mix code built with both ABIs. So, if we detect
3098         dnl that compiling uses the "softfloat" ABI, force the use of the
3099         dnl "softfp" ABI instead.
3100         dnl Confusingly, the __SOFTFP__ preprocessor variable indicates the
3101         dnl "softfloat" ABI, not the "softfp" ABI.
3102         dnl Note: VPX_ASFLAGS is also used in CFLAGS.
3103         AC_TRY_COMPILE([],
3104           [#ifndef __SOFTFP__
3105            #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
3106            #endif],
3107            VPX_ASFLAGS="$VPX_ASFLAGS -mfloat-abi=softfp"
3108            )
3109       fi
3110     ;;
3111     *:x86)
3112       if $CC -E -dM -</dev/null | grep -q __ELF__; then
3113         VPX_USE_YASM=1
3114         VPX_X86_ASM=1
3115       fi
3116     ;;
3117     *:x86_64)
3118       if $CC -E -dM -</dev/null | grep -q __ELF__; then
3119         VPX_USE_YASM=1
3120         VPX_X86_ASM=1
3121       fi
3122     ;;
3123     esac
3125     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_USE_YASM" -a -z "$YASM"; then
3126       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.])
3127     fi # COMPILE_ENVIRONMENT and others
3129     if test -n "$VPX_USE_YASM" && test "$OS_ARCH:$CPU_ARCH" != "WINNT:x86_64"; then
3130       VPX_ASFLAGS="-DPIC"
3131     fi
3133     if test -n "$VPX_X86_ASM"; then
3134       AC_DEFINE(VPX_X86_ASM)
3135     elif test -n "$VPX_ARM_ASM"; then
3136       AC_DEFINE(VPX_ARM_ASM)
3137     else
3138       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
3139     fi
3141     dnl native libvpx no longer has vpx_mem_set_functions
3142     AC_DEFINE(MOZ_VPX_NO_MEM_REPORTING)
3145 dnl ========================================================
3146 dnl = Handle dependent MEDIA defines
3147 dnl ========================================================
3149 if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
3150     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/])
3153 if test -n "$MOZ_VORBIS"; then
3154     AC_DEFINE(MOZ_VORBIS)
3157 if test -n "$MOZ_TREMOR"; then
3158     AC_DEFINE(MOZ_TREMOR)
3161 MOZ_WEBM_ENCODER=1
3162 AC_DEFINE(MOZ_WEBM_ENCODER)
3163 AC_SUBST(MOZ_WEBM_ENCODER)
3165 dnl ==================================
3166 dnl = Check alsa availability on Linux
3167 dnl ==================================
3169 MOZ_ARG_ENABLE_BOOL(alsa,
3170 [  --enable-alsa          Enable Alsa support],
3171    MOZ_ALSA=1,
3172    MOZ_ALSA=)
3174 if test -n "$MOZ_ALSA"; then
3175     PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
3176          [echo "$MOZ_ALSA_PKG_ERRORS"
3177           AC_MSG_ERROR([Need alsa for audio output on Linux. (On Ubuntu, you might try installing the package libasound2-dev.)])])
3180 AC_SUBST(MOZ_ALSA)
3182 dnl ========================================================
3183 dnl = Disable PulseAudio
3184 dnl ========================================================
3186 dnl If using Desktop Linux, ensure that the PA library is available
3187 case "$OS_TARGET" in
3188 WINNT|Darwin|Android|OpenBSD)
3189     ;;
3191     MOZ_PULSEAUDIO=1
3192     ;;
3193 esac
3195 MOZ_ARG_DISABLE_BOOL(pulseaudio,
3196 [  --disable-pulseaudio          Disable PulseAudio support],
3197    MOZ_PULSEAUDIO=,
3198    MOZ_PULSEAUDIO=1)
3200 if test -n "$MOZ_PULSEAUDIO"; then
3201     AC_DEFINE(MOZ_PULSEAUDIO)
3202     if test -z "$gonkdir"; then
3203         PKG_CHECK_MODULES(MOZ_PULSEAUDIO, libpulse, ,
3204              [echo "$MOZ_PULSEAUDIO_PKG_ERRORS"
3205               AC_MSG_ERROR([pulseaudio audio backend requires libpulse development package])])
3206     else
3207         MOZ_PULSEAUDIO_CFLAGS="-I$gonkdir/external/pulseaudio/pulseaudio/src"
3208     fi
3211 AC_SUBST(MOZ_PULSEAUDIO)
3213 dnl ========================================================
3214 dnl NegotiateAuth
3215 dnl ========================================================
3217 MOZ_ARG_DISABLE_BOOL(negotiateauth,
3218 [  --disable-negotiateauth Disable GSS-API negotiation ],
3219     MOZ_AUTH_EXTENSION=,
3220     MOZ_AUTH_EXTENSION=1 )
3222 if test -n "$MOZ_IOS" -a -n "$MOZ_AUTH_EXTENSION"; then
3223    AC_MSG_ERROR([negotiateauth is not supported on iOS.])
3226 dnl ========================================================
3227 dnl Pref extensions (autoconfig)
3228 dnl ========================================================
3229 MOZ_ARG_DISABLE_BOOL(pref-extensions,
3230 [  --disable-pref-extensions
3231                           Disable pref extensions such as autoconfig],
3232   MOZ_PREF_EXTENSIONS=,
3233   MOZ_PREF_EXTENSIONS=1 )
3235 dnl ========================================================
3236 dnl Searching of system directories for extensions.
3237 dnl Note: this switch is meant to be used for test builds
3238 dnl whose behavior should not depend on what happens to be
3239 dnl installed on the local machine.
3240 dnl ========================================================
3241 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
3242 [  --disable-system-extension-dirs
3243                           Disable searching system- and account-global
3244                           directories for extensions of any kind; use
3245                           only profile-specific extension directories],
3246   ENABLE_SYSTEM_EXTENSION_DIRS=,
3247   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
3248 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
3249   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
3252 dnl ========================================================
3253 dnl = Universalchardet
3254 dnl ========================================================
3255 MOZ_ARG_DISABLE_BOOL(universalchardet,
3256 [  --disable-universalchardet
3257                           Disable universal encoding detection],
3258   MOZ_UNIVERSALCHARDET=,
3259   MOZ_UNIVERSALCHARDET=1 )
3261 dnl ========================================================
3262 dnl = ANGLE OpenGL->D3D translator for WebGL
3263 dnl = * only applies to win32
3264 dnl ========================================================
3266 MOZ_ANGLE_RENDERER=
3267 MOZ_D3D_CPU_SUFFIX=
3268 MOZ_HAS_WINSDK_WITH_D3D=
3269 MOZ_D3DCOMPILER_VISTA_DLL=
3270 MOZ_D3DCOMPILER_VISTA_DLL_PATH=
3272 if test "$COMPILE_ENVIRONMENT" ; then
3273 case "$target_os" in
3274 *mingw*)
3275     MOZ_ANGLE_RENDERER=1
3276     ;;
3277 esac
3279 # The DirectX SDK libraries are split into x86 and x64 sub-directories
3280 case "${target_cpu}" in
3281 i*86)
3282   MOZ_D3D_CPU_SUFFIX=x86
3283   ;;
3284 x86_64)
3285   MOZ_D3D_CPU_SUFFIX=x64
3286   ;;
3287 esac
3289 # This is potentially set in external mozconfig files; if it's set,
3290 # then the build exposes the "webgl" context name, which is reserved
3291 # for conformant implementations.
3292 if test -n "$MOZ_WEBGL_CONFORMANT"; then
3293   AC_DEFINE(MOZ_WEBGL_CONFORMANT)
3296 dnl ========================================================
3297 dnl D3D compiler DLL
3298 dnl ========================================================
3299 MOZ_FOUND_D3D_COMPILERS=
3301 if test -n "$MOZ_ANGLE_RENDERER"; then
3302   if test -z "$MOZ_D3D_CPU_SUFFIX"; then
3303     AC_MSG_ERROR([Couldn't determine MOZ_D3D_CPU_SUFFIX.])
3304   fi
3306   ######################################
3307   # Find _46+ for use by Vista+.
3309   # Find a D3D compiler DLL in a Windows SDK.
3310   MOZ_D3DCOMPILER_VISTA_DLL=
3311   case "$MOZ_WINSDK_MAXVER" in
3312   0x0603*|0x0A00*)
3313     MOZ_D3DCOMPILER_VISTA_DLL=d3dcompiler_47.dll
3314     AC_MSG_RESULT([Found D3D compiler in Windows SDK.])
3315   ;;
3316   esac
3318   if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
3319     # We have a name, now track down the path.
3320     if test -n "$WINDOWSSDKDIR"; then
3321       MOZ_D3DCOMPILER_VISTA_DLL_PATH="$WINDOWSSDKDIR/Redist/D3D/$MOZ_D3D_CPU_SUFFIX/$MOZ_D3DCOMPILER_VISTA_DLL"
3322       if test -f "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
3323         AC_MSG_RESULT([Found MOZ_D3DCOMPILER_VISTA_DLL_PATH: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
3324         MOZ_HAS_WINSDK_WITH_D3D=1
3325       else
3326         AC_MSG_RESULT([MOZ_D3DCOMPILER_VISTA_DLL_PATH doesn't exist: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
3327         AC_MSG_ERROR([Windows SDK at "$WINDOWSSDKDIR" appears broken. Try updating to MozillaBuild 1.9 final or higher.])
3328         MOZ_D3DCOMPILER_VISTA_DLL_PATH=
3329       fi
3330     else
3331       AC_MSG_RESULT([Windows SDK not found.])
3332     fi
3333   else
3334     AC_MSG_ERROR([Couldn't find Windows SDK 8.1 or higher needed for ANGLE.])
3335   fi
3337   if test -z "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
3338     MOZ_D3DCOMPILER_VISTA_DLL=
3339   fi
3341   # On mingw, check if headers are provided by toolchain.
3342   if test -n "$GNU_CC"; then
3343     MOZ_CHECK_HEADER(d3d10.h, MOZ_HAS_WINSDK_WITH_D3D=1)
3344   fi
3346   ######################################
3347   # Check that we found what we needed.
3348   MOZ_FOUND_A_D3D_COMPILER=
3350   if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
3351     MOZ_FOUND_A_D3D_COMPILER=1
3352     AC_MSG_RESULT([Found d3dcompiler DLL for Vista+: $MOZ_D3DCOMPILER_VISTA_DLL])
3353   fi
3355   if test -z "$CROSS_COMPILE"; then
3356     if test -z "MOZ_FOUND_A_D3D_COMPILER"; then
3357       AC_MSG_ERROR([Couldn't find an acceptable D3D compiler DLL.])
3358     fi
3359   fi
3360 fi # MOZ_ANGLE_RENDERER
3362 fi # COMPILE_ENVIRONMENT
3365 dnl ========================================================
3366 dnl Gamepad support
3367 dnl ========================================================
3368 MOZ_GAMEPAD_BACKEND=stub
3370 case "$OS_TARGET" in
3371 Darwin)
3372     if test -z "$MOZ_IOS"; then
3373         MOZ_GAMEPAD_BACKEND=cocoa
3374     fi
3375     ;;
3376 WINNT)
3377     MOZ_GAMEPAD_BACKEND=windows
3378     ;;
3379 Linux)
3380     MOZ_CHECK_HEADER([linux/joystick.h])
3381     if test "$ac_cv_header_linux_joystick_h" != "yes"; then
3382       AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers.])
3383     fi
3384     MOZ_GAMEPAD_BACKEND=linux
3385     ;;
3386 Android)
3387     MOZ_GAMEPAD_BACKEND=android
3388     ;;
3390     ;;
3391 esac
3393 AC_SUBST(MOZ_GAMEPAD_BACKEND)
3395 dnl ========================================================
3396 dnl = Breakpad crash reporting (on by default on supported platforms)
3397 dnl ========================================================
3399 case $target in
3400 i?86-*-mingw*|x86_64-*-mingw*)
3401   MOZ_CRASHREPORTER=1
3402   ;;
3403 i?86-apple-darwin*|x86_64-apple-darwin*)
3404   if test -z "$MOZ_IOS"; then
3405     MOZ_CRASHREPORTER=1
3406   fi
3407   ;;
3408 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
3409   if test "$MOZ_ENABLE_GTK"; then
3410     MOZ_CRASHREPORTER=1
3411   fi
3412   ;;
3413 *-android*|*-linuxandroid*)
3414   MOZ_CRASHREPORTER=1
3415   ;;
3416 esac
3418 MOZ_ARG_DISABLE_BOOL(crashreporter,
3419 [  --disable-crashreporter Disable breakpad crash reporting],
3420     [MOZ_CRASHREPORTER=],
3421     [MOZ_CRASHREPORTER=F # Force enable breakpad])
3423 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "Darwin"; then
3424   if test "$MOZ_CRASHREPORTER" = F; then
3425     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
3426   fi
3427   MOZ_CRASHREPORTER=
3430 if test -n "$MOZ_CRASHREPORTER"; then
3431    AC_DEFINE(MOZ_CRASHREPORTER)
3433   if test "$OS_TARGET" = "Linux" && \
3434     test -z "$SKIP_LIBRARY_CHECKS"; then
3435     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
3436   fi
3438   if test "$OS_ARCH" = "WINNT"; then
3439     if test -z "$HAVE_64BIT_BUILD" -a -n "$COMPILE_ENVIRONMENT"; then
3440       MOZ_CRASHREPORTER_INJECTOR=1
3441       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
3442     fi
3443   fi
3446 MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
3447 [  --with-crashreporter-enable-percent=NN
3448                           Enable sending crash reports by default on NN% of users. (default=100)],
3449 [ val=`echo $withval | sed 's/[^0-9]//g'`
3450     MOZ_CRASHREPORTER_ENABLE_PERCENT="$val"])
3452 if test -z "$MOZ_CRASHREPORTER_ENABLE_PERCENT"; then
3453    MOZ_CRASHREPORTER_ENABLE_PERCENT=100
3455 AC_DEFINE_UNQUOTED(MOZ_CRASHREPORTER_ENABLE_PERCENT, $MOZ_CRASHREPORTER_ENABLE_PERCENT)
3457 dnl ========================================================
3458 dnl = libjpeg-turbo configuration
3459 dnl ========================================================
3460 MOZ_LIBJPEG_TURBO=
3461 LIBJPEG_TURBO_USE_YASM=
3462 if test -z "$MOZ_SYSTEM_JPEG"; then
3463     MOZ_LIBJPEG_TURBO=1
3466 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
3467 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
3468     MOZ_LIBJPEG_TURBO=,
3469     MOZ_LIBJPEG_TURBO=1)
3471 if test "$MOZ_SYSTEM_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
3472     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
3475 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
3476 dnl files.
3478 if test -n "$MOZ_LIBJPEG_TURBO" -a -n "$COMPILE_ENVIRONMENT"; then
3480   dnl Do we support libjpeg-turbo on this platform?
3481   case "$OS_ARCH:$CPU_ARCH" in
3482   Darwin:x86)
3483     LIBJPEG_TURBO_ASFLAGS="-DPIC -DMACHO"
3484   ;;
3485   Darwin:x86_64)
3486     LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DMACHO"
3487   ;;
3488   Darwin:arm*)
3489   ;;
3490   WINNT:x86)
3491     LIBJPEG_TURBO_ASFLAGS="-DPIC -DWIN32"
3492   ;;
3493   WINNT:x86_64)
3494     LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DWIN64 -DMSVC"
3495   ;;
3496   *:arm)
3497     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
3498   ;;
3499   *:aarch64)
3500     LIBJPEG_TURBO_ASFLAGS="-march=armv8-a"
3501   ;;
3502   *:mips32)
3503     LIBJPEG_TURBO_ASFLAGS="-mdspr2"
3504   ;;
3505   *:x86)
3506     if $CC -E -dM -</dev/null | grep -q __ELF__; then
3507       LIBJPEG_TURBO_ASFLAGS="-DPIC -DELF"
3508     fi
3509   ;;
3510   *:x86_64)
3511     if $CC -E -dM -</dev/null | grep -q __ELF__; then
3512       LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DELF"
3513     fi
3514   ;;
3515   esac
3518 if test -n "$LIBJPEG_TURBO_ASFLAGS"; then
3519   case "$CPU_ARCH" in
3520 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
3521 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
3522 dnl it doesn't exist or we have too old of a version.
3523   x86_64|x86)
3524     LIBJPEG_TURBO_USE_YASM=1
3526     if test -z "$YASM" ; then
3527         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.])
3528     fi
3530     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
3531     dnl on Linux and 1.1 or newer everywhere else.
3532     if test "$OS_ARCH" = "Linux" ; then
3533         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
3534             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.])
3535         fi
3536     else
3537         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
3538             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.])
3539         fi
3540     fi
3541   ;;
3542   esac
3545 dnl ========================================================
3546 dnl = libav-fft configuration
3547 dnl ========================================================
3549 MOZ_LIBAV_FFT=
3551 dnl Turn on libav-fft for 32-bit windows, and all 64-bit supported platforms.
3552 dnl 32-bit linux/os x have text relocation issues.
3554 case "$OS_ARCH:$CPU_ARCH" in
3555   WINNT:x86)
3556       MOZ_LIBAV_FFT=1
3557   ;;
3558   *:x86_64)
3559       MOZ_LIBAV_FFT=1
3560   ;;
3561 esac
3563 dnl Detect if we can use yasm to compile libav's assembly
3565 if test -n "$MOZ_LIBAV_FFT" -a -n "$COMPILE_ENVIRONMENT"; then
3566   AC_DEFINE(MOZ_LIBAV_FFT)
3567   dnl Do we support libav-fft on this platform?
3568   case "$OS_ARCH:$CPU_ARCH" in
3569   Darwin:x86_64)
3570     LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DMACHO"
3571   ;;
3572   WINNT:x86)
3573     LIBAV_FFT_ASFLAGS="-DPIC -DWIN32"
3574   ;;
3575   WINNT:x86_64)
3576     LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DWIN64 -DMSVC"
3577   ;;
3578   *:x86_64)
3579     if $CC -E -dM -</dev/null | grep -q __ELF__; then
3580       LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DELF"
3581     fi
3582   ;;
3583   *)
3584     AC_MSG_ERROR([libav's FFT routines are only available for 32-bit windows or 64-bit x86 based platforms.])
3585   ;;
3586   esac
3589 if test -n "$LIBAV_FFT_ASFLAGS"; then
3590   dnl If we're on an x86 or x64 system which supports libav-fft's asm routines
3591   dnl check for Yasm, and error out if it doesn't exist or we have too old of a
3592   dnl version.
3593   if test -z "$YASM" ; then
3594     AC_MSG_ERROR([Yasm is required to build with libav's optimized FFT routines, but you do not appear to have Yasm installed. See https://developer.mozilla.org/en/YASM for more details.])
3595   fi
3596   dnl Check that we have the right yasm version.  We require 1.0.1 or newer
3597   dnl on Linux and 1.1 or newer everywhere else.
3598   if test "$OS_ARCH" = "Linux" ; then
3599     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
3600       AC_MSG_ERROR([Yasm 1.0.1 or greater is required to build with libav's optimized FFT routines, but you do not appear to have Yasm installed.  See https://developer.mozilla.org/en/YASM for more details.])
3601     fi
3602   else
3603     if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
3604       AC_MSG_ERROR([Yasm 1.1 or greater is required to build with libav's optimized FFT routines, but you do not appear to have Yasm installed.  See https://developer.mozilla.org/en/YASM for more details.])
3605     fi
3606   fi
3607 elif test -n "$MOZ_LIBAV_FFT" -a "${CPU_ARCH}" != "arm"; then
3608   dnl Warn if we're not building either libav or opendl-max optimized routines.
3609   AC_MSG_WARN([No assembler or assembly support for libav-fft.  Using unoptimized C routines.])
3612 dnl ========================================================
3613 dnl = FFmpeg's ffvpx configuration
3614 dnl ========================================================
3616 MOZ_FFVPX=
3617 case "$CPU_ARCH" in
3618   x86)
3619       MOZ_FFVPX=1
3620   ;;
3621   x86_64)
3622       MOZ_FFVPX=1
3623   ;;
3624 esac
3626 dnl Use same conditional as MOZ_LIBAV_FFT to enable FFmpeg's ffvpx assembly decoder.
3627 if test -n "$MOZ_LIBAV_FFT"; then
3628   FFVPX_ASFLAGS=$LIBAV_FFT_ASFLAGS
3630 if test -n "$MOZ_FFVPX"; then
3631   AC_DEFINE(MOZ_FFVPX)
3634 dnl ========================================================
3635 dnl = Enable compilation of specific extension modules
3636 dnl ========================================================
3638 MOZ_ARG_ENABLE_STRING(extensions,
3639 [  --enable-extensions     Enable extensions],
3640 [ for option in `echo $enableval | sed 's/,/ /g'`; do
3641     if test "$option" = "yes" -o "$option" = "all"; then
3642         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
3643     elif test "$option" = "no" -o "$option" = "none"; then
3644         MOZ_EXTENSIONS=""
3645     elif test "$option" = "default"; then
3646         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
3647     elif test `echo "$option" | grep -c \^-` != 0; then
3648         option=`echo $option | sed 's/^-//'`
3649         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
3650     else
3651         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
3652     fi
3653 done],
3654     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
3656 if test -z "$MOZ_ENABLE_GIO" -a `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
3657     # Suppress warning on non-X11 platforms
3658     if test -n "$MOZ_X11"; then
3659         AC_MSG_WARN([Removing gio from MOZ_EXTENSIONS due to --disable-gio.])
3660     fi
3661     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
3664 if test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
3665     MOZ_GIO_COMPONENT=1
3666     MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's|gio||'`
3668 AC_SUBST(MOZ_GIO_COMPONENT)
3670 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
3671 dnl when trying to build a nonexistent extension.
3672 for extension in $MOZ_EXTENSIONS; do
3673     if test ! -d "${srcdir}/extensions/${extension}"; then
3674         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
3675     fi
3676 done
3678 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
3679   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
3682 if test -n "$MOZ_TREE_FREETYPE"; then
3683    MOZ_ENABLE_CAIRO_FT=1
3684    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
3685    CAIRO_FT_CFLAGS="-I$_topsrcdir/modules/freetype2/include"
3686    AC_SUBST_LIST(CAIRO_FT_CFLAGS)
3689 AC_CHECK_PROGS(WGET, wget, "")
3690 AC_SUBST(WGET)
3692 dnl ========================================================
3693 dnl Maintenance Service
3694 dnl ========================================================
3696 MOZ_ARG_ENABLE_BOOL(maintenance-service,
3697 [  --enable-maintenance-service       Enable building of maintenanceservice],
3698     MOZ_MAINTENANCE_SERVICE=1,
3699     MOZ_MAINTENANCE_SERVICE= )
3701 if test -n "$MOZ_MAINTENANCE_SERVICE"; then
3702   if test "$OS_ARCH" = "WINNT"; then
3703     AC_DEFINE(MOZ_MAINTENANCE_SERVICE)
3704   else
3705     AC_MSG_ERROR([Can only build with --enable-maintenance-service with a Windows target])
3706   fi
3709 dnl ========================================================
3710 dnl Bundled fonts on desktop platforms
3711 dnl ========================================================
3713 MOZ_ARG_ENABLE_BOOL(bundled-fonts,
3714 [  --enable-bundled-fonts  Enable support for bundled fonts on desktop platforms],
3715     MOZ_BUNDLED_FONTS=1,
3716     MOZ_BUNDLED_FONTS=)
3718 if test -n "$MOZ_BUNDLED_FONTS"; then
3719   AC_DEFINE(MOZ_BUNDLED_FONTS)
3722 dnl ========================================================
3723 dnl Verify MAR signatures
3724 dnl ========================================================
3726 MOZ_ARG_ENABLE_BOOL(verify-mar,
3727 [  --enable-verify-mar     Enable verifying MAR signatures],
3728     MOZ_VERIFY_MAR_SIGNATURE=1,
3729     MOZ_VERIFY_MAR_SIGNATURE= )
3731 if test -n "$MOZ_VERIFY_MAR_SIGNATURE"; then
3732   AC_DEFINE(MOZ_VERIFY_MAR_SIGNATURE)
3735 dnl ========================================================
3736 dnl Enable building the signmar program.
3737 dnl This option is much different than the --enable-verify-mar option.
3738 dnl --enable-verify-mar is for enabling the verification check on MAR
3739 dnl files in the updater.  The --enable-signmar option is for building
3740 dnl the signmar program.
3741 dnl ========================================================
3743 MOZ_ARG_ENABLE_BOOL(signmar,
3744 [  --enable-signmar     Enable building the signmar program],
3745     MOZ_ENABLE_SIGNMAR=1,
3746     MOZ_ENABLE_SIGNMAR= )
3748 if test -n "$MOZ_ENABLE_SIGNMAR"; then
3749   if test -z "$COMPILE_ENVIRONMENT" ; then
3750     AC_MSG_WARN([Cannot --enable-signmar with --disable-compile-environment])
3751     MOZ_ENABLE_SIGNMAR=
3752   else
3753     AC_DEFINE(MOZ_ENABLE_SIGNMAR)
3754   fi
3757 dnl ========================================================
3758 dnl Updater
3759 dnl ========================================================
3761 if test "$MOZ_IOS"; then
3762   MOZ_UPDATER=
3765 MOZ_ARG_DISABLE_BOOL(updater,
3766 [  --disable-updater       Disable building of updater],
3767     MOZ_UPDATER=,
3768     MOZ_UPDATER=1 )
3770 if test -n "$MOZ_UPDATER"; then
3771     AC_DEFINE(MOZ_UPDATER)
3774 dnl ========================================================
3775 dnl parental controls (for Windows Vista)
3776 dnl ========================================================
3777 MOZ_ARG_DISABLE_BOOL(parental-controls,
3778 [  --disable-parental-controls
3779                           Do not build parental controls],
3780    MOZ_DISABLE_PARENTAL_CONTROLS=1,
3781    MOZ_DISABLE_PARENTAL_CONTROLS=)
3782 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
3783     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
3786 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
3788 dnl ========================================================
3789 dnl = Disable smartcard support
3790 dnl ========================================================
3791 if test -n "$MOZ_NO_SMART_CARDS"; then
3792     AC_DEFINE(MOZ_NO_SMART_CARDS)
3794 AC_SUBST(MOZ_NO_SMART_CARDS)
3796 dnl ========================================================
3797 dnl = Sandboxing support
3798 dnl ========================================================
3799 if test -n "$MOZ_TSAN" -o -n "$MOZ_ASAN"; then
3800     # Bug 1182565: TSan conflicts with sandboxing on Linux.
3801     # Bug 1287971: LSan also conflicts with sandboxing on Linux.
3802     case $OS_TARGET in
3803     Linux|Android)
3804         MOZ_SANDBOX=
3805         ;;
3806     esac
3809 MOZ_ARG_DISABLE_BOOL(sandbox,
3810 [  --disable-sandbox        Disable sandboxing support],
3811     MOZ_SANDBOX=,
3812     MOZ_SANDBOX=1)
3814 dnl ========================================================
3815 dnl = Content process sandboxing
3816 dnl ========================================================
3817 if test -n "$gonkdir"; then
3818     MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
3821 case "$OS_TARGET:$NIGHTLY_BUILD" in
3822 WINNT:*)
3823     MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
3824     ;;
3825 Darwin:*)
3826     MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
3827     ;;
3828 Linux:1)
3829     case $CPU_ARCH in
3830         x86_64|x86)
3831             MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
3832         ;;
3833     esac
3834     ;;
3835 esac
3837 MOZ_ARG_ENABLE_BOOL(content-sandbox,
3838 [  --enable-content-sandbox Enable sandboxing support for content-processes
3839   --disable-content-sandbox Disable sandboxing support for content-processes],
3840     MOZ_CONTENT_SANDBOX=1,
3841     MOZ_CONTENT_SANDBOX=)
3843 if test -n "$MOZ_CONTENT_SANDBOX" -a -z "$MOZ_SANDBOX"; then
3844     AC_MSG_ERROR([--enable-content-sandbox and --disable-sandbox are conflicting options])
3847 if test -n "$MOZ_CONTENT_SANDBOX"; then
3848     AC_DEFINE(MOZ_CONTENT_SANDBOX)
3851 AC_SUBST(MOZ_CONTENT_SANDBOX)
3853 dnl ========================================================
3854 dnl = Gecko Media Plugin sandboxing
3855 dnl ========================================================
3856 case $OS_TARGET in
3857 WINNT)
3858     MOZ_GMP_SANDBOX=$MOZ_SANDBOX
3859     ;;
3860 Linux)
3861     case $CPU_ARCH in
3862     x86_64|x86)
3863         MOZ_GMP_SANDBOX=$MOZ_SANDBOX
3864         ;;
3865     esac
3866     ;;
3867 Darwin)
3868     MOZ_GMP_SANDBOX=$MOZ_SANDBOX
3869     ;;
3870 esac
3872 if test -n "$MOZ_GMP_SANDBOX"; then
3873     AC_DEFINE(MOZ_GMP_SANDBOX)
3876 AC_SUBST(MOZ_GMP_SANDBOX)
3878 if test -z "$MOZ_CONTENT_SANDBOX" -a -z "$MOZ_GMP_SANDBOX"; then
3879     MOZ_SANDBOX=
3882 if test -n "$MOZ_SANDBOX"; then
3883     AC_DEFINE(MOZ_SANDBOX)
3886 AC_SUBST(MOZ_SANDBOX)
3889 dnl ========================================================
3890 dnl =
3891 dnl = Module specific options
3892 dnl =
3893 dnl ========================================================
3894 MOZ_ARG_HEADER(Individual module options)
3896 dnl ========================================================
3897 dnl = Disable feed handling components
3898 dnl ========================================================
3899 MOZ_ARG_DISABLE_BOOL(feeds,
3900 [  --disable-feeds         Disable feed handling and processing components],
3901     MOZ_FEEDS=,
3902     MOZ_FEEDS=1 )
3903 if test -n "$MOZ_FEEDS"; then
3904     AC_DEFINE(MOZ_FEEDS)
3905 else
3906     if test "$MOZ_BUILD_APP" = "browser"; then
3907         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
3908     fi
3911 dnl ========================================================
3912 dnl Check for sqlite
3913 dnl ========================================================
3915 MOZ_SYSTEM_SQLITE=
3916 MOZ_ARG_ENABLE_BOOL(system-sqlite,
3917 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
3918 MOZ_SYSTEM_SQLITE=1,
3919 MOZ_SYSTEM_SQLITE= )
3921 if test -n "$MOZ_SYSTEM_SQLITE"
3922 then
3923     dnl ============================
3924     dnl === SQLite Version check ===
3925     dnl ============================
3926     dnl Check to see if the system SQLite package is new enough.
3927     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
3929     dnl ==================================
3930     dnl === SQLITE_SECURE_DELETE check ===
3931     dnl ==================================
3932     dnl Check to see if the system SQLite package is compiled with
3933     dnl SQLITE_SECURE_DELETE enabled.
3934     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
3935     _SAVE_CFLAGS="$CFLAGS"
3936     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3937     _SAVE_LIBS="$LIBS"
3938     LIBS="$LIBS $SQLITE_LIBS"
3939     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
3940         AC_TRY_RUN([
3941             #include "sqlite3.h"
3943             int main(int argc, char **argv){
3944               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
3945             }],
3946             ac_cv_sqlite_secure_delete=yes,
3947             ac_cv_sqlite_secure_delete=no,
3948             ac_cv_sqlite_secure_delete=no
3949         )
3950     ])
3951     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
3952     CFLAGS="$_SAVE_CFLAGS"
3953     LIBS="$_SAVE_LIBS"
3954     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
3955         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
3956     fi
3958     dnl ===============================
3959     dnl === SQLITE_THREADSAFE check ===
3960     dnl ===============================
3961     dnl Check to see if the system SQLite package is compiled with
3962     dnl SQLITE_THREADSAFE enabled.
3963     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
3964     _SAVE_CFLAGS="$CFLAGS"
3965     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3966     _SAVE_LIBS="$LIBS"
3967     LIBS="$LIBS $SQLITE_LIBS"
3968     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
3969         AC_TRY_RUN([
3970             #include "sqlite3.h"
3972             int main(int argc, char **argv){
3973               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
3974             }],
3975             ac_cv_sqlite_threadsafe=yes,
3976             ac_cv_sqlite_threadsafe=no,
3977             ac_cv_sqlite_threadsafe=no
3978         )
3979     ])
3980     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
3981     CFLAGS="$_SAVE_CFLAGS"
3982     LIBS="$_SAVE_LIBS"
3983     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
3984         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
3985     fi
3987     dnl ================================
3988     dnl === SQLITE_ENABLE_FTS3 check ===
3989     dnl ================================
3990     dnl check to see if the system SQLite package is compiled with
3991     dnl SQLITE_ENABLE_FTS3 enabled.
3992     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
3993     _SAVE_CFLAGS="$CFLAGS"
3994     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3995     _SAVE_LIBS="$LIBS"
3996     LIBS="$LIBS $SQLITE_LIBS"
3997     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
3998         AC_TRY_RUN([
3999             #include "sqlite3.h"
4001             int main(int argc, char **argv){
4002               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
4003             }],
4004             ac_cv_sqlite_enable_fts3=yes,
4005             ac_cv_sqlite_enable_fts3=no,
4006             ac_cv_sqlite_enable_fts3=no
4007         )
4008     ])
4009     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
4010     CFLAGS="$_SAVE_CFLAGS"
4011     LIBS="$_SAVE_LIBS"
4012     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
4013         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
4014     fi
4016     dnl =========================================
4017     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
4018     dnl =========================================
4019     dnl check to see if the system SQLite package is compiled with
4020     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
4021     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
4022     _SAVE_CFLAGS="$CFLAGS"
4023     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
4024     _SAVE_LIBS="$LIBS"
4025     LIBS="$LIBS $SQLITE_LIBS"
4026     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
4027         AC_TRY_RUN([
4028             #include "sqlite3.h"
4030             int main(int argc, char **argv){
4031               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
4032             }],
4033             ac_cv_sqlite_enable_unlock_notify=yes,
4034             ac_cv_sqlite_enable_unlock_notify=no,
4035             ac_cv_sqlite_enable_unlock_notify=no
4036         )
4037     ])
4038     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
4039     CFLAGS="$_SAVE_CFLAGS"
4040     LIBS="$_SAVE_LIBS"
4041     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
4042         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
4043     fi
4045     dnl =========================================
4046     dnl === SQLITE_ENABLE_DBSTAT_VTAB check ===
4047     dnl =========================================
4048     dnl check to see if the system SQLite package is compiled with
4049     dnl SQLITE_ENABLE_DBSTAT_VTAB.
4050     AC_MSG_CHECKING(for SQLITE_ENABLE_DBSTAT_VTAB support in system SQLite)
4051     _SAVE_CFLAGS="$CFLAGS"
4052     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
4053     _SAVE_LIBS="$LIBS"
4054     LIBS="$LIBS $SQLITE_LIBS"
4055     AC_CACHE_VAL(ac_cv_sqlite_dbstat_vtab,[
4056         AC_TRY_RUN([
4057             #include "sqlite3.h"
4059             int main(int argc, char **argv){
4060               return !sqlite3_compileoption_used("SQLITE_ENABLE_DBSTAT_VTAB");
4061             }],
4062             ac_cv_sqlite_dbstat_vtab=yes,
4063             ac_cv_sqlite_dbstat_vtab=no,
4064             ac_cv_sqlite_dbstat_vtab=no
4065         )
4066     ])
4067     AC_MSG_RESULT($ac_cv_sqlite_dbstat_vtab)
4068     CFLAGS="$_SAVE_CFLAGS"
4069     LIBS="$_SAVE_LIBS"
4070     if test "x$ac_cv_sqlite_dbstat_vtab" = "xno"; then
4071         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_DBSTAT_VTAB.])
4072     fi
4075 if test -n "$MOZ_SYSTEM_SQLITE"; then
4076     AC_DEFINE(MOZ_SYSTEM_SQLITE)
4078 AC_SUBST(MOZ_SYSTEM_SQLITE)
4080 dnl ========================================================
4081 dnl = Enable url-classifier
4082 dnl ========================================================
4083 MOZ_ARG_ENABLE_BOOL(url-classifier,
4084 [  --enable-url-classifier Enable url classifier module],
4085     MOZ_URL_CLASSIFIER=1,
4086     MOZ_URL_CLASSIFIER= )
4087 if test -n "$MOZ_URL_CLASSIFIER"; then
4088     AC_DEFINE(MOZ_URL_CLASSIFIER)
4090 AC_SUBST(MOZ_URL_CLASSIFIER)
4092 dnl ========================================================
4093 dnl = Disable zipwriter
4094 dnl ========================================================
4095 MOZ_ARG_DISABLE_BOOL(zipwriter,
4096 [  --disable-zipwriter     Disable zipwriter component],
4097     MOZ_ZIPWRITER=,
4098     MOZ_ZIPWRITER=1 )
4099 AC_SUBST(MOZ_ZIPWRITER)
4101 dnl ========================================================
4102 dnl = faststripe theme
4103 dnl ========================================================
4104 MOZ_ARG_ENABLE_BOOL(faststripe,
4105 [  --enable-faststripe     Use faststripe theme],
4106     MOZ_THEME_FASTSTRIPE=1,
4107     MOZ_THEME_FASTSTRIPE= )
4108 AC_SUBST(MOZ_THEME_FASTSTRIPE)
4110 dnl ========================================================
4111 dnl =
4112 dnl = Feature options that require extra sources to be pulled
4113 dnl =
4114 dnl ========================================================
4115 dnl MOZ_ARG_HEADER(Features that require extra sources)
4117 dnl ========================================================
4118 dnl =
4119 dnl = Runtime debugging and Optimization Options
4120 dnl =
4121 dnl ========================================================
4122 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
4124 dnl ========================================================
4125 dnl enable mobile optimizations
4126 dnl ========================================================
4127 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
4128 [  --enable-mobile-optimize
4129                           Enable mobile optimizations],
4130     MOZ_GFX_OPTIMIZE_MOBILE=1)
4132 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
4134 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
4135     # We ignore paint will resample on mobile for performance.
4136     # We may want to revisit this later.
4137     MOZ_IGNORE_PAINT_WILL_RESAMPLE=1
4139     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
4140     AC_DEFINE(MOZ_IGNORE_PAINT_WILL_RESAMPLE)
4143 dnl ========================================================
4144 dnl = Enable code optimization. ON by default.
4145 dnl ========================================================
4146 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
4147     MOZ_OPTIMIZE_FLAGS="-O"
4150 MOZ_ARG_ENABLE_STRING(optimize,
4151 [  --disable-optimize      Disable compiler optimization
4152   --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]],
4153 [ if test "$enableval" != "no"; then
4154     MOZ_OPTIMIZE=1
4155     if test -n "$enableval" -a "$enableval" != "yes"; then
4156         MOZ_OPTIMIZE_FLAGS=`echo "$enableval" | sed -e 's|\\\ | |g'`
4157         MOZ_OPTIMIZE=2
4158     fi
4159 else
4160     MOZ_OPTIMIZE=
4161 fi ], MOZ_OPTIMIZE=1)
4163 MOZ_SET_FRAMEPTR_FLAGS
4165 if test "$COMPILE_ENVIRONMENT"; then
4166 if test -n "$MOZ_OPTIMIZE"; then
4167     AC_MSG_CHECKING([for valid C compiler optimization flags])
4168     _SAVE_CFLAGS=$CFLAGS
4169     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
4170     AC_TRY_COMPILE([#include <stdio.h>],
4171         [printf("Hello World\n");],
4172         _results=yes,
4173         _results=no)
4174     AC_MSG_RESULT([$_results])
4175     if test "$_results" = "no"; then
4176         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
4177     fi
4178     CFLAGS=$_SAVE_CFLAGS
4180 fi # COMPILE_ENVIRONMENT
4182 AC_SUBST(MOZ_OPTIMIZE)
4183 AC_SUBST(MOZ_FRAMEPTR_FLAGS)
4184 AC_SUBST(MOZ_OPTIMIZE_FLAGS)
4185 AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
4186 AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
4188 dnl ========================================================
4189 dnl = Enable NS_StackWalk.
4190 dnl ========================================================
4192 # On Windows, NS_StackWalk will only work correctly if we have frame pointers
4193 # available. That will only be true for non-optimized builds, debug builds or
4194 # builds with --enable-profiling in the .mozconfig (which is turned on in
4195 # Nightly by default.)
4196 case "$OS_TARGET" in
4197 WINNT)
4198     if test -z "$MOZ_OPTIMIZE" -o -n "$MOZ_PROFILING" -o -n "$MOZ_DEBUG"; then
4199         MOZ_STACKWALKING=1
4200     else
4201         MOZ_STACKWALKING=
4202     fi
4203     ;;
4205     MOZ_STACKWALKING=1
4206     ;;
4207 esac
4209 if test -n "$MOZ_STACKWALKING"; then
4210     AC_DEFINE(MOZ_STACKWALKING)
4213 AC_SUBST(MOZ_STACKWALKING)
4215 dnl ========================================================
4216 dnl = Disable treating compiler warnings as errors
4217 dnl ========================================================
4218 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
4219    WARNINGS_AS_ERRORS=''
4222 dnl ========================================================
4223 dnl = Enable runtime logging
4224 dnl ========================================================
4225 AC_DEFINE(MOZ_LOGGING)
4226 AC_DEFINE(FORCE_PR_LOG)
4228 dnl ========================================================
4229 dnl = This will enable logging of addref, release, ctor, dtor.
4230 dnl ========================================================
4231 _ENABLE_LOGREFCNT=42
4232 MOZ_ARG_ENABLE_BOOL(logrefcnt,
4233 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
4234     _ENABLE_LOGREFCNT=1,
4235     _ENABLE_LOGREFCNT= )
4236 if test "$_ENABLE_LOGREFCNT" = "1"; then
4237     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
4238 elif test -z "$_ENABLE_LOGREFCNT"; then
4239     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
4242 dnl ========================================================
4243 dnl moz_dump_painting
4244 dnl ========================================================
4245 MOZ_ARG_ENABLE_BOOL(dump-painting,
4246 [  --enable-dump-painting          Enable paint debugging.],
4247     MOZ_DUMP_PAINTING=1,
4248     MOZ_DUMP_PAINTING= )
4249 if test -n "$MOZ_DUMP_PAINTING"; then
4250     AC_DEFINE(MOZ_DUMP_PAINTING)
4251     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
4253 if test -n "$MOZ_DEBUG"; then
4254     AC_DEFINE(MOZ_DUMP_PAINTING)
4257 case "${OS_TARGET}" in
4258 Android|WINNT|Darwin)
4259   MOZ_GLUE_IN_PROGRAM=
4260   ;;
4262   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
4263   MOZ_GLUE_IN_PROGRAM=1
4264   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
4265   ;;
4266 esac
4268 if test -n "$MOZ_REPLACE_MALLOC"; then
4269     MOZ_SYSTEM_JEMALLOC=
4271     dnl Replace-malloc Mac linkage quirks
4272     if test -n "$MACOSX_DEPLOYMENT_TARGET"; then
4273         AC_CACHE_CHECK([how to do weak dynamic linking],
4274             ac_cv_weak_dynamic_linking,
4275             [echo 'extern void foo() __attribute__((weak_import));int bar() { if (foo) foo(); return 0; }' > conftest.c
4276              if AC_TRY_COMMAND([${CC-cc} -o conftest${DLL_SUFFIX} $CFLAGS -dynamiclib $LDFLAGS -Wl,-U,_foo conftest.c $LIBS 1>&5]) &&
4277                 test -s conftest${DLL_SUFFIX}; then
4278                  dnl There are several ways the linker can put link edit rules in a binary:
4279                  dnl - classic info only (for OSX < 10.6)
4280                  dnl - dyld info only
4281                  dnl - both
4282                  if "$OTOOL" -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO_ONLY" > /dev/null; then
4283                      _CLASSIC_INFO=
4284                  else
4285                      _CLASSIC_INFO=1
4286                  fi
4287                  if "$OTOOL" -l conftest${DLL_SUFFIX} 2> /dev/null | grep "LC_DYLD_INFO" > /dev/null; then
4288                      _DYLD_INFO=1
4289                  else
4290                      _DYLD_INFO=
4291                  fi
4292                  dnl With classic info, we need to build with -flat_namespace.
4293                  dnl With dyld info, Xcode 4.5 does the right thing without additional flags,
4294                  dnl but Xcode < 4.5 requires a dummy library and -flat_namespace because it
4295                  dnl forgets to set the weak flag in the dyld info.
4296                  dnl See http://glandium.org/blog/?p=2764 for more details.
4297                  dnl
4298                  dnl Values for ac_cv_weak_dynamic_linking, and subsequently
4299                  dnl MOZ_REPLACE_MALLOC_LINKAGE are thus:
4300                  dnl - "flat namespace" when -flat_namespace alone is needed
4301                  dnl - "dummy library" when a dummy library and -flat_namespace are needed
4302                  dnl - "compiler support" when nothing is needed
4303                  if test -n "$_DYLD_INFO" && dyldinfo -bind conftest${DLL_SUFFIX} 2> /dev/null | grep "_foo (weak import)" > /dev/null; then
4304                      if test -n "$_CLASSIC_INFO"; then
4305                          ac_cv_weak_dynamic_linking="flat namespace"
4306                      else
4307                          ac_cv_weak_dynamic_linking="compiler support"
4308                      fi
4309                  else
4310                      if test -n "$_DYLD_INFO"; then
4311                          ac_cv_weak_dynamic_linking="dummy library"
4312                      else
4313                          ac_cv_weak_dynamic_linking="flat namespace"
4314                      fi
4315                  fi
4316              else
4317                  AC_ERROR([couldn't compile a simple C file])
4318              fi
4319              rm -rf conftest*])
4320         MOZ_REPLACE_MALLOC_LINKAGE="$ac_cv_weak_dynamic_linking"
4321     fi
4323 AC_SUBST(MOZ_REPLACE_MALLOC_LINKAGE)
4325 dnl ========================================================
4326 dnl = Jemalloc build setup
4327 dnl ========================================================
4328 if test -z "$MOZ_MEMORY"; then
4329   case "${target}" in
4330     *-mingw*)
4331       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
4332         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.])
4333       fi
4334       ;;
4335   esac
4336 else
4337   if test -n "$MOZ_JEMALLOC4" -a -z "$MOZ_REPLACE_MALLOC"; then
4338     MOZ_SYSTEM_JEMALLOC=1
4339     AC_CHECK_FUNCS(mallctl nallocx,,
4340       [MOZ_SYSTEM_JEMALLOC=
4341        break])
4342     if test -n "$MOZ_SYSTEM_JEMALLOC"; then
4343       AC_DEFINE(MOZ_SYSTEM_JEMALLOC)
4344     fi
4345   fi
4346   if test "x$MOZ_DEBUG" = "x1"; then
4347     AC_DEFINE(MOZ_MEMORY_DEBUG)
4348   fi
4349   dnl The generic feature tests that determine how to compute ncpus are long and
4350   dnl complicated.  Therefore, simply define special cpp variables for the
4351   dnl platforms we have special knowledge of.
4352   case "${target}" in
4353   *-mingw*)
4354     export MOZ_NO_DEBUG_RTL=1
4355     ;;
4356   esac
4357 fi # MOZ_MEMORY
4358 AC_SUBST(MOZ_SYSTEM_JEMALLOC)
4359 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
4361 # Allow the application to provide a subconfigure script.
4362 # This should be after 'export MOZ_NO_DEBUG_RTL=1' since
4363 # ldap/c-sdk/configure refers to the enviroment value.
4364 if test -f "${srcdir}/${MOZ_BUILD_APP}/configure.in" ; then
4365   do_output_subdirs() {
4366     if test -n "$_subconfigure_subdirs"; then
4367       AC_MSG_ERROR([Cannot specify more than one sub-sub-configure])
4368      fi
4369     _subconfigure_subdir="$1"
4370     _subconfigure_config_args="$ac_configure_args"
4371   }
4372   tmpscript=`$PYTHON -c 'import os, tempfile; print tempfile.mktemp(prefix="subscript.").replace(os.sep, "/")'` || exit 1
4373   m4 "${srcdir}/build/autoconf/subconfigure.m4" \
4374      "${srcdir}/build/autoconf/altoptions.m4" \
4375      "${srcdir}/${MOZ_BUILD_APP}/configure.in" > $tmpscript
4376   . $tmpscript
4377   rm -f $tmpscript
4380 AC_SUBST_LIST(MOZ_GLUE_WRAP_LDFLAGS)
4381 export MOZ_GLUE_WRAP_LDFLAGS
4383 dnl ========================================================
4384 dnl = Enable using the clang plugin to build
4385 dnl ========================================================
4387 MOZ_CONFIG_CLANG_PLUGIN
4389 dnl ========================================================
4390 dnl = Enable stripping of libs & executables
4391 dnl ========================================================
4392 MOZ_ARG_ENABLE_BOOL(strip,
4393 [  --enable-strip          Enable stripping of libs & executables ],
4394     ENABLE_STRIP=1,
4395     ENABLE_STRIP= )
4397 dnl ========================================================
4398 dnl = Enable stripping of libs & executables when packaging
4399 dnl ========================================================
4400 MOZ_ARG_ENABLE_BOOL(install-strip,
4401 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
4402     PKG_SKIP_STRIP= ,
4403     PKG_SKIP_STRIP=1)
4405 dnl ========================================================
4406 dnl = --disable-elf-hack
4407 dnl ========================================================
4409 USE_ELF_HACK=1
4410 MOZ_ARG_DISABLE_BOOL(elf-hack,
4411 [  --disable-elf-hack      Disable elf hacks],
4412     [USE_ELF_HACK=],
4413     [USE_ELF_HACK=1])
4415 # Only enable elfhack where supported
4416 if test "$USE_ELF_HACK" = 1; then
4417     case "${HOST_OS_ARCH},${OS_ARCH}" in
4418     Linux,Linux)
4419         case "${CPU_ARCH}" in
4420         arm | x86 | x86_64)
4421             USE_ELF_HACK=1
4422             ;;
4423         *)
4424             USE_ELF_HACK=
4425             ;;
4426         esac
4427         ;;
4428     *)
4429         USE_ELF_HACK=
4430         ;;
4431     esac
4434 if test -n "$COMPILE_ENVIRONMENT" -a -n "$USE_ELF_HACK"; then
4435     dnl PT_GNU_RELRO segment makes the dynamic linker set a read-only flag on
4436     dnl memory addresses it maps to. The result is that by the time elfhack
4437     dnl kicks in, it is not possible to apply relocations because of that,
4438     dnl thus elfhack effectively skips relocations inside the PT_GNU_RELRO
4439     dnl segment. It makes elfhack mostly useless, so considering the problems
4440     dnl we have we PT_GNU_RELRO (e.g. bug 664366), and until elfhack can deal
4441     dnl with PT_GNU_RELRO segments, it's just simpler to disable elfhack when
4442     dnl the linker creates PT_GNU_RELRO segments. However, when we do want
4443     dnl elfhack enabled, disable PT_GNU_RELRO instead.
4444     AC_CACHE_CHECK([whether linker creates PT_GNU_RELRO segments],
4445         LINK_WITH_PT_GNU_RELRO,
4446         [echo "int main() {return 0;}" > conftest.${ac_ext}
4447          if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.${ac_ext} $LIBS 1>&2) &&
4448             test -s conftest${ac_exeext}; then
4449             if ${TOOLCHAIN_PREFIX}readelf -l conftest${ac_exeext} | grep GNU_RELRO > /dev/null; then
4450                 LINK_WITH_PT_GNU_RELRO=yes
4451             else
4452                 LINK_WITH_PT_GNU_RELRO=no
4453             fi
4454          else
4455              dnl We really don't expect to get here, but just in case
4456              AC_ERROR([couldn't compile a simple C file])
4457          fi
4458          rm -rf conftest*])
4459     if test "$LINK_WITH_PT_GNU_RELRO" = yes; then
4460         if test "$USE_ELF_HACK" = F; then
4461             AC_MSG_CHECKING([for -z norelro option to ld])
4462             _SAVE_LDFLAGS=$LDFLAGS
4463             LDFLAGS="$LDFLAGS -Wl,-z,norelro"
4464             AC_TRY_LINK(,,AC_MSG_RESULT([yes])
4465                         [NSPR_LDFLAGS="$NSPR_LDFLAGS -Wl,-z,norelro"],
4466                         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.]))
4467             USE_ELF_HACK=1
4468         else
4469             AC_MSG_WARN([Disabling elfhack])
4470             USE_ELF_HACK=
4471         fi
4472     fi
4473 fi # COMPILE_ENVIRONMENT and others.
4475 dnl ========================================================
4476 dnl = libstdc++ compatibility hacks
4477 dnl ========================================================
4479 STDCXX_COMPAT=
4480 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
4481 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
4482     STDCXX_COMPAT=1)
4484 if test -n "$STDCXX_COMPAT"; then
4485    eval $(CXX="$CXX" HOST_CXX="$HOST_CXX" $PYTHON -m mozbuild.configure.libstdcxx)
4486    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
4487    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
4488    CXXFLAGS="$CXXFLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
4489    HOST_CXXFLAGS="$HOST_CXXFLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
4492 dnl ========================================================
4493 dnl = frontend JS debug mode
4494 dnl ========================================================
4496 MOZ_ARG_ENABLE_BOOL(debug-js-modules,
4497 [  --enable-debug-js-modules  Enable debug mode for frontend JS libraries],
4498    DEBUG_JS_MODULES=1,
4499    DEBUG_JS_MODULES=)
4501 AC_SUBST(DEBUG_JS_MODULES)
4503 dnl ========================================================
4504 dnl =
4505 dnl = Profiling and Instrumenting
4506 dnl =
4507 dnl ========================================================
4508 MOZ_ARG_HEADER(Profiling and Instrumenting)
4510 dnl ========================================================
4511 dnl = Enable TaskTracer
4512 dnl ========================================================
4513 MOZ_ARG_ENABLE_BOOL(tasktracer,
4514 [  --enable-tasktracer       Set compile flags necessary for using TaskTracer],
4515     MOZ_TASK_TRACER=1,
4516     MOZ_TASK_TRACER= )
4517 if test -n "$MOZ_TASK_TRACER"; then
4518     AC_DEFINE(MOZ_TASK_TRACER)
4519     AC_SUBST(MOZ_TASK_TRACER)
4522 dnl ========================================================
4523 dnl Turn on reflow counting
4524 dnl ========================================================
4525 MOZ_ARG_ENABLE_BOOL(reflow-perf,
4526 [  --enable-reflow-perf    Enable reflow performance tracing],
4527     MOZ_REFLOW_PERF=1,
4528     MOZ_REFLOW_PERF= )
4529 if test -n "$MOZ_REFLOW_PERF"; then
4530     AC_DEFINE(MOZ_REFLOW_PERF)
4533 dnl ========================================================
4534 dnl = Horizon build options - set default preferences for
4535 dnl   the horizon project. Horizon is a browser built on
4536 dnl   top of the graphene runtime.
4537 dnl ========================================================
4538 if test -n "$MOZ_HORIZON"; then
4539     AC_DEFINE(MOZ_HORIZON)
4541 AC_SUBST(MOZ_HORIZON)
4543 dnl ========================================================
4544 dnl = Offer a way to disable the startup cache
4545 dnl ========================================================
4547 MOZ_ARG_DISABLE_BOOL(startupcache,
4548 [  --disable-startupcache          Disable startup cache ],
4549     MOZ_DISABLE_STARTUPCACHE=1,
4550     MOZ_DISABLE_STARTUPCACHE=)
4552 dnl bug 988880: disable startup cache on b2g
4553 if test -n "$MOZ_B2G"; then
4554   MOZ_DISABLE_STARTUPCACHE=1
4556 if test -n "$MOZ_DISABLE_STARTUPCACHE"; then
4557   AC_DEFINE(MOZ_DISABLE_STARTUPCACHE)
4559 AC_SUBST(MOZ_DISABLE_STARTUPCACHE)
4561 dnl =========================================
4562 dnl = Enable packaging Gaia with B2G desktop
4563 dnl =========================================
4564 if test x"$MOZ_WIDGET_TOOLKIT" != x"gonk"; then
4565     if test -n "$GAIADIR" -a ! -d "$GAIADIR" ; then
4566         AC_MSG_ERROR([GAIADIR '$GAIADIR' isn't a valid directory])
4567     fi
4569     AC_SUBST(GAIADIR)
4570     if test -n "$GAIADIR" ; then
4571         AC_DEFINE(PACKAGE_GAIA)
4572     fi
4574     if test -n "$FXOS_SIMULATOR" -a -z "$GAIADIR" ; then
4575         AC_MSG_ERROR([FXOS_SIMULATOR=1 requires GAIADIR to be defined])
4576     fi
4578     if test -n "$FXOS_SIMULATOR" ; then
4579         AC_DEFINE(FXOS_SIMULATOR)
4580         AC_SUBST(FXOS_SIMULATOR)
4581     fi
4584 dnl ========================================================
4585 dnl = Enable Pico Speech Synthesis (Gonk usually)
4586 dnl ========================================================
4587 MOZ_ARG_ENABLE_BOOL(synth-pico,
4588 [  --enable-synth-pico  Set compile flags necessary for compiling Pico Web Speech API ],
4589     MOZ_SYNTH_PICO=1,
4590     MOZ_SYNTH_PICO= )
4591 if test -n "$MOZ_SYNTH_PICO"; then
4592     AC_DEFINE(MOZ_SYNTH_PICO)
4594 AC_SUBST(MOZ_SYNTH_PICO)
4596 dnl ========================================================
4597 dnl = Enable Support for Time Manager API
4598 dnl ========================================================
4599 if test -n "$MOZ_TIME_MANAGER"; then
4600     AC_DEFINE(MOZ_TIME_MANAGER)
4602 AC_SUBST(MOZ_TIME_MANAGER)
4604 dnl ========================================================
4605 dnl = Enable Support for AudioChannelManager API
4606 dnl ========================================================
4607 if test -n "$MOZ_AUDIO_CHANNEL_MANAGER"; then
4608     AC_DEFINE(MOZ_AUDIO_CHANNEL_MANAGER)
4610 AC_SUBST(MOZ_AUDIO_CHANNEL_MANAGER)
4612 dnl ========================================================
4613 dnl = Enable Support for Secure Element API
4614 dnl ========================================================
4615    MOZ_SECUREELEMENT=1,
4616 if test -n "$MOZ_SECUREELEMENT"; then
4617    AC_DEFINE(MOZ_SECUREELEMENT)
4619  AC_SUBST(MOZ_SECUREELEMENT)
4621 dnl ========================================================
4622 dnl = Support for demangling undefined symbols
4623 dnl ========================================================
4624 if test -z "$SKIP_LIBRARY_CHECKS"; then
4625     AC_LANG_SAVE
4626     AC_LANG_CPLUSPLUS
4627     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
4628     AC_LANG_RESTORE
4631 # Demangle only for debug or DMD builds
4632 MOZ_DEMANGLE_SYMBOLS=
4633 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
4634     MOZ_DEMANGLE_SYMBOLS=1
4635     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
4637 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
4639 dnl ========================================================
4640 dnl = Support for gcc stack unwinding (from gcc 3.3)
4641 dnl ========================================================
4642 if test -z "$SKIP_LIBRARY_CHECKS"; then
4643     AC_LANG_SAVE
4644     AC_LANG_CPLUSPLUS
4645     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
4646     AC_LANG_RESTORE
4649 dnl ========================================================
4650 dnl JIT observers
4651 dnl ========================================================
4653 MOZ_ARG_WITH_STRING(jitreport-granularity,
4654 [  --jitreport-granularity=N
4655                            Default granularity at which to report JIT code
4656                            to external tools
4657                              0 - no info
4658                              1 - code ranges for whole functions only
4659                              2 - per-line information
4660                              3 - per-op information],
4661   JITREPORT_GRANULARITY=$withval,
4662   JITREPORT_GRANULARITY=3)
4664 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
4666 dnl ========================================================
4667 dnl = Disable Mozilla's versions of RIL and Geolocation
4668 dnl ========================================================
4669 MOZ_ARG_DISABLE_BOOL(mozril-geoloc,
4670 [  --disable-mozril-geoloc         Disable Mozilla's RIL and geolocation],
4671     DISABLE_MOZ_RIL_GEOLOC=1,
4672     DISABLE_MOZ_RIL_GEOLOC= )
4673 if test -n "$DISABLE_MOZ_RIL_GEOLOC"; then
4674    AC_DEFINE(DISABLE_MOZ_RIL_GEOLOC)
4676 AC_SUBST(DISABLE_MOZ_RIL_GEOLOC)
4678 dnl ========================================================
4679 dnl =
4680 dnl = Misc. Options
4681 dnl =
4682 dnl ========================================================
4683 MOZ_ARG_HEADER(Misc. Options)
4685 dnl ========================================================
4686 dnl = Define default location for MOZILLA_FIVE_HOME
4687 dnl ========================================================
4688 MOZ_ARG_WITH_STRING(default-mozilla-five-home,
4689 [  --with-default-mozilla-five-home
4690                           Set the default value for MOZILLA_FIVE_HOME],
4691 [ val=`echo $withval`
4692   AC_DEFINE_UNQUOTED(MOZ_DEFAULT_MOZILLA_FIVE_HOME,"$val") ])
4694 dnl ========================================================
4695 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
4696 dnl ========================================================
4697 MOZ_ARG_WITH_STRING(user-appdir,
4698 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
4699 [ val=`echo $withval`
4700 if echo "$val" | grep "\/" >/dev/null; then
4701     AC_MSG_ERROR("Homedir must be single relative path.")
4702 else
4703     MOZ_USER_DIR="$val"
4704 fi])
4706 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
4708 dnl ========================================================
4709 dnl = Doxygen configuration
4710 dnl ========================================================
4711 dnl Use commas to specify multiple dirs to this arg
4712 MOZ_DOC_INPUT_DIRS='./dist/include ./dist/idl'
4713 MOZ_ARG_WITH_STRING(doc-input-dirs,
4714 [  --with-doc-input-dirs=DIRS
4715                           Header/idl dirs to create docs from],
4716 [ MOZ_DOC_INPUT_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
4717 AC_SUBST(MOZ_DOC_INPUT_DIRS)
4719 dnl Use commas to specify multiple dirs to this arg
4720 MOZ_DOC_INCLUDE_DIRS='./dist/include ./dist/include/nspr'
4721 MOZ_ARG_WITH_STRING(doc-include-dirs,
4722 [  --with-doc-include-dirs=DIRS
4723                           Include dirs to preprocess doc headers],
4724 [ MOZ_DOC_INCLUDE_DIRS=`echo "$withval" | sed "s/,/ /g"` ] )
4725 AC_SUBST(MOZ_DOC_INCLUDE_DIRS)
4727 MOZ_DOC_OUTPUT_DIR='./dist/docs'
4728 MOZ_ARG_WITH_STRING(doc-output-dir,
4729 [  --with-doc-output-dir=DIR
4730                           Dir to generate docs into],
4731 [ MOZ_DOC_OUTPUT_DIR=$withval ] )
4732 AC_SUBST(MOZ_DOC_OUTPUT_DIR)
4734 if test -z "$SKIP_COMPILER_CHECKS"; then
4735 dnl ========================================================
4736 dnl =
4737 dnl = Compiler Options
4738 dnl =
4739 dnl ========================================================
4740 MOZ_ARG_HEADER(Compiler Options)
4742 dnl ========================================================
4743 dnl Check for gcc -pipe support
4744 dnl ========================================================
4745 AC_MSG_CHECKING([for -pipe support])
4746 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
4747     dnl Any gcc that supports firefox supports -pipe.
4748     CFLAGS="$CFLAGS -pipe"
4749     CXXFLAGS="$CXXFLAGS -pipe"
4750     AC_MSG_RESULT([yes])
4751 else
4752     AC_MSG_RESULT([no])
4755 dnl ========================================================
4756 dnl Profile guided optimization (gcc checks)
4757 dnl ========================================================
4758 dnl Test for profiling options
4759 dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
4761 _SAVE_CFLAGS="$CFLAGS"
4762 CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
4764 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
4765 AC_TRY_COMPILE([], [return 0;],
4766                [ PROFILE_GEN_CFLAGS="-fprofile-generate"
4767                  result="yes" ], result="no")
4768 AC_MSG_RESULT([$result])
4770 if test $result = "yes"; then
4771   PROFILE_GEN_LDFLAGS="-fprofile-generate"
4772   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
4773   PROFILE_USE_LDFLAGS="-fprofile-use"
4776 CFLAGS="$_SAVE_CFLAGS"
4778 AC_SUBST(PROFILE_GEN_CFLAGS)
4779 AC_SUBST(PROFILE_GEN_LDFLAGS)
4780 AC_SUBST(PROFILE_USE_CFLAGS)
4781 AC_SUBST(PROFILE_USE_LDFLAGS)
4783 fi # ! SKIP_COMPILER_CHECKS
4785 AC_DEFINE(CPP_THROW_NEW, [throw()])
4786 AC_LANG_C
4788 if test "$COMPILE_ENVIRONMENT"; then
4789 MOZ_EXPAND_LIBS
4790 fi # COMPILE_ENVIRONMENT
4792 dnl ========================================================
4793 dnl =
4794 dnl = Build depencency options
4795 dnl =
4796 dnl ========================================================
4797 MOZ_ARG_HEADER(Build dependencies)
4799 if test "$GNU_CC" -a "$GNU_CXX"; then
4800   _DEPEND_CFLAGS='-MD -MP -MF $(MDDEPDIR)/$(@F).pp'
4801 else
4802   dnl Don't override this for MSVC
4803   if test -z "$_WIN32_MSVC"; then
4804     _USE_CPP_INCLUDE_FLAG=
4805     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
4806     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
4807   else
4808     echo '#include <stdio.h>' > dummy-hello.c
4809     changequote(,)
4810     dnl This output is localized, split at the first double space or colon and space.
4811     _CL_PREFIX_REGEX="^\([^:]*:.*[ :] \)\(.*\\\stdio.h\)$"
4812     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\1/p'`
4813     _CL_STDIO_PATH=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/'"$_CL_PREFIX_REGEX"'/\2/p'`
4814     changequote([,])
4815     if ! test -e "$_CL_STDIO_PATH"; then
4816         AC_MSG_ERROR([Unable to parse cl -showIncludes prefix. This compiler's locale has an unsupported formatting.])
4817     fi
4818     if test -z "$CL_INCLUDES_PREFIX"; then
4819         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
4820     fi
4821     AC_SUBST(CL_INCLUDES_PREFIX)
4822     rm -f dummy-hello.c
4824     dnl Make sure that the build system can handle non-ASCII characters
4825     dnl in environment variables to prevent it from breaking silently on
4826     dnl non-English systems.
4827     NONASCII=$'\241\241'
4828     AC_SUBST(NONASCII)
4829   fi
4832 dnl ========================================================
4833 dnl =
4834 dnl = Static Build Options
4835 dnl =
4836 dnl ========================================================
4837 MOZ_ARG_HEADER(Static build options)
4839 if test -z "$MOZ_SYSTEM_ZLIB"; then
4840 if test -n "$JS_SHARED_LIBRARY"; then
4841   ZLIB_IN_MOZGLUE=1
4842   AC_DEFINE(ZLIB_IN_MOZGLUE)
4846 AC_SUBST(ZLIB_IN_MOZGLUE)
4848 dnl ========================================================
4849 dnl =
4850 dnl = Standalone module options
4851 dnl =
4852 dnl ========================================================
4853 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
4855 dnl Check for GLib.
4856 dnl ========================================================
4858 if test -z "$SKIP_PATH_CHECKS"; then
4859 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
4860     if test "$MOZ_ENABLE_GTK" ; then
4861         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
4862     fi
4866 if test -z "${GLIB_GMODULE_LIBS}" \
4867    -a -n "${GLIB_CONFIG}"\
4868     -a "${GLIB_CONFIG}" != no\
4869 ; then
4870     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
4873 AC_SUBST_LIST(GLIB_GMODULE_LIBS)
4875 if test "$USE_FC_FREETYPE"; then
4876     if test "$COMPILE_ENVIRONMENT"; then
4877         dnl ========================================================
4878         dnl = Check for freetype2 functionality
4879         dnl ========================================================
4880         if test "$_HAVE_FREETYPE2" -a -z "$MOZ_TREE_FREETYPE"; then
4881             _SAVE_LIBS="$LIBS"
4882             _SAVE_CFLAGS="$CFLAGS"
4883             LIBS="$LIBS $FT2_LIBS"
4884             CFLAGS="$CFLAGS $FT2_CFLAGS"
4886             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
4887                 ac_cv_member_FT_Bitmap_Size_y_ppem,
4888                 [AC_TRY_COMPILE([#include <ft2build.h>
4889                                  #include FT_FREETYPE_H],
4890                                 [FT_Bitmap_Size s;
4891                                  if (sizeof s.y_ppem) return 0;
4892                                  return 1],
4893                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
4894                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
4895             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
4896                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
4897             else
4898                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
4899             fi
4900             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
4901                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
4902                                [FT_Bitmap_Size structure includes y_ppem field])
4904             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table)
4906             LIBS="$_SAVE_LIBS"
4907             CFLAGS="$_SAVE_CFLAGS"
4908         fi
4910         _SAVE_CPPFLAGS="$CPPFLAGS"
4911         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
4912         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
4913             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
4914         CPPFLAGS="$_SAVE_CPPFLAGS"
4915     fi
4918 dnl ========================================================
4919 dnl Check if we need the 32-bit Linux SSE2 error dialog
4920 dnl ========================================================
4922 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
4924 dnl ========================================================
4925 dnl Check for pixman and cairo
4926 dnl ========================================================
4928 MOZ_TREE_CAIRO=1
4929 MOZ_ARG_ENABLE_BOOL(system-cairo,
4930 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
4931 MOZ_TREE_CAIRO=,
4932 MOZ_TREE_CAIRO=1 )
4934 MOZ_TREE_PIXMAN=1
4935 MOZ_ARG_ENABLE_BOOL(system-pixman,
4936 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
4937 MOZ_TREE_PIXMAN=,
4938 MOZ_TREE_PIXMAN=force,
4939 MOZ_TREE_PIXMAN=1 )
4941 # System cairo depends on system pixman
4942 if test "$MOZ_TREE_PIXMAN" = "force"; then
4943     if test -z "$MOZ_TREE_CAIRO"; then
4944         AC_MSG_ERROR([--disable-system-pixman is incompatible with --enable-system-cairo.])
4945     else
4946         MOZ_TREE_PIXMAN=1
4947     fi
4948 elif test -z "$MOZ_TREE_CAIRO"; then
4949     MOZ_TREE_PIXMAN=
4952 if test "$MOZ_TREE_PIXMAN"; then
4953     AC_DEFINE(MOZ_TREE_PIXMAN)
4954 else
4955     PKG_CHECK_MODULES(MOZ_PIXMAN, pixman-1 >= 0.19.2)
4958 if test "$MOZ_TREE_CAIRO"; then
4959     MOZ_CAIRO_CFLAGS="-I${DIST}/include/cairo"
4960     AC_DEFINE(MOZ_TREE_CAIRO)
4962     if test "$OS_ARCH" = "WINNT"; then
4963         # For now we assume that we will have a uint64_t available through
4964         # one of the above headers or mozstdint.h.
4965         AC_DEFINE(HAVE_UINT64_T)
4966     fi
4968     # Define macros for cairo-features.h
4969     TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
4970     if test "$MOZ_X11"; then
4971         XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
4972         XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
4973         PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
4974     fi
4975     if test "$_HAVE_FREETYPE2"; then
4976         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
4977         MOZ_ENABLE_CAIRO_FT=1
4978         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
4979     fi
4981     case "$MOZ_WIDGET_TOOLKIT" in
4982       cocoa | uikit)
4983         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
4984         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
4985         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
4986         ;;
4987       windows)
4988         WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
4989         WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
4990         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
4991         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
4992         MOZ_ENABLE_D2D_SURFACE=1
4993         MOZ_ENABLE_DWRITE_FONT=1
4995         if test "$COMPILE_ENVIRONMENT"; then
4997           MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
4999           dnl D3D10 Layers depend on D2D Surfaces.
5000           if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
5001             MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
5002           fi
5003         fi
5004         ;;
5005     esac
5006     if test "$USE_FC_FREETYPE"; then
5007         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
5008     fi
5009     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
5010     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
5011     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
5012     AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
5013     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
5015     AC_SUBST(PS_SURFACE_FEATURE)
5016     AC_SUBST(SVG_SURFACE_FEATURE)
5017     AC_SUBST(XLIB_SURFACE_FEATURE)
5018     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
5019     AC_SUBST(QUARTZ_SURFACE_FEATURE)
5020     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
5021     AC_SUBST(WIN32_SURFACE_FEATURE)
5022     AC_SUBST(OS2_SURFACE_FEATURE)
5023     AC_SUBST(DIRECTFB_SURFACE_FEATURE)
5024     AC_SUBST(FT_FONT_FEATURE)
5025     AC_SUBST(FC_FONT_FEATURE)
5026     AC_SUBST(WIN32_FONT_FEATURE)
5027     AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
5028     AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
5029     AC_SUBST(QUARTZ_FONT_FEATURE)
5030     AC_SUBST(PNG_FUNCTIONS_FEATURE)
5031     AC_SUBST(QT_SURFACE_FEATURE)
5032     AC_SUBST(TEE_SURFACE_FEATURE)
5034     if test "$MOZ_X11"; then
5035         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
5036     fi
5038     CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
5039 else
5040     PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION)
5041     MOZ_CAIRO_CFLAGS="$CAIRO_CFLAGS"
5042     MOZ_CAIRO_LIBS="$CAIRO_LIBS"
5043     PKG_CHECK_MODULES(CAIRO_TEE, cairo-tee >= $CAIRO_VERSION)
5044     if test "$MOZ_X11"; then
5045         PKG_CHECK_MODULES(CAIRO_XRENDER, cairo-xlib-xrender >= $CAIRO_VERSION)
5046         MOZ_CAIRO_LIBS="$MOZ_CAIRO_LIBS $XLDFLAGS $CAIRO_XRENDER_LIBS"
5047         MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_LIBS"
5048         MOZ_CAIRO_CFLAGS="$MOZ_CAIRO_CFLAGS $CAIRO_XRENDER_CFLAGS"
5049     fi
5052 case "$MOZ_WIDGET_TOOLKIT" in
5053 android|gonk)
5054     TK_CFLAGS="$MOZ_CAIRO_CFLAGS $MOZ_PIXMAN_CFLAGS"
5055     TK_LIBS="$MOZ_CAIRO_LIBS $MOZ_PIXMAN_LIBS"
5056     ;;
5057 esac
5059 AC_SUBST(MOZ_TREE_CAIRO)
5060 AC_SUBST_LIST(MOZ_CAIRO_CFLAGS)
5061 AC_SUBST_LIST(MOZ_CAIRO_LIBS)
5062 AC_SUBST_LIST(MOZ_CAIRO_OSLIBS)
5063 AC_SUBST(MOZ_TREE_PIXMAN)
5065 dnl ========================================================
5066 dnl disable xul
5067 dnl ========================================================
5068 MOZ_ARG_DISABLE_BOOL(xul,
5069 [  --disable-xul           Disable XUL],
5070     MOZ_XUL= )
5071 if test "$MOZ_XUL"; then
5072   AC_DEFINE(MOZ_XUL)
5073 else
5074   dnl remove extensions that require XUL
5075   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/irc//' -e 's/tasks//'`
5078 AC_SUBST(MOZ_XUL)
5080 dnl ========================================================
5081 dnl necko configuration options
5082 dnl ========================================================
5085 dnl option to disable necko's wifi scanner
5088 case "$OS_TARGET" in
5089   Android)
5090     if test -n "$gonkdir"; then
5091       NECKO_WIFI=1
5092     fi
5093     ;;
5094   Darwin)
5095     if test -z "$MOZ_IOS"; then
5096       NECKO_WIFI=1
5097     fi
5098     ;;
5099   DragonFly|FreeBSD|WINNT)
5100     NECKO_WIFI=1
5101     ;;
5102   Linux)
5103     NECKO_WIFI=1
5104     NECKO_WIFI_DBUS=1
5105     ;;
5106 esac
5108 MOZ_ARG_DISABLE_BOOL(necko-wifi,
5109 [  --disable-necko-wifi    Disable necko wifi scanner],
5110     NECKO_WIFI=,
5111     NECKO_WIFI=1)
5113 if test "$NECKO_WIFI"; then
5114   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
5115     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
5116   fi
5117   AC_DEFINE(NECKO_WIFI)
5118   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
5120 AC_SUBST(NECKO_WIFI)
5121 AC_SUBST(NECKO_WIFI_DBUS)
5124 dnl option to disable cookies
5126 MOZ_ARG_DISABLE_BOOL(cookies,
5127 [  --disable-cookies       Disable cookie support],
5128     NECKO_COOKIES=,
5129     NECKO_COOKIES=1)
5130 AC_SUBST(NECKO_COOKIES)
5131 if test "$NECKO_COOKIES"; then
5132     AC_DEFINE(NECKO_COOKIES)
5133     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
5136 dnl ========================================================
5137 if test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
5138     MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
5141 dnl ========================================================
5142 dnl =
5143 dnl = Maintainer debug option (no --enable equivalent)
5144 dnl =
5145 dnl ========================================================
5147 AC_SUBST(AR)
5148 AC_SUBST(AR_FLAGS)
5149 AC_SUBST(AR_EXTRACT)
5150 AC_SUBST(AS)
5151 AC_SUBST(ASFLAGS)
5152 AC_SUBST(AS_DASH_C_FLAG)
5153 AC_SUBST(RC)
5154 AC_SUBST(RCFLAGS)
5155 AC_SUBST(WINDRES)
5156 AC_SUBST(IMPLIB)
5157 AC_SUBST(FILTER)
5158 AC_SUBST(BIN_FLAGS)
5159 AC_SUBST(MOZ_AUTH_EXTENSION)
5160 AC_SUBST(MOZ_PREF_EXTENSIONS)
5161 AC_SUBST(MOZ_DEBUG)
5162 AC_SUBST(MOZ_DEBUG_LDFLAGS)
5163 AC_SUBST(WARNINGS_AS_ERRORS)
5164 AC_SUBST_SET(MOZ_EXTENSIONS)
5165 AC_SUBST(LIBICONV)
5166 AC_SUBST(MOZ_TOOLKIT_SEARCH)
5167 AC_SUBST(MOZ_FEEDS)
5169 AC_SUBST(MOZ_UNIVERSALCHARDET)
5170 AC_SUBST(ACCESSIBILITY)
5171 AC_SUBST(MOZ_SPELLCHECK)
5172 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
5173 AC_SUBST(MOZ_CRASHREPORTER)
5174 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
5175 AC_SUBST(MOZ_MAINTENANCE_SERVICE)
5176 AC_SUBST(MOZ_STUB_INSTALLER)
5177 AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
5178 AC_SUBST(MOZ_ENABLE_SIGNMAR)
5179 AC_SUBST(MOZ_UPDATER)
5181 AC_SUBST(MOZ_ANGLE_RENDERER)
5182 AC_SUBST(MOZ_D3D_CPU_SUFFIX)
5183 AC_SUBST(MOZ_HAS_WINSDK_WITH_D3D)
5184 AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL)
5185 AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL_PATH)
5187 AC_SUBST(MOZ_ANDROID_APPLICATION_CLASS)
5188 AC_SUBST(MOZ_ANDROID_BROWSER_INTENT_CLASS)
5189 AC_SUBST(MOZ_ANDROID_SEARCH_INTENT_CLASS)
5190 AC_SUBST(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
5191 AC_SUBST(MOZ_INSTALL_TRACKING)
5192 AC_SUBST(ENABLE_STRIP)
5193 AC_SUBST(PKG_SKIP_STRIP)
5194 AC_SUBST(STRIP_FLAGS)
5195 AC_SUBST(USE_ELF_HACK)
5196 AC_SUBST(INCREMENTAL_LINKER)
5197 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
5199 AC_SUBST(MOZ_FIX_LINK_PATHS)
5201 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
5202 AC_SUBST(MOZ_LINKER_EXTRACT)
5204 if test -n "$MOZ_BINARY_EXTENSIONS"; then
5205   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
5208 AC_SUBST(MOZ_ADDON_SIGNING)
5209 if test "$MOZ_ADDON_SIGNING" = 1; then
5210   AC_DEFINE(MOZ_ADDON_SIGNING)
5212 AC_SUBST(MOZ_REQUIRE_SIGNING)
5213 if test "$MOZ_REQUIRE_SIGNING" = 1; then
5214   AC_DEFINE(MOZ_REQUIRE_SIGNING)
5217 AC_SUBST(MOZ_JSDOWNLOADS)
5218 if test -n "$MOZ_JSDOWNLOADS"; then
5219   AC_DEFINE(MOZ_JSDOWNLOADS)
5222 dnl ========================================================
5223 dnl = Mac bundle name prefix
5224 dnl ========================================================
5225 MOZ_ARG_WITH_STRING(macbundlename-prefix,
5226 [  --with-macbundlename-prefix=prefix
5227                           Prefix for MOZ_MACBUNDLE_NAME],
5228 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
5230 MOZ_MACBUNDLE_NAME=`echo $MOZ_APP_DISPLAYNAME | tr -d ' '`
5231 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
5232   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
5235 if test "$MOZ_DEBUG"; then
5236   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}Debug.app
5237 else
5238   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
5240 AC_SUBST(MOZ_MACBUNDLE_NAME)
5242 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
5243 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr '[A-Z]' '[a-z]'`
5244 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
5245 if test "$MOZ_DEBUG"; then
5246   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
5249 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
5250 AC_SUBST(MOZ_MACBUNDLE_ID)
5252 dnl ========================================================
5253 dnl = Child Process Name for IPC
5254 dnl ========================================================
5255 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
5256   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
5257 else
5258   # We want to let Android unpack the file at install time, but it only does
5259   # so if the file is named libsomething.so. The lib/ path is also required
5260   # because the unpacked file will be under the lib/ subdirectory and will
5261   # need to be executed from that path.
5262   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
5263   MOZ_CHILD_PROCESS_NAME_PIE="libplugin-container-pie.so"
5264   AC_SUBST(MOZ_CHILD_PROCESS_NAME_PIE)
5266 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
5268 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
5269 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
5271 # The following variables are available to branding and application
5272 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
5273 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
5274 # impacts profile location and user-visible fields.
5275 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
5276 # versions of a given application (e.g. Aurora and Firefox both use
5277 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
5278 # for application.ini's "Name" field, which controls profile location in
5279 # the absence of a "Profile" field (see below), and various system
5280 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
5281 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
5282 # Mac Bundle name, Updater, Installer), it is typically used for nightly
5283 # builds (e.g. Aurora for Firefox).
5284 # - MOZ_APP_VERSION: Defines the application version number.
5285 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
5286 # in the "About" window. If not set, defaults to MOZ_APP_VERSION.
5287 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
5288 # defaults to a lowercase form of MOZ_APP_BASENAME.
5289 # - MOZ_APP_REMOTINGNAME: Used for the internal program name, which affects
5290 # profile name and remoting. If not set, defaults to MOZ_APP_NAME.
5291 # - MOZ_APP_PROFILE: When set, used for application.ini's
5292 # "Profile" field, which controls profile location.
5293 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
5294 # crash reporter server url.
5295 # - MOZ_APP_ANDROID_VERSION_CODE: On Android, "android:versionCode" for
5296 # the main application is set to the value of this variable.  If not
5297 # set, it falls back to a Mozilla-specific value derived from the
5298 # build ID.
5299 # - MOZ_ANDROID_SHARED_ID: On Android, "android:sharedUserId" for all Android
5300 # packages produced.
5301 # - MOZ_ANDROID_GCM_SENDERID: On Android, the Android GCM Sender ID used.  GCM
5302 # sender IDs are not sensitive: see, http://stackoverflow.com/a/18216063.
5303 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
5305 if test -z "$MOZ_APP_NAME"; then
5306    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
5309 if test -z "$MOZ_APP_REMOTINGNAME"; then
5310    MOZ_APP_REMOTINGNAME=$MOZ_APP_NAME
5313 if test -z "$MOZ_APP_VERSION_DISPLAY"; then
5314    MOZ_APP_VERSION_DISPLAY=$MOZ_APP_VERSION
5317 if test -z "$ANDROID_PACKAGE_NAME" ; then
5318    ANDROID_PACKAGE_NAME="org.mozilla.$MOZ_APP_NAME"
5321 # Mozilla released Firefox for Android {Release,Beta} and {Aurora,Nightly} to
5322 # the public with specific common shared IDs and we need to keep them
5323 # consistent forever.  The specific common values are set by per-channel
5324 # branding; all other channels use a generic sharedID, set below.
5325 if test -z "$MOZ_ANDROID_SHARED_ID" ; then
5326    MOZ_ANDROID_SHARED_ID="${ANDROID_PACKAGE_NAME}.sharedID"
5329 # For extensions and langpacks, we require a max version that is compatible
5330 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
5331 # 24.0a1 and 24.0a2 aren't affected
5332 # 24.0 becomes 24.*
5333 # 24.1.1 becomes 24.*
5334 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
5335 if test -z "$IS_ALPHA"; then
5336   changequote(,)
5337   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
5338     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
5339   else
5340     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
5341   fi
5342   changequote([,])
5343 else
5344   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
5347 MOZ_B2G_VERSION=${MOZ_B2G_VERSION:-"1.0.0"}
5348 AC_DEFINE_UNQUOTED(MOZ_B2G_VERSION,"$MOZ_B2G_VERSION")
5349 AC_DEFINE_UNQUOTED(MOZ_B2G_OS_NAME,"$MOZ_B2G_OS_NAME")
5351 AC_SUBST(MOZ_APP_NAME)
5352 AC_SUBST(MOZ_APP_REMOTINGNAME)
5353 AC_SUBST(MOZ_APP_DISPLAYNAME)
5354 AC_SUBST(MOZ_APP_BASENAME)
5355 AC_SUBST(MOZ_APP_VENDOR)
5356 AC_SUBST(MOZ_APP_PROFILE)
5357 AC_SUBST(MOZ_APP_ID)
5358 AC_SUBST(MOZ_APP_ANDROID_VERSION_CODE)
5359 AC_SUBST(MOZ_ANDROID_SHARED_ID)
5360 AC_SUBST(MOZ_ANDROID_GCM_SENDERID)
5361 AC_SUBST(MAR_CHANNEL_ID)
5362 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
5363 AC_SUBST(MOZ_PROFILE_MIGRATOR)
5364 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
5365 AC_SUBST(MOZ_APP_UA_NAME)
5366 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
5367 AC_SUBST(MOZ_APP_VERSION)
5368 AC_SUBST(MOZ_APP_VERSION_DISPLAY)
5369 AC_SUBST(MOZ_APP_MAXVERSION)
5370 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
5371 AC_SUBST(FIREFOX_VERSION)
5372 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
5373 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
5374   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
5377 AC_SUBST(MOZ_APP_STATIC_INI)
5379 AC_SUBST(MOZ_PKG_SPECIAL)
5380 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
5382 AC_SUBST(MOZILLA_OFFICIAL)
5383 if test "$MOZILLA_OFFICIAL"; then
5384     AC_DEFINE(MOZILLA_OFFICIAL)
5385     # Build revisions should always be present in official builds
5386     MOZ_INCLUDE_SOURCE_INFO=1
5389 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
5390 # explicitly set the repository and changeset information in.
5391 AC_SUBST(MOZ_SOURCE_REPO)
5392 AC_SUBST(MOZ_SOURCE_CHANGESET)
5393 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
5395 if test "$MOZ_TELEMETRY_REPORTING"; then
5396     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
5398     # Enable Telemetry by default for nightly and aurora channels
5399     if test -z "$RELEASE_OR_BETA"; then
5400       AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
5401     fi
5404 dnl If we have any service that uploads data (and requires data submission
5405 dnl policy alert), set MOZ_DATA_REPORTING.
5406 dnl We need SUBST for build system and DEFINE for xul preprocessor.
5407 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"; then
5408   MOZ_DATA_REPORTING=1
5409   AC_DEFINE(MOZ_DATA_REPORTING)
5410   AC_SUBST(MOZ_DATA_REPORTING)
5413 dnl win32 options
5414 AC_SUBST(WIN32_REDIST_DIR)
5415 AC_SUBST(WIN_UCRT_REDIST_DIR)
5417 dnl ========================================================
5418 dnl ICU Support
5419 dnl ========================================================
5421 # Internationalization is not built or exposed on Fennec.
5422 # See Bug 1215256
5424 if test "$MOZ_BUILD_APP" = "mobile/android"; then
5425     _INTL_API=no
5426 else
5427     _INTL_API=yes
5430 if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
5431     USE_ICU=1
5434 MOZ_CONFIG_ICU()
5436 dnl Echo the CFLAGS to remove extra whitespace.
5437 CFLAGS=`echo \
5438     $_WARNINGS_CFLAGS \
5439     $CFLAGS`
5441 CXXFLAGS=`echo \
5442     $_WARNINGS_CXXFLAGS \
5443     $CXXFLAGS`
5445 COMPILE_CFLAGS=`echo \
5446     $_DEFINES_CFLAGS \
5447     $COMPILE_CFLAGS`
5449 COMPILE_CXXFLAGS=`echo \
5450     $_DEFINES_CXXFLAGS \
5451     $COMPILE_CXXFLAGS`
5453 HOST_CFLAGS=`echo \
5454     $HOST_CFLAGS`
5456 HOST_CXXFLAGS=`echo \
5457     $HOST_CXXFLAGS`
5459 AC_SUBST(_DEPEND_CFLAGS)
5460 AC_SUBST(MOZ_SYSTEM_JPEG)
5461 AC_SUBST(MOZ_SYSTEM_PNG)
5462 AC_SUBST(MOZ_SYSTEM_BZ2)
5464 AC_SUBST_LIST(MOZ_JPEG_CFLAGS)
5465 AC_SUBST_LIST(MOZ_JPEG_LIBS)
5466 AC_SUBST_LIST(MOZ_BZ2_CFLAGS)
5467 AC_SUBST_LIST(MOZ_BZ2_LIBS)
5468 AC_SUBST_LIST(MOZ_PNG_CFLAGS)
5469 AC_SUBST_LIST(MOZ_PNG_LIBS)
5471 AC_SUBST(MOZ_SYSTEM_NSPR)
5473 AC_SUBST(MOZ_SYSTEM_NSS)
5475 HOST_CMFLAGS=-fobjc-exceptions
5476 HOST_CMMFLAGS=-fobjc-exceptions
5477 OS_COMPILE_CMFLAGS=-fobjc-exceptions
5478 OS_COMPILE_CMMFLAGS=-fobjc-exceptions
5479 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
5480   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
5481   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
5483 AC_SUBST(HOST_CMFLAGS)
5484 AC_SUBST(HOST_CMMFLAGS)
5485 AC_SUBST(OS_COMPILE_CMFLAGS)
5486 AC_SUBST(OS_COMPILE_CMMFLAGS)
5488 OS_CFLAGS="$CFLAGS"
5489 OS_CXXFLAGS="$CXXFLAGS"
5490 OS_CPPFLAGS="$CPPFLAGS"
5491 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
5492 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
5493 OS_LDFLAGS="$LDFLAGS"
5494 OS_LIBS="$LIBS"
5495 AC_SUBST(OS_CFLAGS)
5496 AC_SUBST(OS_CXXFLAGS)
5497 AC_SUBST(OS_CPPFLAGS)
5498 AC_SUBST(OS_COMPILE_CFLAGS)
5499 AC_SUBST(OS_COMPILE_CXXFLAGS)
5500 AC_SUBST(OS_LDFLAGS)
5501 AC_SUBST(OS_LIBS)
5503 AC_SUBST(HOST_CC)
5504 AC_SUBST(HOST_CXX)
5505 AC_SUBST(HOST_CFLAGS)
5506 AC_SUBST(HOST_CPPFLAGS)
5507 AC_SUBST(HOST_CXXFLAGS)
5508 AC_SUBST(HOST_LDFLAGS)
5509 AC_SUBST(HOST_OPTIMIZE_FLAGS)
5510 AC_SUBST(HOST_AR)
5511 AC_SUBST(HOST_AR_FLAGS)
5512 AC_SUBST(HOST_RANLIB)
5513 AC_SUBST(HOST_BIN_SUFFIX)
5515 AC_SUBST(TARGET_XPCOM_ABI)
5516 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
5517 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
5518 AC_SUBST(HAVE_X86_AVX2)
5519 AC_SUBST(HAVE_ALTIVEC)
5520 AC_SUBST(GCC_USE_GNU_LD)
5522 AC_SUBST(WRAP_LDFLAGS)
5523 AC_SUBST(MKSHLIB)
5524 AC_SUBST(MKCSHLIB)
5525 AC_SUBST(DSO_CFLAGS)
5526 AC_SUBST(DSO_PIC_CFLAGS)
5527 AC_SUBST(DSO_LDOPTS)
5528 AC_SUBST(LIB_PREFIX)
5529 AC_SUBST(DLL_PREFIX)
5530 AC_SUBST(DLL_SUFFIX)
5531 AC_DEFINE_UNQUOTED(MOZ_DLL_SUFFIX, "$DLL_SUFFIX")
5532 AC_SUBST(LIB_SUFFIX)
5533 AC_SUBST(OBJ_SUFFIX)
5534 AC_SUBST(BIN_SUFFIX)
5535 AC_SUBST(IMPORT_LIB_SUFFIX)
5536 AC_SUBST(USE_N32)
5537 AC_SUBST(CC_VERSION)
5538 AC_SUBST(NS_ENABLE_TSF)
5539 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
5540 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
5542 AC_SUBST(MOZ_VORBIS)
5543 AC_SUBST(MOZ_TREMOR)
5544 AC_SUBST(MOZ_FFVPX)
5545 AC_SUBST_LIST(FFVPX_ASFLAGS)
5546 AC_SUBST(MOZ_DIRECTSHOW)
5547 AC_SUBST(MOZ_ANDROID_OMX)
5548 AC_SUBST(MOZ_OMX_PLUGIN)
5549 AC_SUBST(MOZ_VPX_ERROR_CONCEALMENT)
5550 AC_SUBST(VPX_USE_YASM)
5551 AC_SUBST_LIST(VPX_ASFLAGS)
5552 AC_SUBST(VPX_AS_CONVERSION)
5553 AC_SUBST(VPX_X86_ASM)
5554 AC_SUBST(VPX_ARM_ASM)
5555 AC_SUBST(MOZ_CODE_COVERAGE)
5556 AC_SUBST(LIBJPEG_TURBO_USE_YASM)
5557 AC_SUBST_LIST(LIBJPEG_TURBO_ASFLAGS)
5558 AC_SUBST(MOZ_LIBAV_FFT)
5559 AC_SUBST_LIST(LIBAV_FFT_ASFLAGS)
5560 AC_SUBST(MOZ_DEVTOOLS)
5562 AC_SUBST(MOZ_PACKAGE_JSSHELL)
5563 AC_SUBST(MOZ_FOLD_LIBS)
5564 AC_SUBST(MOZ_FOLD_LIBS_FLAGS)
5565 AC_SUBST(SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE)
5567 AC_SUBST(DMG_TOOL)
5569 dnl Host JavaScript runtime, if any, to use during cross compiles.
5570 AC_SUBST(JS_BINARY)
5572 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
5574 if test -n "$COMPILE_ENVIRONMENT"; then
5575 AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
5577 dnl Check for missing components
5578 if test "$MOZ_X11"; then
5579     dnl ====================================================
5580     dnl = Check if X headers exist
5581     dnl ====================================================
5582     _SAVE_CFLAGS=$CFLAGS
5583     CFLAGS="$CFLAGS $XCFLAGS"
5584     AC_TRY_COMPILE([
5585         #include <stdio.h>
5586         #include <stdlib.h>
5587         #include <X11/Xlib.h>
5588         #include <X11/Intrinsic.h>
5589         #include <X11/extensions/XShm.h>
5590     ],
5591     [
5592         Display *dpy = 0;
5593         if ((dpy = XOpenDisplay(NULL)) == NULL) {
5594             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
5595             exit(1);
5596         }
5597     ], [],
5598     [ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
5599     CFLAGS="$_SAVE_CFLAGS"
5601     if test -n "$MISSING_X"; then
5602         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
5603     fi
5605 fi # MOZ_X11
5607 fi # COMPILE_ENVIRONMENT
5609 dnl Set various defines and substitutions
5610 dnl ========================================================
5612 if test "$MOZ_DEBUG"; then
5613     AC_DEFINE(MOZ_REFLOW_PERF)
5614     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
5617 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
5618     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
5619     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
5620     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
5621     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
5622     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
5623     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
5624     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
5625     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
5628 if test -n "$MOZ_DEV_EDITION"; then
5629     AC_DEFINE(MOZ_DEV_EDITION)
5632 if test "$MOZ_DEBUG"; then
5633     A11Y_LOG=1
5635 case "$MOZ_UPDATE_CHANNEL" in
5636 aurora|beta|release|esr)
5637     ;;
5639     A11Y_LOG=1
5640     ;;
5641 esac
5642 AC_SUBST(A11Y_LOG)
5643 if test -n "$A11Y_LOG"; then
5644     AC_DEFINE(A11Y_LOG)
5647 AC_SUBST(MOZILLA_VERSION)
5649 dnl Spit out some output
5650 dnl ========================================================
5652 dnl The following defines are used by xpcom
5653 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
5654 CPP_THROW_NEW
5655 HAVE_CPP_AMBIGUITY_RESOLVING_USING
5656 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
5657 HAVE_CPP_PARTIAL_SPECIALIZATION
5658 HAVE_GETPAGESIZE
5659 HAVE_ICONV
5660 HAVE_ICONV_WITH_CONST_INPUT
5661 HAVE_MBRTOWC
5662 HAVE_WCRTOMB
5663 HAVE_STATVFS64
5664 HAVE_STATVFS
5665 HAVE_STATFS64
5666 HAVE_STATFS
5667 HAVE_SYS_STATVFS_H
5668 HAVE_SYS_STATFS_H
5669 HAVE_SYS_VFS_H
5670 HAVE_SYS_MOUNT_H
5673 dnl ========================================================
5674 dnl Determine options to use for running the preprocessor.
5675 dnl ========================================================
5677 if test -z "$GNU_CC" -a "$OS_ARCH" = "WINNT"; then
5678     PREPROCESS_OPTION="-P -Fi"
5679 else
5680     PREPROCESS_OPTION="-E -o "
5683 AC_SUBST(PREPROCESS_OPTION)
5685 dnl ========================================================
5686 dnl mask as shorthand property
5687 dnl ========================================================
5689 # The control structure code will be removed as soon as the feature is stable
5690 # Refer to bug 1281101 for more details.
5691 MOZ_ENABLE_MASK_AS_SHORTHAND=1
5692 AC_DEFINE(MOZ_ENABLE_MASK_AS_SHORTHAND)
5693 AC_SUBST(MOZ_ENABLE_MASK_AS_SHORTHAND)
5695 # Avoid using obsolete NSPR features
5696 AC_DEFINE(NO_NSPR_10_SUPPORT)
5698 # Don't build NSS libpkix
5699 NSS_DISABLE_LIBPKIX=1
5700 AC_SUBST(NSS_DISABLE_LIBPKIX)
5702 MOZ_CREATE_CONFIG_STATUS()
5704 if test "$COMPILE_ENVIRONMENT"; then
5705   MOZ_SUBCONFIGURE_JEMALLOC()
5708 # Run freetype configure script
5710 if test "$MOZ_TREE_FREETYPE"; then
5711    export CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS -std=c99"
5712    export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS"
5713    export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS"
5714    export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS"
5715    # Spaces in the *_CFLAGS and *_LIBS variables are intentionally placed
5716    # to force freetype to use our settings rather than autodetecting
5717    if test -n "$MOZ_SYSTEM_PNG"; then
5718      export LIBPNG_CFLAGS="$MOZ_PNG_CFLAGS "
5719    else
5720      export LIBPNG_CFLAGS="-I$_objdir/dist/include"
5721    fi
5722    export LIBPNG_LIBS="$MOZ_PNG_LIBS "
5723    export ZLIB_CFLAGS="$MOZ_ZLIB_CFLAGS "
5724    export ZLIB_LIBS="$MOZ_ZLIB_LIBS "
5725    export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in"
5726    ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes --with-zlib=yes --without-bzip2 --with-png=yes --without-harfbuzz"
5728    if ! test -e modules; then
5729      mkdir modules
5730    fi
5731    # Only export CC, CXX and RANLIB for the subconfigure, and avoid spilling
5732    # that further down the road.
5733    (export CC CXX RANLIB;
5734     AC_OUTPUT_SUBDIRS(modules/freetype2)
5735    ) || exit 1
5738 if test -z "$direct_nspr_config"; then
5739     dnl ========================================================
5740     dnl = Setup a nice relatively clean build environment for
5741     dnl = sub-configures.
5742     dnl ========================================================
5743     CC="$_SUBDIR_CC"
5744     CXX="$_SUBDIR_CXX"
5745     CFLAGS="$_SUBDIR_CFLAGS"
5746     CPPFLAGS="$_SUBDIR_CPPFLAGS"
5747     CXXFLAGS="$_SUBDIR_CXXFLAGS"
5748     LDFLAGS="$_SUBDIR_LDFLAGS"
5749     HOST_CC="$_SUBDIR_HOST_CC"
5750     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
5751     HOST_CXXFLAGS="$_SUBDIR_HOST_CXXFLAGS"
5752     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
5753     RC=
5756 unset MAKEFILES
5757 unset CONFIG_FILES
5759 # Run all configure scripts specified by a subconfigure
5760 if test -n "$_subconfigure_subdir"; then
5761   _save_srcdir="$srcdir"
5762   srcdir="$srcdir/.."
5763   _save_ac_configure_args="$ac_configure_args"
5764   ac_configure_args="$_subconfigure_config_args"
5765   AC_OUTPUT_SUBDIRS_NOW("$_subconfigure_subdir",$cache_file)
5766   ac_configure_args="$_save_ac_configure_args"
5767   srcdir="$_save_srcdir"
5770 if test "$COMPILE_ENVIRONMENT"; then
5772 export WRAP_LDFLAGS
5774 dnl ========================================================
5775 dnl = Setup a nice relatively clean build environment for
5776 dnl = sub-configures.
5777 dnl ========================================================
5778 CC="$_SUBDIR_CC"
5779 CXX="$_SUBDIR_CXX"
5780 CFLAGS="$_SUBDIR_CFLAGS"
5781 CPPFLAGS="$_SUBDIR_CPPFLAGS"
5782 CXXFLAGS="$_SUBDIR_CXXFLAGS"
5783 LDFLAGS="$_SUBDIR_LDFLAGS"
5784 HOST_CC="$_SUBDIR_HOST_CC"
5785 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
5786 HOST_CXXFLAGS="$_SUBDIR_HOST_CXXFLAGS"
5787 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
5790 # Run the SpiderMonkey 'configure' script.
5791 dist=$MOZ_BUILD_ROOT/dist
5792 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
5794 # --with-system-nspr will have been converted into the relevant $NSPR_CFLAGS
5795 # and $NSPR_LIBS.
5796 ac_configure_args="`echo $ac_configure_args | sed -e 's/--with-system-nspr\S* *//'`"
5798 if test "$_INTL_API" = no; then
5799     ac_configure_args="$ac_configure_args --without-intl-api"
5802 if test -n "$NSPR_CFLAGS" -o -n "$NSPR_LIBS"; then
5803     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
5804     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
5806 ac_configure_args="$ac_configure_args --prefix=$dist"
5807 if test -n "$ZLIB_IN_MOZGLUE"; then
5808    MOZ_ZLIB_LIBS=
5810 export MOZ_SYSTEM_ZLIB
5811 export MOZ_ZLIB_CFLAGS
5812 export MOZ_ZLIB_LIBS
5813 export MOZ_APP_NAME
5814 export MOZ_APP_REMOTINGNAME
5815 export RUSTC
5816 export MOZILLA_CENTRAL_PATH=$_topsrcdir
5817 export STLPORT_CPPFLAGS
5818 export STLPORT_LIBS
5819 unset MOZ_BUILD_APP
5820 export DIST
5821 export MOZ_LINKER
5822 export ZLIB_IN_MOZGLUE
5823 export AR
5824 export RANLIB
5825 export CPP
5826 export CC
5827 export CXX
5828 export ARFLAGS
5829 export CPPFLAGS
5830 export CFLAGS
5831 export CXXFLAGS
5832 export LDFLAGS
5833 export HOST_CC
5834 export HOST_CXX
5835 export HOST_CFLAGS
5836 export HOST_CPPFLAGS
5837 export HOST_CXXFLAGS
5838 export HOST_LDFLAGS
5840 if ! test -e js; then
5841     mkdir js
5844 ac_configure_args="$ac_configure_args JS_STANDALONE="
5845 AC_OUTPUT_SUBDIRS(js/src,$cache_file)
5846 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
5848 fi # COMPILE_ENVIRONMENT
5850 dnl we need to run config.status after js/src subconfigure because we're
5851 dnl traversing its moz.build and we need its config.status for that.
5852 dnl However, writing our own config.status needs to happen before
5853 dnl subconfigures because the setup surrounding subconfigures alters
5854 dnl many AC_SUBSTed variables.
5855 MOZ_RUN_ALL_SUBCONFIGURES()
5857 rm -fr confdefs* $ac_clean_files