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