Bug 1619273 [wpt PR 22036] - Don't compare px rounded font sizes., a=testonly
[gecko.git] / old-configure.in
blob47e4cc825493ecb4f4469eceac2a90f0cc6b4d70
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.25
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 DBUS_VERSION=0.60
66 dnl Set various checks
67 dnl ========================================================
68 MISSING_X=
70 dnl Initialize the Pthread test variables early so they can be
71 dnl  overridden by each platform.
72 dnl ========================================================
73 MOZ_USE_PTHREADS=
74 _PTHREAD_LDFLAGS=""
76 LDFLAGS="$LDFLAGS $LINKER_LDFLAGS"
78 if test "$COMPILE_ENVIRONMENT"; then
79     MOZ_ANDROID_NDK
80 fi # COMPILE_ENVIRONMENT
82 case "$target" in
83 *-android*|*-linuxandroid*)
84     ;;
85 *-linux*)
86     AC_PATH_PROG(OBJCOPY,objcopy)
87     ;;
88 esac
90 case "$target" in
91 *-apple-darwin*)
92     MOZ_IOS_SDK
93     ;;
94 esac
96 AC_SUBST(ANDROID_PACKAGE_NAME)
97 AC_SUBST(OBJCOPY)
99 dnl ========================================================
100 dnl Checks for compilers.
101 dnl ========================================================
103 if test "$COMPILE_ENVIRONMENT"; then
105 if test "$target" != "$host"; then
106     MOZ_CROSS_COMPILER
107 else
108     AC_PROG_CC
109     case "$target" in
110     *-mingw*)
111       # Work around the conftest.exe access problem on Windows
112       sleep 2
113     esac
114     AC_PROG_CXX
115     AC_PROG_RANLIB
116     MOZ_PATH_PROGS(AS, $AS as, $CC)
117     AC_CHECK_PROGS(STRIP, strip, :)
118     AC_CHECK_PROGS(OTOOL, otool, :)
121 if test -n "$MOZ_WINCONSOLE"; then
122     AC_DEFINE(MOZ_WINCONSOLE)
125 MOZ_TOOL_VARIABLES
127 dnl ========================================================
128 dnl Special win32 checks
129 dnl ========================================================
131 WINVER=601
133 case "$target" in
134 *-mingw*)
135     if test "$GCC" != "yes"; then
136         # Check to see if we are really running in a msvc environemnt
137         _WIN32_MSVC=1
139         # Make sure compilers are valid
140         CXXFLAGS="$CXXFLAGS -TP"
141         AC_LANG_SAVE
142         AC_LANG_C
143         AC_TRY_COMPILE([#include <stdio.h>],
144             [ printf("Hello World\n"); ],,
145             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
147         AC_LANG_CPLUSPLUS
148         AC_TRY_COMPILE([#include <new.h>],
149             [ unsigned *test = new unsigned(42); ],,
150             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
151         AC_LANG_RESTORE
153         changequote(,)
154         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
155         changequote([,])
157         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
158         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
159         AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
161         _CC_SUITE=14
162         MSVC_C_RUNTIME_DLL=vcruntime140.dll
163         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
165         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
166         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
168         if test -n "$WIN_UCRT_REDIST_DIR"; then
169           if test ! -d "$WIN_UCRT_REDIST_DIR"; then
170             AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
171           fi
172           WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
173         fi
175         AC_SUBST(MSVC_C_RUNTIME_DLL)
176         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
178         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
180         if test -n "$WIN32_REDIST_DIR"; then
181           if test ! -d "$WIN32_REDIST_DIR"; then
182             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
183           fi
184           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
185         fi
187         # Check linker version, except in lld builds
188         case "$LINKER" in
189         *lld*)
190             ;;
191         *)
192             _LD_FULL_VERSION=`"${LINKER}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
193             _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
194             if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
195                 AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
196             fi
197             ;;
198         esac
200         INCREMENTAL_LINKER=1
202         unset _MSVC_VER_FILTER
204         WRAP_STL_INCLUDES=1
205         STL_FLAGS="-I${DIST}/stl_wrappers"
206     else
207         # Check w32api version
208         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
209         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
210         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
211         AC_TRY_COMPILE([#include <w32api.h>],
212             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
213                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
214                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
215                 #error "test failed."
216             #endif
217             , [ res=yes ], [ res=no ])
218         AC_MSG_RESULT([$res])
219         if test "$res" != "yes"; then
220             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
221         fi
222         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
223         # causing problems with local implementations with the same name.
224         AC_DEFINE(STRSAFE_NO_DEPRECATE)
225     fi # !GNU_CC
227     CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
228     CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
230     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
231     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
232     # Require OS features provided by IE 8.0 (Win7)
233     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
235     ;;
236 esac
238 if test -n "$_WIN32_MSVC"; then
239     SKIP_PATH_CHECKS=1
240     SKIP_COMPILER_CHECKS=1
241     SKIP_LIBRARY_CHECKS=1
243     # Since we're skipping compiler and library checks, hard-code
244     # some facts here.
245     AC_DEFINE(HAVE_IO_H)
246     AC_DEFINE(HAVE_ISATTY)
249 fi # COMPILE_ENVIRONMENT
251 AC_SUBST(GNU_CC)
252 AC_SUBST(GNU_CXX)
254 AC_SUBST_LIST(STL_FLAGS)
255 AC_SUBST(WRAP_STL_INCLUDES)
257 dnl ========================================================
258 dnl Checks for programs.
259 dnl ========================================================
260 if test "$COMPILE_ENVIRONMENT"; then
262 AC_PATH_XTRA
264 XCFLAGS="$X_CFLAGS"
266 fi # COMPILE_ENVIRONMENT
268 dnl ========================================================
269 dnl set the defaults first
270 dnl ========================================================
271 MOZ_USER_DIR=".mozilla"
273 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
275 MOZ_FS_LAYOUT=unix
277 dnl Configure platform-specific CPU architecture compiler options.
278 dnl ==============================================================
279 if test "$COMPILE_ENVIRONMENT"; then
280     MOZ_ARCH_OPTS
281 fi # COMPILE_ENVIRONMENT
283 dnl ========================================================
284 dnl Android libstdc++
285 dnl ========================================================
287 MOZ_ANDROID_CPU_ARCH
288 if test "$COMPILE_ENVIRONMENT"; then
289     MOZ_ANDROID_STLPORT
290 fi # COMPILE_ENVIRONMENT
292 dnl ========================================================
293 dnl Suppress Clang Argument Warnings
294 dnl ========================================================
295 WARNINGS_CFLAGS="$_WARNINGS_CFLAGS"
296 if test -n "${CLANG_CC}${CLANG_CL}"; then
297     WARNINGS_CFLAGS="-Qunused-arguments $WARNINGS_CFLAGS"
298     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
300 if test -n "${CLANG_CXX}${CLANG_CL}"; then
301     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
304 if test -n "$COMPILE_ENVIRONMENT"; then
305    MOZ_CONFIG_SANITIZE
308 dnl ========================================================
309 dnl GNU specific defaults
310 dnl ========================================================
311 if test "$GNU_CC"; then
312     MMX_FLAGS="-mmmx"
313     SSE_FLAGS="-msse"
314     SSE2_FLAGS="-msse2"
315     SSSE3_FLAGS="-mssse3"
316     CFLAGS="$CFLAGS -fno-strict-aliasing"
317     DSO_CFLAGS=''
319     if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
320         DSO_PIC_CFLAGS='-fPIC'
321         ASFLAGS="$ASFLAGS -fPIC"
322     fi
324     AC_MSG_CHECKING([for --noexecstack option to as])
325     _SAVE_CFLAGS=$CFLAGS
326     CFLAGS="$CFLAGS -Wa,--noexecstack"
327     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
328                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
329                      AC_MSG_RESULT([no]))
330     CFLAGS=$_SAVE_CFLAGS
331     AC_MSG_CHECKING([for -z noexecstack option to ld])
332     _SAVE_LDFLAGS=$LDFLAGS
333     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
334     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
335                   AC_MSG_RESULT([no])
336                   LDFLAGS=$_SAVE_LDFLAGS)
338     AC_MSG_CHECKING([for -z text option to ld])
339     _SAVE_LDFLAGS=$LDFLAGS
340     LDFLAGS="$LDFLAGS -Wl,-z,text"
341     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
342                   AC_MSG_RESULT([no])
343                   LDFLAGS=$_SAVE_LDFLAGS)
345     AC_MSG_CHECKING([for -z relro option to ld])
346     _SAVE_LDFLAGS=$LDFLAGS
347     LDFLAGS="$LDFLAGS -Wl,-z,relro"
348     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
349                   AC_MSG_RESULT([no])
350                   LDFLAGS=$_SAVE_LDFLAGS)
352     AC_MSG_CHECKING([for -z nocopyreloc option to ld])
353     _SAVE_LDFLAGS=$LDFLAGS
354     LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
355     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
356                   AC_MSG_RESULT([no])
357                   LDFLAGS=$_SAVE_LDFLAGS)
359     AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
360     _SAVE_LDFLAGS=$LDFLAGS
361     LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
362     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
363                   AC_MSG_RESULT([no])
364                   LDFLAGS=$_SAVE_LDFLAGS)
366     AC_MSG_CHECKING([for --build-id=sha1 option to ld])
367     _SAVE_LDFLAGS=$LDFLAGS
368     LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
369     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
370                   AC_MSG_RESULT([no])
371                   LDFLAGS=$_SAVE_LDFLAGS)
373     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
374     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
375     _SAVE_LDFLAGS=$LDFLAGS
376     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
377     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
378                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
379                   AC_MSG_RESULT([no]))
380     LDFLAGS=$_SAVE_LDFLAGS
382     # Check for -mssse3 on $CC
383     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
384     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
385     _SAVE_CFLAGS=$CFLAGS
386     CFLAGS="$CFLAGS -mssse3"
387     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
388                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
389                      AC_MSG_RESULT([no]))
390     CFLAGS=$_SAVE_CFLAGS
392     # Check for -msse4.1 on $CC
393     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
394     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
395     _SAVE_CFLAGS=$CFLAGS
396     CFLAGS="$CFLAGS -msse4.1"
397     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
398                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
399                      AC_MSG_RESULT([no]))
400     CFLAGS=$_SAVE_CFLAGS
402     case "${CPU_ARCH}" in
403     x86 | x86_64)
404       AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
405       AC_TRY_COMPILE([],
406                      [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
407                      result="yes", result="no")
408       AC_MSG_RESULT("$result")
409       if test "$result" = "yes"; then
410           HAVE_X86_AVX2=1
411       fi
412       ;;
414     ppc*)
415       AC_MSG_CHECKING([whether we can enable AltiVec support])
416       HAVE_ALTIVEC=
417       _SAVE_CFLAGS=$CFLAGS
418       CFLAGS="$CFLAGS -maltivec"
419       AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
420                        [HAVE_ALTIVEC=1],
421                        AC_MSG_RESULT([no]))
422       CFLAGS=$_SAVE_CFLAGS
423       ;;
424     esac
426     DSO_LDOPTS='-shared'
427     if test "$GCC_USE_GNU_LD"; then
428         # Some tools like ASan use a runtime library that is only
429         # linked against executables, so we must allow undefined
430         # symbols for shared objects in some cases.
431         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
432             # Don't allow undefined symbols in libraries
433             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
435             # BSDs need `environ' exposed for posix_spawn (bug 753046)
436             case "$OS_TARGET" in
437             DragonFly|FreeBSD|NetBSD|OpenBSD)
438                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
439                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
440                 else
441                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
442                 fi
443                 ;;
444             esac
445         fi
446     fi
448     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
449     _USE_CPP_INCLUDE_FLAG=1
451     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
454 if test "$GNU_CXX"; then
455     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
457     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
458     _USE_CPP_INCLUDE_FLAG=1
461 # For profiling builds keep the symbol information
462 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
463     case "$OS_TARGET" in
464     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
465         STRIP_FLAGS="--strip-debug"
466         ;;
467     esac
470 dnl ========================================================
471 dnl = Enable DMD
472 dnl ========================================================
474 if test "$MOZ_DMD"; then
475     if test "${CPU_ARCH}" = "arm"; then
476         CFLAGS="$CFLAGS -funwind-tables"
477         CXXFLAGS="$CXXFLAGS -funwind-tables"
478     fi
481 dnl ========================================================
482 dnl System overrides of the defaults for host
483 dnl ========================================================
484 case "$host" in
485 *mingw*)
486     if test -n "$_WIN32_MSVC"; then
487         HOST_CFLAGS="$HOST_CFLAGS"
488     else
489         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
490     fi
491     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
492     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
493     HOST_BIN_SUFFIX=.exe
495     case "${host_cpu}" in
496     i*86)
497         if test -n "$_WIN32_MSVC"; then
498             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
499         fi
500         ;;
501     x86_64)
502         if test -n "$_WIN32_MSVC"; then
503             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
504         fi
505         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
506         ;;
507     esac
508     ;;
510 *-darwin*)
511     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
512     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
513     ;;
515 *-linux*|*-kfreebsd*-gnu|*-gnu*)
516     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
517     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
518     ;;
521     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
522     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
523     ;;
524 esac
526 dnl ========================================================
527 dnl System overrides of the defaults for target
528 dnl ========================================================
530 case "$target" in
531 *-darwin*)
532     MOZ_OPTIMIZE_FLAGS="-O3"
533     CXXFLAGS="$CXXFLAGS -stdlib=libc++"
534     DSO_LDOPTS=''
535     STRIP_FLAGS="$STRIP_FLAGS -x -S"
536     # Ensure that if we're targeting iOS an SDK was provided.
537     AC_CACHE_CHECK(for iOS target,
538                    ac_cv_ios_target,
539                    [AC_TRY_COMPILE([#include <TargetConditionals.h>
540 #if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
541 #error not iOS
542 #endif],
543                                    [],
544                                    ac_cv_ios_target="yes",
545                                    ac_cv_ios_target="no")])
546     if test "$ac_cv_ios_target" = "yes" -a -z $MOZ_IOS; then
547        AC_MSG_ERROR([targeting iOS but not using an iOS SDK?])
548     fi
549     if test -z "$MOZ_IOS"; then
550         # The ExceptionHandling framework is needed for Objective-C exception
551         # logging code in nsObjCExceptions.h. Currently we only use that in debug
552         # builds.
553         MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
554     fi
556     dnl DTrace and -dead_strip don't interact well. See bug 403132.
557     dnl ===================================================================
558     if test "x$enable_dtrace" = "xyes"; then
559         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
560     else
561         dnl check for the presence of the -dead_strip linker flag
562         AC_MSG_CHECKING([for -dead_strip option to ld])
563         _SAVE_LDFLAGS=$LDFLAGS
564         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
565         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
566         if test -n "$_HAVE_DEAD_STRIP" ; then
567             AC_MSG_RESULT([yes])
568             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
569         else
570             AC_MSG_RESULT([no])
571         fi
573         LDFLAGS=$_SAVE_LDFLAGS
574     fi
576     MOZ_FIX_LINK_PATHS="-Wl,-executable_path,${DIST}/bin"
577     ;;
579 *-android*|*-linuxandroid*)
580     if test "$COMPILE_ENVIRONMENT" -a -n "$MOZ_MEMORY"; then
581         MOZ_LINKER=1
582     fi
584     MOZ_GFX_OPTIMIZE_MOBILE=1
585     if test -z "$CLANG_CC"; then
586         MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
587     else
588         MOZ_OPTIMIZE_FLAGS="-O2"
589     fi
590     ;;
592 *-*linux*)
593     if test "$GNU_CC" -o "$GNU_CXX"; then
594         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
595         if test -n "$MOZ_DEBUG"; then
596             MOZ_OPTIMIZE_FLAGS="-Os"
597         else
598             MOZ_OPTIMIZE_FLAGS="-O2"
599         fi
600         if test -z "$CLANG_CC"; then
601            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
602         fi
603     fi
605     case "${target_cpu}" in
606     alpha*)
607         CFLAGS="$CFLAGS -mieee"
608         CXXFLAGS="$CXXFLAGS -mieee"
609     ;;
610     esac
611     ;;
612 *-mingw*)
613     DSO_CFLAGS=
614     DSO_PIC_CFLAGS=
615     # certain versions of cygwin's makedepend barf on the
616     # #include <string> vs -I./dist/include/string issue so don't use it
617     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
618         # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
619         if test -z "$CLANG_CC"; then
620             AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
621         fi
623         DSO_LDOPTS='-shared'
624         # Use temp file for windres (bug 213281)
625         RCFLAGS='-O coff --use-temp-file'
626         # mingw doesn't require kernel32, user32, and advapi32 explicitly
627         LIBS="$LIBS -luuid -lusp10 -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32"
628         MOZ_FIX_LINK_PATHS=
630         MOZ_OPTIMIZE_FLAGS="-O2"
632         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
633         WIN32_GUI_EXE_LDFLAGS=-mwindows
635         # Silence problematic clang warnings
636         CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
637         LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
638     else
639         TARGET_COMPILER_ABI=msvc
640         RANLIB='echo not_ranlib'
641         STRIP='echo not_strip'
642         PKG_SKIP_STRIP=1
643         # aarch64 doesn't support subsystems below 6.02
644         if test "$CPU_ARCH" = "aarch64"; then
645             WIN32_SUBSYSTEM_VERSION=6.02
646         else
647             WIN32_SUBSYSTEM_VERSION=6.01
648         fi
649         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
650         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
651         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
652         _USE_CPP_INCLUDE_FLAG=1
653         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
654         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
655         CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
656         CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
657         if test -z "$CLANG_CL"; then
658             CPPFLAGS="$CPPFLAGS -utf-8"
659         fi
660         if test "$CPU_ARCH" = "x86"; then
661             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
662             dnl more recent, so set that explicitly here unless another
663             dnl target arch has already been set.
664             changequote(,)
665             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
666               CFLAGS="$CFLAGS -arch:SSE2"
667             fi
668             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
669               CXXFLAGS="$CXXFLAGS -arch:SSE2"
670             fi
671             changequote([,])
672             SSE_FLAGS="-arch:SSE"
673             SSE2_FLAGS="-arch:SSE2"
674             dnl MSVC allows the use of intrinsics without any flags
675             dnl and doesn't have a separate arch for SSSE3
676             SSSE3_FLAGS="-arch:SSE2"
677         fi
678         dnl clang-cl requires appropriate flags to enable SSSE3 support
679         dnl on all architectures.
680         if test -n "$CLANG_CL"; then
681             SSSE3_FLAGS="-mssse3"
682         fi
683         dnl VS2013+ supports -Gw for better linker optimizations.
684         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
685         dnl Disabled on ASan because it causes false-positive ODR violations.
686         if test -z "$MOZ_ASAN"; then
687             CFLAGS="$CFLAGS -Gw"
688             CXXFLAGS="$CXXFLAGS -Gw"
689         else
690             # String tail merging doesn't play nice with ASan's ODR checker.
691             LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
692         fi
693         if test -n "$CLANG_CL"; then
694             # XXX We should combine some of these with our generic GCC-style
695             # warning checks.
696             #
697             # Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
698             CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
699             # We use offsetof on non-POD objects all the time.
700             # We also suppress this warning on other platforms.
701             CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
702             # This warns for reasonable things like:
703             #   enum { X = 0xffffffffU };
704             # which is annoying for IDL headers.
705             CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
706             # This warns for cases that would be reached by the Microsoft
707             # #include rules, but also currently warns on cases that would
708             # *also* be reached by standard C++ include rules.  That
709             # behavior doesn't seem useful, so we turn it off.
710             CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
711             # We normally error out on unknown pragmas, but since clang-cl
712             # claims to be MSVC, it would be difficult to add
713             # #if defined(_MSC_VER) && !defined(__clang__) everywhere we
714             # use such pragmas, so just ignore them.
715             CFLAGS="$CFLAGS -Wno-unknown-pragmas"
716             CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
717             # We get errors about various #pragma intrinsic directives from
718             # clang-cl, and we don't need to hear about those.
719             CFLAGS="$CFLAGS -Wno-ignored-pragmas"
720             CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
721             # clang-cl's Intrin.h marks things like _ReadWriteBarrier
722             # as __attribute((__deprecated__)).  This is nice to know,
723             # but since we don't get the equivalent warning from MSVC,
724             # let's just ignore it.
725             CFLAGS="$CFLAGS -Wno-deprecated-declarations"
726             CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
727             # We use a function like:
728             #   __declspec(noreturn) __inline void f() {}
729             # which -Winvalid-noreturn complains about.  Again, MSVC seems
730             # OK with it, so let's silence the warning.
731             CFLAGS="$CFLAGS -Wno-invalid-noreturn"
732             CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
733             # Missing |override| on virtual function declarations isn't
734             # something that MSVC currently warns about.
735             CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
736             # We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
737             # declaration on |operator delete(void*)|.  However, clang-cl
738             # must internally declare |operator delete(void*)| differently,
739             # which causes this warning for virtually every file in the
740             # tree.  clang-cl doesn't support -fno-exceptions or equivalent,
741             # so there doesn't seem to be any way to convince clang-cl to
742             # declare |delete| differently.  Therefore, suppress this
743             # warning.
744             CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
745             # Macros like STDMETHOD() and IFACEMETHOD() can declare
746             # __attribute__((nothrow)) on their respective method declarations,
747             # while the definitions are left without the matching attribute.
748             CXXFLAGS="$CXXFLAGS -Wno-microsoft-exception-spec"
749             # At least one MSVC header and several headers in-tree have
750             # unused typedefs, so turn this on.
751             CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
752             # jemalloc uses __declspec(allocator) as a profiler hint,
753             # which clang-cl doesn't understand.
754             CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
755             # __attribute__((unused)) really means "might be unused" and
756             # we use it to avoid warnings about things that are unused
757             # in some compilation units, but used in many others.  This
758             # warning insists on complaining about the latter case, which
759             # is annoying, and rather noisy.
760             CXXFLAGS="$CXXFLAGS -Wno-used-but-marked-unused"
761         fi
762         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
763         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
764         LIBS="$LIBS user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib"
765         MOZ_DEBUG_LDFLAGS='-DEBUG'
766         # Use a higher optimization level for clang-cl, so we can come closer
767         # to MSVC's performance numbers (see bug 1443590).
768         if test -n "$CLANG_CL"; then
769             MOZ_OPTIMIZE_FLAGS='-O2'
770         else
771             MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
772         fi
773         MOZ_FIX_LINK_PATHS=
774         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
775         if test -z "$DEVELOPER_OPTIONS"; then
776             LDFLAGS="$LDFLAGS -RELEASE"
777         fi
778         RCFLAGS="-nologo"
779         dnl Minimum reqiurement of Gecko is VS2015 or later which supports
780         dnl both SSSE3 and SSE4.1.
781         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
782         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
783         dnl allow AVX2 code from VS2015
784         HAVE_X86_AVX2=1
785     fi
786     AC_DEFINE(WIN32_LEAN_AND_MEAN)
787     dnl See http://support.microsoft.com/kb/143208 to use STL
788     AC_DEFINE(NOMINMAX)
789     BIN_SUFFIX='.exe'
790     MOZ_USER_DIR="Mozilla"
792     case "$host_os" in
793     cygwin*|msvc*|mks*)
794         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.])
795         ;;
796     esac
798     case "$target" in
799     i*86-*)
800         if test -n "$GNU_CC"; then
801             CFLAGS="$CFLAGS -mstackrealign"
802             CXXFLAGS="$CXXFLAGS -mstackrealign"
803             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
804         else
805             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
806             LDFLAGS="$LDFLAGS -SAFESEH"
807         fi
809         AC_DEFINE(_X86_)
810         ;;
811     x86_64-*)
812         if test -n "$_WIN32_MSVC"; then
813             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
814         fi
815         AC_DEFINE(_AMD64_)
816         ;;
817     aarch64-*)
818         if test -n "$_WIN32_MSVC"; then
819             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
820         fi
821         AC_DEFINE(_ARM64_)
822         ;;
823     *)
824         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
825         ;;
826     esac
827     ;;
829 *-netbsd*)
830     DSO_CFLAGS=''
831     CFLAGS="$CFLAGS -Dunix"
832     CXXFLAGS="$CXXFLAGS -Dunix"
833     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
834         DSO_PIC_CFLAGS='-fPIC -DPIC'
835         DSO_LDOPTS='-shared'
836         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
837     else
838         DSO_PIC_CFLAGS='-fPIC -DPIC'
839         DSO_LDOPTS='-shared'
840     fi
841     # This will fail on a.out systems prior to 1.5.1_ALPHA.
842     if test "$LIBRUNPATH"; then
843         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
844     fi
845     ;;
847 *-openbsd*)
848     if test -z "$X11BASE"; then
849         X11BASE=/usr/X11R6
850     fi
851     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
852     DSO_CFLAGS=''
853     DSO_PIC_CFLAGS='-fPIC'
854     DSO_LDOPTS='-shared -fPIC'
855     if test "$LIBRUNPATH"; then
856         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
857     fi
858     ;;
860 *-solaris*)
861     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
862     ;;
864 esac
866 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
867     MOZ_OPTIMIZE_FLAGS="-O"
870 AC_SUBST_LIST(MMX_FLAGS)
871 AC_SUBST_LIST(SSE_FLAGS)
872 AC_SUBST_LIST(SSE2_FLAGS)
873 AC_SUBST_LIST(SSSE3_FLAGS)
875 AC_SUBST(MOZ_LINKER)
876 if test -n "$MOZ_LINKER"; then
877   AC_DEFINE(MOZ_LINKER)
878   MOZ_LINKER_EXTRACT=1
879   AC_CHECK_PROGS(XZ, xz)
882 if test -z "$COMPILE_ENVIRONMENT"; then
883     SKIP_COMPILER_CHECKS=1
884     SKIP_LIBRARY_CHECKS=1
885     PKG_SKIP_STRIP=1
886     MOZ_DEBUGGING_OPTS
887 else
888     MOZ_COMPILER_OPTS
889 fi # COMPILE_ENVIRONMENT
891 if test -z "$SKIP_COMPILER_CHECKS"; then
892 dnl Checks for typedefs, structures, and compiler characteristics.
893 dnl ========================================================
894 AC_C_CONST
895 AC_TYPE_MODE_T
896 AC_TYPE_OFF_T
897 AC_TYPE_PID_T
898 AC_TYPE_SIZE_T
899 AC_LANG_CPLUSPLUS
900 AC_LANG_C
902 AC_LANG_CPLUSPLUS
904 MOZ_CXX11
906 AC_LANG_C
908 case "${OS_TARGET}" in
909 Darwin)
910   ;;
912   STL_FLAGS="-I${DIST}/stl_wrappers"
913   WRAP_STL_INCLUDES=1
914   ;;
915 esac
917 if test "$MOZ_BUILD_APP" = "tools/crashreporter"; then
918     WRAP_STL_INCLUDES=
921 dnl Checks for header files.
922 dnl ========================================================
923 AC_HEADER_DIRENT
924 case "$target_os" in
925 bitrig*|dragonfly*|freebsd*|openbsd*)
926 # for stuff like -lXshm
927     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
928     ;;
929 esac
931 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
932 AC_CACHE_CHECK(for sockaddr_in.sin_len,
933                    ac_cv_sockaddr_in_sin_len,
934                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
935                                     #include <sys/types.h>
936                                     #endif
937                                     #include <netinet/in.h>
938                                     struct sockaddr_in x;
939                                     void *foo = (void*) &x.sin_len;],
940                                    [],
941                                    [ac_cv_sockaddr_in_sin_len=true],
942                                    [ac_cv_sockaddr_in_sin_len=false])])
943 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
944   AC_DEFINE(HAVE_SIN_LEN)
945 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
946   AC_DEFINE(HAVE_SCONN_LEN)
949 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
950                ac_cv_sockaddr_in6_sin6_len,
951                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
952                                 #include <sys/types.h>
953                                 #endif
954                                 #include <netinet/in.h>
955                                 struct sockaddr_in6 x;
956                                 void *foo = (void*) &x.sin6_len;],
957                                [],
958                                [ac_cv_sockaddr_in6_sin6_len=true],
959                                [ac_cv_sockaddr_in6_sin6_len=false])])
960 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
961   AC_DEFINE(HAVE_SIN6_LEN)
964 AC_CACHE_CHECK(for sockaddr.sa_len,
965                ac_cv_sockaddr_sa_len,
966                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
967                                 #include <sys/types.h>
968                                 #endif
969                                 #include <sys/socket.h>
970                                 struct sockaddr x;
971                                 void *foo = (void*) &x.sa_len;],
972                                [],
973                                [ac_cv_sockaddr_sa_len=true],
974                                [ac_cv_sockaddr_sa_len=false])])
975 if test "$ac_cv_sockaddr_sa_len" = true ; then
976   AC_DEFINE(HAVE_SA_LEN)
979 MOZ_ARG_ENABLE_BOOL(dtrace,
980               [  --enable-dtrace         build with dtrace support if available (default=no)],
981               [enable_dtrace="yes"],)
982 if test "x$enable_dtrace" = "xyes"; then
983   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
984   if test -n "$HAVE_DTRACE"; then
985       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
986   else
987       AC_MSG_ERROR([dtrace enabled but sys/sdt.h not found]);
988   fi
990 AC_SUBST(HAVE_DTRACE)
992 dnl Checks for libraries.
993 dnl ========================================================
994 AC_CHECK_LIB(c_r, gethostbyname_r)
996 dnl We don't want to link with libdl even if it's present on OS X, since
997 dnl it's not used and not part of the default installation. OS/2 has dlfcn
998 dnl in libc.
999 dnl We don't want to link against libm or libpthread on Darwin since
1000 dnl they both are just symlinks to libSystem and explicitly linking
1001 dnl against libSystem causes issues when debugging (see bug 299601).
1002 case $target in
1003 *-darwin*)
1004     ;;
1006     AC_SEARCH_LIBS(dlopen, dl,
1007         MOZ_CHECK_HEADER(dlfcn.h,
1008         AC_DEFINE(HAVE_DLOPEN)))
1009     ;;
1010 esac
1012 _SAVE_CFLAGS="$CFLAGS"
1013 CFLAGS="$CFLAGS -D_GNU_SOURCE"
1014 AC_CHECK_FUNCS(dladdr memmem)
1015 CFLAGS="$_SAVE_CFLAGS"
1017 if test ! "$GNU_CXX"; then
1018     AC_CHECK_LIB(C, demangle)
1021 AC_CHECK_LIB(socket, socket)
1023 XLDFLAGS="$X_LIBS"
1024 XLIBS="$X_EXTRA_LIBS"
1026 dnl ========================================================
1027 dnl Checks for X libraries.
1028 dnl Ordering is important.
1029 dnl Xt is dependent upon SM as of X11R6
1030 dnl ========================================================
1031 if test -n "$MOZ_X11"; then
1032     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
1033     _SAVE_LDFLAGS="$LDFLAGS"
1034     _SAVE_LIBS="$LIBS"
1035     LDFLAGS="$XLDFLAGS $LDFLAGS"
1036     AC_CHECK_LIB(X11, XDrawLines, [XLIBS="-lX11 $XLIBS"],
1037         [MISSING_X="$MISSING_X -lX11"], $XLIBS)
1038     AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
1039         [MISSING_X="$MISSING_X -lXext"], $XLIBS)
1041     AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
1042         unset ac_cv_lib_Xt_XtFree
1043         AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
1044         AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
1045         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
1046             [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
1047         ])
1049     dnl ========================================================
1050     dnl = Check for xcb
1051     dnl ========================================================
1052     AC_CHECK_LIB(xcb, xcb_connect, [XLIBS="-lxcb $XLIBS"],
1053         [MISSING_X="$MISSING_X -lxcb"], $XLIBS)
1054     AC_CHECK_LIB(xcb-shm, xcb_shm_query_version, [XLIBS="-lxcb-shm $XLIBS"],
1055         [MISSING_X="$MISSING_X -lxcb-shm"], $XLIBS)
1056     AC_CHECK_LIB(X11-xcb, XGetXCBConnection, [XLIBS="-lX11-xcb $XLIBS"],
1057         [MISSING_X="$MISSING_X -lX11-xcb"], $XLIBS)
1059     LDFLAGS="$_SAVE_LDFLAGS"
1060     LIBS="$_SAVE_LIBS"
1061 fi # $MOZ_X11
1063 AC_SUBST_LIST(XCFLAGS)
1064 AC_SUBST_LIST(XLDFLAGS)
1065 AC_SUBST_LIST(XLIBS)
1066 AC_SUBST_LIST(XEXT_LIBS)
1067 AC_SUBST_LIST(XT_LIBS)
1069 dnl ========================================================
1070 dnl = pthread support
1071 dnl = Start by checking whether the system support pthreads
1072 dnl ========================================================
1073 case "$target_os" in
1074 darwin*)
1075     MOZ_USE_PTHREADS=1
1076     ;;
1078     AC_CHECK_LIB(pthreads, pthread_create,
1079         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
1080         AC_CHECK_LIB(pthread, pthread_create,
1081             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
1082             AC_CHECK_LIB(c_r, pthread_create,
1083                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
1084                 AC_CHECK_LIB(c, pthread_create,
1085                     MOZ_USE_PTHREADS=1
1086                 )
1087             )
1088         )
1089     )
1090     ;;
1091 esac
1093 dnl ========================================================
1094 dnl Do the platform specific pthread hackery
1095 dnl ========================================================
1096 if test "$MOZ_USE_PTHREADS"x != x
1097 then
1098     dnl
1099     dnl See if -pthread is supported.
1100     dnl
1101     rm -f conftest*
1102     ac_cv_have_dash_pthread=no
1103     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
1104     echo 'int main() { return 0; }' | cat > conftest.c
1105     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
1106     if test $? -eq 0; then
1107         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1108             ac_cv_have_dash_pthread=yes
1109             case "$target_os" in
1110             freebsd*)
1111 # Freebsd doesn't use -pthread for compiles, it uses them for linking
1112                 ;;
1113             *)
1114                 CFLAGS="$CFLAGS -pthread"
1115                 CXXFLAGS="$CXXFLAGS -pthread"
1116                 ;;
1117             esac
1118         fi
1119     fi
1120     rm -f conftest*
1121     AC_MSG_RESULT($ac_cv_have_dash_pthread)
1123     dnl
1124     dnl See if -pthreads is supported.
1125     dnl
1126     ac_cv_have_dash_pthreads=no
1127     if test "$ac_cv_have_dash_pthread" = "no"; then
1128         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
1129         echo 'int main() { return 0; }' | cat > conftest.c
1130         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
1131         if test $? -eq 0; then
1132             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1133                 ac_cv_have_dash_pthreads=yes
1134                 CFLAGS="$CFLAGS -pthreads"
1135                 CXXFLAGS="$CXXFLAGS -pthreads"
1136             fi
1137         fi
1138         rm -f conftest*
1139         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
1140     fi
1142     case "$target" in
1143         *-*-freebsd*)
1144             AC_DEFINE(_REENTRANT)
1145             AC_DEFINE(_THREAD_SAFE)
1146             dnl -pthread links in -lpthread, so don't specify it explicitly.
1147             if test "$ac_cv_have_dash_pthread" = "yes"; then
1148                 _PTHREAD_LDFLAGS="-pthread"
1149             fi
1150             ;;
1152         *-*-openbsd*|*-*-bsdi*)
1153             AC_DEFINE(_REENTRANT)
1154             AC_DEFINE(_THREAD_SAFE)
1155             dnl -pthread links in -lc_r, so don't specify it explicitly.
1156             if test "$ac_cv_have_dash_pthread" = "yes"; then
1157                 _PTHREAD_LDFLAGS="-pthread"
1158             fi
1159             ;;
1161         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
1162             AC_DEFINE(_REENTRANT)
1163             ;;
1165     esac
1166     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
1167     AC_SUBST(MOZ_USE_PTHREADS)
1168     MOZ_CHECK_HEADERS(pthread.h)
1172 dnl Checks for library functions.
1173 dnl ========================================================
1174 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall)
1176 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
1177 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
1178                ac_cv_clock_monotonic,
1179                [for libs in "" -lrt; do
1180                     _SAVE_LIBS="$LIBS"
1181                     _SAVE_CFLAGS="$CFLAGS"
1182                     LIBS="$LIBS $libs"
1183                     CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
1184 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
1185 dnl we should or not be able to use it. To detect if we can, we need to make the
1186 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
1187                     AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
1188                                  #include <time.h>],
1189                                  [ struct timespec ts;
1190                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
1191                                  ac_cv_clock_monotonic=$libs
1192                                  LIBS="$_SAVE_LIBS"
1193                                  break,
1194                                  ac_cv_clock_monotonic=no)
1195                     LIBS="$_SAVE_LIBS"
1196                     CFLAGS="$_SAVE_CFLAGS"
1197                 done])
1198 if test "$ac_cv_clock_monotonic" != "no"; then
1199     HAVE_CLOCK_MONOTONIC=1
1200     REALTIME_LIBS=$ac_cv_clock_monotonic
1201     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
1202     AC_SUBST(HAVE_CLOCK_MONOTONIC)
1203     AC_SUBST_LIST(REALTIME_LIBS)
1206 dnl Turn on warnings-as-errors to prevent implicit declaration of
1207 dnl pthread_cond_timedwait_monotonic_np, which can cause this test to
1208 dnl inadvertently pass even if the function does not really exist.
1209 _SAVE_CFLAGS="$CFLAGS"
1210 CFLAGS="$CFLAGS $WARNINGS_AS_ERRORS"
1211 AC_CACHE_CHECK(for pthread_cond_timedwait_monotonic_np,
1212                ac_cv_pthread_cond_timedwait_monotonic_np,
1213                AC_TRY_LINK([#include <pthread.h>],
1214                            [pthread_cond_timedwait_monotonic_np(0, 0, 0);],
1215                            ac_cv_pthread_cond_timewait_monotonic_np=yes,
1216                            ac_cv_pthread_cond_timewait_monotonic_np=no))
1217 if test "$ac_cv_pthread_cond_timewait_monotonic_np" != "no"; then
1218     AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
1220 CFLAGS=$_SAVE_CFLAGS
1222 AC_CACHE_CHECK(
1223     [for res_ninit()],
1224     ac_cv_func_res_ninit,
1225     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
1226         dnl no need for res_ninit() on NetBSD and OpenBSD
1227         ac_cv_func_res_ninit=no
1228      else
1229         AC_TRY_LINK([
1230             #ifdef linux
1231             #define _BSD_SOURCE 1
1232             #endif
1233             #include <sys/types.h>
1234             #include <netinet/in.h>
1235             #include <arpa/nameser.h>
1236             #include <resolv.h>
1237             ],
1238             [int foo = res_ninit(&_res);],
1239             [ac_cv_func_res_ninit=yes],
1240             [ac_cv_func_res_ninit=no])
1241      fi
1242     ])
1244 if test "$ac_cv_func_res_ninit" = "yes"; then
1245     AC_DEFINE(HAVE_RES_NINIT)
1246 dnl must add the link line we do something as foolish as this... dougt
1247 dnl else
1248 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
1249 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
1252 AC_LANG_C
1254 dnl **********************
1255 dnl *** va_copy checks ***
1256 AC_CACHE_CHECK([for an implementation of va_copy()],
1257                ac_cv_va_copy,
1258     [AC_TRY_COMPILE([#include <stdarg.h>
1259                      #include <stdlib.h>
1260         void f (int i, ...) {
1261             va_list args1, args2;
1262             va_start (args1, i);
1263             va_copy (args2, args1);
1264             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1265                 exit (1);
1266             va_end (args1); va_end (args2);
1267         }],
1268         [f(0, 42); return 0],
1269         [ac_cv_va_copy=yes],
1270         [ac_cv_va_copy=no]
1271     )]
1273 AC_CACHE_CHECK([whether va_list can be copied by value],
1274                ac_cv_va_val_copy,
1275     [AC_TRY_COMPILE([#include <stdarg.h>
1276                      #include <stdlib.h>
1277         void f (int i, ...) {
1278             va_list args1, args2;
1279             va_start (args1, i);
1280             args2 = args1;
1281             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1282                 exit (1);
1283             va_end (args1); va_end (args2);
1284         }],
1285         [f(0, 42); return 0],
1286         [ac_cv_va_val_copy=yes],
1287         [ac_cv_va_val_copy=no],
1288     )]
1290 if test "x$ac_cv_va_copy" = "xyes"; then
1291     AC_DEFINE(VA_COPY, va_copy)
1292     AC_DEFINE(HAVE_VA_COPY)
1295 if test "x$ac_cv_va_val_copy" = "xno"; then
1296    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
1299 dnl ===================================================================
1300 dnl ========================================================
1301 dnl Put your C++ language/feature checks below
1302 dnl ========================================================
1303 AC_LANG_CPLUSPLUS
1305 ARM_ABI_PREFIX=
1306 if test "$GNU_CC"; then
1307   if test "$CPU_ARCH" = "arm" ; then
1308     AC_CACHE_CHECK(for ARM EABI,
1309         ac_cv_gcc_arm_eabi,
1310         [AC_TRY_COMPILE([],
1311                         [
1312 #if defined(__ARM_EABI__)
1313   return 0;
1314 #else
1315 #error Not ARM EABI.
1316 #endif
1317                         ],
1318                         ac_cv_gcc_arm_eabi="yes",
1319                         ac_cv_gcc_arm_eabi="no")])
1320     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
1321         HAVE_ARM_EABI=1
1322         ARM_ABI_PREFIX=eabi-
1323     else
1324         ARM_ABI_PREFIX=oabi-
1325     fi
1326   fi
1328   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
1331 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
1332 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
1333 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
1334 # linking XUL.
1335 _SAVE_LDFLAGS=$LDFLAGS
1336 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
1337 AC_CACHE_CHECK(for __thread keyword for TLS variables,
1338                ac_cv_thread_keyword,
1339                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
1340                             [return tlsIsMainThread;],
1341                             ac_cv_thread_keyword=yes,
1342                             ac_cv_thread_keyword=no)])
1343 LDFLAGS=$_SAVE_LDFLAGS
1344 # The custom dynamic linker doesn't support TLS variables
1345 MOZ_TLS=
1346 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
1347   # mips builds fail with TLS variables because of a binutils bug.
1348   # See bug 528687
1349   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
1350   case "${target}" in
1351     mips*-*)
1352       :
1353       ;;
1354     *-android*|*-linuxandroid*)
1355       :
1356       ;;
1357     *-openbsd*)
1358       :
1359       ;;
1360     *)
1361       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
1362       MOZ_TLS=1
1363       ;;
1364   esac
1367 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
1368 if test -n "$MOZ_LINKER"; then
1369   if test "$CPU_ARCH" = arm; then
1370     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
1371     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
1372       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1373       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1374     fi
1375   fi
1377 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
1378 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
1379 dnl Since the linker only understands the sysv ones, no need to build the
1380 dnl gnu style tables anyways.
1381   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
1384 dnl End of C++ language/feature checks
1385 AC_LANG_C
1387 dnl ========================================================
1388 dnl =  Internationalization checks
1389 dnl ========================================================
1391 dnl Internationalization and Locale support is different
1392 dnl on various UNIX platforms.  Checks for specific i18n
1393 dnl features go here.
1395 AC_HAVE_FUNCS(localeconv)
1397 fi # ! SKIP_COMPILER_CHECKS
1399 if test -n "${COMPILE_ENVIRONMENT}"; then
1400   MOZ_CHECK_ALLOCATOR
1403 TARGET_XPCOM_ABI=
1404 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1405     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1406     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
1409 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1410 dnl features that Windows actually does support.
1412 if test -n "$SKIP_COMPILER_CHECKS"; then
1413    dnl Windows has malloc.h
1414    AC_DEFINE(MALLOC_H, [<malloc.h>])
1415    AC_DEFINE(HAVE_FORCEINLINE)
1416    AC_DEFINE(HAVE_LOCALECONV)
1417 fi # SKIP_COMPILER_CHECKS
1419 dnl Mozilla specific options
1420 dnl ========================================================
1421 dnl The macros used for command line options
1422 dnl are defined in build/autoconf/altoptions.m4.
1424 dnl ========================================================
1425 dnl =
1426 dnl = Check for external package dependencies
1427 dnl =
1428 dnl ========================================================
1429 MOZ_ARG_HEADER(External Packages)
1431 case "$OS_TARGET" in
1432 WINNT|Darwin|Android)
1433   MOZ_FOLD_LIBS=1
1434   ;;
1436   MOZ_FOLD_LIBS=
1437   ;;
1438 esac
1440 MOZ_CONFIG_NSPR()
1442 dnl ========================================================
1443 dnl system libevent Support
1444 dnl ========================================================
1445 MOZ_ARG_WITH_STRING(system-libevent,
1446 [  --with-system-libevent[=PFX]
1447                           Use system libevent [installed at prefix PFX]],
1448     LIBEVENT_DIR=$withval)
1450 _SAVE_CFLAGS=$CFLAGS
1451 _SAVE_LDFLAGS=$LDFLAGS
1452 _SAVE_LIBS=$LIBS
1453 if test "$LIBEVENT_DIR" = yes; then
1454     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
1455         MOZ_SYSTEM_LIBEVENT=1,
1456         LIBEVENT_DIR=/usr)
1458 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
1459     MOZ_SYSTEM_LIBEVENT=
1460 elif test -z "$MOZ_SYSTEM_LIBEVENT"; then
1461     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
1462     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
1463     MOZ_CHECK_HEADER(event.h,
1464         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
1465              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
1466          fi],
1467         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
1468     AC_CHECK_LIB(event, event_init,
1469                  [MOZ_SYSTEM_LIBEVENT=1
1470                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
1471                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
1472                  [MOZ_SYSTEM_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
1474 CFLAGS=$_SAVE_CFLAGS
1475 LDFLAGS=$_SAVE_LDFLAGS
1476 LIBS=$_SAVE_LIBS
1478 AC_SUBST(MOZ_SYSTEM_LIBEVENT)
1480 dnl ========================================================
1481 dnl = If NSS was not detected in the system,
1482 dnl = use the one in the source tree (mozilla/security/nss)
1483 dnl ========================================================
1485 MOZ_ARG_WITH_BOOL(system-nss,
1486 [  --with-system-nss       Use system installed NSS],
1487     _USE_SYSTEM_NSS=1 )
1489 if test -n "$_USE_SYSTEM_NSS"; then
1490     AM_PATH_NSS(3.51, [MOZ_SYSTEM_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
1493 NSS_CFLAGS="$NSS_CFLAGS -I${DIST}/include/nss"
1494 if test -z "$MOZ_SYSTEM_NSS"; then
1495    case "${OS_ARCH}" in
1496         # Only few platforms have been tested with GYP
1497         WINNT|Darwin|Linux|DragonFly|FreeBSD|NetBSD|OpenBSD|SunOS)
1498             ;;
1499         *)
1500             AC_MSG_ERROR([building in-tree NSS is not supported on this platform. Use --with-system-nss])
1501             ;;
1502    esac
1505 dnl system ZLIB support
1506 dnl ========================================================
1507 MOZ_ZLIB_CHECK([1.2.3])
1509 if test -z "$SKIP_LIBRARY_CHECKS"; then
1511 dnl ========================================================
1512 dnl system PNG Support
1513 dnl ========================================================
1514 MOZ_ARG_WITH_STRING(system-png,
1515 [  --with-system-png[=PFX]
1516                           Use system libpng [installed at prefix PFX]],
1517     PNG_DIR=$withval)
1519 _SAVE_CFLAGS=$CFLAGS
1520 _SAVE_LDFLAGS=$LDFLAGS
1521 _SAVE_LIBS=$LIBS
1522 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
1523     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
1524     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
1526 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
1527     MOZ_SYSTEM_PNG=
1528 else
1529     AC_CHECK_LIB(png, png_get_valid, [MOZ_SYSTEM_PNG=1 MOZ_PNG_LIBS="-lpng"],
1530                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1531     AC_CHECK_LIB(png, png_get_acTL, ,
1532                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
1534 if test "$MOZ_SYSTEM_PNG" = 1; then
1535     AC_TRY_COMPILE([ #include <stdio.h>
1536                      #include <sys/types.h>
1537                      #include <png.h> ],
1538                    [ #if PNG_LIBPNG_VER < $MOZPNG
1539                      #error "Insufficient libpng version ($MOZPNG required)."
1540                      #endif
1541                      #ifndef PNG_UINT_31_MAX
1542                      #error "Insufficient libpng version."
1543                      #endif ],
1544                    MOZ_SYSTEM_PNG=1,
1545                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1547 CFLAGS=$_SAVE_CFLAGS
1548 LDFLAGS=$_SAVE_LDFLAGS
1549 LIBS=$_SAVE_LIBS
1551 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_SYSTEM_PNG" = 1; then
1552     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
1553     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
1556 fi # SKIP_LIBRARY_CHECKS
1558 dnl ========================================================
1559 dnl =
1560 dnl = Application
1561 dnl =
1562 dnl ========================================================
1564 MOZ_ARG_HEADER(Application)
1566 ENABLE_SYSTEM_EXTENSION_DIRS=1
1567 MOZ_BRANDING_DIRECTORY=
1568 MOZ_OFFICIAL_BRANDING=
1569 MOZ_AUTH_EXTENSION=1
1570 if test "$MOZ_IOS"; then
1571    MOZ_AUTH_EXTENSION=
1573 MOZ_PREF_EXTENSIONS=1
1574 MOZ_SPELLCHECK=1
1575 MOZ_UNIVERSALCHARDET=1
1576 MOZ_XUL=1
1577 MOZ_ZIPWRITER=1
1578 MOZ_NO_SMART_CARDS=
1579 NECKO_COOKIES=1
1580 MOZ_USE_NATIVE_POPUP_WINDOWS=
1581 MOZ_EXCLUDE_HYPHENATION_DICTIONARIES=
1582 MOZ_SANDBOX=1
1583 MOZ_BINARY_EXTENSIONS=
1584 MOZ_DEVTOOLS=server
1586 case "$target_os" in
1587     mingw*)
1588         NS_ENABLE_TSF=1
1589         AC_DEFINE(NS_ENABLE_TSF)
1590         ;;
1591 esac
1593 # Optional Firefox for Android partner distribution directory.
1594 MOZ_ARG_WITH_STRING(android-distribution-directory,
1595 [  --with-android-distribution-directory=dir
1596                           Optional Firefox for Android partner distribution directory.],
1597   MOZ_ANDROID_DISTRIBUTION_DIRECTORY=$withval)
1599 if test -n "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY"; then
1600   # A distribution directory must have an assets/distribution directory.
1601   # See https://wiki.mozilla.org/Mobile/Distribution_Files.
1602   if test ! -d "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY/assets/distribution" ; then
1603     AC_MSG_ERROR([--with-android-distribution-directory does not contain assets/distribution;
1604                   (looked for ${MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets/distribution).])
1605   fi
1607 AC_SUBST(MOZ_ANDROID_DISTRIBUTION_DIRECTORY)
1609 dnl ========================================================
1610 dnl = Trademarked Branding
1611 dnl ========================================================
1612 MOZ_ARG_ENABLE_BOOL(official-branding,
1613 [  --enable-official-branding
1614                           Enable Official mozilla.org Branding
1615                           Do not distribute builds with
1616                           --enable-official-branding unless you have
1617                           permission to use trademarks per
1618                           http://www.mozilla.org/foundation/trademarks/ .],
1619     MOZ_OFFICIAL_BRANDING=1,
1620     MOZ_OFFICIAL_BRANDING=)
1622 # Allow the application to influence configure with a confvars.sh script.
1623 AC_MSG_CHECKING([if app-specific confvars.sh exists])
1624 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
1625   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
1626   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
1627 else
1628   AC_MSG_RESULT([no])
1631 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
1632 MOZ_ARG_WITH_STRING(app-name,
1633 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
1634 WITH_APP_NAME=$withval,
1637 if test -n "$WITH_APP_NAME" ; then
1638     MOZ_APP_NAME="$WITH_APP_NAME"
1641 MOZ_ARG_WITH_STRING(app-basename,
1642 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
1643 WITH_APP_BASENAME=$withval,
1646 if test -n "$WITH_APP_BASENAME" ; then
1647     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
1650 dnl ========================================================
1651 dnl Ensure Android SDK and build-tools versions depending on
1652 dnl mobile target.
1653 dnl ========================================================
1655 case "$MOZ_BUILD_APP" in
1656 mobile/android)
1657     MOZ_ANDROID_SDK
1658     ;;
1659 esac
1661 dnl ========================================================
1662 dnl =
1663 dnl = Toolkit Options
1664 dnl =
1665 dnl ========================================================
1666 MOZ_ARG_HEADER(Toolkit Options)
1668 dnl ========================================================
1669 dnl = Enable the toolkit as needed                         =
1670 dnl ========================================================
1672 case "$MOZ_WIDGET_TOOLKIT" in
1674 cocoa)
1675     LDFLAGS="$LDFLAGS -framework Cocoa"
1676     # Use -Wl as a trick to avoid -framework and framework names from
1677     # being separated by AC_SUBST_LIST.
1678     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'
1679     TK_CFLAGS=""
1680     CFLAGS="$CFLAGS $TK_CFLAGS"
1681     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
1682     MOZ_USER_DIR="Mozilla"
1683     MOZ_FS_LAYOUT=bundle
1684     ;;
1686 uikit)
1687     LDFLAGS="$LDFLAGS -framework UIKit"
1688     TK_CFLAGS=""
1689     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'
1690     CFLAGS="$CFLAGS $TK_CFLAGS"
1691     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
1692     MOZ_USER_DIR="Mozilla"
1693     MOZ_FS_LAYOUT=bundle
1694     ;;
1696 esac
1698 if test "$OS_TARGET" = Darwin; then
1699     LDFLAGS="$LDFLAGS -lobjc"
1702 dnl there are a lot of tests on MOZ_ENABLE_GTK below, that are more convenient
1703 dnl to keep that way than testing against MOZ_WIDGET_TOOLKIT
1704 case "$MOZ_WIDGET_TOOLKIT" in
1705 gtk*)
1706     MOZ_ENABLE_GTK=1
1707     ;;
1708 esac
1710 if test "$COMPILE_ENVIRONMENT"; then
1711   if test "$MOZ_WIDGET_TOOLKIT" = gtk; then
1712     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)
1713     MOZ_GTK3_CFLAGS="-I${_topsrcdir}/widget/gtk/compat-gtk3 $MOZ_GTK3_CFLAGS"
1714     TK_CFLAGS=$MOZ_GTK3_CFLAGS
1715     TK_LIBS=$MOZ_GTK3_LIBS
1716     dnl GDK_VERSION_MIN_REQUIRED is not set here as GDK3 deprecated warnings
1717     dnl are suppressed by widget/gtk/compat-gtk3/gdk/gdkversionmacros.h.
1718     AC_DEFINE_UNQUOTED(GDK_VERSION_MAX_ALLOWED,$GDK_VERSION_MAX_ALLOWED)
1719     GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32
1720   fi
1721   if test "$MOZ_ENABLE_GTK"; then
1722     if test "$MOZ_X11"; then
1723       GDK_PACKAGES=gdk-x11-2.0
1724     fi
1725     AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
1726     AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)
1728     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)
1729     MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
1730   fi
1731 fi # COMPILE_ENVIRONMENT
1733 AC_SUBST(MOZ_FS_LAYOUT)
1735 AC_SUBST_LIST(TK_CFLAGS)
1736 AC_SUBST_LIST(TK_LIBS)
1738 dnl ========================================================
1739 dnl =
1740 dnl = Components & Features
1741 dnl =
1742 dnl ========================================================
1743 MOZ_ARG_HEADER(Components and Features)
1745 AC_SUBST(MOZ_OFFICIAL_BRANDING)
1746 if test -n "$MOZ_OFFICIAL_BRANDING"; then
1747   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
1748     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
1749   else
1750     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
1751     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
1752   fi
1755 MOZ_ARG_WITH_STRING(branding,
1756 [  --with-branding=dir     Use branding from the specified directory.],
1757     MOZ_BRANDING_DIRECTORY=$withval)
1759 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
1760 if test -z "$REAL_BRANDING_DIRECTORY"; then
1761   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
1764 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
1765   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
1766 elif test -f "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
1767   . "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"
1770 AC_SUBST(MOZ_BRANDING_DIRECTORY)
1772 dnl ========================================================
1773 dnl = Distribution ID
1774 dnl ========================================================
1775 MOZ_ARG_WITH_STRING(distribution-id,
1776 [  --with-distribution-id=ID
1777                           Set distribution-specific id (default=org.mozilla)],
1778 [ val=`echo $withval`
1779     MOZ_DISTRIBUTION_ID="$val"])
1781 if test -z "$MOZ_DISTRIBUTION_ID"; then
1782    MOZ_DISTRIBUTION_ID="org.mozilla"
1785 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
1786 AC_SUBST(MOZ_DISTRIBUTION_ID)
1788 dnl ========================================================
1789 dnl = libproxy support
1790 dnl ========================================================
1792 if test "$MOZ_ENABLE_GTK"
1793 then
1794     MOZ_ENABLE_LIBPROXY=
1796     MOZ_ARG_ENABLE_BOOL(libproxy,
1797     [  --enable-libproxy         Enable libproxy support ],
1798     MOZ_ENABLE_LIBPROXY=1,
1799     MOZ_ENABLE_LIBPROXY=)
1801     if test "$MOZ_ENABLE_LIBPROXY"
1802     then
1803         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
1804         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
1805     fi
1807 AC_SUBST(MOZ_ENABLE_LIBPROXY)
1809 dnl ========================================================
1810 dnl = dbus support
1811 dnl ========================================================
1813 if test "$MOZ_ENABLE_GTK"
1814 then
1815     MOZ_ENABLE_DBUS=1
1817     MOZ_ARG_DISABLE_BOOL(dbus,
1818     [  --disable-dbus          Disable dbus support ],
1819         MOZ_ENABLE_DBUS=,
1820         MOZ_ENABLE_DBUS=1)
1822     if test "$MOZ_ENABLE_DBUS"
1823     then
1824         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
1825         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
1826         AC_DEFINE(MOZ_ENABLE_DBUS)
1827     fi
1829 AC_SUBST(MOZ_ENABLE_DBUS)
1831 dnl =========================================================
1832 dnl = Whether to exclude hyphenations files in the build
1833 dnl =========================================================
1834 if test -n "$MOZ_EXCLUDE_HYPHENATION_DICTIONARIES"; then
1835     AC_DEFINE(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
1838 AC_TRY_COMPILE([#include <linux/ethtool.h>],
1839                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
1840                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
1842 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
1844 if test -n "$MOZ_WEBRTC"; then
1845     if test -n "$MOZ_X11"; then
1846       MOZ_WEBRTC_X11_LIBS="-lXext -lXdamage -lXfixes -lXcomposite"
1847     fi
1850 AC_SUBST_LIST(MOZ_WEBRTC_X11_LIBS)
1852 dnl ========================================================
1853 dnl = Apple platform decoder support
1854 dnl ========================================================
1855 if test "$COMPILE_ENVIRONMENT"; then
1856 if test -n "$MOZ_APPLEMEDIA"; then
1857   # hack in frameworks for fmp4 - see bug 1029974
1858   # We load VideoToolbox and CoreMedia dynamically, so they don't appear here.
1859   LDFLAGS="$LDFLAGS -framework AudioToolbox"
1860   dnl Verify CoreMedia is available.
1861   AC_CHECK_HEADERS([CoreMedia/CoreMedia.h VideoToolbox/VideoToolbox.h], [],
1862     [AC_MSG_ERROR([MacOS X 10.9 SDK or later is required])])
1864 fi # COMPILE_ENVIRONMENT
1866 dnl ========================================================
1867 dnl = Handle dependent MEDIA defines
1868 dnl ========================================================
1870 MOZ_WEBM_ENCODER=1
1871 AC_DEFINE(MOZ_WEBM_ENCODER)
1872 AC_SUBST(MOZ_WEBM_ENCODER)
1874 dnl ========================================================
1875 dnl NegotiateAuth
1876 dnl ========================================================
1878 MOZ_ARG_DISABLE_BOOL(negotiateauth,
1879 [  --disable-negotiateauth Disable GSS-API negotiation ],
1880     MOZ_AUTH_EXTENSION=,
1881     MOZ_AUTH_EXTENSION=1 )
1883 if test -n "$MOZ_IOS" -a -n "$MOZ_AUTH_EXTENSION"; then
1884    AC_MSG_ERROR([negotiateauth is not supported on iOS.])
1887 dnl ========================================================
1888 dnl Pref extensions (autoconfig)
1889 dnl ========================================================
1890 MOZ_ARG_DISABLE_BOOL(pref-extensions,
1891 [  --disable-pref-extensions
1892                           Disable pref extensions such as autoconfig],
1893   MOZ_PREF_EXTENSIONS=,
1894   MOZ_PREF_EXTENSIONS=1 )
1896 dnl ========================================================
1897 dnl Searching of system directories for extensions.
1898 dnl Note: this switch is meant to be used for test builds
1899 dnl whose behavior should not depend on what happens to be
1900 dnl installed on the local machine.
1901 dnl ========================================================
1902 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
1903 [  --disable-system-extension-dirs
1904                           Disable searching system- and account-global
1905                           directories for extensions of any kind; use
1906                           only profile-specific extension directories],
1907   ENABLE_SYSTEM_EXTENSION_DIRS=,
1908   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
1909 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
1910   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
1913 dnl ========================================================
1914 dnl = Universalchardet
1915 dnl ========================================================
1916 MOZ_ARG_DISABLE_BOOL(universalchardet,
1917 [  --disable-universalchardet
1918                           Disable universal encoding detection],
1919   MOZ_UNIVERSALCHARDET=,
1920   MOZ_UNIVERSALCHARDET=1 )
1922 dnl ========================================================
1923 dnl Gamepad support
1924 dnl ========================================================
1926 if test "$COMPILE_ENVIRONMENT" ; then
1928 dnl Moved gamepad platform check to moz.build, linux header check still needed here.
1929 if test "$OS_TARGET" = "Linux"; then
1930     MOZ_CHECK_HEADER([linux/joystick.h])
1931     if test "$ac_cv_header_linux_joystick_h" != "yes"; then
1932       AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers.])
1933     fi
1936 fi # COMPILE_ENVIRONMENT
1939 dnl ========================================================
1940 dnl = Breakpad crash reporting (on by default on supported platforms)
1941 dnl ========================================================
1943 case $target in
1944 i?86-*-mingw*|x86_64-*-mingw*|aarch64-*-mingw*)
1945   MOZ_CRASHREPORTER=1
1946   ;;
1947 i?86-apple-darwin*|x86_64-apple-darwin*)
1948   if test -z "$MOZ_IOS"; then
1949     MOZ_CRASHREPORTER=1
1950   fi
1951   ;;
1952 *-android*|*-linuxandroid*)
1953   dnl Android/arm is arm-unknown-linux-androideabi, so android condition should
1954   dnl be before Linux condition
1955   MOZ_CRASHREPORTER=1
1956   ;;
1957 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
1958   if test "$MOZ_ENABLE_GTK"; then
1959     MOZ_CRASHREPORTER=1
1960   fi
1961   ;;
1962 esac
1964 MOZ_ARG_DISABLE_BOOL(crashreporter,
1965 [  --disable-crashreporter Disable breakpad crash reporting],
1966     [MOZ_CRASHREPORTER=],
1967     [MOZ_CRASHREPORTER=F # Force enable breakpad])
1969 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "Darwin" -a "$MOZ_WIDGET_TOOLKIT" != "android"; then
1970   if test "$MOZ_CRASHREPORTER" = F; then
1971     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
1972   fi
1973   MOZ_CRASHREPORTER=
1976 if test -n "$MOZ_CRASHREPORTER"; then
1977    AC_DEFINE(MOZ_CRASHREPORTER)
1979   if test "$OS_TARGET" = "Linux" && \
1980     test -z "$SKIP_LIBRARY_CHECKS"; then
1981     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
1982   fi
1984   if test "$OS_ARCH" = "WINNT"; then
1985     if test -z "$HAVE_64BIT_BUILD" -a -n "$COMPILE_ENVIRONMENT"; then
1986       MOZ_CRASHREPORTER_INJECTOR=1
1987       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
1988     fi
1989   fi
1992 dnl ========================================================
1993 dnl = Enable compilation of specific extension modules
1994 dnl ========================================================
1996 MOZ_ARG_ENABLE_STRING(extensions,
1997 [  --enable-extensions     Enable extensions],
1998 [ for option in `echo $enableval | sed 's/,/ /g'`; do
1999     if test "$option" = "yes" -o "$option" = "all"; then
2000         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
2001     elif test "$option" = "no" -o "$option" = "none"; then
2002         MOZ_EXTENSIONS=""
2003     elif test "$option" = "default"; then
2004         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
2005     elif test `echo "$option" | grep -c \^-` != 0; then
2006         option=`echo $option | sed 's/^-//'`
2007         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
2008     else
2009         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
2010     fi
2011 done],
2012     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
2014 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
2015 dnl when trying to build a nonexistent extension.
2016 for extension in $MOZ_EXTENSIONS; do
2017     if test ! -d "${srcdir}/extensions/${extension}"; then
2018         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
2019     fi
2020 done
2022 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
2023   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
2026 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
2027 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
2028 if test -n "$MOZ_TREE_FREETYPE" -a "$OS_TARGET" != WINNT; then
2029    MOZ_ENABLE_CAIRO_FT=1
2030    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
2031    CAIRO_FT_CFLAGS="-I$_topsrcdir/modules/freetype2/include"
2032    AC_SUBST_LIST(CAIRO_FT_CFLAGS)
2035 AC_CHECK_PROGS(WGET, wget, "")
2036 AC_SUBST(WGET)
2038 dnl ========================================================
2039 dnl Updater
2040 dnl ========================================================
2042 if test "$MOZ_IOS"; then
2043   MOZ_UPDATER=
2046 MOZ_ARG_DISABLE_BOOL(updater,
2047 [  --disable-updater       Disable building of updater],
2048     MOZ_UPDATER=,
2049     MOZ_UPDATER=1 )
2051 if test -n "$MOZ_UPDATER"; then
2052     AC_DEFINE(MOZ_UPDATER)
2055 dnl ========================================================
2056 dnl parental controls (for Windows Vista)
2057 dnl ========================================================
2058 MOZ_ARG_DISABLE_BOOL(parental-controls,
2059 [  --disable-parental-controls
2060                           Do not build parental controls],
2061    MOZ_DISABLE_PARENTAL_CONTROLS=1,
2062    MOZ_DISABLE_PARENTAL_CONTROLS=)
2063 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
2064     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
2067 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
2069 dnl ========================================================
2070 dnl = Disable smartcard support
2071 dnl ========================================================
2072 if test -n "$MOZ_NO_SMART_CARDS"; then
2073     AC_DEFINE(MOZ_NO_SMART_CARDS)
2075 AC_SUBST(MOZ_NO_SMART_CARDS)
2077 dnl ========================================================
2078 dnl = Sandboxing support
2079 dnl ========================================================
2080 if test -n "$MOZ_TSAN" -o -n "$MOZ_ASAN"; then
2081     # Bug 1182565: TSan conflicts with sandboxing on Linux.
2082     # Bug 1287971: LSan also conflicts with sandboxing on Linux.
2083     case $OS_TARGET in
2084     Linux|Android)
2085         MOZ_SANDBOX=
2086         ;;
2087     esac
2090 MOZ_ARG_DISABLE_BOOL(sandbox,
2091 [  --disable-sandbox        Disable sandboxing support],
2092     MOZ_SANDBOX=,
2093     MOZ_SANDBOX=1)
2095 case "$OS_TARGET" in
2096 WINNT|Darwin|OpenBSD)
2098 Linux)
2099     case $CPU_ARCH in
2100         x86_64|x86)
2101         ;;
2102         # Linux sandbox is only available on x86 and x86_64.
2103         *)
2104             MOZ_SANDBOX=
2105         ;;
2106     esac
2107     ;;
2109     # Only enable the sandbox by default on Linux, OpenBSD, macOS, and Windows
2110     MOZ_SANDBOX=
2112 esac
2114 if test -n "$MOZ_SANDBOX"; then
2115     AC_DEFINE(MOZ_SANDBOX)
2118 AC_SUBST(MOZ_SANDBOX)
2121 dnl ========================================================
2122 dnl =
2123 dnl = Module specific options
2124 dnl =
2125 dnl ========================================================
2126 MOZ_ARG_HEADER(Individual module options)
2128 dnl ==============================
2129 dnl === SQLite fdatasync check ===
2130 dnl ==============================
2131 dnl Check to see if fdatasync is available and make use of it
2132 AC_CHECK_FUNC(fdatasync)
2134 dnl ========================================================
2135 dnl = Disable zipwriter
2136 dnl ========================================================
2137 MOZ_ARG_DISABLE_BOOL(zipwriter,
2138 [  --disable-zipwriter     Disable zipwriter component],
2139     MOZ_ZIPWRITER=,
2140     MOZ_ZIPWRITER=1 )
2141 AC_SUBST(MOZ_ZIPWRITER)
2143 dnl ========================================================
2144 dnl =
2145 dnl = Feature options that require extra sources to be pulled
2146 dnl =
2147 dnl ========================================================
2148 dnl MOZ_ARG_HEADER(Features that require extra sources)
2150 dnl ========================================================
2151 dnl =
2152 dnl = Runtime debugging and Optimization Options
2153 dnl =
2154 dnl ========================================================
2155 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
2157 dnl ========================================================
2158 dnl enable mobile optimizations
2159 dnl ========================================================
2160 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
2161 [  --enable-mobile-optimize
2162                           Enable mobile optimizations],
2163     MOZ_GFX_OPTIMIZE_MOBILE=1)
2165 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
2167 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
2168     # We ignore paint will resample on mobile for performance.
2169     # We may want to revisit this later.
2170     MOZ_IGNORE_PAINT_WILL_RESAMPLE=1
2172     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
2173     AC_DEFINE(MOZ_IGNORE_PAINT_WILL_RESAMPLE)
2176 dnl ========================================================
2177 dnl = Enable code optimization. ON by default.
2178 dnl ========================================================
2180 # Use value from moz.configure if one is defined. Else use our computed
2181 # value.
2182 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
2183     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
2186 if test "$COMPILE_ENVIRONMENT"; then
2187 if test -n "$MOZ_OPTIMIZE"; then
2188     AC_MSG_CHECKING([for valid C compiler optimization flags])
2189     _SAVE_CFLAGS=$CFLAGS
2190     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
2191     AC_TRY_COMPILE([#include <stdio.h>],
2192         [printf("Hello World\n");],
2193         _results=yes,
2194         _results=no)
2195     AC_MSG_RESULT([$_results])
2196     if test "$_results" = "no"; then
2197         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
2198     fi
2199     CFLAGS=$_SAVE_CFLAGS
2200     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
2201         # When using llvm-based LTO, non numeric optimization levels are
2202         # not supported by the linker, so force the linker to use -O2 (
2203         # which doesn't influence the level compilation units are actually
2204         # compiled at).
2205         case " $MOZ_OPTIMIZE_FLAGS " in
2206         *\ -Os\ *|*\ -Oz\ *)
2207             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
2208             ;;
2209         esac
2210     fi
2212 fi # COMPILE_ENVIRONMENT
2214 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
2215 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
2216 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
2218 dnl ========================================================
2219 dnl = Enable runtime logging
2220 dnl ========================================================
2221 AC_DEFINE(MOZ_LOGGING)
2222 AC_DEFINE(FORCE_PR_LOG)
2224 dnl ========================================================
2225 dnl = This will enable logging of addref, release, ctor, dtor.
2226 dnl ========================================================
2227 _ENABLE_LOGREFCNT=42
2228 MOZ_ARG_ENABLE_BOOL(logrefcnt,
2229 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
2230     _ENABLE_LOGREFCNT=1,
2231     _ENABLE_LOGREFCNT= )
2232 if test "$_ENABLE_LOGREFCNT" = "1"; then
2233     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
2234 elif test -z "$_ENABLE_LOGREFCNT"; then
2235     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
2238 dnl ========================================================
2239 dnl moz_dump_painting
2240 dnl ========================================================
2241 MOZ_ARG_ENABLE_BOOL(dump-painting,
2242 [  --enable-dump-painting          Enable paint debugging.],
2243     MOZ_DUMP_PAINTING=1,
2244     MOZ_DUMP_PAINTING= )
2245 if test -n "$MOZ_DUMP_PAINTING"; then
2246     AC_DEFINE(MOZ_DUMP_PAINTING)
2247     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
2249 if test -n "$MOZ_DEBUG"; then
2250     AC_DEFINE(MOZ_DUMP_PAINTING)
2253 case "${OS_TARGET}" in
2254 Android|WINNT|Darwin)
2255   MOZ_GLUE_IN_PROGRAM=
2256   ;;
2258   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
2259   MOZ_GLUE_IN_PROGRAM=1
2260   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
2261   ;;
2262 esac
2264 dnl ========================================================
2265 dnl = Jemalloc build setup
2266 dnl ========================================================
2267 if test -z "$MOZ_MEMORY"; then
2268   case "${target}" in
2269     *-mingw*)
2270       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
2271         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.])
2272       fi
2273       ;;
2274   esac
2275 else
2276   dnl The generic feature tests that determine how to compute ncpus are long and
2277   dnl complicated.  Therefore, simply define special cpp variables for the
2278   dnl platforms we have special knowledge of.
2279   case "${target}" in
2280   *-mingw*)
2281     export MOZ_NO_DEBUG_RTL=1
2282     ;;
2283   esac
2284 fi # MOZ_MEMORY
2285 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
2287 dnl ========================================================
2288 dnl = Enable using the clang plugin to build
2289 dnl ========================================================
2291 if test -n "$COMPILE_ENVIRONMENT"; then
2292 MOZ_CONFIG_CLANG_PLUGIN
2293 fi # COMPILE_ENVIRONMENT
2295 dnl ========================================================
2296 dnl = Enable stripping of libs & executables
2297 dnl ========================================================
2298 MOZ_ARG_ENABLE_BOOL(strip,
2299 [  --enable-strip          Enable stripping of libs & executables ],
2300     ENABLE_STRIP=1,
2301     ENABLE_STRIP= )
2303 dnl ========================================================
2304 dnl = Enable stripping of libs & executables when packaging
2305 dnl ========================================================
2306 MOZ_ARG_ENABLE_BOOL(install-strip,
2307 [  --enable-install-strip  Enable stripping of libs & executables when packaging ],
2308     PKG_SKIP_STRIP= ,
2309     PKG_SKIP_STRIP=1)
2311 dnl ========================================================
2312 dnl = frontend JS debug mode
2313 dnl ========================================================
2315 MOZ_ARG_ENABLE_BOOL(debug-js-modules,
2316 [  --enable-debug-js-modules  Enable debug mode for frontend JS libraries],
2317    DEBUG_JS_MODULES=1,
2318    DEBUG_JS_MODULES=)
2320 AC_SUBST(DEBUG_JS_MODULES)
2322 dnl ========================================================
2323 dnl =
2324 dnl = Profiling and Instrumenting
2325 dnl =
2326 dnl ========================================================
2327 MOZ_ARG_HEADER(Profiling and Instrumenting)
2329 dnl ========================================================
2330 dnl = Offer a way to disable the startup cache
2331 dnl ========================================================
2333 MOZ_ARG_DISABLE_BOOL(startupcache,
2334 [  --disable-startupcache          Disable startup cache ],
2335     MOZ_DISABLE_STARTUPCACHE=1,
2336     MOZ_DISABLE_STARTUPCACHE=)
2338 if test -n "$MOZ_DISABLE_STARTUPCACHE"; then
2339   AC_DEFINE(MOZ_DISABLE_STARTUPCACHE)
2341 AC_SUBST(MOZ_DISABLE_STARTUPCACHE)
2343 dnl ========================================================
2344 dnl = Support for demangling undefined symbols
2345 dnl ========================================================
2346 if test -z "$SKIP_LIBRARY_CHECKS"; then
2347     AC_LANG_SAVE
2348     AC_LANG_CPLUSPLUS
2349     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
2350     AC_LANG_RESTORE
2353 # Demangle only for debug or DMD builds
2354 MOZ_DEMANGLE_SYMBOLS=
2355 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
2356     MOZ_DEMANGLE_SYMBOLS=1
2357     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
2359 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
2361 dnl ========================================================
2362 dnl = Support for gcc stack unwinding (from gcc 3.3)
2363 dnl ========================================================
2364 if test -z "$SKIP_LIBRARY_CHECKS"; then
2365     AC_LANG_SAVE
2366     AC_LANG_CPLUSPLUS
2367     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
2368     AC_LANG_RESTORE
2371 dnl ========================================================
2372 dnl JIT observers
2373 dnl ========================================================
2375 MOZ_ARG_WITH_STRING(jitreport-granularity,
2376 [  --jitreport-granularity=N
2377                            Default granularity at which to report JIT code
2378                            to external tools
2379                              0 - no info
2380                              1 - code ranges for whole functions only
2381                              2 - per-line information
2382                              3 - per-op information],
2383   JITREPORT_GRANULARITY=$withval,
2384   JITREPORT_GRANULARITY=3)
2386 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
2388 dnl ========================================================
2389 dnl =
2390 dnl = Misc. Options
2391 dnl =
2392 dnl ========================================================
2393 MOZ_ARG_HEADER(Misc. Options)
2395 dnl ========================================================
2396 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
2397 dnl ========================================================
2398 MOZ_ARG_WITH_STRING(user-appdir,
2399 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
2400 [ val=`echo $withval`
2401 if echo "$val" | grep "\/" >/dev/null; then
2402     AC_MSG_ERROR("Homedir must be single relative path.")
2403 else
2404     MOZ_USER_DIR="$val"
2405 fi])
2407 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
2409 if test -z "$SKIP_COMPILER_CHECKS"; then
2410 dnl ========================================================
2411 dnl =
2412 dnl = Compiler Options
2413 dnl =
2414 dnl ========================================================
2415 MOZ_ARG_HEADER(Compiler Options)
2417 dnl ========================================================
2418 dnl Check for gcc -pipe support
2419 dnl ========================================================
2420 AC_MSG_CHECKING([for -pipe support])
2421 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
2422     dnl Any gcc that supports firefox supports -pipe.
2423     CFLAGS="$CFLAGS -pipe"
2424     CXXFLAGS="$CXXFLAGS -pipe"
2425     AC_MSG_RESULT([yes])
2426 else
2427     AC_MSG_RESULT([no])
2430 fi # ! SKIP_COMPILER_CHECKS
2432 AC_LANG_C
2434 if test "$COMPILE_ENVIRONMENT"; then
2435 MOZ_EXPAND_LIBS
2436 fi # COMPILE_ENVIRONMENT
2438 dnl ========================================================
2439 dnl =
2440 dnl = Static Build Options
2441 dnl =
2442 dnl ========================================================
2443 MOZ_ARG_HEADER(Static build options)
2445 if test -z "$MOZ_SYSTEM_ZLIB"; then
2446 if test -n "$JS_SHARED_LIBRARY" -o -n "$MOZ_LINKER" -o "$MOZ_WIDGET_TOOLKIT" = android; then
2447   ZLIB_IN_MOZGLUE=1
2448   AC_DEFINE(ZLIB_IN_MOZGLUE)
2452 AC_SUBST(ZLIB_IN_MOZGLUE)
2454 dnl ========================================================
2455 dnl =
2456 dnl = Standalone module options
2457 dnl =
2458 dnl ========================================================
2459 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
2461 dnl Check for GLib.
2462 dnl ========================================================
2464 if test -z "$SKIP_PATH_CHECKS"; then
2465 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
2466     if test "$MOZ_ENABLE_GTK" ; then
2467         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
2468     fi
2472 if test -z "${GLIB_GMODULE_LIBS}" \
2473    -a -n "${GLIB_CONFIG}"\
2474     -a "${GLIB_CONFIG}" != no\
2475 ; then
2476     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
2479 AC_SUBST_LIST(GLIB_GMODULE_LIBS)
2481 if test "$USE_FC_FREETYPE"; then
2482     if test "$COMPILE_ENVIRONMENT"; then
2483         dnl ========================================================
2484         dnl = Check for freetype2 functionality
2485         dnl ========================================================
2486         if test "$_HAVE_FREETYPE2" -a -z "$MOZ_TREE_FREETYPE"; then
2487             _SAVE_LIBS="$LIBS"
2488             _SAVE_CFLAGS="$CFLAGS"
2489             LIBS="$LIBS $FT2_LIBS"
2490             CFLAGS="$CFLAGS $FT2_CFLAGS"
2492             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
2493                 ac_cv_member_FT_Bitmap_Size_y_ppem,
2494                 [AC_TRY_COMPILE([#include <ft2build.h>
2495                                  #include FT_FREETYPE_H],
2496                                 [FT_Bitmap_Size s;
2497                                  if (sizeof s.y_ppem) return 0;
2498                                  return 1],
2499                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
2500                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
2501             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
2502                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
2503             else
2504                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
2505             fi
2506             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
2507                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
2508                                [FT_Bitmap_Size structure includes y_ppem field])
2510             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table)
2512             LIBS="$_SAVE_LIBS"
2513             CFLAGS="$_SAVE_CFLAGS"
2514         fi
2516         _SAVE_CPPFLAGS="$CPPFLAGS"
2517         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
2518         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
2519             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
2520         CPPFLAGS="$_SAVE_CPPFLAGS"
2521     fi
2524 dnl ========================================================
2525 dnl Check if we need the 32-bit Linux SSE2 error dialog
2526 dnl ========================================================
2528 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
2530 dnl ========================================================
2531 dnl Check for pixman and cairo
2532 dnl ========================================================
2534 MOZ_TREE_CAIRO=1
2535 MOZ_ARG_ENABLE_BOOL(system-cairo,
2536 [ --enable-system-cairo  Obsolete: do not use this option],
2537 AC_MSG_ERROR(--enable-system-cairo is not supported),
2538 MOZ_TREE_CAIRO=1 )
2540 MOZ_TREE_PIXMAN=1
2541 MOZ_ARG_ENABLE_BOOL(system-pixman,
2542 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
2543 MOZ_TREE_PIXMAN=,
2544 MOZ_TREE_PIXMAN=force,
2545 MOZ_TREE_PIXMAN=1 )
2547 if test "$MOZ_TREE_PIXMAN"; then
2548     AC_DEFINE(MOZ_TREE_PIXMAN)
2549 else
2550     PKG_CHECK_MODULES(MOZ_PIXMAN, pixman-1 >= 0.19.2)
2553 MOZ_CAIRO_CFLAGS="-I${DIST}/include/cairo"
2554 AC_DEFINE(MOZ_TREE_CAIRO)
2556 if test "$OS_ARCH" = "WINNT"; then
2557     # For now we assume that we will have a uint64_t available through
2558     # one of the above headers or mozstdint.h.
2559     AC_DEFINE(HAVE_UINT64_T)
2562 # Define macros for cairo-features.h
2563 TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
2564 if test "$MOZ_X11"; then
2565     XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
2566     XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
2567     PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
2569 if test "$_HAVE_FREETYPE2"; then
2570     FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
2571     MOZ_ENABLE_CAIRO_FT=1
2572     CAIRO_FT_CFLAGS="$FT2_CFLAGS"
2575 case "$MOZ_WIDGET_TOOLKIT" in
2576   cocoa | uikit)
2577     QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
2578     QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
2579     QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
2580     ;;
2581   windows)
2582     WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
2583     WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
2584     WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
2586     if test "$COMPILE_ENVIRONMENT"; then
2587       MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
2588     fi
2589     ;;
2590 esac
2591 if test "$USE_FC_FREETYPE"; then
2592     FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
2594 AC_SUBST(MOZ_ENABLE_CAIRO_FT)
2595 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
2597 AC_SUBST(PS_SURFACE_FEATURE)
2598 AC_SUBST(SVG_SURFACE_FEATURE)
2599 AC_SUBST(XLIB_SURFACE_FEATURE)
2600 AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
2601 AC_SUBST(QUARTZ_SURFACE_FEATURE)
2602 AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
2603 AC_SUBST(WIN32_SURFACE_FEATURE)
2604 AC_SUBST(OS2_SURFACE_FEATURE)
2605 AC_SUBST(DIRECTFB_SURFACE_FEATURE)
2606 AC_SUBST(FT_FONT_FEATURE)
2607 AC_SUBST(FC_FONT_FEATURE)
2608 AC_SUBST(WIN32_FONT_FEATURE)
2609 AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
2610 AC_SUBST(QUARTZ_FONT_FEATURE)
2611 AC_SUBST(PNG_FUNCTIONS_FEATURE)
2612 AC_SUBST(QT_SURFACE_FEATURE)
2613 AC_SUBST(TEE_SURFACE_FEATURE)
2615 if test "$MOZ_X11"; then
2616     MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
2619 CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
2621 case "$MOZ_WIDGET_TOOLKIT" in
2622 android)
2623     TK_CFLAGS="$MOZ_CAIRO_CFLAGS $MOZ_PIXMAN_CFLAGS"
2624     TK_LIBS="$MOZ_CAIRO_LIBS $MOZ_PIXMAN_LIBS"
2625     ;;
2626 esac
2628 AC_SUBST(MOZ_TREE_CAIRO)
2629 AC_SUBST_LIST(MOZ_CAIRO_CFLAGS)
2630 AC_SUBST_LIST(MOZ_CAIRO_LIBS)
2631 AC_SUBST_LIST(MOZ_CAIRO_OSLIBS)
2632 AC_SUBST(MOZ_TREE_PIXMAN)
2634 BINDGEN_SYSTEM_FLAGS="$_BINDGEN_CFLAGS $NSPR_CFLAGS $NSS_CFLAGS $MOZ_PIXMAN_CFLAGS $MOZ_CAIRO_CFLAGS"
2635 AC_SUBST(BINDGEN_SYSTEM_FLAGS)
2636 BINDGEN_SYSTEM_TOML_FLAGS="$BINDGEN_SYSTEM_FLAGS"
2637 AC_SUBST_TOML_LIST(BINDGEN_SYSTEM_TOML_FLAGS)
2639 dnl ========================================================
2640 dnl disable xul
2641 dnl ========================================================
2642 MOZ_ARG_DISABLE_BOOL(xul,
2643 [  --disable-xul           Disable XUL],
2644     MOZ_XUL= )
2645 if test "$MOZ_XUL"; then
2646   AC_DEFINE(MOZ_XUL)
2647 else
2648   dnl remove extensions that require XUL
2649   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/irc//' -e 's/tasks//'`
2652 AC_SUBST(MOZ_XUL)
2654 dnl ========================================================
2655 dnl necko configuration options
2656 dnl ========================================================
2659 dnl option to disable necko's wifi scanner
2662 if test "$MOZ_WIDGET_TOOLKIT"; then
2664   case "$OS_TARGET" in
2665     Darwin)
2666       if test -z "$MOZ_IOS"; then
2667         NECKO_WIFI=1
2668       fi
2669       ;;
2670     DragonFly|FreeBSD|WINNT)
2671       NECKO_WIFI=1
2672       ;;
2673     Linux)
2674       NECKO_WIFI=1
2675       NECKO_WIFI_DBUS=1
2676       ;;
2677   esac
2681 MOZ_ARG_DISABLE_BOOL(necko-wifi,
2682 [  --disable-necko-wifi    Disable necko wifi scanner],
2683     NECKO_WIFI=,
2684     NECKO_WIFI=1)
2686 if test "$NECKO_WIFI"; then
2687   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
2688     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
2689   fi
2690   AC_DEFINE(NECKO_WIFI)
2691   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
2693 AC_SUBST(NECKO_WIFI)
2694 AC_SUBST(NECKO_WIFI_DBUS)
2697 dnl option to disable cookies
2699 MOZ_ARG_DISABLE_BOOL(cookies,
2700 [  --disable-cookies       Disable cookie support],
2701     NECKO_COOKIES=,
2702     NECKO_COOKIES=1)
2703 AC_SUBST(NECKO_COOKIES)
2704 if test "$NECKO_COOKIES"; then
2705     AC_DEFINE(NECKO_COOKIES)
2706     _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_COOKIES"
2709 dnl ========================================================
2710 dnl =
2711 dnl = Maintainer debug option (no --enable equivalent)
2712 dnl =
2713 dnl ========================================================
2715 AC_SUBST(NM)
2716 AC_SUBST_LIST(ASFLAGS)
2717 AC_SUBST(RCFLAGS)
2718 AC_SUBST(IMPLIB)
2719 AC_SUBST(FILTER)
2720 AC_SUBST(MOZ_AUTH_EXTENSION)
2721 AC_SUBST(MOZ_PREF_EXTENSIONS)
2722 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
2723 AC_SUBST_LIST(WARNINGS_CFLAGS)
2724 AC_SUBST_SET(MOZ_EXTENSIONS)
2726 AC_SUBST(MOZ_UNIVERSALCHARDET)
2727 AC_SUBST(MOZ_SPELLCHECK)
2728 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
2729 AC_SUBST(MOZ_CRASHREPORTER)
2730 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
2731 AC_SUBST(MOZ_STUB_INSTALLER)
2732 AC_SUBST(MOZ_UPDATER)
2734 AC_SUBST(MOZ_ANDROID_APPLICATION_CLASS)
2735 AC_SUBST(MOZ_ANDROID_BROWSER_INTENT_CLASS)
2736 AC_SUBST(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
2737 AC_SUBST(ENABLE_STRIP)
2738 AC_SUBST(PKG_SKIP_STRIP)
2739 AC_SUBST(STRIP_FLAGS)
2740 AC_SUBST(INCREMENTAL_LINKER)
2742 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
2744 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
2745 AC_SUBST(MOZ_LINKER_EXTRACT)
2747 if test -n "$MOZ_BINARY_EXTENSIONS"; then
2748   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
2751 AC_SUBST(MOZ_REQUIRE_SIGNING)
2752 if test "$MOZ_REQUIRE_SIGNING" = 1; then
2753   AC_DEFINE(MOZ_REQUIRE_SIGNING)
2756 dnl ========================================================
2757 dnl = Mac bundle name prefix
2758 dnl ========================================================
2759 MOZ_ARG_WITH_STRING(macbundlename-prefix,
2760 [  --with-macbundlename-prefix=prefix
2761                           Prefix for MOZ_MACBUNDLE_NAME],
2762 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
2764 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
2765 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
2766   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
2769 if test "$MOZ_DEBUG"; then
2770   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
2771 else
2772   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
2774 AC_SUBST(MOZ_MACBUNDLE_NAME)
2776 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
2777 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
2778 # Otherwise, use MOZ_APP_DISPLAYNAME
2779 if test -z "$MOZ_MACBUNDLE_ID"; then
2780    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
2782 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
2783 if test "$MOZ_DEBUG"; then
2784   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
2787 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
2788 AC_SUBST(MOZ_MACBUNDLE_ID)
2790 dnl ========================================================
2791 dnl = Child Process Name for IPC
2792 dnl ========================================================
2793 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
2794   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
2795 else
2796   # We want to let Android unpack the file at install time, but it only does
2797   # so if the file is named libsomething.so. The lib/ path is also required
2798   # because the unpacked file will be under the lib/ subdirectory and will
2799   # need to be executed from that path.
2800   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
2802 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
2803 MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
2805 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
2806 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
2807 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
2809 # The following variables are available to branding and application
2810 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
2811 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
2812 # impacts profile location and user-visible fields.
2813 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
2814 # versions of a given application (e.g. Aurora and Firefox both use
2815 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
2816 # for application.ini's "Name" field, which controls profile location in
2817 # the absence of a "Profile" field (see below), and various system
2818 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
2819 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
2820 # Mac Bundle name, Updater, Installer), it is typically used for nightly
2821 # builds (e.g. Aurora for Firefox).
2822 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
2823 # defaults to a lowercase form of MOZ_APP_BASENAME.
2824 # - MOZ_APP_REMOTINGNAME: Used for the internal program name, which affects
2825 # profile name and remoting. If not set, defaults to MOZ_APP_NAME.
2826 # - MOZ_APP_PROFILE: When set, used for application.ini's
2827 # "Profile" field, which controls profile location.
2828 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
2829 # crash reporter server url.
2830 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
2832 # The following environment variables used to have an effect, but don't anymore:
2833 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
2834 # the contents from the version.txt file in the application directory, or
2835 # browser/config/version.txt if there isn't one.
2836 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
2837 # in the "About" window. This was replaced with the contents from the
2838 # version_display.txt or version.txt in the application directory, or
2839 # browser/config/version_display.txt.
2841 if test -z "$MOZ_APP_NAME"; then
2842    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
2845 if test -z "$MOZ_APP_REMOTINGNAME"; then
2846    MOZ_APP_REMOTINGNAME=$MOZ_APP_NAME
2849 if test -z "$ANDROID_PACKAGE_NAME" ; then
2850    # When we got rid of the Aurora channel we decided to replace the old
2851    # Nightly ANDROID_PACKAGE_NAME with Aurora. To make sure this is inherited
2852    # by all mozilla-central based branches we make this the new "default"
2853    # for Fennec. Non mozilla-central based branches set ANDROID_PACKAGE_NAME
2854    # in their mozconfig, so they will never get this. If there are ever
2855    # non-Fennec builds for Android, they will fall into the else block
2856    # and use their own default name.
2857    # https://bugzilla.mozilla.org/show_bug.cgi?id=1357808 has additional
2858    # background on this.
2859    if test "$MOZ_APP_NAME" = "fennec"; then
2860       ANDROID_PACKAGE_NAME="org.mozilla.fennec_aurora"
2861    else
2862       ANDROID_PACKAGE_NAME="org.mozilla.$MOZ_APP_NAME"
2863    fi
2866 # For extensions and langpacks, we require a max version that is compatible
2867 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
2868 # 24.0a1 and 24.0a2 aren't affected
2869 # 24.0 becomes 24.*
2870 # 24.1.1 becomes 24.*
2871 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
2872 if test -z "$IS_ALPHA"; then
2873   changequote(,)
2874   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
2875     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
2876   else
2877     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
2878   fi
2879   changequote([,])
2880 else
2881   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
2884 AC_SUBST(MOZ_APP_NAME)
2885 AC_SUBST(MOZ_APP_REMOTINGNAME)
2886 AC_SUBST(MOZ_APP_DISPLAYNAME)
2887 AC_SUBST(MOZ_APP_BASENAME)
2888 AC_SUBST(MOZ_APP_VENDOR)
2889 AC_SUBST(MOZ_APP_PROFILE)
2890 AC_SUBST(MOZ_APP_ID)
2891 AC_SUBST(MAR_CHANNEL_ID)
2892 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
2893 AC_SUBST(MOZ_PROFILE_MIGRATOR)
2894 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
2895 AC_SUBST(MOZ_APP_UA_NAME)
2896 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
2897 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
2898 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
2900 AC_SUBST(MOZ_APP_MAXVERSION)
2901 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
2902 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
2903   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
2906 AC_SUBST(MOZ_PKG_SPECIAL)
2907 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
2909 if test "$MOZILLA_OFFICIAL"; then
2910     # Build revisions should always be present in official builds
2911     MOZ_INCLUDE_SOURCE_INFO=1
2914 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
2915 # explicitly set the repository and changeset information in.
2916 AC_SUBST(MOZ_SOURCE_REPO)
2917 AC_SUBST(MOZ_SOURCE_CHANGESET)
2918 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
2920 dnl If we have any service that uploads data (and requires data submission
2921 dnl policy alert), set MOZ_DATA_REPORTING.
2922 dnl We need SUBST for build system and DEFINE for xul preprocessor.
2923 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"  || test -n "$MOZ_NORMANDY"; then
2924   MOZ_DATA_REPORTING=1
2925   AC_DEFINE(MOZ_DATA_REPORTING)
2926   AC_SUBST(MOZ_DATA_REPORTING)
2929 dnl win32 options
2930 AC_SUBST(WIN32_REDIST_DIR)
2931 AC_SUBST(WIN_UCRT_REDIST_DIR)
2933 dnl ========================================================
2934 dnl ICU Support
2935 dnl ========================================================
2937 _INTL_API=yes
2939 if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
2940     USE_ICU=1
2943 MOZ_CONFIG_ICU()
2945 dnl Echo the CFLAGS to remove extra whitespace.
2946 CFLAGS=`echo \
2947     $_COMPILATION_CFLAGS \
2948     $CFLAGS`
2950 CXXFLAGS=`echo \
2951     $_WARNINGS_CXXFLAGS \
2952     $_COMPILATION_CXXFLAGS \
2953     $CXXFLAGS`
2955 COMPILE_CFLAGS=`echo \
2956     $_DEFINES_CFLAGS \
2957     $COMPILE_CFLAGS`
2959 COMPILE_CXXFLAGS=`echo \
2960     $_DEFINES_CXXFLAGS \
2961     $COMPILE_CXXFLAGS`
2963 HOST_CFLAGS=`echo \
2964     $_WARNINGS_HOST_CFLAGS \
2965     $_COMPILATION_HOST_CFLAGS \
2966     $HOST_CFLAGS`
2968 HOST_CXXFLAGS=`echo \
2969     $_WARNINGS_HOST_CXXFLAGS \
2970     $_COMPILATION_HOST_CXXFLAGS \
2971     $HOST_CXXFLAGS`
2973 AC_SUBST(MOZ_SYSTEM_PNG)
2975 AC_SUBST_LIST(MOZ_PNG_CFLAGS)
2976 AC_SUBST_LIST(MOZ_PNG_LIBS)
2978 AC_SUBST(MOZ_SYSTEM_NSPR)
2980 AC_SUBST(MOZ_SYSTEM_NSS)
2982 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
2983 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
2984 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
2985 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
2986 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
2987   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
2988   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
2990 AC_SUBST(HOST_CMFLAGS)
2991 AC_SUBST(HOST_CMMFLAGS)
2992 AC_SUBST(OS_COMPILE_CMFLAGS)
2993 AC_SUBST(OS_COMPILE_CMMFLAGS)
2995 OS_CFLAGS="$CFLAGS"
2996 OS_CXXFLAGS="$CXXFLAGS"
2997 OS_CPPFLAGS="$CPPFLAGS"
2998 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
2999 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
3000 OS_LDFLAGS="$LDFLAGS"
3001 OS_LIBS="$LIBS"
3002 AC_SUBST_LIST(OS_CFLAGS)
3003 AC_SUBST_LIST(OS_CXXFLAGS)
3004 AC_SUBST_LIST(OS_CPPFLAGS)
3005 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
3006 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
3007 AC_SUBST_LIST(OS_LDFLAGS)
3008 AC_SUBST(OS_LIBS)
3010 AC_SUBST(HOST_CC)
3011 AC_SUBST(HOST_CXX)
3012 AC_SUBST_LIST(HOST_CFLAGS)
3013 AC_SUBST_LIST(HOST_CPPFLAGS)
3014 AC_SUBST_LIST(HOST_CXXFLAGS)
3015 AC_SUBST(HOST_LDFLAGS)
3016 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
3017 AC_SUBST(HOST_BIN_SUFFIX)
3019 AC_SUBST(TARGET_XPCOM_ABI)
3020 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
3021 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
3022 AC_SUBST(HAVE_X86_AVX2)
3023 AC_SUBST(HAVE_ALTIVEC)
3025 AC_SUBST_LIST(DSO_CFLAGS)
3026 AC_SUBST_LIST(DSO_PIC_CFLAGS)
3027 AC_SUBST(DSO_LDOPTS)
3028 AC_SUBST(BIN_SUFFIX)
3029 AC_SUBST(USE_N32)
3030 AC_SUBST(NS_ENABLE_TSF)
3031 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
3032 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
3034 AC_SUBST(MOZ_DEVTOOLS)
3036 AC_SUBST(MOZ_PACKAGE_JSSHELL)
3037 AC_SUBST(MOZ_FOLD_LIBS)
3038 AC_SUBST_LIST(MOZ_FOLD_LIBS_FLAGS)
3040 AC_SUBST(DMG_TOOL)
3042 dnl Host JavaScript runtime, if any, to use during cross compiles.
3043 AC_SUBST(JS_BINARY)
3045 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
3047 if test -n "$COMPILE_ENVIRONMENT"; then
3048 AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
3050 dnl Check for missing components
3051 if test "$MOZ_X11"; then
3052     dnl ====================================================
3053     dnl = Check if X headers exist
3054     dnl ====================================================
3055     _SAVE_CFLAGS=$CFLAGS
3056     CFLAGS="$CFLAGS $XCFLAGS"
3057     AC_TRY_COMPILE([
3058         #include <stdio.h>
3059         #include <stdlib.h>
3060         #include <X11/Xlib.h>
3061         #include <X11/Intrinsic.h>
3062         #include <X11/extensions/XShm.h>
3063     ],
3064     [
3065         Display *dpy = 0;
3066         if ((dpy = XOpenDisplay(NULL)) == NULL) {
3067             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
3068             exit(1);
3069         }
3070     ], [],
3071     [ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
3072     CFLAGS="$_SAVE_CFLAGS"
3074     if test -n "$MISSING_X"; then
3075         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
3076     fi
3078 fi # MOZ_X11
3080 fi # COMPILE_ENVIRONMENT
3082 dnl Set various defines and substitutions
3083 dnl ========================================================
3085 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
3086     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
3087     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
3088     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
3089     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
3090     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
3091     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
3092     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
3093     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
3096 AC_SUBST(MOZ_DEV_EDITION)
3097 if test -n "$MOZ_DEV_EDITION"; then
3098     AC_DEFINE(MOZ_DEV_EDITION)
3101 if test "$MOZ_DEBUG" -o "$DEVELOPER_OPTIONS"; then
3102     A11Y_LOG=1
3104 AC_SUBST(A11Y_LOG)
3105 if test -n "$A11Y_LOG"; then
3106     AC_DEFINE(A11Y_LOG)
3109 dnl Spit out some output
3110 dnl ========================================================
3112 dnl The following defines are used by xpcom
3113 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
3114 HAVE_GETPAGESIZE
3115 HAVE_STATVFS64
3116 HAVE_STATVFS
3117 HAVE_STATFS64
3118 HAVE_STATFS
3119 HAVE_SYS_STATVFS_H
3120 HAVE_SYS_STATFS_H
3121 HAVE_SYS_VFS_H
3122 HAVE_SYS_MOUNT_H
3125 # Avoid using obsolete NSPR features
3126 AC_DEFINE(NO_NSPR_10_SUPPORT)
3128 MOZ_CREATE_CONFIG_STATUS()
3130 rm -fr confdefs* $ac_clean_files