Bug 1505686 [wpt PR 13978] - html: Fix an issue of type-change-state.html about selec...
[gecko.git] / old-configure.in
blob5b474171d479e96da1baec87db545f7763c0fb89
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 dnl Get version of various core apps from the version files.
693 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
694 FIREFOX_VERSION_DISPLAY=`cat $_topsrcdir/browser/config/version_display.txt`
696 if test -z "$FIREFOX_VERSION"; then
697     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
700 if test -z "$FIREFOX_VERSION_DISPLAY"; then
701     AC_MSG_ERROR([FIREFOX_VERSION_DISPLAY is unexpectedly blank.])
704 MOZ_DOING_LTO(lto_is_enabled)
706 dnl ========================================================
707 dnl System overrides of the defaults for target
708 dnl ========================================================
710 case "$target" in
711 *-darwin*)
712     MOZ_OPTIMIZE_FLAGS="-O3"
713     CXXFLAGS="$CXXFLAGS -stdlib=libc++"
714     DSO_LDOPTS=''
715     STRIP_FLAGS="$STRIP_FLAGS -x -S"
716     # Ensure that if we're targeting iOS an SDK was provided.
717     AC_CACHE_CHECK(for iOS target,
718                    ac_cv_ios_target,
719                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
720 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
721 #error not iOS
722 #endif],
723                                    [],
724                                    ac_cv_ios_target="yes",
725                                    ac_cv_ios_target="no")])
726     if test "$ac_cv_ios_target" = "yes" -a -z $MOZ_IOS; then
727        AC_MSG_ERROR([targeting iOS but not using an iOS SDK?])
728     fi
729     if test -n "$MOZ_IOS"; then
730         direct_nspr_config=1
731     else
732         # The ExceptionHandling framework is needed for Objective-C exception
733         # logging code in nsObjCExceptions.h. Currently we only use that in debug
734         # builds.
735         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
736     fi
738     if test "x$lto_is_enabled" = "xyes"; then
739         echo "Skipping -dead_strip because lto is enabled."
740     dnl DTrace and -dead_strip don't interact well. See bug 403132.
741     dnl ===================================================================
742     elif test "x$enable_dtrace" = "xyes"; then
743         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
744     else
745         dnl check for the presence of the -dead_strip linker flag
746         AC_MSG_CHECKING([for -dead_strip option to ld])
747         _SAVE_LDFLAGS=$LDFLAGS
748         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
749         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
750         if test -n "$_HAVE_DEAD_STRIP" ; then
751             AC_MSG_RESULT([yes])
752             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
753         else
754             AC_MSG_RESULT([no])
755         fi
757         LDFLAGS=$_SAVE_LDFLAGS
758     fi
760     MOZ_FIX_LINK_PATHS="-Wl,-executable_path,${DIST}/bin"
761     ;;
763 *-android*|*-linuxandroid*)
764     AC_DEFINE(NO_PW_GECOS)
766     if test "$COMPILE_ENVIRONMENT"; then
767         MOZ_LINKER=1
768     fi
770     MOZ_GFX_OPTIMIZE_MOBILE=1
771     if test -z "$CLANG_CC"; then
772         MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
773     else
774         # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
775         # -Oz is smaller than -Os on clang.
776         MOZ_OPTIMIZE_FLAGS="-Oz"
777     fi
778     ;;
780 *-*linux*)
781     if test "$GNU_CC" -o "$GNU_CXX"; then
782         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
783         if test -n "$MOZ_DEBUG"; then
784             MOZ_OPTIMIZE_FLAGS="-Os"
785         else
786             MOZ_OPTIMIZE_FLAGS="-O2"
787         fi
788         if test -z "$CLANG_CC"; then
789            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
790         fi
791     fi
793     case "${target_cpu}" in
794     alpha*)
795         CFLAGS="$CFLAGS -mieee"
796         CXXFLAGS="$CXXFLAGS -mieee"
797     ;;
798     esac
799     ;;
800 *-mingw*)
801     DSO_CFLAGS=
802     DSO_PIC_CFLAGS=
803     RC=rc.exe
804     # certain versions of cygwin's makedepend barf on the
805     # #include <string> vs -I./dist/include/string issue so don't use it
806     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
807         CC="$CC -mwindows"
808         CXX="$CXX -mwindows"
809         CPP="$CPP -mwindows"
810         CFLAGS="$CFLAGS -mms-bitfields"
811         CXXFLAGS="$CXXFLAGS -mms-bitfields"
812         DSO_LDOPTS='-shared'
813         RC='$(WINDRES)'
814         # Use temp file for windres (bug 213281)
815         RCFLAGS='-O coff --use-temp-file'
816         # mingw doesn't require kernel32, user32, and advapi32 explicitly
817         LIBS="$LIBS -luuid -lusp10 -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32"
818         MOZ_FIX_LINK_PATHS=
820         MOZ_OPTIMIZE_FLAGS="-O1"
822         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
823         WIN32_GUI_EXE_LDFLAGS=-mwindows
825         if test -z "$CLANG_CC"; then
826             # Use static libgcc and libstdc++
827             LDFLAGS="$LDFLAGS -static"
829             # GCC/binutils can't link to a function if we try to include dllexport function
830             # in the same library as dllimport caller. To work around it, we build NSPR
831             # and NSS with -mnop-fun-dllimport flag. The drawback of this solution is that
832             # function thunks need to be generated for cross-DLL calls.
833             MOZ_FOLD_LIBS_FLAGS="-mnop-fun-dllimport"
834         else
835             # Silence problematic clang warnings
836             CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
837         fi
838     else
839         TARGET_COMPILER_ABI=msvc
840         case "$LINKER" in
841         *lld*)
842             AR='llvm-lib'
843             AR_FLAGS='-llvmlibthin -out:$@'
844             ;;
845         *)
846             AR='lib'
847             AR_FLAGS='-NOLOGO -OUT:$@'
848             ;;
849         esac
850         AR_EXTRACT=
851         RANLIB='echo not_ranlib'
852         STRIP='echo not_strip'
853         PKG_SKIP_STRIP=1
854         # aarch64 doesn't support subsystems below 6.02
855         if test "$CPU_ARCH" = "aarch64"; then
856             WIN32_SUBSYSTEM_VERSION=6.02
857         else
858             WIN32_SUBSYSTEM_VERSION=6.01
859         fi
860         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
861         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
862         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
863         _USE_CPP_INCLUDE_FLAG=1
864         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
865         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
866         CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
867         CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
868         if test -z "$CLANG_CL"; then
869             CPPFLAGS="$CPPFLAGS -utf-8"
870         fi
871         if test "$CPU_ARCH" = "x86"; then
872             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
873             dnl more recent, so set that explicitly here unless another
874             dnl target arch has already been set.
875             changequote(,)
876             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
877               CFLAGS="$CFLAGS -arch:SSE2"
878             fi
879             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
880               CXXFLAGS="$CXXFLAGS -arch:SSE2"
881             fi
882             changequote([,])
883             SSE_FLAGS="-arch:SSE"
884             SSE2_FLAGS="-arch:SSE2"
885             dnl MSVC allows the use of intrinsics without any flags
886             dnl and doesn't have a separate arch for SSSE3
887             SSSE3_FLAGS="-arch:SSE2"
888         fi
889         dnl clang-cl requires appropriate flags to enable SSSE3 support
890         dnl on all architectures.
891         if test -n "$CLANG_CL"; then
892             SSSE3_FLAGS="-mssse3"
893         fi
894         dnl VS2013+ supports -Gw for better linker optimizations.
895         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
896         dnl Disabled on ASan because it causes false-positive ODR violations.
897         if test -z "$MOZ_ASAN"; then
898             CFLAGS="$CFLAGS -Gw"
899             CXXFLAGS="$CXXFLAGS -Gw"
900         fi
901         # khuey says we can safely ignore MSVC warning C4251
902         # MSVC warning C4244 (implicit type conversion may lose data) warns
903         # and requires workarounds for perfectly valid code.  Also, GCC/clang
904         # don't warn about it by default. So for consistency/sanity, we turn
905         # it off on MSVC, too.
906         # MSVC warning C4267 warns for narrowing type conversions from size_t
907         # to 32-bit integer types on 64-bit platforms.  Since this is virtually
908         # the same thing as C4244, we disable C4267, too.
909         # MSVC warning C4800 warns when a value is implicitly cast to bool,
910         # because this also forces narrowing to a single byte, which can be a
911         # perf hit.  But this matters so little in practice (and often we want
912         # that behavior) that it's better to turn it off.
913         # MSVC warning C4595 warns non-member operator new or delete functions
914         # may not be declared inline, as of VS2015 Update 2.
915         CFLAGS="$CFLAGS -wd4244 -wd4267"
916         CXXFLAGS="$CXXFLAGS -wd4251 -wd4244 -wd4267 -wd4800 -wd4595"
917         # Silence "warning C4065: switch statement contains 'default' but no
918         # 'case' labels".  See bug 1461304.
919         CXXFLAGS="$CXXFLAGS -wd4065"
920         if test -n "$CLANG_CL"; then
921             # XXX We should combine some of these with our generic GCC-style
922             # warning checks.
923             #
924             # Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
925             CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
926             # We use offsetof on non-POD objects all the time.
927             # We also suppress this warning on other platforms.
928             CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
929             # This warns for reasonable things like:
930             #   enum { X = 0xffffffffU };
931             # which is annoying for IDL headers.
932             CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
933             # This warns for cases that would be reached by the Microsoft
934             # #include rules, but also currently warns on cases that would
935             # *also* be reached by standard C++ include rules.  That
936             # behavior doesn't seem useful, so we turn it off.
937             CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
938             # We normally error out on unknown pragmas, but since clang-cl
939             # claims to be MSVC, it would be difficult to add
940             # #if defined(_MSC_VER) && !defined(__clang__) everywhere we
941             # use such pragmas, so just ignore them.
942             CFLAGS="$CFLAGS -Wno-unknown-pragmas"
943             CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
944             # We get errors about various #pragma intrinsic directives from
945             # clang-cl, and we don't need to hear about those.
946             CFLAGS="$CFLAGS -Wno-ignored-pragmas"
947             CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
948             # clang-cl's Intrin.h marks things like _ReadWriteBarrier
949             # as __attribute((__deprecated__)).  This is nice to know,
950             # but since we don't get the equivalent warning from MSVC,
951             # let's just ignore it.
952             CFLAGS="$CFLAGS -Wno-deprecated-declarations"
953             CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
954             # We use a function like:
955             #   __declspec(noreturn) __inline void f() {}
956             # which -Winvalid-noreturn complains about.  Again, MSVC seems
957             # OK with it, so let's silence the warning.
958             CFLAGS="$CFLAGS -Wno-invalid-noreturn"
959             CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
960             # Missing |override| on virtual function declarations isn't
961             # something that MSVC currently warns about.
962             CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
963             # We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
964             # declaration on |operator delete(void*)|.  However, clang-cl
965             # must internally declare |operator delete(void*)| differently,
966             # which causes this warning for virtually every file in the
967             # tree.  clang-cl doesn't support -fno-exceptions or equivalent,
968             # so there doesn't seem to be any way to convince clang-cl to
969             # declare |delete| differently.  Therefore, suppress this
970             # warning.
971             CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
972             # At least one MSVC header and several headers in-tree have
973             # unused typedefs, so turn this on.
974             CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
975             # jemalloc uses __declspec(allocator) as a profiler hint,
976             # which clang-cl doesn't understand.
977             CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
978             # __attribute__((unused)) really means "might be unused" and
979             # we use it to avoid warnings about things that are unused
980             # in some compilation units, but used in many others.  This
981             # warning insists on complaining about the latter case, which
982             # is annoying, and rather noisy.
983             CXXFLAGS="$CXXFLAGS -Wno-used-but-marked-unused"
984         fi
985         # make 'foo == bar;' error out
986         CFLAGS="$CFLAGS -we4553"
987         CXXFLAGS="$CXXFLAGS -we4553"
988         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
989         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
990         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib"
991         MOZ_DEBUG_LDFLAGS='-DEBUG'
992         WARNINGS_AS_ERRORS='-WX'
993         # Use a higher optimization level for clang-cl, so we can come closer
994         # to MSVC's performance numbers (see bug 1443590).
995         if test -n "$CLANG_CL"; then
996             MOZ_OPTIMIZE_FLAGS='-O2'
997         else
998             MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
999         fi
1000         MOZ_FIX_LINK_PATHS=
1001         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
1002         if test -z "$DEVELOPER_OPTIONS"; then
1003             LDFLAGS="$LDFLAGS -RELEASE"
1004         fi
1005         RCFLAGS="-nologo"
1006         dnl Minimum reqiurement of Gecko is VS2015 or later which supports
1007         dnl both SSSE3 and SSE4.1.
1008         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
1009         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
1010         dnl allow AVX2 code from VS2015
1011         HAVE_X86_AVX2=1
1012     fi
1013     AC_DEFINE(WIN32_LEAN_AND_MEAN)
1014     dnl See http://support.microsoft.com/kb/143208 to use STL
1015     AC_DEFINE(NOMINMAX)
1016     BIN_SUFFIX='.exe'
1017     MOZ_USER_DIR="Mozilla"
1019     case "$host_os" in
1020     cygwin*|msvc*|mks*)
1021         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.])
1022         ;;
1023     esac
1025     if test -n "$GNU_CC" -a -z "$CLANG_CC"; then
1026         CFLAGS="$CFLAGS -fno-keep-inline-dllexport"
1027         CXXFLAGS="$CXXFLAGS -fno-keep-inline-dllexport"
1028     fi
1030     case "$target" in
1031     i*86-*)
1032         if test -n "$GNU_CC"; then
1033             CFLAGS="$CFLAGS -mstackrealign"
1034             CXXFLAGS="$CXXFLAGS -mstackrealign"
1035             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
1036             if test -z "$CLANG_CC"; then
1037                 LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup"
1038             fi
1039         else
1040             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
1041             LDFLAGS="$LDFLAGS -SAFESEH"
1042         fi
1044         AC_DEFINE(_X86_)
1045         ;;
1046     x86_64-*)
1047         if test -n "$_WIN32_MSVC"; then
1048             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
1049         fi
1050         AC_DEFINE(_AMD64_)
1051         ;;
1052     aarch64-*)
1053         if test -n "$_WIN32_MSVC"; then
1054             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
1055         fi
1056         AC_DEFINE(_ARM64_)
1057         ;;
1058     *)
1059         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
1060         ;;
1061     esac
1062     ;;
1064 *-netbsd*)
1065     DSO_CFLAGS=''
1066     CFLAGS="$CFLAGS -Dunix"
1067     CXXFLAGS="$CXXFLAGS -Dunix"
1068     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
1069         DSO_PIC_CFLAGS='-fPIC -DPIC'
1070         DSO_LDOPTS='-shared'
1071         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
1072     else
1073         DSO_PIC_CFLAGS='-fPIC -DPIC'
1074         DSO_LDOPTS='-shared'
1075     fi
1076     # This will fail on a.out systems prior to 1.5.1_ALPHA.
1077     if test "$LIBRUNPATH"; then
1078         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
1079     fi
1080     ;;
1082 *-openbsd*)
1083     if test -z "$X11BASE"; then
1084         X11BASE=/usr/X11R6
1085     fi
1086     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
1087     DSO_CFLAGS=''
1088     DSO_PIC_CFLAGS='-fPIC'
1089     DSO_LDOPTS='-shared -fPIC'
1090     if test "$LIBRUNPATH"; then
1091         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
1092     fi
1093     ;;
1095 *-solaris*)
1096     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
1097     ;;
1099 esac
1101 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
1102     MOZ_OPTIMIZE_FLAGS="-O"
1105 AC_SUBST_LIST(MMX_FLAGS)
1106 AC_SUBST_LIST(SSE_FLAGS)
1107 AC_SUBST_LIST(SSE2_FLAGS)
1108 AC_SUBST_LIST(SSSE3_FLAGS)
1110 AC_SUBST(MOZ_LINKER)
1111 if test -n "$MOZ_LINKER"; then
1112   AC_DEFINE(MOZ_LINKER)
1113   MOZ_LINKER_EXTRACT=1
1114   AC_CHECK_PROGS(XZ, xz)
1117 if test -z "$COMPILE_ENVIRONMENT"; then
1118     SKIP_COMPILER_CHECKS=1
1119     SKIP_LIBRARY_CHECKS=1
1120     PKG_SKIP_STRIP=1
1121     MOZ_DEBUGGING_OPTS
1122 else
1123     MOZ_COMPILER_OPTS
1124 fi # COMPILE_ENVIRONMENT
1126 if test -z "$SKIP_COMPILER_CHECKS"; then
1127 dnl Checks for typedefs, structures, and compiler characteristics.
1128 dnl ========================================================
1129 AC_C_CONST
1130 AC_TYPE_MODE_T
1131 AC_TYPE_OFF_T
1132 AC_TYPE_PID_T
1133 AC_TYPE_SIZE_T
1134 AC_LANG_CPLUSPLUS
1135 AC_LANG_C
1137 AC_LANG_CPLUSPLUS
1139 MOZ_CXX11
1141 AC_LANG_C
1143 case "${OS_TARGET}" in
1144 Darwin)
1145   ;;
1147   STL_FLAGS="-I${DIST}/stl_wrappers"
1148   WRAP_STL_INCLUDES=1
1149   ;;
1150 esac
1152 dnl Checks for header files.
1153 dnl ========================================================
1154 AC_HEADER_DIRENT
1155 case "$target_os" in
1156 bitrig*|dragonfly*|freebsd*|openbsd*)
1157 # for stuff like -lXshm
1158     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
1159     ;;
1160 esac
1162 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
1163 AC_CACHE_CHECK(for sockaddr_in.sin_len,
1164                    ac_cv_sockaddr_in_sin_len,
1165                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
1166                                     #include <sys/types.h>
1167                                     #endif
1168                                     #include <netinet/in.h>
1169                                     struct sockaddr_in x;
1170                                     void *foo = (void*) &x.sin_len;],
1171                                    [],
1172                                    [ac_cv_sockaddr_in_sin_len=true],
1173                                    [ac_cv_sockaddr_in_sin_len=false])])
1174 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
1175   AC_DEFINE(HAVE_SIN_LEN)
1176 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
1177   AC_DEFINE(HAVE_SCONN_LEN)
1180 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
1181                ac_cv_sockaddr_in6_sin6_len,
1182                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
1183                                 #include <sys/types.h>
1184                                 #endif
1185                                 #include <netinet/in.h>
1186                                 struct sockaddr_in6 x;
1187                                 void *foo = (void*) &x.sin6_len;],
1188                                [],
1189                                [ac_cv_sockaddr_in6_sin6_len=true],
1190                                [ac_cv_sockaddr_in6_sin6_len=false])])
1191 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
1192   AC_DEFINE(HAVE_SIN6_LEN)
1195 AC_CACHE_CHECK(for sockaddr.sa_len,
1196                ac_cv_sockaddr_sa_len,
1197                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
1198                                 #include <sys/types.h>
1199                                 #endif
1200                                 #include <sys/socket.h>
1201                                 struct sockaddr x;
1202                                 void *foo = (void*) &x.sa_len;],
1203                                [],
1204                                [ac_cv_sockaddr_sa_len=true],
1205                                [ac_cv_sockaddr_sa_len=false])])
1206 if test "$ac_cv_sockaddr_sa_len" = true ; then
1207   AC_DEFINE(HAVE_SA_LEN)
1210 MOZ_ARG_ENABLE_BOOL(dtrace,
1211               [  --enable-dtrace         build with dtrace support if available (default=no)],
1212               [enable_dtrace="yes"],)
1213 if test "x$enable_dtrace" = "xyes"; then
1214   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
1215   if test -n "$HAVE_DTRACE"; then
1216       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
1217   else
1218       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
1219   fi
1221 AC_SUBST(HAVE_DTRACE)
1223 dnl Checks for libraries.
1224 dnl ========================================================
1225 AC_CHECK_LIB(c_r, gethostbyname_r)
1227 dnl We don't want to link with libdl even if it's present on OS X, since
1228 dnl it's not used and not part of the default installation. OS/2 has dlfcn
1229 dnl in libc.
1230 dnl We don't want to link against libm or libpthread on Darwin since
1231 dnl they both are just symlinks to libSystem and explicitly linking
1232 dnl against libSystem causes issues when debugging (see bug 299601).
1233 case $target in
1234 *-darwin*)
1235     ;;
1237     AC_SEARCH_LIBS(dlopen, dl,
1238         MOZ_CHECK_HEADER(dlfcn.h,
1239         AC_DEFINE(HAVE_DLOPEN)))
1240     ;;
1241 esac
1243 _SAVE_CFLAGS="$CFLAGS"
1244 CFLAGS="$CFLAGS -D_GNU_SOURCE"
1245 AC_CHECK_FUNCS(dladdr memmem)
1246 CFLAGS="$_SAVE_CFLAGS"
1248 if test ! "$GNU_CXX"; then
1249     AC_CHECK_LIB(C, demangle)
1252 AC_CHECK_LIB(socket, socket)
1254 XLDFLAGS="$X_LIBS"
1255 XLIBS="$X_EXTRA_LIBS"
1257 dnl ========================================================
1258 dnl Checks for X libraries.
1259 dnl Ordering is important.
1260 dnl Xt is dependent upon SM as of X11R6
1261 dnl ========================================================
1262 if test -n "$MOZ_X11"; then
1263     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
1264     _SAVE_LDFLAGS="$LDFLAGS"
1265     _SAVE_LIBS="$LIBS"
1266     LDFLAGS="$XLDFLAGS $LDFLAGS"
1267     AC_CHECK_LIB(X11, XDrawLines, [XLIBS="-lX11 $XLIBS"],
1268         [MISSING_X="$MISSING_X -lX11"], $XLIBS)
1269     AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
1270         [MISSING_X="$MISSING_X -lXext"], $XLIBS)
1272     AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
1273         unset ac_cv_lib_Xt_XtFree
1274         AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
1275         AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
1276         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
1277             [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
1278         ])
1280     dnl ========================================================
1281     dnl = Check for xcb
1282     dnl ========================================================
1283     AC_CHECK_LIB(xcb, xcb_connect, [XLIBS="-lxcb $XLIBS"],
1284         [MISSING_X="$MISSING_X -lxcb"], $XLIBS)
1285     AC_CHECK_LIB(xcb-shm, xcb_shm_query_version, [XLIBS="-lxcb-shm $XLIBS"],
1286         [MISSING_X="$MISSING_X -lxcb-shm"], $XLIBS)
1287     AC_CHECK_LIB(X11-xcb, XGetXCBConnection, [XLIBS="-lX11-xcb $XLIBS"],
1288         [MISSING_X="$MISSING_X -lX11-xcb"], $XLIBS)
1290     LDFLAGS="$_SAVE_LDFLAGS"
1291     LIBS="$_SAVE_LIBS"
1292 fi # $MOZ_X11
1294 AC_SUBST_LIST(XCFLAGS)
1295 AC_SUBST_LIST(XLDFLAGS)
1296 AC_SUBST_LIST(XLIBS)
1297 AC_SUBST_LIST(XEXT_LIBS)
1298 AC_SUBST_LIST(XT_LIBS)
1300 dnl ========================================================
1301 dnl = pthread support
1302 dnl = Start by checking whether the system support pthreads
1303 dnl ========================================================
1304 case "$target_os" in
1305 darwin*)
1306     MOZ_USE_PTHREADS=1
1307     ;;
1309     AC_CHECK_LIB(pthreads, pthread_create,
1310         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
1311         AC_CHECK_LIB(pthread, pthread_create,
1312             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
1313             AC_CHECK_LIB(c_r, pthread_create,
1314                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
1315                 AC_CHECK_LIB(c, pthread_create,
1316                     MOZ_USE_PTHREADS=1
1317                 )
1318             )
1319         )
1320     )
1321     ;;
1322 esac
1324 dnl ========================================================
1325 dnl Do the platform specific pthread hackery
1326 dnl ========================================================
1327 if test "$MOZ_USE_PTHREADS"x != x
1328 then
1329     dnl
1330     dnl See if -pthread is supported.
1331     dnl
1332     rm -f conftest*
1333     ac_cv_have_dash_pthread=no
1334     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
1335     echo 'int main() { return 0; }' | cat > conftest.c
1336     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
1337     if test $? -eq 0; then
1338         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1339             ac_cv_have_dash_pthread=yes
1340             case "$target_os" in
1341             freebsd*)
1342 # Freebsd doesn't use -pthread for compiles, it uses them for linking
1343                 ;;
1344             *)
1345                 CFLAGS="$CFLAGS -pthread"
1346                 CXXFLAGS="$CXXFLAGS -pthread"
1347                 ;;
1348             esac
1349         fi
1350     fi
1351     rm -f conftest*
1352     AC_MSG_RESULT($ac_cv_have_dash_pthread)
1354     dnl
1355     dnl See if -pthreads is supported.
1356     dnl
1357     ac_cv_have_dash_pthreads=no
1358     if test "$ac_cv_have_dash_pthread" = "no"; then
1359         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
1360         echo 'int main() { return 0; }' | cat > conftest.c
1361         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
1362         if test $? -eq 0; then
1363             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1364                 ac_cv_have_dash_pthreads=yes
1365                 CFLAGS="$CFLAGS -pthreads"
1366                 CXXFLAGS="$CXXFLAGS -pthreads"
1367             fi
1368         fi
1369         rm -f conftest*
1370         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
1371     fi
1373     case "$target" in
1374         *-*-freebsd*)
1375             AC_DEFINE(_REENTRANT)
1376             AC_DEFINE(_THREAD_SAFE)
1377             dnl -pthread links in -lpthread, so don't specify it explicitly.
1378             if test "$ac_cv_have_dash_pthread" = "yes"; then
1379                 _PTHREAD_LDFLAGS="-pthread"
1380             fi
1381             ;;
1383         *-*-openbsd*|*-*-bsdi*)
1384             AC_DEFINE(_REENTRANT)
1385             AC_DEFINE(_THREAD_SAFE)
1386             dnl -pthread links in -lc_r, so don't specify it explicitly.
1387             if test "$ac_cv_have_dash_pthread" = "yes"; then
1388                 _PTHREAD_LDFLAGS="-pthread"
1389             fi
1390             ;;
1392         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
1393             AC_DEFINE(_REENTRANT)
1394             ;;
1396     esac
1397     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
1398     AC_SUBST(MOZ_USE_PTHREADS)
1399     MOZ_CHECK_HEADERS(pthread.h)
1403 dnl Checks for library functions.
1404 dnl ========================================================
1405 AC_PROG_GCC_TRADITIONAL
1406 AC_FUNC_MEMCMP
1407 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall)
1409 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
1410 dnl avoid this on Darwin, since depending on your system config, we may think
1411 dnl it exists but it really doesn't
1412 case "$OS_TARGET" in
1413 Darwin)
1414   ;;
1416   AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
1417                  ac_cv_clock_monotonic,
1418                  [for libs in "" -lrt; do
1419                       _SAVE_LIBS="$LIBS"
1420                       LIBS="$LIBS $libs"
1421                       AC_TRY_LINK([#include <time.h>],
1422                                    [ struct timespec ts;
1423                                      clock_gettime(CLOCK_MONOTONIC, &ts); ],
1424                                    ac_cv_clock_monotonic=$libs
1425                                    LIBS="$_SAVE_LIBS"
1426                                    break,
1427                                    ac_cv_clock_monotonic=no)
1428                       LIBS="$_SAVE_LIBS"
1429                   done])
1430   if test "$ac_cv_clock_monotonic" != "no"; then
1431       HAVE_CLOCK_MONOTONIC=1
1432       REALTIME_LIBS=$ac_cv_clock_monotonic
1433       AC_DEFINE(HAVE_CLOCK_MONOTONIC)
1434       AC_SUBST(HAVE_CLOCK_MONOTONIC)
1435       AC_SUBST_LIST(REALTIME_LIBS)
1436   fi
1437   ;;
1438 esac
1440 dnl Turn on warnings-as-errors to prevent implicit declaration of
1441 dnl pthread_cond_timedwait_monotonic_np, which can cause this test to
1442 dnl inadvertently pass even if the function does not really exist.
1443 _SAVE_CFLAGS="$CFLAGS"
1444 CFLAGS="$CFLAGS $WARNINGS_AS_ERRORS"
1445 AC_CACHE_CHECK(for pthread_cond_timedwait_monotonic_np,
1446                ac_cv_pthread_cond_timedwait_monotonic_np,
1447                AC_TRY_LINK([#include <pthread.h>],
1448                            [pthread_cond_timedwait_monotonic_np(0, 0, 0);],
1449                            ac_cv_pthread_cond_timewait_monotonic_np=yes,
1450                            ac_cv_pthread_cond_timewait_monotonic_np=no))
1451 if test "$ac_cv_pthread_cond_timewait_monotonic_np" != "no"; then
1452     AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
1454 CFLAGS=$_SAVE_CFLAGS
1456 AC_CACHE_CHECK(
1457     [for res_ninit()],
1458     ac_cv_func_res_ninit,
1459     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
1460         dnl no need for res_ninit() on NetBSD and OpenBSD
1461         ac_cv_func_res_ninit=no
1462      else
1463         AC_TRY_LINK([
1464             #ifdef linux
1465             #define _BSD_SOURCE 1
1466             #endif
1467             #include <sys/types.h>
1468             #include <netinet/in.h>
1469             #include <arpa/nameser.h>
1470             #include <resolv.h>
1471             ],
1472             [int foo = res_ninit(&_res);],
1473             [ac_cv_func_res_ninit=yes],
1474             [ac_cv_func_res_ninit=no])
1475      fi
1476     ])
1478 if test "$ac_cv_func_res_ninit" = "yes"; then
1479     AC_DEFINE(HAVE_RES_NINIT)
1480 dnl must add the link line we do something as foolish as this... dougt
1481 dnl else
1482 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
1483 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
1486 AC_LANG_C
1488 dnl **********************
1489 dnl *** va_copy checks ***
1490 AC_CACHE_CHECK([for an implementation of va_copy()],
1491                ac_cv_va_copy,
1492     [AC_TRY_COMPILE([#include <stdarg.h>
1493                      #include <stdlib.h>
1494         void f (int i, ...) {
1495             va_list args1, args2;
1496             va_start (args1, i);
1497             va_copy (args2, args1);
1498             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1499                 exit (1);
1500             va_end (args1); va_end (args2);
1501         }],
1502         [f(0, 42); return 0],
1503         [ac_cv_va_copy=yes],
1504         [ac_cv_va_copy=no]
1505     )]
1507 AC_CACHE_CHECK([whether va_list can be copied by value],
1508                ac_cv_va_val_copy,
1509     [AC_TRY_COMPILE([#include <stdarg.h>
1510                      #include <stdlib.h>
1511         void f (int i, ...) {
1512             va_list args1, args2;
1513             va_start (args1, i);
1514             args2 = args1;
1515             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1516                 exit (1);
1517             va_end (args1); va_end (args2);
1518         }],
1519         [f(0, 42); return 0],
1520         [ac_cv_va_val_copy=yes],
1521         [ac_cv_va_val_copy=no],
1522     )]
1524 if test "x$ac_cv_va_copy" = "xyes"; then
1525     AC_DEFINE(VA_COPY, va_copy)
1526     AC_DEFINE(HAVE_VA_COPY)
1529 if test "x$ac_cv_va_val_copy" = "xno"; then
1530    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
1533 dnl ===================================================================
1534 dnl ========================================================
1535 dnl Put your C++ language/feature checks below
1536 dnl ========================================================
1537 AC_LANG_CPLUSPLUS
1539 ARM_ABI_PREFIX=
1540 if test "$GNU_CC"; then
1541   if test "$CPU_ARCH" = "arm" ; then
1542     AC_CACHE_CHECK(for ARM EABI,
1543         ac_cv_gcc_arm_eabi,
1544         [AC_TRY_COMPILE([],
1545                         [
1546 #if defined(__ARM_EABI__)
1547   return 0;
1548 #else
1549 #error Not ARM EABI.
1550 #endif
1551                         ],
1552                         ac_cv_gcc_arm_eabi="yes",
1553                         ac_cv_gcc_arm_eabi="no")])
1554     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
1555         HAVE_ARM_EABI=1
1556         ARM_ABI_PREFIX=eabi-
1557     else
1558         ARM_ABI_PREFIX=oabi-
1559     fi
1560   fi
1562   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
1565 dnl See if a dynamic_cast to void* gives the most derived object.
1566 AC_CACHE_CHECK(for C++ dynamic_cast to void*,
1567                ac_cv_cpp_dynamic_cast_void_ptr,
1568                [AC_TRY_RUN([class X { int i; public: virtual ~X() { } };
1569                             class Y { int j; public: virtual ~Y() { } };
1570                             class Z : public X, public Y { int k; };
1572                             int main() {
1573                                  Z mdo;
1574                                  X *subx = (X*)&mdo;
1575                                  Y *suby = (Y*)&mdo;
1576                                  return !((((void*)&mdo != (void*)subx) &&
1577                                            ((void*)&mdo == dynamic_cast<void*>(subx))) ||
1578                                           (((void*)&mdo != (void*)suby) &&
1579                                            ((void*)&mdo == dynamic_cast<void*>(suby))));
1580                             }],
1581                            ac_cv_cpp_dynamic_cast_void_ptr=yes,
1582                            ac_cv_cpp_dynamic_cast_void_ptr=no,
1583                            ac_cv_cpp_dynamic_cast_void_ptr=no)])
1584 if test "$ac_cv_cpp_dynamic_cast_void_ptr" = yes ; then
1585    AC_DEFINE(HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR)
1589 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
1590 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
1591 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
1592 # linking XUL.
1593 _SAVE_LDFLAGS=$LDFLAGS
1594 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
1595 AC_CACHE_CHECK(for __thread keyword for TLS variables,
1596                ac_cv_thread_keyword,
1597                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
1598                             [return tlsIsMainThread;],
1599                             ac_cv_thread_keyword=yes,
1600                             ac_cv_thread_keyword=no)])
1601 LDFLAGS=$_SAVE_LDFLAGS
1602 # The custom dynamic linker doesn't support TLS variables
1603 MOZ_TLS=
1604 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
1605   # mips builds fail with TLS variables because of a binutils bug.
1606   # See bug 528687
1607   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
1608   case "${target}" in
1609     mips*-*)
1610       :
1611       ;;
1612     *-android*|*-linuxandroid*)
1613       :
1614       ;;
1615     *-openbsd*)
1616       :
1617       ;;
1618     *)
1619       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
1620       MOZ_TLS=1
1621       ;;
1622   esac
1625 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
1626 if test -n "$MOZ_LINKER"; then
1627   if test "$CPU_ARCH" = arm; then
1628     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
1629     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
1630       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1631       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1632     fi
1633   fi
1635 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
1636 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
1637 dnl Since the linker only understands the sysv ones, no need to build the
1638 dnl gnu style tables anyways.
1639   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
1642 dnl End of C++ language/feature checks
1643 AC_LANG_C
1645 dnl ========================================================
1646 dnl =  Internationalization checks
1647 dnl ========================================================
1649 dnl Internationalization and Locale support is different
1650 dnl on various UNIX platforms.  Checks for specific i18n
1651 dnl features go here.
1653 AC_HAVE_FUNCS(localeconv)
1655 fi # ! SKIP_COMPILER_CHECKS
1657 if test -n "${COMPILE_ENVIRONMENT}"; then
1658   MOZ_CHECK_ALLOCATOR
1661 TARGET_XPCOM_ABI=
1662 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1663     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1664     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
1667 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1668 dnl features that Windows actually does support.
1670 if test -n "$SKIP_COMPILER_CHECKS"; then
1671    dnl Windows has malloc.h
1672    AC_DEFINE(MALLOC_H, [<malloc.h>])
1673    AC_DEFINE(HAVE_FORCEINLINE)
1674    AC_DEFINE(HAVE_LOCALECONV)
1675 fi # SKIP_COMPILER_CHECKS
1677 dnl Mozilla specific options
1678 dnl ========================================================
1679 dnl The macros used for command line options
1680 dnl are defined in build/autoconf/altoptions.m4.
1682 dnl ========================================================
1683 dnl =
1684 dnl = Check for external package dependencies
1685 dnl =
1686 dnl ========================================================
1687 MOZ_ARG_HEADER(External Packages)
1689 case "$OS_TARGET" in
1690 WINNT|Darwin|Android)
1691   MOZ_FOLD_LIBS=1
1692   ;;
1694   MOZ_FOLD_LIBS=
1695   ;;
1696 esac
1698 MOZ_CONFIG_NSPR()
1700 dnl ========================================================
1701 dnl system libevent Support
1702 dnl ========================================================
1703 MOZ_ARG_WITH_STRING(system-libevent,
1704 [  --with-system-libevent[=PFX]
1705                           Use system libevent [installed at prefix PFX]],
1706     LIBEVENT_DIR=$withval)
1708 _SAVE_CFLAGS=$CFLAGS
1709 _SAVE_LDFLAGS=$LDFLAGS
1710 _SAVE_LIBS=$LIBS
1711 if test "$LIBEVENT_DIR" = yes; then
1712     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
1713         MOZ_SYSTEM_LIBEVENT=1,
1714         LIBEVENT_DIR=/usr)
1716 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
1717     MOZ_SYSTEM_LIBEVENT=
1718 elif test -z "$MOZ_SYSTEM_LIBEVENT"; then
1719     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
1720     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
1721     MOZ_CHECK_HEADER(event.h,
1722         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
1723              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
1724          fi],
1725         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
1726     AC_CHECK_LIB(event, event_init,
1727                  [MOZ_SYSTEM_LIBEVENT=1
1728                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
1729                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
1730                  [MOZ_SYSTEM_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
1732 CFLAGS=$_SAVE_CFLAGS
1733 LDFLAGS=$_SAVE_LDFLAGS
1734 LIBS=$_SAVE_LIBS
1736 AC_SUBST(MOZ_SYSTEM_LIBEVENT)
1738 dnl ========================================================
1739 dnl = If NSS was not detected in the system,
1740 dnl = use the one in the source tree (mozilla/security/nss)
1741 dnl ========================================================
1743 MOZ_ARG_WITH_BOOL(system-nss,
1744 [  --with-system-nss       Use system installed NSS],
1745     _USE_SYSTEM_NSS=1 )
1747 if test -n "$_USE_SYSTEM_NSS"; then
1748     AM_PATH_NSS(3.40, [MOZ_SYSTEM_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
1751 NSS_CFLAGS="$NSS_CFLAGS -I${DIST}/include/nss"
1752 if test -z "$MOZ_SYSTEM_NSS"; then
1753    case "${OS_ARCH}" in
1754         # Only few platforms have been tested with GYP
1755         WINNT|Darwin|Linux|DragonFly|FreeBSD|NetBSD|OpenBSD|SunOS)
1756             ;;
1757         *)
1758             AC_MSG_ERROR([building in-tree NSS is not supported on this platform. Use --with-system-nss])
1759             ;;
1760    esac
1763 if test -z "$SKIP_LIBRARY_CHECKS"; then
1764 dnl system JPEG support
1765 dnl ========================================================
1766 MOZ_ARG_WITH_STRING(system-jpeg,
1767 [  --with-system-jpeg[=PFX]
1768                           Use system libjpeg [installed at prefix PFX]],
1769     JPEG_DIR=$withval)
1771 _SAVE_CFLAGS=$CFLAGS
1772 _SAVE_LDFLAGS=$LDFLAGS
1773 _SAVE_LIBS=$LIBS
1774 if test -n "${JPEG_DIR}" -a "${JPEG_DIR}" != "yes"; then
1775     CFLAGS="-I${JPEG_DIR}/include $CFLAGS"
1776     LDFLAGS="-L${JPEG_DIR}/lib $LDFLAGS"
1778 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
1779     MOZ_SYSTEM_JPEG=
1780 else
1781     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [MOZ_SYSTEM_JPEG=1 MOZ_JPEG_LIBS="-ljpeg"], MOZ_SYSTEM_JPEG=)
1784 if test "$MOZ_SYSTEM_JPEG" = 1; then
1785     AC_TRY_COMPILE([ #include <stdio.h>
1786                      #include <sys/types.h>
1787                      #include <jpeglib.h> ],
1788                    [ #if JPEG_LIB_VERSION < $MOZJPEG
1789                      #error "Insufficient JPEG library version ($MOZJPEG required)."
1790                      #endif
1791                      #ifndef JCS_EXTENSIONS
1792                      #error "libjpeg-turbo JCS_EXTENSIONS required"
1793                      #endif
1794                      ],
1795                    MOZ_SYSTEM_JPEG=1,
1796                    AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
1798 CFLAGS=$_SAVE_CFLAGS
1799 LDFLAGS=$_SAVE_LDFLAGS
1800 LIBS=$_SAVE_LIBS
1802 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$MOZ_SYSTEM_JPEG" = 1; then
1803     MOZ_JPEG_CFLAGS="-I${JPEG_DIR}/include"
1804     MOZ_JPEG_LIBS="-L${JPEG_DIR}/lib ${MOZ_JPEG_LIBS}"
1806 fi # SKIP_LIBRARY_CHECKS
1808 dnl system ZLIB support
1809 dnl ========================================================
1810 MOZ_ZLIB_CHECK([1.2.3])
1812 if test -z "$SKIP_LIBRARY_CHECKS"; then
1814 dnl ========================================================
1815 dnl system PNG Support
1816 dnl ========================================================
1817 MOZ_ARG_WITH_STRING(system-png,
1818 [  --with-system-png[=PFX]
1819                           Use system libpng [installed at prefix PFX]],
1820     PNG_DIR=$withval)
1822 _SAVE_CFLAGS=$CFLAGS
1823 _SAVE_LDFLAGS=$LDFLAGS
1824 _SAVE_LIBS=$LIBS
1825 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
1826     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
1827     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
1829 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
1830     MOZ_SYSTEM_PNG=
1831 else
1832     AC_CHECK_LIB(png, png_get_valid, [MOZ_SYSTEM_PNG=1 MOZ_PNG_LIBS="-lpng"],
1833                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1834     AC_CHECK_LIB(png, png_get_acTL, ,
1835                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
1837 if test "$MOZ_SYSTEM_PNG" = 1; then
1838     AC_TRY_COMPILE([ #include <stdio.h>
1839                      #include <sys/types.h>
1840                      #include <png.h> ],
1841                    [ #if PNG_LIBPNG_VER < $MOZPNG
1842                      #error "Insufficient libpng version ($MOZPNG required)."
1843                      #endif
1844                      #ifndef PNG_UINT_31_MAX
1845                      #error "Insufficient libpng version."
1846                      #endif ],
1847                    MOZ_SYSTEM_PNG=1,
1848                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1850 CFLAGS=$_SAVE_CFLAGS
1851 LDFLAGS=$_SAVE_LDFLAGS
1852 LIBS=$_SAVE_LIBS
1854 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_SYSTEM_PNG" = 1; then
1855     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
1856     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
1859 fi # SKIP_LIBRARY_CHECKS
1861 dnl ========================================================
1862 dnl =
1863 dnl = Application
1864 dnl =
1865 dnl ========================================================
1867 MOZ_ARG_HEADER(Application)
1869 ENABLE_SYSTEM_EXTENSION_DIRS=1
1870 MOZ_BRANDING_DIRECTORY=
1871 MOZ_OFFICIAL_BRANDING=
1872 MOZ_FEEDS=1
1873 MOZ_AUTH_EXTENSION=1
1874 if test "$MOZ_IOS"; then
1875    MOZ_AUTH_EXTENSION=
1877 VPX_USE_YASM=
1878 VPX_ASFLAGS=
1879 VPX_AS_CONVERSION=
1880 VPX_X86_ASM=
1881 VPX_ARM_ASM=
1882 LIBJPEG_TURBO_AS=
1883 LIBJPEG_TURBO_ASFLAGS=
1884 MOZ_PREF_EXTENSIONS=1
1885 MOZ_SPELLCHECK=1
1886 MOZ_TOOLKIT_SEARCH=1
1887 MOZ_UNIVERSALCHARDET=1
1888 MOZ_XUL=1
1889 MOZ_ZIPWRITER=1
1890 MOZ_NO_SMART_CARDS=
1891 NECKO_COOKIES=1
1892 MOZ_USE_NATIVE_POPUP_WINDOWS=
1893 MOZ_EXCLUDE_HYPHENATION_DICTIONARIES=
1894 MOZ_CONTENT_SANDBOX=
1895 MOZ_GMP_SANDBOX=
1896 MOZ_SANDBOX=1
1897 MOZ_BINARY_EXTENSIONS=
1898 MOZ_DEVTOOLS=server
1900 case "$target_os" in
1901     mingw*)
1902         NS_ENABLE_TSF=1
1903         AC_DEFINE(NS_ENABLE_TSF)
1904         ;;
1905 esac
1907 # Optional Firefox for Android partner distribution directory.
1908 MOZ_ARG_WITH_STRING(android-distribution-directory,
1909 [  --with-android-distribution-directory=dir
1910                           Optional Firefox for Android partner distribution directory.],
1911   MOZ_ANDROID_DISTRIBUTION_DIRECTORY=$withval)
1913 if test -n "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY"; then
1914   # A distribution directory must have an assets/distribution directory.
1915   # See https://wiki.mozilla.org/Mobile/Distribution_Files.
1916   if test ! -d "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY/assets/distribution" ; then
1917     AC_MSG_ERROR([--with-android-distribution-directory does not contain assets/distribution;
1918                   (looked for ${MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets/distribution).])
1919   fi
1921 AC_SUBST(MOZ_ANDROID_DISTRIBUTION_DIRECTORY)
1923 dnl ========================================================
1924 dnl = Trademarked Branding
1925 dnl ========================================================
1926 MOZ_ARG_ENABLE_BOOL(official-branding,
1927 [  --enable-official-branding
1928                           Enable Official mozilla.org Branding
1929                           Do not distribute builds with
1930                           --enable-official-branding unless you have
1931                           permission to use trademarks per
1932                           http://www.mozilla.org/foundation/trademarks/ .],
1933     MOZ_OFFICIAL_BRANDING=1,
1934     MOZ_OFFICIAL_BRANDING=)
1936 # Allow the application to influence configure with a confvars.sh script.
1937 AC_MSG_CHECKING([if app-specific confvars.sh exists])
1938 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
1939   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
1940   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
1941 else
1942   AC_MSG_RESULT([no])
1945 # Allow influencing configure with a defines.sh script.
1946 . "${srcdir}/build/defines.sh"
1948 # If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
1949 # set in defines.sh
1950 if test "$BUILDING_RELEASE"; then
1951   # Override value in defines.sh, if any
1952   EARLY_BETA_OR_EARLIER=
1953 elif test "$EARLY_BETA_OR_EARLIER"; then
1954   AC_DEFINE(EARLY_BETA_OR_EARLIER)
1956 AC_SUBST(EARLY_BETA_OR_EARLIER)
1958 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
1959 MOZ_ARG_WITH_STRING(app-name,
1960 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
1961 WITH_APP_NAME=$withval,
1964 if test -n "$WITH_APP_NAME" ; then
1965     MOZ_APP_NAME="$WITH_APP_NAME"
1968 MOZ_ARG_WITH_STRING(app-basename,
1969 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
1970 WITH_APP_BASENAME=$withval,
1973 if test -n "$WITH_APP_BASENAME" ; then
1974     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
1977 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
1978 # that haven't made a confvars.sh yet. Don't add new stuff here, use
1979 # MOZ_BUILD_APP.
1980 case "$MOZ_BUILD_APP" in
1981 browser)
1982   AC_DEFINE(MOZ_PHOENIX)
1983   ;;
1985 xulrunner)
1986   AC_DEFINE(MOZ_XULRUNNER)
1987   ;;
1988 esac
1990 # Graphene is a desktop runtime for running applications with a HTML UI.
1991 if test -n "$MOZ_GRAPHENE"; then
1992     AC_DEFINE(MOZ_GRAPHENE)
1995 AC_SUBST(MOZ_PHOENIX)
1996 AC_SUBST(MOZ_XULRUNNER)
1998 dnl ========================================================
1999 dnl Ensure Android SDK and build-tools versions depending on
2000 dnl mobile target.
2001 dnl ========================================================
2003 case "$MOZ_BUILD_APP" in
2004 mobile/android)
2005     MOZ_ANDROID_SDK(26, 26, 27.0.3)
2006     ;;
2007 esac
2009 dnl ========================================================
2010 dnl =
2011 dnl = Toolkit Options
2012 dnl =
2013 dnl ========================================================
2014 MOZ_ARG_HEADER(Toolkit Options)
2016 dnl ========================================================
2017 dnl = Enable the toolkit as needed                         =
2018 dnl ========================================================
2020 case "$MOZ_WIDGET_TOOLKIT" in
2022 cocoa)
2023     LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
2024     # Use -Wl as a trick to avoid -framework and framework names from
2025     # being separated by AC_SUBST_LIST.
2026     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'
2027     TK_CFLAGS=""
2028     CFLAGS="$CFLAGS $TK_CFLAGS"
2029     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
2030     MOZ_USER_DIR="Mozilla"
2031     MOZ_FS_LAYOUT=bundle
2032     ;;
2034 uikit)
2035     LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
2036     TK_CFLAGS=""
2037     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'
2038     CFLAGS="$CFLAGS $TK_CFLAGS"
2039     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
2040     MOZ_USER_DIR="Mozilla"
2041     MOZ_FS_LAYOUT=bundle
2042     ;;
2044 esac
2046 dnl there are a lot of tests on MOZ_ENABLE_GTK below, that are more convenient
2047 dnl to keep that way than testing against MOZ_WIDGET_TOOLKIT
2048 case "$MOZ_WIDGET_TOOLKIT" in
2049 gtk*)
2050     MOZ_ENABLE_GTK=1
2051     ;;
2052 esac
2054 if test "$COMPILE_ENVIRONMENT"; then
2055   if test "$MOZ_WIDGET_TOOLKIT" = gtk3; then
2056     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)
2057     MOZ_GTK3_CFLAGS="-I${_topsrcdir}/widget/gtk/compat-gtk3 $MOZ_GTK3_CFLAGS"
2058     TK_CFLAGS=$MOZ_GTK3_CFLAGS
2059     TK_LIBS=$MOZ_GTK3_LIBS
2060     dnl GDK_VERSION_MIN_REQUIRED is not set here as GDK3 deprecated warnings
2061     dnl are suppressed by widget/gtk/compat-gtk3/gdk/gdkversionmacros.h.
2062     AC_DEFINE_UNQUOTED(GDK_VERSION_MAX_ALLOWED,$GDK_VERSION_MAX_ALLOWED)
2063     GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32
2064   fi
2065   if test "$MOZ_ENABLE_GTK"; then
2066     if test "$MOZ_X11"; then
2067       GDK_PACKAGES=gdk-x11-2.0
2068     fi
2069     AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
2070     AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)
2072     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)
2073     MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
2074   fi
2075 fi # COMPILE_ENVIRONMENT
2077 AC_SUBST(MOZ_FS_LAYOUT)
2079 dnl ========================================================
2080 dnl = startup-notification support module
2081 dnl ========================================================
2083 if test "$MOZ_ENABLE_GTK"
2084 then
2085     MOZ_ENABLE_STARTUP_NOTIFICATION=
2087     MOZ_ARG_ENABLE_BOOL(startup-notification,
2088     [  --enable-startup-notification
2089                           Enable startup-notification support (default: disabled) ],
2090         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
2091         MOZ_ENABLE_STARTUP_NOTIFICATION=)
2092     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
2093     then
2094         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
2095                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
2096         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
2097             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
2098             then
2099                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
2100             fi
2101             MOZ_ENABLE_STARTUP_NOTIFICATION=
2102         ])
2103     fi
2105     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
2106         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
2107     fi
2109     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
2111 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
2113 AC_SUBST_LIST(TK_CFLAGS)
2114 AC_SUBST_LIST(TK_LIBS)
2116 AC_SUBST(MOC)
2117 AC_SUBST(RCC)
2119 dnl ========================================================
2120 dnl =
2121 dnl = Components & Features
2122 dnl =
2123 dnl ========================================================
2124 MOZ_ARG_HEADER(Components and Features)
2126 AC_SUBST(MOZ_OFFICIAL_BRANDING)
2127 if test -n "$MOZ_OFFICIAL_BRANDING"; then
2128   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
2129     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
2130   else
2131     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
2132     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
2133   fi
2136 MOZ_ARG_WITH_STRING(branding,
2137 [  --with-branding=dir     Use branding from the specified directory.],
2138     MOZ_BRANDING_DIRECTORY=$withval)
2140 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
2141 if test -z "$REAL_BRANDING_DIRECTORY"; then
2142   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
2145 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
2146   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
2147 elif test -f "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
2148   . "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"
2151 AC_SUBST(MOZ_BRANDING_DIRECTORY)
2153 dnl ========================================================
2154 dnl = Distribution ID
2155 dnl ========================================================
2156 MOZ_ARG_WITH_STRING(distribution-id,
2157 [  --with-distribution-id=ID
2158                           Set distribution-specific id (default=org.mozilla)],
2159 [ val=`echo $withval`
2160     MOZ_DISTRIBUTION_ID="$val"])
2162 if test -z "$MOZ_DISTRIBUTION_ID"; then
2163    MOZ_DISTRIBUTION_ID="org.mozilla"
2166 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
2167 AC_SUBST(MOZ_DISTRIBUTION_ID)
2169 dnl ========================================================
2170 dnl = GConf support module
2171 dnl ========================================================
2173 if test "$MOZ_X11"
2174 then
2175     if test "$MOZ_ENABLE_GTK"
2176     then
2177         MOZ_ENABLE_GCONF=1
2178     fi
2180     dnl ========================================================
2181     dnl = GConf support module
2182     dnl ========================================================
2183     MOZ_ARG_DISABLE_BOOL(gconf,
2184     [  --disable-gconf      Disable Gconf support ],
2185         MOZ_ENABLE_GCONF=,
2186         MOZ_ENABLE_GCONF=1)
2188     if test "$MOZ_ENABLE_GCONF"
2189     then
2190         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
2191             MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
2192             MOZ_ENABLE_GCONF=1
2193         ],[
2194             if test -n "$MOZ_ENABLE_GCONF";
2195             then
2196                 AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
2197             else
2198                 AC_MSG_WARN([Many automated tests will fail with --disable-gconf. See bug 1167201.])
2199             fi
2200         ])
2201     fi
2203     if test "$MOZ_ENABLE_GCONF"; then
2204         AC_DEFINE(MOZ_ENABLE_GCONF)
2205     fi
2207     AC_SUBST(MOZ_ENABLE_GCONF)
2210 dnl ========================================================
2211 dnl = libproxy support
2212 dnl ========================================================
2214 if test "$MOZ_ENABLE_GTK"
2215 then
2216     MOZ_ENABLE_LIBPROXY=
2218     MOZ_ARG_ENABLE_BOOL(libproxy,
2219     [  --enable-libproxy         Enable libproxy support ],
2220     MOZ_ENABLE_LIBPROXY=1,
2221     MOZ_ENABLE_LIBPROXY=)
2223     if test "$MOZ_ENABLE_LIBPROXY"
2224     then
2225         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
2226         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
2227     fi
2229 AC_SUBST(MOZ_ENABLE_LIBPROXY)
2231 dnl ========================================================
2232 dnl = dbus support
2233 dnl ========================================================
2235 if test "$MOZ_ENABLE_GTK"
2236 then
2237     MOZ_ENABLE_DBUS=1
2239     MOZ_ARG_DISABLE_BOOL(dbus,
2240     [  --disable-dbus          Disable dbus support ],
2241         MOZ_ENABLE_DBUS=,
2242         MOZ_ENABLE_DBUS=1)
2244     if test "$MOZ_ENABLE_DBUS"
2245     then
2246         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
2247         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
2248         AC_DEFINE(MOZ_ENABLE_DBUS)
2249     fi
2251 AC_SUBST(MOZ_ENABLE_DBUS)
2253 dnl =========================================================
2254 dnl = Whether to exclude hyphenations files in the build
2255 dnl =========================================================
2256 if test -n "$MOZ_EXCLUDE_HYPHENATION_DICTIONARIES"; then
2257     AC_DEFINE(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
2260 AC_TRY_COMPILE([#include <linux/ethtool.h>],
2261                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
2262                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
2264 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
2266 if test -n "$MOZ_WEBRTC"; then
2267     if test -n "$MOZ_X11"; then
2268       MOZ_WEBRTC_X11_LIBS="-lXext -lXdamage -lXfixes -lXcomposite"
2269     fi
2272 AC_SUBST_LIST(MOZ_WEBRTC_X11_LIBS)
2274 dnl ========================================================
2275 dnl = Apple platform decoder support
2276 dnl ========================================================
2277 if test "$COMPILE_ENVIRONMENT"; then
2278 if test -n "$MOZ_APPLEMEDIA"; then
2279   # hack in frameworks for fmp4 - see bug 1029974
2280   # We load VideoToolbox and CoreMedia dynamically, so they don't appear here.
2281   LDFLAGS="$LDFLAGS -framework AudioToolbox"
2282   dnl Verify CoreMedia is available.
2283   AC_CHECK_HEADER([CoreMedia/CoreMedia.h], [],
2284     [AC_MSG_ERROR([MacOS X 10.9 SDK or later is required])])
2286 fi # COMPILE_ENVIRONMENT
2288 dnl system libvpx Support
2289 dnl ========================================================
2290 MOZ_ARG_WITH_BOOL(system-libvpx,
2291 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
2292     MOZ_SYSTEM_LIBVPX=1)
2294 MOZ_LIBVPX_CFLAGS=
2295 MOZ_LIBVPX_LIBS=
2297 _SAVE_CFLAGS=$CFLAGS
2298 _SAVE_LIBS=$LIBS
2299 if test -n "$MOZ_SYSTEM_LIBVPX"; then
2300     dnl ============================
2301     dnl === libvpx Version check ===
2302     dnl ============================
2303     dnl Check to see if we have a system libvpx package.
2304     PKG_CHECK_MODULES(MOZ_LIBVPX, vpx >= 1.5.0)
2306     CFLAGS="$CFLAGS $MOZ_LIBVPX_CFLAGS"
2307     LIBS="$LIBS $MOZ_LIBVPX_LIBS"
2309     MOZ_CHECK_HEADER([vpx/vpx_decoder.h], [],
2310      [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.])])
2312     AC_CHECK_LIB(vpx, vpx_codec_dec_init_ver, [],
2313      [AC_MSG_ERROR([--with-system-libvpx requested but symbol vpx_codec_dec_init_ver not found])])
2315     MOZ_CHECK_HEADER([vpx_mem/vpx_mem.h],
2316      [AC_CHECK_FUNC(vpx_mem_set_functions)])
2317     if test "$ac_cv_header_vpx_mem_vpx_mem_h" = no -o \
2318             "$ac_cv_func_vpx_mem_set_functions" = no; then
2319         AC_DEFINE(MOZ_VPX_NO_MEM_REPORTING)
2320     fi
2322 CFLAGS=$_SAVE_CFLAGS
2323 LIBS=$_SAVE_LIBS
2325 AC_SUBST(MOZ_SYSTEM_LIBVPX)
2326 AC_SUBST_LIST(MOZ_LIBVPX_CFLAGS)
2327 AC_SUBST_LIST(MOZ_LIBVPX_LIBS)
2329 if test -z "$MOZ_SYSTEM_LIBVPX"; then
2331     dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
2332     dnl We currently require yasm on all x86 platforms and require yasm 1.1.0 on Win32.
2333     dnl We currently require gcc on all arm platforms.
2335     dnl See if we have assembly on this platform.
2336     case "$OS_ARCH:$CPU_ARCH" in
2337     Darwin:x86)
2338       VPX_USE_YASM=1
2339       VPX_X86_ASM=1
2340     ;;
2341     Darwin:x86_64)
2342       VPX_USE_YASM=1
2343       VPX_X86_ASM=1
2344     ;;
2345     WINNT:x86_64)
2346       VPX_USE_YASM=1
2347       VPX_X86_ASM=1
2348     ;;
2349     WINNT:x86)
2350       dnl Check for yasm 1.1 or greater.
2351       if test -n "$COMPILE_ENVIRONMENT" -a -z "$YASM"; then
2352         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.])
2353       elif test -n "$COMPILE_ENVIRONMENT" -a "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
2354         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.])
2355       else
2356         VPX_USE_YASM=1
2357         VPX_X86_ASM=1
2358         dnl The encoder needs obj_int_extract to get asm offsets.
2359       fi # COMPILE_ENVIRONMENT and others
2360     ;;
2361     *:arm*)
2362       if test -n "$GNU_AS" ; then
2363         dnl These flags are a lie; they're just used to enable the requisite
2364         dnl opcodes; actual arch detection is done at runtime.
2365         VPX_ASFLAGS="-march=armv7-a -mfpu=neon"
2366         VPX_AS_CONVERSION='$(PERL) $(topsrcdir)/media/libvpx/libvpx/build/make/ads2gas.pl'
2367         VPX_ARM_ASM=1
2368         dnl Building with -mfpu=neon requires either the "softfp" or the
2369         dnl "hardfp" ABI. Depending on the compiler's default target, and the
2370         dnl CFLAGS, the default ABI might be neither, in which case it is the
2371         dnl "softfloat" ABI.
2372         dnl The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
2373         dnl we can safely mix code built with both ABIs. So, if we detect
2374         dnl that compiling uses the "softfloat" ABI, force the use of the
2375         dnl "softfp" ABI instead.
2376         dnl Confusingly, the __SOFTFP__ preprocessor variable indicates the
2377         dnl "softfloat" ABI, not the "softfp" ABI.
2378         dnl Note: VPX_ASFLAGS is also used in CFLAGS.
2379         AC_TRY_COMPILE([],
2380           [#ifndef __SOFTFP__
2381            #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
2382            #endif],
2383            VPX_ASFLAGS="$VPX_ASFLAGS -mfloat-abi=softfp"
2384            )
2385       fi
2386     ;;
2387     *:x86)
2388       if $CC -E -dM -</dev/null | grep -q __ELF__; then
2389         VPX_USE_YASM=1
2390         VPX_X86_ASM=1
2391       fi
2392     ;;
2393     *:x86_64)
2394       if $CC -E -dM -</dev/null | grep -q __ELF__; then
2395         VPX_USE_YASM=1
2396         VPX_X86_ASM=1
2397       fi
2398     ;;
2399     esac
2401     if test -n "$COMPILE_ENVIRONMENT" -a -n "$VPX_USE_YASM" -a -z "$YASM"; then
2402       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.])
2403     fi # COMPILE_ENVIRONMENT and others
2405     if test -n "$VPX_USE_YASM" && test "$OS_ARCH:$CPU_ARCH" != "WINNT:x86_64"; then
2406       VPX_ASFLAGS="-DPIC"
2407     fi
2409     if test -n "$VPX_X86_ASM"; then
2410       AC_DEFINE(VPX_X86_ASM)
2411     elif test -n "$VPX_ARM_ASM"; then
2412       AC_DEFINE(VPX_ARM_ASM)
2413     else
2414       AC_MSG_WARN([No assembler or assembly support for libvpx. Using unoptimized C routines.])
2415     fi
2417     dnl native libvpx no longer has vpx_mem_set_functions
2418     AC_DEFINE(MOZ_VPX_NO_MEM_REPORTING)
2421 dnl ========================================================
2422 dnl = Handle dependent MEDIA defines
2423 dnl ========================================================
2425 MOZ_WEBM_ENCODER=1
2426 AC_DEFINE(MOZ_WEBM_ENCODER)
2427 AC_SUBST(MOZ_WEBM_ENCODER)
2429 dnl ========================================================
2430 dnl NegotiateAuth
2431 dnl ========================================================
2433 MOZ_ARG_DISABLE_BOOL(negotiateauth,
2434 [  --disable-negotiateauth Disable GSS-API negotiation ],
2435     MOZ_AUTH_EXTENSION=,
2436     MOZ_AUTH_EXTENSION=1 )
2438 if test -n "$MOZ_IOS" -a -n "$MOZ_AUTH_EXTENSION"; then
2439    AC_MSG_ERROR([negotiateauth is not supported on iOS.])
2442 dnl ========================================================
2443 dnl Pref extensions (autoconfig)
2444 dnl ========================================================
2445 MOZ_ARG_DISABLE_BOOL(pref-extensions,
2446 [  --disable-pref-extensions
2447                           Disable pref extensions such as autoconfig],
2448   MOZ_PREF_EXTENSIONS=,
2449   MOZ_PREF_EXTENSIONS=1 )
2451 dnl ========================================================
2452 dnl Searching of system directories for extensions.
2453 dnl Note: this switch is meant to be used for test builds
2454 dnl whose behavior should not depend on what happens to be
2455 dnl installed on the local machine.
2456 dnl ========================================================
2457 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
2458 [  --disable-system-extension-dirs
2459                           Disable searching system- and account-global
2460                           directories for extensions of any kind; use
2461                           only profile-specific extension directories],
2462   ENABLE_SYSTEM_EXTENSION_DIRS=,
2463   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
2464 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
2465   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
2468 dnl ========================================================
2469 dnl = Universalchardet
2470 dnl ========================================================
2471 MOZ_ARG_DISABLE_BOOL(universalchardet,
2472 [  --disable-universalchardet
2473                           Disable universal encoding detection],
2474   MOZ_UNIVERSALCHARDET=,
2475   MOZ_UNIVERSALCHARDET=1 )
2477 dnl ========================================================
2478 dnl = ANGLE OpenGL->D3D translator for WebGL
2479 dnl = * only applies to win32 (and then, not MINGW)
2480 dnl ========================================================
2482 MOZ_ANGLE_RENDERER=
2483 MOZ_D3D_CPU_SUFFIX=
2484 MOZ_HAS_WINSDK_WITH_D3D=
2485 MOZ_D3DCOMPILER_VISTA_DLL=
2486 MOZ_D3DCOMPILER_VISTA_DLL_PATH=
2488 if test "$COMPILE_ENVIRONMENT" ; then
2489 case "$target_os" in
2490 *mingw*)
2491     MOZ_ANGLE_RENDERER=1
2492     ;;
2493 esac
2495 # The DirectX SDK libraries are split into x86 and x64 sub-directories
2496 case "${target_cpu}" in
2497 i*86)
2498   MOZ_D3D_CPU_SUFFIX=x86
2499   ;;
2500 x86_64)
2501   MOZ_D3D_CPU_SUFFIX=x64
2502   ;;
2503 aarch64)
2504   MOZ_D3D_CPU_SUFFIX=arm
2505   ;;
2506 esac
2508 dnl ========================================================
2509 dnl D3D compiler DLL
2510 dnl ========================================================
2511 MOZ_FOUND_D3D_COMPILERS=
2513 if test -n "$MOZ_ANGLE_RENDERER"; then
2514   if test -z "$MOZ_D3D_CPU_SUFFIX"; then
2515     AC_MSG_ERROR([Couldn't determine MOZ_D3D_CPU_SUFFIX.])
2516   fi
2518   ######################################
2519   # Find _46+ for use by Vista+.
2521   # Find a D3D compiler DLL in a Windows SDK.
2522   MOZ_D3DCOMPILER_VISTA_DLL=
2523   case "$MOZ_WINSDK_MAXVER" in
2524   0x0603*|0x0A00*)
2525     MOZ_D3DCOMPILER_VISTA_DLL=d3dcompiler_47.dll
2526     AC_MSG_RESULT([Found D3D compiler in Windows SDK.])
2527   ;;
2528   esac
2530   if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
2531     # We have a name, now track down the path.
2532     if test -n "$WINDOWSSDKDIR"; then
2533       MOZ_D3DCOMPILER_VISTA_DLL_PATH="$WINDOWSSDKDIR/Redist/D3D/$MOZ_D3D_CPU_SUFFIX/$MOZ_D3DCOMPILER_VISTA_DLL"
2534       if test -f "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
2535         AC_MSG_RESULT([Found MOZ_D3DCOMPILER_VISTA_DLL_PATH: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
2536         MOZ_HAS_WINSDK_WITH_D3D=1
2537       elif test "$target_cpu" = "aarch64" -a "$MOZ_D3DCOMPILER_VISTA_DLL" = "d3dcompiler_47.dll"; then
2538         AC_MSG_RESULT([AArch64 Windows includes d3dcompiler DLLs])
2539         MOZ_D3DCOMPILER_VISTA_DLL_PATH=
2540       else
2541         AC_MSG_RESULT([MOZ_D3DCOMPILER_VISTA_DLL_PATH doesn't exist: $MOZ_D3DCOMPILER_VISTA_DLL_PATH])
2542         AC_MSG_ERROR([Windows SDK at "$WINDOWSSDKDIR" appears broken. Try updating to MozillaBuild 1.9 final or higher.])
2543         MOZ_D3DCOMPILER_VISTA_DLL_PATH=
2544       fi
2545     else
2546       AC_MSG_RESULT([Windows SDK not found.])
2547     fi
2548   else
2549     if test "$OS_ARCH" = "$HOST_OS_ARCH"; then
2550       AC_MSG_ERROR([Couldn't find Windows SDK 8.1 or higher needed for ANGLE.])
2551     else
2552       AC_MSG_RESULT([Windows SDK not needed for ANGLE in Linux MinGW build.])
2553     fi
2554   fi
2556   if test -z "$MOZ_D3DCOMPILER_VISTA_DLL_PATH"; then
2557     MOZ_D3DCOMPILER_VISTA_DLL=
2558   fi
2560   # On mingw, check if headers are provided by toolchain.
2561   if test -n "$GNU_CC"; then
2562     MOZ_CHECK_HEADER(d3d10.h, MOZ_HAS_WINSDK_WITH_D3D=1)
2563   fi
2565   ######################################
2566   # Check that we found what we needed.
2567   MOZ_FOUND_A_D3D_COMPILER=
2569   if test -n "$MOZ_D3DCOMPILER_VISTA_DLL"; then
2570     MOZ_FOUND_A_D3D_COMPILER=1
2571     AC_MSG_RESULT([Found d3dcompiler DLL for Vista+: $MOZ_D3DCOMPILER_VISTA_DLL])
2572   fi
2574   if test -z "$CROSS_COMPILE"; then
2575     if test -z "MOZ_FOUND_A_D3D_COMPILER"; then
2576       AC_MSG_ERROR([Couldn't find an acceptable D3D compiler DLL.])
2577     fi
2578   fi
2579 fi # MOZ_ANGLE_RENDERER
2581 dnl ========================================================
2582 dnl Gamepad support
2583 dnl ========================================================
2585 dnl Moved gamepad platform check to moz.build, linux header check still needed here.
2586 if test "$OS_TARGET" = "Linux"; then
2587     MOZ_CHECK_HEADER([linux/joystick.h])
2588     if test "$ac_cv_header_linux_joystick_h" != "yes"; then
2589       AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers.])
2590     fi
2593 fi # COMPILE_ENVIRONMENT
2596 dnl ========================================================
2597 dnl = Breakpad crash reporting (on by default on supported platforms)
2598 dnl ========================================================
2600 case $target in
2601 i?86-*-mingw*|x86_64-*-mingw*)
2602   MOZ_CRASHREPORTER=1
2603   ;;
2604 i?86-apple-darwin*|x86_64-apple-darwin*)
2605   if test -z "$MOZ_IOS"; then
2606     MOZ_CRASHREPORTER=1
2607   fi
2608   ;;
2609 *-android*|*-linuxandroid*)
2610   dnl Android/arm is arm-unknown-linux-androideabi, so android condition should
2611   dnl be before Linux condition
2612   MOZ_CRASHREPORTER=1
2613   ;;
2614 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
2615   if test "$MOZ_ENABLE_GTK"; then
2616     MOZ_CRASHREPORTER=1
2617   fi
2618   ;;
2619 esac
2621 MOZ_ARG_DISABLE_BOOL(crashreporter,
2622 [  --disable-crashreporter Disable breakpad crash reporting],
2623     [MOZ_CRASHREPORTER=],
2624     [MOZ_CRASHREPORTER=F # Force enable breakpad])
2626 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "Darwin"; then
2627   if test "$MOZ_CRASHREPORTER" = F; then
2628     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
2629   fi
2630   MOZ_CRASHREPORTER=
2633 if test -n "$MOZ_CRASHREPORTER"; then
2634    AC_DEFINE(MOZ_CRASHREPORTER)
2636   if test "$OS_TARGET" = "Linux" && \
2637     test -z "$SKIP_LIBRARY_CHECKS"; then
2638     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
2639   fi
2641   if test "$OS_ARCH" = "WINNT"; then
2642     if test -z "$HAVE_64BIT_BUILD" -a -n "$COMPILE_ENVIRONMENT"; then
2643       MOZ_CRASHREPORTER_INJECTOR=1
2644       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
2645     fi
2646   fi
2649 dnl ========================================================
2650 dnl = libjpeg-turbo configuration
2651 dnl ========================================================
2652 MOZ_LIBJPEG_TURBO=
2653 LIBJPEG_TURBO_USE_YASM=
2654 if test -z "$MOZ_SYSTEM_JPEG"; then
2655     MOZ_LIBJPEG_TURBO=1
2658 MOZ_ARG_DISABLE_BOOL(libjpeg_turbo,
2659 [ --disable-libjpeg-turbo  Disable optimized jpeg decoding routines],
2660     MOZ_LIBJPEG_TURBO=,
2661     MOZ_LIBJPEG_TURBO=1)
2663 if test "$MOZ_SYSTEM_JPEG" = 1 -a "$MOZ_LIBJPEG_TURBO" = 1; then
2664     AC_MSG_ERROR([cannot use --with-system-jpeg with --enable-libjpeg-turbo.])
2667 dnl Detect if we can use yasm to compile libjpeg-turbo's optimized assembly
2668 dnl files.
2670 if test -n "$MOZ_LIBJPEG_TURBO" -a -n "$COMPILE_ENVIRONMENT"; then
2672   dnl Do we support libjpeg-turbo on this platform?
2673   case "$OS_ARCH:$CPU_ARCH" in
2674   Darwin:x86)
2675     LIBJPEG_TURBO_ASFLAGS="-DPIC -DMACHO"
2676   ;;
2677   Darwin:x86_64)
2678     LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DMACHO"
2679   ;;
2680   Darwin:arm*)
2681   ;;
2682   WINNT:x86)
2683     LIBJPEG_TURBO_ASFLAGS="-DPIC -DWIN32"
2684   ;;
2685   WINNT:x86_64)
2686     LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DWIN64 -DMSVC"
2687   ;;
2688   WINNT:*)
2689   ;;
2690   *:arm)
2691     LIBJPEG_TURBO_ASFLAGS="-march=armv7-a -mfpu=neon"
2692   ;;
2693   *:aarch64)
2694     LIBJPEG_TURBO_ASFLAGS="-march=armv8-a"
2695   ;;
2696   *:mips32)
2697     LIBJPEG_TURBO_ASFLAGS="-mdspr2"
2698   ;;
2699   *:x86)
2700     if $CC -E -dM -</dev/null | grep -q __ELF__; then
2701       LIBJPEG_TURBO_ASFLAGS="-DPIC -DELF"
2702     fi
2703   ;;
2704   *:x86_64)
2705     if $CC -E -dM -</dev/null | grep -q __ELF__; then
2706       LIBJPEG_TURBO_ASFLAGS="-D__x86_64__ -DPIC -DELF"
2707     fi
2708   ;;
2709   esac
2712 if test -n "$LIBJPEG_TURBO_ASFLAGS"; then
2713   case "$CPU_ARCH" in
2714 dnl If we're on an x86 or x64 system which supports libjpeg-turbo's asm routines
2715 dnl and --disable-libjpeg-turbo wasn't passed, check for Yasm, and error out if
2716 dnl it doesn't exist or we have too old of a version.
2717   x86_64|x86)
2718     LIBJPEG_TURBO_USE_YASM=1
2720     if test -z "$YASM" ; then
2721         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.])
2722     fi
2724     dnl Check that we have the right yasm version.  We require 1.0.1 or newer
2725     dnl on Linux and 1.1 or newer everywhere else.
2726     if test "$OS_ARCH" = "Linux" ; then
2727         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
2728             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.])
2729         fi
2730     else
2731         if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
2732             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.])
2733         fi
2734     fi
2735   ;;
2736   esac
2739 dnl ========================================================
2740 dnl = libav-fft configuration
2741 dnl ========================================================
2743 MOZ_LIBAV_FFT=
2745 dnl Turn on libav-fft for 32-bit windows, and all 64-bit supported platforms.
2746 dnl 32-bit linux/os x have text relocation issues.
2748 case "$OS_ARCH:$CPU_ARCH" in
2749   WINNT:x86)
2750       MOZ_LIBAV_FFT=1
2751   ;;
2752   *:x86_64)
2753       MOZ_LIBAV_FFT=1
2754   ;;
2755 esac
2757 dnl Detect if we can use yasm to compile libav's assembly
2759 if test -n "$MOZ_LIBAV_FFT" -a -n "$COMPILE_ENVIRONMENT"; then
2760   AC_DEFINE(MOZ_LIBAV_FFT)
2761   dnl Do we support libav-fft on this platform?
2762   case "$OS_ARCH:$CPU_ARCH" in
2763   Darwin:x86_64)
2764     LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DMACHO"
2765   ;;
2766   WINNT:x86)
2767     LIBAV_FFT_ASFLAGS="-DPIC -DWIN32"
2768   ;;
2769   WINNT:x86_64)
2770     LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DWIN64 -DMSVC"
2771   ;;
2772   *:x86_64)
2773     if $CC -E -dM -</dev/null | grep -q __ELF__; then
2774       LIBAV_FFT_ASFLAGS="-D__x86_64__ -DPIC -DELF"
2775     fi
2776   ;;
2777   *)
2778     AC_MSG_ERROR([libav's FFT routines are only available for 32-bit windows or 64-bit x86 based platforms.])
2779   ;;
2780   esac
2783 if test -n "$LIBAV_FFT_ASFLAGS"; then
2784   dnl If we're on an x86 or x64 system which supports libav-fft's asm routines
2785   dnl check for Yasm, and error out if it doesn't exist or we have too old of a
2786   dnl version.
2787   if test -z "$YASM" ; then
2788     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.])
2789   fi
2790   dnl Check that we have the right yasm version.  We require 1.0.1 or newer
2791   dnl on Linux and 1.1 or newer everywhere else.
2792   if test "$OS_ARCH" = "Linux" ; then
2793     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
2794       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.])
2795     fi
2796   else
2797     if test "$_YASM_MAJOR_VERSION" -lt "1" -o \( "$_YASM_MAJOR_VERSION" -eq "1" -a "$_YASM_MINOR_VERSION" -lt "1" \) ; then
2798       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.])
2799     fi
2800   fi
2801 elif test -n "$MOZ_LIBAV_FFT" -a "${CPU_ARCH}" != "arm"; then
2802   dnl Warn if we're not building either libav or opendl-max optimized routines.
2803   AC_MSG_WARN([No assembler or assembly support for libav-fft.  Using unoptimized C routines.])
2806 dnl ========================================================
2807 dnl = FFmpeg's ffvpx configuration
2808 dnl ========================================================
2810 MOZ_FFVPX=
2811 MOZ_FFVPX_FLACONLY=
2812 case "$CPU_ARCH" in
2813   x86|x86_64)
2814       MOZ_FFVPX=1
2815       dnl Use same conditional as MOZ_LIBAV_FFT to enable FFmpeg's ffvpx assembly decoder.
2816       if test -n "$LIBAV_FFT_ASFLAGS"; then
2817           FFVPX_ASFLAGS=$LIBAV_FFT_ASFLAGS
2818       else
2819           dnl On x86 system with assembly optimizations disabled, the ffvp9 and
2820           dnl ffvp8 decoders give worse performance than libvpx ones. So we only
2821           dnl enable the FFmpeg FLAC decoder on those machines.
2822           MOZ_FFVPX_FLACONLY=1
2823       fi
2824   ;;
2825   arm*|aarch64)
2826       case "$OS_TARGET" in
2827         WINNT)
2828           dnl don't set up anything special
2829           ;;
2830         *)
2831           MOZ_FFVPX=1
2832           MOZ_FFVPX_FLACONLY=1
2833           dnl Use same conditional as MOZ_LIBVPX to enable FFmpeg's ffvpx assembly decoder.
2834           dnl aarch 64 FLAC decoder for now will be C only.
2835           FFVPX_ASFLAGS=$VPX_ASFLAGS
2836           ;;
2837       esac
2838   ;;
2839 esac
2841 if test -n "$MOZ_FFVPX"; then
2842   AC_DEFINE(MOZ_FFVPX)
2844 if test -n "$MOZ_FFVPX_FLACONLY"; then
2845   AC_DEFINE(MOZ_FFVPX_FLACONLY)
2848 dnl ========================================================
2849 dnl = Enable compilation of specific extension modules
2850 dnl ========================================================
2852 MOZ_ARG_ENABLE_STRING(extensions,
2853 [  --enable-extensions     Enable extensions],
2854 [ for option in `echo $enableval | sed 's/,/ /g'`; do
2855     if test "$option" = "yes" -o "$option" = "all"; then
2856         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
2857     elif test "$option" = "no" -o "$option" = "none"; then
2858         MOZ_EXTENSIONS=""
2859     elif test "$option" = "default"; then
2860         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
2861     elif test `echo "$option" | grep -c \^-` != 0; then
2862         option=`echo $option | sed 's/^-//'`
2863         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
2864     else
2865         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
2866     fi
2867 done],
2868     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
2870 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
2871 dnl when trying to build a nonexistent extension.
2872 for extension in $MOZ_EXTENSIONS; do
2873     if test ! -d "${srcdir}/extensions/${extension}"; then
2874         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
2875     fi
2876 done
2878 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
2879   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
2882 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
2883 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
2884 if test -n "$MOZ_TREE_FREETYPE" -a "$OS_TARGET" != WINNT; then
2885    MOZ_ENABLE_CAIRO_FT=1
2886    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
2887    CAIRO_FT_CFLAGS="-I$_topsrcdir/modules/freetype2/include"
2888    AC_SUBST_LIST(CAIRO_FT_CFLAGS)
2891 AC_CHECK_PROGS(WGET, wget, "")
2892 AC_SUBST(WGET)
2894 dnl ========================================================
2895 dnl Enable building the signmar program.
2896 dnl This option is much different than the --enable-verify-mar option.
2897 dnl --enable-verify-mar is for enabling the verification check on MAR
2898 dnl files in the updater.  The --enable-signmar option is for building
2899 dnl the signmar program.
2900 dnl ========================================================
2902 MOZ_ARG_ENABLE_BOOL(signmar,
2903 [  --enable-signmar     Enable building the signmar program],
2904     MOZ_ENABLE_SIGNMAR=1,
2905     MOZ_ENABLE_SIGNMAR= )
2907 if test -n "$MOZ_ENABLE_SIGNMAR"; then
2908   if test -z "$COMPILE_ENVIRONMENT" ; then
2909     AC_MSG_WARN([Cannot --enable-signmar with --disable-compile-environment])
2910     MOZ_ENABLE_SIGNMAR=
2911   else
2912     AC_DEFINE(MOZ_ENABLE_SIGNMAR)
2913   fi
2916 dnl ========================================================
2917 dnl Updater
2918 dnl ========================================================
2920 if test "$MOZ_IOS"; then
2921   MOZ_UPDATER=
2924 MOZ_ARG_DISABLE_BOOL(updater,
2925 [  --disable-updater       Disable building of updater],
2926     MOZ_UPDATER=,
2927     MOZ_UPDATER=1 )
2929 if test -n "$MOZ_UPDATER"; then
2930     AC_DEFINE(MOZ_UPDATER)
2933 dnl ========================================================
2934 dnl parental controls (for Windows Vista)
2935 dnl ========================================================
2936 MOZ_ARG_DISABLE_BOOL(parental-controls,
2937 [  --disable-parental-controls
2938                           Do not build parental controls],
2939    MOZ_DISABLE_PARENTAL_CONTROLS=1,
2940    MOZ_DISABLE_PARENTAL_CONTROLS=)
2941 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
2942     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
2945 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
2947 dnl ========================================================
2948 dnl = Disable smartcard support
2949 dnl ========================================================
2950 if test -n "$MOZ_NO_SMART_CARDS"; then
2951     AC_DEFINE(MOZ_NO_SMART_CARDS)
2953 AC_SUBST(MOZ_NO_SMART_CARDS)
2955 dnl ========================================================
2956 dnl = Sandboxing support
2957 dnl ========================================================
2958 if test -n "$MOZ_TSAN" -o -n "$MOZ_ASAN"; then
2959     # Bug 1182565: TSan conflicts with sandboxing on Linux.
2960     # Bug 1287971: LSan also conflicts with sandboxing on Linux.
2961     case $OS_TARGET in
2962     Linux|Android)
2963         MOZ_SANDBOX=
2964         ;;
2965     esac
2968 case "$OS_TARGET:$CPU_ARCH" in
2969 WINNT:aarch64)
2970     # No sandbox support on AArch64 Windows.
2971     MOZ_SANDBOX=
2972     ;;
2973 esac
2975 MOZ_ARG_DISABLE_BOOL(sandbox,
2976 [  --disable-sandbox        Disable sandboxing support],
2977     MOZ_SANDBOX=,
2978     MOZ_SANDBOX=1)
2980 dnl ========================================================
2981 dnl = Content process sandboxing
2982 dnl ========================================================
2984 case "$OS_TARGET" in
2985 WINNT)
2986     MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
2987     ;;
2988 Darwin)
2989     MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
2990     ;;
2991 Linux)
2992     case $CPU_ARCH in
2993         x86_64|x86)
2994             MOZ_CONTENT_SANDBOX=$MOZ_SANDBOX
2995         ;;
2996     esac
2997     ;;
2998 esac
3000 MOZ_ARG_ENABLE_BOOL(content-sandbox,
3001 [  --enable-content-sandbox Enable sandboxing support for content-processes
3002   --disable-content-sandbox Disable sandboxing support for content-processes],
3003     MOZ_CONTENT_SANDBOX=1,
3004     MOZ_CONTENT_SANDBOX=)
3006 if test -n "$MOZ_CONTENT_SANDBOX" -a -z "$MOZ_SANDBOX"; then
3007     AC_MSG_ERROR([--enable-content-sandbox and --disable-sandbox are conflicting options])
3010 if test -n "$MOZ_CONTENT_SANDBOX"; then
3011     AC_DEFINE(MOZ_CONTENT_SANDBOX)
3014 AC_SUBST(MOZ_CONTENT_SANDBOX)
3016 dnl ========================================================
3017 dnl = Gecko Media Plugin sandboxing
3018 dnl ========================================================
3019 case $OS_TARGET in
3020 WINNT)
3021     MOZ_GMP_SANDBOX=$MOZ_SANDBOX
3022     ;;
3023 Linux)
3024     case $CPU_ARCH in
3025     x86_64|x86)
3026         MOZ_GMP_SANDBOX=$MOZ_SANDBOX
3027         ;;
3028     esac
3029     ;;
3030 Darwin)
3031     MOZ_GMP_SANDBOX=$MOZ_SANDBOX
3032     ;;
3033 esac
3035 if test -n "$MOZ_GMP_SANDBOX"; then
3036     AC_DEFINE(MOZ_GMP_SANDBOX)
3039 AC_SUBST(MOZ_GMP_SANDBOX)
3041 if test -z "$MOZ_CONTENT_SANDBOX" -a -z "$MOZ_GMP_SANDBOX"; then
3042     MOZ_SANDBOX=
3045 if test -n "$MOZ_SANDBOX"; then
3046     AC_DEFINE(MOZ_SANDBOX)
3049 AC_SUBST(MOZ_SANDBOX)
3052 dnl ========================================================
3053 dnl =
3054 dnl = Module specific options
3055 dnl =
3056 dnl ========================================================
3057 MOZ_ARG_HEADER(Individual module options)
3059 dnl ========================================================
3060 dnl = Disable feed handling components
3061 dnl ========================================================
3062 MOZ_ARG_DISABLE_BOOL(feeds,
3063 [  --disable-feeds         Disable feed handling and processing components],
3064     MOZ_FEEDS=,
3065     MOZ_FEEDS=1 )
3066 if test -n "$MOZ_FEEDS"; then
3067     AC_DEFINE(MOZ_FEEDS)
3068 else
3069     if test "$MOZ_BUILD_APP" = "browser"; then
3070         AC_MSG_ERROR([Cannot build Firefox with --disable-feeds.])
3071     fi
3074 dnl ========================================================
3075 dnl Check for sqlite
3076 dnl ========================================================
3078 MOZ_SYSTEM_SQLITE=
3079 MOZ_ARG_ENABLE_BOOL(system-sqlite,
3080 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
3081 MOZ_SYSTEM_SQLITE=1,
3082 MOZ_SYSTEM_SQLITE= )
3084 if test -n "$MOZ_SYSTEM_SQLITE"
3085 then
3086     dnl ============================
3087     dnl === SQLite Version check ===
3088     dnl ============================
3089     dnl Check to see if the system SQLite package is new enough.
3090     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
3092     dnl ==================================
3093     dnl === SQLITE_SECURE_DELETE check ===
3094     dnl ==================================
3095     dnl Check to see if the system SQLite package is compiled with
3096     dnl SQLITE_SECURE_DELETE enabled.
3097     AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system SQLite)
3098     _SAVE_CFLAGS="$CFLAGS"
3099     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3100     _SAVE_LIBS="$LIBS"
3101     LIBS="$LIBS $SQLITE_LIBS"
3102     AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
3103         AC_TRY_RUN([
3104             #include "sqlite3.h"
3106             int main(int argc, char **argv){
3107               return !sqlite3_compileoption_used("SQLITE_SECURE_DELETE");
3108             }],
3109             ac_cv_sqlite_secure_delete=yes,
3110             ac_cv_sqlite_secure_delete=no,
3111             ac_cv_sqlite_secure_delete=no
3112         )
3113     ])
3114     AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
3115     CFLAGS="$_SAVE_CFLAGS"
3116     LIBS="$_SAVE_LIBS"
3117     if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
3118         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_SECURE_DELETE.])
3119     fi
3121     dnl ===============================
3122     dnl === SQLITE_THREADSAFE check ===
3123     dnl ===============================
3124     dnl Check to see if the system SQLite package is compiled with
3125     dnl SQLITE_THREADSAFE enabled.
3126     AC_MSG_CHECKING(for SQLITE_THREADSAFE support in system SQLite)
3127     _SAVE_CFLAGS="$CFLAGS"
3128     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3129     _SAVE_LIBS="$LIBS"
3130     LIBS="$LIBS $SQLITE_LIBS"
3131     AC_CACHE_VAL(ac_cv_sqlite_threadsafe,[
3132         AC_TRY_RUN([
3133             #include "sqlite3.h"
3135             int main(int argc, char **argv){
3136               return !sqlite3_compileoption_used("SQLITE_THREADSAFE=1");
3137             }],
3138             ac_cv_sqlite_threadsafe=yes,
3139             ac_cv_sqlite_threadsafe=no,
3140             ac_cv_sqlite_threadsafe=no
3141         )
3142     ])
3143     AC_MSG_RESULT($ac_cv_sqlite_threadsafe)
3144     CFLAGS="$_SAVE_CFLAGS"
3145     LIBS="$_SAVE_LIBS"
3146     if test "x$ac_cv_sqlite_threadsafe" = "xno"; then
3147         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_THREADSAFE.])
3148     fi
3150     dnl ================================
3151     dnl === SQLITE_ENABLE_FTS3 check ===
3152     dnl ================================
3153     dnl check to see if the system SQLite package is compiled with
3154     dnl SQLITE_ENABLE_FTS3 enabled.
3155     AC_MSG_CHECKING(for SQLITE_ENABLE_FTS3 support in system SQLite)
3156     _SAVE_CFLAGS="$CFLAGS"
3157     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3158     _SAVE_LIBS="$LIBS"
3159     LIBS="$LIBS $SQLITE_LIBS"
3160     AC_CACHE_VAL(ac_cv_sqlite_enable_fts3,[
3161         AC_TRY_RUN([
3162             #include "sqlite3.h"
3164             int main(int argc, char **argv){
3165               return !sqlite3_compileoption_used("SQLITE_ENABLE_FTS3");
3166             }],
3167             ac_cv_sqlite_enable_fts3=yes,
3168             ac_cv_sqlite_enable_fts3=no,
3169             ac_cv_sqlite_enable_fts3=no
3170         )
3171     ])
3172     AC_MSG_RESULT($ac_cv_sqlite_enable_fts3)
3173     CFLAGS="$_SAVE_CFLAGS"
3174     LIBS="$_SAVE_LIBS"
3175     if test "x$ac_cv_sqlite_enable_fts3" = "xno"; then
3176         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_FTS3.])
3177     fi
3179     dnl =========================================
3180     dnl === SQLITE_ENABLE_UNLOCK_NOTIFY check ===
3181     dnl =========================================
3182     dnl check to see if the system SQLite package is compiled with
3183     dnl SQLITE_ENABLE_UNLOCK_NOTIFY enabled.
3184     AC_MSG_CHECKING(for SQLITE_ENABLE_UNLOCK_NOTIFY support in system SQLite)
3185     _SAVE_CFLAGS="$CFLAGS"
3186     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3187     _SAVE_LIBS="$LIBS"
3188     LIBS="$LIBS $SQLITE_LIBS"
3189     AC_CACHE_VAL(ac_cv_sqlite_enable_unlock_notify,[
3190         AC_TRY_RUN([
3191             #include "sqlite3.h"
3193             int main(int argc, char **argv){
3194               return !sqlite3_compileoption_used("SQLITE_ENABLE_UNLOCK_NOTIFY");
3195             }],
3196             ac_cv_sqlite_enable_unlock_notify=yes,
3197             ac_cv_sqlite_enable_unlock_notify=no,
3198             ac_cv_sqlite_enable_unlock_notify=no
3199         )
3200     ])
3201     AC_MSG_RESULT($ac_cv_sqlite_enable_unlock_notify)
3202     CFLAGS="$_SAVE_CFLAGS"
3203     LIBS="$_SAVE_LIBS"
3204     if test "x$ac_cv_sqlite_enable_unlock_notify" = "xno"; then
3205         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_UNLOCK_NOTIFY.])
3206     fi
3208     dnl =========================================
3209     dnl === SQLITE_ENABLE_DBSTAT_VTAB check ===
3210     dnl =========================================
3211     dnl check to see if the system SQLite package is compiled with
3212     dnl SQLITE_ENABLE_DBSTAT_VTAB.
3213     AC_MSG_CHECKING(for SQLITE_ENABLE_DBSTAT_VTAB support in system SQLite)
3214     _SAVE_CFLAGS="$CFLAGS"
3215     CFLAGS="$CFLAGS $SQLITE_CFLAGS"
3216     _SAVE_LIBS="$LIBS"
3217     LIBS="$LIBS $SQLITE_LIBS"
3218     AC_CACHE_VAL(ac_cv_sqlite_dbstat_vtab,[
3219         AC_TRY_RUN([
3220             #include "sqlite3.h"
3222             int main(int argc, char **argv){
3223               return !sqlite3_compileoption_used("SQLITE_ENABLE_DBSTAT_VTAB");
3224             }],
3225             ac_cv_sqlite_dbstat_vtab=yes,
3226             ac_cv_sqlite_dbstat_vtab=no,
3227             ac_cv_sqlite_dbstat_vtab=no
3228         )
3229     ])
3230     AC_MSG_RESULT($ac_cv_sqlite_dbstat_vtab)
3231     CFLAGS="$_SAVE_CFLAGS"
3232     LIBS="$_SAVE_LIBS"
3233     if test "x$ac_cv_sqlite_dbstat_vtab" = "xno"; then
3234         AC_MSG_ERROR([System SQLite library is not compiled with SQLITE_ENABLE_DBSTAT_VTAB.])
3235     fi
3236 else
3237     dnl ==============================
3238     dnl === SQLite fdatasync check ===
3239     dnl ==============================
3240     dnl Check to see if fdatasync is available
3241     AC_CHECK_FUNC(fdatasync)
3244 if test -n "$MOZ_SYSTEM_SQLITE"; then
3245     AC_DEFINE(MOZ_SYSTEM_SQLITE)
3247 AC_SUBST(MOZ_SYSTEM_SQLITE)
3249 dnl ========================================================
3250 dnl = Disable zipwriter
3251 dnl ========================================================
3252 MOZ_ARG_DISABLE_BOOL(zipwriter,
3253 [  --disable-zipwriter     Disable zipwriter component],
3254     MOZ_ZIPWRITER=,
3255     MOZ_ZIPWRITER=1 )
3256 AC_SUBST(MOZ_ZIPWRITER)
3258 dnl ========================================================
3259 dnl =
3260 dnl = Feature options that require extra sources to be pulled
3261 dnl =
3262 dnl ========================================================
3263 dnl MOZ_ARG_HEADER(Features that require extra sources)
3265 dnl ========================================================
3266 dnl =
3267 dnl = Runtime debugging and Optimization Options
3268 dnl =
3269 dnl ========================================================
3270 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
3272 dnl ========================================================
3273 dnl enable mobile optimizations
3274 dnl ========================================================
3275 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
3276 [  --enable-mobile-optimize
3277                           Enable mobile optimizations],
3278     MOZ_GFX_OPTIMIZE_MOBILE=1)
3280 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
3282 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
3283     # We ignore paint will resample on mobile for performance.
3284     # We may want to revisit this later.
3285     MOZ_IGNORE_PAINT_WILL_RESAMPLE=1
3287     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
3288     AC_DEFINE(MOZ_IGNORE_PAINT_WILL_RESAMPLE)
3291 dnl ========================================================
3292 dnl = Enable code optimization. ON by default.
3293 dnl ========================================================
3295 # Use value from moz.configure if one is defined. Else use our computed
3296 # value.
3297 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
3298     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
3301 MOZ_SET_FRAMEPTR_FLAGS
3303 if test "$COMPILE_ENVIRONMENT"; then
3304 if test -n "$MOZ_OPTIMIZE"; then
3305     AC_MSG_CHECKING([for valid C compiler optimization flags])
3306     _SAVE_CFLAGS=$CFLAGS
3307     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
3308     AC_TRY_COMPILE([#include <stdio.h>],
3309         [printf("Hello World\n");],
3310         _results=yes,
3311         _results=no)
3312     AC_MSG_RESULT([$_results])
3313     if test "$_results" = "no"; then
3314         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
3315     fi
3316     CFLAGS=$_SAVE_CFLAGS
3317     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
3318         # When using llvm-based LTO, non numeric optimization levels are
3319         # not supported by the linker, so force the linker to use -O2 (
3320         # which doesn't influence the level compilation units are actually
3321         # compiled at).
3322         case " $MOZ_OPTIMIZE_FLAGS " in
3323         *\ -Os\ *|*\ -Oz\ *)
3324             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
3325             ;;
3326         esac
3327     fi
3329 fi # COMPILE_ENVIRONMENT
3331 AC_SUBST_LIST(MOZ_FRAMEPTR_FLAGS)
3332 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
3333 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
3334 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
3336 dnl ========================================================
3337 dnl = Disable treating compiler warnings as errors
3338 dnl ========================================================
3339 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
3340    WARNINGS_AS_ERRORS=''
3343 dnl ========================================================
3344 dnl = Enable runtime logging
3345 dnl ========================================================
3346 AC_DEFINE(MOZ_LOGGING)
3347 AC_DEFINE(FORCE_PR_LOG)
3349 dnl ========================================================
3350 dnl = This will enable logging of addref, release, ctor, dtor.
3351 dnl ========================================================
3352 _ENABLE_LOGREFCNT=42
3353 MOZ_ARG_ENABLE_BOOL(logrefcnt,
3354 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
3355     _ENABLE_LOGREFCNT=1,
3356     _ENABLE_LOGREFCNT= )
3357 if test "$_ENABLE_LOGREFCNT" = "1"; then
3358     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
3359 elif test -z "$_ENABLE_LOGREFCNT"; then
3360     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
3363 dnl ========================================================
3364 dnl moz_dump_painting
3365 dnl ========================================================
3366 MOZ_ARG_ENABLE_BOOL(dump-painting,
3367 [  --enable-dump-painting          Enable paint debugging.],
3368     MOZ_DUMP_PAINTING=1,
3369     MOZ_DUMP_PAINTING= )
3370 if test -n "$MOZ_DUMP_PAINTING"; then
3371     AC_DEFINE(MOZ_DUMP_PAINTING)
3372     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
3374 if test -n "$MOZ_DEBUG"; then
3375     AC_DEFINE(MOZ_DUMP_PAINTING)
3378 case "${OS_TARGET}" in
3379 Android|WINNT|Darwin)
3380   MOZ_GLUE_IN_PROGRAM=
3381   ;;
3383   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
3384   MOZ_GLUE_IN_PROGRAM=1
3385   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
3386   ;;
3387 esac
3389 dnl ========================================================
3390 dnl = Jemalloc build setup
3391 dnl ========================================================
3392 if test -z "$MOZ_MEMORY"; then
3393   case "${target}" in
3394     *-mingw*)
3395       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
3396         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.])
3397       fi
3398       ;;
3399   esac
3400 else
3401   dnl The generic feature tests that determine how to compute ncpus are long and
3402   dnl complicated.  Therefore, simply define special cpp variables for the
3403   dnl platforms we have special knowledge of.
3404   case "${target}" in
3405   *-mingw*)
3406     export MOZ_NO_DEBUG_RTL=1
3407     ;;
3408   esac
3409 fi # MOZ_MEMORY
3410 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
3412 AC_SUBST_LIST(MOZ_GLUE_WRAP_LDFLAGS)
3413 export MOZ_GLUE_WRAP_LDFLAGS
3415 dnl ========================================================
3416 dnl = Enable using the clang plugin to build
3417 dnl ========================================================
3419 if test -n "$COMPILE_ENVIRONMENT"; then
3420 MOZ_CONFIG_CLANG_PLUGIN
3421 fi # COMPILE_ENVIRONMENT
3423 dnl ========================================================
3424 dnl = Enable stripping of libs & executables
3425 dnl ========================================================
3426 MOZ_ARG_ENABLE_BOOL(strip,
3427 [  --enable-strip          Enable stripping of libs & executables ],
3428     ENABLE_STRIP=1,
3429     ENABLE_STRIP= )
3431 dnl ========================================================
3432 dnl = Enable stripping of libs & executables when packaging
3433 dnl ========================================================
3434 MOZ_ARG_ENABLE_BOOL(install-strip,
3435 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
3436     PKG_SKIP_STRIP= ,
3437     PKG_SKIP_STRIP=1)
3439 dnl ========================================================
3440 dnl = frontend JS debug mode
3441 dnl ========================================================
3443 MOZ_ARG_ENABLE_BOOL(debug-js-modules,
3444 [  --enable-debug-js-modules  Enable debug mode for frontend JS libraries],
3445    DEBUG_JS_MODULES=1,
3446    DEBUG_JS_MODULES=)
3448 AC_SUBST(DEBUG_JS_MODULES)
3450 dnl ========================================================
3451 dnl =
3452 dnl = Profiling and Instrumenting
3453 dnl =
3454 dnl ========================================================
3455 MOZ_ARG_HEADER(Profiling and Instrumenting)
3457 dnl ========================================================
3458 dnl = Offer a way to disable the startup cache
3459 dnl ========================================================
3461 MOZ_ARG_DISABLE_BOOL(startupcache,
3462 [  --disable-startupcache          Disable startup cache ],
3463     MOZ_DISABLE_STARTUPCACHE=1,
3464     MOZ_DISABLE_STARTUPCACHE=)
3466 if test -n "$MOZ_DISABLE_STARTUPCACHE"; then
3467   AC_DEFINE(MOZ_DISABLE_STARTUPCACHE)
3469 AC_SUBST(MOZ_DISABLE_STARTUPCACHE)
3471 dnl ========================================================
3472 dnl = Support for demangling undefined symbols
3473 dnl ========================================================
3474 if test -z "$SKIP_LIBRARY_CHECKS"; then
3475     AC_LANG_SAVE
3476     AC_LANG_CPLUSPLUS
3477     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
3478     AC_LANG_RESTORE
3481 # Demangle only for debug or DMD builds
3482 MOZ_DEMANGLE_SYMBOLS=
3483 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
3484     MOZ_DEMANGLE_SYMBOLS=1
3485     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
3487 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
3489 dnl ========================================================
3490 dnl = Support for gcc stack unwinding (from gcc 3.3)
3491 dnl ========================================================
3492 if test -z "$SKIP_LIBRARY_CHECKS"; then
3493     AC_LANG_SAVE
3494     AC_LANG_CPLUSPLUS
3495     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
3496     AC_LANG_RESTORE
3499 dnl ========================================================
3500 dnl JIT observers
3501 dnl ========================================================
3503 MOZ_ARG_WITH_STRING(jitreport-granularity,
3504 [  --jitreport-granularity=N
3505                            Default granularity at which to report JIT code
3506                            to external tools
3507                              0 - no info
3508                              1 - code ranges for whole functions only
3509                              2 - per-line information
3510                              3 - per-op information],
3511   JITREPORT_GRANULARITY=$withval,
3512   JITREPORT_GRANULARITY=3)
3514 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
3516 dnl ========================================================
3517 dnl =
3518 dnl = Misc. Options
3519 dnl =
3520 dnl ========================================================
3521 MOZ_ARG_HEADER(Misc. Options)
3523 dnl ========================================================
3524 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
3525 dnl ========================================================
3526 MOZ_ARG_WITH_STRING(user-appdir,
3527 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
3528 [ val=`echo $withval`
3529 if echo "$val" | grep "\/" >/dev/null; then
3530     AC_MSG_ERROR("Homedir must be single relative path.")
3531 else
3532     MOZ_USER_DIR="$val"
3533 fi])
3535 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
3537 if test -z "$SKIP_COMPILER_CHECKS"; then
3538 dnl ========================================================
3539 dnl =
3540 dnl = Compiler Options
3541 dnl =
3542 dnl ========================================================
3543 MOZ_ARG_HEADER(Compiler Options)
3545 dnl ========================================================
3546 dnl Check for gcc -pipe support
3547 dnl ========================================================
3548 AC_MSG_CHECKING([for -pipe support])
3549 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
3550     dnl Any gcc that supports firefox supports -pipe.
3551     CFLAGS="$CFLAGS -pipe"
3552     CXXFLAGS="$CXXFLAGS -pipe"
3553     AC_MSG_RESULT([yes])
3554 else
3555     AC_MSG_RESULT([no])
3558 fi # ! SKIP_COMPILER_CHECKS
3560 AC_DEFINE(CPP_THROW_NEW, [throw()])
3561 AC_LANG_C
3563 if test "$COMPILE_ENVIRONMENT"; then
3564 MOZ_EXPAND_LIBS
3565 fi # COMPILE_ENVIRONMENT
3567 dnl ========================================================
3568 dnl =
3569 dnl = Static Build Options
3570 dnl =
3571 dnl ========================================================
3572 MOZ_ARG_HEADER(Static build options)
3574 if test -z "$MOZ_SYSTEM_ZLIB"; then
3575 if test -n "$JS_SHARED_LIBRARY" -o -n "$MOZ_LINKER"; then
3576   ZLIB_IN_MOZGLUE=1
3577   AC_DEFINE(ZLIB_IN_MOZGLUE)
3581 AC_SUBST(ZLIB_IN_MOZGLUE)
3583 dnl ========================================================
3584 dnl =
3585 dnl = Standalone module options
3586 dnl =
3587 dnl ========================================================
3588 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
3590 dnl Check for GLib.
3591 dnl ========================================================
3593 if test -z "$SKIP_PATH_CHECKS"; then
3594 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
3595     if test "$MOZ_ENABLE_GTK" ; then
3596         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
3597     fi
3601 if test -z "${GLIB_GMODULE_LIBS}" \
3602    -a -n "${GLIB_CONFIG}"\
3603     -a "${GLIB_CONFIG}" != no\
3604 ; then
3605     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
3608 AC_SUBST_LIST(GLIB_GMODULE_LIBS)
3610 if test "$USE_FC_FREETYPE"; then
3611     if test "$COMPILE_ENVIRONMENT"; then
3612         dnl ========================================================
3613         dnl = Check for freetype2 functionality
3614         dnl ========================================================
3615         if test "$_HAVE_FREETYPE2" -a -z "$MOZ_TREE_FREETYPE"; then
3616             _SAVE_LIBS="$LIBS"
3617             _SAVE_CFLAGS="$CFLAGS"
3618             LIBS="$LIBS $FT2_LIBS"
3619             CFLAGS="$CFLAGS $FT2_CFLAGS"
3621             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
3622                 ac_cv_member_FT_Bitmap_Size_y_ppem,
3623                 [AC_TRY_COMPILE([#include <ft2build.h>
3624                                  #include FT_FREETYPE_H],
3625                                 [FT_Bitmap_Size s;
3626                                  if (sizeof s.y_ppem) return 0;
3627                                  return 1],
3628                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
3629                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
3630             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
3631                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
3632             else
3633                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
3634             fi
3635             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
3636                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
3637                                [FT_Bitmap_Size structure includes y_ppem field])
3639             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table)
3641             LIBS="$_SAVE_LIBS"
3642             CFLAGS="$_SAVE_CFLAGS"
3643         fi
3645         _SAVE_CPPFLAGS="$CPPFLAGS"
3646         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
3647         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
3648             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
3649         CPPFLAGS="$_SAVE_CPPFLAGS"
3650     fi
3653 dnl ========================================================
3654 dnl Check if we need the 32-bit Linux SSE2 error dialog
3655 dnl ========================================================
3657 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
3659 dnl ========================================================
3660 dnl Check for pixman and cairo
3661 dnl ========================================================
3663 MOZ_TREE_CAIRO=1
3664 MOZ_ARG_ENABLE_BOOL(system-cairo,
3665 [ --enable-system-cairo  Obsolete: do not use this option],
3666 AC_MSG_ERROR(--enable-system-cairo is not supported),
3667 MOZ_TREE_CAIRO=1 )
3669 MOZ_TREE_PIXMAN=1
3670 MOZ_ARG_ENABLE_BOOL(system-pixman,
3671 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
3672 MOZ_TREE_PIXMAN=,
3673 MOZ_TREE_PIXMAN=force,
3674 MOZ_TREE_PIXMAN=1 )
3676 if test "$MOZ_TREE_PIXMAN"; then
3677     AC_DEFINE(MOZ_TREE_PIXMAN)
3678 else
3679     PKG_CHECK_MODULES(MOZ_PIXMAN, pixman-1 >= 0.19.2)
3682 MOZ_CAIRO_CFLAGS="-I${DIST}/include/cairo"
3683 AC_DEFINE(MOZ_TREE_CAIRO)
3685 if test "$OS_ARCH" = "WINNT"; then
3686     # For now we assume that we will have a uint64_t available through
3687     # one of the above headers or mozstdint.h.
3688     AC_DEFINE(HAVE_UINT64_T)
3691 # Define macros for cairo-features.h
3692 TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
3693 if test "$MOZ_X11"; then
3694     XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
3695     XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
3696     PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
3698 if test "$_HAVE_FREETYPE2"; then
3699     FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
3700     MOZ_ENABLE_CAIRO_FT=1
3701     CAIRO_FT_CFLAGS="$FT2_CFLAGS"
3704 case "$MOZ_WIDGET_TOOLKIT" in
3705   cocoa | uikit)
3706     QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
3707     QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
3708     QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
3709     ;;
3710   windows)
3711     WIN32_D2D_SURFACE_FEATURE="#define CAIRO_HAS_D2D_SURFACE 1"
3712     WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
3713     WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
3714     WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
3715     MOZ_ENABLE_D2D_SURFACE=1
3717     if test "$COMPILE_ENVIRONMENT"; then
3719       dnl D3D10 Layers depend on D2D Surfaces.
3720       if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
3721         MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
3722       fi
3723     fi
3724     ;;
3725 esac
3726 if test "$USE_FC_FREETYPE"; then
3727     FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
3729 AC_SUBST(MOZ_ENABLE_CAIRO_FT)
3730 AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
3731 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
3733 AC_SUBST(PS_SURFACE_FEATURE)
3734 AC_SUBST(SVG_SURFACE_FEATURE)
3735 AC_SUBST(XLIB_SURFACE_FEATURE)
3736 AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
3737 AC_SUBST(QUARTZ_SURFACE_FEATURE)
3738 AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
3739 AC_SUBST(WIN32_SURFACE_FEATURE)
3740 AC_SUBST(OS2_SURFACE_FEATURE)
3741 AC_SUBST(DIRECTFB_SURFACE_FEATURE)
3742 AC_SUBST(FT_FONT_FEATURE)
3743 AC_SUBST(FC_FONT_FEATURE)
3744 AC_SUBST(WIN32_FONT_FEATURE)
3745 AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
3746 AC_SUBST(WIN32_D2D_SURFACE_FEATURE)
3747 AC_SUBST(QUARTZ_FONT_FEATURE)
3748 AC_SUBST(PNG_FUNCTIONS_FEATURE)
3749 AC_SUBST(QT_SURFACE_FEATURE)
3750 AC_SUBST(TEE_SURFACE_FEATURE)
3752 if test "$MOZ_X11"; then
3753     MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
3756 CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
3758 case "$MOZ_WIDGET_TOOLKIT" in
3759 android)
3760     TK_CFLAGS="$MOZ_CAIRO_CFLAGS $MOZ_PIXMAN_CFLAGS"
3761     TK_LIBS="$MOZ_CAIRO_LIBS $MOZ_PIXMAN_LIBS"
3762     ;;
3763 esac
3765 AC_SUBST(MOZ_TREE_CAIRO)
3766 AC_SUBST_LIST(MOZ_CAIRO_CFLAGS)
3767 AC_SUBST_LIST(MOZ_CAIRO_LIBS)
3768 AC_SUBST_LIST(MOZ_CAIRO_OSLIBS)
3769 AC_SUBST(MOZ_TREE_PIXMAN)
3771 BINDGEN_SYSTEM_FLAGS="$_BINDGEN_CFLAGS $NSPR_CFLAGS $NSS_CFLAGS $MOZ_PIXMAN_CFLAGS $MOZ_CAIRO_CFLAGS"
3772 AC_SUBST(BINDGEN_SYSTEM_FLAGS)
3773 BINDGEN_SYSTEM_TOML_FLAGS="$BINDGEN_SYSTEM_FLAGS"
3774 AC_SUBST_TOML_LIST(BINDGEN_SYSTEM_TOML_FLAGS)
3776 dnl ========================================================
3777 dnl disable xul
3778 dnl ========================================================
3779 MOZ_ARG_DISABLE_BOOL(xul,
3780 [  --disable-xul           Disable XUL],
3781     MOZ_XUL= )
3782 if test "$MOZ_XUL"; then
3783   AC_DEFINE(MOZ_XUL)
3784 else
3785   dnl remove extensions that require XUL
3786   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/irc//' -e 's/tasks//'`
3789 AC_SUBST(MOZ_XUL)
3791 dnl ========================================================
3792 dnl necko configuration options
3793 dnl ========================================================
3796 dnl option to disable necko's wifi scanner
3799 if test "$MOZ_WIDGET_TOOLKIT"; then
3801   case "$OS_TARGET" in
3802     Darwin)
3803       if test -z "$MOZ_IOS"; then
3804         NECKO_WIFI=1
3805       fi
3806       ;;
3807     DragonFly|FreeBSD|WINNT)
3808       NECKO_WIFI=1
3809       ;;
3810     Linux)
3811       NECKO_WIFI=1
3812       NECKO_WIFI_DBUS=1
3813       ;;
3814   esac
3818 MOZ_ARG_DISABLE_BOOL(necko-wifi,
3819 [  --disable-necko-wifi    Disable necko wifi scanner],
3820     NECKO_WIFI=,
3821     NECKO_WIFI=1)
3823 if test "$NECKO_WIFI"; then
3824   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
3825     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
3826   fi
3827   AC_DEFINE(NECKO_WIFI)
3828   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
3830 AC_SUBST(NECKO_WIFI)
3831 AC_SUBST(NECKO_WIFI_DBUS)
3834 dnl option to disable cookies
3836 MOZ_ARG_DISABLE_BOOL(cookies,
3837 [  --disable-cookies       Disable cookie support],
3838     NECKO_COOKIES=,
3839     NECKO_COOKIES=1)
3840 AC_SUBST(NECKO_COOKIES)
3841 if test "$NECKO_COOKIES"; then
3842     AC_DEFINE(NECKO_COOKIES)
3843     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
3846 dnl ========================================================
3847 dnl =
3848 dnl = Maintainer debug option (no --enable equivalent)
3849 dnl =
3850 dnl ========================================================
3852 AC_SUBST(AR)
3853 AC_SUBST(AR_FLAGS)
3854 AC_SUBST(AR_EXTRACT)
3855 AC_SUBST(NM)
3856 AC_SUBST_LIST(ASFLAGS)
3857 AC_SUBST(RC)
3858 AC_SUBST(RCFLAGS)
3859 AC_SUBST(WINDRES)
3860 AC_SUBST(IMPLIB)
3861 AC_SUBST(FILTER)
3862 AC_SUBST(MOZ_AUTH_EXTENSION)
3863 AC_SUBST(MOZ_PREF_EXTENSIONS)
3864 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
3865 AC_SUBST(WARNINGS_AS_ERRORS)
3866 AC_SUBST_LIST(WARNINGS_CFLAGS)
3867 AC_SUBST_SET(MOZ_EXTENSIONS)
3868 AC_SUBST(MOZ_TOOLKIT_SEARCH)
3869 AC_SUBST(MOZ_FEEDS)
3871 AC_SUBST(MOZ_UNIVERSALCHARDET)
3872 AC_SUBST(MOZ_SPELLCHECK)
3873 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
3874 AC_SUBST(MOZ_CRASHREPORTER)
3875 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
3876 AC_SUBST(MOZ_STUB_INSTALLER)
3877 AC_SUBST(MOZ_ENABLE_SIGNMAR)
3878 AC_SUBST(MOZ_UPDATER)
3880 AC_SUBST(MOZ_ANGLE_RENDERER)
3881 AC_SUBST(MOZ_D3D_CPU_SUFFIX)
3882 AC_SUBST(MOZ_HAS_WINSDK_WITH_D3D)
3883 AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL)
3884 AC_SUBST(MOZ_D3DCOMPILER_VISTA_DLL_PATH)
3886 AC_SUBST(MOZ_ANDROID_APPLICATION_CLASS)
3887 AC_SUBST(MOZ_ANDROID_BROWSER_INTENT_CLASS)
3888 AC_SUBST(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
3889 AC_SUBST(ENABLE_STRIP)
3890 AC_SUBST(PKG_SKIP_STRIP)
3891 AC_SUBST(STRIP_FLAGS)
3892 AC_SUBST(INCREMENTAL_LINKER)
3894 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
3896 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
3897 AC_SUBST(MOZ_LINKER_EXTRACT)
3899 if test -n "$MOZ_BINARY_EXTENSIONS"; then
3900   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
3903 AC_SUBST(MOZ_REQUIRE_SIGNING)
3904 if test "$MOZ_REQUIRE_SIGNING" = 1; then
3905   AC_DEFINE(MOZ_REQUIRE_SIGNING)
3908 dnl ========================================================
3909 dnl = Mac bundle name prefix
3910 dnl ========================================================
3911 MOZ_ARG_WITH_STRING(macbundlename-prefix,
3912 [  --with-macbundlename-prefix=prefix
3913                           Prefix for MOZ_MACBUNDLE_NAME],
3914 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
3916 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
3917 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
3918   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
3921 if test "$MOZ_DEBUG"; then
3922   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
3923 else
3924   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
3926 AC_SUBST(MOZ_MACBUNDLE_NAME)
3928 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
3929 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
3930 # Otherwise, use MOZ_APP_DISPLAYNAME
3931 if test -z "$MOZ_MACBUNDLE_ID"; then
3932    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
3934 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
3935 if test "$MOZ_DEBUG"; then
3936   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
3939 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
3940 AC_SUBST(MOZ_MACBUNDLE_ID)
3942 dnl ========================================================
3943 dnl = Child Process Name for IPC
3944 dnl ========================================================
3945 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
3946   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
3947 else
3948   # We want to let Android unpack the file at install time, but it only does
3949   # so if the file is named libsomething.so. The lib/ path is also required
3950   # because the unpacked file will be under the lib/ subdirectory and will
3951   # need to be executed from that path.
3952   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
3954 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
3955 MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
3957 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
3958 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
3959 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
3961 # The following variables are available to branding and application
3962 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
3963 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
3964 # impacts profile location and user-visible fields.
3965 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
3966 # versions of a given application (e.g. Aurora and Firefox both use
3967 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
3968 # for application.ini's "Name" field, which controls profile location in
3969 # the absence of a "Profile" field (see below), and various system
3970 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
3971 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
3972 # Mac Bundle name, Updater, Installer), it is typically used for nightly
3973 # builds (e.g. Aurora for Firefox).
3974 # - MOZ_APP_VERSION: Defines the application version number.
3975 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
3976 # in the "About" window. If not set, defaults to MOZ_APP_VERSION.
3977 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
3978 # defaults to a lowercase form of MOZ_APP_BASENAME.
3979 # - MOZ_APP_REMOTINGNAME: Used for the internal program name, which affects
3980 # profile name and remoting. If not set, defaults to MOZ_APP_NAME.
3981 # - MOZ_APP_PROFILE: When set, used for application.ini's
3982 # "Profile" field, which controls profile location.
3983 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
3984 # crash reporter server url.
3985 # - MOZ_APP_ANDROID_VERSION_CODE: On Android, "android:versionCode" for
3986 # the main application is set to the value of this variable.  If not
3987 # set, it falls back to a Mozilla-specific value derived from the
3988 # build ID.
3989 # - MOZ_ANDROID_SHARED_ID: On Android, "android:sharedUserId" for all Android
3990 # packages produced.
3991 # - MOZ_ANDROID_GCM_SENDERID: On Android, the Android GCM Sender ID used.  GCM
3992 # sender IDs are not sensitive: see, http://stackoverflow.com/a/18216063.
3993 # - MOZ_MMA_GCM_SENDERID: This GCM Sender ID is used for MMA integration.
3994 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
3996 if test -z "$MOZ_APP_NAME"; then
3997    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
4000 if test -z "$MOZ_APP_REMOTINGNAME"; then
4001    MOZ_APP_REMOTINGNAME=$MOZ_APP_NAME
4004 if test -z "$MOZ_APP_VERSION_DISPLAY"; then
4005    MOZ_APP_VERSION_DISPLAY=$MOZ_APP_VERSION
4008 if test -z "$ANDROID_PACKAGE_NAME" ; then
4009    # When we got rid of the Aurora channel we decided to replace the old
4010    # Nightly ANDROID_PACKAGE_NAME with Aurora. To make sure this is inherited
4011    # by all mozilla-central based branches we make this the new "default"
4012    # for Fennec. Non mozilla-central based branches set ANDROID_PACKAGE_NAME
4013    # in their mozconfig, so they will never get this. If there are ever
4014    # non-Fennec builds for Android, they will fall into the else block
4015    # and use their own default name.
4016    # https://bugzilla.mozilla.org/show_bug.cgi?id=1357808 has additional
4017    # background on this.
4018    if test "$MOZ_APP_NAME" = "fennec"; then
4019       ANDROID_PACKAGE_NAME="org.mozilla.fennec_aurora"
4020    else
4021       ANDROID_PACKAGE_NAME="org.mozilla.$MOZ_APP_NAME"
4022    fi
4025 # Mozilla released Firefox for Android {Release,Beta} and {Aurora,Nightly} to
4026 # the public with specific common shared IDs and we need to keep them
4027 # consistent forever.  The specific common values are set by per-channel
4028 # branding; all other channels use a generic sharedID, set below.
4029 if test -z "$MOZ_ANDROID_SHARED_ID" ; then
4030    MOZ_ANDROID_SHARED_ID="${ANDROID_PACKAGE_NAME}.sharedID"
4033 # For extensions and langpacks, we require a max version that is compatible
4034 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
4035 # 24.0a1 and 24.0a2 aren't affected
4036 # 24.0 becomes 24.*
4037 # 24.1.1 becomes 24.*
4038 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
4039 if test -z "$IS_ALPHA"; then
4040   changequote(,)
4041   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
4042     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
4043   else
4044     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
4045   fi
4046   changequote([,])
4047 else
4048   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
4051 AC_SUBST(MOZ_APP_NAME)
4052 AC_SUBST(MOZ_APP_REMOTINGNAME)
4053 AC_SUBST(MOZ_APP_DISPLAYNAME)
4054 AC_SUBST(MOZ_APP_BASENAME)
4055 AC_SUBST(MOZ_APP_VENDOR)
4056 AC_SUBST(MOZ_APP_PROFILE)
4057 AC_SUBST(MOZ_APP_ID)
4058 AC_SUBST(MOZ_APP_ANDROID_VERSION_CODE)
4059 AC_SUBST(MOZ_ANDROID_SHARED_ID)
4060 AC_SUBST(MOZ_ANDROID_GCM_SENDERID)
4061 AC_SUBST(MOZ_MMA_GCM_SENDERID)
4062 AC_SUBST(MAR_CHANNEL_ID)
4063 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
4064 AC_SUBST(MOZ_PROFILE_MIGRATOR)
4065 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
4066 AC_SUBST(MOZ_APP_UA_NAME)
4067 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
4068 AC_SUBST(MOZ_APP_VERSION)
4069 AC_SUBST(MOZ_APP_VERSION_DISPLAY)
4070 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
4071 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
4073 AC_SUBST(MOZ_APP_MAXVERSION)
4074 AC_DEFINE_UNQUOTED(FIREFOX_VERSION,$FIREFOX_VERSION)
4075 AC_SUBST(FIREFOX_VERSION)
4076 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
4077 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
4078   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
4081 AC_SUBST(MOZ_PKG_SPECIAL)
4082 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
4084 if test "$MOZILLA_OFFICIAL"; then
4085     # Build revisions should always be present in official builds
4086     MOZ_INCLUDE_SOURCE_INFO=1
4089 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
4090 # explicitly set the repository and changeset information in.
4091 AC_SUBST(MOZ_SOURCE_REPO)
4092 AC_SUBST(MOZ_SOURCE_CHANGESET)
4093 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
4095 if test "$MOZ_TELEMETRY_REPORTING"; then
4096     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
4098     # Enable Telemetry by default for nightly and aurora channels
4099     if test -z "$RELEASE_OR_BETA"; then
4100       AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
4101     fi
4104 dnl If we have any service that uploads data (and requires data submission
4105 dnl policy alert), set MOZ_DATA_REPORTING.
4106 dnl We need SUBST for build system and DEFINE for xul preprocessor.
4107 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"; then
4108   MOZ_DATA_REPORTING=1
4109   AC_DEFINE(MOZ_DATA_REPORTING)
4110   AC_SUBST(MOZ_DATA_REPORTING)
4113 dnl win32 options
4114 AC_SUBST(WIN32_REDIST_DIR)
4115 AC_SUBST(WIN_UCRT_REDIST_DIR)
4116 AC_SUBST(WIN_DIA_SDK_BIN_DIR)
4118 dnl ========================================================
4119 dnl ICU Support
4120 dnl ========================================================
4122 _INTL_API=yes
4124 if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
4125     USE_ICU=1
4128 MOZ_CONFIG_ICU()
4130 dnl Echo the CFLAGS to remove extra whitespace.
4131 CFLAGS=`echo \
4132     $_COMPILATION_CFLAGS \
4133     $CFLAGS`
4135 CXXFLAGS=`echo \
4136     $_WARNINGS_CXXFLAGS \
4137     $_COMPILATION_CXXFLAGS \
4138     $CXXFLAGS`
4140 COMPILE_CFLAGS=`echo \
4141     $_DEFINES_CFLAGS \
4142     $COMPILE_CFLAGS`
4144 COMPILE_CXXFLAGS=`echo \
4145     $_DEFINES_CXXFLAGS \
4146     $COMPILE_CXXFLAGS`
4148 HOST_CFLAGS=`echo \
4149     $_WARNINGS_HOST_CFLAGS \
4150     $_COMPILATION_HOST_CFLAGS \
4151     $HOST_CFLAGS`
4153 HOST_CXXFLAGS=`echo \
4154     $_WARNINGS_HOST_CXXFLAGS \
4155     $_COMPILATION_HOST_CXXFLAGS \
4156     $HOST_CXXFLAGS`
4158 AC_SUBST(MOZ_SYSTEM_JPEG)
4159 AC_SUBST(MOZ_SYSTEM_PNG)
4161 AC_SUBST_LIST(MOZ_JPEG_CFLAGS)
4162 AC_SUBST_LIST(MOZ_JPEG_LIBS)
4163 AC_SUBST_LIST(MOZ_PNG_CFLAGS)
4164 AC_SUBST_LIST(MOZ_PNG_LIBS)
4166 AC_SUBST(MOZ_SYSTEM_NSPR)
4168 AC_SUBST(MOZ_SYSTEM_NSS)
4170 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
4171 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
4172 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
4173 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
4174 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
4175   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
4176   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
4178 AC_SUBST(HOST_CMFLAGS)
4179 AC_SUBST(HOST_CMMFLAGS)
4180 AC_SUBST(OS_COMPILE_CMFLAGS)
4181 AC_SUBST(OS_COMPILE_CMMFLAGS)
4183 OS_CFLAGS="$CFLAGS"
4184 OS_CXXFLAGS="$CXXFLAGS"
4185 OS_CPPFLAGS="$CPPFLAGS"
4186 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
4187 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
4188 OS_LDFLAGS="$LDFLAGS"
4189 OS_LIBS="$LIBS"
4190 AC_SUBST_LIST(OS_CFLAGS)
4191 AC_SUBST_LIST(OS_CXXFLAGS)
4192 AC_SUBST_LIST(OS_CPPFLAGS)
4193 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
4194 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
4195 AC_SUBST_LIST(OS_LDFLAGS)
4196 AC_SUBST(OS_LIBS)
4198 AC_SUBST(HOST_CC)
4199 AC_SUBST(HOST_CXX)
4200 AC_SUBST_LIST(HOST_CFLAGS)
4201 AC_SUBST_LIST(HOST_CPPFLAGS)
4202 AC_SUBST_LIST(HOST_CXXFLAGS)
4203 AC_SUBST(HOST_LDFLAGS)
4204 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
4205 AC_SUBST(HOST_AR)
4206 AC_SUBST(HOST_AR_FLAGS)
4207 AC_SUBST(HOST_RANLIB)
4208 AC_SUBST(HOST_BIN_SUFFIX)
4210 AC_SUBST(TARGET_XPCOM_ABI)
4211 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
4212 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
4213 AC_SUBST(HAVE_X86_AVX2)
4214 AC_SUBST(HAVE_ALTIVEC)
4216 AC_SUBST_LIST(DSO_CFLAGS)
4217 AC_SUBST_LIST(DSO_PIC_CFLAGS)
4218 AC_SUBST(DSO_LDOPTS)
4219 AC_SUBST(BIN_SUFFIX)
4220 AC_SUBST(USE_N32)
4221 AC_SUBST(CC_VERSION)
4222 AC_SUBST(NS_ENABLE_TSF)
4223 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
4224 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
4226 AC_SUBST(MOZ_FFVPX)
4227 AC_SUBST(MOZ_FFVPX_FLACONLY)
4228 AC_SUBST_LIST(FFVPX_ASFLAGS)
4229 AC_SUBST(VPX_USE_YASM)
4230 AC_SUBST_LIST(VPX_ASFLAGS)
4231 AC_SUBST(VPX_AS_CONVERSION)
4232 AC_SUBST(VPX_X86_ASM)
4233 AC_SUBST(VPX_ARM_ASM)
4234 AC_SUBST(LIBJPEG_TURBO_USE_YASM)
4235 AC_SUBST_LIST(LIBJPEG_TURBO_ASFLAGS)
4236 AC_SUBST(MOZ_LIBAV_FFT)
4237 AC_SUBST_LIST(LIBAV_FFT_ASFLAGS)
4238 AC_SUBST(MOZ_DEVTOOLS)
4240 AC_SUBST(MOZ_PACKAGE_JSSHELL)
4241 AC_SUBST(MOZ_FOLD_LIBS)
4242 AC_SUBST_LIST(MOZ_FOLD_LIBS_FLAGS)
4244 AC_SUBST(DMG_TOOL)
4246 dnl Host JavaScript runtime, if any, to use during cross compiles.
4247 AC_SUBST(JS_BINARY)
4249 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
4251 if test -n "$COMPILE_ENVIRONMENT"; then
4252 AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
4254 dnl Check for missing components
4255 if test "$MOZ_X11"; then
4256     dnl ====================================================
4257     dnl = Check if X headers exist
4258     dnl ====================================================
4259     _SAVE_CFLAGS=$CFLAGS
4260     CFLAGS="$CFLAGS $XCFLAGS"
4261     AC_TRY_COMPILE([
4262         #include <stdio.h>
4263         #include <stdlib.h>
4264         #include <X11/Xlib.h>
4265         #include <X11/Intrinsic.h>
4266         #include <X11/extensions/XShm.h>
4267     ],
4268     [
4269         Display *dpy = 0;
4270         if ((dpy = XOpenDisplay(NULL)) == NULL) {
4271             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
4272             exit(1);
4273         }
4274     ], [],
4275     [ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
4276     CFLAGS="$_SAVE_CFLAGS"
4278     if test -n "$MISSING_X"; then
4279         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
4280     fi
4282 fi # MOZ_X11
4284 fi # COMPILE_ENVIRONMENT
4286 dnl Set various defines and substitutions
4287 dnl ========================================================
4289 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
4290     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
4291     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
4292     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
4293     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
4294     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
4295     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
4296     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
4297     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
4300 AC_SUBST(MOZ_DEV_EDITION)
4301 if test -n "$MOZ_DEV_EDITION"; then
4302     AC_DEFINE(MOZ_DEV_EDITION)
4305 if test "$MOZ_DEBUG" -o "$DEVELOPER_OPTIONS"; then
4306     A11Y_LOG=1
4308 AC_SUBST(A11Y_LOG)
4309 if test -n "$A11Y_LOG"; then
4310     AC_DEFINE(A11Y_LOG)
4313 dnl Spit out some output
4314 dnl ========================================================
4316 dnl The following defines are used by xpcom
4317 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
4318 CPP_THROW_NEW
4319 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
4320 HAVE_GETPAGESIZE
4321 HAVE_STATVFS64
4322 HAVE_STATVFS
4323 HAVE_STATFS64
4324 HAVE_STATFS
4325 HAVE_SYS_STATVFS_H
4326 HAVE_SYS_STATFS_H
4327 HAVE_SYS_VFS_H
4328 HAVE_SYS_MOUNT_H
4331 # Avoid using obsolete NSPR features
4332 AC_DEFINE(NO_NSPR_10_SUPPORT)
4334 # Don't build NSS libpkix
4335 NSS_DISABLE_LIBPKIX=1
4336 AC_SUBST(NSS_DISABLE_LIBPKIX)
4338 MOZ_CREATE_CONFIG_STATUS()
4340 if test -z "$direct_nspr_config"; then
4341     dnl ========================================================
4342     dnl = Setup a nice relatively clean build environment for
4343     dnl = sub-configures.
4344     dnl ========================================================
4345     CC="$_SUBDIR_CC"
4346     CXX="$_SUBDIR_CXX"
4347     CFLAGS="$_SUBDIR_CFLAGS"
4348     CPPFLAGS="$_SUBDIR_CPPFLAGS"
4349     CXXFLAGS="$_SUBDIR_CXXFLAGS"
4350     LDFLAGS="$_SUBDIR_LDFLAGS"
4351     HOST_CC="$_SUBDIR_HOST_CC"
4352     HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
4353     HOST_CXXFLAGS="$_SUBDIR_HOST_CXXFLAGS"
4354     HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
4355     RC=
4358 unset MAKEFILES
4359 unset CONFIG_FILES
4361 # Run all configure scripts specified by a subconfigure
4362 if test -n "$_subconfigure_subdir"; then
4363   _save_srcdir="$srcdir"
4364   srcdir="$srcdir/.."
4365   _save_ac_configure_args="$ac_configure_args"
4366   ac_configure_args="$_subconfigure_config_args"
4367   AC_OUTPUT_SUBDIRS_NOW("$_subconfigure_subdir",$cache_file)
4368   ac_configure_args="$_save_ac_configure_args"
4369   srcdir="$_save_srcdir"
4372 if test "$COMPILE_ENVIRONMENT" -a "$MOZ_WIDGET_TOOLKIT"; then
4375 dnl ========================================================
4376 dnl = Setup a nice relatively clean build environment for
4377 dnl = sub-configures.
4378 dnl ========================================================
4379 CC="$_SUBDIR_CC"
4380 CXX="$_SUBDIR_CXX"
4381 CFLAGS="$_SUBDIR_CFLAGS"
4382 CPPFLAGS="$_SUBDIR_CPPFLAGS"
4383 CXXFLAGS="$_SUBDIR_CXXFLAGS"
4384 LDFLAGS="$_SUBDIR_LDFLAGS"
4385 HOST_CC="$_SUBDIR_HOST_CC"
4386 HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
4387 HOST_CXXFLAGS="$_SUBDIR_HOST_CXXFLAGS"
4388 HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
4391 # Run the SpiderMonkey 'configure' script.
4392 dist=$MOZ_BUILD_ROOT/dist
4393 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
4395 # --with-system-nspr will have been converted into the relevant $NSPR_CFLAGS
4396 # and $NSPR_LIBS.
4397 ac_configure_args="`echo $ac_configure_args | sed -e 's/--with-system-nspr\S* *//'`"
4399 if test "$_INTL_API" = no; then
4400     ac_configure_args="$ac_configure_args --without-intl-api"
4403 if test -n "$NSPR_CFLAGS" -o -n "$NSPR_LIBS"; then
4404     ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'"
4405     ac_configure_args="$ac_configure_args --with-nspr-libs='$NSPR_LIBS'"
4407 ac_configure_args="$ac_configure_args --prefix=$dist"
4408 if test -n "$ZLIB_IN_MOZGLUE"; then
4409    MOZ_ZLIB_LIBS=
4411 export MOZ_SYSTEM_ZLIB
4412 export MOZ_ZLIB_CFLAGS
4413 export MOZ_ZLIB_LIBS
4414 export MOZ_APP_NAME
4415 export MOZ_APP_REMOTINGNAME
4416 export MOZ_DEV_EDITION
4417 export RUSTC
4418 export CARGO
4419 export MOZILLA_CENTRAL_PATH=$_topsrcdir
4420 export STLPORT_CPPFLAGS
4421 export STLPORT_LIBS
4422 unset MOZ_BUILD_APP
4423 export DIST
4424 export MOZ_LINKER
4425 export ZLIB_IN_MOZGLUE
4426 export AR
4427 export RANLIB
4428 export CPP
4429 export CC
4430 export CXX
4431 export ARFLAGS
4432 export CPPFLAGS
4433 export CFLAGS
4434 export CXXFLAGS
4435 export LDFLAGS
4436 export HOST_CC
4437 export HOST_CXX
4438 export HOST_CFLAGS
4439 export HOST_CPPFLAGS
4440 export HOST_CXXFLAGS
4441 export HOST_LDFLAGS
4443 if ! test -e js; then
4444     mkdir js
4447 ac_configure_args="$ac_configure_args JS_STANDALONE="
4448 AC_OUTPUT_SUBDIRS(js/src,$cache_file)
4449 ac_configure_args="$_SUBDIR_CONFIG_ARGS"
4451 fi # COMPILE_ENVIRONMENT
4453 dnl we need to run config.status after js/src subconfigure because we're
4454 dnl traversing its moz.build and we need its config.status for that.
4455 dnl However, writing our own config.status needs to happen before
4456 dnl subconfigures because the setup surrounding subconfigures alters
4457 dnl many AC_SUBSTed variables.
4458 MOZ_RUN_ALL_SUBCONFIGURES()
4460 rm -fr confdefs* $ac_clean_files