Bug 1509898 [wpt PR 14236] - Simplify interpolation of 2-D matrix transforms., a...
[gecko.git] / old-configure.in
blob301267e70236d69394c817dc3ae0459a377f8a2c
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=10635
50 NSPR_VERSION=4
51 NSPR_MINVER=4.19
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 CAIRO_VERSION=1.10
61 GTK2_VERSION=2.18.0
62 GTK3_VERSION=3.4.0
63 GDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4
64 WINDRES_VERSION=2.14.90
65 W32API_VERSION=3.14
66 GCONF_VERSION=1.2.1
67 STARTUP_NOTIFICATION_VERSION=0.8
68 DBUS_VERSION=0.60
69 SQLITE_VERSION=3.25.3
71 dnl Set various checks
72 dnl ========================================================
73 MISSING_X=
75 dnl Initialize the Pthread test variables early so they can be
76 dnl  overridden by each platform.
77 dnl ========================================================
78 MOZ_USE_PTHREADS=
79 _PTHREAD_LDFLAGS=""
81 LDFLAGS="$LDFLAGS $LINKER_LDFLAGS"
83 if test "$COMPILE_ENVIRONMENT"; then
84     MOZ_ANDROID_NDK
85 fi # COMPILE_ENVIRONMENT
87 case "$target" in
88 *-android*|*-linuxandroid*)
89     AC_DEFINE(ANDROID)
90     ;;
91 *-linux*)
92     AC_PATH_PROG(OBJCOPY,objcopy)
93     ;;
94 esac
96 case "$target" in
97 *-apple-darwin*)
98     MOZ_IOS_SDK
99     ;;
100 esac
102 AC_SUBST(ANDROID_SOURCE)
103 AC_SUBST(ANDROID_PACKAGE_NAME)
104 AC_SUBST(OBJCOPY)
106 dnl ========================================================
107 dnl Checks for compilers.
108 dnl ========================================================
110 dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269)
111 AR_FLAGS='crs $@'
113 if test "$COMPILE_ENVIRONMENT"; then
115 if test "$target" != "$host"; then
116     MOZ_CROSS_COMPILER
117 else
118     AC_PROG_CC
119     case "$target" in
120     *-mingw*)
121       # Work around the conftest.exe access problem on Windows
122       sleep 2
123     esac
124     AC_PROG_CXX
125     AC_PROG_RANLIB
126     MOZ_PATH_PROGS(AS, $AS as, $CC)
127     AC_CHECK_PROGS(AR, ar, :)
128     AC_CHECK_PROGS(STRIP, strip, :)
129     AC_CHECK_PROGS(WINDRES, windres, :)
130     AC_CHECK_PROGS(OTOOL, otool, :)
131     if test -z "$HOST_RANLIB"; then
132         HOST_RANLIB="$RANLIB"
133     fi
134     if test -z "$HOST_AR"; then
135         HOST_AR="$AR"
136     fi
137     if test -z "$HOST_AR_FLAGS"; then
138         HOST_AR_FLAGS="$AR_FLAGS"
139     fi
142 if test -n "$MOZ_WINCONSOLE"; then
143     AC_DEFINE(MOZ_WINCONSOLE)
146 MOZ_TOOL_VARIABLES
148 dnl ========================================================
149 dnl Special win32 checks
150 dnl ========================================================
152 WINVER=601
154 case "$target" in
155 *-mingw*)
156     if test "$GCC" != "yes"; then
157         # Check to see if we are really running in a msvc environemnt
158         _WIN32_MSVC=1
160         # Make sure compilers are valid
161         CFLAGS="$CFLAGS -nologo"
162         CXXFLAGS="$CXXFLAGS -TP -nologo"
163         AC_LANG_SAVE
164         AC_LANG_C
165         AC_TRY_COMPILE([#include <stdio.h>],
166             [ printf("Hello World\n"); ],,
167             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
169         AC_LANG_CPLUSPLUS
170         AC_TRY_COMPILE([#include <new.h>],
171             [ unsigned *test = new unsigned(42); ],,
172             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
173         AC_LANG_RESTORE
175         changequote(,)
176         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
177         changequote([,])
179         _MSC_VER=`echo ${CC_VERSION} | cut -c 1-2,4-5`
181         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
182         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
183         AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
185         _CC_SUITE=14
186         MSVC_C_RUNTIME_DLL=vcruntime140.dll
187         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
189         MOZ_CHECK_HEADER(dia2.h, MSVC_HAS_DIA_SDK=1)
190         if test -n "$MSVC_HAS_DIA_SDK"; then
191             AC_DEFINE(MSVC_HAS_DIA_SDK)
192         fi
194         if test "$_MSC_VER" -ge "1910"; then # VS2017+
195             # C5038: Enable initializer list order warnings
196             # The -w1#### flag treats warning C#### as if it was a warning level
197             # 1 warning, and thus enables it because we enable /W3 warnings. We
198             # don't use -we#### because it would enable warning C#### but treat
199             # it as an error, even in third-party code.
200             # https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level
201             CXXFLAGS="$CXXFLAGS -w15038"
202         fi
204         # C5026: move constructor was implicitly defined as deleted
205         CXXFLAGS="$CXXFLAGS -wd5026"
207         # C5027: move assignment operator was implicitly defined as deleted
208         CXXFLAGS="$CXXFLAGS -wd5027"
210         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
211         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
213         # https://connect.microsoft.com/VisualStudio/feedback/details/888527/warnings-on-dbghelp-h
214         # for dbghelp.h, imagehlp.h, and shobj.h
215         # C4091: 'typedef ': ignored on left of '' when no variable is declared
216         CFLAGS="$CFLAGS -wd4091"
217         CXXFLAGS="$CXXFLAGS -wd4091"
219         # This is intended as a temporary hack to support building with VS2015.
220         # 'noexcept' used with no exception handling mode specified;
221         # termination on exception is not guaranteed. Specify /EHsc
222         CXXFLAGS="$CXXFLAGS -wd4577"
224         if test -n "$WIN_UCRT_REDIST_DIR"; then
225           if test ! -d "$WIN_UCRT_REDIST_DIR"; then
226             AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
227           fi
228           WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && pwd -W`
229         fi
231         if test -n "$WIN_DIA_SDK_BIN_DIR"; then
232           if test ! -d "$WIN_DIA_SDK_BIN_DIR"; then
233             AC_MSG_ERROR([Invalid Windows DIA SDK directory: ${WIN_DIA_SDK_BIN_DIR}])
234           fi
235           WIN_DIA_SDK_BIN_DIR=`cd "$WIN_DIA_SDK_BIN_DIR" && pwd -W`
236         fi
238         AC_SUBST(MSVC_HAS_DIA_SDK)
239         AC_SUBST(MSVC_C_RUNTIME_DLL)
240         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
242         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
244         if test -n "$WIN32_REDIST_DIR"; then
245           if test ! -d "$WIN32_REDIST_DIR"; then
246             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
247           fi
248           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd -W`
249         fi
251         # Check linker version, except in lld builds
252         case "$LINKER" in
253         *lld*)
254             ;;
255         *)
256             _LD_FULL_VERSION=`"${LINKER}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
257             _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
258             if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
259                 AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
260             fi
261             ;;
262         esac
264         INCREMENTAL_LINKER=1
266         unset _MSVC_VER_FILTER
268         WRAP_STL_INCLUDES=1
269         STL_FLAGS="-I${DIST}/stl_wrappers"
270         CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
271         CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
272     else
273         # Check w32api version
274         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
275         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
276         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
277         AC_TRY_COMPILE([#include <w32api.h>],
278             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
279                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
280                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
281                 #error "test failed."
282             #endif
283             , [ res=yes ], [ res=no ])
284         AC_MSG_RESULT([$res])
285         if test "$res" != "yes"; then
286             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
287         fi
288         # Check windres version
289         AC_MSG_CHECKING([for windres version >= $WINDRES_VERSION])
290         _WINDRES_VERSION=`${WINDRES} --version 2>&1 | grep -i windres 2>/dev/null | $AWK '{ print $3 }'`
291         AC_MSG_RESULT([$_WINDRES_VERSION])
292         _WINDRES_MAJOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
293         _WINDRES_MINOR_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
294         _WINDRES_RELEASE_VERSION=`echo $_WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
295         WINDRES_MAJOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $1 }'`
296         WINDRES_MINOR_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $2 }'`
297         WINDRES_RELEASE_VERSION=`echo $WINDRES_VERSION | $AWK -F\. '{ print $3 }'`
298         if test "$_WINDRES_MAJOR_VERSION" -lt "$WINDRES_MAJOR_VERSION" -o \
299                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
300                 "$_WINDRES_MINOR_VERSION" -lt "$WINDRES_MINOR_VERSION" -o \
301                 "$_WINDRES_MAJOR_VERSION" -eq "$WINDRES_MAJOR_VERSION" -a \
302                 "$_WINDRES_MINOR_VERSION" -eq "$WINDRES_MINOR_VERSION" -a \
303                 "$_WINDRES_RELEASE_VERSION" -lt "$WINDRES_RELEASE_VERSION"
304         then
305             AC_MSG_ERROR([windres version $WINDRES_VERSION or higher is required to build.])
306         fi
308         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
309         # causing problems with local implementations with the same name.
310         AC_DEFINE(STRSAFE_NO_DEPRECATE)
311     fi # !GNU_CC
313     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
314     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
315     # Require OS features provided by IE 8.0 (Win7)
316     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
318     ;;
319 esac
321 if test -n "$_WIN32_MSVC"; then
322     SKIP_PATH_CHECKS=1
323     SKIP_COMPILER_CHECKS=1
324     SKIP_LIBRARY_CHECKS=1
326     # Since we're skipping compiler and library checks, hard-code
327     # some facts here.
328     AC_DEFINE(HAVE_IO_H)
329     AC_DEFINE(HAVE_ISATTY)
332 fi # COMPILE_ENVIRONMENT
334 AC_SUBST(_MSC_VER)
336 AC_SUBST(GNU_CC)
337 AC_SUBST(GNU_CXX)
339 AC_SUBST_LIST(STL_FLAGS)
340 AC_SUBST(WRAP_STL_INCLUDES)
342 dnl ========================================================
343 dnl Checks for programs.
344 dnl ========================================================
345 if test "$COMPILE_ENVIRONMENT"; then
347 dnl ========================================================
348 dnl = Mac OS X SDK support
349 dnl ========================================================
350 MACOS_SDK_DIR=
351 MOZ_ARG_WITH_STRING(macos-sdk,
352 [  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)],
353     MACOS_SDK_DIR=$withval)
355 MACOS_PRIVATE_FRAMEWORKS_DIR_DEFAULTED=
356 MOZ_ARG_WITH_STRING(macos-private-frameworks,
357 [  --with-macos-private-frameworks=dir    Location of private frameworks to use (Mac OS X only)],
358     MACOS_PRIVATE_FRAMEWORKS_DIR=$withval,
359     MACOS_PRIVATE_FRAMEWORKS_DIR=/System/Library/PrivateFrameworks
360     MACOS_PRIVATE_FRAMEWORKS_DEFAULTED=1)
362 if test -z "${MACOS_PRIVATE_FRAMEWORKS_DEFAULTED}"; then
363   if test -z "$CROSS_COMPILE"; then
364     AC_MSG_WARN([You should only be using --with-macos-private-frameworks when cross-compiling.])
365   fi
366   if test ! -d "$MACOS_PRIVATE_FRAMEWORKS_DIR"; then
367     AC_MSG_ERROR([PrivateFrameworks directory not found.])
368   fi
371 dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use.
372 AC_SUBST(MACOS_SDK_DIR)
373 AC_SUBST(MACOS_PRIVATE_FRAMEWORKS_DIR)
375 if test "$MACOS_SDK_DIR"; then
376   dnl Sync this section with the ones in NSPR and NSS.
377   dnl Changes to the cross environment here need to be accounted for in
378   dnl the libIDL checks (below) and xpidl build.
380   if test ! -d "$MACOS_SDK_DIR"; then
381     AC_MSG_ERROR([SDK not found.  When using --with-macos-sdk, you must
382 specify a valid SDK.  SDKs are installed when the optional cross-development
383 tools are selected during the Xcode/Developer Tools installation.])
384   fi
386   CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}"
387   CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}"
389   dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER.
390   CPP="$CPP -isysroot ${MACOS_SDK_DIR}"
391   CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}"
393   AC_LANG_SAVE
394   AC_MSG_CHECKING([for valid compiler/Mac OS X SDK combination])
395   AC_LANG_CPLUSPLUS
396   AC_TRY_COMPILE([#include <new>],[],
397    result=yes,
398    result=no)
399   AC_LANG_RESTORE
400   AC_MSG_RESULT($result)
402   if test "$result" = "no" ; then
403     AC_MSG_ERROR([The selected compiler and Mac OS X SDK are incompatible.])
404   fi
407 AC_PATH_XTRA
409 XCFLAGS="$X_CFLAGS"
411 fi # COMPILE_ENVIRONMENT
413 dnl ========================================================
414 dnl set the defaults first
415 dnl ========================================================
416 AR_EXTRACT='$(AR) x'
417 MOZ_USER_DIR=".mozilla"
419 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
421 MOZ_FS_LAYOUT=unix
423 dnl Configure platform-specific CPU architecture compiler options.
424 dnl ==============================================================
425 if test "$COMPILE_ENVIRONMENT"; then
426     MOZ_ARCH_OPTS
427 else
428     if test "$OS_TARGET" = Android; then
429         dnl Default Android builds to ARMv7.
430         MOZ_ARCH=armv7-a
431     fi
432 fi # COMPILE_ENVIRONMENT
434 dnl ========================================================
435 dnl Android libstdc++, placed here so it can use MOZ_ARCH
436 dnl computed above.
437 dnl ========================================================
439 MOZ_ANDROID_CPU_ARCH
440 if test "$COMPILE_ENVIRONMENT"; then
441     MOZ_ANDROID_STLPORT
442 fi # COMPILE_ENVIRONMENT
444 dnl ========================================================
445 dnl Suppress Clang Argument Warnings
446 dnl ========================================================
447 WARNINGS_CFLAGS="$_WARNINGS_CFLAGS"
448 if test -n "${CLANG_CC}${CLANG_CL}"; then
449     WARNINGS_CFLAGS="-Qunused-arguments $WARNINGS_CFLAGS"
450     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
452 if test -n "${CLANG_CXX}${CLANG_CL}"; then
453     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
456 if test -n "$COMPILE_ENVIRONMENT"; then
457    MOZ_CONFIG_SANITIZE
460 dnl ========================================================
461 dnl Add optional and non-optional hardening flags
462 dnl ========================================================
464 CFLAGS="$CFLAGS $MOZ_HARDENING_CFLAGS"
465 CPPFLAGS="$CPPFLAGS $MOZ_HARDENING_CFLAGS"
466 CXXFLAGS="$CXXFLAGS $MOZ_HARDENING_CFLAGS"
468 dnl ========================================================
469 dnl GNU specific defaults
470 dnl ========================================================
471 if test "$GNU_CC"; then
472     MMX_FLAGS="-mmmx"
473     SSE_FLAGS="-msse"
474     SSE2_FLAGS="-msse2"
475     SSSE3_FLAGS="-mssse3"
476     # FIXME: Let us build with strict aliasing. bug 414641.
477     CFLAGS="$CFLAGS -fno-strict-aliasing"
478     WARNINGS_AS_ERRORS='-Werror'
479     DSO_CFLAGS=''
481     if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
482         DSO_PIC_CFLAGS='-fPIC'
483         ASFLAGS="$ASFLAGS -fPIC"
484     fi
486     AC_MSG_CHECKING([for --noexecstack option to as])
487     _SAVE_CFLAGS=$CFLAGS
488     CFLAGS="$CFLAGS -Wa,--noexecstack"
489     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
490                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
491                      AC_MSG_RESULT([no]))
492     CFLAGS=$_SAVE_CFLAGS
493     AC_MSG_CHECKING([for -z noexecstack option to ld])
494     _SAVE_LDFLAGS=$LDFLAGS
495     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
496     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
497                   AC_MSG_RESULT([no])
498                   LDFLAGS=$_SAVE_LDFLAGS)
500     AC_MSG_CHECKING([for -z text option to ld])
501     _SAVE_LDFLAGS=$LDFLAGS
502     LDFLAGS="$LDFLAGS -Wl,-z,text"
503     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
504                   AC_MSG_RESULT([no])
505                   LDFLAGS=$_SAVE_LDFLAGS)
507     AC_MSG_CHECKING([for -z relro option to ld])
508     _SAVE_LDFLAGS=$LDFLAGS
509     LDFLAGS="$LDFLAGS -Wl,-z,relro"
510     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
511                   AC_MSG_RESULT([no])
512                   LDFLAGS=$_SAVE_LDFLAGS)
514     AC_MSG_CHECKING([for -z nocopyreloc option to ld])
515     _SAVE_LDFLAGS=$LDFLAGS
516     LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
517     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
518                   AC_MSG_RESULT([no])
519                   LDFLAGS=$_SAVE_LDFLAGS)
521     AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
522     _SAVE_LDFLAGS=$LDFLAGS
523     LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
524     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
525                   AC_MSG_RESULT([no])
526                   LDFLAGS=$_SAVE_LDFLAGS)
528     AC_MSG_CHECKING([for --build-id=sha1 option to ld])
529     _SAVE_LDFLAGS=$LDFLAGS
530     LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
531     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
532                   AC_MSG_RESULT([no])
533                   LDFLAGS=$_SAVE_LDFLAGS)
535     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
536     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
537     _SAVE_LDFLAGS=$LDFLAGS
538     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
539     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
540                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
541                   AC_MSG_RESULT([no]))
542     LDFLAGS=$_SAVE_LDFLAGS
544     # Check for -mssse3 on $CC
545     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
546     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
547     _SAVE_CFLAGS=$CFLAGS
548     CFLAGS="$CFLAGS -mssse3"
549     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
550                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
551                      AC_MSG_RESULT([no]))
552     CFLAGS=$_SAVE_CFLAGS
554     # Check for -msse4.1 on $CC
555     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
556     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
557     _SAVE_CFLAGS=$CFLAGS
558     CFLAGS="$CFLAGS -msse4.1"
559     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
560                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
561                      AC_MSG_RESULT([no]))
562     CFLAGS=$_SAVE_CFLAGS
564     case "${CPU_ARCH}" in
565     x86 | x86_64)
566       AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
567       AC_TRY_COMPILE([],
568                      [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
569                      result="yes", result="no")
570       AC_MSG_RESULT("$result")
571       if test "$result" = "yes"; then
572           HAVE_X86_AVX2=1
573       fi
574       ;;
576     ppc*)
577       AC_MSG_CHECKING([whether we can enable AltiVec support])
578       HAVE_ALTIVEC=
579       _SAVE_CFLAGS=$CFLAGS
580       CFLAGS="$CFLAGS -maltivec"
581       AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
582                        [HAVE_ALTIVEC=1],
583                        AC_MSG_RESULT([no]))
584       CFLAGS=$_SAVE_CFLAGS
585       ;;
586     esac
588     DSO_LDOPTS='-shared'
589     if test "$GCC_USE_GNU_LD"; then
590         # Some tools like ASan use a runtime library that is only
591         # linked against executables, so we must allow undefined
592         # symbols for shared objects in some cases.
593         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
594             # Don't allow undefined symbols in libraries
595             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
597             # BSDs need `environ' exposed for posix_spawn (bug 753046)
598             case "$OS_TARGET" in
599             DragonFly|FreeBSD|NetBSD|OpenBSD)
600                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
601                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
602                 else
603                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
604                 fi
605                 ;;
606             esac
607         fi
608     fi
610     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
611     _USE_CPP_INCLUDE_FLAG=1
613     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
616 if test "$GNU_CXX"; then
617     # FIXME: Let us build with strict aliasing. bug 414641.
618     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
620     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
621     _USE_CPP_INCLUDE_FLAG=1
624 # For profiling builds keep the symbol information
625 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
626     case "$OS_TARGET" in
627     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
628         STRIP_FLAGS="--strip-debug"
629         ;;
630     esac
633 dnl ========================================================
634 dnl = Enable DMD
635 dnl ========================================================
637 if test "$MOZ_DMD"; then
638     if test "${CPU_ARCH}" = "arm"; then
639         CFLAGS="$CFLAGS -funwind-tables"
640         CXXFLAGS="$CXXFLAGS -funwind-tables"
641     fi
644 dnl ========================================================
645 dnl System overrides of the defaults for host
646 dnl ========================================================
647 case "$host" in
648 *mingw*)
649     if test -n "$_WIN32_MSVC"; then
650         HOST_AR=lib
651         HOST_AR_FLAGS='-NOLOGO -OUT:$@'
652         HOST_CFLAGS="$HOST_CFLAGS -nologo"
653         HOST_RANLIB='echo ranlib'
654     else
655         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
656     fi
657     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
658     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
659     HOST_BIN_SUFFIX=.exe
661     case "${host_cpu}" in
662     i*86)
663         if test -n "$_WIN32_MSVC"; then
664             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
665         fi
666         ;;
667     x86_64)
668         if test -n "$_WIN32_MSVC"; then
669             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
670         fi
671         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
672         ;;
673     esac
674     ;;
676 *-darwin*)
677     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
678     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
679     ;;
681 *-linux*|*-kfreebsd*-gnu|*-gnu*)
682     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
683     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
684     ;;
687     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
688     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
689     ;;
690 esac
692 MOZ_DOING_LTO(lto_is_enabled)
694 dnl ========================================================
695 dnl System overrides of the defaults for target
696 dnl ========================================================
698 case "$target" in
699 *-darwin*)
700     MOZ_OPTIMIZE_FLAGS="-O3"
701     CXXFLAGS="$CXXFLAGS -stdlib=libc++"
702     DSO_LDOPTS=''
703     STRIP_FLAGS="$STRIP_FLAGS -x -S"
704     # Ensure that if we're targeting iOS an SDK was provided.
705     AC_CACHE_CHECK(for iOS target,
706                    ac_cv_ios_target,
707                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
708 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
709 #error not iOS
710 #endif],
711                                    [],
712                                    ac_cv_ios_target="yes",
713                                    ac_cv_ios_target="no")])
714     if test "$ac_cv_ios_target" = "yes" -a -z $MOZ_IOS; then
715        AC_MSG_ERROR([targeting iOS but not using an iOS SDK?])
716     fi
717     if test -n "$MOZ_IOS"; then
718         direct_nspr_config=1
719     else
720         # The ExceptionHandling framework is needed for Objective-C exception
721         # logging code in nsObjCExceptions.h. Currently we only use that in debug
722         # builds.
723         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
724     fi
726     if test "x$lto_is_enabled" = "xyes"; then
727         echo "Skipping -dead_strip because lto is enabled."
728     dnl DTrace and -dead_strip don't interact well. See bug 403132.
729     dnl ===================================================================
730     elif test "x$enable_dtrace" = "xyes"; then
731         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
732     else
733         dnl check for the presence of the -dead_strip linker flag
734         AC_MSG_CHECKING([for -dead_strip option to ld])
735         _SAVE_LDFLAGS=$LDFLAGS
736         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
737         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
738         if test -n "$_HAVE_DEAD_STRIP" ; then
739             AC_MSG_RESULT([yes])
740             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
741         else
742             AC_MSG_RESULT([no])
743         fi
745         LDFLAGS=$_SAVE_LDFLAGS
746     fi
748     MOZ_FIX_LINK_PATHS="-Wl,-executable_path,${DIST}/bin"
749     ;;
751 *-android*|*-linuxandroid*)
752     AC_DEFINE(NO_PW_GECOS)
754     if test "$COMPILE_ENVIRONMENT"; then
755         MOZ_LINKER=1
756     fi
758     MOZ_GFX_OPTIMIZE_MOBILE=1
759     if test -z "$CLANG_CC"; then
760         MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
761     else
762         # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
763         # -Oz is smaller than -Os on clang.
764         MOZ_OPTIMIZE_FLAGS="-Oz"
765         # Disable the outliner, which causes performance regressions, and is
766         # enabled on some platforms at -Oz.
767         DISABLE_OUTLINER="-mno-outline"
768         _SAVE_CFLAGS=$CFLAGS
769         CFLAGS="$CFLAGS $DISABLE_OUTLINER"
770         AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
771         CFLAGS="$_SAVE_CFLAGS"
772     fi
773     ;;
775 *-*linux*)
776     if test "$GNU_CC" -o "$GNU_CXX"; then
777         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
778         if test -n "$MOZ_DEBUG"; then
779             MOZ_OPTIMIZE_FLAGS="-Os"
780         else
781             MOZ_OPTIMIZE_FLAGS="-O2"
782         fi
783         if test -z "$CLANG_CC"; then
784            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
785         fi
786     fi
788     case "${target_cpu}" in
789     alpha*)
790         CFLAGS="$CFLAGS -mieee"
791         CXXFLAGS="$CXXFLAGS -mieee"
792     ;;
793     esac
794     ;;
795 *-mingw*)
796     DSO_CFLAGS=
797     DSO_PIC_CFLAGS=
798     RC=rc.exe
799     # certain versions of cygwin's makedepend barf on the
800     # #include <string> vs -I./dist/include/string issue so don't use it
801     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
802         CC="$CC -mwindows"
803         CXX="$CXX -mwindows"
804         CPP="$CPP -mwindows"
805         CFLAGS="$CFLAGS -mms-bitfields"
806         CXXFLAGS="$CXXFLAGS -mms-bitfields"
807         DSO_LDOPTS='-shared'
808         RC='$(WINDRES)'
809         # Use temp file for windres (bug 213281)
810         RCFLAGS='-O coff --use-temp-file'
811         # mingw doesn't require kernel32, user32, and advapi32 explicitly
812         LIBS="$LIBS -luuid -lusp10 -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32"
813         MOZ_FIX_LINK_PATHS=
815         MOZ_OPTIMIZE_FLAGS="-O1"
817         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
818         WIN32_GUI_EXE_LDFLAGS=-mwindows
820         if test -z "$CLANG_CC"; then
821             # Use static libgcc and libstdc++
822             LDFLAGS="$LDFLAGS -static"
824             # GCC/binutils can't link to a function if we try to include dllexport function
825             # in the same library as dllimport caller. To work around it, we build NSPR
826             # and NSS with -mnop-fun-dllimport flag. The drawback of this solution is that
827             # function thunks need to be generated for cross-DLL calls.
828             MOZ_FOLD_LIBS_FLAGS="-mnop-fun-dllimport"
829         else
830             # Silence problematic clang warnings
831             CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
832         fi
833     else
834         TARGET_COMPILER_ABI=msvc
835         case "$LINKER" in
836         *lld*)
837             AR='llvm-lib'
838             AR_FLAGS='-llvmlibthin -out:$@'
839             ;;
840         *)
841             AR='lib'
842             AR_FLAGS='-NOLOGO -OUT:$@'
843             ;;
844         esac
845         AR_EXTRACT=
846         RANLIB='echo not_ranlib'
847         STRIP='echo not_strip'
848         PKG_SKIP_STRIP=1
849         # aarch64 doesn't support subsystems below 6.02
850         if test "$CPU_ARCH" = "aarch64"; then
851             WIN32_SUBSYSTEM_VERSION=6.02
852         else
853             WIN32_SUBSYSTEM_VERSION=6.01
854         fi
855         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
856         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
857         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
858         _USE_CPP_INCLUDE_FLAG=1
859         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
860         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
861         CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
862         CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
863         if test -z "$CLANG_CL"; then
864             CPPFLAGS="$CPPFLAGS -utf-8"
865         fi
866         if test "$CPU_ARCH" = "x86"; then
867             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
868             dnl more recent, so set that explicitly here unless another
869             dnl target arch has already been set.
870             changequote(,)
871             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
872               CFLAGS="$CFLAGS -arch:SSE2"
873             fi
874             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
875               CXXFLAGS="$CXXFLAGS -arch:SSE2"
876             fi
877             changequote([,])
878             SSE_FLAGS="-arch:SSE"
879             SSE2_FLAGS="-arch:SSE2"
880             dnl MSVC allows the use of intrinsics without any flags
881             dnl and doesn't have a separate arch for SSSE3
882             SSSE3_FLAGS="-arch:SSE2"
883         fi
884         dnl clang-cl requires appropriate flags to enable SSSE3 support
885         dnl on all architectures.
886         if test -n "$CLANG_CL"; then
887             SSSE3_FLAGS="-mssse3"
888         fi
889         dnl VS2013+ supports -Gw for better linker optimizations.
890         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
891         dnl Disabled on ASan because it causes false-positive ODR violations.
892         if test -z "$MOZ_ASAN"; then
893             CFLAGS="$CFLAGS -Gw"
894             CXXFLAGS="$CXXFLAGS -Gw"
895         fi
896         # khuey says we can safely ignore MSVC warning C4251
897         # MSVC warning C4244 (implicit type conversion may lose data) warns
898         # and requires workarounds for perfectly valid code.  Also, GCC/clang
899         # don't warn about it by default. So for consistency/sanity, we turn
900         # it off on MSVC, too.
901         # MSVC warning C4267 warns for narrowing type conversions from size_t
902         # to 32-bit integer types on 64-bit platforms.  Since this is virtually
903         # the same thing as C4244, we disable C4267, too.
904         # MSVC warning C4800 warns when a value is implicitly cast to bool,
905         # because this also forces narrowing to a single byte, which can be a
906         # perf hit.  But this matters so little in practice (and often we want
907         # that behavior) that it's better to turn it off.
908         # MSVC warning C4595 warns non-member operator new or delete functions
909         # may not be declared inline, as of VS2015 Update 2.
910         CFLAGS="$CFLAGS -wd4244 -wd4267"
911         CXXFLAGS="$CXXFLAGS -wd4251 -wd4244 -wd4267 -wd4800 -wd4595"
912         # Silence "warning C4065: switch statement contains 'default' but no
913         # 'case' labels".  See bug 1461304.
914         CXXFLAGS="$CXXFLAGS -wd4065"
915         if test -n "$CLANG_CL"; then
916             # XXX We should combine some of these with our generic GCC-style
917             # warning checks.
918             #
919             # Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
920             CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
921             # We use offsetof on non-POD objects all the time.
922             # We also suppress this warning on other platforms.
923             CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
924             # This warns for reasonable things like:
925             #   enum { X = 0xffffffffU };
926             # which is annoying for IDL headers.
927             CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
928             # This warns for cases that would be reached by the Microsoft
929             # #include rules, but also currently warns on cases that would
930             # *also* be reached by standard C++ include rules.  That
931             # behavior doesn't seem useful, so we turn it off.
932             CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
933             # We normally error out on unknown pragmas, but since clang-cl
934             # claims to be MSVC, it would be difficult to add
935             # #if defined(_MSC_VER) && !defined(__clang__) everywhere we
936             # use such pragmas, so just ignore them.
937             CFLAGS="$CFLAGS -Wno-unknown-pragmas"
938             CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
939             # We get errors about various #pragma intrinsic directives from
940             # clang-cl, and we don't need to hear about those.
941             CFLAGS="$CFLAGS -Wno-ignored-pragmas"
942             CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
943             # clang-cl's Intrin.h marks things like _ReadWriteBarrier
944             # as __attribute((__deprecated__)).  This is nice to know,
945             # but since we don't get the equivalent warning from MSVC,
946             # let's just ignore it.
947             CFLAGS="$CFLAGS -Wno-deprecated-declarations"
948             CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
949             # We use a function like:
950             #   __declspec(noreturn) __inline void f() {}
951             # which -Winvalid-noreturn complains about.  Again, MSVC seems
952             # OK with it, so let's silence the warning.
953             CFLAGS="$CFLAGS -Wno-invalid-noreturn"
954             CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
955             # Missing |override| on virtual function declarations isn't
956             # something that MSVC currently warns about.
957             CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
958             # We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
959             # declaration on |operator delete(void*)|.  However, clang-cl
960             # must internally declare |operator delete(void*)| differently,
961             # which causes this warning for virtually every file in the
962             # tree.  clang-cl doesn't support -fno-exceptions or equivalent,
963             # so there doesn't seem to be any way to convince clang-cl to
964             # declare |delete| differently.  Therefore, suppress this
965             # warning.
966             CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
967             # At least one MSVC header and several headers in-tree have
968             # unused typedefs, so turn this on.
969             CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
970             # jemalloc uses __declspec(allocator) as a profiler hint,
971             # which clang-cl doesn't understand.
972             CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
973             # __attribute__((unused)) really means "might be unused" and
974             # we use it to avoid warnings about things that are unused
975             # in some compilation units, but used in many others.  This
976             # warning insists on complaining about the latter case, which
977             # is annoying, and rather noisy.
978             CXXFLAGS="$CXXFLAGS -Wno-used-but-marked-unused"
979         fi
980         # make 'foo == bar;' error out
981         CFLAGS="$CFLAGS -we4553"
982         CXXFLAGS="$CXXFLAGS -we4553"
983         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
984         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
985         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib"
986         MOZ_DEBUG_LDFLAGS='-DEBUG'
987         WARNINGS_AS_ERRORS='-WX'
988         # Use a higher optimization level for clang-cl, so we can come closer
989         # to MSVC's performance numbers (see bug 1443590).
990         if test -n "$CLANG_CL"; then
991             MOZ_OPTIMIZE_FLAGS='-O2'
992         else
993             MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
994         fi
995         MOZ_FIX_LINK_PATHS=
996         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
997         if test -z "$DEVELOPER_OPTIONS"; then
998             LDFLAGS="$LDFLAGS -RELEASE"
999         fi
1000         RCFLAGS="-nologo"
1001         dnl Minimum reqiurement of Gecko is VS2015 or later which supports
1002         dnl both SSSE3 and SSE4.1.
1003         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
1004         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
1005         dnl allow AVX2 code from VS2015
1006         HAVE_X86_AVX2=1
1007     fi
1008     AC_DEFINE(WIN32_LEAN_AND_MEAN)
1009     dnl See http://support.microsoft.com/kb/143208 to use STL
1010     AC_DEFINE(NOMINMAX)
1011     BIN_SUFFIX='.exe'
1012     MOZ_USER_DIR="Mozilla"
1014     case "$host_os" in
1015     cygwin*|msvc*|mks*)
1016         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.])
1017         ;;
1018     esac
1020     if test -n "$GNU_CC" -a -z "$CLANG_CC"; then
1021         CFLAGS="$CFLAGS -fno-keep-inline-dllexport"
1022         CXXFLAGS="$CXXFLAGS -fno-keep-inline-dllexport"
1023     fi
1025     case "$target" in
1026     i*86-*)
1027         if test -n "$GNU_CC"; then
1028             CFLAGS="$CFLAGS -mstackrealign"
1029             CXXFLAGS="$CXXFLAGS -mstackrealign"
1030             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
1031             if test -z "$CLANG_CC"; then
1032                 LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup"
1033             fi
1034         else
1035             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
1036             LDFLAGS="$LDFLAGS -SAFESEH"
1037         fi
1039         AC_DEFINE(_X86_)
1040         ;;
1041     x86_64-*)
1042         if test -n "$_WIN32_MSVC"; then
1043             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
1044         fi
1045         AC_DEFINE(_AMD64_)
1046         ;;
1047     aarch64-*)
1048         if test -n "$_WIN32_MSVC"; then
1049             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
1050         fi
1051         AC_DEFINE(_ARM64_)
1052         ;;
1053     *)
1054         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
1055         ;;
1056     esac
1057     ;;
1059 *-netbsd*)
1060     DSO_CFLAGS=''
1061     CFLAGS="$CFLAGS -Dunix"
1062     CXXFLAGS="$CXXFLAGS -Dunix"
1063     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
1064         DSO_PIC_CFLAGS='-fPIC -DPIC'
1065         DSO_LDOPTS='-shared'
1066         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
1067     else
1068         DSO_PIC_CFLAGS='-fPIC -DPIC'
1069         DSO_LDOPTS='-shared'
1070     fi
1071     # This will fail on a.out systems prior to 1.5.1_ALPHA.
1072     if test "$LIBRUNPATH"; then
1073         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
1074     fi
1075     ;;
1077 *-openbsd*)
1078     if test -z "$X11BASE"; then
1079         X11BASE=/usr/X11R6
1080     fi
1081     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
1082     DSO_CFLAGS=''
1083     DSO_PIC_CFLAGS='-fPIC'
1084     DSO_LDOPTS='-shared -fPIC'
1085     if test "$LIBRUNPATH"; then
1086         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
1087     fi
1088     ;;
1090 *-solaris*)
1091     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
1092     ;;
1094 esac
1096 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
1097     MOZ_OPTIMIZE_FLAGS="-O"
1100 AC_SUBST_LIST(MMX_FLAGS)
1101 AC_SUBST_LIST(SSE_FLAGS)
1102 AC_SUBST_LIST(SSE2_FLAGS)
1103 AC_SUBST_LIST(SSSE3_FLAGS)
1105 AC_SUBST(MOZ_LINKER)
1106 if test -n "$MOZ_LINKER"; then
1107   AC_DEFINE(MOZ_LINKER)
1108   MOZ_LINKER_EXTRACT=1
1109   AC_CHECK_PROGS(XZ, xz)
1112 if test -z "$COMPILE_ENVIRONMENT"; then
1113     SKIP_COMPILER_CHECKS=1
1114     SKIP_LIBRARY_CHECKS=1
1115     PKG_SKIP_STRIP=1
1116     MOZ_DEBUGGING_OPTS
1117 else
1118     MOZ_COMPILER_OPTS
1119 fi # COMPILE_ENVIRONMENT
1121 if test -z "$SKIP_COMPILER_CHECKS"; then
1122 dnl Checks for typedefs, structures, and compiler characteristics.
1123 dnl ========================================================
1124 AC_C_CONST
1125 AC_TYPE_MODE_T
1126 AC_TYPE_OFF_T
1127 AC_TYPE_PID_T
1128 AC_TYPE_SIZE_T
1129 AC_LANG_CPLUSPLUS
1130 AC_LANG_C
1132 AC_LANG_CPLUSPLUS
1134 MOZ_CXX11
1136 AC_LANG_C
1138 case "${OS_TARGET}" in
1139 Darwin)
1140   ;;
1142   STL_FLAGS="-I${DIST}/stl_wrappers"
1143   WRAP_STL_INCLUDES=1
1144   ;;
1145 esac
1147 dnl Checks for header files.
1148 dnl ========================================================
1149 AC_HEADER_DIRENT
1150 case "$target_os" in
1151 bitrig*|dragonfly*|freebsd*|openbsd*)
1152 # for stuff like -lXshm
1153     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
1154     ;;
1155 esac
1157 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
1158 AC_CACHE_CHECK(for sockaddr_in.sin_len,
1159                    ac_cv_sockaddr_in_sin_len,
1160                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
1161                                     #include <sys/types.h>
1162                                     #endif
1163                                     #include <netinet/in.h>
1164                                     struct sockaddr_in x;
1165                                     void *foo = (void*) &x.sin_len;],
1166                                    [],
1167                                    [ac_cv_sockaddr_in_sin_len=true],
1168                                    [ac_cv_sockaddr_in_sin_len=false])])
1169 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
1170   AC_DEFINE(HAVE_SIN_LEN)
1171 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
1172   AC_DEFINE(HAVE_SCONN_LEN)
1175 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
1176                ac_cv_sockaddr_in6_sin6_len,
1177                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
1178                                 #include <sys/types.h>
1179                                 #endif
1180                                 #include <netinet/in.h>
1181                                 struct sockaddr_in6 x;
1182                                 void *foo = (void*) &x.sin6_len;],
1183                                [],
1184                                [ac_cv_sockaddr_in6_sin6_len=true],
1185                                [ac_cv_sockaddr_in6_sin6_len=false])])
1186 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
1187   AC_DEFINE(HAVE_SIN6_LEN)
1190 AC_CACHE_CHECK(for sockaddr.sa_len,
1191                ac_cv_sockaddr_sa_len,
1192                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
1193                                 #include <sys/types.h>
1194                                 #endif
1195                                 #include <sys/socket.h>
1196                                 struct sockaddr x;
1197                                 void *foo = (void*) &x.sa_len;],
1198                                [],
1199                                [ac_cv_sockaddr_sa_len=true],
1200                                [ac_cv_sockaddr_sa_len=false])])
1201 if test "$ac_cv_sockaddr_sa_len" = true ; then
1202   AC_DEFINE(HAVE_SA_LEN)
1205 MOZ_ARG_ENABLE_BOOL(dtrace,
1206               [  --enable-dtrace         build with dtrace support if available (default=no)],
1207               [enable_dtrace="yes"],)
1208 if test "x$enable_dtrace" = "xyes"; then
1209   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
1210   if test -n "$HAVE_DTRACE"; then
1211       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
1212   else
1213       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
1214   fi
1216 AC_SUBST(HAVE_DTRACE)
1218 dnl Checks for libraries.
1219 dnl ========================================================
1220 AC_CHECK_LIB(c_r, gethostbyname_r)
1222 dnl We don't want to link with libdl even if it's present on OS X, since
1223 dnl it's not used and not part of the default installation. OS/2 has dlfcn
1224 dnl in libc.
1225 dnl We don't want to link against libm or libpthread on Darwin since
1226 dnl they both are just symlinks to libSystem and explicitly linking
1227 dnl against libSystem causes issues when debugging (see bug 299601).
1228 case $target in
1229 *-darwin*)
1230     ;;
1232     AC_SEARCH_LIBS(dlopen, dl,
1233         MOZ_CHECK_HEADER(dlfcn.h,
1234         AC_DEFINE(HAVE_DLOPEN)))
1235     ;;
1236 esac
1238 _SAVE_CFLAGS="$CFLAGS"
1239 CFLAGS="$CFLAGS -D_GNU_SOURCE"
1240 AC_CHECK_FUNCS(dladdr memmem)
1241 CFLAGS="$_SAVE_CFLAGS"
1243 if test ! "$GNU_CXX"; then
1244     AC_CHECK_LIB(C, demangle)
1247 AC_CHECK_LIB(socket, socket)
1249 XLDFLAGS="$X_LIBS"
1250 XLIBS="$X_EXTRA_LIBS"
1252 dnl ========================================================
1253 dnl Checks for X libraries.
1254 dnl Ordering is important.
1255 dnl Xt is dependent upon SM as of X11R6
1256 dnl ========================================================
1257 if test -n "$MOZ_X11"; then
1258     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
1259     _SAVE_LDFLAGS="$LDFLAGS"
1260     _SAVE_LIBS="$LIBS"
1261     LDFLAGS="$XLDFLAGS $LDFLAGS"
1262     AC_CHECK_LIB(X11, XDrawLines, [XLIBS="-lX11 $XLIBS"],
1263         [MISSING_X="$MISSING_X -lX11"], $XLIBS)
1264     AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
1265         [MISSING_X="$MISSING_X -lXext"], $XLIBS)
1267     AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
1268         unset ac_cv_lib_Xt_XtFree
1269         AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
1270         AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
1271         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
1272             [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
1273         ])
1275     dnl ========================================================
1276     dnl = Check for xcb
1277     dnl ========================================================
1278     AC_CHECK_LIB(xcb, xcb_connect, [XLIBS="-lxcb $XLIBS"],
1279         [MISSING_X="$MISSING_X -lxcb"], $XLIBS)
1280     AC_CHECK_LIB(xcb-shm, xcb_shm_query_version, [XLIBS="-lxcb-shm $XLIBS"],
1281         [MISSING_X="$MISSING_X -lxcb-shm"], $XLIBS)
1282     AC_CHECK_LIB(X11-xcb, XGetXCBConnection, [XLIBS="-lX11-xcb $XLIBS"],
1283         [MISSING_X="$MISSING_X -lX11-xcb"], $XLIBS)
1285     LDFLAGS="$_SAVE_LDFLAGS"
1286     LIBS="$_SAVE_LIBS"
1287 fi # $MOZ_X11
1289 AC_SUBST_LIST(XCFLAGS)
1290 AC_SUBST_LIST(XLDFLAGS)
1291 AC_SUBST_LIST(XLIBS)
1292 AC_SUBST_LIST(XEXT_LIBS)
1293 AC_SUBST_LIST(XT_LIBS)
1295 dnl ========================================================
1296 dnl = pthread support
1297 dnl = Start by checking whether the system support pthreads
1298 dnl ========================================================
1299 case "$target_os" in
1300 darwin*)
1301     MOZ_USE_PTHREADS=1
1302     ;;
1304     AC_CHECK_LIB(pthreads, pthread_create,
1305         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
1306         AC_CHECK_LIB(pthread, pthread_create,
1307             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
1308             AC_CHECK_LIB(c_r, pthread_create,
1309                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
1310                 AC_CHECK_LIB(c, pthread_create,
1311                     MOZ_USE_PTHREADS=1
1312                 )
1313             )
1314         )
1315     )
1316     ;;
1317 esac
1319 dnl ========================================================
1320 dnl Do the platform specific pthread hackery
1321 dnl ========================================================
1322 if test "$MOZ_USE_PTHREADS"x != x
1323 then
1324     dnl
1325     dnl See if -pthread is supported.
1326     dnl
1327     rm -f conftest*
1328     ac_cv_have_dash_pthread=no
1329     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
1330     echo 'int main() { return 0; }' | cat > conftest.c
1331     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
1332     if test $? -eq 0; then
1333         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1334             ac_cv_have_dash_pthread=yes
1335             case "$target_os" in
1336             freebsd*)
1337 # Freebsd doesn't use -pthread for compiles, it uses them for linking
1338                 ;;
1339             *)
1340                 CFLAGS="$CFLAGS -pthread"
1341                 CXXFLAGS="$CXXFLAGS -pthread"
1342                 ;;
1343             esac
1344         fi
1345     fi
1346     rm -f conftest*
1347     AC_MSG_RESULT($ac_cv_have_dash_pthread)
1349     dnl
1350     dnl See if -pthreads is supported.
1351     dnl
1352     ac_cv_have_dash_pthreads=no
1353     if test "$ac_cv_have_dash_pthread" = "no"; then
1354         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
1355         echo 'int main() { return 0; }' | cat > conftest.c
1356         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
1357         if test $? -eq 0; then
1358             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1359                 ac_cv_have_dash_pthreads=yes
1360                 CFLAGS="$CFLAGS -pthreads"
1361                 CXXFLAGS="$CXXFLAGS -pthreads"
1362             fi
1363         fi
1364         rm -f conftest*
1365         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
1366     fi
1368     case "$target" in
1369         *-*-freebsd*)
1370             AC_DEFINE(_REENTRANT)
1371             AC_DEFINE(_THREAD_SAFE)
1372             dnl -pthread links in -lpthread, so don't specify it explicitly.
1373             if test "$ac_cv_have_dash_pthread" = "yes"; then
1374                 _PTHREAD_LDFLAGS="-pthread"
1375             fi
1376             ;;
1378         *-*-openbsd*|*-*-bsdi*)
1379             AC_DEFINE(_REENTRANT)
1380             AC_DEFINE(_THREAD_SAFE)
1381             dnl -pthread links in -lc_r, so don't specify it explicitly.
1382             if test "$ac_cv_have_dash_pthread" = "yes"; then
1383                 _PTHREAD_LDFLAGS="-pthread"
1384             fi
1385             ;;
1387         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
1388             AC_DEFINE(_REENTRANT)
1389             ;;
1391     esac
1392     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
1393     AC_SUBST(MOZ_USE_PTHREADS)
1394     MOZ_CHECK_HEADERS(pthread.h)
1398 dnl Checks for library functions.
1399 dnl ========================================================
1400 AC_PROG_GCC_TRADITIONAL
1401 AC_FUNC_MEMCMP
1402 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall)
1404 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
1405 dnl avoid this on Darwin, since depending on your system config, we may think
1406 dnl it exists but it really doesn't
1407 case "$OS_TARGET" in
1408 Darwin)
1409   ;;
1411   AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
1412                  ac_cv_clock_monotonic,
1413                  [for libs in "" -lrt; do
1414                       _SAVE_LIBS="$LIBS"
1415                       LIBS="$LIBS $libs"
1416                       AC_TRY_LINK([#include <time.h>],
1417                                    [ struct timespec ts;
1418                                      clock_gettime(CLOCK_MONOTONIC, &ts); ],
1419                                    ac_cv_clock_monotonic=$libs
1420                                    LIBS="$_SAVE_LIBS"
1421                                    break,
1422                                    ac_cv_clock_monotonic=no)
1423                       LIBS="$_SAVE_LIBS"
1424                   done])
1425   if test "$ac_cv_clock_monotonic" != "no"; then
1426       HAVE_CLOCK_MONOTONIC=1
1427       REALTIME_LIBS=$ac_cv_clock_monotonic
1428       AC_DEFINE(HAVE_CLOCK_MONOTONIC)
1429       AC_SUBST(HAVE_CLOCK_MONOTONIC)
1430       AC_SUBST_LIST(REALTIME_LIBS)
1431   fi
1432   ;;
1433 esac
1435 dnl Turn on warnings-as-errors to prevent implicit declaration of
1436 dnl pthread_cond_timedwait_monotonic_np, which can cause this test to
1437 dnl inadvertently pass even if the function does not really exist.
1438 _SAVE_CFLAGS="$CFLAGS"
1439 CFLAGS="$CFLAGS $WARNINGS_AS_ERRORS"
1440 AC_CACHE_CHECK(for pthread_cond_timedwait_monotonic_np,
1441                ac_cv_pthread_cond_timedwait_monotonic_np,
1442                AC_TRY_LINK([#include <pthread.h>],
1443                            [pthread_cond_timedwait_monotonic_np(0, 0, 0);],
1444                            ac_cv_pthread_cond_timewait_monotonic_np=yes,
1445                            ac_cv_pthread_cond_timewait_monotonic_np=no))
1446 if test "$ac_cv_pthread_cond_timewait_monotonic_np" != "no"; then
1447     AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
1449 CFLAGS=$_SAVE_CFLAGS
1451 AC_CACHE_CHECK(
1452     [for res_ninit()],
1453     ac_cv_func_res_ninit,
1454     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
1455         dnl no need for res_ninit() on NetBSD and OpenBSD
1456         ac_cv_func_res_ninit=no
1457      else
1458         AC_TRY_LINK([
1459             #ifdef linux
1460             #define _BSD_SOURCE 1
1461             #endif
1462             #include <sys/types.h>
1463             #include <netinet/in.h>
1464             #include <arpa/nameser.h>
1465             #include <resolv.h>
1466             ],
1467             [int foo = res_ninit(&_res);],
1468             [ac_cv_func_res_ninit=yes],
1469             [ac_cv_func_res_ninit=no])
1470      fi
1471     ])
1473 if test "$ac_cv_func_res_ninit" = "yes"; then
1474     AC_DEFINE(HAVE_RES_NINIT)
1475 dnl must add the link line we do something as foolish as this... dougt
1476 dnl else
1477 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
1478 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
1481 AC_LANG_C
1483 dnl **********************
1484 dnl *** va_copy checks ***
1485 AC_CACHE_CHECK([for an implementation of va_copy()],
1486                ac_cv_va_copy,
1487     [AC_TRY_COMPILE([#include <stdarg.h>
1488                      #include <stdlib.h>
1489         void f (int i, ...) {
1490             va_list args1, args2;
1491             va_start (args1, i);
1492             va_copy (args2, args1);
1493             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1494                 exit (1);
1495             va_end (args1); va_end (args2);
1496         }],
1497         [f(0, 42); return 0],
1498         [ac_cv_va_copy=yes],
1499         [ac_cv_va_copy=no]
1500     )]
1502 AC_CACHE_CHECK([whether va_list can be copied by value],
1503                ac_cv_va_val_copy,
1504     [AC_TRY_COMPILE([#include <stdarg.h>
1505                      #include <stdlib.h>
1506         void f (int i, ...) {
1507             va_list args1, args2;
1508             va_start (args1, i);
1509             args2 = args1;
1510             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1511                 exit (1);
1512             va_end (args1); va_end (args2);
1513         }],
1514         [f(0, 42); return 0],
1515         [ac_cv_va_val_copy=yes],
1516         [ac_cv_va_val_copy=no],
1517     )]
1519 if test "x$ac_cv_va_copy" = "xyes"; then
1520     AC_DEFINE(VA_COPY, va_copy)
1521     AC_DEFINE(HAVE_VA_COPY)
1524 if test "x$ac_cv_va_val_copy" = "xno"; then
1525    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
1528 dnl ===================================================================
1529 dnl ========================================================
1530 dnl Put your C++ language/feature checks below
1531 dnl ========================================================
1532 AC_LANG_CPLUSPLUS
1534 ARM_ABI_PREFIX=
1535 if test "$GNU_CC"; then
1536   if test "$CPU_ARCH" = "arm" ; then
1537     AC_CACHE_CHECK(for ARM EABI,
1538         ac_cv_gcc_arm_eabi,
1539         [AC_TRY_COMPILE([],
1540                         [
1541 #if defined(__ARM_EABI__)
1542   return 0;
1543 #else
1544 #error Not ARM EABI.
1545 #endif
1546                         ],
1547                         ac_cv_gcc_arm_eabi="yes",
1548                         ac_cv_gcc_arm_eabi="no")])
1549     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
1550         HAVE_ARM_EABI=1
1551         ARM_ABI_PREFIX=eabi-
1552     else
1553         ARM_ABI_PREFIX=oabi-
1554     fi
1555   fi
1557   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
1560 dnl See if a dynamic_cast to void* gives the most derived object.
1561 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
1562                ac_cv_cpp_dynamic_cast_void_ptr,
1563                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
1564                             class Y { int j; public: virtual ~Y() { } };
1565                             class Z : public X, public Y { int k; };
1567                             int main() {
1568                                  Z mdo;
1569                                  X *subx = (X*)&mdo;
1570                                  Y *suby = (Y*)&mdo;
1571                                  return !((((void*)&mdo != (void*)subx) &&
1572                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
1573                                           (((void*)&mdo != (void*)suby) &&
1574                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
1575                             }],
1576                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
1577                            ac_cv_cpp_dynamic_cast_void_ptr=no,
1578                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
1579 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
1580    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
1584 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
1585 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
1586 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
1587 # linking XUL.
1588 _SAVE_LDFLAGS=$LDFLAGS
1589 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
1590 AC_CACHE_CHECK(for __thread keyword for TLS variables,
1591                ac_cv_thread_keyword,
1592                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
1593                             [return tlsIsMainThread;],
1594                             ac_cv_thread_keyword=yes,
1595                             ac_cv_thread_keyword=no)])
1596 LDFLAGS=$_SAVE_LDFLAGS
1597 # The custom dynamic linker doesn't support TLS variables
1598 MOZ_TLS=
1599 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
1600   # mips builds fail with TLS variables because of a binutils bug.
1601   # See bug 528687
1602   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
1603   case "${target}" in
1604     mips*-*)
1605       :
1606       ;;
1607     *-android*|*-linuxandroid*)
1608       :
1609       ;;
1610     *-openbsd*)
1611       :
1612       ;;
1613     *)
1614       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
1615       MOZ_TLS=1
1616       ;;
1617   esac
1620 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
1621 if test -n "$MOZ_LINKER"; then
1622   if test "$CPU_ARCH" = arm; then
1623     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
1624     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
1625       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1626       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1627     fi
1628   fi
1630 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
1631 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
1632 dnl Since the linker only understands the sysv ones, no need to build the
1633 dnl gnu style tables anyways.
1634   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
1637 dnl End of C++ language/feature checks
1638 AC_LANG_C
1640 dnl ========================================================
1641 dnl =  Internationalization checks
1642 dnl ========================================================
1644 dnl Internationalization and Locale support is different
1645 dnl on various UNIX platforms.  Checks for specific i18n
1646 dnl features go here.
1648 AC_HAVE_FUNCS(localeconv)
1650 fi # ! SKIP_COMPILER_CHECKS
1652 if test -n "${COMPILE_ENVIRONMENT}"; then
1653   MOZ_CHECK_ALLOCATOR
1656 TARGET_XPCOM_ABI=
1657 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1658     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1659     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
1662 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1663 dnl features that Windows actually does support.
1665 if test -n "$SKIP_COMPILER_CHECKS"; then
1666    dnl Windows has malloc.h
1667    AC_DEFINE(MALLOC_H, [<malloc.h>])
1668    AC_DEFINE(HAVE_FORCEINLINE)
1669    AC_DEFINE(HAVE_LOCALECONV)
1670 fi # SKIP_COMPILER_CHECKS
1672 dnl Mozilla specific options
1673 dnl ========================================================
1674 dnl The macros used for command line options
1675 dnl are defined in build/autoconf/altoptions.m4.
1677 dnl ========================================================
1678 dnl =
1679 dnl = Check for external package dependencies
1680 dnl =
1681 dnl ========================================================
1682 MOZ_ARG_HEADER(External Packages)
1684 case "$OS_TARGET" in
1685 WINNT|Darwin|Android)
1686   MOZ_FOLD_LIBS=1
1687   ;;
1689   MOZ_FOLD_LIBS=
1690   ;;
1691 esac
1693 MOZ_CONFIG_NSPR()
1695 dnl ========================================================
1696 dnl system libevent Support
1697 dnl ========================================================
1698 MOZ_ARG_WITH_STRING(system-libevent,
1699 [  --with-system-libevent[=PFX]
1700                           Use system libevent [installed at prefix PFX]],
1701     LIBEVENT_DIR=$withval)
1703 _SAVE_CFLAGS=$CFLAGS
1704 _SAVE_LDFLAGS=$LDFLAGS
1705 _SAVE_LIBS=$LIBS
1706 if test "$LIBEVENT_DIR" = yes; then
1707     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
1708         MOZ_SYSTEM_LIBEVENT=1,
1709         LIBEVENT_DIR=/usr)
1711 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
1712     MOZ_SYSTEM_LIBEVENT=
1713 elif test -z "$MOZ_SYSTEM_LIBEVENT"; then
1714     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
1715     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
1716     MOZ_CHECK_HEADER(event.h,
1717         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
1718              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
1719          fi],
1720         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
1721     AC_CHECK_LIB(event, event_init,
1722                  [MOZ_SYSTEM_LIBEVENT=1
1723                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
1724                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
1725                  [MOZ_SYSTEM_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
1727 CFLAGS=$_SAVE_CFLAGS
1728 LDFLAGS=$_SAVE_LDFLAGS
1729 LIBS=$_SAVE_LIBS
1731 AC_SUBST(MOZ_SYSTEM_LIBEVENT)
1733 dnl ========================================================
1734 dnl = If NSS was not detected in the system,
1735 dnl = use the one in the source tree (mozilla/security/nss)
1736 dnl ========================================================
1738 MOZ_ARG_WITH_BOOL(system-nss,
1739 [  --with-system-nss       Use system installed NSS],
1740     _USE_SYSTEM_NSS=1 )
1742 if test -n "$_USE_SYSTEM_NSS"; then
1743     AM_PATH_NSS(3.41, [MOZ_SYSTEM_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
1746 NSS_CFLAGS="$NSS_CFLAGS -I${DIST}/include/nss"
1747 if test -z "$MOZ_SYSTEM_NSS"; then
1748    case "${OS_ARCH}" in
1749         # Only few platforms have been tested with GYP
1750         WINNT|Darwin|Linux|DragonFly|FreeBSD|NetBSD|OpenBSD|SunOS)
1751             ;;
1752         *)
1753             AC_MSG_ERROR([building in-tree NSS is not supported on this platform. Use --with-system-nss])
1754             ;;
1755    esac
1758 if test -z "$SKIP_LIBRARY_CHECKS"; then
1759 dnl system JPEG support
1760 dnl ========================================================
1761 MOZ_ARG_WITH_STRING(system-jpeg,
1762 [  --with-system-jpeg[=PFX]
1763                           Use system libjpeg [installed at prefix PFX]],
1764     JPEG_DIR=$withval)
1766 _SAVE_CFLAGS=$CFLAGS
1767 _SAVE_LDFLAGS=$LDFLAGS
1768 _SAVE_LIBS=$LIBS
1769 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
1770     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
1771     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
1773 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
1774     MOZ_SYSTEM_JPEG=
1775 else
1776     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_SYSTEM_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_SYSTEM_JPEG=)
1779 if test "$MOZ_SYSTEM_JPEG" = 1; then
1780     AC_TRY_COMPILE([ #include <stdio.h>
1781                      #include <sys/types.h>
1782                      #include <jpeglib.h> ],
1783                    [ #if JPEG_LIB_VERSION < $MOZJPEG
1784                      #error "Insufficient JPEG library version ($MOZJPEG required)."
1785                      #endif
1786                      #ifndef JCS_EXTENSIONS
1787                      #error "libjpeg-turbo JCS_EXTENSIONS required"
1788                      #endif
1789                      ],
1790                    MOZ_SYSTEM_JPEG=1,
1791                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
1793 CFLAGS=$_SAVE_CFLAGS
1794 LDFLAGS=$_SAVE_LDFLAGS
1795 LIBS=$_SAVE_LIBS
1797 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_SYSTEM_JPEG" = 1; then
1798     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
1799     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
1801 fi # SKIP_LIBRARY_CHECKS
1803 dnl system ZLIB support
1804 dnl ========================================================
1805 MOZ_ZLIB_CHECK([1.2.3])
1807 if test -z "$SKIP_LIBRARY_CHECKS"; then
1809 dnl ========================================================
1810 dnl system PNG Support
1811 dnl ========================================================
1812 MOZ_ARG_WITH_STRING(system-png,
1813 [  --with-system-png[=PFX]
1814                           Use system libpng [installed at prefix PFX]],
1815     PNG_DIR=$withval)
1817 _SAVE_CFLAGS=$CFLAGS
1818 _SAVE_LDFLAGS=$LDFLAGS
1819 _SAVE_LIBS=$LIBS
1820 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
1821     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
1822     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
1824 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
1825     MOZ_SYSTEM_PNG=
1826 else
1827     AC_CHECK_LIB(png, png_get_valid, [MOZ_SYSTEM_PNG=1 MOZ_PNG_LIBS="-lpng"],
1828                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1829     AC_CHECK_LIB(png, png_get_acTL, ,
1830                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
1832 if test "$MOZ_SYSTEM_PNG" = 1; then
1833     AC_TRY_COMPILE([ #include <stdio.h>
1834                      #include <sys/types.h>
1835                      #include <png.h> ],
1836                    [ #if PNG_LIBPNG_VER < $MOZPNG
1837                      #error "Insufficient libpng version ($MOZPNG required)."
1838                      #endif
1839                      #ifndef PNG_UINT_31_MAX
1840                      #error "Insufficient libpng version."
1841                      #endif ],
1842                    MOZ_SYSTEM_PNG=1,
1843                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1845 CFLAGS=$_SAVE_CFLAGS
1846 LDFLAGS=$_SAVE_LDFLAGS
1847 LIBS=$_SAVE_LIBS
1849 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_SYSTEM_PNG" = 1; then
1850     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
1851     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
1854 fi # SKIP_LIBRARY_CHECKS
1856 dnl ========================================================
1857 dnl =
1858 dnl = Application
1859 dnl =
1860 dnl ========================================================
1862 MOZ_ARG_HEADER(Application)
1864 ENABLE_SYSTEM_EXTENSION_DIRS=1
1865 MOZ_BRANDING_DIRECTORY=
1866 MOZ_OFFICIAL_BRANDING=
1867 MOZ_FEEDS=1
1868 MOZ_AUTH_EXTENSION=1
1869 if test "$MOZ_IOS"; then
1870    MOZ_AUTH_EXTENSION=
1872 VPX_USE_YASM=
1873 VPX_ASFLAGS=
1874 VPX_AS_CONVERSION=
1875 VPX_X86_ASM=
1876 VPX_ARM_ASM=
1877 LIBJPEG_TURBO_AS=
1878 LIBJPEG_TURBO_ASFLAGS=
1879 MOZ_PREF_EXTENSIONS=1
1880 MOZ_SPELLCHECK=1
1881 MOZ_TOOLKIT_SEARCH=1
1882 MOZ_UNIVERSALCHARDET=1
1883 MOZ_XUL=1
1884 MOZ_ZIPWRITER=1
1885 MOZ_NO_SMART_CARDS=
1886 NECKO_COOKIES=1
1887 MOZ_USE_NATIVE_POPUP_WINDOWS=
1888 MOZ_EXCLUDE_HYPHENATION_DICTIONARIES=
1889 MOZ_CONTENT_SANDBOX=
1890 MOZ_GMP_SANDBOX=
1891 MOZ_SANDBOX=1
1892 MOZ_BINARY_EXTENSIONS=
1893 MOZ_DEVTOOLS=server
1895 case "$target_os" in
1896     mingw*)
1897         NS_ENABLE_TSF=1
1898         AC_DEFINE(NS_ENABLE_TSF)
1899         ;;
1900 esac
1902 # Optional Firefox for Android partner distribution directory.
1903 MOZ_ARG_WITH_STRING(android-distribution-directory,
1904 [  --with-android-distribution-directory=dir
1905                           Optional Firefox for Android partner distribution directory.],
1906   MOZ_ANDROID_DISTRIBUTION_DIRECTORY=$withval)
1908 if test -n "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY"; then
1909   # A distribution directory must have an assets/distribution directory.
1910   # See https://wiki.mozilla.org/Mobile/Distribution_Files.
1911   if test ! -d "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY/assets/distribution" ; then
1912     AC_MSG_ERROR([--with-android-distribution-directory does not contain assets/distribution;
1913                   (looked for ${MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets/distribution).])
1914   fi
1916 AC_SUBST(MOZ_ANDROID_DISTRIBUTION_DIRECTORY)
1918 dnl ========================================================
1919 dnl = Trademarked Branding
1920 dnl ========================================================
1921 MOZ_ARG_ENABLE_BOOL(official-branding,
1922 [  --enable-official-branding
1923                           Enable Official mozilla.org Branding
1924                           Do not distribute builds with
1925                           --enable-official-branding unless you have
1926                           permission to use trademarks per
1927                           http://www.mozilla.org/foundation/trademarks/ .],
1928     MOZ_OFFICIAL_BRANDING=1,
1929     MOZ_OFFICIAL_BRANDING=)
1931 # Allow the application to influence configure with a confvars.sh script.
1932 AC_MSG_CHECKING([if app-specific confvars.sh exists])
1933 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
1934   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
1935   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
1936 else
1937   AC_MSG_RESULT([no])
1940 # Allow influencing configure with a defines.sh script.
1941 . "${srcdir}/build/defines.sh"
1943 # If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
1944 # set in defines.sh
1945 if test "$BUILDING_RELEASE"; then
1946   # Override value in defines.sh, if any
1947   EARLY_BETA_OR_EARLIER=
1948 elif test "$EARLY_BETA_OR_EARLIER"; then
1949   AC_DEFINE(EARLY_BETA_OR_EARLIER)
1951 AC_SUBST(EARLY_BETA_OR_EARLIER)
1953 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
1954 MOZ_ARG_WITH_STRING(app-name,
1955 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
1956 WITH_APP_NAME=$withval,
1959 if test -n "$WITH_APP_NAME" ; then
1960     MOZ_APP_NAME="$WITH_APP_NAME"
1963 MOZ_ARG_WITH_STRING(app-basename,
1964 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
1965 WITH_APP_BASENAME=$withval,
1968 if test -n "$WITH_APP_BASENAME" ; then
1969     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
1972 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
1973 # that haven't made a confvars.sh yet. Don't add new stuff here, use
1974 # MOZ_BUILD_APP.
1975 case "$MOZ_BUILD_APP" in
1976 browser)
1977   AC_DEFINE(MOZ_PHOENIX)
1978   ;;
1980 xulrunner)
1981   AC_DEFINE(MOZ_XULRUNNER)
1982   ;;
1983 esac
1985 # Graphene is a desktop runtime for running applications with a HTML UI.
1986 if test -n "$MOZ_GRAPHENE"; then
1987     AC_DEFINE(MOZ_GRAPHENE)
1990 AC_SUBST(MOZ_PHOENIX)
1991 AC_SUBST(MOZ_XULRUNNER)
1993 dnl ========================================================
1994 dnl Ensure Android SDK and build-tools versions depending on
1995 dnl mobile target.
1996 dnl ========================================================
1998 case "$MOZ_BUILD_APP" in
1999 mobile/android)
2000     MOZ_ANDROID_SDK(26, 26, 27.0.3)
2001     ;;
2002 esac
2004 dnl ========================================================
2005 dnl =
2006 dnl = Toolkit Options
2007 dnl =
2008 dnl ========================================================
2009 MOZ_ARG_HEADER(Toolkit Options)
2011 dnl ========================================================
2012 dnl = Enable the toolkit as needed                         =
2013 dnl ========================================================
2015 case "$MOZ_WIDGET_TOOLKIT" in
2017 cocoa)
2018     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
2019     # Use -Wl as a trick to avoid -framework and framework names from
2020     # being separated by AC_SUBST_LIST.
2021     TK_LIBS='-Wl,-framework,Foundation -Wl,-framework,CoreFoundation -Wl,-framework,CoreLocation -Wl,-framework,QuartzCore -Wl,-framework,Carbon -Wl,-framework,CoreAudio -Wl,-framework,CoreVideo -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,AddressBook -Wl,-framework,OpenGL -Wl,-framework,Security -Wl,-framework,ServiceManagement -Wl,-framework,CoreServices -Wl,-framework,ApplicationServices -Wl,-framework,AppKit'
2022     TK_CFLAGS=""
2023     CFLAGS="$CFLAGS $TK_CFLAGS"
2024     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
2025     MOZ_USER_DIR="Mozilla"
2026     MOZ_FS_LAYOUT=bundle
2027     ;;
2029 uikit)
2030     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
2031     TK_CFLAGS=""
2032     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'
2033     CFLAGS="$CFLAGS $TK_CFLAGS"
2034     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
2035     MOZ_USER_DIR="Mozilla"
2036     MOZ_FS_LAYOUT=bundle
2037     ;;
2039 esac
2041 dnl there are a lot of tests on MOZ_ENABLE_GTK below, that are more convenient
2042 dnl to keep that way than testing against MOZ_WIDGET_TOOLKIT
2043 case "$MOZ_WIDGET_TOOLKIT" in
2044 gtk*)
2045     MOZ_ENABLE_GTK=1
2046     ;;
2047 esac
2049 if test "$COMPILE_ENVIRONMENT"; then
2050   if test "$MOZ_WIDGET_TOOLKIT" = gtk3; then
2051     PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 gio-unix-2.0 $GDK_PACKAGES)
2052     MOZ_GTK3_CFLAGS="-I${_topsrcdir}/widget/gtk/compat-gtk3 $MOZ_GTK3_CFLAGS"
2053     TK_CFLAGS=$MOZ_GTK3_CFLAGS
2054     TK_LIBS=$MOZ_GTK3_LIBS
2055     dnl GDK_VERSION_MIN_REQUIRED is not set here as GDK3 deprecated warnings
2056     dnl are suppressed by widget/gtk/compat-gtk3/gdk/gdkversionmacros.h.
2057     AC_DEFINE_UNQUOTED(GDK_VERSION_MAX_ALLOWED,$GDK_VERSION_MAX_ALLOWED)
2058     GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32
2059   fi
2060   if test "$MOZ_ENABLE_GTK"; then
2061     if test "$MOZ_X11"; then
2062       GDK_PACKAGES=gdk-x11-2.0
2063     fi
2064     AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
2065     AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)
2067     PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 >= $GLIB_VERSION gobject-2.0 gio-unix-2.0 $GDK_PACKAGES)
2068     MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
2069   fi
2070 fi # COMPILE_ENVIRONMENT
2072 AC_SUBST(MOZ_FS_LAYOUT)
2074 dnl ========================================================
2075 dnl = startup-notification support module
2076 dnl ========================================================
2078 if test "$MOZ_ENABLE_GTK"
2079 then
2080     MOZ_ENABLE_STARTUP_NOTIFICATION=
2082     MOZ_ARG_ENABLE_BOOL(startup-notification,
2083     [  --enable-startup-notification
2084                           Enable startup-notification support (default: disabled) ],
2085         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
2086         MOZ_ENABLE_STARTUP_NOTIFICATION=)
2087     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
2088     then
2089         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
2090                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
2091         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
2092             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
2093             then
2094                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
2095             fi
2096             MOZ_ENABLE_STARTUP_NOTIFICATION=
2097         ])
2098     fi
2100     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
2101         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
2102     fi
2104     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
2106 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
2108 AC_SUBST_LIST(TK_CFLAGS)
2109 AC_SUBST_LIST(TK_LIBS)
2111 AC_SUBST(MOC)
2112 AC_SUBST(RCC)
2114 dnl ========================================================
2115 dnl =
2116 dnl = Components & Features
2117 dnl =
2118 dnl ========================================================
2119 MOZ_ARG_HEADER(Components and Features)
2121 AC_SUBST(MOZ_OFFICIAL_BRANDING)
2122 if test -n "$MOZ_OFFICIAL_BRANDING"; then
2123   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
2124     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
2125   else
2126     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
2127     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
2128   fi
2131 MOZ_ARG_WITH_STRING(branding,
2132 [  --with-branding=dir     Use branding from the specified directory.],
2133     MOZ_BRANDING_DIRECTORY=$withval)
2135 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
2136 if test -z "$REAL_BRANDING_DIRECTORY"; then
2137   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
2140 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
2141   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
2142 elif test -f "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
2143   . "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"
2146 AC_SUBST(MOZ_BRANDING_DIRECTORY)
2148 dnl ========================================================
2149 dnl = Distribution ID
2150 dnl ========================================================
2151 MOZ_ARG_WITH_STRING(distribution-id,
2152 [  --with-distribution-id=ID
2153                           Set distribution-specific id (default=org.mozilla)],
2154 [ val=`echo $withval`
2155     MOZ_DISTRIBUTION_ID="$val"])
2157 if test -z "$MOZ_DISTRIBUTION_ID"; then
2158    MOZ_DISTRIBUTION_ID="org.mozilla"
2161 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
2162 AC_SUBST(MOZ_DISTRIBUTION_ID)
2164 dnl ========================================================
2165 dnl = GConf support module
2166 dnl ========================================================
2168 if test "$MOZ_X11"
2169 then
2170     if test "$MOZ_ENABLE_GTK"
2171     then
2172         MOZ_ENABLE_GCONF=1
2173     fi
2175     dnl ========================================================
2176     dnl = GConf support module
2177     dnl ========================================================
2178     MOZ_ARG_DISABLE_BOOL(gconf,
2179     [  --disable-gconf      Disable Gconf support ],
2180         MOZ_ENABLE_GCONF=,
2181         MOZ_ENABLE_GCONF=1)
2183     if test "$MOZ_ENABLE_GCONF"
2184     then
2185         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
2186             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
2187             MOZ_ENABLE_GCONF=1
2188         ],[
2189             if test -n "$MOZ_ENABLE_GCONF";
2190             then
2191                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
2192             else
2193                 AC_MSG_WARN([Many automated tests will fail with --disable-gconf. See bug 1167201.])
2194             fi
2195         ])
2196     fi
2198     if test "$MOZ_ENABLE_GCONF"; then
2199         AC_DEFINE(MOZ_ENABLE_GCONF)
2200     fi
2202     AC_SUBST(MOZ_ENABLE_GCONF)
2205 dnl ========================================================
2206 dnl = libproxy support
2207 dnl ========================================================
2209 if test "$MOZ_ENABLE_GTK"
2210 then
2211     MOZ_ENABLE_LIBPROXY=
2213     MOZ_ARG_ENABLE_BOOL(libproxy,
2214     [  --enable-libproxy         Enable libproxy support ],
2215     MOZ_ENABLE_LIBPROXY=1,
2216     MOZ_ENABLE_LIBPROXY=)
2218     if test "$MOZ_ENABLE_LIBPROXY"
2219     then
2220         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
2221         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
2222     fi
2224 AC_SUBST(MOZ_ENABLE_LIBPROXY)
2226 dnl ========================================================
2227 dnl = dbus support
2228 dnl ========================================================
2230 if test "$MOZ_ENABLE_GTK"
2231 then
2232     MOZ_ENABLE_DBUS=1
2234     MOZ_ARG_DISABLE_BOOL(dbus,
2235     [  --disable-dbus          Disable dbus support ],
2236         MOZ_ENABLE_DBUS=,
2237         MOZ_ENABLE_DBUS=1)
2239     if test "$MOZ_ENABLE_DBUS"
2240     then
2241         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
2242         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
2243         AC_DEFINE(MOZ_ENABLE_DBUS)
2244     fi
2246 AC_SUBST(MOZ_ENABLE_DBUS)
2248 dnl =========================================================
2249 dnl = Whether to exclude hyphenations files in the build
2250 dnl =========================================================
2251 if test -n "$MOZ_EXCLUDE_HYPHENATION_DICTIONARIES"; then
2252     AC_DEFINE(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
2255 AC_TRY_COMPILE([#include <linux/ethtool.h>],
2256                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
2257                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
2259 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
2261 if test -n "$MOZ_WEBRTC"; then
2262     if test -n "$MOZ_X11"; then
2263       MOZ_WEBRTC_X11_LIBS="-lXext -lXdamage -lXfixes -lXcomposite"
2264     fi
2267 AC_SUBST_LIST(MOZ_WEBRTC_X11_LIBS)
2269 dnl ========================================================
2270 dnl = Apple platform decoder support
2271 dnl ========================================================
2272 if test "$COMPILE_ENVIRONMENT"; then
2273 if test -n "$MOZ_APPLEMEDIA"; then
2274   # hack in frameworks for fmp4 - see bug 1029974
2275   # We load VideoToolbox and CoreMedia dynamically, so they don't appear here.
2276   LDFLAGS="$LDFLAGS -framework AudioToolbox"
2277   dnl Verify CoreMedia is available.
2278   AC_CHECK_HEADERS([CoreMedia/CoreMedia.h VideoToolbox/VideoToolbox.h], [],
2279     [AC_MSG_ERROR([MacOS X 10.9 SDK or later is required])])
2281 fi # COMPILE_ENVIRONMENT
2283 dnl system libvpx Support
2284 dnl ========================================================
2285 MOZ_ARG_WITH_BOOL(system-libvpx,
2286 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
2287     MOZ_SYSTEM_LIBVPX=1)
2289 MOZ_LIBVPX_CFLAGS=
2290 MOZ_LIBVPX_LIBS=
2292 _SAVE_CFLAGS=$CFLAGS
2293 _SAVE_LIBS=$LIBS
2294 if test -n "$MOZ_SYSTEM_LIBVPX"; then
2295     dnl ============================
2296     dnl === libvpx Version check ===
2297     dnl ============================
2298     dnl Check to see if we have a system libvpx package.
2299     PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.5.0)
2301     CFLAGS="$CFLAGS $MOZ_LIBVPX_CFLAGS"
2302     LIBS="$LIBS $MOZ_LIBVPX_LIBS"
2304     MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [],
2305      [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.])])
2307     AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [],
2308      [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
2310     MOZ_CHECK_HEADER([vpx_mem/vpx_mem.h],
2311      [AC_CHECK_FUNC(vpx_mem_set_functions)])
2312     if test "$ac_cv_header_vpx_mem_vpx_mem_h" = no -o \
2313             "$ac_cv_func_vpx_mem_set_functions" = no; then
2314         AC_DEFINE(MOZ_VPX_NO_MEM_REPORTING)
2315     fi
2317 CFLAGS=$_SAVE_CFLAGS
2318 LIBS=$_SAVE_LIBS
2320 AC_SUBST(MOZ_SYSTEM_LIBVPX)
2321 AC_SUBST_LIST(MOZ_LIBVPX_CFLAGS)
2322 AC_SUBST_LIST(MOZ_LIBVPX_LIBS)
2324 if test -z "$MOZ_SYSTEM_LIBVPX"; then
2326     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
2327     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
2328     dnl We currently require gcc on all arm platforms.
2330     dnl See if we have assembly on this platform.
2331     case "$OS_ARCH:$CPU_ARCH" in
2332     Darwin:x86)
2333       VPX_USE_YASM=1
2334       VPX_X86_ASM=1
2335     ;;
2336     Darwin:x86_64)
2337       VPX_USE_YASM=1
2338       VPX_X86_ASM=1
2339     ;;
2340     WINNT:x86_64)
2341       VPX_USE_YASM=1
2342       VPX_X86_ASM=1
2343     ;;
2344     WINNT:x86)
2345       dnl Check for yasm 1.1 or greater.
2346       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
2347         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.])
2348       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
2349         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.])
2350       else
2351         VPX_USE_YASM=1
2352         VPX_X86_ASM=1
2353         dnl The encoder needs obj_int_extract to get asm offsets.
2354       fi # COMPILE_ENVIRONMENT and others
2355     ;;
2356     *:arm*)
2357       if test -n "$GNU_AS" ; then
2358         dnl These flags are a lie; they're just used to enable the requisite
2359         dnl opcodes; actual arch detection is done at runtime.
2360         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
2361         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/libvpx/build/make/ads2gas.pl'
2362         VPX_ARM_ASM=1
2363         dnl Building with -mfpu=neon requires either the "softfp" or the
2364         dnl "hardfp" ABI. Depending on the compiler's default target, and the
2365         dnl CFLAGS, the default ABI might be neither, in which case it is the
2366         dnl "softfloat" ABI.
2367         dnl The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
2368         dnl we can safely mix code built with both ABIs. So, if we detect
2369         dnl that compiling uses the "softfloat" ABI, force the use of the
2370         dnl "softfp" ABI instead.
2371         dnl Confusingly, the __SOFTFP__ preprocessor variable indicates the
2372         dnl "softfloat" ABI, not the "softfp" ABI.
2373         dnl Note: VPX_ASFLAGS is also used in CFLAGS.
2374         AC_TRY_COMPILE([],
2375           [#ifndef __SOFTFP__
2376            #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
2377            #endif],
2378            VPX_ASFLAGS="$VPX_ASFLAGS -mfloat-abi=softfp"
2379            )
2380       fi
2381     ;;
2382     *:x86)
2383       if $CC -E -dM -</dev/null | grep -q __ELF__; then
2384         VPX_USE_YASM=1
2385         VPX_X86_ASM=1
2386       fi
2387     ;;
2388     *:x86_64)
2389       if $CC -E -dM -</dev/null | grep -q __ELF__; then
2390         VPX_USE_YASM=1
2391         VPX_X86_ASM=1
2392       fi
2393     ;;
2394     esac
2396     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_USE_YASM" -a -z "$YASM"; then
2397       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.])
2398     fi # COMPILE_ENVIRONMENT and others
2400     if test -n "$VPX_USE_YASM" && test "$OS_ARCH:$CPU_ARCH" != "WINNT:x86_64"; then
2401       VPX_ASFLAGS="-DPIC"
2402     fi
2404     if test -n "$VPX_X86_ASM"; then
2405       AC_DEFINE(VPX_X86_ASM)
2406     elif test -n "$VPX_ARM_ASM"; then
2407       AC_DEFINE(VPX_ARM_ASM)
2408     else
2409       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
2410     fi
2412     dnl native libvpx no longer has vpx_mem_set_functions
2413     AC_DEFINE(MOZ_VPX_NO_MEM_REPORTING)
2416 dnl ========================================================
2417 dnl = Handle dependent MEDIA defines
2418 dnl ========================================================
2420 MOZ_WEBM_ENCODER=1
2421 AC_DEFINE(MOZ_WEBM_ENCODER)
2422 AC_SUBST(MOZ_WEBM_ENCODER)
2424 dnl ========================================================
2425 dnl NegotiateAuth
2426 dnl ========================================================
2428 MOZ_ARG_DISABLE_BOOL(negotiateauth,
2429 [  --disable-negotiateauth Disable GSS-API negotiation ],
2430     MOZ_AUTH_EXTENSION=,
2431     MOZ_AUTH_EXTENSION=1 )
2433 if test -n "$MOZ_IOS" -a -n "$MOZ_AUTH_EXTENSION"; then
2434    AC_MSG_ERROR([negotiateauth is not supported on iOS.])
2437 dnl ========================================================
2438 dnl Pref extensions (autoconfig)
2439 dnl ========================================================
2440 MOZ_ARG_DISABLE_BOOL(pref-extensions,
2441 [  --disable-pref-extensions
2442                           Disable pref extensions such as autoconfig],
2443   MOZ_PREF_EXTENSIONS=,
2444   MOZ_PREF_EXTENSIONS=1 )
2446 dnl ========================================================
2447 dnl Searching of system directories for extensions.
2448 dnl Note: this switch is meant to be used for test builds
2449 dnl whose behavior should not depend on what happens to be
2450 dnl installed on the local machine.
2451 dnl ========================================================
2452 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
2453 [  --disable-system-extension-dirs
2454                           Disable searching system- and account-global
2455                           directories for extensions of any kind; use
2456                           only profile-specific extension directories],
2457   ENABLE_SYSTEM_EXTENSION_DIRS=,
2458   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
2459 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
2460   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
2463 dnl ========================================================
2464 dnl = Universalchardet
2465 dnl ========================================================
2466 MOZ_ARG_DISABLE_BOOL(universalchardet,
2467 [  --disable-universalchardet
2468                           Disable universal encoding detection],
2469   MOZ_UNIVERSALCHARDET=,
2470   MOZ_UNIVERSALCHARDET=1 )
2472 dnl ========================================================
2473 dnl = ANGLE OpenGL->D3D translator for WebGL
2474 dnl = * only applies to win32 (and then, not MINGW)
2475 dnl ========================================================
2477 MOZ_ANGLE_RENDERER=
2478 MOZ_D3D_CPU_SUFFIX=
2479 MOZ_HAS_WINSDK_WITH_D3D=
2480 MOZ_D3DCOMPILER_VISTA_DLL=
2481 MOZ_D3DCOMPILER_VISTA_DLL_PATH=
2483 if test "$COMPILE_ENVIRONMENT" ; then
2484 case "$target_os" in
2485 *mingw*)
2486     MOZ_ANGLE_RENDERER=1
2487     ;;
2488 esac
2490 # The DirectX SDK libraries are split into x86 and x64 sub-directories
2491 case "${target_cpu}" in
2492 i*86)
2493   MOZ_D3D_CPU_SUFFIX=x86
2494   ;;
2495 x86_64)
2496   MOZ_D3D_CPU_SUFFIX=x64
2497   ;;
2498 aarch64)
2499   MOZ_D3D_CPU_SUFFIX=arm
2500   ;;
2501 esac
2503 dnl ========================================================
2504 dnl D3D compiler DLL
2505 dnl ========================================================
2506 MOZ_FOUND_D3D_COMPILERS=
2508 if test -n "$MOZ_ANGLE_RENDERER"; then
2509   if test -z "$MOZ_D3D_CPU_SUFFIX"; then
2510     AC_MSG_ERROR([Couldn't determine MOZ_D3D_CPU_SUFFIX.])
2511   fi
2513   ######################################
2514   # Find _46+ for use by Vista+.
2516   # Find a D3D compiler DLL in a Windows SDK.
2517   MOZ_D3DCOMPILER_VISTA_DLL=
2518   case "$MOZ_WINSDK_MAXVER" in
2519   0x0603*|0x0A00*)
2520     MOZ_D3DCOMPILER_VISTA_DLL=d3dcompiler_47.dll
2521     AC_MSG_RESULT([Found D3D compiler in Windows SDK.])
2522   ;;
2523   esac
2525   if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
2526     # We have a name, now track down the path.
2527     if test -n "$WINDOWSSDKDIR"; then
2528       MOZ_D3DCOMPILER_VISTA_DLL_PATH="$WINDOWSSDKDIR/Redist/D3D/$MOZ_D3D_CPU_SUFFIX/$MOZ_D3DCOMPILER_VISTA_DLL"
2529       if test -f "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
2530         AC_MSG_RESULT([Found MOZ_D3DCOMPILER_VISTA_DLL_PATH: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
2531         MOZ_HAS_WINSDK_WITH_D3D=1
2532       elif test "$target_cpu" = "aarch64" -a "$MOZ_D3DCOMPILER_VISTA_DLL" = "d3dcompiler_47.dll"; then
2533         AC_MSG_RESULT([AArch64 Windows includes d3dcompiler DLLs])
2534         MOZ_D3DCOMPILER_VISTA_DLL_PATH=
2535       else
2536         AC_MSG_RESULT([MOZ_D3DCOMPILER_VISTA_DLL_PATH doesn't exist: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
2537         AC_MSG_ERROR([Windows SDK at "$WINDOWSSDKDIR" appears broken. Try updating to MozillaBuild 1.9 final or higher.])
2538         MOZ_D3DCOMPILER_VISTA_DLL_PATH=
2539       fi
2540     else
2541       AC_MSG_RESULT([Windows SDK not found.])
2542     fi
2543   else
2544     if test "$OS_ARCH" = "$HOST_OS_ARCH"; then
2545       AC_MSG_ERROR([Couldn't find Windows SDK 8.1 or higher needed for ANGLE.])
2546     else
2547       AC_MSG_RESULT([Windows SDK not needed for ANGLE in Linux MinGW build.])
2548     fi
2549   fi
2551   if test -z "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
2552     MOZ_D3DCOMPILER_VISTA_DLL=
2553   fi
2555   # On mingw, check if headers are provided by toolchain.
2556   if test -n "$GNU_CC"; then
2557     MOZ_CHECK_HEADER(d3d10.h, MOZ_HAS_WINSDK_WITH_D3D=1)
2558   fi
2560   ######################################
2561   # Check that we found what we needed.
2562   MOZ_FOUND_A_D3D_COMPILER=
2564   if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
2565     MOZ_FOUND_A_D3D_COMPILER=1
2566     AC_MSG_RESULT([Found d3dcompiler DLL for Vista+: $MOZ_D3DCOMPILER_VISTA_DLL])
2567   fi
2569   if test -z "$CROSS_COMPILE"; then
2570     if test -z "MOZ_FOUND_A_D3D_COMPILER"; then
2571       AC_MSG_ERROR([Couldn't find an acceptable D3D compiler DLL.])
2572     fi
2573   fi
2574 fi # MOZ_ANGLE_RENDERER
2576 dnl ========================================================
2577 dnl Gamepad support
2578 dnl ========================================================
2580 dnl Moved gamepad platform check to moz.build, linux header check still needed here.
2581 if test "$OS_TARGET" = "Linux"; then
2582     MOZ_CHECK_HEADER([linux/joystick.h])
2583     if test "$ac_cv_header_linux_joystick_h" != "yes"; then
2584       AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers.])
2585     fi
2588 fi # COMPILE_ENVIRONMENT
2591 dnl ========================================================
2592 dnl = Breakpad crash reporting (on by default on supported platforms)
2593 dnl ========================================================
2595 case $target in
2596 i?86-*-mingw*|x86_64-*-mingw*)
2597   MOZ_CRASHREPORTER=1
2598   ;;
2599 i?86-apple-darwin*|x86_64-apple-darwin*)
2600   if test -z "$MOZ_IOS"; then
2601     MOZ_CRASHREPORTER=1
2602   fi
2603   ;;
2604 *-android*|*-linuxandroid*)
2605   dnl Android/arm is arm-unknown-linux-androideabi, so android condition should
2606   dnl be before Linux condition
2607   MOZ_CRASHREPORTER=1
2608   ;;
2609 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
2610   if test "$MOZ_ENABLE_GTK"; then
2611     MOZ_CRASHREPORTER=1
2612   fi
2613   ;;
2614 esac
2616 MOZ_ARG_DISABLE_BOOL(crashreporter,
2617 [  --disable-crashreporter Disable breakpad crash reporting],
2618     [MOZ_CRASHREPORTER=],
2619     [MOZ_CRASHREPORTER=F # Force enable breakpad])
2621 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "Darwin"; then
2622   if test "$MOZ_CRASHREPORTER" = F; then
2623     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
2624   fi
2625   MOZ_CRASHREPORTER=
2628 if test -n "$MOZ_CRASHREPORTER"; then
2629    AC_DEFINE(MOZ_CRASHREPORTER)
2631   if test "$OS_TARGET" = "Linux" && \
2632     test -z "$SKIP_LIBRARY_CHECKS"; then
2633     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
2634   fi
2636   if test "$OS_ARCH" = "WINNT"; then
2637     if test -z "$HAVE_64BIT_BUILD" -a -n "$COMPILE_ENVIRONMENT"; then
2638       MOZ_CRASHREPORTER_INJECTOR=1
2639       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
2640     fi
2641   fi
2644 dnl ========================================================
2645 dnl = libjpeg-turbo configuration
2646 dnl ========================================================
2647 MOZ_LIBJPEG_TURBO=
2648 LIBJPEG_TURBO_USE_YASM=
2649 if test -z "$MOZ_SYSTEM_JPEG"; then
2650     MOZ_LIBJPEG_TURBO=1
2653 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
2654 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
2655     MOZ_LIBJPEG_TURBO=,
2656     MOZ_LIBJPEG_TURBO=1)
2658 if test "$MOZ_SYSTEM_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
2659     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
2662 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
2663 dnl files.
2665 if test -n "$MOZ_LIBJPEG_TURBO" -a -n "$COMPILE_ENVIRONMENT"; then
2667   dnl Do we support libjpeg-turbo on this platform?
2668   case "$OS_ARCH:$CPU_ARCH" in
2669   Darwin:x86)
2670     LIBJPEG_TURBO_ASFLAGS="-DPIC -DMACHO"
2671   ;;
2672   Darwin:x86_64)
2673     LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DMACHO"
2674   ;;
2675   Darwin:arm*)
2676   ;;
2677   WINNT:x86)
2678     LIBJPEG_TURBO_ASFLAGS="-DPIC -DWIN32"
2679   ;;
2680   WINNT:x86_64)
2681     LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DWIN64 -DMSVC"
2682   ;;
2683   WINNT:*)
2684   ;;
2685   *:arm)
2686     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
2687   ;;
2688   *:aarch64)
2689     LIBJPEG_TURBO_ASFLAGS="-march=armv8-a"
2690   ;;
2691   *:mips32)
2692     LIBJPEG_TURBO_ASFLAGS="-mdspr2"
2693   ;;
2694   *:x86)
2695     if $CC -E -dM -</dev/null | grep -q __ELF__; then
2696       LIBJPEG_TURBO_ASFLAGS="-DPIC -DELF"
2697     fi
2698   ;;
2699   *:x86_64)
2700     if $CC -E -dM -</dev/null | grep -q __ELF__; then
2701       LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DELF"
2702     fi
2703   ;;
2704   esac
2707 if test -n "$LIBJPEG_TURBO_ASFLAGS"; then
2708   case "$CPU_ARCH" in
2709 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
2710 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
2711 dnl it doesn't exist or we have too old of a version.
2712   x86_64|x86)
2713     LIBJPEG_TURBO_USE_YASM=1
2715     if test -z "$YASM" ; then
2716         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.])
2717     fi
2719     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
2720     dnl on Linux and 1.1 or newer everywhere else.
2721     if test "$OS_ARCH" = "Linux" ; then
2722         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
2723             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.])
2724         fi
2725     else
2726         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
2727             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.])
2728         fi
2729     fi
2730   ;;
2731   esac
2734 dnl ========================================================
2735 dnl = libav-fft configuration
2736 dnl ========================================================
2738 MOZ_LIBAV_FFT=
2740 dnl Turn on libav-fft for 32-bit windows, and all 64-bit supported platforms.
2741 dnl 32-bit linux/os x have text relocation issues.
2743 case "$OS_ARCH:$CPU_ARCH" in
2744   WINNT:x86)
2745       MOZ_LIBAV_FFT=1
2746   ;;
2747   *:x86_64)
2748       MOZ_LIBAV_FFT=1
2749   ;;
2750 esac
2752 dnl Detect if we can use yasm to compile libav's assembly
2754 if test -n "$MOZ_LIBAV_FFT" -a -n "$COMPILE_ENVIRONMENT"; then
2755   AC_DEFINE(MOZ_LIBAV_FFT)
2756   dnl Do we support libav-fft on this platform?
2757   case "$OS_ARCH:$CPU_ARCH" in
2758   Darwin:x86_64)
2759     LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DMACHO"
2760   ;;
2761   WINNT:x86)
2762     LIBAV_FFT_ASFLAGS="-DPIC -DWIN32"
2763   ;;
2764   WINNT:x86_64)
2765     LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DWIN64 -DMSVC"
2766   ;;
2767   *:x86_64)
2768     if $CC -E -dM -</dev/null | grep -q __ELF__; then
2769       LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DELF"
2770     fi
2771   ;;
2772   *)
2773     AC_MSG_ERROR([libav's FFT routines are only available for 32-bit windows or 64-bit x86 based platforms.])
2774   ;;
2775   esac
2778 if test -n "$LIBAV_FFT_ASFLAGS"; then
2779   dnl If we're on an x86 or x64 system which supports libav-fft's asm routines
2780   dnl check for Yasm, and error out if it doesn't exist or we have too old of a
2781   dnl version.
2782   if test -z "$YASM" ; then
2783     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.])
2784   fi
2785   dnl Check that we have the right yasm version.  We require 1.0.1 or newer
2786   dnl on Linux and 1.1 or newer everywhere else.
2787   if test "$OS_ARCH" = "Linux" ; then
2788     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
2789       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.])
2790     fi
2791   else
2792     if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
2793       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.])
2794     fi
2795   fi
2796 elif test -n "$MOZ_LIBAV_FFT" -a "${CPU_ARCH}" != "arm"; then
2797   dnl Warn if we're not building either libav or opendl-max optimized routines.
2798   AC_MSG_WARN([No assembler or assembly support for libav-fft.  Using unoptimized C routines.])
2801 dnl ========================================================
2802 dnl = FFmpeg's ffvpx configuration
2803 dnl ========================================================
2805 MOZ_FFVPX=
2806 MOZ_FFVPX_FLACONLY=
2807 case "$CPU_ARCH" in
2808   x86|x86_64)
2809       MOZ_FFVPX=1
2810       dnl Use same conditional as MOZ_LIBAV_FFT to enable FFmpeg's ffvpx assembly decoder.
2811       if test -n "$LIBAV_FFT_ASFLAGS"; then
2812           FFVPX_ASFLAGS=$LIBAV_FFT_ASFLAGS
2813       else
2814           dnl On x86 system with assembly optimizations disabled, the ffvp9 and
2815           dnl ffvp8 decoders give worse performance than libvpx ones. So we only
2816           dnl enable the FFmpeg FLAC decoder on those machines.
2817           MOZ_FFVPX_FLACONLY=1
2818       fi
2819   ;;
2820   arm*|aarch64)
2821       case "$OS_TARGET" in
2822         WINNT)
2823           dnl don't set up anything special
2824           ;;
2825         *)
2826           MOZ_FFVPX=1
2827           MOZ_FFVPX_FLACONLY=1
2828           dnl Use same conditional as MOZ_LIBVPX to enable FFmpeg's ffvpx assembly decoder.
2829           dnl aarch 64 FLAC decoder for now will be C only.
2830           FFVPX_ASFLAGS=$VPX_ASFLAGS
2831           ;;
2832       esac
2833   ;;
2834 esac
2836 if test -n "$MOZ_FFVPX"; then
2837   AC_DEFINE(MOZ_FFVPX)
2839 if test -n "$MOZ_FFVPX_FLACONLY"; then
2840   AC_DEFINE(MOZ_FFVPX_FLACONLY)
2843 dnl ========================================================
2844 dnl = Enable compilation of specific extension modules
2845 dnl ========================================================
2847 MOZ_ARG_ENABLE_STRING(extensions,
2848 [  --enable-extensions     Enable extensions],
2849 [ for option in `echo $enableval | sed 's/,/ /g'`; do
2850     if test "$option" = "yes" -o "$option" = "all"; then
2851         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
2852     elif test "$option" = "no" -o "$option" = "none"; then
2853         MOZ_EXTENSIONS=""
2854     elif test "$option" = "default"; then
2855         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
2856     elif test `echo "$option" | grep -c \^-` != 0; then
2857         option=`echo $option | sed 's/^-//'`
2858         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
2859     else
2860         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
2861     fi
2862 done],
2863     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
2865 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
2866 dnl when trying to build a nonexistent extension.
2867 for extension in $MOZ_EXTENSIONS; do
2868     if test ! -d "${srcdir}/extensions/${extension}"; then
2869         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
2870     fi
2871 done
2873 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
2874   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
2877 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
2878 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
2879 if test -n "$MOZ_TREE_FREETYPE" -a "$OS_TARGET" != WINNT; then
2880    MOZ_ENABLE_CAIRO_FT=1
2881    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
2882    CAIRO_FT_CFLAGS="-I$_topsrcdir/modules/freetype2/include"
2883    AC_SUBST_LIST(CAIRO_FT_CFLAGS)
2886 AC_CHECK_PROGS(WGET, wget, "")
2887 AC_SUBST(WGET)
2889 dnl ========================================================
2890 dnl Enable building the signmar program.
2891 dnl This option is much different than the --enable-verify-mar option.
2892 dnl --enable-verify-mar is for enabling the verification check on MAR
2893 dnl files in the updater.  The --enable-signmar option is for building
2894 dnl the signmar program.
2895 dnl ========================================================
2897 MOZ_ARG_ENABLE_BOOL(signmar,
2898 [  --enable-signmar     Enable building the signmar program],
2899     MOZ_ENABLE_SIGNMAR=1,
2900     MOZ_ENABLE_SIGNMAR= )
2902 if test -n "$MOZ_ENABLE_SIGNMAR"; then
2903   if test -z "$COMPILE_ENVIRONMENT" ; then
2904     AC_MSG_WARN([Cannot --enable-signmar with --disable-compile-environment])
2905     MOZ_ENABLE_SIGNMAR=
2906   else
2907     AC_DEFINE(MOZ_ENABLE_SIGNMAR)
2908   fi
2911 dnl ========================================================
2912 dnl Updater
2913 dnl ========================================================
2915 if test "$MOZ_IOS"; then
2916   MOZ_UPDATER=
2919 MOZ_ARG_DISABLE_BOOL(updater,
2920 [  --disable-updater       Disable building of updater],
2921     MOZ_UPDATER=,
2922     MOZ_UPDATER=1 )
2924 if test -n "$MOZ_UPDATER"; then
2925     AC_DEFINE(MOZ_UPDATER)
2928 dnl ========================================================
2929 dnl parental controls (for Windows Vista)
2930 dnl ========================================================
2931 MOZ_ARG_DISABLE_BOOL(parental-controls,
2932 [  --disable-parental-controls
2933                           Do not build parental controls],
2934    MOZ_DISABLE_PARENTAL_CONTROLS=1,
2935    MOZ_DISABLE_PARENTAL_CONTROLS=)
2936 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
2937     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
2940 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
2942 dnl ========================================================
2943 dnl = Disable smartcard support
2944 dnl ========================================================
2945 if test -n "$MOZ_NO_SMART_CARDS"; then
2946     AC_DEFINE(MOZ_NO_SMART_CARDS)
2948 AC_SUBST(MOZ_NO_SMART_CARDS)
2950 dnl ========================================================
2951 dnl = Sandboxing support
2952 dnl ========================================================
2953 if test -n "$MOZ_TSAN" -o -n "$MOZ_ASAN"; then
2954     # Bug 1182565: TSan conflicts with sandboxing on Linux.
2955     # Bug 1287971: LSan also conflicts with sandboxing on Linux.
2956     case $OS_TARGET in
2957     Linux|Android)
2958         MOZ_SANDBOX=
2959         ;;
2960     esac
2963 MOZ_ARG_DISABLE_BOOL(sandbox,
2964 [  --disable-sandbox        Disable sandboxing support],
2965     MOZ_SANDBOX=,
2966     MOZ_SANDBOX=1)
2968 dnl ========================================================
2969 dnl = Content process sandboxing
2970 dnl ========================================================
2972 case "$OS_TARGET" in
2973 WINNT)
2974     MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
2975     ;;
2976 Darwin)
2977     MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
2978     ;;
2979 Linux)
2980     case $CPU_ARCH in
2981         x86_64|x86)
2982             MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
2983         ;;
2984     esac
2985     ;;
2986 esac
2988 MOZ_ARG_ENABLE_BOOL(content-sandbox,
2989 [  --enable-content-sandbox Enable sandboxing support for content-processes
2990   --disable-content-sandbox Disable sandboxing support for content-processes],
2991     MOZ_CONTENT_SANDBOX=1,
2992     MOZ_CONTENT_SANDBOX=)
2994 if test -n "$MOZ_CONTENT_SANDBOX" -a -z "$MOZ_SANDBOX"; then
2995     AC_MSG_ERROR([--enable-content-sandbox and --disable-sandbox are conflicting options])
2998 if test -n "$MOZ_CONTENT_SANDBOX"; then
2999     AC_DEFINE(MOZ_CONTENT_SANDBOX)
3002 AC_SUBST(MOZ_CONTENT_SANDBOX)
3004 dnl ========================================================
3005 dnl = Gecko Media Plugin sandboxing
3006 dnl ========================================================
3007 case $OS_TARGET in
3008 WINNT)
3009     MOZ_GMP_SANDBOX=$MOZ_SANDBOX
3010     ;;
3011 Linux)
3012     case $CPU_ARCH in
3013     x86_64|x86)
3014         MOZ_GMP_SANDBOX=$MOZ_SANDBOX
3015         ;;
3016     esac
3017     ;;
3018 Darwin)
3019     MOZ_GMP_SANDBOX=$MOZ_SANDBOX
3020     ;;
3021 esac
3023 if test -n "$MOZ_GMP_SANDBOX"; then
3024     AC_DEFINE(MOZ_GMP_SANDBOX)
3027 AC_SUBST(MOZ_GMP_SANDBOX)
3029 if test -z "$MOZ_CONTENT_SANDBOX" -a -z "$MOZ_GMP_SANDBOX"; then
3030     MOZ_SANDBOX=
3033 if test -n "$MOZ_SANDBOX"; then
3034     AC_DEFINE(MOZ_SANDBOX)
3037 AC_SUBST(MOZ_SANDBOX)
3040 dnl ========================================================
3041 dnl =
3042 dnl = Module specific options
3043 dnl =
3044 dnl ========================================================
3045 MOZ_ARG_HEADER(Individual module options)
3047 dnl ========================================================
3048 dnl = Disable feed handling components
3049 dnl ========================================================
3050 MOZ_ARG_DISABLE_BOOL(feeds,
3051 [  --disable-feeds         Disable feed handling and processing components],
3052     MOZ_FEEDS=,
3053     MOZ_FEEDS=1 )
3054 if test -n "$MOZ_FEEDS"; then
3055     AC_DEFINE(MOZ_FEEDS)
3056 else
3057     if test "$MOZ_BUILD_APP" = "browser"; then
3058         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
3059     fi
3062 dnl ========================================================
3063 dnl Check for sqlite
3064 dnl ========================================================
3066 MOZ_SYSTEM_SQLITE=
3067 MOZ_ARG_ENABLE_BOOL(system-sqlite,
3068 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
3069 MOZ_SYSTEM_SQLITE=1,
3070 MOZ_SYSTEM_SQLITE= )
3072 if test -n "$MOZ_SYSTEM_SQLITE"
3073 then
3074     dnl ============================
3075     dnl === SQLite Version check ===
3076     dnl ============================
3077     dnl Check to see if the system SQLite package is new enough.
3078     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
3080     dnl ==================================
3081     dnl === SQLITE_SECURE_DELETE check ===
3082     dnl ==================================
3083     dnl Check to see if the system SQLite package is compiled with
3084     dnl SQLITE_SECURE_DELETE enabled.
3085     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
3086     _SAVE_CFLAGS="$CFLAGS"
3087     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3088     _SAVE_LIBS="$LIBS"
3089     LIBS="$LIBS $SQLITE_LIBS"
3090     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
3091         AC_TRY_RUN([
3092             #include "sqlite3.h"
3094             int main(int argc, char **argv){
3095               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
3096             }],
3097             ac_cv_sqlite_secure_delete=yes,
3098             ac_cv_sqlite_secure_delete=no,
3099             ac_cv_sqlite_secure_delete=no
3100         )
3101     ])
3102     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
3103     CFLAGS="$_SAVE_CFLAGS"
3104     LIBS="$_SAVE_LIBS"
3105     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
3106         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
3107     fi
3109     dnl ===============================
3110     dnl === SQLITE_THREADSAFE check ===
3111     dnl ===============================
3112     dnl Check to see if the system SQLite package is compiled with
3113     dnl SQLITE_THREADSAFE enabled.
3114     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
3115     _SAVE_CFLAGS="$CFLAGS"
3116     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3117     _SAVE_LIBS="$LIBS"
3118     LIBS="$LIBS $SQLITE_LIBS"
3119     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
3120         AC_TRY_RUN([
3121             #include "sqlite3.h"
3123             int main(int argc, char **argv){
3124               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
3125             }],
3126             ac_cv_sqlite_threadsafe=yes,
3127             ac_cv_sqlite_threadsafe=no,
3128             ac_cv_sqlite_threadsafe=no
3129         )
3130     ])
3131     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
3132     CFLAGS="$_SAVE_CFLAGS"
3133     LIBS="$_SAVE_LIBS"
3134     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
3135         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
3136     fi
3138     dnl ================================
3139     dnl === SQLITE_ENABLE_FTS3 check ===
3140     dnl ================================
3141     dnl check to see if the system SQLite package is compiled with
3142     dnl SQLITE_ENABLE_FTS3 enabled.
3143     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
3144     _SAVE_CFLAGS="$CFLAGS"
3145     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3146     _SAVE_LIBS="$LIBS"
3147     LIBS="$LIBS $SQLITE_LIBS"
3148     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
3149         AC_TRY_RUN([
3150             #include "sqlite3.h"
3152             int main(int argc, char **argv){
3153               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
3154             }],
3155             ac_cv_sqlite_enable_fts3=yes,
3156             ac_cv_sqlite_enable_fts3=no,
3157             ac_cv_sqlite_enable_fts3=no
3158         )
3159     ])
3160     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
3161     CFLAGS="$_SAVE_CFLAGS"
3162     LIBS="$_SAVE_LIBS"
3163     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
3164         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
3165     fi
3167     dnl =========================================
3168     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
3169     dnl =========================================
3170     dnl check to see if the system SQLite package is compiled with
3171     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
3172     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
3173     _SAVE_CFLAGS="$CFLAGS"
3174     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3175     _SAVE_LIBS="$LIBS"
3176     LIBS="$LIBS $SQLITE_LIBS"
3177     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
3178         AC_TRY_RUN([
3179             #include "sqlite3.h"
3181             int main(int argc, char **argv){
3182               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
3183             }],
3184             ac_cv_sqlite_enable_unlock_notify=yes,
3185             ac_cv_sqlite_enable_unlock_notify=no,
3186             ac_cv_sqlite_enable_unlock_notify=no
3187         )
3188     ])
3189     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
3190     CFLAGS="$_SAVE_CFLAGS"
3191     LIBS="$_SAVE_LIBS"
3192     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
3193         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
3194     fi
3196     dnl =========================================
3197     dnl === SQLITE_ENABLE_DBSTAT_VTAB check ===
3198     dnl =========================================
3199     dnl check to see if the system SQLite package is compiled with
3200     dnl SQLITE_ENABLE_DBSTAT_VTAB.
3201     AC_MSG_CHECKING(for SQLITE_ENABLE_DBSTAT_VTAB support in system SQLite)
3202     _SAVE_CFLAGS="$CFLAGS"
3203     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3204     _SAVE_LIBS="$LIBS"
3205     LIBS="$LIBS $SQLITE_LIBS"
3206     AC_CACHE_VAL(ac_cv_sqlite_dbstat_vtab,[
3207         AC_TRY_RUN([
3208             #include "sqlite3.h"
3210             int main(int argc, char **argv){
3211               return !sqlite3_compileoption_used("SQLITE_ENABLE_DBSTAT_VTAB");
3212             }],
3213             ac_cv_sqlite_dbstat_vtab=yes,
3214             ac_cv_sqlite_dbstat_vtab=no,
3215             ac_cv_sqlite_dbstat_vtab=no
3216         )
3217     ])
3218     AC_MSG_RESULT($ac_cv_sqlite_dbstat_vtab)
3219     CFLAGS="$_SAVE_CFLAGS"
3220     LIBS="$_SAVE_LIBS"
3221     if test "x$ac_cv_sqlite_dbstat_vtab" = "xno"; then
3222         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_DBSTAT_VTAB.])
3223     fi
3224 else
3225     dnl ==============================
3226     dnl === SQLite fdatasync check ===
3227     dnl ==============================
3228     dnl Check to see if fdatasync is available
3229     AC_CHECK_FUNC(fdatasync)
3232 if test -n "$MOZ_SYSTEM_SQLITE"; then
3233     AC_DEFINE(MOZ_SYSTEM_SQLITE)
3235 AC_SUBST(MOZ_SYSTEM_SQLITE)
3237 dnl ========================================================
3238 dnl = Disable zipwriter
3239 dnl ========================================================
3240 MOZ_ARG_DISABLE_BOOL(zipwriter,
3241 [  --disable-zipwriter     Disable zipwriter component],
3242     MOZ_ZIPWRITER=,
3243     MOZ_ZIPWRITER=1 )
3244 AC_SUBST(MOZ_ZIPWRITER)
3246 dnl ========================================================
3247 dnl =
3248 dnl = Feature options that require extra sources to be pulled
3249 dnl =
3250 dnl ========================================================
3251 dnl MOZ_ARG_HEADER(Features that require extra sources)
3253 dnl ========================================================
3254 dnl =
3255 dnl = Runtime debugging and Optimization Options
3256 dnl =
3257 dnl ========================================================
3258 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
3260 dnl ========================================================
3261 dnl enable mobile optimizations
3262 dnl ========================================================
3263 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
3264 [  --enable-mobile-optimize
3265                           Enable mobile optimizations],
3266     MOZ_GFX_OPTIMIZE_MOBILE=1)
3268 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
3270 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
3271     # We ignore paint will resample on mobile for performance.
3272     # We may want to revisit this later.
3273     MOZ_IGNORE_PAINT_WILL_RESAMPLE=1
3275     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
3276     AC_DEFINE(MOZ_IGNORE_PAINT_WILL_RESAMPLE)
3279 dnl ========================================================
3280 dnl = Enable code optimization. ON by default.
3281 dnl ========================================================
3283 # Use value from moz.configure if one is defined. Else use our computed
3284 # value.
3285 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
3286     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
3289 MOZ_SET_FRAMEPTR_FLAGS
3291 if test "$COMPILE_ENVIRONMENT"; then
3292 if test -n "$MOZ_OPTIMIZE"; then
3293     AC_MSG_CHECKING([for valid C compiler optimization flags])
3294     _SAVE_CFLAGS=$CFLAGS
3295     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
3296     AC_TRY_COMPILE([#include <stdio.h>],
3297         [printf("Hello World\n");],
3298         _results=yes,
3299         _results=no)
3300     AC_MSG_RESULT([$_results])
3301     if test "$_results" = "no"; then
3302         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
3303     fi
3304     CFLAGS=$_SAVE_CFLAGS
3305     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
3306         # When using llvm-based LTO, non numeric optimization levels are
3307         # not supported by the linker, so force the linker to use -O2 (
3308         # which doesn't influence the level compilation units are actually
3309         # compiled at).
3310         case " $MOZ_OPTIMIZE_FLAGS " in
3311         *\ -Os\ *|*\ -Oz\ *)
3312             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
3313             ;;
3314         esac
3315     fi
3317 fi # COMPILE_ENVIRONMENT
3319 AC_SUBST_LIST(MOZ_FRAMEPTR_FLAGS)
3320 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
3321 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
3322 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
3324 dnl ========================================================
3325 dnl = Disable treating compiler warnings as errors
3326 dnl ========================================================
3327 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
3328    WARNINGS_AS_ERRORS=''
3331 dnl ========================================================
3332 dnl = Enable runtime logging
3333 dnl ========================================================
3334 AC_DEFINE(MOZ_LOGGING)
3335 AC_DEFINE(FORCE_PR_LOG)
3337 dnl ========================================================
3338 dnl = This will enable logging of addref, release, ctor, dtor.
3339 dnl ========================================================
3340 _ENABLE_LOGREFCNT=42
3341 MOZ_ARG_ENABLE_BOOL(logrefcnt,
3342 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
3343     _ENABLE_LOGREFCNT=1,
3344     _ENABLE_LOGREFCNT= )
3345 if test "$_ENABLE_LOGREFCNT" = "1"; then
3346     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
3347 elif test -z "$_ENABLE_LOGREFCNT"; then
3348     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
3351 dnl ========================================================
3352 dnl moz_dump_painting
3353 dnl ========================================================
3354 MOZ_ARG_ENABLE_BOOL(dump-painting,
3355 [  --enable-dump-painting          Enable paint debugging.],
3356     MOZ_DUMP_PAINTING=1,
3357     MOZ_DUMP_PAINTING= )
3358 if test -n "$MOZ_DUMP_PAINTING"; then
3359     AC_DEFINE(MOZ_DUMP_PAINTING)
3360     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
3362 if test -n "$MOZ_DEBUG"; then
3363     AC_DEFINE(MOZ_DUMP_PAINTING)
3366 case "${OS_TARGET}" in
3367 Android|WINNT|Darwin)
3368   MOZ_GLUE_IN_PROGRAM=
3369   ;;
3371   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
3372   MOZ_GLUE_IN_PROGRAM=1
3373   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
3374   ;;
3375 esac
3377 dnl ========================================================
3378 dnl = Jemalloc build setup
3379 dnl ========================================================
3380 if test -z "$MOZ_MEMORY"; then
3381   case "${target}" in
3382     *-mingw*)
3383       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
3384         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.])
3385       fi
3386       ;;
3387   esac
3388 else
3389   dnl The generic feature tests that determine how to compute ncpus are long and
3390   dnl complicated.  Therefore, simply define special cpp variables for the
3391   dnl platforms we have special knowledge of.
3392   case "${target}" in
3393   *-mingw*)
3394     export MOZ_NO_DEBUG_RTL=1
3395     ;;
3396   esac
3397 fi # MOZ_MEMORY
3398 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
3400 AC_SUBST_LIST(MOZ_GLUE_WRAP_LDFLAGS)
3401 export MOZ_GLUE_WRAP_LDFLAGS
3403 dnl ========================================================
3404 dnl = Enable using the clang plugin to build
3405 dnl ========================================================
3407 if test -n "$COMPILE_ENVIRONMENT"; then
3408 MOZ_CONFIG_CLANG_PLUGIN
3409 fi # COMPILE_ENVIRONMENT
3411 dnl ========================================================
3412 dnl = Enable stripping of libs & executables
3413 dnl ========================================================
3414 MOZ_ARG_ENABLE_BOOL(strip,
3415 [  --enable-strip          Enable stripping of libs & executables ],
3416     ENABLE_STRIP=1,
3417     ENABLE_STRIP= )
3419 dnl ========================================================
3420 dnl = Enable stripping of libs & executables when packaging
3421 dnl ========================================================
3422 MOZ_ARG_ENABLE_BOOL(install-strip,
3423 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
3424     PKG_SKIP_STRIP= ,
3425     PKG_SKIP_STRIP=1)
3427 dnl ========================================================
3428 dnl = frontend JS debug mode
3429 dnl ========================================================
3431 MOZ_ARG_ENABLE_BOOL(debug-js-modules,
3432 [  --enable-debug-js-modules  Enable debug mode for frontend JS libraries],
3433    DEBUG_JS_MODULES=1,
3434    DEBUG_JS_MODULES=)
3436 AC_SUBST(DEBUG_JS_MODULES)
3438 dnl ========================================================
3439 dnl =
3440 dnl = Profiling and Instrumenting
3441 dnl =
3442 dnl ========================================================
3443 MOZ_ARG_HEADER(Profiling and Instrumenting)
3445 dnl ========================================================
3446 dnl = Offer a way to disable the startup cache
3447 dnl ========================================================
3449 MOZ_ARG_DISABLE_BOOL(startupcache,
3450 [  --disable-startupcache          Disable startup cache ],
3451     MOZ_DISABLE_STARTUPCACHE=1,
3452     MOZ_DISABLE_STARTUPCACHE=)
3454 if test -n "$MOZ_DISABLE_STARTUPCACHE"; then
3455   AC_DEFINE(MOZ_DISABLE_STARTUPCACHE)
3457 AC_SUBST(MOZ_DISABLE_STARTUPCACHE)
3459 dnl ========================================================
3460 dnl = Support for demangling undefined symbols
3461 dnl ========================================================
3462 if test -z "$SKIP_LIBRARY_CHECKS"; then
3463     AC_LANG_SAVE
3464     AC_LANG_CPLUSPLUS
3465     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
3466     AC_LANG_RESTORE
3469 # Demangle only for debug or DMD builds
3470 MOZ_DEMANGLE_SYMBOLS=
3471 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
3472     MOZ_DEMANGLE_SYMBOLS=1
3473     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
3475 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
3477 dnl ========================================================
3478 dnl = Support for gcc stack unwinding (from gcc 3.3)
3479 dnl ========================================================
3480 if test -z "$SKIP_LIBRARY_CHECKS"; then
3481     AC_LANG_SAVE
3482     AC_LANG_CPLUSPLUS
3483     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
3484     AC_LANG_RESTORE
3487 dnl ========================================================
3488 dnl JIT observers
3489 dnl ========================================================
3491 MOZ_ARG_WITH_STRING(jitreport-granularity,
3492 [  --jitreport-granularity=N
3493                            Default granularity at which to report JIT code
3494                            to external tools
3495                              0 - no info
3496                              1 - code ranges for whole functions only
3497                              2 - per-line information
3498                              3 - per-op information],
3499   JITREPORT_GRANULARITY=$withval,
3500   JITREPORT_GRANULARITY=3)
3502 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
3504 dnl ========================================================
3505 dnl =
3506 dnl = Misc. Options
3507 dnl =
3508 dnl ========================================================
3509 MOZ_ARG_HEADER(Misc. Options)
3511 dnl ========================================================
3512 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
3513 dnl ========================================================
3514 MOZ_ARG_WITH_STRING(user-appdir,
3515 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
3516 [ val=`echo $withval`
3517 if echo "$val" | grep "\/" >/dev/null; then
3518     AC_MSG_ERROR("Homedir must be single relative path.")
3519 else
3520     MOZ_USER_DIR="$val"
3521 fi])
3523 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
3525 if test -z "$SKIP_COMPILER_CHECKS"; then
3526 dnl ========================================================
3527 dnl =
3528 dnl = Compiler Options
3529 dnl =
3530 dnl ========================================================
3531 MOZ_ARG_HEADER(Compiler Options)
3533 dnl ========================================================
3534 dnl Check for gcc -pipe support
3535 dnl ========================================================
3536 AC_MSG_CHECKING([for -pipe support])
3537 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
3538     dnl Any gcc that supports firefox supports -pipe.
3539     CFLAGS="$CFLAGS -pipe"
3540     CXXFLAGS="$CXXFLAGS -pipe"
3541     AC_MSG_RESULT([yes])
3542 else
3543     AC_MSG_RESULT([no])
3546 fi # ! SKIP_COMPILER_CHECKS
3548 AC_DEFINE(CPP_THROW_NEW, [throw()])
3549 AC_LANG_C
3551 if test "$COMPILE_ENVIRONMENT"; then
3552 MOZ_EXPAND_LIBS
3553 fi # COMPILE_ENVIRONMENT
3555 dnl ========================================================
3556 dnl =
3557 dnl = Static Build Options
3558 dnl =
3559 dnl ========================================================
3560 MOZ_ARG_HEADER(Static build options)
3562 if test -z "$MOZ_SYSTEM_ZLIB"; then
3563 if test -n "$JS_SHARED_LIBRARY" -o -n "$MOZ_LINKER"; then
3564   ZLIB_IN_MOZGLUE=1
3565   AC_DEFINE(ZLIB_IN_MOZGLUE)
3569 AC_SUBST(ZLIB_IN_MOZGLUE)
3571 dnl ========================================================
3572 dnl =
3573 dnl = Standalone module options
3574 dnl =
3575 dnl ========================================================
3576 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
3578 dnl Check for GLib.
3579 dnl ========================================================
3581 if test -z "$SKIP_PATH_CHECKS"; then
3582 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
3583     if test "$MOZ_ENABLE_GTK" ; then
3584         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
3585     fi
3589 if test -z "${GLIB_GMODULE_LIBS}" \
3590    -a -n "${GLIB_CONFIG}"\
3591     -a "${GLIB_CONFIG}" != no\
3592 ; then
3593     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
3596 AC_SUBST_LIST(GLIB_GMODULE_LIBS)
3598 if test "$USE_FC_FREETYPE"; then
3599     if test "$COMPILE_ENVIRONMENT"; then
3600         dnl ========================================================
3601         dnl = Check for freetype2 functionality
3602         dnl ========================================================
3603         if test "$_HAVE_FREETYPE2" -a -z "$MOZ_TREE_FREETYPE"; then
3604             _SAVE_LIBS="$LIBS"
3605             _SAVE_CFLAGS="$CFLAGS"
3606             LIBS="$LIBS $FT2_LIBS"
3607             CFLAGS="$CFLAGS $FT2_CFLAGS"
3609             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
3610                 ac_cv_member_FT_Bitmap_Size_y_ppem,
3611                 [AC_TRY_COMPILE([#include <ft2build.h>
3612                                  #include FT_FREETYPE_H],
3613                                 [FT_Bitmap_Size s;
3614                                  if (sizeof s.y_ppem) return 0;
3615                                  return 1],
3616                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
3617                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
3618             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
3619                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
3620             else
3621                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
3622             fi
3623             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
3624                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
3625                                [FT_Bitmap_Size structure includes y_ppem field])
3627             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table)
3629             LIBS="$_SAVE_LIBS"
3630             CFLAGS="$_SAVE_CFLAGS"
3631         fi
3633         _SAVE_CPPFLAGS="$CPPFLAGS"
3634         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
3635         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
3636             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
3637         CPPFLAGS="$_SAVE_CPPFLAGS"
3638     fi
3641 dnl ========================================================
3642 dnl Check if we need the 32-bit Linux SSE2 error dialog
3643 dnl ========================================================
3645 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
3647 dnl ========================================================
3648 dnl Check for pixman and cairo
3649 dnl ========================================================
3651 MOZ_TREE_CAIRO=1
3652 MOZ_ARG_ENABLE_BOOL(system-cairo,
3653 [ --enable-system-cairo  Obsolete: do not use this option],
3654 AC_MSG_ERROR(--enable-system-cairo is not supported),
3655 MOZ_TREE_CAIRO=1 )
3657 MOZ_TREE_PIXMAN=1
3658 MOZ_ARG_ENABLE_BOOL(system-pixman,
3659 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
3660 MOZ_TREE_PIXMAN=,
3661 MOZ_TREE_PIXMAN=force,
3662 MOZ_TREE_PIXMAN=1 )
3664 if test "$MOZ_TREE_PIXMAN"; then
3665     AC_DEFINE(MOZ_TREE_PIXMAN)
3666 else
3667     PKG_CHECK_MODULES(MOZ_PIXMAN, pixman-1 >= 0.19.2)
3670 MOZ_CAIRO_CFLAGS="-I${DIST}/include/cairo"
3671 AC_DEFINE(MOZ_TREE_CAIRO)
3673 if test "$OS_ARCH" = "WINNT"; then
3674     # For now we assume that we will have a uint64_t available through
3675     # one of the above headers or mozstdint.h.
3676     AC_DEFINE(HAVE_UINT64_T)
3679 # Define macros for cairo-features.h
3680 TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
3681 if test "$MOZ_X11"; then
3682     XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
3683     XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
3684     PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
3686 if test "$_HAVE_FREETYPE2"; then
3687     FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
3688     MOZ_ENABLE_CAIRO_FT=1
3689     CAIRO_FT_CFLAGS="$FT2_CFLAGS"
3692 case "$MOZ_WIDGET_TOOLKIT" in
3693   cocoa | uikit)
3694     QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
3695     QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
3696     QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
3697     ;;
3698   windows)
3699     WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
3700     WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
3701     WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
3702     WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
3703     MOZ_ENABLE_D2D_SURFACE=1
3705     if test "$COMPILE_ENVIRONMENT"; then
3707       dnl D3D10 Layers depend on D2D Surfaces.
3708       if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
3709         MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
3710       fi
3711     fi
3712     ;;
3713 esac
3714 if test "$USE_FC_FREETYPE"; then
3715     FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
3717 AC_SUBST(MOZ_ENABLE_CAIRO_FT)
3718 AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
3719 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
3721 AC_SUBST(PS_SURFACE_FEATURE)
3722 AC_SUBST(SVG_SURFACE_FEATURE)
3723 AC_SUBST(XLIB_SURFACE_FEATURE)
3724 AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
3725 AC_SUBST(QUARTZ_SURFACE_FEATURE)
3726 AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
3727 AC_SUBST(WIN32_SURFACE_FEATURE)
3728 AC_SUBST(OS2_SURFACE_FEATURE)
3729 AC_SUBST(DIRECTFB_SURFACE_FEATURE)
3730 AC_SUBST(FT_FONT_FEATURE)
3731 AC_SUBST(FC_FONT_FEATURE)
3732 AC_SUBST(WIN32_FONT_FEATURE)
3733 AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
3734 AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
3735 AC_SUBST(QUARTZ_FONT_FEATURE)
3736 AC_SUBST(PNG_FUNCTIONS_FEATURE)
3737 AC_SUBST(QT_SURFACE_FEATURE)
3738 AC_SUBST(TEE_SURFACE_FEATURE)
3740 if test "$MOZ_X11"; then
3741     MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
3744 CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
3746 case "$MOZ_WIDGET_TOOLKIT" in
3747 android)
3748     TK_CFLAGS="$MOZ_CAIRO_CFLAGS $MOZ_PIXMAN_CFLAGS"
3749     TK_LIBS="$MOZ_CAIRO_LIBS $MOZ_PIXMAN_LIBS"
3750     ;;
3751 esac
3753 AC_SUBST(MOZ_TREE_CAIRO)
3754 AC_SUBST_LIST(MOZ_CAIRO_CFLAGS)
3755 AC_SUBST_LIST(MOZ_CAIRO_LIBS)
3756 AC_SUBST_LIST(MOZ_CAIRO_OSLIBS)
3757 AC_SUBST(MOZ_TREE_PIXMAN)
3759 BINDGEN_SYSTEM_FLAGS="$_BINDGEN_CFLAGS $NSPR_CFLAGS $NSS_CFLAGS $MOZ_PIXMAN_CFLAGS $MOZ_CAIRO_CFLAGS"
3760 AC_SUBST(BINDGEN_SYSTEM_FLAGS)
3761 BINDGEN_SYSTEM_TOML_FLAGS="$BINDGEN_SYSTEM_FLAGS"
3762 AC_SUBST_TOML_LIST(BINDGEN_SYSTEM_TOML_FLAGS)
3764 dnl ========================================================
3765 dnl disable xul
3766 dnl ========================================================
3767 MOZ_ARG_DISABLE_BOOL(xul,
3768 [  --disable-xul           Disable XUL],
3769     MOZ_XUL= )
3770 if test "$MOZ_XUL"; then
3771   AC_DEFINE(MOZ_XUL)
3772 else
3773   dnl remove extensions that require XUL
3774   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/irc//' -e 's/tasks//'`
3777 AC_SUBST(MOZ_XUL)
3779 dnl ========================================================
3780 dnl necko configuration options
3781 dnl ========================================================
3784 dnl option to disable necko's wifi scanner
3787 if test "$MOZ_WIDGET_TOOLKIT"; then
3789   case "$OS_TARGET" in
3790     Darwin)
3791       if test -z "$MOZ_IOS"; then
3792         NECKO_WIFI=1
3793       fi
3794       ;;
3795     DragonFly|FreeBSD|WINNT)
3796       NECKO_WIFI=1
3797       ;;
3798     Linux)
3799       NECKO_WIFI=1
3800       NECKO_WIFI_DBUS=1
3801       ;;
3802   esac
3806 MOZ_ARG_DISABLE_BOOL(necko-wifi,
3807 [  --disable-necko-wifi    Disable necko wifi scanner],
3808     NECKO_WIFI=,
3809     NECKO_WIFI=1)
3811 if test "$NECKO_WIFI"; then
3812   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
3813     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
3814   fi
3815   AC_DEFINE(NECKO_WIFI)
3816   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
3818 AC_SUBST(NECKO_WIFI)
3819 AC_SUBST(NECKO_WIFI_DBUS)
3822 dnl option to disable cookies
3824 MOZ_ARG_DISABLE_BOOL(cookies,
3825 [  --disable-cookies       Disable cookie support],
3826     NECKO_COOKIES=,
3827     NECKO_COOKIES=1)
3828 AC_SUBST(NECKO_COOKIES)
3829 if test "$NECKO_COOKIES"; then
3830     AC_DEFINE(NECKO_COOKIES)
3831     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
3834 dnl ========================================================
3835 dnl =
3836 dnl = Maintainer debug option (no --enable equivalent)
3837 dnl =
3838 dnl ========================================================
3840 AC_SUBST(AR)
3841 AC_SUBST(AR_FLAGS)
3842 AC_SUBST(AR_EXTRACT)
3843 AC_SUBST(NM)
3844 AC_SUBST_LIST(ASFLAGS)
3845 AC_SUBST(RC)
3846 AC_SUBST(RCFLAGS)
3847 AC_SUBST(WINDRES)
3848 AC_SUBST(IMPLIB)
3849 AC_SUBST(FILTER)
3850 AC_SUBST(MOZ_AUTH_EXTENSION)
3851 AC_SUBST(MOZ_PREF_EXTENSIONS)
3852 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
3853 AC_SUBST(WARNINGS_AS_ERRORS)
3854 AC_SUBST_LIST(WARNINGS_CFLAGS)
3855 AC_SUBST_SET(MOZ_EXTENSIONS)
3856 AC_SUBST(MOZ_TOOLKIT_SEARCH)
3857 AC_SUBST(MOZ_FEEDS)
3859 AC_SUBST(MOZ_UNIVERSALCHARDET)
3860 AC_SUBST(MOZ_SPELLCHECK)
3861 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
3862 AC_SUBST(MOZ_CRASHREPORTER)
3863 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
3864 AC_SUBST(MOZ_STUB_INSTALLER)
3865 AC_SUBST(MOZ_ENABLE_SIGNMAR)
3866 AC_SUBST(MOZ_UPDATER)
3868 AC_SUBST(MOZ_ANGLE_RENDERER)
3869 AC_SUBST(MOZ_D3D_CPU_SUFFIX)
3870 AC_SUBST(MOZ_HAS_WINSDK_WITH_D3D)
3871 AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL)
3872 AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL_PATH)
3874 AC_SUBST(MOZ_ANDROID_APPLICATION_CLASS)
3875 AC_SUBST(MOZ_ANDROID_BROWSER_INTENT_CLASS)
3876 AC_SUBST(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
3877 AC_SUBST(ENABLE_STRIP)
3878 AC_SUBST(PKG_SKIP_STRIP)
3879 AC_SUBST(STRIP_FLAGS)
3880 AC_SUBST(INCREMENTAL_LINKER)
3882 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
3884 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
3885 AC_SUBST(MOZ_LINKER_EXTRACT)
3887 if test -n "$MOZ_BINARY_EXTENSIONS"; then
3888   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
3891 AC_SUBST(MOZ_REQUIRE_SIGNING)
3892 if test "$MOZ_REQUIRE_SIGNING" = 1; then
3893   AC_DEFINE(MOZ_REQUIRE_SIGNING)
3896 dnl ========================================================
3897 dnl = Mac bundle name prefix
3898 dnl ========================================================
3899 MOZ_ARG_WITH_STRING(macbundlename-prefix,
3900 [  --with-macbundlename-prefix=prefix
3901                           Prefix for MOZ_MACBUNDLE_NAME],
3902 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
3904 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
3905 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
3906   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
3909 if test "$MOZ_DEBUG"; then
3910   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
3911 else
3912   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
3914 AC_SUBST(MOZ_MACBUNDLE_NAME)
3916 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
3917 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
3918 # Otherwise, use MOZ_APP_DISPLAYNAME
3919 if test -z "$MOZ_MACBUNDLE_ID"; then
3920    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
3922 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
3923 if test "$MOZ_DEBUG"; then
3924   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
3927 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
3928 AC_SUBST(MOZ_MACBUNDLE_ID)
3930 dnl ========================================================
3931 dnl = Child Process Name for IPC
3932 dnl ========================================================
3933 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
3934   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
3935 else
3936   # We want to let Android unpack the file at install time, but it only does
3937   # so if the file is named libsomething.so. The lib/ path is also required
3938   # because the unpacked file will be under the lib/ subdirectory and will
3939   # need to be executed from that path.
3940   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
3942 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
3943 MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
3945 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
3946 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
3947 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
3949 # The following variables are available to branding and application
3950 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
3951 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
3952 # impacts profile location and user-visible fields.
3953 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
3954 # versions of a given application (e.g. Aurora and Firefox both use
3955 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
3956 # for application.ini's "Name" field, which controls profile location in
3957 # the absence of a "Profile" field (see below), and various system
3958 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
3959 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
3960 # Mac Bundle name, Updater, Installer), it is typically used for nightly
3961 # builds (e.g. Aurora for Firefox).
3962 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
3963 # defaults to a lowercase form of MOZ_APP_BASENAME.
3964 # - MOZ_APP_REMOTINGNAME: Used for the internal program name, which affects
3965 # profile name and remoting. If not set, defaults to MOZ_APP_NAME.
3966 # - MOZ_APP_PROFILE: When set, used for application.ini's
3967 # "Profile" field, which controls profile location.
3968 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
3969 # crash reporter server url.
3970 # - MOZ_APP_ANDROID_VERSION_CODE: On Android, "android:versionCode" for
3971 # the main application is set to the value of this variable.  If not
3972 # set, it falls back to a Mozilla-specific value derived from the
3973 # build ID.
3974 # - MOZ_ANDROID_SHARED_ID: On Android, "android:sharedUserId" for all Android
3975 # packages produced.
3976 # - MOZ_ANDROID_GCM_SENDERID: On Android, the Android GCM Sender ID used.  GCM
3977 # sender IDs are not sensitive: see, http://stackoverflow.com/a/18216063.
3978 # - MOZ_MMA_GCM_SENDERID: This GCM Sender ID is used for MMA integration.
3979 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
3981 # The following environment variables used to have an effect, but don't anymore:
3982 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
3983 # the contents from the version.txt file in the application directory, or
3984 # browser/config/version.txt if there isn't one.
3985 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
3986 # in the "About" window. This was replaced with the contents from the
3987 # version_display.txt or version.txt in the application directory, or
3988 # browser/config/version_display.txt.
3990 if test -z "$MOZ_APP_NAME"; then
3991    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
3994 if test -z "$MOZ_APP_REMOTINGNAME"; then
3995    MOZ_APP_REMOTINGNAME=$MOZ_APP_NAME
3998 if test -z "$ANDROID_PACKAGE_NAME" ; then
3999    # When we got rid of the Aurora channel we decided to replace the old
4000    # Nightly ANDROID_PACKAGE_NAME with Aurora. To make sure this is inherited
4001    # by all mozilla-central based branches we make this the new "default"
4002    # for Fennec. Non mozilla-central based branches set ANDROID_PACKAGE_NAME
4003    # in their mozconfig, so they will never get this. If there are ever
4004    # non-Fennec builds for Android, they will fall into the else block
4005    # and use their own default name.
4006    # https://bugzilla.mozilla.org/show_bug.cgi?id=1357808 has additional
4007    # background on this.
4008    if test "$MOZ_APP_NAME" = "fennec"; then
4009       ANDROID_PACKAGE_NAME="org.mozilla.fennec_aurora"
4010    else
4011       ANDROID_PACKAGE_NAME="org.mozilla.$MOZ_APP_NAME"
4012    fi
4015 # Mozilla released Firefox for Android {Release,Beta} and {Aurora,Nightly} to
4016 # the public with specific common shared IDs and we need to keep them
4017 # consistent forever.  The specific common values are set by per-channel
4018 # branding; all other channels use a generic sharedID, set below.
4019 if test -z "$MOZ_ANDROID_SHARED_ID" ; then
4020    MOZ_ANDROID_SHARED_ID="${ANDROID_PACKAGE_NAME}.sharedID"
4023 # For extensions and langpacks, we require a max version that is compatible
4024 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
4025 # 24.0a1 and 24.0a2 aren't affected
4026 # 24.0 becomes 24.*
4027 # 24.1.1 becomes 24.*
4028 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
4029 if test -z "$IS_ALPHA"; then
4030   changequote(,)
4031   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
4032     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
4033   else
4034     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
4035   fi
4036   changequote([,])
4037 else
4038   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
4041 AC_SUBST(MOZ_APP_NAME)
4042 AC_SUBST(MOZ_APP_REMOTINGNAME)
4043 AC_SUBST(MOZ_APP_DISPLAYNAME)
4044 AC_SUBST(MOZ_APP_BASENAME)
4045 AC_SUBST(MOZ_APP_VENDOR)
4046 AC_SUBST(MOZ_APP_PROFILE)
4047 AC_SUBST(MOZ_APP_ID)
4048 AC_SUBST(MOZ_APP_ANDROID_VERSION_CODE)
4049 AC_SUBST(MOZ_ANDROID_SHARED_ID)
4050 AC_SUBST(MOZ_ANDROID_GCM_SENDERID)
4051 AC_SUBST(MOZ_MMA_GCM_SENDERID)
4052 AC_SUBST(MAR_CHANNEL_ID)
4053 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
4054 AC_SUBST(MOZ_PROFILE_MIGRATOR)
4055 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
4056 AC_SUBST(MOZ_APP_UA_NAME)
4057 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
4058 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
4059 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
4061 AC_SUBST(MOZ_APP_MAXVERSION)
4062 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
4063 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
4064   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
4067 AC_SUBST(MOZ_PKG_SPECIAL)
4068 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
4070 if test "$MOZILLA_OFFICIAL"; then
4071     # Build revisions should always be present in official builds
4072     MOZ_INCLUDE_SOURCE_INFO=1
4075 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
4076 # explicitly set the repository and changeset information in.
4077 AC_SUBST(MOZ_SOURCE_REPO)
4078 AC_SUBST(MOZ_SOURCE_CHANGESET)
4079 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
4081 if test "$MOZ_TELEMETRY_REPORTING"; then
4082     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
4084     # Enable Telemetry by default for nightly and aurora channels
4085     if test -z "$RELEASE_OR_BETA"; then
4086       AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
4087     fi
4090 dnl If we have any service that uploads data (and requires data submission
4091 dnl policy alert), set MOZ_DATA_REPORTING.
4092 dnl We need SUBST for build system and DEFINE for xul preprocessor.
4093 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"; then
4094   MOZ_DATA_REPORTING=1
4095   AC_DEFINE(MOZ_DATA_REPORTING)
4096   AC_SUBST(MOZ_DATA_REPORTING)
4099 dnl win32 options
4100 AC_SUBST(WIN32_REDIST_DIR)
4101 AC_SUBST(WIN_UCRT_REDIST_DIR)
4102 AC_SUBST(WIN_DIA_SDK_BIN_DIR)
4104 dnl ========================================================
4105 dnl ICU Support
4106 dnl ========================================================
4108 _INTL_API=yes
4110 if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
4111     USE_ICU=1
4114 MOZ_CONFIG_ICU()
4116 dnl Echo the CFLAGS to remove extra whitespace.
4117 CFLAGS=`echo \
4118     $_COMPILATION_CFLAGS \
4119     $CFLAGS`
4121 CXXFLAGS=`echo \
4122     $_WARNINGS_CXXFLAGS \
4123     $_COMPILATION_CXXFLAGS \
4124     $CXXFLAGS`
4126 COMPILE_CFLAGS=`echo \
4127     $_DEFINES_CFLAGS \
4128     $COMPILE_CFLAGS`
4130 COMPILE_CXXFLAGS=`echo \
4131     $_DEFINES_CXXFLAGS \
4132     $COMPILE_CXXFLAGS`
4134 HOST_CFLAGS=`echo \
4135     $_WARNINGS_HOST_CFLAGS \
4136     $_COMPILATION_HOST_CFLAGS \
4137     $HOST_CFLAGS`
4139 HOST_CXXFLAGS=`echo \
4140     $_WARNINGS_HOST_CXXFLAGS \
4141     $_COMPILATION_HOST_CXXFLAGS \
4142     $HOST_CXXFLAGS`
4144 AC_SUBST(MOZ_SYSTEM_JPEG)
4145 AC_SUBST(MOZ_SYSTEM_PNG)
4147 AC_SUBST_LIST(MOZ_JPEG_CFLAGS)
4148 AC_SUBST_LIST(MOZ_JPEG_LIBS)
4149 AC_SUBST_LIST(MOZ_PNG_CFLAGS)
4150 AC_SUBST_LIST(MOZ_PNG_LIBS)
4152 AC_SUBST(MOZ_SYSTEM_NSPR)
4154 AC_SUBST(MOZ_SYSTEM_NSS)
4156 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
4157 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
4158 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
4159 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
4160 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
4161   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
4162   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
4164 AC_SUBST(HOST_CMFLAGS)
4165 AC_SUBST(HOST_CMMFLAGS)
4166 AC_SUBST(OS_COMPILE_CMFLAGS)
4167 AC_SUBST(OS_COMPILE_CMMFLAGS)
4169 OS_CFLAGS="$CFLAGS"
4170 OS_CXXFLAGS="$CXXFLAGS"
4171 OS_CPPFLAGS="$CPPFLAGS"
4172 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
4173 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
4174 OS_LDFLAGS="$LDFLAGS"
4175 OS_LIBS="$LIBS"
4176 AC_SUBST_LIST(OS_CFLAGS)
4177 AC_SUBST_LIST(OS_CXXFLAGS)
4178 AC_SUBST_LIST(OS_CPPFLAGS)
4179 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
4180 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
4181 AC_SUBST_LIST(OS_LDFLAGS)
4182 AC_SUBST(OS_LIBS)
4184 AC_SUBST(HOST_CC)
4185 AC_SUBST(HOST_CXX)
4186 AC_SUBST_LIST(HOST_CFLAGS)
4187 AC_SUBST_LIST(HOST_CPPFLAGS)
4188 AC_SUBST_LIST(HOST_CXXFLAGS)
4189 AC_SUBST(HOST_LDFLAGS)
4190 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
4191 AC_SUBST(HOST_AR)
4192 AC_SUBST(HOST_AR_FLAGS)
4193 AC_SUBST(HOST_RANLIB)
4194 AC_SUBST(HOST_BIN_SUFFIX)
4196 AC_SUBST(TARGET_XPCOM_ABI)
4197 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
4198 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
4199 AC_SUBST(HAVE_X86_AVX2)
4200 AC_SUBST(HAVE_ALTIVEC)
4202 AC_SUBST_LIST(DSO_CFLAGS)
4203 AC_SUBST_LIST(DSO_PIC_CFLAGS)
4204 AC_SUBST(DSO_LDOPTS)
4205 AC_SUBST(BIN_SUFFIX)
4206 AC_SUBST(USE_N32)
4207 AC_SUBST(CC_VERSION)
4208 AC_SUBST(NS_ENABLE_TSF)
4209 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
4210 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
4212 AC_SUBST(MOZ_FFVPX)
4213 AC_SUBST(MOZ_FFVPX_FLACONLY)
4214 AC_SUBST_LIST(FFVPX_ASFLAGS)
4215 AC_SUBST(VPX_USE_YASM)
4216 AC_SUBST_LIST(VPX_ASFLAGS)
4217 AC_SUBST(VPX_AS_CONVERSION)
4218 AC_SUBST(VPX_X86_ASM)
4219 AC_SUBST(VPX_ARM_ASM)
4220 AC_SUBST(LIBJPEG_TURBO_USE_YASM)
4221 AC_SUBST_LIST(LIBJPEG_TURBO_ASFLAGS)
4222 AC_SUBST(MOZ_LIBAV_FFT)
4223 AC_SUBST_LIST(LIBAV_FFT_ASFLAGS)
4224 AC_SUBST(MOZ_DEVTOOLS)
4226 AC_SUBST(MOZ_PACKAGE_JSSHELL)
4227 AC_SUBST(MOZ_FOLD_LIBS)
4228 AC_SUBST_LIST(MOZ_FOLD_LIBS_FLAGS)
4230 AC_SUBST(DMG_TOOL)
4232 dnl Host JavaScript runtime, if any, to use during cross compiles.
4233 AC_SUBST(JS_BINARY)
4235 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
4237 if test -n "$COMPILE_ENVIRONMENT"; then
4238 AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
4240 dnl Check for missing components
4241 if test "$MOZ_X11"; then
4242     dnl ====================================================
4243     dnl = Check if X headers exist
4244     dnl ====================================================
4245     _SAVE_CFLAGS=$CFLAGS
4246     CFLAGS="$CFLAGS $XCFLAGS"
4247     AC_TRY_COMPILE([
4248         #include <stdio.h>
4249         #include <stdlib.h>
4250         #include <X11/Xlib.h>
4251         #include <X11/Intrinsic.h>
4252         #include <X11/extensions/XShm.h>
4253     ],
4254     [
4255         Display *dpy = 0;
4256         if ((dpy = XOpenDisplay(NULL)) == NULL) {
4257             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
4258             exit(1);
4259         }
4260     ], [],
4261     [ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
4262     CFLAGS="$_SAVE_CFLAGS"
4264     if test -n "$MISSING_X"; then
4265         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
4266     fi
4268 fi # MOZ_X11
4270 fi # COMPILE_ENVIRONMENT
4272 dnl Set various defines and substitutions
4273 dnl ========================================================
4275 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
4276     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
4277     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
4278     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
4279     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
4280     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
4281     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
4282     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
4283     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
4286 AC_SUBST(MOZ_DEV_EDITION)
4287 if test -n "$MOZ_DEV_EDITION"; then
4288     AC_DEFINE(MOZ_DEV_EDITION)
4291 if test "$MOZ_DEBUG" -o "$DEVELOPER_OPTIONS"; then
4292     A11Y_LOG=1
4294 AC_SUBST(A11Y_LOG)
4295 if test -n "$A11Y_LOG"; then
4296     AC_DEFINE(A11Y_LOG)
4299 dnl Spit out some output
4300 dnl ========================================================
4302 dnl The following defines are used by xpcom
4303 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
4304 CPP_THROW_NEW
4305 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
4306 HAVE_GETPAGESIZE
4307 HAVE_STATVFS64
4308 HAVE_STATVFS
4309 HAVE_STATFS64
4310 HAVE_STATFS
4311 HAVE_SYS_STATVFS_H
4312 HAVE_SYS_STATFS_H
4313 HAVE_SYS_VFS_H
4314 HAVE_SYS_MOUNT_H
4317 # Avoid using obsolete NSPR features
4318 AC_DEFINE(NO_NSPR_10_SUPPORT)
4320 # Don't build NSS libpkix
4321 NSS_DISABLE_LIBPKIX=1
4322 AC_SUBST(NSS_DISABLE_LIBPKIX)
4324 MOZ_CREATE_CONFIG_STATUS()
4326 if test -z "$direct_nspr_config"; then
4327     dnl ========================================================
4328     dnl = Setup a nice relatively clean build environment for
4329     dnl = sub-configures.
4330     dnl ========================================================
4331     CC="$_SUBDIR_CC"
4332     CXX="$_SUBDIR_CXX"
4333     CFLAGS="$_SUBDIR_CFLAGS"
4334     CPPFLAGS="$_SUBDIR_CPPFLAGS"
4335     CXXFLAGS="$_SUBDIR_CXXFLAGS"
4336     LDFLAGS="$_SUBDIR_LDFLAGS"
4337     HOST_CC="$_SUBDIR_HOST_CC"
4338     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
4339     HOST_CXXFLAGS="$_SUBDIR_HOST_CXXFLAGS"
4340     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
4341     RC=
4344 unset MAKEFILES
4345 unset CONFIG_FILES
4347 # Run all configure scripts specified by a subconfigure
4348 if test -n "$_subconfigure_subdir"; then
4349   _save_srcdir="$srcdir"
4350   srcdir="$srcdir/.."
4351   _save_ac_configure_args="$ac_configure_args"
4352   ac_configure_args="$_subconfigure_config_args"
4353   AC_OUTPUT_SUBDIRS_NOW("$_subconfigure_subdir",$cache_file)
4354   ac_configure_args="$_save_ac_configure_args"
4355   srcdir="$_save_srcdir"
4358 if test "$COMPILE_ENVIRONMENT" -a "$MOZ_WIDGET_TOOLKIT"; then
4361 dnl ========================================================
4362 dnl = Setup a nice relatively clean build environment for
4363 dnl = sub-configures.
4364 dnl ========================================================
4365 CC="$_SUBDIR_CC"
4366 CXX="$_SUBDIR_CXX"
4367 CFLAGS="$_SUBDIR_CFLAGS"
4368 CPPFLAGS="$_SUBDIR_CPPFLAGS"
4369 CXXFLAGS="$_SUBDIR_CXXFLAGS"
4370 LDFLAGS="$_SUBDIR_LDFLAGS"
4371 HOST_CC="$_SUBDIR_HOST_CC"
4372 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
4373 HOST_CXXFLAGS="$_SUBDIR_HOST_CXXFLAGS"
4374 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
4377 # Run the SpiderMonkey 'configure' script.
4378 dist=$MOZ_BUILD_ROOT/dist
4379 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
4381 # --with-system-nspr will have been converted into the relevant $NSPR_CFLAGS
4382 # and $NSPR_LIBS.
4383 ac_configure_args="`echo $ac_configure_args | sed -e 's/--with-system-nspr[[^[:space:]]]* *//'`"
4385 if test "$_INTL_API" = no; then
4386     ac_configure_args="$ac_configure_args --without-intl-api"
4389 if test -n "$NSPR_CFLAGS" -o -n "$NSPR_LIBS"; then
4390     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
4391     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
4393 ac_configure_args="$ac_configure_args --prefix=$dist"
4394 if test -n "$ZLIB_IN_MOZGLUE"; then
4395    MOZ_ZLIB_LIBS=
4397 export MOZ_SYSTEM_ZLIB
4398 export MOZ_ZLIB_CFLAGS
4399 export MOZ_ZLIB_LIBS
4400 export MOZ_APP_NAME
4401 export MOZ_APP_REMOTINGNAME
4402 export MOZ_DEV_EDITION
4403 export RUSTC
4404 export CARGO
4405 export MOZILLA_CENTRAL_PATH=$_topsrcdir
4406 export STLPORT_CPPFLAGS
4407 export STLPORT_LIBS
4408 unset MOZ_BUILD_APP
4409 export DIST
4410 export MOZ_LINKER
4411 export ZLIB_IN_MOZGLUE
4412 export AR
4413 export RANLIB
4414 export CPP
4415 export CC
4416 export CXX
4417 export ARFLAGS
4418 export CPPFLAGS
4419 export CFLAGS
4420 export CXXFLAGS
4421 export LDFLAGS
4422 export HOST_CC
4423 export HOST_CXX
4424 export HOST_CFLAGS
4425 export HOST_CPPFLAGS
4426 export HOST_CXXFLAGS
4427 export HOST_LDFLAGS
4429 if ! test -e js; then
4430     mkdir js
4433 ac_configure_args="$ac_configure_args JS_STANDALONE="
4434 AC_OUTPUT_SUBDIRS(js/src,$cache_file)
4435 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
4437 fi # COMPILE_ENVIRONMENT
4439 dnl we need to run config.status after js/src subconfigure because we're
4440 dnl traversing its moz.build and we need its config.status for that.
4441 dnl However, writing our own config.status needs to happen before
4442 dnl subconfigures because the setup surrounding subconfigures alters
4443 dnl many AC_SUBSTed variables.
4444 MOZ_RUN_ALL_SUBCONFIGURES()
4446 rm -fr confdefs* $ac_clean_files