Bug 1568151 - Replace `target.getInspector()` by `target.getFront("inspector")`....
[gecko.git] / old-configure.in
blob69fe6cb4157d5fdfa62cb8cec4e0d592a216fdc3
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 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 MOZPNG=10635
49 NSPR_VERSION=4
50 NSPR_MINVER=4.21
51 NSS_VERSION=3
53 dnl Set the minimum version of toolkit libs used by mozilla
54 dnl ========================================================
55 GLIB_VERSION=2.22
56 # 2_26 is the earliest version we can set GLIB_VERSION_MIN_REQUIRED.
57 # The macro won't be used when compiling with earlier versions anyway.
58 GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26
59 CAIRO_VERSION=1.10
60 GTK2_VERSION=2.18.0
61 GTK3_VERSION=3.4.0
62 GDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4
63 W32API_VERSION=3.14
64 STARTUP_NOTIFICATION_VERSION=0.8
65 DBUS_VERSION=0.60
66 SQLITE_VERSION=3.29.0
68 dnl Set various checks
69 dnl ========================================================
70 MISSING_X=
72 dnl Initialize the Pthread test variables early so they can be
73 dnl  overridden by each platform.
74 dnl ========================================================
75 MOZ_USE_PTHREADS=
76 _PTHREAD_LDFLAGS=""
78 LDFLAGS="$LDFLAGS $LINKER_LDFLAGS"
80 if test "$COMPILE_ENVIRONMENT"; then
81     MOZ_ANDROID_NDK
82 fi # COMPILE_ENVIRONMENT
84 case "$target" in
85 *-android*|*-linuxandroid*)
86     ;;
87 *-linux*)
88     AC_PATH_PROG(OBJCOPY,objcopy)
89     ;;
90 esac
92 case "$target" in
93 *-apple-darwin*)
94     MOZ_IOS_SDK
95     ;;
96 esac
98 AC_SUBST(ANDROID_PACKAGE_NAME)
99 AC_SUBST(OBJCOPY)
101 dnl ========================================================
102 dnl Checks for compilers.
103 dnl ========================================================
105 if test "$COMPILE_ENVIRONMENT"; then
107 if test "$target" != "$host"; then
108     MOZ_CROSS_COMPILER
109 else
110     AC_PROG_CC
111     case "$target" in
112     *-mingw*)
113       # Work around the conftest.exe access problem on Windows
114       sleep 2
115     esac
116     AC_PROG_CXX
117     AC_PROG_RANLIB
118     MOZ_PATH_PROGS(AS, $AS as, $CC)
119     AC_CHECK_PROGS(STRIP, strip, :)
120     AC_CHECK_PROGS(OTOOL, otool, :)
123 if test -n "$MOZ_WINCONSOLE"; then
124     AC_DEFINE(MOZ_WINCONSOLE)
127 MOZ_TOOL_VARIABLES
129 dnl ========================================================
130 dnl Special win32 checks
131 dnl ========================================================
133 WINVER=601
135 case "$target" in
136 *-mingw*)
137     if test "$GCC" != "yes"; then
138         # Check to see if we are really running in a msvc environemnt
139         _WIN32_MSVC=1
141         # Make sure compilers are valid
142         CFLAGS="$CFLAGS -nologo"
143         CXXFLAGS="$CXXFLAGS -TP -nologo"
144         AC_LANG_SAVE
145         AC_LANG_C
146         AC_TRY_COMPILE([#include <stdio.h>],
147             [ printf("Hello World\n"); ],,
148             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
150         AC_LANG_CPLUSPLUS
151         AC_TRY_COMPILE([#include <new.h>],
152             [ unsigned *test = new unsigned(42); ],,
153             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
154         AC_LANG_RESTORE
156         changequote(,)
157         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
158         changequote([,])
160         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
161         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
162         AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
164         _CC_SUITE=14
165         MSVC_C_RUNTIME_DLL=vcruntime140.dll
166         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
168         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
169         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
171         if test -n "$WIN_UCRT_REDIST_DIR"; then
172           if test ! -d "$WIN_UCRT_REDIST_DIR"; then
173             AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
174           fi
175           WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && pwd -W`
176         fi
178         AC_SUBST(MSVC_C_RUNTIME_DLL)
179         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
181         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
183         if test -n "$WIN32_REDIST_DIR"; then
184           if test ! -d "$WIN32_REDIST_DIR"; then
185             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
186           fi
187           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd -W`
188         fi
190         # Check linker version, except in lld builds
191         case "$LINKER" in
192         *lld*)
193             ;;
194         *)
195             _LD_FULL_VERSION=`"${LINKER}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
196             _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
197             if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
198                 AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
199             fi
200             ;;
201         esac
203         INCREMENTAL_LINKER=1
205         unset _MSVC_VER_FILTER
207         WRAP_STL_INCLUDES=1
208         STL_FLAGS="-I${DIST}/stl_wrappers"
209         CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
210         CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
211     else
212         # Check w32api version
213         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
214         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
215         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
216         AC_TRY_COMPILE([#include <w32api.h>],
217             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
218                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
219                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
220                 #error "test failed."
221             #endif
222             , [ res=yes ], [ res=no ])
223         AC_MSG_RESULT([$res])
224         if test "$res" != "yes"; then
225             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
226         fi
227         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
228         # causing problems with local implementations with the same name.
229         AC_DEFINE(STRSAFE_NO_DEPRECATE)
230     fi # !GNU_CC
232     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
233     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
234     # Require OS features provided by IE 8.0 (Win7)
235     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
237     ;;
238 esac
240 if test -n "$_WIN32_MSVC"; then
241     SKIP_PATH_CHECKS=1
242     SKIP_COMPILER_CHECKS=1
243     SKIP_LIBRARY_CHECKS=1
245     # Since we're skipping compiler and library checks, hard-code
246     # some facts here.
247     AC_DEFINE(HAVE_IO_H)
248     AC_DEFINE(HAVE_ISATTY)
251 fi # COMPILE_ENVIRONMENT
253 AC_SUBST(GNU_CC)
254 AC_SUBST(GNU_CXX)
256 AC_SUBST_LIST(STL_FLAGS)
257 AC_SUBST(WRAP_STL_INCLUDES)
259 dnl ========================================================
260 dnl Checks for programs.
261 dnl ========================================================
262 if test "$COMPILE_ENVIRONMENT"; then
264 AC_PATH_XTRA
266 XCFLAGS="$X_CFLAGS"
268 fi # COMPILE_ENVIRONMENT
270 dnl ========================================================
271 dnl set the defaults first
272 dnl ========================================================
273 MOZ_USER_DIR=".mozilla"
275 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
277 MOZ_FS_LAYOUT=unix
279 dnl Configure platform-specific CPU architecture compiler options.
280 dnl ==============================================================
281 if test "$COMPILE_ENVIRONMENT"; then
282     MOZ_ARCH_OPTS
283 fi # COMPILE_ENVIRONMENT
285 dnl ========================================================
286 dnl Android libstdc++
287 dnl ========================================================
289 MOZ_ANDROID_CPU_ARCH
290 if test "$COMPILE_ENVIRONMENT"; then
291     MOZ_ANDROID_STLPORT
292 fi # COMPILE_ENVIRONMENT
294 dnl ========================================================
295 dnl Suppress Clang Argument Warnings
296 dnl ========================================================
297 WARNINGS_CFLAGS="$_WARNINGS_CFLAGS"
298 if test -n "${CLANG_CC}${CLANG_CL}"; then
299     WARNINGS_CFLAGS="-Qunused-arguments $WARNINGS_CFLAGS"
300     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
302 if test -n "${CLANG_CXX}${CLANG_CL}"; then
303     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
306 if test -n "$COMPILE_ENVIRONMENT"; then
307    MOZ_CONFIG_SANITIZE
310 dnl ========================================================
311 dnl Add optional and non-optional hardening flags
312 dnl ========================================================
314 CFLAGS="$CFLAGS $MOZ_HARDENING_CFLAGS"
315 CPPFLAGS="$CPPFLAGS $MOZ_HARDENING_CFLAGS"
316 CXXFLAGS="$CXXFLAGS $MOZ_HARDENING_CFLAGS"
317 LDFLAGS="$LDFLAGS $MOZ_HARDENING_LDFLAGS"
319 dnl ========================================================
320 dnl GNU specific defaults
321 dnl ========================================================
322 if test "$GNU_CC"; then
323     MMX_FLAGS="-mmmx"
324     SSE_FLAGS="-msse"
325     SSE2_FLAGS="-msse2"
326     SSSE3_FLAGS="-mssse3"
327     # FIXME: Let us build with strict aliasing. bug 414641.
328     CFLAGS="$CFLAGS -fno-strict-aliasing"
329     WARNINGS_AS_ERRORS='-Werror'
330     DSO_CFLAGS=''
332     if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
333         DSO_PIC_CFLAGS='-fPIC'
334         ASFLAGS="$ASFLAGS -fPIC"
335     fi
337     AC_MSG_CHECKING([for --noexecstack option to as])
338     _SAVE_CFLAGS=$CFLAGS
339     CFLAGS="$CFLAGS -Wa,--noexecstack"
340     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
341                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
342                      AC_MSG_RESULT([no]))
343     CFLAGS=$_SAVE_CFLAGS
344     AC_MSG_CHECKING([for -z noexecstack option to ld])
345     _SAVE_LDFLAGS=$LDFLAGS
346     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
347     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
348                   AC_MSG_RESULT([no])
349                   LDFLAGS=$_SAVE_LDFLAGS)
351     AC_MSG_CHECKING([for -z text option to ld])
352     _SAVE_LDFLAGS=$LDFLAGS
353     LDFLAGS="$LDFLAGS -Wl,-z,text"
354     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
355                   AC_MSG_RESULT([no])
356                   LDFLAGS=$_SAVE_LDFLAGS)
358     AC_MSG_CHECKING([for -z relro option to ld])
359     _SAVE_LDFLAGS=$LDFLAGS
360     LDFLAGS="$LDFLAGS -Wl,-z,relro"
361     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
362                   AC_MSG_RESULT([no])
363                   LDFLAGS=$_SAVE_LDFLAGS)
365     AC_MSG_CHECKING([for -z nocopyreloc option to ld])
366     _SAVE_LDFLAGS=$LDFLAGS
367     LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
368     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
369                   AC_MSG_RESULT([no])
370                   LDFLAGS=$_SAVE_LDFLAGS)
372     AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
373     _SAVE_LDFLAGS=$LDFLAGS
374     LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
375     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
376                   AC_MSG_RESULT([no])
377                   LDFLAGS=$_SAVE_LDFLAGS)
379     AC_MSG_CHECKING([for --build-id=sha1 option to ld])
380     _SAVE_LDFLAGS=$LDFLAGS
381     LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
382     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
383                   AC_MSG_RESULT([no])
384                   LDFLAGS=$_SAVE_LDFLAGS)
386     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
387     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
388     _SAVE_LDFLAGS=$LDFLAGS
389     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
390     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
391                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
392                   AC_MSG_RESULT([no]))
393     LDFLAGS=$_SAVE_LDFLAGS
395     # Check for -mssse3 on $CC
396     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
397     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
398     _SAVE_CFLAGS=$CFLAGS
399     CFLAGS="$CFLAGS -mssse3"
400     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
401                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
402                      AC_MSG_RESULT([no]))
403     CFLAGS=$_SAVE_CFLAGS
405     # Check for -msse4.1 on $CC
406     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
407     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
408     _SAVE_CFLAGS=$CFLAGS
409     CFLAGS="$CFLAGS -msse4.1"
410     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
411                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
412                      AC_MSG_RESULT([no]))
413     CFLAGS=$_SAVE_CFLAGS
415     case "${CPU_ARCH}" in
416     x86 | x86_64)
417       AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
418       AC_TRY_COMPILE([],
419                      [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
420                      result="yes", result="no")
421       AC_MSG_RESULT("$result")
422       if test "$result" = "yes"; then
423           HAVE_X86_AVX2=1
424       fi
425       ;;
427     ppc*)
428       AC_MSG_CHECKING([whether we can enable AltiVec support])
429       HAVE_ALTIVEC=
430       _SAVE_CFLAGS=$CFLAGS
431       CFLAGS="$CFLAGS -maltivec"
432       AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
433                        [HAVE_ALTIVEC=1],
434                        AC_MSG_RESULT([no]))
435       CFLAGS=$_SAVE_CFLAGS
436       ;;
437     esac
439     DSO_LDOPTS='-shared'
440     if test "$GCC_USE_GNU_LD"; then
441         # Some tools like ASan use a runtime library that is only
442         # linked against executables, so we must allow undefined
443         # symbols for shared objects in some cases.
444         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
445             # Don't allow undefined symbols in libraries
446             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
448             # BSDs need `environ' exposed for posix_spawn (bug 753046)
449             case "$OS_TARGET" in
450             DragonFly|FreeBSD|NetBSD|OpenBSD)
451                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
452                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
453                 else
454                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
455                 fi
456                 ;;
457             esac
458         fi
459     fi
461     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
462     _USE_CPP_INCLUDE_FLAG=1
464     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
467 if test "$GNU_CXX"; then
468     # FIXME: Let us build with strict aliasing. bug 414641.
469     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
471     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
472     _USE_CPP_INCLUDE_FLAG=1
475 # For profiling builds keep the symbol information
476 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
477     case "$OS_TARGET" in
478     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
479         STRIP_FLAGS="--strip-debug"
480         ;;
481     esac
484 dnl ========================================================
485 dnl = Enable DMD
486 dnl ========================================================
488 if test "$MOZ_DMD"; then
489     if test "${CPU_ARCH}" = "arm"; then
490         CFLAGS="$CFLAGS -funwind-tables"
491         CXXFLAGS="$CXXFLAGS -funwind-tables"
492     fi
495 dnl ========================================================
496 dnl System overrides of the defaults for host
497 dnl ========================================================
498 case "$host" in
499 *mingw*)
500     if test -n "$_WIN32_MSVC"; then
501         HOST_CFLAGS="$HOST_CFLAGS -nologo"
502     else
503         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
504     fi
505     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
506     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
507     HOST_BIN_SUFFIX=.exe
509     case "${host_cpu}" in
510     i*86)
511         if test -n "$_WIN32_MSVC"; then
512             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
513         fi
514         ;;
515     x86_64)
516         if test -n "$_WIN32_MSVC"; then
517             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
518         fi
519         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
520         ;;
521     esac
522     ;;
524 *-darwin*)
525     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
526     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
527     ;;
529 *-linux*|*-kfreebsd*-gnu|*-gnu*)
530     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
531     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
532     ;;
535     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
536     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
537     ;;
538 esac
540 dnl ========================================================
541 dnl System overrides of the defaults for target
542 dnl ========================================================
544 case "$target" in
545 *-darwin*)
546     MOZ_OPTIMIZE_FLAGS="-O3"
547     CXXFLAGS="$CXXFLAGS -stdlib=libc++"
548     DSO_LDOPTS=''
549     STRIP_FLAGS="$STRIP_FLAGS -x -S"
550     # Ensure that if we're targeting iOS an SDK was provided.
551     AC_CACHE_CHECK(for iOS target,
552                    ac_cv_ios_target,
553                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
554 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
555 #error not iOS
556 #endif],
557                                    [],
558                                    ac_cv_ios_target="yes",
559                                    ac_cv_ios_target="no")])
560     if test "$ac_cv_ios_target" = "yes" -a -z $MOZ_IOS; then
561        AC_MSG_ERROR([targeting iOS but not using an iOS SDK?])
562     fi
563     if test -z "$MOZ_IOS"; then
564         # The ExceptionHandling framework is needed for Objective-C exception
565         # logging code in nsObjCExceptions.h. Currently we only use that in debug
566         # builds.
567         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
568     fi
570     dnl DTrace and -dead_strip don't interact well. See bug 403132.
571     dnl ===================================================================
572     if test "x$enable_dtrace" = "xyes"; then
573         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
574     else
575         dnl check for the presence of the -dead_strip linker flag
576         AC_MSG_CHECKING([for -dead_strip option to ld])
577         _SAVE_LDFLAGS=$LDFLAGS
578         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
579         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
580         if test -n "$_HAVE_DEAD_STRIP" ; then
581             AC_MSG_RESULT([yes])
582             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
583         else
584             AC_MSG_RESULT([no])
585         fi
587         LDFLAGS=$_SAVE_LDFLAGS
588     fi
590     MOZ_FIX_LINK_PATHS="-Wl,-executable_path,${DIST}/bin"
591     ;;
593 *-android*|*-linuxandroid*)
594     AC_DEFINE(NO_PW_GECOS)
596     if test "$COMPILE_ENVIRONMENT"; then
597         MOZ_LINKER=1
598     fi
600     MOZ_GFX_OPTIMIZE_MOBILE=1
601     if test -z "$CLANG_CC"; then
602         MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
603     else
604         # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
605         # -Oz is smaller than -Os on clang.
606         MOZ_OPTIMIZE_FLAGS="-Oz"
607         # Disable the outliner, which causes performance regressions, and is
608         # enabled on some platforms at -Oz.
609         if test -z "$MOZ_LTO"; then
610             DISABLE_OUTLINER="-mno-outline"
611             _SAVE_CFLAGS=$CFLAGS
612             CFLAGS="$CFLAGS $DISABLE_OUTLINER"
613             AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
614             CFLAGS="$_SAVE_CFLAGS"
615         else
616             DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
617             _SAVE_LDFLAGS=$LDFLAGS
618             LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
619             AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
620             LDFLAGS="$_SAVE_LDFLAGS"
621         fi
622     fi
623     ;;
625 *-*linux*)
626     if test "$GNU_CC" -o "$GNU_CXX"; then
627         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
628         if test -n "$MOZ_DEBUG"; then
629             MOZ_OPTIMIZE_FLAGS="-Os"
630         else
631             MOZ_OPTIMIZE_FLAGS="-O2"
632         fi
633         if test -z "$CLANG_CC"; then
634            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
635         fi
636     fi
638     case "${target_cpu}" in
639     alpha*)
640         CFLAGS="$CFLAGS -mieee"
641         CXXFLAGS="$CXXFLAGS -mieee"
642     ;;
643     esac
644     ;;
645 *-mingw*)
646     DSO_CFLAGS=
647     DSO_PIC_CFLAGS=
648     # certain versions of cygwin's makedepend barf on the
649     # #include <string> vs -I./dist/include/string issue so don't use it
650     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
651         CC="$CC -mwindows"
652         CXX="$CXX -mwindows"
653         CPP="$CPP -mwindows"
654         CFLAGS="$CFLAGS -mms-bitfields"
655         CXXFLAGS="$CXXFLAGS -mms-bitfields"
656         DSO_LDOPTS='-shared'
657         # Use temp file for windres (bug 213281)
658         RCFLAGS='-O coff --use-temp-file'
659         # mingw doesn't require kernel32, user32, and advapi32 explicitly
660         LIBS="$LIBS -luuid -lusp10 -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32"
661         MOZ_FIX_LINK_PATHS=
663         MOZ_OPTIMIZE_FLAGS="-O1"
665         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
666         WIN32_GUI_EXE_LDFLAGS=-mwindows
668         if test -z "$CLANG_CC"; then
669             # Use static libgcc and libstdc++
670             LDFLAGS="$LDFLAGS -static"
672             # GCC/binutils can't link to a function if we try to include dllexport function
673             # in the same library as dllimport caller. To work around it, we build NSPR
674             # and NSS with -mnop-fun-dllimport flag. The drawback of this solution is that
675             # function thunks need to be generated for cross-DLL calls.
676             MOZ_FOLD_LIBS_FLAGS="-mnop-fun-dllimport"
677         else
678             # Silence problematic clang warnings
679             CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
680         fi
681     else
682         TARGET_COMPILER_ABI=msvc
683         RANLIB='echo not_ranlib'
684         STRIP='echo not_strip'
685         PKG_SKIP_STRIP=1
686         # aarch64 doesn't support subsystems below 6.02
687         if test "$CPU_ARCH" = "aarch64"; then
688             WIN32_SUBSYSTEM_VERSION=6.02
689         else
690             WIN32_SUBSYSTEM_VERSION=6.01
691         fi
692         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
693         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
694         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
695         _USE_CPP_INCLUDE_FLAG=1
696         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
697         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
698         CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
699         CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
700         if test -z "$CLANG_CL"; then
701             CPPFLAGS="$CPPFLAGS -utf-8"
702         fi
703         if test "$CPU_ARCH" = "x86"; then
704             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
705             dnl more recent, so set that explicitly here unless another
706             dnl target arch has already been set.
707             changequote(,)
708             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
709               CFLAGS="$CFLAGS -arch:SSE2"
710             fi
711             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
712               CXXFLAGS="$CXXFLAGS -arch:SSE2"
713             fi
714             changequote([,])
715             SSE_FLAGS="-arch:SSE"
716             SSE2_FLAGS="-arch:SSE2"
717             dnl MSVC allows the use of intrinsics without any flags
718             dnl and doesn't have a separate arch for SSSE3
719             SSSE3_FLAGS="-arch:SSE2"
720         fi
721         dnl clang-cl requires appropriate flags to enable SSSE3 support
722         dnl on all architectures.
723         if test -n "$CLANG_CL"; then
724             SSSE3_FLAGS="-mssse3"
725         fi
726         dnl VS2013+ supports -Gw for better linker optimizations.
727         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
728         dnl Disabled on ASan because it causes false-positive ODR violations.
729         if test -z "$MOZ_ASAN"; then
730             CFLAGS="$CFLAGS -Gw"
731             CXXFLAGS="$CXXFLAGS -Gw"
732         else
733             # String tail merging doesn't play nice with ASan's ODR checker.
734             LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
735         fi
736         if test -n "$CLANG_CL"; then
737             # XXX We should combine some of these with our generic GCC-style
738             # warning checks.
739             #
740             # Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
741             CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
742             # We use offsetof on non-POD objects all the time.
743             # We also suppress this warning on other platforms.
744             CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
745             # This warns for reasonable things like:
746             #   enum { X = 0xffffffffU };
747             # which is annoying for IDL headers.
748             CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
749             # This warns for cases that would be reached by the Microsoft
750             # #include rules, but also currently warns on cases that would
751             # *also* be reached by standard C++ include rules.  That
752             # behavior doesn't seem useful, so we turn it off.
753             CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
754             # We normally error out on unknown pragmas, but since clang-cl
755             # claims to be MSVC, it would be difficult to add
756             # #if defined(_MSC_VER) && !defined(__clang__) everywhere we
757             # use such pragmas, so just ignore them.
758             CFLAGS="$CFLAGS -Wno-unknown-pragmas"
759             CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
760             # We get errors about various #pragma intrinsic directives from
761             # clang-cl, and we don't need to hear about those.
762             CFLAGS="$CFLAGS -Wno-ignored-pragmas"
763             CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
764             # clang-cl's Intrin.h marks things like _ReadWriteBarrier
765             # as __attribute((__deprecated__)).  This is nice to know,
766             # but since we don't get the equivalent warning from MSVC,
767             # let's just ignore it.
768             CFLAGS="$CFLAGS -Wno-deprecated-declarations"
769             CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
770             # We use a function like:
771             #   __declspec(noreturn) __inline void f() {}
772             # which -Winvalid-noreturn complains about.  Again, MSVC seems
773             # OK with it, so let's silence the warning.
774             CFLAGS="$CFLAGS -Wno-invalid-noreturn"
775             CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
776             # Missing |override| on virtual function declarations isn't
777             # something that MSVC currently warns about.
778             CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
779             # We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
780             # declaration on |operator delete(void*)|.  However, clang-cl
781             # must internally declare |operator delete(void*)| differently,
782             # which causes this warning for virtually every file in the
783             # tree.  clang-cl doesn't support -fno-exceptions or equivalent,
784             # so there doesn't seem to be any way to convince clang-cl to
785             # declare |delete| differently.  Therefore, suppress this
786             # warning.
787             CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
788             # At least one MSVC header and several headers in-tree have
789             # unused typedefs, so turn this on.
790             CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
791             # jemalloc uses __declspec(allocator) as a profiler hint,
792             # which clang-cl doesn't understand.
793             CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
794             # __attribute__((unused)) really means "might be unused" and
795             # we use it to avoid warnings about things that are unused
796             # in some compilation units, but used in many others.  This
797             # warning insists on complaining about the latter case, which
798             # is annoying, and rather noisy.
799             CXXFLAGS="$CXXFLAGS -Wno-used-but-marked-unused"
800         fi
801         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
802         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
803         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib"
804         MOZ_DEBUG_LDFLAGS='-DEBUG'
805         WARNINGS_AS_ERRORS='-WX'
806         # Use a higher optimization level for clang-cl, so we can come closer
807         # to MSVC's performance numbers (see bug 1443590).
808         if test -n "$CLANG_CL"; then
809             MOZ_OPTIMIZE_FLAGS='-O2'
810         else
811             MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
812         fi
813         MOZ_FIX_LINK_PATHS=
814         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
815         if test -z "$DEVELOPER_OPTIONS"; then
816             LDFLAGS="$LDFLAGS -RELEASE"
817         fi
818         RCFLAGS="-nologo"
819         dnl Minimum reqiurement of Gecko is VS2015 or later which supports
820         dnl both SSSE3 and SSE4.1.
821         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
822         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
823         dnl allow AVX2 code from VS2015
824         HAVE_X86_AVX2=1
825     fi
826     AC_DEFINE(WIN32_LEAN_AND_MEAN)
827     dnl See http://support.microsoft.com/kb/143208 to use STL
828     AC_DEFINE(NOMINMAX)
829     BIN_SUFFIX='.exe'
830     MOZ_USER_DIR="Mozilla"
832     case "$host_os" in
833     cygwin*|msvc*|mks*)
834         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.])
835         ;;
836     esac
838     if test -n "$GNU_CC" -a -z "$CLANG_CC"; then
839         CFLAGS="$CFLAGS -fno-keep-inline-dllexport"
840         CXXFLAGS="$CXXFLAGS -fno-keep-inline-dllexport"
841     fi
843     case "$target" in
844     i*86-*)
845         if test -n "$GNU_CC"; then
846             CFLAGS="$CFLAGS -mstackrealign"
847             CXXFLAGS="$CXXFLAGS -mstackrealign"
848             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
849             if test -z "$CLANG_CC"; then
850                 LDFLAGS="$LDFLAGS -Wl,--enable-stdcall-fixup"
851             fi
852         else
853             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
854             LDFLAGS="$LDFLAGS -SAFESEH"
855         fi
857         AC_DEFINE(_X86_)
858         ;;
859     x86_64-*)
860         if test -n "$_WIN32_MSVC"; then
861             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
862         fi
863         AC_DEFINE(_AMD64_)
864         ;;
865     aarch64-*)
866         if test -n "$_WIN32_MSVC"; then
867             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
868         fi
869         AC_DEFINE(_ARM64_)
870         ;;
871     *)
872         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
873         ;;
874     esac
875     ;;
877 *-netbsd*)
878     DSO_CFLAGS=''
879     CFLAGS="$CFLAGS -Dunix"
880     CXXFLAGS="$CXXFLAGS -Dunix"
881     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
882         DSO_PIC_CFLAGS='-fPIC -DPIC'
883         DSO_LDOPTS='-shared'
884         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
885     else
886         DSO_PIC_CFLAGS='-fPIC -DPIC'
887         DSO_LDOPTS='-shared'
888     fi
889     # This will fail on a.out systems prior to 1.5.1_ALPHA.
890     if test "$LIBRUNPATH"; then
891         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
892     fi
893     ;;
895 *-openbsd*)
896     if test -z "$X11BASE"; then
897         X11BASE=/usr/X11R6
898     fi
899     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
900     DSO_CFLAGS=''
901     DSO_PIC_CFLAGS='-fPIC'
902     DSO_LDOPTS='-shared -fPIC'
903     if test "$LIBRUNPATH"; then
904         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
905     fi
906     ;;
908 *-solaris*)
909     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
910     ;;
912 esac
914 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
915     MOZ_OPTIMIZE_FLAGS="-O"
918 AC_SUBST_LIST(MMX_FLAGS)
919 AC_SUBST_LIST(SSE_FLAGS)
920 AC_SUBST_LIST(SSE2_FLAGS)
921 AC_SUBST_LIST(SSSE3_FLAGS)
923 AC_SUBST(MOZ_LINKER)
924 if test -n "$MOZ_LINKER"; then
925   AC_DEFINE(MOZ_LINKER)
926   MOZ_LINKER_EXTRACT=1
927   AC_CHECK_PROGS(XZ, xz)
930 if test -z "$COMPILE_ENVIRONMENT"; then
931     SKIP_COMPILER_CHECKS=1
932     SKIP_LIBRARY_CHECKS=1
933     PKG_SKIP_STRIP=1
934     MOZ_DEBUGGING_OPTS
935 else
936     MOZ_COMPILER_OPTS
937 fi # COMPILE_ENVIRONMENT
939 if test -z "$SKIP_COMPILER_CHECKS"; then
940 dnl Checks for typedefs, structures, and compiler characteristics.
941 dnl ========================================================
942 AC_C_CONST
943 AC_TYPE_MODE_T
944 AC_TYPE_OFF_T
945 AC_TYPE_PID_T
946 AC_TYPE_SIZE_T
947 AC_LANG_CPLUSPLUS
948 AC_LANG_C
950 AC_LANG_CPLUSPLUS
952 MOZ_CXX11
954 AC_LANG_C
956 case "${OS_TARGET}" in
957 Darwin)
958   ;;
960   STL_FLAGS="-I${DIST}/stl_wrappers"
961   WRAP_STL_INCLUDES=1
962   ;;
963 esac
965 if test "$MOZ_BUILD_APP" = "tools/crashreporter"; then
966     WRAP_STL_INCLUDES=
969 dnl Checks for header files.
970 dnl ========================================================
971 AC_HEADER_DIRENT
972 case "$target_os" in
973 bitrig*|dragonfly*|freebsd*|openbsd*)
974 # for stuff like -lXshm
975     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
976     ;;
977 esac
979 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
980 AC_CACHE_CHECK(for sockaddr_in.sin_len,
981                    ac_cv_sockaddr_in_sin_len,
982                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
983                                     #include <sys/types.h>
984                                     #endif
985                                     #include <netinet/in.h>
986                                     struct sockaddr_in x;
987                                     void *foo = (void*) &x.sin_len;],
988                                    [],
989                                    [ac_cv_sockaddr_in_sin_len=true],
990                                    [ac_cv_sockaddr_in_sin_len=false])])
991 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
992   AC_DEFINE(HAVE_SIN_LEN)
993 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
994   AC_DEFINE(HAVE_SCONN_LEN)
997 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
998                ac_cv_sockaddr_in6_sin6_len,
999                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
1000                                 #include <sys/types.h>
1001                                 #endif
1002                                 #include <netinet/in.h>
1003                                 struct sockaddr_in6 x;
1004                                 void *foo = (void*) &x.sin6_len;],
1005                                [],
1006                                [ac_cv_sockaddr_in6_sin6_len=true],
1007                                [ac_cv_sockaddr_in6_sin6_len=false])])
1008 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
1009   AC_DEFINE(HAVE_SIN6_LEN)
1012 AC_CACHE_CHECK(for sockaddr.sa_len,
1013                ac_cv_sockaddr_sa_len,
1014                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
1015                                 #include <sys/types.h>
1016                                 #endif
1017                                 #include <sys/socket.h>
1018                                 struct sockaddr x;
1019                                 void *foo = (void*) &x.sa_len;],
1020                                [],
1021                                [ac_cv_sockaddr_sa_len=true],
1022                                [ac_cv_sockaddr_sa_len=false])])
1023 if test "$ac_cv_sockaddr_sa_len" = true ; then
1024   AC_DEFINE(HAVE_SA_LEN)
1027 MOZ_ARG_ENABLE_BOOL(dtrace,
1028               [  --enable-dtrace         build with dtrace support if available (default=no)],
1029               [enable_dtrace="yes"],)
1030 if test "x$enable_dtrace" = "xyes"; then
1031   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
1032   if test -n "$HAVE_DTRACE"; then
1033       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
1034   else
1035       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
1036   fi
1038 AC_SUBST(HAVE_DTRACE)
1040 dnl Checks for libraries.
1041 dnl ========================================================
1042 AC_CHECK_LIB(c_r, gethostbyname_r)
1044 dnl We don't want to link with libdl even if it's present on OS X, since
1045 dnl it's not used and not part of the default installation. OS/2 has dlfcn
1046 dnl in libc.
1047 dnl We don't want to link against libm or libpthread on Darwin since
1048 dnl they both are just symlinks to libSystem and explicitly linking
1049 dnl against libSystem causes issues when debugging (see bug 299601).
1050 case $target in
1051 *-darwin*)
1052     ;;
1054     AC_SEARCH_LIBS(dlopen, dl,
1055         MOZ_CHECK_HEADER(dlfcn.h,
1056         AC_DEFINE(HAVE_DLOPEN)))
1057     ;;
1058 esac
1060 _SAVE_CFLAGS="$CFLAGS"
1061 CFLAGS="$CFLAGS -D_GNU_SOURCE"
1062 AC_CHECK_FUNCS(dladdr memmem)
1063 CFLAGS="$_SAVE_CFLAGS"
1065 if test ! "$GNU_CXX"; then
1066     AC_CHECK_LIB(C, demangle)
1069 AC_CHECK_LIB(socket, socket)
1071 XLDFLAGS="$X_LIBS"
1072 XLIBS="$X_EXTRA_LIBS"
1074 dnl ========================================================
1075 dnl Checks for X libraries.
1076 dnl Ordering is important.
1077 dnl Xt is dependent upon SM as of X11R6
1078 dnl ========================================================
1079 if test -n "$MOZ_X11"; then
1080     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
1081     _SAVE_LDFLAGS="$LDFLAGS"
1082     _SAVE_LIBS="$LIBS"
1083     LDFLAGS="$XLDFLAGS $LDFLAGS"
1084     AC_CHECK_LIB(X11, XDrawLines, [XLIBS="-lX11 $XLIBS"],
1085         [MISSING_X="$MISSING_X -lX11"], $XLIBS)
1086     AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
1087         [MISSING_X="$MISSING_X -lXext"], $XLIBS)
1089     AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
1090         unset ac_cv_lib_Xt_XtFree
1091         AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
1092         AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
1093         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
1094             [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
1095         ])
1097     dnl ========================================================
1098     dnl = Check for xcb
1099     dnl ========================================================
1100     AC_CHECK_LIB(xcb, xcb_connect, [XLIBS="-lxcb $XLIBS"],
1101         [MISSING_X="$MISSING_X -lxcb"], $XLIBS)
1102     AC_CHECK_LIB(xcb-shm, xcb_shm_query_version, [XLIBS="-lxcb-shm $XLIBS"],
1103         [MISSING_X="$MISSING_X -lxcb-shm"], $XLIBS)
1104     AC_CHECK_LIB(X11-xcb, XGetXCBConnection, [XLIBS="-lX11-xcb $XLIBS"],
1105         [MISSING_X="$MISSING_X -lX11-xcb"], $XLIBS)
1107     LDFLAGS="$_SAVE_LDFLAGS"
1108     LIBS="$_SAVE_LIBS"
1109 fi # $MOZ_X11
1111 AC_SUBST_LIST(XCFLAGS)
1112 AC_SUBST_LIST(XLDFLAGS)
1113 AC_SUBST_LIST(XLIBS)
1114 AC_SUBST_LIST(XEXT_LIBS)
1115 AC_SUBST_LIST(XT_LIBS)
1117 dnl ========================================================
1118 dnl = pthread support
1119 dnl = Start by checking whether the system support pthreads
1120 dnl ========================================================
1121 case "$target_os" in
1122 darwin*)
1123     MOZ_USE_PTHREADS=1
1124     ;;
1126     AC_CHECK_LIB(pthreads, pthread_create,
1127         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
1128         AC_CHECK_LIB(pthread, pthread_create,
1129             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
1130             AC_CHECK_LIB(c_r, pthread_create,
1131                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
1132                 AC_CHECK_LIB(c, pthread_create,
1133                     MOZ_USE_PTHREADS=1
1134                 )
1135             )
1136         )
1137     )
1138     ;;
1139 esac
1141 dnl ========================================================
1142 dnl Do the platform specific pthread hackery
1143 dnl ========================================================
1144 if test "$MOZ_USE_PTHREADS"x != x
1145 then
1146     dnl
1147     dnl See if -pthread is supported.
1148     dnl
1149     rm -f conftest*
1150     ac_cv_have_dash_pthread=no
1151     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
1152     echo 'int main() { return 0; }' | cat > conftest.c
1153     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
1154     if test $? -eq 0; then
1155         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1156             ac_cv_have_dash_pthread=yes
1157             case "$target_os" in
1158             freebsd*)
1159 # Freebsd doesn't use -pthread for compiles, it uses them for linking
1160                 ;;
1161             *)
1162                 CFLAGS="$CFLAGS -pthread"
1163                 CXXFLAGS="$CXXFLAGS -pthread"
1164                 ;;
1165             esac
1166         fi
1167     fi
1168     rm -f conftest*
1169     AC_MSG_RESULT($ac_cv_have_dash_pthread)
1171     dnl
1172     dnl See if -pthreads is supported.
1173     dnl
1174     ac_cv_have_dash_pthreads=no
1175     if test "$ac_cv_have_dash_pthread" = "no"; then
1176         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
1177         echo 'int main() { return 0; }' | cat > conftest.c
1178         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
1179         if test $? -eq 0; then
1180             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1181                 ac_cv_have_dash_pthreads=yes
1182                 CFLAGS="$CFLAGS -pthreads"
1183                 CXXFLAGS="$CXXFLAGS -pthreads"
1184             fi
1185         fi
1186         rm -f conftest*
1187         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
1188     fi
1190     case "$target" in
1191         *-*-freebsd*)
1192             AC_DEFINE(_REENTRANT)
1193             AC_DEFINE(_THREAD_SAFE)
1194             dnl -pthread links in -lpthread, so don't specify it explicitly.
1195             if test "$ac_cv_have_dash_pthread" = "yes"; then
1196                 _PTHREAD_LDFLAGS="-pthread"
1197             fi
1198             ;;
1200         *-*-openbsd*|*-*-bsdi*)
1201             AC_DEFINE(_REENTRANT)
1202             AC_DEFINE(_THREAD_SAFE)
1203             dnl -pthread links in -lc_r, so don't specify it explicitly.
1204             if test "$ac_cv_have_dash_pthread" = "yes"; then
1205                 _PTHREAD_LDFLAGS="-pthread"
1206             fi
1207             ;;
1209         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
1210             AC_DEFINE(_REENTRANT)
1211             ;;
1213     esac
1214     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
1215     AC_SUBST(MOZ_USE_PTHREADS)
1216     MOZ_CHECK_HEADERS(pthread.h)
1220 dnl Checks for library functions.
1221 dnl ========================================================
1222 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall)
1224 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
1225 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
1226                ac_cv_clock_monotonic,
1227                [for libs in "" -lrt; do
1228                     _SAVE_LIBS="$LIBS"
1229                     _SAVE_CFLAGS="$CFLAGS"
1230                     LIBS="$LIBS $libs"
1231                     CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
1232 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
1233 dnl we should or not be able to use it. To detect if we can, we need to make the
1234 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
1235                     AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
1236                                  #include <time.h>],
1237                                  [ struct timespec ts;
1238                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
1239                                  ac_cv_clock_monotonic=$libs
1240                                  LIBS="$_SAVE_LIBS"
1241                                  break,
1242                                  ac_cv_clock_monotonic=no)
1243                     LIBS="$_SAVE_LIBS"
1244                     CFLAGS="$_SAVE_CFLAGS"
1245                 done])
1246 if test "$ac_cv_clock_monotonic" != "no"; then
1247     HAVE_CLOCK_MONOTONIC=1
1248     REALTIME_LIBS=$ac_cv_clock_monotonic
1249     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
1250     AC_SUBST(HAVE_CLOCK_MONOTONIC)
1251     AC_SUBST_LIST(REALTIME_LIBS)
1254 dnl Turn on warnings-as-errors to prevent implicit declaration of
1255 dnl pthread_cond_timedwait_monotonic_np, which can cause this test to
1256 dnl inadvertently pass even if the function does not really exist.
1257 _SAVE_CFLAGS="$CFLAGS"
1258 CFLAGS="$CFLAGS $WARNINGS_AS_ERRORS"
1259 AC_CACHE_CHECK(for pthread_cond_timedwait_monotonic_np,
1260                ac_cv_pthread_cond_timedwait_monotonic_np,
1261                AC_TRY_LINK([#include <pthread.h>],
1262                            [pthread_cond_timedwait_monotonic_np(0, 0, 0);],
1263                            ac_cv_pthread_cond_timewait_monotonic_np=yes,
1264                            ac_cv_pthread_cond_timewait_monotonic_np=no))
1265 if test "$ac_cv_pthread_cond_timewait_monotonic_np" != "no"; then
1266     AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
1268 CFLAGS=$_SAVE_CFLAGS
1270 AC_CACHE_CHECK(
1271     [for res_ninit()],
1272     ac_cv_func_res_ninit,
1273     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
1274         dnl no need for res_ninit() on NetBSD and OpenBSD
1275         ac_cv_func_res_ninit=no
1276      else
1277         AC_TRY_LINK([
1278             #ifdef linux
1279             #define _BSD_SOURCE 1
1280             #endif
1281             #include <sys/types.h>
1282             #include <netinet/in.h>
1283             #include <arpa/nameser.h>
1284             #include <resolv.h>
1285             ],
1286             [int foo = res_ninit(&_res);],
1287             [ac_cv_func_res_ninit=yes],
1288             [ac_cv_func_res_ninit=no])
1289      fi
1290     ])
1292 if test "$ac_cv_func_res_ninit" = "yes"; then
1293     AC_DEFINE(HAVE_RES_NINIT)
1294 dnl must add the link line we do something as foolish as this... dougt
1295 dnl else
1296 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
1297 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
1300 AC_LANG_C
1302 dnl **********************
1303 dnl *** va_copy checks ***
1304 AC_CACHE_CHECK([for an implementation of va_copy()],
1305                ac_cv_va_copy,
1306     [AC_TRY_COMPILE([#include <stdarg.h>
1307                      #include <stdlib.h>
1308         void f (int i, ...) {
1309             va_list args1, args2;
1310             va_start (args1, i);
1311             va_copy (args2, args1);
1312             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1313                 exit (1);
1314             va_end (args1); va_end (args2);
1315         }],
1316         [f(0, 42); return 0],
1317         [ac_cv_va_copy=yes],
1318         [ac_cv_va_copy=no]
1319     )]
1321 AC_CACHE_CHECK([whether va_list can be copied by value],
1322                ac_cv_va_val_copy,
1323     [AC_TRY_COMPILE([#include <stdarg.h>
1324                      #include <stdlib.h>
1325         void f (int i, ...) {
1326             va_list args1, args2;
1327             va_start (args1, i);
1328             args2 = args1;
1329             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1330                 exit (1);
1331             va_end (args1); va_end (args2);
1332         }],
1333         [f(0, 42); return 0],
1334         [ac_cv_va_val_copy=yes],
1335         [ac_cv_va_val_copy=no],
1336     )]
1338 if test "x$ac_cv_va_copy" = "xyes"; then
1339     AC_DEFINE(VA_COPY, va_copy)
1340     AC_DEFINE(HAVE_VA_COPY)
1343 if test "x$ac_cv_va_val_copy" = "xno"; then
1344    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
1347 dnl ===================================================================
1348 dnl ========================================================
1349 dnl Put your C++ language/feature checks below
1350 dnl ========================================================
1351 AC_LANG_CPLUSPLUS
1353 ARM_ABI_PREFIX=
1354 if test "$GNU_CC"; then
1355   if test "$CPU_ARCH" = "arm" ; then
1356     AC_CACHE_CHECK(for ARM EABI,
1357         ac_cv_gcc_arm_eabi,
1358         [AC_TRY_COMPILE([],
1359                         [
1360 #if defined(__ARM_EABI__)
1361   return 0;
1362 #else
1363 #error Not ARM EABI.
1364 #endif
1365                         ],
1366                         ac_cv_gcc_arm_eabi="yes",
1367                         ac_cv_gcc_arm_eabi="no")])
1368     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
1369         HAVE_ARM_EABI=1
1370         ARM_ABI_PREFIX=eabi-
1371     else
1372         ARM_ABI_PREFIX=oabi-
1373     fi
1374   fi
1376   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
1379 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
1380 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
1381 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
1382 # linking XUL.
1383 _SAVE_LDFLAGS=$LDFLAGS
1384 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
1385 AC_CACHE_CHECK(for __thread keyword for TLS variables,
1386                ac_cv_thread_keyword,
1387                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
1388                             [return tlsIsMainThread;],
1389                             ac_cv_thread_keyword=yes,
1390                             ac_cv_thread_keyword=no)])
1391 LDFLAGS=$_SAVE_LDFLAGS
1392 # The custom dynamic linker doesn't support TLS variables
1393 MOZ_TLS=
1394 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
1395   # mips builds fail with TLS variables because of a binutils bug.
1396   # See bug 528687
1397   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
1398   case "${target}" in
1399     mips*-*)
1400       :
1401       ;;
1402     *-android*|*-linuxandroid*)
1403       :
1404       ;;
1405     *-openbsd*)
1406       :
1407       ;;
1408     *)
1409       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
1410       MOZ_TLS=1
1411       ;;
1412   esac
1415 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
1416 if test -n "$MOZ_LINKER"; then
1417   if test "$CPU_ARCH" = arm; then
1418     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
1419     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
1420       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1421       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1422     fi
1423   fi
1425 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
1426 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
1427 dnl Since the linker only understands the sysv ones, no need to build the
1428 dnl gnu style tables anyways.
1429   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
1432 dnl End of C++ language/feature checks
1433 AC_LANG_C
1435 dnl ========================================================
1436 dnl =  Internationalization checks
1437 dnl ========================================================
1439 dnl Internationalization and Locale support is different
1440 dnl on various UNIX platforms.  Checks for specific i18n
1441 dnl features go here.
1443 AC_HAVE_FUNCS(localeconv)
1445 fi # ! SKIP_COMPILER_CHECKS
1447 if test -n "${COMPILE_ENVIRONMENT}"; then
1448   MOZ_CHECK_ALLOCATOR
1451 TARGET_XPCOM_ABI=
1452 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1453     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1454     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
1457 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1458 dnl features that Windows actually does support.
1460 if test -n "$SKIP_COMPILER_CHECKS"; then
1461    dnl Windows has malloc.h
1462    AC_DEFINE(MALLOC_H, [<malloc.h>])
1463    AC_DEFINE(HAVE_FORCEINLINE)
1464    AC_DEFINE(HAVE_LOCALECONV)
1465 fi # SKIP_COMPILER_CHECKS
1467 dnl Mozilla specific options
1468 dnl ========================================================
1469 dnl The macros used for command line options
1470 dnl are defined in build/autoconf/altoptions.m4.
1472 dnl ========================================================
1473 dnl =
1474 dnl = Check for external package dependencies
1475 dnl =
1476 dnl ========================================================
1477 MOZ_ARG_HEADER(External Packages)
1479 case "$OS_TARGET" in
1480 WINNT|Darwin|Android)
1481   MOZ_FOLD_LIBS=1
1482   ;;
1484   MOZ_FOLD_LIBS=
1485   ;;
1486 esac
1488 MOZ_CONFIG_NSPR()
1490 dnl ========================================================
1491 dnl system libevent Support
1492 dnl ========================================================
1493 MOZ_ARG_WITH_STRING(system-libevent,
1494 [  --with-system-libevent[=PFX]
1495                           Use system libevent [installed at prefix PFX]],
1496     LIBEVENT_DIR=$withval)
1498 _SAVE_CFLAGS=$CFLAGS
1499 _SAVE_LDFLAGS=$LDFLAGS
1500 _SAVE_LIBS=$LIBS
1501 if test "$LIBEVENT_DIR" = yes; then
1502     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
1503         MOZ_SYSTEM_LIBEVENT=1,
1504         LIBEVENT_DIR=/usr)
1506 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
1507     MOZ_SYSTEM_LIBEVENT=
1508 elif test -z "$MOZ_SYSTEM_LIBEVENT"; then
1509     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
1510     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
1511     MOZ_CHECK_HEADER(event.h,
1512         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
1513              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
1514          fi],
1515         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
1516     AC_CHECK_LIB(event, event_init,
1517                  [MOZ_SYSTEM_LIBEVENT=1
1518                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
1519                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
1520                  [MOZ_SYSTEM_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
1522 CFLAGS=$_SAVE_CFLAGS
1523 LDFLAGS=$_SAVE_LDFLAGS
1524 LIBS=$_SAVE_LIBS
1526 AC_SUBST(MOZ_SYSTEM_LIBEVENT)
1528 dnl ========================================================
1529 dnl = If NSS was not detected in the system,
1530 dnl = use the one in the source tree (mozilla/security/nss)
1531 dnl ========================================================
1533 MOZ_ARG_WITH_BOOL(system-nss,
1534 [  --with-system-nss       Use system installed NSS],
1535     _USE_SYSTEM_NSS=1 )
1537 if test -n "$_USE_SYSTEM_NSS"; then
1538     AM_PATH_NSS(3.46, [MOZ_SYSTEM_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
1541 NSS_CFLAGS="$NSS_CFLAGS -I${DIST}/include/nss"
1542 if test -z "$MOZ_SYSTEM_NSS"; then
1543    case "${OS_ARCH}" in
1544         # Only few platforms have been tested with GYP
1545         WINNT|Darwin|Linux|DragonFly|FreeBSD|NetBSD|OpenBSD|SunOS)
1546             ;;
1547         *)
1548             AC_MSG_ERROR([building in-tree NSS is not supported on this platform. Use --with-system-nss])
1549             ;;
1550    esac
1553 dnl system ZLIB support
1554 dnl ========================================================
1555 MOZ_ZLIB_CHECK([1.2.3])
1557 if test -z "$SKIP_LIBRARY_CHECKS"; then
1559 dnl ========================================================
1560 dnl system PNG Support
1561 dnl ========================================================
1562 MOZ_ARG_WITH_STRING(system-png,
1563 [  --with-system-png[=PFX]
1564                           Use system libpng [installed at prefix PFX]],
1565     PNG_DIR=$withval)
1567 _SAVE_CFLAGS=$CFLAGS
1568 _SAVE_LDFLAGS=$LDFLAGS
1569 _SAVE_LIBS=$LIBS
1570 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
1571     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
1572     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
1574 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
1575     MOZ_SYSTEM_PNG=
1576 else
1577     AC_CHECK_LIB(png, png_get_valid, [MOZ_SYSTEM_PNG=1 MOZ_PNG_LIBS="-lpng"],
1578                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1579     AC_CHECK_LIB(png, png_get_acTL, ,
1580                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
1582 if test "$MOZ_SYSTEM_PNG" = 1; then
1583     AC_TRY_COMPILE([ #include <stdio.h>
1584                      #include <sys/types.h>
1585                      #include <png.h> ],
1586                    [ #if PNG_LIBPNG_VER < $MOZPNG
1587                      #error "Insufficient libpng version ($MOZPNG required)."
1588                      #endif
1589                      #ifndef PNG_UINT_31_MAX
1590                      #error "Insufficient libpng version."
1591                      #endif ],
1592                    MOZ_SYSTEM_PNG=1,
1593                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1595 CFLAGS=$_SAVE_CFLAGS
1596 LDFLAGS=$_SAVE_LDFLAGS
1597 LIBS=$_SAVE_LIBS
1599 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_SYSTEM_PNG" = 1; then
1600     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
1601     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
1604 fi # SKIP_LIBRARY_CHECKS
1606 dnl ========================================================
1607 dnl =
1608 dnl = Application
1609 dnl =
1610 dnl ========================================================
1612 MOZ_ARG_HEADER(Application)
1614 ENABLE_SYSTEM_EXTENSION_DIRS=1
1615 MOZ_BRANDING_DIRECTORY=
1616 MOZ_OFFICIAL_BRANDING=
1617 MOZ_AUTH_EXTENSION=1
1618 if test "$MOZ_IOS"; then
1619    MOZ_AUTH_EXTENSION=
1621 MOZ_PREF_EXTENSIONS=1
1622 MOZ_SPELLCHECK=1
1623 MOZ_UNIVERSALCHARDET=1
1624 MOZ_XUL=1
1625 MOZ_ZIPWRITER=1
1626 MOZ_NO_SMART_CARDS=
1627 NECKO_COOKIES=1
1628 MOZ_USE_NATIVE_POPUP_WINDOWS=
1629 MOZ_EXCLUDE_HYPHENATION_DICTIONARIES=
1630 MOZ_SANDBOX=1
1631 MOZ_BINARY_EXTENSIONS=
1632 MOZ_DEVTOOLS=server
1634 case "$target_os" in
1635     mingw*)
1636         NS_ENABLE_TSF=1
1637         AC_DEFINE(NS_ENABLE_TSF)
1638         ;;
1639 esac
1641 # Optional Firefox for Android partner distribution directory.
1642 MOZ_ARG_WITH_STRING(android-distribution-directory,
1643 [  --with-android-distribution-directory=dir
1644                           Optional Firefox for Android partner distribution directory.],
1645   MOZ_ANDROID_DISTRIBUTION_DIRECTORY=$withval)
1647 if test -n "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY"; then
1648   # A distribution directory must have an assets/distribution directory.
1649   # See https://wiki.mozilla.org/Mobile/Distribution_Files.
1650   if test ! -d "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY/assets/distribution" ; then
1651     AC_MSG_ERROR([--with-android-distribution-directory does not contain assets/distribution;
1652                   (looked for ${MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets/distribution).])
1653   fi
1655 AC_SUBST(MOZ_ANDROID_DISTRIBUTION_DIRECTORY)
1657 dnl ========================================================
1658 dnl = Trademarked Branding
1659 dnl ========================================================
1660 MOZ_ARG_ENABLE_BOOL(official-branding,
1661 [  --enable-official-branding
1662                           Enable Official mozilla.org Branding
1663                           Do not distribute builds with
1664                           --enable-official-branding unless you have
1665                           permission to use trademarks per
1666                           http://www.mozilla.org/foundation/trademarks/ .],
1667     MOZ_OFFICIAL_BRANDING=1,
1668     MOZ_OFFICIAL_BRANDING=)
1670 # Allow the application to influence configure with a confvars.sh script.
1671 AC_MSG_CHECKING([if app-specific confvars.sh exists])
1672 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
1673   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
1674   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
1675 else
1676   AC_MSG_RESULT([no])
1679 # Allow influencing configure with a defines.sh script.
1680 . "${srcdir}/build/defines.sh"
1682 # If we're not building a release build, define EARLY_BETA_OR_EARLIER if it is
1683 # set in defines.sh
1684 if test "$BUILDING_RELEASE"; then
1685   # Override value in defines.sh, if any
1686   EARLY_BETA_OR_EARLIER=
1687 elif test "$EARLY_BETA_OR_EARLIER"; then
1688   AC_DEFINE(EARLY_BETA_OR_EARLIER)
1690 AC_SUBST(EARLY_BETA_OR_EARLIER)
1692 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
1693 MOZ_ARG_WITH_STRING(app-name,
1694 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
1695 WITH_APP_NAME=$withval,
1698 if test -n "$WITH_APP_NAME" ; then
1699     MOZ_APP_NAME="$WITH_APP_NAME"
1702 MOZ_ARG_WITH_STRING(app-basename,
1703 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
1704 WITH_APP_BASENAME=$withval,
1707 if test -n "$WITH_APP_BASENAME" ; then
1708     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
1711 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
1712 # that haven't made a confvars.sh yet. Don't add new stuff here, use
1713 # MOZ_BUILD_APP.
1714 case "$MOZ_BUILD_APP" in
1715 browser)
1716   AC_DEFINE(MOZ_PHOENIX)
1717   ;;
1718 esac
1720 # Graphene is a desktop runtime for running applications with a HTML UI.
1721 if test -n "$MOZ_GRAPHENE"; then
1722     AC_DEFINE(MOZ_GRAPHENE)
1725 AC_SUBST(MOZ_PHOENIX)
1727 dnl ========================================================
1728 dnl Ensure Android SDK and build-tools versions depending on
1729 dnl mobile target.
1730 dnl ========================================================
1732 case "$MOZ_BUILD_APP" in
1733 mobile/android)
1734     MOZ_ANDROID_SDK
1735     ;;
1736 esac
1738 dnl ========================================================
1739 dnl =
1740 dnl = Toolkit Options
1741 dnl =
1742 dnl ========================================================
1743 MOZ_ARG_HEADER(Toolkit Options)
1745 dnl ========================================================
1746 dnl = Enable the toolkit as needed                         =
1747 dnl ========================================================
1749 case "$MOZ_WIDGET_TOOLKIT" in
1751 cocoa)
1752     LDFLAGS="$LDFLAGS -framework Cocoa"
1753     # Use -Wl as a trick to avoid -framework and framework names from
1754     # being separated by AC_SUBST_LIST.
1755     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'
1756     TK_CFLAGS=""
1757     CFLAGS="$CFLAGS $TK_CFLAGS"
1758     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
1759     MOZ_USER_DIR="Mozilla"
1760     MOZ_FS_LAYOUT=bundle
1761     ;;
1763 uikit)
1764     LDFLAGS="$LDFLAGS -framework UIKit"
1765     TK_CFLAGS=""
1766     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'
1767     CFLAGS="$CFLAGS $TK_CFLAGS"
1768     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
1769     MOZ_USER_DIR="Mozilla"
1770     MOZ_FS_LAYOUT=bundle
1771     ;;
1773 esac
1775 if test "$OS_TARGET" = Darwin; then
1776     LDFLAGS="$LDFLAGS -lobjc"
1779 dnl there are a lot of tests on MOZ_ENABLE_GTK below, that are more convenient
1780 dnl to keep that way than testing against MOZ_WIDGET_TOOLKIT
1781 case "$MOZ_WIDGET_TOOLKIT" in
1782 gtk*)
1783     MOZ_ENABLE_GTK=1
1784     ;;
1785 esac
1787 if test "$COMPILE_ENVIRONMENT"; then
1788   if test "$MOZ_WIDGET_TOOLKIT" = gtk3; then
1789     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)
1790     MOZ_GTK3_CFLAGS="-I${_topsrcdir}/widget/gtk/compat-gtk3 $MOZ_GTK3_CFLAGS"
1791     TK_CFLAGS=$MOZ_GTK3_CFLAGS
1792     TK_LIBS=$MOZ_GTK3_LIBS
1793     dnl GDK_VERSION_MIN_REQUIRED is not set here as GDK3 deprecated warnings
1794     dnl are suppressed by widget/gtk/compat-gtk3/gdk/gdkversionmacros.h.
1795     AC_DEFINE_UNQUOTED(GDK_VERSION_MAX_ALLOWED,$GDK_VERSION_MAX_ALLOWED)
1796     GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32
1797   fi
1798   if test "$MOZ_ENABLE_GTK"; then
1799     if test "$MOZ_X11"; then
1800       GDK_PACKAGES=gdk-x11-2.0
1801     fi
1802     AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
1803     AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)
1805     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)
1806     MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
1807   fi
1808 fi # COMPILE_ENVIRONMENT
1810 AC_SUBST(MOZ_FS_LAYOUT)
1812 dnl ========================================================
1813 dnl = startup-notification support module
1814 dnl ========================================================
1816 if test "$MOZ_ENABLE_GTK"
1817 then
1818     MOZ_ENABLE_STARTUP_NOTIFICATION=
1820     MOZ_ARG_ENABLE_BOOL(startup-notification,
1821     [  --enable-startup-notification
1822                           Enable startup-notification support (default: disabled) ],
1823         MOZ_ENABLE_STARTUP_NOTIFICATION=force,
1824         MOZ_ENABLE_STARTUP_NOTIFICATION=)
1825     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
1826     then
1827         PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
1828                           libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
1829         [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
1830             if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
1831             then
1832                 AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
1833             fi
1834             MOZ_ENABLE_STARTUP_NOTIFICATION=
1835         ])
1836     fi
1838     if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
1839         AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
1840     fi
1842     TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
1844 AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
1846 AC_SUBST_LIST(TK_CFLAGS)
1847 AC_SUBST_LIST(TK_LIBS)
1849 dnl ========================================================
1850 dnl =
1851 dnl = Components & Features
1852 dnl =
1853 dnl ========================================================
1854 MOZ_ARG_HEADER(Components and Features)
1856 AC_SUBST(MOZ_OFFICIAL_BRANDING)
1857 if test -n "$MOZ_OFFICIAL_BRANDING"; then
1858   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
1859     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
1860   else
1861     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
1862     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
1863   fi
1866 MOZ_ARG_WITH_STRING(branding,
1867 [  --with-branding=dir     Use branding from the specified directory.],
1868     MOZ_BRANDING_DIRECTORY=$withval)
1870 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
1871 if test -z "$REAL_BRANDING_DIRECTORY"; then
1872   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
1875 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
1876   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
1877 elif test -f "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
1878   . "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"
1881 AC_SUBST(MOZ_BRANDING_DIRECTORY)
1883 dnl ========================================================
1884 dnl = Distribution ID
1885 dnl ========================================================
1886 MOZ_ARG_WITH_STRING(distribution-id,
1887 [  --with-distribution-id=ID
1888                           Set distribution-specific id (default=org.mozilla)],
1889 [ val=`echo $withval`
1890     MOZ_DISTRIBUTION_ID="$val"])
1892 if test -z "$MOZ_DISTRIBUTION_ID"; then
1893    MOZ_DISTRIBUTION_ID="org.mozilla"
1896 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
1897 AC_SUBST(MOZ_DISTRIBUTION_ID)
1899 dnl ========================================================
1900 dnl = libproxy support
1901 dnl ========================================================
1903 if test "$MOZ_ENABLE_GTK"
1904 then
1905     MOZ_ENABLE_LIBPROXY=
1907     MOZ_ARG_ENABLE_BOOL(libproxy,
1908     [  --enable-libproxy         Enable libproxy support ],
1909     MOZ_ENABLE_LIBPROXY=1,
1910     MOZ_ENABLE_LIBPROXY=)
1912     if test "$MOZ_ENABLE_LIBPROXY"
1913     then
1914         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
1915         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
1916     fi
1918 AC_SUBST(MOZ_ENABLE_LIBPROXY)
1920 dnl ========================================================
1921 dnl = dbus support
1922 dnl ========================================================
1924 if test "$MOZ_ENABLE_GTK"
1925 then
1926     MOZ_ENABLE_DBUS=1
1928     MOZ_ARG_DISABLE_BOOL(dbus,
1929     [  --disable-dbus          Disable dbus support ],
1930         MOZ_ENABLE_DBUS=,
1931         MOZ_ENABLE_DBUS=1)
1933     if test "$MOZ_ENABLE_DBUS"
1934     then
1935         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
1936         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
1937         AC_DEFINE(MOZ_ENABLE_DBUS)
1938     fi
1940 AC_SUBST(MOZ_ENABLE_DBUS)
1942 dnl =========================================================
1943 dnl = Whether to exclude hyphenations files in the build
1944 dnl =========================================================
1945 if test -n "$MOZ_EXCLUDE_HYPHENATION_DICTIONARIES"; then
1946     AC_DEFINE(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
1949 AC_TRY_COMPILE([#include <linux/ethtool.h>],
1950                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
1951                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
1953 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
1955 if test -n "$MOZ_WEBRTC"; then
1956     if test -n "$MOZ_X11"; then
1957       MOZ_WEBRTC_X11_LIBS="-lXext -lXdamage -lXfixes -lXcomposite"
1958     fi
1961 AC_SUBST_LIST(MOZ_WEBRTC_X11_LIBS)
1963 dnl ========================================================
1964 dnl = Apple platform decoder support
1965 dnl ========================================================
1966 if test "$COMPILE_ENVIRONMENT"; then
1967 if test -n "$MOZ_APPLEMEDIA"; then
1968   # hack in frameworks for fmp4 - see bug 1029974
1969   # We load VideoToolbox and CoreMedia dynamically, so they don't appear here.
1970   LDFLAGS="$LDFLAGS -framework AudioToolbox"
1971   dnl Verify CoreMedia is available.
1972   AC_CHECK_HEADERS([CoreMedia/CoreMedia.h VideoToolbox/VideoToolbox.h], [],
1973     [AC_MSG_ERROR([MacOS X 10.9 SDK or later is required])])
1975 fi # COMPILE_ENVIRONMENT
1977 dnl ========================================================
1978 dnl = Handle dependent MEDIA defines
1979 dnl ========================================================
1981 MOZ_WEBM_ENCODER=1
1982 AC_DEFINE(MOZ_WEBM_ENCODER)
1983 AC_SUBST(MOZ_WEBM_ENCODER)
1985 dnl ========================================================
1986 dnl NegotiateAuth
1987 dnl ========================================================
1989 MOZ_ARG_DISABLE_BOOL(negotiateauth,
1990 [  --disable-negotiateauth Disable GSS-API negotiation ],
1991     MOZ_AUTH_EXTENSION=,
1992     MOZ_AUTH_EXTENSION=1 )
1994 if test -n "$MOZ_IOS" -a -n "$MOZ_AUTH_EXTENSION"; then
1995    AC_MSG_ERROR([negotiateauth is not supported on iOS.])
1998 dnl ========================================================
1999 dnl Pref extensions (autoconfig)
2000 dnl ========================================================
2001 MOZ_ARG_DISABLE_BOOL(pref-extensions,
2002 [  --disable-pref-extensions
2003                           Disable pref extensions such as autoconfig],
2004   MOZ_PREF_EXTENSIONS=,
2005   MOZ_PREF_EXTENSIONS=1 )
2007 dnl ========================================================
2008 dnl Searching of system directories for extensions.
2009 dnl Note: this switch is meant to be used for test builds
2010 dnl whose behavior should not depend on what happens to be
2011 dnl installed on the local machine.
2012 dnl ========================================================
2013 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
2014 [  --disable-system-extension-dirs
2015                           Disable searching system- and account-global
2016                           directories for extensions of any kind; use
2017                           only profile-specific extension directories],
2018   ENABLE_SYSTEM_EXTENSION_DIRS=,
2019   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
2020 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
2021   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
2024 dnl ========================================================
2025 dnl = Universalchardet
2026 dnl ========================================================
2027 MOZ_ARG_DISABLE_BOOL(universalchardet,
2028 [  --disable-universalchardet
2029                           Disable universal encoding detection],
2030   MOZ_UNIVERSALCHARDET=,
2031   MOZ_UNIVERSALCHARDET=1 )
2033 dnl ========================================================
2034 dnl Gamepad support
2035 dnl ========================================================
2037 if test "$COMPILE_ENVIRONMENT" ; then
2039 dnl Moved gamepad platform check to moz.build, linux header check still needed here.
2040 if test "$OS_TARGET" = "Linux"; then
2041     MOZ_CHECK_HEADER([linux/joystick.h])
2042     if test "$ac_cv_header_linux_joystick_h" != "yes"; then
2043       AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers.])
2044     fi
2047 fi # COMPILE_ENVIRONMENT
2050 dnl ========================================================
2051 dnl = Breakpad crash reporting (on by default on supported platforms)
2052 dnl ========================================================
2054 case $target in
2055 i?86-*-mingw*|x86_64-*-mingw*|aarch64-*-mingw*)
2056   MOZ_CRASHREPORTER=1
2057   ;;
2058 i?86-apple-darwin*|x86_64-apple-darwin*)
2059   if test -z "$MOZ_IOS"; then
2060     MOZ_CRASHREPORTER=1
2061   fi
2062   ;;
2063 *-android*|*-linuxandroid*)
2064   dnl Android/arm is arm-unknown-linux-androideabi, so android condition should
2065   dnl be before Linux condition
2066   MOZ_CRASHREPORTER=1
2067   ;;
2068 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
2069   if test "$MOZ_ENABLE_GTK"; then
2070     MOZ_CRASHREPORTER=1
2071   fi
2072   ;;
2073 esac
2075 MOZ_ARG_DISABLE_BOOL(crashreporter,
2076 [  --disable-crashreporter Disable breakpad crash reporting],
2077     [MOZ_CRASHREPORTER=],
2078     [MOZ_CRASHREPORTER=F # Force enable breakpad])
2080 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "Darwin" -a "$MOZ_WIDGET_TOOLKIT" != "android"; then
2081   if test "$MOZ_CRASHREPORTER" = F; then
2082     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
2083   fi
2084   MOZ_CRASHREPORTER=
2087 if test -n "$MOZ_CRASHREPORTER"; then
2088    AC_DEFINE(MOZ_CRASHREPORTER)
2090   if test "$OS_TARGET" = "Linux" && \
2091     test -z "$SKIP_LIBRARY_CHECKS"; then
2092     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
2093   fi
2095   if test "$OS_ARCH" = "WINNT"; then
2096     if test -z "$HAVE_64BIT_BUILD" -a -n "$COMPILE_ENVIRONMENT"; then
2097       MOZ_CRASHREPORTER_INJECTOR=1
2098       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
2099     fi
2100   fi
2103 dnl ========================================================
2104 dnl = Enable compilation of specific extension modules
2105 dnl ========================================================
2107 MOZ_ARG_ENABLE_STRING(extensions,
2108 [  --enable-extensions     Enable extensions],
2109 [ for option in `echo $enableval | sed 's/,/ /g'`; do
2110     if test "$option" = "yes" -o "$option" = "all"; then
2111         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
2112     elif test "$option" = "no" -o "$option" = "none"; then
2113         MOZ_EXTENSIONS=""
2114     elif test "$option" = "default"; then
2115         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
2116     elif test `echo "$option" | grep -c \^-` != 0; then
2117         option=`echo $option | sed 's/^-//'`
2118         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
2119     else
2120         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
2121     fi
2122 done],
2123     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
2125 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
2126 dnl when trying to build a nonexistent extension.
2127 for extension in $MOZ_EXTENSIONS; do
2128     if test ! -d "${srcdir}/extensions/${extension}"; then
2129         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
2130     fi
2131 done
2133 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
2134   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
2137 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
2138 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
2139 if test -n "$MOZ_TREE_FREETYPE" -a "$OS_TARGET" != WINNT; then
2140    MOZ_ENABLE_CAIRO_FT=1
2141    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
2142    CAIRO_FT_CFLAGS="-I$_topsrcdir/modules/freetype2/include"
2143    AC_SUBST_LIST(CAIRO_FT_CFLAGS)
2146 AC_CHECK_PROGS(WGET, wget, "")
2147 AC_SUBST(WGET)
2149 dnl ========================================================
2150 dnl Updater
2151 dnl ========================================================
2153 if test "$MOZ_IOS"; then
2154   MOZ_UPDATER=
2157 MOZ_ARG_DISABLE_BOOL(updater,
2158 [  --disable-updater       Disable building of updater],
2159     MOZ_UPDATER=,
2160     MOZ_UPDATER=1 )
2162 if test -n "$MOZ_UPDATER"; then
2163     AC_DEFINE(MOZ_UPDATER)
2166 dnl ========================================================
2167 dnl parental controls (for Windows Vista)
2168 dnl ========================================================
2169 MOZ_ARG_DISABLE_BOOL(parental-controls,
2170 [  --disable-parental-controls
2171                           Do not build parental controls],
2172    MOZ_DISABLE_PARENTAL_CONTROLS=1,
2173    MOZ_DISABLE_PARENTAL_CONTROLS=)
2174 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
2175     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
2178 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
2180 dnl ========================================================
2181 dnl = Disable smartcard support
2182 dnl ========================================================
2183 if test -n "$MOZ_NO_SMART_CARDS"; then
2184     AC_DEFINE(MOZ_NO_SMART_CARDS)
2186 AC_SUBST(MOZ_NO_SMART_CARDS)
2188 dnl ========================================================
2189 dnl = Sandboxing support
2190 dnl ========================================================
2191 if test -n "$MOZ_TSAN" -o -n "$MOZ_ASAN"; then
2192     # Bug 1182565: TSan conflicts with sandboxing on Linux.
2193     # Bug 1287971: LSan also conflicts with sandboxing on Linux.
2194     case $OS_TARGET in
2195     Linux|Android)
2196         MOZ_SANDBOX=
2197         ;;
2198     esac
2201 MOZ_ARG_DISABLE_BOOL(sandbox,
2202 [  --disable-sandbox        Disable sandboxing support],
2203     MOZ_SANDBOX=,
2204     MOZ_SANDBOX=1)
2206 case "$OS_TARGET" in
2207 WINNT|Darwin)
2209 Linux)
2210     case $CPU_ARCH in
2211         x86_64|x86)
2212         ;;
2213         # Linux sandbox is only available on x86 and x86_64.
2214         *)
2215             MOZ_SANDBOX=
2216         ;;
2217     esac
2218     ;;
2220     # Only enable the sandbox by default on Linux, macOS, and Windows
2221     MOZ_SANDBOX=
2223 esac
2225 if test -n "$MOZ_SANDBOX"; then
2226     AC_DEFINE(MOZ_SANDBOX)
2229 AC_SUBST(MOZ_SANDBOX)
2232 dnl ========================================================
2233 dnl =
2234 dnl = Module specific options
2235 dnl =
2236 dnl ========================================================
2237 MOZ_ARG_HEADER(Individual module options)
2239 dnl ========================================================
2240 dnl Check for sqlite
2241 dnl ========================================================
2243 MOZ_SYSTEM_SQLITE=
2244 MOZ_ARG_ENABLE_BOOL(system-sqlite,
2245 [  --enable-system-sqlite  Use system sqlite (located with pkgconfig)],
2246 MOZ_SYSTEM_SQLITE=1,
2247 MOZ_SYSTEM_SQLITE= )
2249 if test -n "$MOZ_SYSTEM_SQLITE"
2250 then
2251     dnl ============================
2252     dnl === SQLite Version check ===
2253     dnl ============================
2254     dnl Check to see if the system SQLite package is new enough.
2255     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
2256 else
2257     dnl ==============================
2258     dnl === SQLite fdatasync check ===
2259     dnl ==============================
2260     dnl Check to see if fdatasync is available
2261     AC_CHECK_FUNC(fdatasync)
2264 if test -n "$MOZ_SYSTEM_SQLITE"; then
2265     AC_DEFINE(MOZ_SYSTEM_SQLITE)
2267 AC_SUBST(MOZ_SYSTEM_SQLITE)
2269 dnl ========================================================
2270 dnl = Disable zipwriter
2271 dnl ========================================================
2272 MOZ_ARG_DISABLE_BOOL(zipwriter,
2273 [  --disable-zipwriter     Disable zipwriter component],
2274     MOZ_ZIPWRITER=,
2275     MOZ_ZIPWRITER=1 )
2276 AC_SUBST(MOZ_ZIPWRITER)
2278 dnl ========================================================
2279 dnl =
2280 dnl = Feature options that require extra sources to be pulled
2281 dnl =
2282 dnl ========================================================
2283 dnl MOZ_ARG_HEADER(Features that require extra sources)
2285 dnl ========================================================
2286 dnl =
2287 dnl = Runtime debugging and Optimization Options
2288 dnl =
2289 dnl ========================================================
2290 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
2292 dnl ========================================================
2293 dnl enable mobile optimizations
2294 dnl ========================================================
2295 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
2296 [  --enable-mobile-optimize
2297                           Enable mobile optimizations],
2298     MOZ_GFX_OPTIMIZE_MOBILE=1)
2300 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
2302 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
2303     # We ignore paint will resample on mobile for performance.
2304     # We may want to revisit this later.
2305     MOZ_IGNORE_PAINT_WILL_RESAMPLE=1
2307     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
2308     AC_DEFINE(MOZ_IGNORE_PAINT_WILL_RESAMPLE)
2311 dnl ========================================================
2312 dnl = Enable code optimization. ON by default.
2313 dnl ========================================================
2315 # Use value from moz.configure if one is defined. Else use our computed
2316 # value.
2317 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
2318     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
2321 if test "$COMPILE_ENVIRONMENT"; then
2322 if test -n "$MOZ_OPTIMIZE"; then
2323     AC_MSG_CHECKING([for valid C compiler optimization flags])
2324     _SAVE_CFLAGS=$CFLAGS
2325     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
2326     AC_TRY_COMPILE([#include <stdio.h>],
2327         [printf("Hello World\n");],
2328         _results=yes,
2329         _results=no)
2330     AC_MSG_RESULT([$_results])
2331     if test "$_results" = "no"; then
2332         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
2333     fi
2334     CFLAGS=$_SAVE_CFLAGS
2335     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
2336         # When using llvm-based LTO, non numeric optimization levels are
2337         # not supported by the linker, so force the linker to use -O2 (
2338         # which doesn't influence the level compilation units are actually
2339         # compiled at).
2340         case " $MOZ_OPTIMIZE_FLAGS " in
2341         *\ -Os\ *|*\ -Oz\ *)
2342             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
2343             ;;
2344         esac
2345     fi
2347 fi # COMPILE_ENVIRONMENT
2349 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
2350 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
2351 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
2353 dnl ========================================================
2354 dnl = Disable treating compiler warnings as errors
2355 dnl ========================================================
2356 if test -z "$MOZ_ENABLE_WARNINGS_AS_ERRORS"; then
2357    WARNINGS_AS_ERRORS=''
2360 dnl ========================================================
2361 dnl = Enable runtime logging
2362 dnl ========================================================
2363 AC_DEFINE(MOZ_LOGGING)
2364 AC_DEFINE(FORCE_PR_LOG)
2366 dnl ========================================================
2367 dnl = This will enable logging of addref, release, ctor, dtor.
2368 dnl ========================================================
2369 _ENABLE_LOGREFCNT=42
2370 MOZ_ARG_ENABLE_BOOL(logrefcnt,
2371 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
2372     _ENABLE_LOGREFCNT=1,
2373     _ENABLE_LOGREFCNT= )
2374 if test "$_ENABLE_LOGREFCNT" = "1"; then
2375     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
2376 elif test -z "$_ENABLE_LOGREFCNT"; then
2377     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
2380 dnl ========================================================
2381 dnl moz_dump_painting
2382 dnl ========================================================
2383 MOZ_ARG_ENABLE_BOOL(dump-painting,
2384 [  --enable-dump-painting          Enable paint debugging.],
2385     MOZ_DUMP_PAINTING=1,
2386     MOZ_DUMP_PAINTING= )
2387 if test -n "$MOZ_DUMP_PAINTING"; then
2388     AC_DEFINE(MOZ_DUMP_PAINTING)
2389     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
2391 if test -n "$MOZ_DEBUG"; then
2392     AC_DEFINE(MOZ_DUMP_PAINTING)
2395 case "${OS_TARGET}" in
2396 Android|WINNT|Darwin)
2397   MOZ_GLUE_IN_PROGRAM=
2398   ;;
2400   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
2401   MOZ_GLUE_IN_PROGRAM=1
2402   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
2403   ;;
2404 esac
2406 dnl ========================================================
2407 dnl = Jemalloc build setup
2408 dnl ========================================================
2409 if test -z "$MOZ_MEMORY"; then
2410   case "${target}" in
2411     *-mingw*)
2412       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
2413         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.])
2414       fi
2415       ;;
2416   esac
2417 else
2418   dnl The generic feature tests that determine how to compute ncpus are long and
2419   dnl complicated.  Therefore, simply define special cpp variables for the
2420   dnl platforms we have special knowledge of.
2421   case "${target}" in
2422   *-mingw*)
2423     export MOZ_NO_DEBUG_RTL=1
2424     ;;
2425   esac
2426 fi # MOZ_MEMORY
2427 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
2429 dnl ========================================================
2430 dnl = Enable using the clang plugin to build
2431 dnl ========================================================
2433 if test -n "$COMPILE_ENVIRONMENT"; then
2434 MOZ_CONFIG_CLANG_PLUGIN
2435 fi # COMPILE_ENVIRONMENT
2437 dnl ========================================================
2438 dnl = Enable stripping of libs & executables
2439 dnl ========================================================
2440 MOZ_ARG_ENABLE_BOOL(strip,
2441 [  --enable-strip          Enable stripping of libs & executables ],
2442     ENABLE_STRIP=1,
2443     ENABLE_STRIP= )
2445 dnl ========================================================
2446 dnl = Enable stripping of libs & executables when packaging
2447 dnl ========================================================
2448 MOZ_ARG_ENABLE_BOOL(install-strip,
2449 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
2450     PKG_SKIP_STRIP= ,
2451     PKG_SKIP_STRIP=1)
2453 dnl ========================================================
2454 dnl = frontend JS debug mode
2455 dnl ========================================================
2457 MOZ_ARG_ENABLE_BOOL(debug-js-modules,
2458 [  --enable-debug-js-modules  Enable debug mode for frontend JS libraries],
2459    DEBUG_JS_MODULES=1,
2460    DEBUG_JS_MODULES=)
2462 AC_SUBST(DEBUG_JS_MODULES)
2464 dnl ========================================================
2465 dnl =
2466 dnl = Profiling and Instrumenting
2467 dnl =
2468 dnl ========================================================
2469 MOZ_ARG_HEADER(Profiling and Instrumenting)
2471 dnl ========================================================
2472 dnl = Offer a way to disable the startup cache
2473 dnl ========================================================
2475 MOZ_ARG_DISABLE_BOOL(startupcache,
2476 [  --disable-startupcache          Disable startup cache ],
2477     MOZ_DISABLE_STARTUPCACHE=1,
2478     MOZ_DISABLE_STARTUPCACHE=)
2480 if test -n "$MOZ_DISABLE_STARTUPCACHE"; then
2481   AC_DEFINE(MOZ_DISABLE_STARTUPCACHE)
2483 AC_SUBST(MOZ_DISABLE_STARTUPCACHE)
2485 dnl ========================================================
2486 dnl = Support for demangling undefined symbols
2487 dnl ========================================================
2488 if test -z "$SKIP_LIBRARY_CHECKS"; then
2489     AC_LANG_SAVE
2490     AC_LANG_CPLUSPLUS
2491     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
2492     AC_LANG_RESTORE
2495 # Demangle only for debug or DMD builds
2496 MOZ_DEMANGLE_SYMBOLS=
2497 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
2498     MOZ_DEMANGLE_SYMBOLS=1
2499     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
2501 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
2503 dnl ========================================================
2504 dnl = Support for gcc stack unwinding (from gcc 3.3)
2505 dnl ========================================================
2506 if test -z "$SKIP_LIBRARY_CHECKS"; then
2507     AC_LANG_SAVE
2508     AC_LANG_CPLUSPLUS
2509     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
2510     AC_LANG_RESTORE
2513 dnl ========================================================
2514 dnl JIT observers
2515 dnl ========================================================
2517 MOZ_ARG_WITH_STRING(jitreport-granularity,
2518 [  --jitreport-granularity=N
2519                            Default granularity at which to report JIT code
2520                            to external tools
2521                              0 - no info
2522                              1 - code ranges for whole functions only
2523                              2 - per-line information
2524                              3 - per-op information],
2525   JITREPORT_GRANULARITY=$withval,
2526   JITREPORT_GRANULARITY=3)
2528 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
2530 dnl ========================================================
2531 dnl =
2532 dnl = Misc. Options
2533 dnl =
2534 dnl ========================================================
2535 MOZ_ARG_HEADER(Misc. Options)
2537 dnl ========================================================
2538 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
2539 dnl ========================================================
2540 MOZ_ARG_WITH_STRING(user-appdir,
2541 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
2542 [ val=`echo $withval`
2543 if echo "$val" | grep "\/" >/dev/null; then
2544     AC_MSG_ERROR("Homedir must be single relative path.")
2545 else
2546     MOZ_USER_DIR="$val"
2547 fi])
2549 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
2551 if test -z "$SKIP_COMPILER_CHECKS"; then
2552 dnl ========================================================
2553 dnl =
2554 dnl = Compiler Options
2555 dnl =
2556 dnl ========================================================
2557 MOZ_ARG_HEADER(Compiler Options)
2559 dnl ========================================================
2560 dnl Check for gcc -pipe support
2561 dnl ========================================================
2562 AC_MSG_CHECKING([for -pipe support])
2563 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
2564     dnl Any gcc that supports firefox supports -pipe.
2565     CFLAGS="$CFLAGS -pipe"
2566     CXXFLAGS="$CXXFLAGS -pipe"
2567     AC_MSG_RESULT([yes])
2568 else
2569     AC_MSG_RESULT([no])
2572 fi # ! SKIP_COMPILER_CHECKS
2574 AC_DEFINE(CPP_THROW_NEW, [throw()])
2575 AC_LANG_C
2577 if test "$COMPILE_ENVIRONMENT"; then
2578 MOZ_EXPAND_LIBS
2579 fi # COMPILE_ENVIRONMENT
2581 dnl ========================================================
2582 dnl =
2583 dnl = Static Build Options
2584 dnl =
2585 dnl ========================================================
2586 MOZ_ARG_HEADER(Static build options)
2588 if test -z "$MOZ_SYSTEM_ZLIB"; then
2589 if test -n "$JS_SHARED_LIBRARY" -o -n "$MOZ_LINKER"; then
2590   ZLIB_IN_MOZGLUE=1
2591   AC_DEFINE(ZLIB_IN_MOZGLUE)
2595 AC_SUBST(ZLIB_IN_MOZGLUE)
2597 dnl ========================================================
2598 dnl =
2599 dnl = Standalone module options
2600 dnl =
2601 dnl ========================================================
2602 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
2604 dnl Check for GLib.
2605 dnl ========================================================
2607 if test -z "$SKIP_PATH_CHECKS"; then
2608 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
2609     if test "$MOZ_ENABLE_GTK" ; then
2610         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
2611     fi
2615 if test -z "${GLIB_GMODULE_LIBS}" \
2616    -a -n "${GLIB_CONFIG}"\
2617     -a "${GLIB_CONFIG}" != no\
2618 ; then
2619     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
2622 AC_SUBST_LIST(GLIB_GMODULE_LIBS)
2624 if test "$USE_FC_FREETYPE"; then
2625     if test "$COMPILE_ENVIRONMENT"; then
2626         dnl ========================================================
2627         dnl = Check for freetype2 functionality
2628         dnl ========================================================
2629         if test "$_HAVE_FREETYPE2" -a -z "$MOZ_TREE_FREETYPE"; then
2630             _SAVE_LIBS="$LIBS"
2631             _SAVE_CFLAGS="$CFLAGS"
2632             LIBS="$LIBS $FT2_LIBS"
2633             CFLAGS="$CFLAGS $FT2_CFLAGS"
2635             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
2636                 ac_cv_member_FT_Bitmap_Size_y_ppem,
2637                 [AC_TRY_COMPILE([#include <ft2build.h>
2638                                  #include FT_FREETYPE_H],
2639                                 [FT_Bitmap_Size s;
2640                                  if (sizeof s.y_ppem) return 0;
2641                                  return 1],
2642                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
2643                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
2644             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
2645                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
2646             else
2647                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
2648             fi
2649             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
2650                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
2651                                [FT_Bitmap_Size structure includes y_ppem field])
2653             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table)
2655             LIBS="$_SAVE_LIBS"
2656             CFLAGS="$_SAVE_CFLAGS"
2657         fi
2659         _SAVE_CPPFLAGS="$CPPFLAGS"
2660         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
2661         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
2662             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
2663         CPPFLAGS="$_SAVE_CPPFLAGS"
2664     fi
2667 dnl ========================================================
2668 dnl Check if we need the 32-bit Linux SSE2 error dialog
2669 dnl ========================================================
2671 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
2673 dnl ========================================================
2674 dnl Check for pixman and cairo
2675 dnl ========================================================
2677 MOZ_TREE_CAIRO=1
2678 MOZ_ARG_ENABLE_BOOL(system-cairo,
2679 [ --enable-system-cairo  Obsolete: do not use this option],
2680 AC_MSG_ERROR(--enable-system-cairo is not supported),
2681 MOZ_TREE_CAIRO=1 )
2683 MOZ_TREE_PIXMAN=1
2684 MOZ_ARG_ENABLE_BOOL(system-pixman,
2685 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
2686 MOZ_TREE_PIXMAN=,
2687 MOZ_TREE_PIXMAN=force,
2688 MOZ_TREE_PIXMAN=1 )
2690 if test "$MOZ_TREE_PIXMAN"; then
2691     AC_DEFINE(MOZ_TREE_PIXMAN)
2692 else
2693     PKG_CHECK_MODULES(MOZ_PIXMAN, pixman-1 >= 0.19.2)
2696 MOZ_CAIRO_CFLAGS="-I${DIST}/include/cairo"
2697 AC_DEFINE(MOZ_TREE_CAIRO)
2699 if test "$OS_ARCH" = "WINNT"; then
2700     # For now we assume that we will have a uint64_t available through
2701     # one of the above headers or mozstdint.h.
2702     AC_DEFINE(HAVE_UINT64_T)
2705 # Define macros for cairo-features.h
2706 TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
2707 if test "$MOZ_X11"; then
2708     XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
2709     XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
2710     PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
2712 if test "$_HAVE_FREETYPE2"; then
2713     FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
2714     MOZ_ENABLE_CAIRO_FT=1
2715     CAIRO_FT_CFLAGS="$FT2_CFLAGS"
2718 case "$MOZ_WIDGET_TOOLKIT" in
2719   cocoa | uikit)
2720     QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
2721     QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
2722     QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
2723     ;;
2724   windows)
2725     WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
2726     WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
2727     WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
2729     if test "$COMPILE_ENVIRONMENT"; then
2730       MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
2731     fi
2732     ;;
2733 esac
2734 if test "$USE_FC_FREETYPE"; then
2735     FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
2737 AC_SUBST(MOZ_ENABLE_CAIRO_FT)
2738 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
2740 AC_SUBST(PS_SURFACE_FEATURE)
2741 AC_SUBST(SVG_SURFACE_FEATURE)
2742 AC_SUBST(XLIB_SURFACE_FEATURE)
2743 AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
2744 AC_SUBST(QUARTZ_SURFACE_FEATURE)
2745 AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
2746 AC_SUBST(WIN32_SURFACE_FEATURE)
2747 AC_SUBST(OS2_SURFACE_FEATURE)
2748 AC_SUBST(DIRECTFB_SURFACE_FEATURE)
2749 AC_SUBST(FT_FONT_FEATURE)
2750 AC_SUBST(FC_FONT_FEATURE)
2751 AC_SUBST(WIN32_FONT_FEATURE)
2752 AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
2753 AC_SUBST(QUARTZ_FONT_FEATURE)
2754 AC_SUBST(PNG_FUNCTIONS_FEATURE)
2755 AC_SUBST(QT_SURFACE_FEATURE)
2756 AC_SUBST(TEE_SURFACE_FEATURE)
2758 if test "$MOZ_X11"; then
2759     MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
2762 CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
2764 case "$MOZ_WIDGET_TOOLKIT" in
2765 android)
2766     TK_CFLAGS="$MOZ_CAIRO_CFLAGS $MOZ_PIXMAN_CFLAGS"
2767     TK_LIBS="$MOZ_CAIRO_LIBS $MOZ_PIXMAN_LIBS"
2768     ;;
2769 esac
2771 AC_SUBST(MOZ_TREE_CAIRO)
2772 AC_SUBST_LIST(MOZ_CAIRO_CFLAGS)
2773 AC_SUBST_LIST(MOZ_CAIRO_LIBS)
2774 AC_SUBST_LIST(MOZ_CAIRO_OSLIBS)
2775 AC_SUBST(MOZ_TREE_PIXMAN)
2777 BINDGEN_SYSTEM_FLAGS="$_BINDGEN_CFLAGS $NSPR_CFLAGS $NSS_CFLAGS $MOZ_PIXMAN_CFLAGS $MOZ_CAIRO_CFLAGS"
2778 AC_SUBST(BINDGEN_SYSTEM_FLAGS)
2779 BINDGEN_SYSTEM_TOML_FLAGS="$BINDGEN_SYSTEM_FLAGS"
2780 AC_SUBST_TOML_LIST(BINDGEN_SYSTEM_TOML_FLAGS)
2782 dnl ========================================================
2783 dnl disable xul
2784 dnl ========================================================
2785 MOZ_ARG_DISABLE_BOOL(xul,
2786 [  --disable-xul           Disable XUL],
2787     MOZ_XUL= )
2788 if test "$MOZ_XUL"; then
2789   AC_DEFINE(MOZ_XUL)
2790 else
2791   dnl remove extensions that require XUL
2792   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/irc//' -e 's/tasks//'`
2795 AC_SUBST(MOZ_XUL)
2797 dnl ========================================================
2798 dnl necko configuration options
2799 dnl ========================================================
2802 dnl option to disable necko's wifi scanner
2805 if test "$MOZ_WIDGET_TOOLKIT"; then
2807   case "$OS_TARGET" in
2808     Darwin)
2809       if test -z "$MOZ_IOS"; then
2810         NECKO_WIFI=1
2811       fi
2812       ;;
2813     DragonFly|FreeBSD|WINNT)
2814       NECKO_WIFI=1
2815       ;;
2816     Linux)
2817       NECKO_WIFI=1
2818       NECKO_WIFI_DBUS=1
2819       ;;
2820   esac
2824 MOZ_ARG_DISABLE_BOOL(necko-wifi,
2825 [  --disable-necko-wifi    Disable necko wifi scanner],
2826     NECKO_WIFI=,
2827     NECKO_WIFI=1)
2829 if test "$NECKO_WIFI"; then
2830   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
2831     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
2832   fi
2833   AC_DEFINE(NECKO_WIFI)
2834   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
2836 AC_SUBST(NECKO_WIFI)
2837 AC_SUBST(NECKO_WIFI_DBUS)
2840 dnl option to disable cookies
2842 MOZ_ARG_DISABLE_BOOL(cookies,
2843 [  --disable-cookies       Disable cookie support],
2844     NECKO_COOKIES=,
2845     NECKO_COOKIES=1)
2846 AC_SUBST(NECKO_COOKIES)
2847 if test "$NECKO_COOKIES"; then
2848     AC_DEFINE(NECKO_COOKIES)
2849     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
2852 dnl ========================================================
2853 dnl =
2854 dnl = Maintainer debug option (no --enable equivalent)
2855 dnl =
2856 dnl ========================================================
2858 AC_SUBST(NM)
2859 AC_SUBST_LIST(ASFLAGS)
2860 AC_SUBST(RCFLAGS)
2861 AC_SUBST(IMPLIB)
2862 AC_SUBST(FILTER)
2863 AC_SUBST(MOZ_AUTH_EXTENSION)
2864 AC_SUBST(MOZ_PREF_EXTENSIONS)
2865 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
2866 AC_SUBST(WARNINGS_AS_ERRORS)
2867 AC_SUBST_LIST(WARNINGS_CFLAGS)
2868 AC_SUBST_SET(MOZ_EXTENSIONS)
2870 AC_SUBST(MOZ_UNIVERSALCHARDET)
2871 AC_SUBST(MOZ_SPELLCHECK)
2872 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
2873 AC_SUBST(MOZ_CRASHREPORTER)
2874 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
2875 AC_SUBST(MOZ_STUB_INSTALLER)
2876 AC_SUBST(MOZ_UPDATER)
2878 AC_SUBST(MOZ_ANDROID_APPLICATION_CLASS)
2879 AC_SUBST(MOZ_ANDROID_BROWSER_INTENT_CLASS)
2880 AC_SUBST(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
2881 AC_SUBST(ENABLE_STRIP)
2882 AC_SUBST(PKG_SKIP_STRIP)
2883 AC_SUBST(STRIP_FLAGS)
2884 AC_SUBST(INCREMENTAL_LINKER)
2886 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
2888 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
2889 AC_SUBST(MOZ_LINKER_EXTRACT)
2891 if test -n "$MOZ_BINARY_EXTENSIONS"; then
2892   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
2895 AC_SUBST(MOZ_REQUIRE_SIGNING)
2896 if test "$MOZ_REQUIRE_SIGNING" = 1; then
2897   AC_DEFINE(MOZ_REQUIRE_SIGNING)
2900 dnl ========================================================
2901 dnl = Mac bundle name prefix
2902 dnl ========================================================
2903 MOZ_ARG_WITH_STRING(macbundlename-prefix,
2904 [  --with-macbundlename-prefix=prefix
2905                           Prefix for MOZ_MACBUNDLE_NAME],
2906 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
2908 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
2909 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
2910   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
2913 if test "$MOZ_DEBUG"; then
2914   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
2915 else
2916   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
2918 AC_SUBST(MOZ_MACBUNDLE_NAME)
2920 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
2921 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
2922 # Otherwise, use MOZ_APP_DISPLAYNAME
2923 if test -z "$MOZ_MACBUNDLE_ID"; then
2924    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
2926 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
2927 if test "$MOZ_DEBUG"; then
2928   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
2931 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
2932 AC_SUBST(MOZ_MACBUNDLE_ID)
2934 dnl ========================================================
2935 dnl = Child Process Name for IPC
2936 dnl ========================================================
2937 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
2938   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
2939 else
2940   # We want to let Android unpack the file at install time, but it only does
2941   # so if the file is named libsomething.so. The lib/ path is also required
2942   # because the unpacked file will be under the lib/ subdirectory and will
2943   # need to be executed from that path.
2944   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
2946 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
2947 MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
2949 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
2950 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
2951 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
2953 # The following variables are available to branding and application
2954 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
2955 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
2956 # impacts profile location and user-visible fields.
2957 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
2958 # versions of a given application (e.g. Aurora and Firefox both use
2959 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
2960 # for application.ini's "Name" field, which controls profile location in
2961 # the absence of a "Profile" field (see below), and various system
2962 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
2963 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
2964 # Mac Bundle name, Updater, Installer), it is typically used for nightly
2965 # builds (e.g. Aurora for Firefox).
2966 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
2967 # defaults to a lowercase form of MOZ_APP_BASENAME.
2968 # - MOZ_APP_REMOTINGNAME: Used for the internal program name, which affects
2969 # profile name and remoting. If not set, defaults to MOZ_APP_NAME.
2970 # - MOZ_APP_PROFILE: When set, used for application.ini's
2971 # "Profile" field, which controls profile location.
2972 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
2973 # crash reporter server url.
2974 # - MOZ_APP_ANDROID_VERSION_CODE: On Android, "android:versionCode" for
2975 # the main application is set to the value of this variable.  If not
2976 # set, it falls back to a Mozilla-specific value derived from the
2977 # build ID.
2978 # - MOZ_ANDROID_SHARED_ID: On Android, "android:sharedUserId" for all Android
2979 # packages produced.
2980 # - MOZ_ANDROID_GCM_SENDERID: On Android, the Android GCM Sender ID used.  GCM
2981 # sender IDs are not sensitive: see, http://stackoverflow.com/a/18216063.
2982 # - MOZ_MMA_GCM_SENDERID: This GCM Sender ID is used for MMA integration.
2983 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
2985 # The following environment variables used to have an effect, but don't anymore:
2986 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
2987 # the contents from the version.txt file in the application directory, or
2988 # browser/config/version.txt if there isn't one.
2989 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
2990 # in the "About" window. This was replaced with the contents from the
2991 # version_display.txt or version.txt in the application directory, or
2992 # browser/config/version_display.txt.
2994 if test -z "$MOZ_APP_NAME"; then
2995    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
2998 if test -z "$MOZ_APP_REMOTINGNAME"; then
2999    MOZ_APP_REMOTINGNAME=$MOZ_APP_NAME
3002 if test -z "$ANDROID_PACKAGE_NAME" ; then
3003    # When we got rid of the Aurora channel we decided to replace the old
3004    # Nightly ANDROID_PACKAGE_NAME with Aurora. To make sure this is inherited
3005    # by all mozilla-central based branches we make this the new "default"
3006    # for Fennec. Non mozilla-central based branches set ANDROID_PACKAGE_NAME
3007    # in their mozconfig, so they will never get this. If there are ever
3008    # non-Fennec builds for Android, they will fall into the else block
3009    # and use their own default name.
3010    # https://bugzilla.mozilla.org/show_bug.cgi?id=1357808 has additional
3011    # background on this.
3012    if test "$MOZ_APP_NAME" = "fennec"; then
3013       ANDROID_PACKAGE_NAME="org.mozilla.fennec_aurora"
3014    else
3015       ANDROID_PACKAGE_NAME="org.mozilla.$MOZ_APP_NAME"
3016    fi
3019 # Mozilla released Firefox for Android {Release,Beta} and {Aurora,Nightly} to
3020 # the public with specific common shared IDs and we need to keep them
3021 # consistent forever.  The specific common values are set by per-channel
3022 # branding; all other channels use a generic sharedID, set below.
3023 if test -z "$MOZ_ANDROID_SHARED_ID" ; then
3024    MOZ_ANDROID_SHARED_ID="${ANDROID_PACKAGE_NAME}.sharedID"
3027 # For extensions and langpacks, we require a max version that is compatible
3028 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
3029 # 24.0a1 and 24.0a2 aren't affected
3030 # 24.0 becomes 24.*
3031 # 24.1.1 becomes 24.*
3032 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
3033 if test -z "$IS_ALPHA"; then
3034   changequote(,)
3035   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
3036     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
3037   else
3038     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
3039   fi
3040   changequote([,])
3041 else
3042   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
3045 AC_SUBST(MOZ_APP_NAME)
3046 AC_SUBST(MOZ_APP_REMOTINGNAME)
3047 AC_SUBST(MOZ_APP_DISPLAYNAME)
3048 AC_SUBST(MOZ_APP_BASENAME)
3049 AC_SUBST(MOZ_APP_VENDOR)
3050 AC_SUBST(MOZ_APP_PROFILE)
3051 AC_SUBST(MOZ_APP_ID)
3052 AC_SUBST(MOZ_APP_ANDROID_VERSION_CODE)
3053 AC_SUBST(MOZ_ANDROID_SHARED_ID)
3054 AC_SUBST(MOZ_ANDROID_GCM_SENDERID)
3055 AC_SUBST(MOZ_MMA_GCM_SENDERID)
3056 AC_SUBST(MAR_CHANNEL_ID)
3057 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
3058 AC_SUBST(MOZ_PROFILE_MIGRATOR)
3059 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
3060 AC_SUBST(MOZ_APP_UA_NAME)
3061 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
3062 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
3063 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
3065 AC_SUBST(MOZ_APP_MAXVERSION)
3066 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
3067 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
3068   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
3071 AC_SUBST(MOZ_PKG_SPECIAL)
3072 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
3074 if test "$MOZILLA_OFFICIAL"; then
3075     # Build revisions should always be present in official builds
3076     MOZ_INCLUDE_SOURCE_INFO=1
3079 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
3080 # explicitly set the repository and changeset information in.
3081 AC_SUBST(MOZ_SOURCE_REPO)
3082 AC_SUBST(MOZ_SOURCE_CHANGESET)
3083 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
3085 dnl If we have any service that uploads data (and requires data submission
3086 dnl policy alert), set MOZ_DATA_REPORTING.
3087 dnl We need SUBST for build system and DEFINE for xul preprocessor.
3088 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"  || test -n "$MOZ_NORMANDY"; then
3089   MOZ_DATA_REPORTING=1
3090   AC_DEFINE(MOZ_DATA_REPORTING)
3091   AC_SUBST(MOZ_DATA_REPORTING)
3094 dnl win32 options
3095 AC_SUBST(WIN32_REDIST_DIR)
3096 AC_SUBST(WIN_UCRT_REDIST_DIR)
3098 dnl ========================================================
3099 dnl ICU Support
3100 dnl ========================================================
3102 _INTL_API=yes
3104 if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
3105     USE_ICU=1
3108 MOZ_CONFIG_ICU()
3110 dnl Echo the CFLAGS to remove extra whitespace.
3111 CFLAGS=`echo \
3112     $_COMPILATION_CFLAGS \
3113     $CFLAGS`
3115 CXXFLAGS=`echo \
3116     $_WARNINGS_CXXFLAGS \
3117     $_COMPILATION_CXXFLAGS \
3118     $CXXFLAGS`
3120 COMPILE_CFLAGS=`echo \
3121     $_DEFINES_CFLAGS \
3122     $COMPILE_CFLAGS`
3124 COMPILE_CXXFLAGS=`echo \
3125     $_DEFINES_CXXFLAGS \
3126     $COMPILE_CXXFLAGS`
3128 HOST_CFLAGS=`echo \
3129     $_WARNINGS_HOST_CFLAGS \
3130     $_COMPILATION_HOST_CFLAGS \
3131     $HOST_CFLAGS`
3133 HOST_CXXFLAGS=`echo \
3134     $_WARNINGS_HOST_CXXFLAGS \
3135     $_COMPILATION_HOST_CXXFLAGS \
3136     $HOST_CXXFLAGS`
3138 AC_SUBST(MOZ_SYSTEM_PNG)
3140 AC_SUBST_LIST(MOZ_PNG_CFLAGS)
3141 AC_SUBST_LIST(MOZ_PNG_LIBS)
3143 AC_SUBST(MOZ_SYSTEM_NSPR)
3145 AC_SUBST(MOZ_SYSTEM_NSS)
3147 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
3148 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
3149 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
3150 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
3151 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
3152   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
3153   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
3155 AC_SUBST(HOST_CMFLAGS)
3156 AC_SUBST(HOST_CMMFLAGS)
3157 AC_SUBST(OS_COMPILE_CMFLAGS)
3158 AC_SUBST(OS_COMPILE_CMMFLAGS)
3160 OS_CFLAGS="$CFLAGS"
3161 OS_CXXFLAGS="$CXXFLAGS"
3162 OS_CPPFLAGS="$CPPFLAGS"
3163 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
3164 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
3165 OS_LDFLAGS="$LDFLAGS"
3166 OS_LIBS="$LIBS"
3167 AC_SUBST_LIST(OS_CFLAGS)
3168 AC_SUBST_LIST(OS_CXXFLAGS)
3169 AC_SUBST_LIST(OS_CPPFLAGS)
3170 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
3171 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
3172 AC_SUBST_LIST(OS_LDFLAGS)
3173 AC_SUBST(OS_LIBS)
3175 AC_SUBST(HOST_CC)
3176 AC_SUBST(HOST_CXX)
3177 AC_SUBST_LIST(HOST_CFLAGS)
3178 AC_SUBST_LIST(HOST_CPPFLAGS)
3179 AC_SUBST_LIST(HOST_CXXFLAGS)
3180 AC_SUBST(HOST_LDFLAGS)
3181 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
3182 AC_SUBST(HOST_BIN_SUFFIX)
3184 AC_SUBST(TARGET_XPCOM_ABI)
3185 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
3186 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
3187 AC_SUBST(HAVE_X86_AVX2)
3188 AC_SUBST(HAVE_ALTIVEC)
3190 AC_SUBST_LIST(DSO_CFLAGS)
3191 AC_SUBST_LIST(DSO_PIC_CFLAGS)
3192 AC_SUBST(DSO_LDOPTS)
3193 AC_SUBST(BIN_SUFFIX)
3194 AC_SUBST(USE_N32)
3195 AC_SUBST(NS_ENABLE_TSF)
3196 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
3197 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
3199 AC_SUBST(MOZ_DEVTOOLS)
3201 AC_SUBST(MOZ_PACKAGE_JSSHELL)
3202 AC_SUBST(MOZ_FOLD_LIBS)
3203 AC_SUBST_LIST(MOZ_FOLD_LIBS_FLAGS)
3205 AC_SUBST(DMG_TOOL)
3207 dnl Host JavaScript runtime, if any, to use during cross compiles.
3208 AC_SUBST(JS_BINARY)
3210 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
3212 if test -n "$COMPILE_ENVIRONMENT"; then
3213 AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
3215 dnl Check for missing components
3216 if test "$MOZ_X11"; then
3217     dnl ====================================================
3218     dnl = Check if X headers exist
3219     dnl ====================================================
3220     _SAVE_CFLAGS=$CFLAGS
3221     CFLAGS="$CFLAGS $XCFLAGS"
3222     AC_TRY_COMPILE([
3223         #include <stdio.h>
3224         #include <stdlib.h>
3225         #include <X11/Xlib.h>
3226         #include <X11/Intrinsic.h>
3227         #include <X11/extensions/XShm.h>
3228     ],
3229     [
3230         Display *dpy = 0;
3231         if ((dpy = XOpenDisplay(NULL)) == NULL) {
3232             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
3233             exit(1);
3234         }
3235     ], [],
3236     [ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
3237     CFLAGS="$_SAVE_CFLAGS"
3239     if test -n "$MISSING_X"; then
3240         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
3241     fi
3243 fi # MOZ_X11
3245 fi # COMPILE_ENVIRONMENT
3247 dnl Set various defines and substitutions
3248 dnl ========================================================
3250 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
3251     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
3252     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
3253     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
3254     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
3255     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
3256     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
3257     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
3258     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
3261 AC_SUBST(MOZ_DEV_EDITION)
3262 if test -n "$MOZ_DEV_EDITION"; then
3263     AC_DEFINE(MOZ_DEV_EDITION)
3266 if test "$MOZ_DEBUG" -o "$DEVELOPER_OPTIONS"; then
3267     A11Y_LOG=1
3269 AC_SUBST(A11Y_LOG)
3270 if test -n "$A11Y_LOG"; then
3271     AC_DEFINE(A11Y_LOG)
3274 dnl Spit out some output
3275 dnl ========================================================
3277 dnl The following defines are used by xpcom
3278 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
3279 CPP_THROW_NEW
3280 HAVE_GETPAGESIZE
3281 HAVE_STATVFS64
3282 HAVE_STATVFS
3283 HAVE_STATFS64
3284 HAVE_STATFS
3285 HAVE_SYS_STATVFS_H
3286 HAVE_SYS_STATFS_H
3287 HAVE_SYS_VFS_H
3288 HAVE_SYS_MOUNT_H
3291 # Avoid using obsolete NSPR features
3292 AC_DEFINE(NO_NSPR_10_SUPPORT)
3294 MOZ_CREATE_CONFIG_STATUS()
3296 rm -fr confdefs* $ac_clean_files