Bug 1646700 [wpt PR 24235] - Update picture-in-picture idlharness test, a=testonly
[gecko.git] / old-configure.in
blob50768dceb6c67974703d6469afcfd064e333dfae
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
50 dnl Set the minimum version of toolkit libs used by mozilla
51 dnl ========================================================
52 GLIB_VERSION=2.22
53 # 2_26 is the earliest version we can set GLIB_VERSION_MIN_REQUIRED.
54 # The macro won't be used when compiling with earlier versions anyway.
55 GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26
56 CAIRO_VERSION=1.10
57 GTK2_VERSION=2.18.0
58 GTK3_VERSION=3.4.0
59 GDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4
60 W32API_VERSION=3.14
61 DBUS_VERSION=0.60
63 dnl Set various checks
64 dnl ========================================================
65 MISSING_X=
67 dnl Initialize the Pthread test variables early so they can be
68 dnl  overridden by each platform.
69 dnl ========================================================
70 MOZ_USE_PTHREADS=
71 _PTHREAD_LDFLAGS=""
73 LDFLAGS="$LDFLAGS $LINKER_LDFLAGS"
75 if test "$COMPILE_ENVIRONMENT"; then
76     MOZ_ANDROID_NDK
77 fi # COMPILE_ENVIRONMENT
79 case "$target" in
80 *-android*|*-linuxandroid*)
81     ;;
82 *-linux*)
83     AC_PATH_PROG(OBJCOPY,objcopy)
84     ;;
85 esac
87 AC_SUBST(ANDROID_PACKAGE_NAME)
88 AC_SUBST(OBJCOPY)
90 dnl ========================================================
91 dnl Checks for compilers.
92 dnl ========================================================
94 if test "$COMPILE_ENVIRONMENT"; then
96 if test "$target" != "$host"; then
97     MOZ_CROSS_COMPILER
98 else
99     AC_PROG_CC
100     case "$target" in
101     *-mingw*)
102       # Work around the conftest.exe access problem on Windows
103       sleep 2
104     esac
105     AC_PROG_CXX
106     AC_PROG_RANLIB
107     MOZ_PATH_PROGS(AS, $AS as, $CC)
108     AC_CHECK_PROGS(STRIP, strip, :)
109     AC_CHECK_PROGS(OTOOL, otool, :)
112 if test -n "$MOZ_WINCONSOLE"; then
113     AC_DEFINE(MOZ_WINCONSOLE)
116 MOZ_TOOL_VARIABLES
118 dnl ========================================================
119 dnl Special win32 checks
120 dnl ========================================================
122 WINVER=601
124 case "$target" in
125 *-mingw*)
126     if test "$GCC" != "yes"; then
127         # Check to see if we are really running in a msvc environemnt
128         _WIN32_MSVC=1
130         # Make sure compilers are valid
131         CXXFLAGS="$CXXFLAGS -TP"
132         AC_LANG_SAVE
133         AC_LANG_C
134         AC_TRY_COMPILE([#include <stdio.h>],
135             [ printf("Hello World\n"); ],,
136             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
138         AC_LANG_CPLUSPLUS
139         AC_TRY_COMPILE([#include <new.h>],
140             [ unsigned *test = new unsigned(42); ],,
141             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
142         AC_LANG_RESTORE
144         changequote(,)
145         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
146         changequote([,])
148         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
149         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
150         AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
152         _CC_SUITE=14
153         MSVC_C_RUNTIME_DLL=vcruntime140.dll
154         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
156         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
157         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
159         if test -n "$WIN_UCRT_REDIST_DIR"; then
160           if test ! -d "$WIN_UCRT_REDIST_DIR"; then
161             AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
162           fi
163           WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
164         fi
166         AC_SUBST(MSVC_C_RUNTIME_DLL)
167         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
169         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
171         if test -n "$WIN32_REDIST_DIR"; then
172           if test ! -d "$WIN32_REDIST_DIR"; then
173             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
174           fi
175           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
176         fi
178         # Check linker version, except in lld builds
179         case "$LINKER" in
180         *lld*)
181             ;;
182         *)
183             _LD_FULL_VERSION=`"${LINKER}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
184             _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
185             if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
186                 AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
187             fi
188             ;;
189         esac
191         INCREMENTAL_LINKER=1
193         unset _MSVC_VER_FILTER
195         WRAP_STL_INCLUDES=1
196         STL_FLAGS="-I${DIST}/stl_wrappers"
197     else
198         # Check w32api version
199         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
200         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
201         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
202         AC_TRY_COMPILE([#include <w32api.h>],
203             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
204                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
205                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
206                 #error "test failed."
207             #endif
208             , [ res=yes ], [ res=no ])
209         AC_MSG_RESULT([$res])
210         if test "$res" != "yes"; then
211             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
212         fi
213         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
214         # causing problems with local implementations with the same name.
215         AC_DEFINE(STRSAFE_NO_DEPRECATE)
216     fi # !GNU_CC
218     CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
219     CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
221     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
222     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
223     # Require OS features provided by IE 8.0 (Win7)
224     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
226     ;;
227 esac
229 if test -n "$_WIN32_MSVC"; then
230     SKIP_PATH_CHECKS=1
231     SKIP_COMPILER_CHECKS=1
232     SKIP_LIBRARY_CHECKS=1
234     # Since we're skipping compiler and library checks, hard-code
235     # some facts here.
236     AC_DEFINE(HAVE_IO_H)
237     AC_DEFINE(HAVE_ISATTY)
240 fi # COMPILE_ENVIRONMENT
242 AC_SUBST(GNU_CC)
243 AC_SUBST(GNU_CXX)
245 AC_SUBST_LIST(STL_FLAGS)
246 AC_SUBST(WRAP_STL_INCLUDES)
248 dnl ========================================================
249 dnl Checks for programs.
250 dnl ========================================================
251 if test "$COMPILE_ENVIRONMENT"; then
253 AC_PATH_XTRA
255 XCFLAGS="$X_CFLAGS"
257 fi # COMPILE_ENVIRONMENT
259 dnl ========================================================
260 dnl set the defaults first
261 dnl ========================================================
262 MOZ_USER_DIR=".mozilla"
264 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
266 MOZ_FS_LAYOUT=unix
268 dnl Configure platform-specific CPU architecture compiler options.
269 dnl ==============================================================
270 if test "$COMPILE_ENVIRONMENT"; then
271     MOZ_ARCH_OPTS
272 fi # COMPILE_ENVIRONMENT
274 dnl ========================================================
275 dnl Android libstdc++
276 dnl ========================================================
278 MOZ_ANDROID_CPU_ARCH
279 if test "$COMPILE_ENVIRONMENT"; then
280     MOZ_ANDROID_STLPORT
281 fi # COMPILE_ENVIRONMENT
283 dnl ========================================================
284 dnl Suppress Clang Argument Warnings
285 dnl ========================================================
286 WARNINGS_CFLAGS="$_WARNINGS_CFLAGS"
287 if test -n "${CLANG_CC}${CLANG_CL}"; then
288     WARNINGS_CFLAGS="-Qunused-arguments $WARNINGS_CFLAGS"
289     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
291 if test -n "${CLANG_CXX}${CLANG_CL}"; then
292     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
295 if test -n "$COMPILE_ENVIRONMENT"; then
296    MOZ_CONFIG_SANITIZE
299 dnl ========================================================
300 dnl GNU specific defaults
301 dnl ========================================================
302 if test "$GNU_CC"; then
303     MMX_FLAGS="-mmmx"
304     SSE_FLAGS="-msse"
305     SSE2_FLAGS="-msse2"
306     SSSE3_FLAGS="-mssse3"
307     CFLAGS="$CFLAGS -fno-strict-aliasing"
308     DSO_CFLAGS=''
310     if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
311         DSO_PIC_CFLAGS='-fPIC'
312         ASFLAGS="$ASFLAGS -fPIC"
313     fi
315     AC_MSG_CHECKING([for --noexecstack option to as])
316     _SAVE_CFLAGS=$CFLAGS
317     CFLAGS="$CFLAGS -Wa,--noexecstack"
318     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
319                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
320                      AC_MSG_RESULT([no]))
321     CFLAGS=$_SAVE_CFLAGS
322     AC_MSG_CHECKING([for -z noexecstack option to ld])
323     _SAVE_LDFLAGS=$LDFLAGS
324     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
325     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
326                   AC_MSG_RESULT([no])
327                   LDFLAGS=$_SAVE_LDFLAGS)
329     AC_MSG_CHECKING([for -z text option to ld])
330     _SAVE_LDFLAGS=$LDFLAGS
331     LDFLAGS="$LDFLAGS -Wl,-z,text"
332     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
333                   AC_MSG_RESULT([no])
334                   LDFLAGS=$_SAVE_LDFLAGS)
336     AC_MSG_CHECKING([for -z relro option to ld])
337     _SAVE_LDFLAGS=$LDFLAGS
338     LDFLAGS="$LDFLAGS -Wl,-z,relro"
339     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
340                   AC_MSG_RESULT([no])
341                   LDFLAGS=$_SAVE_LDFLAGS)
343     AC_MSG_CHECKING([for -z nocopyreloc option to ld])
344     _SAVE_LDFLAGS=$LDFLAGS
345     LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
346     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
347                   AC_MSG_RESULT([no])
348                   LDFLAGS=$_SAVE_LDFLAGS)
350     AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
351     _SAVE_LDFLAGS=$LDFLAGS
352     LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
353     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
354                   AC_MSG_RESULT([no])
355                   LDFLAGS=$_SAVE_LDFLAGS)
357     AC_MSG_CHECKING([for --build-id=sha1 option to ld])
358     _SAVE_LDFLAGS=$LDFLAGS
359     LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
360     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
361                   AC_MSG_RESULT([no])
362                   LDFLAGS=$_SAVE_LDFLAGS)
364     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
365     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
366     _SAVE_LDFLAGS=$LDFLAGS
367     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
368     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
369                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
370                   AC_MSG_RESULT([no]))
371     LDFLAGS=$_SAVE_LDFLAGS
373     # Check for -mssse3 on $CC
374     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
375     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
376     _SAVE_CFLAGS=$CFLAGS
377     CFLAGS="$CFLAGS -mssse3"
378     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
379                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
380                      AC_MSG_RESULT([no]))
381     CFLAGS=$_SAVE_CFLAGS
383     # Check for -msse4.1 on $CC
384     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
385     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
386     _SAVE_CFLAGS=$CFLAGS
387     CFLAGS="$CFLAGS -msse4.1"
388     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
389                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
390                      AC_MSG_RESULT([no]))
391     CFLAGS=$_SAVE_CFLAGS
393     case "${CPU_ARCH}" in
394     x86 | x86_64)
395       AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
396       AC_TRY_COMPILE([],
397                      [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
398                      result="yes", result="no")
399       AC_MSG_RESULT("$result")
400       if test "$result" = "yes"; then
401           HAVE_X86_AVX2=1
402       fi
403       ;;
405     ppc*)
406       AC_MSG_CHECKING([whether we can enable AltiVec support])
407       HAVE_ALTIVEC=
408       _SAVE_CFLAGS=$CFLAGS
409       CFLAGS="$CFLAGS -maltivec"
410       AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
411                        [HAVE_ALTIVEC=1],
412                        AC_MSG_RESULT([no]))
413       CFLAGS=$_SAVE_CFLAGS
414       ;;
415     esac
417     DSO_LDOPTS='-shared'
418     if test "$GCC_USE_GNU_LD"; then
419         # Some tools like ASan use a runtime library that is only
420         # linked against executables, so we must allow undefined
421         # symbols for shared objects in some cases.
422         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
423             # Don't allow undefined symbols in libraries
424             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
426             # BSDs need `environ' exposed for posix_spawn (bug 753046)
427             case "$OS_TARGET" in
428             DragonFly|FreeBSD|NetBSD|OpenBSD)
429                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
430                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
431                 else
432                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
433                 fi
434                 ;;
435             esac
436         fi
437     fi
439     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
441     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
444 if test "$GNU_CXX"; then
445     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
447     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
450 dnl ========================================================
451 dnl = Enable DMD
452 dnl ========================================================
454 if test "$MOZ_DMD"; then
455     if test "${CPU_ARCH}" = "arm"; then
456         CFLAGS="$CFLAGS -funwind-tables"
457         CXXFLAGS="$CXXFLAGS -funwind-tables"
458     fi
461 dnl ========================================================
462 dnl System overrides of the defaults for host
463 dnl ========================================================
464 case "$host" in
465 *mingw*)
466     if test -n "$_WIN32_MSVC"; then
467         HOST_CFLAGS="$HOST_CFLAGS"
468     else
469         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
470     fi
471     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
472     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
473     HOST_BIN_SUFFIX=.exe
475     case "${host_cpu}" in
476     i*86)
477         if test -n "$_WIN32_MSVC"; then
478             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
479         fi
480         ;;
481     x86_64)
482         if test -n "$_WIN32_MSVC"; then
483             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
484         fi
485         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
486         ;;
487     esac
488     ;;
490 *-darwin*)
491     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
492     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
493     ;;
495 *-linux*|*-kfreebsd*-gnu|*-gnu*)
496     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
497     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
498     ;;
501     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
502     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
503     ;;
504 esac
506 dnl ========================================================
507 dnl System overrides of the defaults for target
508 dnl ========================================================
510 case "$target" in
511 *-darwin*)
512     MOZ_OPTIMIZE_FLAGS="-O3"
513     CXXFLAGS="$CXXFLAGS -stdlib=libc++"
514     DSO_LDOPTS=''
515     # The ExceptionHandling framework is needed for Objective-C exception
516     # logging code in nsObjCExceptions.h. Currently we only use that in debug
517     # builds.
518     MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
520     dnl DTrace and -dead_strip don't interact well. See bug 403132.
521     dnl ===================================================================
522     if test "x$enable_dtrace" = "xyes"; then
523         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
524     else
525         dnl check for the presence of the -dead_strip linker flag
526         AC_MSG_CHECKING([for -dead_strip option to ld])
527         _SAVE_LDFLAGS=$LDFLAGS
528         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
529         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
530         if test -n "$_HAVE_DEAD_STRIP" ; then
531             AC_MSG_RESULT([yes])
532             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
533         else
534             AC_MSG_RESULT([no])
535         fi
537         LDFLAGS=$_SAVE_LDFLAGS
538     fi
540     MOZ_FIX_LINK_PATHS="-Wl,-executable_path,${DIST}/bin"
541     ;;
543 *-android*|*-linuxandroid*)
544     if test "$COMPILE_ENVIRONMENT" -a -n "$MOZ_MEMORY"; then
545         MOZ_LINKER=1
546     fi
548     MOZ_GFX_OPTIMIZE_MOBILE=1
549     if test -z "$CLANG_CC"; then
550         MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
551     elif test -n "$RELEASE_OR_BETA"; then
552         # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
553         # -Oz is smaller than -Os on clang.
554         MOZ_OPTIMIZE_FLAGS="-Oz"
555         # Disable the outliner, which causes performance regressions, and is
556         # enabled on some platforms at -Oz.
557         if test -z "$MOZ_LTO"; then
558             DISABLE_OUTLINER="-mno-outline"
559             _SAVE_CFLAGS=$CFLAGS
560             CFLAGS="$CFLAGS $DISABLE_OUTLINER"
561             AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
562             CFLAGS="$_SAVE_CFLAGS"
563         else
564             DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
565             _SAVE_LDFLAGS=$LDFLAGS
566             LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
567             AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
568             LDFLAGS="$_SAVE_LDFLAGS"
569         fi
570     else
571         MOZ_OPTIMIZE_FLAGS="-O2"
572     fi
573     ;;
575 *-*linux*)
576     if test "$GNU_CC" -o "$GNU_CXX"; then
577         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
578         if test -n "$MOZ_DEBUG"; then
579             MOZ_OPTIMIZE_FLAGS="-Os"
580         else
581             MOZ_OPTIMIZE_FLAGS="-O2"
582         fi
583         if test -z "$CLANG_CC"; then
584            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
585         fi
586     fi
588     case "${target_cpu}" in
589     alpha*)
590         CFLAGS="$CFLAGS -mieee"
591         CXXFLAGS="$CXXFLAGS -mieee"
592     ;;
593     esac
594     ;;
595 *-mingw*)
596     DSO_CFLAGS=
597     DSO_PIC_CFLAGS=
598     # certain versions of cygwin's makedepend barf on the
599     # #include <string> vs -I./dist/include/string issue so don't use it
600     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
601         # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
602         if test -z "$CLANG_CC"; then
603             AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
604         fi
606         DSO_LDOPTS='-shared'
607         # Use temp file for windres (bug 213281)
608         RCFLAGS='-O coff --use-temp-file'
609         # mingw doesn't require kernel32, user32, and advapi32 explicitly
610         LIBS="$LIBS -luuid -lusp10 -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32"
611         MOZ_FIX_LINK_PATHS=
613         MOZ_OPTIMIZE_FLAGS="-O2"
615         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
616         WIN32_GUI_EXE_LDFLAGS=-mwindows
618         # Silence problematic clang warnings
619         CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
620         LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
621     else
622         TARGET_COMPILER_ABI=msvc
623         RANLIB='echo not_ranlib'
624         STRIP='echo not_strip'
625         # aarch64 doesn't support subsystems below 6.02
626         if test "$CPU_ARCH" = "aarch64"; then
627             WIN32_SUBSYSTEM_VERSION=6.02
628         else
629             WIN32_SUBSYSTEM_VERSION=6.01
630         fi
631         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
632         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
633         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
634         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
635         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
636         CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
637         CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
638         if test -z "$CLANG_CL"; then
639             CPPFLAGS="$CPPFLAGS -utf-8"
640         fi
641         if test "$CPU_ARCH" = "x86"; then
642             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
643             dnl more recent, so set that explicitly here unless another
644             dnl target arch has already been set.
645             changequote(,)
646             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
647               CFLAGS="$CFLAGS -arch:SSE2"
648             fi
649             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
650               CXXFLAGS="$CXXFLAGS -arch:SSE2"
651             fi
652             changequote([,])
653             SSE_FLAGS="-arch:SSE"
654             SSE2_FLAGS="-arch:SSE2"
655             dnl MSVC allows the use of intrinsics without any flags
656             dnl and doesn't have a separate arch for SSSE3
657             SSSE3_FLAGS="-arch:SSE2"
658         fi
659         dnl clang-cl requires appropriate flags to enable SSSE3 support
660         dnl on all architectures.
661         if test -n "$CLANG_CL"; then
662             SSSE3_FLAGS="-mssse3"
663         fi
664         dnl VS2013+ supports -Gw for better linker optimizations.
665         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
666         dnl Disabled on ASan because it causes false-positive ODR violations.
667         if test -z "$MOZ_ASAN"; then
668             CFLAGS="$CFLAGS -Gw"
669             CXXFLAGS="$CXXFLAGS -Gw"
670         else
671             # String tail merging doesn't play nice with ASan's ODR checker.
672             LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
673         fi
674         if test -n "$CLANG_CL"; then
675             # XXX We should combine some of these with our generic GCC-style
676             # warning checks.
677             #
678             # Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
679             CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
680             # We use offsetof on non-POD objects all the time.
681             # We also suppress this warning on other platforms.
682             CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
683             # This warns for reasonable things like:
684             #   enum { X = 0xffffffffU };
685             # which is annoying for IDL headers.
686             CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
687             # This warns for cases that would be reached by the Microsoft
688             # #include rules, but also currently warns on cases that would
689             # *also* be reached by standard C++ include rules.  That
690             # behavior doesn't seem useful, so we turn it off.
691             CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
692             # We normally error out on unknown pragmas, but since clang-cl
693             # claims to be MSVC, it would be difficult to add
694             # #if defined(_MSC_VER) && !defined(__clang__) everywhere we
695             # use such pragmas, so just ignore them.
696             CFLAGS="$CFLAGS -Wno-unknown-pragmas"
697             CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
698             # We get errors about various #pragma intrinsic directives from
699             # clang-cl, and we don't need to hear about those.
700             CFLAGS="$CFLAGS -Wno-ignored-pragmas"
701             CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
702             # clang-cl's Intrin.h marks things like _ReadWriteBarrier
703             # as __attribute((__deprecated__)).  This is nice to know,
704             # but since we don't get the equivalent warning from MSVC,
705             # let's just ignore it.
706             CFLAGS="$CFLAGS -Wno-deprecated-declarations"
707             CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
708             # We use a function like:
709             #   __declspec(noreturn) __inline void f() {}
710             # which -Winvalid-noreturn complains about.  Again, MSVC seems
711             # OK with it, so let's silence the warning.
712             CFLAGS="$CFLAGS -Wno-invalid-noreturn"
713             CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
714             # Missing |override| on virtual function declarations isn't
715             # something that MSVC currently warns about.
716             CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
717             # We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
718             # declaration on |operator delete(void*)|.  However, clang-cl
719             # must internally declare |operator delete(void*)| differently,
720             # which causes this warning for virtually every file in the
721             # tree.  clang-cl doesn't support -fno-exceptions or equivalent,
722             # so there doesn't seem to be any way to convince clang-cl to
723             # declare |delete| differently.  Therefore, suppress this
724             # warning.
725             CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
726             # Macros like STDMETHOD() and IFACEMETHOD() can declare
727             # __attribute__((nothrow)) on their respective method declarations,
728             # while the definitions are left without the matching attribute.
729             CXXFLAGS="$CXXFLAGS -Wno-microsoft-exception-spec"
730             # At least one MSVC header and several headers in-tree have
731             # unused typedefs, so turn this on.
732             CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
733             # jemalloc uses __declspec(allocator) as a profiler hint,
734             # which clang-cl doesn't understand.
735             CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
736             # __attribute__((unused)) really means "might be unused" and
737             # we use it to avoid warnings about things that are unused
738             # in some compilation units, but used in many others.  This
739             # warning insists on complaining about the latter case, which
740             # is annoying, and rather noisy.
741             CXXFLAGS="$CXXFLAGS -Wno-used-but-marked-unused"
742         fi
743         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
744         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
745         LIBS="$LIBS user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib"
746         MOZ_DEBUG_LDFLAGS='-DEBUG'
747         # Use a higher optimization level for clang-cl, so we can come closer
748         # to MSVC's performance numbers (see bug 1443590).
749         if test -n "$CLANG_CL"; then
750             MOZ_OPTIMIZE_FLAGS='-O2'
751         else
752             MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
753         fi
754         MOZ_FIX_LINK_PATHS=
755         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
756         if test -z "$DEVELOPER_OPTIONS"; then
757             LDFLAGS="$LDFLAGS -RELEASE"
758         fi
759         RCFLAGS="-nologo"
760         dnl Minimum reqiurement of Gecko is VS2015 or later which supports
761         dnl both SSSE3 and SSE4.1.
762         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
763         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
764         dnl allow AVX2 code from VS2015
765         HAVE_X86_AVX2=1
766     fi
767     AC_DEFINE(WIN32_LEAN_AND_MEAN)
768     dnl See http://support.microsoft.com/kb/143208 to use STL
769     AC_DEFINE(NOMINMAX)
770     BIN_SUFFIX='.exe'
771     MOZ_USER_DIR="Mozilla"
773     case "$host_os" in
774     cygwin*|msvc*|mks*)
775         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.])
776         ;;
777     esac
779     case "$target" in
780     i*86-*)
781         if test -n "$GNU_CC"; then
782             CFLAGS="$CFLAGS -mstackrealign"
783             CXXFLAGS="$CXXFLAGS -mstackrealign"
784             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
785         else
786             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
787             LDFLAGS="$LDFLAGS -SAFESEH"
788         fi
790         AC_DEFINE(_X86_)
791         ;;
792     x86_64-*)
793         if test -n "$_WIN32_MSVC"; then
794             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
795         fi
796         AC_DEFINE(_AMD64_)
797         ;;
798     aarch64-*)
799         if test -n "$_WIN32_MSVC"; then
800             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
801         fi
802         AC_DEFINE(_ARM64_)
803         ;;
804     *)
805         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
806         ;;
807     esac
808     ;;
810 *-netbsd*)
811     DSO_CFLAGS=''
812     CFLAGS="$CFLAGS -Dunix"
813     CXXFLAGS="$CXXFLAGS -Dunix"
814     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
815         DSO_PIC_CFLAGS='-fPIC -DPIC'
816         DSO_LDOPTS='-shared'
817         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
818     else
819         DSO_PIC_CFLAGS='-fPIC -DPIC'
820         DSO_LDOPTS='-shared'
821     fi
822     # This will fail on a.out systems prior to 1.5.1_ALPHA.
823     if test "$LIBRUNPATH"; then
824         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
825     fi
826     ;;
828 *-openbsd*)
829     if test -z "$X11BASE"; then
830         X11BASE=/usr/X11R6
831     fi
832     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
833     DSO_CFLAGS=''
834     DSO_PIC_CFLAGS='-fPIC'
835     DSO_LDOPTS='-shared -fPIC'
836     if test "$LIBRUNPATH"; then
837         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
838     fi
839     ;;
841 *-solaris*)
842     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
843     ;;
845 esac
847 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
848     MOZ_OPTIMIZE_FLAGS="-O"
851 AC_SUBST_LIST(MMX_FLAGS)
852 AC_SUBST_LIST(SSE_FLAGS)
853 AC_SUBST_LIST(SSE2_FLAGS)
854 AC_SUBST_LIST(SSSE3_FLAGS)
856 AC_SUBST(MOZ_LINKER)
857 if test -n "$MOZ_LINKER"; then
858   AC_DEFINE(MOZ_LINKER)
859   MOZ_LINKER_EXTRACT=1
860   AC_CHECK_PROGS(XZ, xz)
863 if test -z "$COMPILE_ENVIRONMENT"; then
864     SKIP_COMPILER_CHECKS=1
865     SKIP_LIBRARY_CHECKS=1
866     MOZ_DEBUGGING_OPTS
867 else
868     MOZ_COMPILER_OPTS
869 fi # COMPILE_ENVIRONMENT
871 if test -z "$SKIP_COMPILER_CHECKS"; then
872 dnl Checks for typedefs, structures, and compiler characteristics.
873 dnl ========================================================
874 AC_C_CONST
875 AC_TYPE_MODE_T
876 AC_TYPE_OFF_T
877 AC_TYPE_PID_T
878 AC_TYPE_SIZE_T
879 AC_LANG_CPLUSPLUS
880 AC_LANG_C
882 AC_LANG_CPLUSPLUS
884 MOZ_CXX11
886 AC_LANG_C
888 case "${OS_TARGET}" in
889 Darwin)
890   ;;
892   STL_FLAGS="-I${DIST}/stl_wrappers"
893   WRAP_STL_INCLUDES=1
894   ;;
895 esac
897 if test "$MOZ_BUILD_APP" = "tools/crashreporter"; then
898     WRAP_STL_INCLUDES=
901 dnl Checks for header files.
902 dnl ========================================================
903 AC_HEADER_DIRENT
904 case "$target_os" in
905 bitrig*|dragonfly*|freebsd*|openbsd*)
906 # for stuff like -lXshm
907     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
908     ;;
909 esac
911 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
912 AC_CACHE_CHECK(for sockaddr_in.sin_len,
913                    ac_cv_sockaddr_in_sin_len,
914                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
915                                     #include <sys/types.h>
916                                     #endif
917                                     #include <netinet/in.h>
918                                     struct sockaddr_in x;
919                                     void *foo = (void*) &x.sin_len;],
920                                    [],
921                                    [ac_cv_sockaddr_in_sin_len=true],
922                                    [ac_cv_sockaddr_in_sin_len=false])])
923 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
924   AC_DEFINE(HAVE_SIN_LEN)
925 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
926   AC_DEFINE(HAVE_SCONN_LEN)
929 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
930                ac_cv_sockaddr_in6_sin6_len,
931                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
932                                 #include <sys/types.h>
933                                 #endif
934                                 #include <netinet/in.h>
935                                 struct sockaddr_in6 x;
936                                 void *foo = (void*) &x.sin6_len;],
937                                [],
938                                [ac_cv_sockaddr_in6_sin6_len=true],
939                                [ac_cv_sockaddr_in6_sin6_len=false])])
940 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
941   AC_DEFINE(HAVE_SIN6_LEN)
944 AC_CACHE_CHECK(for sockaddr.sa_len,
945                ac_cv_sockaddr_sa_len,
946                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
947                                 #include <sys/types.h>
948                                 #endif
949                                 #include <sys/socket.h>
950                                 struct sockaddr x;
951                                 void *foo = (void*) &x.sa_len;],
952                                [],
953                                [ac_cv_sockaddr_sa_len=true],
954                                [ac_cv_sockaddr_sa_len=false])])
955 if test "$ac_cv_sockaddr_sa_len" = true ; then
956   AC_DEFINE(HAVE_SA_LEN)
959 dnl Checks for libraries.
960 dnl ========================================================
961 AC_CHECK_LIB(c_r, gethostbyname_r)
963 dnl We don't want to link with libdl even if it's present on OS X, since
964 dnl it's not used and not part of the default installation. OS/2 has dlfcn
965 dnl in libc.
966 dnl We don't want to link against libm or libpthread on Darwin since
967 dnl they both are just symlinks to libSystem and explicitly linking
968 dnl against libSystem causes issues when debugging (see bug 299601).
969 case $target in
970 *-darwin*)
971     ;;
973     AC_SEARCH_LIBS(dlopen, dl,
974         MOZ_CHECK_HEADER(dlfcn.h,
975         AC_DEFINE(HAVE_DLOPEN)))
976     ;;
977 esac
979 _SAVE_CFLAGS="$CFLAGS"
980 CFLAGS="$CFLAGS -D_GNU_SOURCE"
981 AC_CHECK_FUNCS(dladdr memmem)
982 CFLAGS="$_SAVE_CFLAGS"
984 if test ! "$GNU_CXX"; then
985     AC_CHECK_LIB(C, demangle)
988 AC_CHECK_LIB(socket, socket)
990 XLDFLAGS="$X_LIBS"
991 XLIBS="$X_EXTRA_LIBS"
993 dnl ========================================================
994 dnl Checks for X libraries.
995 dnl Ordering is important.
996 dnl Xt is dependent upon SM as of X11R6
997 dnl ========================================================
998 if test -n "$MOZ_X11"; then
999     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
1000     _SAVE_LDFLAGS="$LDFLAGS"
1001     _SAVE_LIBS="$LIBS"
1002     LDFLAGS="$XLDFLAGS $LDFLAGS"
1003     AC_CHECK_LIB(X11, XDrawLines, [XLIBS="-lX11 $XLIBS"],
1004         [MISSING_X="$MISSING_X -lX11"], $XLIBS)
1005     AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
1006         [MISSING_X="$MISSING_X -lXext"], $XLIBS)
1008     AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
1009         unset ac_cv_lib_Xt_XtFree
1010         AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
1011         AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
1012         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
1013             [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
1014         ])
1016     dnl ========================================================
1017     dnl = Check for xcb
1018     dnl ========================================================
1019     AC_CHECK_LIB(xcb, xcb_connect, [XLIBS="-lxcb $XLIBS"],
1020         [MISSING_X="$MISSING_X -lxcb"], $XLIBS)
1021     AC_CHECK_LIB(xcb-shm, xcb_shm_query_version, [XLIBS="-lxcb-shm $XLIBS"],
1022         [MISSING_X="$MISSING_X -lxcb-shm"], $XLIBS)
1023     AC_CHECK_LIB(X11-xcb, XGetXCBConnection, [XLIBS="-lX11-xcb $XLIBS"],
1024         [MISSING_X="$MISSING_X -lX11-xcb"], $XLIBS)
1026     LDFLAGS="$_SAVE_LDFLAGS"
1027     LIBS="$_SAVE_LIBS"
1028 fi # $MOZ_X11
1030 AC_SUBST_LIST(XCFLAGS)
1031 AC_SUBST_LIST(XLDFLAGS)
1032 AC_SUBST_LIST(XLIBS)
1033 AC_SUBST_LIST(XEXT_LIBS)
1034 AC_SUBST_LIST(XT_LIBS)
1036 dnl ========================================================
1037 dnl = pthread support
1038 dnl = Start by checking whether the system support pthreads
1039 dnl ========================================================
1040 case "$target_os" in
1041 darwin*)
1042     MOZ_USE_PTHREADS=1
1043     ;;
1045     AC_CHECK_LIB(pthreads, pthread_create,
1046         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
1047         AC_CHECK_LIB(pthread, pthread_create,
1048             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
1049             AC_CHECK_LIB(c_r, pthread_create,
1050                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
1051                 AC_CHECK_LIB(c, pthread_create,
1052                     MOZ_USE_PTHREADS=1
1053                 )
1054             )
1055         )
1056     )
1057     ;;
1058 esac
1060 dnl ========================================================
1061 dnl Do the platform specific pthread hackery
1062 dnl ========================================================
1063 if test "$MOZ_USE_PTHREADS"x != x
1064 then
1065     dnl
1066     dnl See if -pthread is supported.
1067     dnl
1068     rm -f conftest*
1069     ac_cv_have_dash_pthread=no
1070     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
1071     echo 'int main() { return 0; }' | cat > conftest.c
1072     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
1073     if test $? -eq 0; then
1074         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1075             ac_cv_have_dash_pthread=yes
1076             case "$target_os" in
1077             freebsd*)
1078 # Freebsd doesn't use -pthread for compiles, it uses them for linking
1079                 ;;
1080             *)
1081                 CFLAGS="$CFLAGS -pthread"
1082                 CXXFLAGS="$CXXFLAGS -pthread"
1083                 ;;
1084             esac
1085         fi
1086     fi
1087     rm -f conftest*
1088     AC_MSG_RESULT($ac_cv_have_dash_pthread)
1090     dnl
1091     dnl See if -pthreads is supported.
1092     dnl
1093     ac_cv_have_dash_pthreads=no
1094     if test "$ac_cv_have_dash_pthread" = "no"; then
1095         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
1096         echo 'int main() { return 0; }' | cat > conftest.c
1097         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
1098         if test $? -eq 0; then
1099             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1100                 ac_cv_have_dash_pthreads=yes
1101                 CFLAGS="$CFLAGS -pthreads"
1102                 CXXFLAGS="$CXXFLAGS -pthreads"
1103             fi
1104         fi
1105         rm -f conftest*
1106         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
1107     fi
1109     case "$target" in
1110         *-*-freebsd*)
1111             AC_DEFINE(_REENTRANT)
1112             AC_DEFINE(_THREAD_SAFE)
1113             dnl -pthread links in -lpthread, so don't specify it explicitly.
1114             if test "$ac_cv_have_dash_pthread" = "yes"; then
1115                 _PTHREAD_LDFLAGS="-pthread"
1116             fi
1117             ;;
1119         *-*-openbsd*|*-*-bsdi*)
1120             AC_DEFINE(_REENTRANT)
1121             AC_DEFINE(_THREAD_SAFE)
1122             dnl -pthread links in -lc_r, so don't specify it explicitly.
1123             if test "$ac_cv_have_dash_pthread" = "yes"; then
1124                 _PTHREAD_LDFLAGS="-pthread"
1125             fi
1126             ;;
1128         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
1129             AC_DEFINE(_REENTRANT)
1130             ;;
1132     esac
1133     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
1134     AC_SUBST(MOZ_USE_PTHREADS)
1135     MOZ_CHECK_HEADERS(pthread.h)
1139 dnl Checks for library functions.
1140 dnl ========================================================
1141 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall)
1143 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
1144 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
1145                ac_cv_clock_monotonic,
1146                [for libs in "" -lrt; do
1147                     _SAVE_LIBS="$LIBS"
1148                     _SAVE_CFLAGS="$CFLAGS"
1149                     LIBS="$LIBS $libs"
1150                     CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
1151 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
1152 dnl we should or not be able to use it. To detect if we can, we need to make the
1153 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
1154                     AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
1155                                  #include <time.h>],
1156                                  [ struct timespec ts;
1157                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
1158                                  ac_cv_clock_monotonic=$libs
1159                                  LIBS="$_SAVE_LIBS"
1160                                  CFLAGS="$_SAVE_CFLAGS"
1161                                  break,
1162                                  ac_cv_clock_monotonic=no)
1163                     LIBS="$_SAVE_LIBS"
1164                     CFLAGS="$_SAVE_CFLAGS"
1165                 done])
1166 if test "$ac_cv_clock_monotonic" != "no"; then
1167     HAVE_CLOCK_MONOTONIC=1
1168     REALTIME_LIBS=$ac_cv_clock_monotonic
1169     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
1170     AC_SUBST(HAVE_CLOCK_MONOTONIC)
1171     AC_SUBST_LIST(REALTIME_LIBS)
1174 dnl Turn on warnings-as-errors to prevent implicit declaration of
1175 dnl pthread_cond_timedwait_monotonic_np, which can cause this test to
1176 dnl inadvertently pass even if the function does not really exist.
1177 _SAVE_CFLAGS="$CFLAGS"
1178 CFLAGS="$CFLAGS $WARNINGS_AS_ERRORS"
1179 AC_CACHE_CHECK(for pthread_cond_timedwait_monotonic_np,
1180                ac_cv_pthread_cond_timedwait_monotonic_np,
1181                AC_TRY_LINK([#include <pthread.h>],
1182                            [pthread_cond_timedwait_monotonic_np(0, 0, 0);],
1183                            ac_cv_pthread_cond_timewait_monotonic_np=yes,
1184                            ac_cv_pthread_cond_timewait_monotonic_np=no))
1185 if test "$ac_cv_pthread_cond_timewait_monotonic_np" != "no"; then
1186     AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
1188 CFLAGS=$_SAVE_CFLAGS
1190 AC_CACHE_CHECK(
1191     [for res_ninit()],
1192     ac_cv_func_res_ninit,
1193     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
1194         dnl no need for res_ninit() on NetBSD and OpenBSD
1195         ac_cv_func_res_ninit=no
1196      else
1197         AC_TRY_LINK([
1198             #ifdef linux
1199             #define _BSD_SOURCE 1
1200             #endif
1201             #include <sys/types.h>
1202             #include <netinet/in.h>
1203             #include <arpa/nameser.h>
1204             #include <resolv.h>
1205             ],
1206             [int foo = res_ninit(&_res);],
1207             [ac_cv_func_res_ninit=yes],
1208             [ac_cv_func_res_ninit=no])
1209      fi
1210     ])
1212 if test "$ac_cv_func_res_ninit" = "yes"; then
1213     AC_DEFINE(HAVE_RES_NINIT)
1214 dnl must add the link line we do something as foolish as this... dougt
1215 dnl else
1216 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
1217 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
1220 AC_LANG_C
1222 dnl **********************
1223 dnl *** va_copy checks ***
1224 AC_CACHE_CHECK([for an implementation of va_copy()],
1225                ac_cv_va_copy,
1226     [AC_TRY_COMPILE([#include <stdarg.h>
1227                      #include <stdlib.h>
1228         void f (int i, ...) {
1229             va_list args1, args2;
1230             va_start (args1, i);
1231             va_copy (args2, args1);
1232             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1233                 exit (1);
1234             va_end (args1); va_end (args2);
1235         }],
1236         [f(0, 42); return 0],
1237         [ac_cv_va_copy=yes],
1238         [ac_cv_va_copy=no]
1239     )]
1241 AC_CACHE_CHECK([whether va_list can be copied by value],
1242                ac_cv_va_val_copy,
1243     [AC_TRY_COMPILE([#include <stdarg.h>
1244                      #include <stdlib.h>
1245         void f (int i, ...) {
1246             va_list args1, args2;
1247             va_start (args1, i);
1248             args2 = args1;
1249             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1250                 exit (1);
1251             va_end (args1); va_end (args2);
1252         }],
1253         [f(0, 42); return 0],
1254         [ac_cv_va_val_copy=yes],
1255         [ac_cv_va_val_copy=no],
1256     )]
1258 if test "x$ac_cv_va_copy" = "xyes"; then
1259     AC_DEFINE(VA_COPY, va_copy)
1260     AC_DEFINE(HAVE_VA_COPY)
1263 if test "x$ac_cv_va_val_copy" = "xno"; then
1264    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
1267 dnl ===================================================================
1268 dnl ========================================================
1269 dnl Put your C++ language/feature checks below
1270 dnl ========================================================
1271 AC_LANG_CPLUSPLUS
1273 ARM_ABI_PREFIX=
1274 if test "$GNU_CC"; then
1275   if test "$CPU_ARCH" = "arm" ; then
1276     AC_CACHE_CHECK(for ARM EABI,
1277         ac_cv_gcc_arm_eabi,
1278         [AC_TRY_COMPILE([],
1279                         [
1280 #if defined(__ARM_EABI__)
1281   return 0;
1282 #else
1283 #error Not ARM EABI.
1284 #endif
1285                         ],
1286                         ac_cv_gcc_arm_eabi="yes",
1287                         ac_cv_gcc_arm_eabi="no")])
1288     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
1289         HAVE_ARM_EABI=1
1290         ARM_ABI_PREFIX=eabi-
1291     else
1292         ARM_ABI_PREFIX=oabi-
1293     fi
1294   fi
1296   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
1299 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
1300 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
1301 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
1302 # linking XUL.
1303 _SAVE_LDFLAGS=$LDFLAGS
1304 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
1305 AC_CACHE_CHECK(for __thread keyword for TLS variables,
1306                ac_cv_thread_keyword,
1307                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
1308                             [return tlsIsMainThread;],
1309                             ac_cv_thread_keyword=yes,
1310                             ac_cv_thread_keyword=no)])
1311 LDFLAGS=$_SAVE_LDFLAGS
1312 # The custom dynamic linker doesn't support TLS variables
1313 MOZ_TLS=
1314 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
1315   # mips builds fail with TLS variables because of a binutils bug.
1316   # See bug 528687
1317   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
1318   case "${target}" in
1319     mips*-*)
1320       :
1321       ;;
1322     *-android*|*-linuxandroid*)
1323       :
1324       ;;
1325     *-openbsd*)
1326       :
1327       ;;
1328     *)
1329       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
1330       MOZ_TLS=1
1331       ;;
1332   esac
1335 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
1336 if test -n "$MOZ_LINKER"; then
1337   if test "$CPU_ARCH" = arm; then
1338     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
1339     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
1340       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1341       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1342     fi
1343   fi
1345 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
1346 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
1347 dnl Since the linker only understands the sysv ones, no need to build the
1348 dnl gnu style tables anyways.
1349   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
1352 dnl End of C++ language/feature checks
1353 AC_LANG_C
1355 dnl ========================================================
1356 dnl =  Internationalization checks
1357 dnl ========================================================
1359 dnl Internationalization and Locale support is different
1360 dnl on various UNIX platforms.  Checks for specific i18n
1361 dnl features go here.
1363 AC_HAVE_FUNCS(localeconv)
1365 fi # ! SKIP_COMPILER_CHECKS
1367 if test -n "${COMPILE_ENVIRONMENT}"; then
1368   MOZ_CHECK_ALLOCATOR
1371 TARGET_XPCOM_ABI=
1372 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1373     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1374     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
1377 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1378 dnl features that Windows actually does support.
1380 if test -n "$SKIP_COMPILER_CHECKS"; then
1381    dnl Windows has malloc.h
1382    AC_DEFINE(MALLOC_H, [<malloc.h>])
1383    AC_DEFINE(HAVE_FORCEINLINE)
1384    AC_DEFINE(HAVE_LOCALECONV)
1385 fi # SKIP_COMPILER_CHECKS
1387 dnl Mozilla specific options
1388 dnl ========================================================
1389 dnl The macros used for command line options
1390 dnl are defined in build/autoconf/altoptions.m4.
1392 dnl ========================================================
1393 dnl =
1394 dnl = Check for external package dependencies
1395 dnl =
1396 dnl ========================================================
1397 MOZ_ARG_HEADER(External Packages)
1399 dnl ========================================================
1400 dnl system libevent Support
1401 dnl ========================================================
1402 MOZ_ARG_WITH_STRING(system-libevent,
1403 [  --with-system-libevent[=PFX]
1404                           Use system libevent [installed at prefix PFX]],
1405     LIBEVENT_DIR=$withval)
1407 _SAVE_CFLAGS=$CFLAGS
1408 _SAVE_LDFLAGS=$LDFLAGS
1409 _SAVE_LIBS=$LIBS
1410 if test "$LIBEVENT_DIR" = yes; then
1411     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
1412         MOZ_SYSTEM_LIBEVENT=1,
1413         LIBEVENT_DIR=/usr)
1415 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
1416     MOZ_SYSTEM_LIBEVENT=
1417 elif test -z "$MOZ_SYSTEM_LIBEVENT"; then
1418     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
1419     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
1420     MOZ_CHECK_HEADER(event.h,
1421         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
1422              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
1423          fi],
1424         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
1425     AC_CHECK_LIB(event, event_init,
1426                  [MOZ_SYSTEM_LIBEVENT=1
1427                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
1428                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
1429                  [MOZ_SYSTEM_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
1431 CFLAGS=$_SAVE_CFLAGS
1432 LDFLAGS=$_SAVE_LDFLAGS
1433 LIBS=$_SAVE_LIBS
1435 AC_SUBST(MOZ_SYSTEM_LIBEVENT)
1437 if test -z "$SKIP_LIBRARY_CHECKS"; then
1439 dnl ========================================================
1440 dnl system PNG Support
1441 dnl ========================================================
1442 MOZ_ARG_WITH_STRING(system-png,
1443 [  --with-system-png[=PFX]
1444                           Use system libpng [installed at prefix PFX]],
1445     PNG_DIR=$withval)
1447 _SAVE_CFLAGS=$CFLAGS
1448 _SAVE_LDFLAGS=$LDFLAGS
1449 _SAVE_LIBS=$LIBS
1450 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
1451     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
1452     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
1454 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
1455     MOZ_SYSTEM_PNG=
1456 else
1457     AC_CHECK_LIB(png, png_get_valid, [MOZ_SYSTEM_PNG=1 MOZ_PNG_LIBS="-lpng"],
1458                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1459     AC_CHECK_LIB(png, png_get_acTL, ,
1460                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
1462 if test "$MOZ_SYSTEM_PNG" = 1; then
1463     AC_TRY_COMPILE([ #include <stdio.h>
1464                      #include <sys/types.h>
1465                      #include <png.h> ],
1466                    [ #if PNG_LIBPNG_VER < $MOZPNG
1467                      #error "Insufficient libpng version ($MOZPNG required)."
1468                      #endif
1469                      #ifndef PNG_UINT_31_MAX
1470                      #error "Insufficient libpng version."
1471                      #endif ],
1472                    MOZ_SYSTEM_PNG=1,
1473                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1475 CFLAGS=$_SAVE_CFLAGS
1476 LDFLAGS=$_SAVE_LDFLAGS
1477 LIBS=$_SAVE_LIBS
1479 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_SYSTEM_PNG" = 1; then
1480     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
1481     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
1484 fi # SKIP_LIBRARY_CHECKS
1486 dnl ========================================================
1487 dnl =
1488 dnl = Application
1489 dnl =
1490 dnl ========================================================
1492 MOZ_ARG_HEADER(Application)
1494 ENABLE_SYSTEM_EXTENSION_DIRS=1
1495 MOZ_BRANDING_DIRECTORY=
1496 MOZ_OFFICIAL_BRANDING=
1497 MOZ_AUTH_EXTENSION=1
1498 MOZ_PREF_EXTENSIONS=1
1499 MOZ_SPELLCHECK=1
1500 MOZ_UNIVERSALCHARDET=1
1501 MOZ_XUL=1
1502 MOZ_ZIPWRITER=1
1503 MOZ_NO_SMART_CARDS=
1504 MOZ_USE_NATIVE_POPUP_WINDOWS=
1505 MOZ_EXCLUDE_HYPHENATION_DICTIONARIES=
1506 MOZ_SANDBOX=1
1507 MOZ_BINARY_EXTENSIONS=
1508 MOZ_DEVTOOLS=server
1510 case "$target_os" in
1511     mingw*)
1512         NS_ENABLE_TSF=1
1513         AC_DEFINE(NS_ENABLE_TSF)
1514         ;;
1515 esac
1517 # Optional Firefox for Android partner distribution directory.
1518 MOZ_ARG_WITH_STRING(android-distribution-directory,
1519 [  --with-android-distribution-directory=dir
1520                           Optional Firefox for Android partner distribution directory.],
1521   MOZ_ANDROID_DISTRIBUTION_DIRECTORY=$withval)
1523 if test -n "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY"; then
1524   # A distribution directory must have an assets/distribution directory.
1525   # See https://wiki.mozilla.org/Mobile/Distribution_Files.
1526   if test ! -d "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY/assets/distribution" ; then
1527     AC_MSG_ERROR([--with-android-distribution-directory does not contain assets/distribution;
1528                   (looked for ${MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets/distribution).])
1529   fi
1531 AC_SUBST(MOZ_ANDROID_DISTRIBUTION_DIRECTORY)
1533 dnl ========================================================
1534 dnl = Trademarked Branding
1535 dnl ========================================================
1536 MOZ_ARG_ENABLE_BOOL(official-branding,
1537 [  --enable-official-branding
1538                           Enable Official mozilla.org Branding
1539                           Do not distribute builds with
1540                           --enable-official-branding unless you have
1541                           permission to use trademarks per
1542                           http://www.mozilla.org/foundation/trademarks/ .],
1543     MOZ_OFFICIAL_BRANDING=1,
1544     MOZ_OFFICIAL_BRANDING=)
1546 # Allow the application to influence configure with a confvars.sh script.
1547 AC_MSG_CHECKING([if app-specific confvars.sh exists])
1548 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
1549   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
1550   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
1551 else
1552   AC_MSG_RESULT([no])
1555 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
1556 MOZ_ARG_WITH_STRING(app-name,
1557 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
1558 WITH_APP_NAME=$withval,
1561 if test -n "$WITH_APP_NAME" ; then
1562     MOZ_APP_NAME="$WITH_APP_NAME"
1565 MOZ_ARG_WITH_STRING(app-basename,
1566 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
1567 WITH_APP_BASENAME=$withval,
1570 if test -n "$WITH_APP_BASENAME" ; then
1571     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
1574 dnl ========================================================
1575 dnl Ensure Android SDK and build-tools versions depending on
1576 dnl mobile target.
1577 dnl ========================================================
1579 case "$MOZ_BUILD_APP" in
1580 mobile/android)
1581     MOZ_ANDROID_SDK
1582     ;;
1583 esac
1585 dnl ========================================================
1586 dnl =
1587 dnl = Toolkit Options
1588 dnl =
1589 dnl ========================================================
1590 MOZ_ARG_HEADER(Toolkit Options)
1592 dnl ========================================================
1593 dnl = Enable the toolkit as needed                         =
1594 dnl ========================================================
1596 case "$MOZ_WIDGET_TOOLKIT" in
1598 cocoa)
1599     LDFLAGS="$LDFLAGS -framework Cocoa"
1600     # Use -Wl as a trick to avoid -framework and framework names from
1601     # being separated by AC_SUBST_LIST.
1602     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'
1603     TK_CFLAGS=""
1604     CFLAGS="$CFLAGS $TK_CFLAGS"
1605     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
1606     MOZ_USER_DIR="Mozilla"
1607     MOZ_FS_LAYOUT=bundle
1608     ;;
1610 uikit)
1611     LDFLAGS="$LDFLAGS -framework UIKit"
1612     TK_CFLAGS=""
1613     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'
1614     CFLAGS="$CFLAGS $TK_CFLAGS"
1615     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
1616     MOZ_USER_DIR="Mozilla"
1617     MOZ_FS_LAYOUT=bundle
1618     ;;
1620 esac
1622 if test "$OS_TARGET" = Darwin; then
1623     LDFLAGS="$LDFLAGS -lobjc"
1626 dnl there are a lot of tests on MOZ_ENABLE_GTK below, that are more convenient
1627 dnl to keep that way than testing against MOZ_WIDGET_TOOLKIT
1628 case "$MOZ_WIDGET_TOOLKIT" in
1629 gtk*)
1630     MOZ_ENABLE_GTK=1
1631     ;;
1632 esac
1634 if test "$COMPILE_ENVIRONMENT"; then
1635   if test "$MOZ_WIDGET_TOOLKIT" = gtk; then
1636     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)
1637     MOZ_GTK3_CFLAGS="-I${_topsrcdir}/widget/gtk/compat-gtk3 $MOZ_GTK3_CFLAGS"
1638     TK_CFLAGS=$MOZ_GTK3_CFLAGS
1639     TK_LIBS=$MOZ_GTK3_LIBS
1640     dnl GDK_VERSION_MIN_REQUIRED is not set here as GDK3 deprecated warnings
1641     dnl are suppressed by widget/gtk/compat-gtk3/gdk/gdkversionmacros.h.
1642     AC_DEFINE_UNQUOTED(GDK_VERSION_MAX_ALLOWED,$GDK_VERSION_MAX_ALLOWED)
1643     GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32
1644   fi
1645   if test "$MOZ_ENABLE_GTK"; then
1646     if test "$MOZ_X11"; then
1647       GDK_PACKAGES=gdk-x11-2.0
1648     fi
1649     AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
1650     AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)
1652     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)
1653     MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
1654   fi
1655 fi # COMPILE_ENVIRONMENT
1657 AC_SUBST(MOZ_FS_LAYOUT)
1659 AC_SUBST_LIST(TK_CFLAGS)
1660 AC_SUBST_LIST(TK_LIBS)
1662 dnl ========================================================
1663 dnl =
1664 dnl = Components & Features
1665 dnl =
1666 dnl ========================================================
1667 MOZ_ARG_HEADER(Components and Features)
1669 AC_SUBST(MOZ_OFFICIAL_BRANDING)
1670 if test -n "$MOZ_OFFICIAL_BRANDING"; then
1671   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
1672     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
1673   else
1674     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
1675     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
1676   fi
1679 MOZ_ARG_WITH_STRING(branding,
1680 [  --with-branding=dir     Use branding from the specified directory.],
1681     MOZ_BRANDING_DIRECTORY=$withval)
1683 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
1684 if test -z "$REAL_BRANDING_DIRECTORY"; then
1685   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
1688 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
1689   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
1690 elif test -f "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
1691   . "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"
1694 AC_SUBST(MOZ_BRANDING_DIRECTORY)
1696 dnl ========================================================
1697 dnl = Distribution ID
1698 dnl ========================================================
1699 MOZ_ARG_WITH_STRING(distribution-id,
1700 [  --with-distribution-id=ID
1701                           Set distribution-specific id (default=org.mozilla)],
1702 [ val=`echo $withval`
1703     MOZ_DISTRIBUTION_ID="$val"])
1705 if test -z "$MOZ_DISTRIBUTION_ID"; then
1706    MOZ_DISTRIBUTION_ID="org.mozilla"
1709 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
1710 AC_SUBST(MOZ_DISTRIBUTION_ID)
1712 dnl ========================================================
1713 dnl = libproxy support
1714 dnl ========================================================
1716 if test "$MOZ_ENABLE_GTK"
1717 then
1718     MOZ_ENABLE_LIBPROXY=
1720     MOZ_ARG_ENABLE_BOOL(libproxy,
1721     [  --enable-libproxy         Enable libproxy support ],
1722     MOZ_ENABLE_LIBPROXY=1,
1723     MOZ_ENABLE_LIBPROXY=)
1725     if test "$MOZ_ENABLE_LIBPROXY"
1726     then
1727         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
1728         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
1729     fi
1731 AC_SUBST(MOZ_ENABLE_LIBPROXY)
1733 dnl ========================================================
1734 dnl = dbus support
1735 dnl ========================================================
1737 if test "$MOZ_ENABLE_GTK"
1738 then
1739     MOZ_ENABLE_DBUS=1
1741     MOZ_ARG_DISABLE_BOOL(dbus,
1742     [  --disable-dbus          Disable dbus support ],
1743         MOZ_ENABLE_DBUS=,
1744         MOZ_ENABLE_DBUS=1)
1746     if test "$MOZ_ENABLE_DBUS"
1747     then
1748         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
1749         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
1750         AC_DEFINE(MOZ_ENABLE_DBUS)
1751     fi
1753 AC_SUBST(MOZ_ENABLE_DBUS)
1755 dnl =========================================================
1756 dnl = Whether to exclude hyphenations files in the build
1757 dnl =========================================================
1758 if test -n "$MOZ_EXCLUDE_HYPHENATION_DICTIONARIES"; then
1759     AC_DEFINE(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
1762 AC_TRY_COMPILE([#include <linux/ethtool.h>],
1763                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
1764                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
1766 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
1768 if test -n "$MOZ_WEBRTC"; then
1769     if test -n "$MOZ_X11"; then
1770       MOZ_WEBRTC_X11_LIBS="-lXext -lXdamage -lXfixes -lXcomposite"
1771     fi
1774 AC_SUBST_LIST(MOZ_WEBRTC_X11_LIBS)
1776 dnl ========================================================
1777 dnl = Apple platform decoder support
1778 dnl ========================================================
1779 if test "$COMPILE_ENVIRONMENT"; then
1780 if test -n "$MOZ_APPLEMEDIA"; then
1781   # hack in frameworks for fmp4 - see bug 1029974
1782   # We load VideoToolbox and CoreMedia dynamically, so they don't appear here.
1783   LDFLAGS="$LDFLAGS -framework AudioToolbox"
1784   dnl Verify CoreMedia is available.
1785   AC_CHECK_HEADERS([CoreMedia/CoreMedia.h VideoToolbox/VideoToolbox.h], [],
1786     [AC_MSG_ERROR([MacOS X 10.9 SDK or later is required])])
1788 fi # COMPILE_ENVIRONMENT
1790 dnl ========================================================
1791 dnl = Handle dependent MEDIA defines
1792 dnl ========================================================
1794 MOZ_WEBM_ENCODER=1
1795 AC_DEFINE(MOZ_WEBM_ENCODER)
1796 AC_SUBST(MOZ_WEBM_ENCODER)
1798 dnl ========================================================
1799 dnl NegotiateAuth
1800 dnl ========================================================
1802 MOZ_ARG_DISABLE_BOOL(negotiateauth,
1803 [  --disable-negotiateauth Disable GSS-API negotiation ],
1804     MOZ_AUTH_EXTENSION=,
1805     MOZ_AUTH_EXTENSION=1 )
1807 dnl ========================================================
1808 dnl Pref extensions (autoconfig)
1809 dnl ========================================================
1810 MOZ_ARG_DISABLE_BOOL(pref-extensions,
1811 [  --disable-pref-extensions
1812                           Disable pref extensions such as autoconfig],
1813   MOZ_PREF_EXTENSIONS=,
1814   MOZ_PREF_EXTENSIONS=1 )
1816 dnl ========================================================
1817 dnl Searching of system directories for extensions.
1818 dnl Note: this switch is meant to be used for test builds
1819 dnl whose behavior should not depend on what happens to be
1820 dnl installed on the local machine.
1821 dnl ========================================================
1822 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
1823 [  --disable-system-extension-dirs
1824                           Disable searching system- and account-global
1825                           directories for extensions of any kind; use
1826                           only profile-specific extension directories],
1827   ENABLE_SYSTEM_EXTENSION_DIRS=,
1828   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
1829 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
1830   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
1833 dnl ========================================================
1834 dnl = Universalchardet
1835 dnl ========================================================
1836 MOZ_ARG_DISABLE_BOOL(universalchardet,
1837 [  --disable-universalchardet
1838                           Disable universal encoding detection],
1839   MOZ_UNIVERSALCHARDET=,
1840   MOZ_UNIVERSALCHARDET=1 )
1842 dnl ========================================================
1843 dnl Gamepad support
1844 dnl ========================================================
1846 if test "$COMPILE_ENVIRONMENT" ; then
1848 dnl Moved gamepad platform check to moz.build, linux header check still needed here.
1849 if test "$OS_TARGET" = "Linux"; then
1850     MOZ_CHECK_HEADER([linux/joystick.h])
1851     if test "$ac_cv_header_linux_joystick_h" != "yes"; then
1852       AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers.])
1853     fi
1856 fi # COMPILE_ENVIRONMENT
1859 dnl ========================================================
1860 dnl = Breakpad crash reporting (on by default on supported platforms)
1861 dnl ========================================================
1863 case $target in
1864 i?86-*-mingw*|x86_64-*-mingw*|aarch64-*-mingw*)
1865   MOZ_CRASHREPORTER=1
1866   ;;
1867 i?86-apple-darwin*|x86_64-apple-darwin*)
1868   MOZ_CRASHREPORTER=1
1869   ;;
1870 *-android*|*-linuxandroid*)
1871   dnl Android/arm is arm-unknown-linux-androideabi, so android condition should
1872   dnl be before Linux condition
1873   MOZ_CRASHREPORTER=1
1874   ;;
1875 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
1876   if test "$MOZ_ENABLE_GTK"; then
1877     MOZ_CRASHREPORTER=1
1878   fi
1879   ;;
1880 esac
1882 MOZ_ARG_DISABLE_BOOL(crashreporter,
1883 [  --disable-crashreporter Disable breakpad crash reporting],
1884     [MOZ_CRASHREPORTER=],
1885     [MOZ_CRASHREPORTER=F # Force enable breakpad])
1887 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "Darwin" -a "$MOZ_WIDGET_TOOLKIT" != "android"; then
1888   if test "$MOZ_CRASHREPORTER" = F; then
1889     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
1890   fi
1891   MOZ_CRASHREPORTER=
1894 if test -n "$MOZ_CRASHREPORTER"; then
1895    AC_DEFINE(MOZ_CRASHREPORTER)
1897   if test "$OS_TARGET" = "Linux" && \
1898     test -z "$SKIP_LIBRARY_CHECKS"; then
1899     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
1900   fi
1902   if test "$OS_ARCH" = "WINNT"; then
1903     if test -z "$HAVE_64BIT_BUILD" -a -n "$COMPILE_ENVIRONMENT"; then
1904       MOZ_CRASHREPORTER_INJECTOR=1
1905       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
1906     fi
1907   fi
1910 dnl ========================================================
1911 dnl = Enable compilation of specific extension modules
1912 dnl ========================================================
1914 MOZ_ARG_ENABLE_STRING(extensions,
1915 [  --enable-extensions     Enable extensions],
1916 [ for option in `echo $enableval | sed 's/,/ /g'`; do
1917     if test "$option" = "yes" -o "$option" = "all"; then
1918         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
1919     elif test "$option" = "no" -o "$option" = "none"; then
1920         MOZ_EXTENSIONS=""
1921     elif test "$option" = "default"; then
1922         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
1923     elif test `echo "$option" | grep -c \^-` != 0; then
1924         option=`echo $option | sed 's/^-//'`
1925         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
1926     else
1927         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
1928     fi
1929 done],
1930     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
1932 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
1933 dnl when trying to build a nonexistent extension.
1934 for extension in $MOZ_EXTENSIONS; do
1935     if test ! -d "${srcdir}/extensions/${extension}"; then
1936         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
1937     fi
1938 done
1940 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
1941   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
1944 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
1945 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
1946 if test -n "$MOZ_TREE_FREETYPE" -a "$OS_TARGET" != WINNT; then
1947    MOZ_ENABLE_CAIRO_FT=1
1948    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
1949    CAIRO_FT_CFLAGS="-I$_topsrcdir/modules/freetype2/include"
1950    AC_SUBST_LIST(CAIRO_FT_CFLAGS)
1953 AC_CHECK_PROGS(WGET, wget, "")
1954 AC_SUBST(WGET)
1956 dnl ========================================================
1957 dnl Updater
1958 dnl ========================================================
1960 MOZ_ARG_DISABLE_BOOL(updater,
1961 [  --disable-updater       Disable building of updater],
1962     MOZ_UPDATER=,
1963     MOZ_UPDATER=1 )
1965 if test -n "$MOZ_UPDATER"; then
1966     AC_DEFINE(MOZ_UPDATER)
1969 dnl ========================================================
1970 dnl parental controls (for Windows Vista)
1971 dnl ========================================================
1972 MOZ_ARG_DISABLE_BOOL(parental-controls,
1973 [  --disable-parental-controls
1974                           Do not build parental controls],
1975    MOZ_DISABLE_PARENTAL_CONTROLS=1,
1976    MOZ_DISABLE_PARENTAL_CONTROLS=)
1977 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
1978     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
1981 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
1983 dnl ========================================================
1984 dnl = Disable smartcard support
1985 dnl ========================================================
1986 if test -n "$MOZ_NO_SMART_CARDS"; then
1987     AC_DEFINE(MOZ_NO_SMART_CARDS)
1989 AC_SUBST(MOZ_NO_SMART_CARDS)
1991 dnl ========================================================
1992 dnl = Sandboxing support
1993 dnl ========================================================
1994 if test -n "$MOZ_TSAN" -o -n "$MOZ_ASAN"; then
1995     # Bug 1182565: TSan conflicts with sandboxing on Linux.
1996     # Bug 1287971: LSan also conflicts with sandboxing on Linux.
1997     case $OS_TARGET in
1998     Linux|Android)
1999         MOZ_SANDBOX=
2000         ;;
2001     esac
2004 MOZ_ARG_DISABLE_BOOL(sandbox,
2005 [  --disable-sandbox        Disable sandboxing support],
2006     MOZ_SANDBOX=,
2007     MOZ_SANDBOX=1)
2009 case "$OS_TARGET" in
2010 WINNT|Darwin|OpenBSD)
2012 Linux)
2013     case $CPU_ARCH in
2014         x86_64|x86)
2015         ;;
2016         # Linux sandbox is only available on x86 and x86_64.
2017         *)
2018             MOZ_SANDBOX=
2019         ;;
2020     esac
2021     ;;
2023     # Only enable the sandbox by default on Linux, OpenBSD, macOS, and Windows
2024     MOZ_SANDBOX=
2026 esac
2028 if test -n "$MOZ_SANDBOX"; then
2029     AC_DEFINE(MOZ_SANDBOX)
2032 AC_SUBST(MOZ_SANDBOX)
2035 dnl ========================================================
2036 dnl =
2037 dnl = Module specific options
2038 dnl =
2039 dnl ========================================================
2040 MOZ_ARG_HEADER(Individual module options)
2042 dnl ==============================
2043 dnl === SQLite fdatasync check ===
2044 dnl ==============================
2045 dnl Check to see if fdatasync is available and make use of it
2046 AC_CHECK_FUNC(fdatasync)
2048 dnl ========================================================
2049 dnl = Disable zipwriter
2050 dnl ========================================================
2051 MOZ_ARG_DISABLE_BOOL(zipwriter,
2052 [  --disable-zipwriter     Disable zipwriter component],
2053     MOZ_ZIPWRITER=,
2054     MOZ_ZIPWRITER=1 )
2055 AC_SUBST(MOZ_ZIPWRITER)
2057 dnl ========================================================
2058 dnl =
2059 dnl = Feature options that require extra sources to be pulled
2060 dnl =
2061 dnl ========================================================
2062 dnl MOZ_ARG_HEADER(Features that require extra sources)
2064 dnl ========================================================
2065 dnl =
2066 dnl = Runtime debugging and Optimization Options
2067 dnl =
2068 dnl ========================================================
2069 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
2071 dnl ========================================================
2072 dnl enable mobile optimizations
2073 dnl ========================================================
2074 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
2075 [  --enable-mobile-optimize
2076                           Enable mobile optimizations],
2077     MOZ_GFX_OPTIMIZE_MOBILE=1)
2079 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
2081 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
2082     # We ignore paint will resample on mobile for performance.
2083     # We may want to revisit this later.
2084     MOZ_IGNORE_PAINT_WILL_RESAMPLE=1
2086     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
2087     AC_DEFINE(MOZ_IGNORE_PAINT_WILL_RESAMPLE)
2090 dnl ========================================================
2091 dnl = Enable code optimization. ON by default.
2092 dnl ========================================================
2094 # Use value from moz.configure if one is defined. Else use our computed
2095 # value.
2096 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
2097     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
2100 if test "$COMPILE_ENVIRONMENT"; then
2101 if test -n "$MOZ_OPTIMIZE"; then
2102     AC_MSG_CHECKING([for valid C compiler optimization flags])
2103     _SAVE_CFLAGS=$CFLAGS
2104     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
2105     AC_TRY_COMPILE([#include <stdio.h>],
2106         [printf("Hello World\n");],
2107         _results=yes,
2108         _results=no)
2109     AC_MSG_RESULT([$_results])
2110     if test "$_results" = "no"; then
2111         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
2112     fi
2113     CFLAGS=$_SAVE_CFLAGS
2114     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
2115         # When using llvm-based LTO, non numeric optimization levels are
2116         # not supported by the linker, so force the linker to use -O2 (
2117         # which doesn't influence the level compilation units are actually
2118         # compiled at).
2119         case " $MOZ_OPTIMIZE_FLAGS " in
2120         *\ -Os\ *|*\ -Oz\ *)
2121             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
2122             ;;
2123         esac
2124     fi
2126 fi # COMPILE_ENVIRONMENT
2128 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
2129 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
2130 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
2132 dnl ========================================================
2133 dnl = Enable runtime logging
2134 dnl ========================================================
2135 AC_DEFINE(MOZ_LOGGING)
2136 AC_DEFINE(FORCE_PR_LOG)
2138 dnl ========================================================
2139 dnl = This will enable logging of addref, release, ctor, dtor.
2140 dnl ========================================================
2141 _ENABLE_LOGREFCNT=42
2142 MOZ_ARG_ENABLE_BOOL(logrefcnt,
2143 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
2144     _ENABLE_LOGREFCNT=1,
2145     _ENABLE_LOGREFCNT= )
2146 if test "$_ENABLE_LOGREFCNT" = "1"; then
2147     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
2148 elif test -z "$_ENABLE_LOGREFCNT"; then
2149     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
2152 dnl ========================================================
2153 dnl moz_dump_painting
2154 dnl ========================================================
2155 MOZ_ARG_ENABLE_BOOL(dump-painting,
2156 [  --enable-dump-painting          Enable paint debugging.],
2157     MOZ_DUMP_PAINTING=1,
2158     MOZ_DUMP_PAINTING= )
2159 if test -n "$MOZ_DUMP_PAINTING"; then
2160     AC_DEFINE(MOZ_DUMP_PAINTING)
2161     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
2163 if test -n "$MOZ_DEBUG"; then
2164     AC_DEFINE(MOZ_DUMP_PAINTING)
2167 case "${OS_TARGET}" in
2168 Android|WINNT|Darwin)
2169   MOZ_GLUE_IN_PROGRAM=
2170   ;;
2172   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
2173   MOZ_GLUE_IN_PROGRAM=1
2174   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
2175   ;;
2176 esac
2178 dnl ========================================================
2179 dnl = Jemalloc build setup
2180 dnl ========================================================
2181 if test -z "$MOZ_MEMORY"; then
2182   case "${target}" in
2183     *-mingw*)
2184       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
2185         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.])
2186       fi
2187       ;;
2188   esac
2189 else
2190   dnl The generic feature tests that determine how to compute ncpus are long and
2191   dnl complicated.  Therefore, simply define special cpp variables for the
2192   dnl platforms we have special knowledge of.
2193   case "${target}" in
2194   *-mingw*)
2195     export MOZ_NO_DEBUG_RTL=1
2196     ;;
2197   esac
2198 fi # MOZ_MEMORY
2199 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
2201 dnl ========================================================
2202 dnl = Enable using the clang plugin to build
2203 dnl ========================================================
2205 if test -n "$COMPILE_ENVIRONMENT"; then
2206 MOZ_CONFIG_CLANG_PLUGIN
2207 fi # COMPILE_ENVIRONMENT
2209 dnl ========================================================
2210 dnl = frontend JS debug mode
2211 dnl ========================================================
2213 MOZ_ARG_ENABLE_BOOL(debug-js-modules,
2214 [  --enable-debug-js-modules  Enable debug mode for frontend JS libraries],
2215    DEBUG_JS_MODULES=1,
2216    DEBUG_JS_MODULES=)
2218 AC_SUBST(DEBUG_JS_MODULES)
2220 dnl ========================================================
2221 dnl =
2222 dnl = Profiling and Instrumenting
2223 dnl =
2224 dnl ========================================================
2225 MOZ_ARG_HEADER(Profiling and Instrumenting)
2227 dnl ========================================================
2228 dnl = Offer a way to disable the startup cache
2229 dnl ========================================================
2231 MOZ_ARG_DISABLE_BOOL(startupcache,
2232 [  --disable-startupcache          Disable startup cache ],
2233     MOZ_DISABLE_STARTUPCACHE=1,
2234     MOZ_DISABLE_STARTUPCACHE=)
2236 if test -n "$MOZ_DISABLE_STARTUPCACHE"; then
2237   AC_DEFINE(MOZ_DISABLE_STARTUPCACHE)
2239 AC_SUBST(MOZ_DISABLE_STARTUPCACHE)
2241 dnl ========================================================
2242 dnl = Support for demangling undefined symbols
2243 dnl ========================================================
2244 if test -z "$SKIP_LIBRARY_CHECKS"; then
2245     AC_LANG_SAVE
2246     AC_LANG_CPLUSPLUS
2247     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
2248     AC_LANG_RESTORE
2251 # Demangle only for debug or DMD builds
2252 MOZ_DEMANGLE_SYMBOLS=
2253 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
2254     MOZ_DEMANGLE_SYMBOLS=1
2255     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
2257 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
2259 dnl ========================================================
2260 dnl = Support for gcc stack unwinding (from gcc 3.3)
2261 dnl ========================================================
2262 if test -z "$SKIP_LIBRARY_CHECKS"; then
2263     AC_LANG_SAVE
2264     AC_LANG_CPLUSPLUS
2265     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
2266     AC_LANG_RESTORE
2269 dnl ========================================================
2270 dnl =
2271 dnl = Misc. Options
2272 dnl =
2273 dnl ========================================================
2274 MOZ_ARG_HEADER(Misc. Options)
2276 dnl ========================================================
2277 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
2278 dnl ========================================================
2279 MOZ_ARG_WITH_STRING(user-appdir,
2280 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
2281 [ val=`echo $withval`
2282 if echo "$val" | grep "\/" >/dev/null; then
2283     AC_MSG_ERROR("Homedir must be single relative path.")
2284 else
2285     MOZ_USER_DIR="$val"
2286 fi])
2288 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
2290 if test -z "$SKIP_COMPILER_CHECKS"; then
2291 dnl ========================================================
2292 dnl =
2293 dnl = Compiler Options
2294 dnl =
2295 dnl ========================================================
2296 MOZ_ARG_HEADER(Compiler Options)
2298 dnl ========================================================
2299 dnl Check for gcc -pipe support
2300 dnl ========================================================
2301 AC_MSG_CHECKING([for -pipe support])
2302 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
2303     dnl Any gcc that supports firefox supports -pipe.
2304     CFLAGS="$CFLAGS -pipe"
2305     CXXFLAGS="$CXXFLAGS -pipe"
2306     AC_MSG_RESULT([yes])
2307 else
2308     AC_MSG_RESULT([no])
2311 fi # ! SKIP_COMPILER_CHECKS
2313 AC_LANG_C
2315 if test "$COMPILE_ENVIRONMENT"; then
2316 MOZ_EXPAND_LIBS
2317 fi # COMPILE_ENVIRONMENT
2319 dnl ========================================================
2320 dnl =
2321 dnl = Static Build Options
2322 dnl =
2323 dnl ========================================================
2324 MOZ_ARG_HEADER(Static build options)
2326 if test -z "$MOZ_SYSTEM_ZLIB"; then
2327 if test -n "$JS_SHARED_LIBRARY" -o -n "$MOZ_LINKER" -o "$MOZ_WIDGET_TOOLKIT" = android; then
2328   ZLIB_IN_MOZGLUE=1
2329   AC_DEFINE(ZLIB_IN_MOZGLUE)
2333 AC_SUBST(ZLIB_IN_MOZGLUE)
2335 dnl ========================================================
2336 dnl =
2337 dnl = Standalone module options
2338 dnl =
2339 dnl ========================================================
2340 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
2342 dnl Check for GLib.
2343 dnl ========================================================
2345 if test -z "$SKIP_PATH_CHECKS"; then
2346 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
2347     if test "$MOZ_ENABLE_GTK" ; then
2348         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
2349     fi
2353 if test -z "${GLIB_GMODULE_LIBS}" \
2354    -a -n "${GLIB_CONFIG}"\
2355     -a "${GLIB_CONFIG}" != no\
2356 ; then
2357     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
2360 AC_SUBST_LIST(GLIB_GMODULE_LIBS)
2362 if test "$USE_FC_FREETYPE"; then
2363     if test "$COMPILE_ENVIRONMENT"; then
2364         dnl ========================================================
2365         dnl = Check for freetype2 functionality
2366         dnl ========================================================
2367         if test "$_HAVE_FREETYPE2" -a -z "$MOZ_TREE_FREETYPE"; then
2368             _SAVE_LIBS="$LIBS"
2369             _SAVE_CFLAGS="$CFLAGS"
2370             LIBS="$LIBS $FT2_LIBS"
2371             CFLAGS="$CFLAGS $FT2_CFLAGS"
2373             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
2374                 ac_cv_member_FT_Bitmap_Size_y_ppem,
2375                 [AC_TRY_COMPILE([#include <ft2build.h>
2376                                  #include FT_FREETYPE_H],
2377                                 [FT_Bitmap_Size s;
2378                                  if (sizeof s.y_ppem) return 0;
2379                                  return 1],
2380                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
2381                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
2382             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
2383                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
2384             else
2385                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
2386             fi
2387             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
2388                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
2389                                [FT_Bitmap_Size structure includes y_ppem field])
2391             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table)
2393             LIBS="$_SAVE_LIBS"
2394             CFLAGS="$_SAVE_CFLAGS"
2395         fi
2397         _SAVE_CPPFLAGS="$CPPFLAGS"
2398         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
2399         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
2400             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
2401         CPPFLAGS="$_SAVE_CPPFLAGS"
2402     fi
2405 dnl ========================================================
2406 dnl Check if we need the 32-bit Linux SSE2 error dialog
2407 dnl ========================================================
2409 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
2411 dnl ========================================================
2412 dnl Check for pixman and cairo
2413 dnl ========================================================
2415 MOZ_TREE_CAIRO=1
2416 MOZ_ARG_ENABLE_BOOL(system-cairo,
2417 [ --enable-system-cairo  Obsolete: do not use this option],
2418 AC_MSG_ERROR(--enable-system-cairo is not supported),
2419 MOZ_TREE_CAIRO=1 )
2421 MOZ_TREE_PIXMAN=1
2422 MOZ_ARG_ENABLE_BOOL(system-pixman,
2423 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
2424 MOZ_TREE_PIXMAN=,
2425 MOZ_TREE_PIXMAN=force,
2426 MOZ_TREE_PIXMAN=1 )
2428 if test "$MOZ_TREE_PIXMAN"; then
2429     AC_DEFINE(MOZ_TREE_PIXMAN)
2430 else
2431     PKG_CHECK_MODULES(MOZ_PIXMAN, pixman-1 >= 0.19.2)
2434 MOZ_CAIRO_CFLAGS="-I${DIST}/include/cairo"
2435 AC_DEFINE(MOZ_TREE_CAIRO)
2437 if test "$OS_ARCH" = "WINNT"; then
2438     # For now we assume that we will have a uint64_t available through
2439     # one of the above headers or mozstdint.h.
2440     AC_DEFINE(HAVE_UINT64_T)
2443 # Define macros for cairo-features.h
2444 TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
2445 if test "$MOZ_X11"; then
2446     XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
2447     XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
2448     PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
2450 if test "$_HAVE_FREETYPE2"; then
2451     FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
2452     MOZ_ENABLE_CAIRO_FT=1
2453     CAIRO_FT_CFLAGS="$FT2_CFLAGS"
2456 case "$MOZ_WIDGET_TOOLKIT" in
2457   cocoa | uikit)
2458     QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
2459     QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
2460     QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
2461     ;;
2462   windows)
2463     WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
2464     WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
2465     WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
2467     if test "$COMPILE_ENVIRONMENT"; then
2468       MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
2469     fi
2470     ;;
2471 esac
2472 if test "$USE_FC_FREETYPE"; then
2473     FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
2475 AC_SUBST(MOZ_ENABLE_CAIRO_FT)
2476 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
2478 AC_SUBST(PS_SURFACE_FEATURE)
2479 AC_SUBST(SVG_SURFACE_FEATURE)
2480 AC_SUBST(XLIB_SURFACE_FEATURE)
2481 AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
2482 AC_SUBST(QUARTZ_SURFACE_FEATURE)
2483 AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
2484 AC_SUBST(WIN32_SURFACE_FEATURE)
2485 AC_SUBST(OS2_SURFACE_FEATURE)
2486 AC_SUBST(DIRECTFB_SURFACE_FEATURE)
2487 AC_SUBST(FT_FONT_FEATURE)
2488 AC_SUBST(FC_FONT_FEATURE)
2489 AC_SUBST(WIN32_FONT_FEATURE)
2490 AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
2491 AC_SUBST(QUARTZ_FONT_FEATURE)
2492 AC_SUBST(PNG_FUNCTIONS_FEATURE)
2493 AC_SUBST(QT_SURFACE_FEATURE)
2494 AC_SUBST(TEE_SURFACE_FEATURE)
2496 if test "$MOZ_X11"; then
2497     MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
2500 CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
2502 case "$MOZ_WIDGET_TOOLKIT" in
2503 android)
2504     TK_CFLAGS="$MOZ_CAIRO_CFLAGS $MOZ_PIXMAN_CFLAGS"
2505     TK_LIBS="$MOZ_CAIRO_LIBS $MOZ_PIXMAN_LIBS"
2506     ;;
2507 esac
2509 AC_SUBST(MOZ_TREE_CAIRO)
2510 AC_SUBST_LIST(MOZ_CAIRO_CFLAGS)
2511 AC_SUBST_LIST(MOZ_CAIRO_LIBS)
2512 AC_SUBST_LIST(MOZ_CAIRO_OSLIBS)
2513 AC_SUBST(MOZ_TREE_PIXMAN)
2515 BINDGEN_SYSTEM_FLAGS="$_BINDGEN_CFLAGS $NSPR_CFLAGS $NSS_CFLAGS $MOZ_PIXMAN_CFLAGS $MOZ_CAIRO_CFLAGS"
2516 AC_SUBST(BINDGEN_SYSTEM_FLAGS)
2517 BINDGEN_SYSTEM_TOML_FLAGS="$BINDGEN_SYSTEM_FLAGS"
2518 AC_SUBST_TOML_LIST(BINDGEN_SYSTEM_TOML_FLAGS)
2520 dnl ========================================================
2521 dnl disable xul
2522 dnl ========================================================
2523 MOZ_ARG_DISABLE_BOOL(xul,
2524 [  --disable-xul           Disable XUL],
2525     MOZ_XUL= )
2526 if test "$MOZ_XUL"; then
2527   AC_DEFINE(MOZ_XUL)
2528 else
2529   dnl remove extensions that require XUL
2530   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/irc//' -e 's/tasks//'`
2533 AC_SUBST(MOZ_XUL)
2535 dnl ========================================================
2536 dnl necko configuration options
2537 dnl ========================================================
2540 dnl option to disable necko's wifi scanner
2543 if test "$MOZ_WIDGET_TOOLKIT"; then
2545   case "$OS_TARGET" in
2546     Darwin)
2547       NECKO_WIFI=1
2548       ;;
2549     DragonFly|FreeBSD|WINNT)
2550       NECKO_WIFI=1
2551       ;;
2552     Linux)
2553       NECKO_WIFI=1
2554       NECKO_WIFI_DBUS=1
2555       ;;
2556   esac
2560 MOZ_ARG_DISABLE_BOOL(necko-wifi,
2561 [  --disable-necko-wifi    Disable necko wifi scanner],
2562     NECKO_WIFI=,
2563     NECKO_WIFI=1)
2565 if test "$NECKO_WIFI"; then
2566   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
2567     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
2568   fi
2569   AC_DEFINE(NECKO_WIFI)
2570   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
2572 AC_SUBST(NECKO_WIFI)
2573 AC_SUBST(NECKO_WIFI_DBUS)
2575 dnl ========================================================
2576 dnl =
2577 dnl = Maintainer debug option (no --enable equivalent)
2578 dnl =
2579 dnl ========================================================
2581 AC_SUBST(NM)
2582 AC_SUBST_LIST(ASFLAGS)
2583 AC_SUBST(RCFLAGS)
2584 AC_SUBST(IMPLIB)
2585 AC_SUBST(FILTER)
2586 AC_SUBST(MOZ_AUTH_EXTENSION)
2587 AC_SUBST(MOZ_PREF_EXTENSIONS)
2588 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
2589 AC_SUBST_LIST(WARNINGS_CFLAGS)
2590 AC_SUBST_SET(MOZ_EXTENSIONS)
2592 AC_SUBST(MOZ_UNIVERSALCHARDET)
2593 AC_SUBST(MOZ_SPELLCHECK)
2594 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
2595 AC_SUBST(MOZ_CRASHREPORTER)
2596 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
2597 AC_SUBST(MOZ_STUB_INSTALLER)
2598 AC_SUBST(MOZ_UPDATER)
2600 AC_SUBST(MOZ_ANDROID_APPLICATION_CLASS)
2601 AC_SUBST(MOZ_ANDROID_BROWSER_INTENT_CLASS)
2602 AC_SUBST(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
2603 AC_SUBST(INCREMENTAL_LINKER)
2605 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
2607 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
2608 AC_SUBST(MOZ_LINKER_EXTRACT)
2610 if test -n "$MOZ_BINARY_EXTENSIONS"; then
2611   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
2614 AC_SUBST(MOZ_REQUIRE_SIGNING)
2615 if test "$MOZ_REQUIRE_SIGNING" = 1; then
2616   AC_DEFINE(MOZ_REQUIRE_SIGNING)
2619 dnl ========================================================
2620 dnl = Mac bundle name prefix
2621 dnl ========================================================
2622 MOZ_ARG_WITH_STRING(macbundlename-prefix,
2623 [  --with-macbundlename-prefix=prefix
2624                           Prefix for MOZ_MACBUNDLE_NAME],
2625 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
2627 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
2628 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
2629   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
2632 if test "$MOZ_DEBUG"; then
2633   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
2634 else
2635   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
2637 AC_SUBST(MOZ_MACBUNDLE_NAME)
2639 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
2640 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
2641 # Otherwise, use MOZ_APP_DISPLAYNAME
2642 if test -z "$MOZ_MACBUNDLE_ID"; then
2643    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
2645 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
2646 if test "$MOZ_DEBUG"; then
2647   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
2650 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
2651 AC_SUBST(MOZ_MACBUNDLE_ID)
2653 dnl ========================================================
2654 dnl = Child Process Name for IPC
2655 dnl ========================================================
2656 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
2657   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
2658 else
2659   # We want to let Android unpack the file at install time, but it only does
2660   # so if the file is named libsomething.so. The lib/ path is also required
2661   # because the unpacked file will be under the lib/ subdirectory and will
2662   # need to be executed from that path.
2663   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
2665 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
2666 MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
2668 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
2669 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
2670 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
2672 # The following variables are available to branding and application
2673 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
2674 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
2675 # impacts profile location and user-visible fields.
2676 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
2677 # versions of a given application (e.g. Aurora and Firefox both use
2678 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
2679 # for application.ini's "Name" field, which controls profile location in
2680 # the absence of a "Profile" field (see below), and various system
2681 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
2682 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
2683 # Mac Bundle name, Updater, Installer), it is typically used for nightly
2684 # builds (e.g. Aurora for Firefox).
2685 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
2686 # defaults to a lowercase form of MOZ_APP_BASENAME.
2687 # - MOZ_APP_REMOTINGNAME: Used for the internal program name, which affects
2688 # profile name and remoting. If not set, defaults to MOZ_APP_NAME.
2689 # - MOZ_APP_PROFILE: When set, used for application.ini's
2690 # "Profile" field, which controls profile location.
2691 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
2692 # crash reporter server url.
2693 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
2695 # The following environment variables used to have an effect, but don't anymore:
2696 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
2697 # the contents from the version.txt file in the application directory, or
2698 # browser/config/version.txt if there isn't one.
2699 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
2700 # in the "About" window. This was replaced with the contents from the
2701 # version_display.txt or version.txt in the application directory, or
2702 # browser/config/version_display.txt.
2704 if test -z "$MOZ_APP_NAME"; then
2705    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
2708 if test -z "$MOZ_APP_REMOTINGNAME"; then
2709    MOZ_APP_REMOTINGNAME=$MOZ_APP_NAME
2712 if test -z "$ANDROID_PACKAGE_NAME" ; then
2713    # When we got rid of the Aurora channel we decided to replace the old
2714    # Nightly ANDROID_PACKAGE_NAME with Aurora. To make sure this is inherited
2715    # by all mozilla-central based branches we make this the new "default"
2716    # for Fennec. Non mozilla-central based branches set ANDROID_PACKAGE_NAME
2717    # in their mozconfig, so they will never get this. If there are ever
2718    # non-Fennec builds for Android, they will fall into the else block
2719    # and use their own default name.
2720    # https://bugzilla.mozilla.org/show_bug.cgi?id=1357808 has additional
2721    # background on this.
2722    if test "$MOZ_APP_NAME" = "fennec"; then
2723       ANDROID_PACKAGE_NAME="org.mozilla.fennec_aurora"
2724    else
2725       ANDROID_PACKAGE_NAME="org.mozilla.$MOZ_APP_NAME"
2726    fi
2729 # For extensions and langpacks, we require a max version that is compatible
2730 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
2731 # 24.0a1 and 24.0a2 aren't affected
2732 # 24.0 becomes 24.*
2733 # 24.1.1 becomes 24.*
2734 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
2735 if test -z "$IS_ALPHA"; then
2736   changequote(,)
2737   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
2738     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
2739   else
2740     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
2741   fi
2742   changequote([,])
2743 else
2744   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
2747 AC_SUBST(MOZ_APP_NAME)
2748 AC_SUBST(MOZ_APP_REMOTINGNAME)
2749 AC_SUBST(MOZ_APP_DISPLAYNAME)
2750 AC_SUBST(MOZ_APP_BASENAME)
2751 AC_SUBST(MOZ_APP_VENDOR)
2752 AC_SUBST(MOZ_APP_PROFILE)
2753 AC_SUBST(MOZ_APP_ID)
2754 AC_SUBST(MAR_CHANNEL_ID)
2755 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
2756 AC_SUBST(MOZ_PROFILE_MIGRATOR)
2757 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
2758 AC_SUBST(MOZ_APP_UA_NAME)
2759 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
2760 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
2761 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
2763 AC_SUBST(MOZ_APP_MAXVERSION)
2764 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
2765 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
2766   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
2769 AC_SUBST(MOZ_PKG_SPECIAL)
2770 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
2772 if test "$MOZILLA_OFFICIAL"; then
2773     # Build revisions should always be present in official builds
2774     MOZ_INCLUDE_SOURCE_INFO=1
2777 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
2778 # explicitly set the repository and changeset information in.
2779 AC_SUBST(MOZ_SOURCE_REPO)
2780 AC_SUBST(MOZ_SOURCE_CHANGESET)
2781 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
2783 dnl If we have any service that uploads data (and requires data submission
2784 dnl policy alert), set MOZ_DATA_REPORTING.
2785 dnl We need SUBST for build system and DEFINE for xul preprocessor.
2786 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"  || test -n "$MOZ_NORMANDY"; then
2787   MOZ_DATA_REPORTING=1
2788   AC_DEFINE(MOZ_DATA_REPORTING)
2789   AC_SUBST(MOZ_DATA_REPORTING)
2792 dnl win32 options
2793 AC_SUBST(WIN32_REDIST_DIR)
2794 AC_SUBST(WIN_UCRT_REDIST_DIR)
2796 dnl Echo the CFLAGS to remove extra whitespace.
2797 CFLAGS=`echo \
2798     $_COMPILATION_CFLAGS \
2799     $CFLAGS`
2801 CXXFLAGS=`echo \
2802     $_WARNINGS_CXXFLAGS \
2803     $_COMPILATION_CXXFLAGS \
2804     $CXXFLAGS`
2806 COMPILE_CFLAGS=`echo \
2807     $_DEFINES_CFLAGS \
2808     $COMPILE_CFLAGS`
2810 COMPILE_CXXFLAGS=`echo \
2811     $_DEFINES_CXXFLAGS \
2812     $COMPILE_CXXFLAGS`
2814 HOST_CFLAGS=`echo \
2815     $_WARNINGS_HOST_CFLAGS \
2816     $_COMPILATION_HOST_CFLAGS \
2817     $HOST_CFLAGS`
2819 HOST_CXXFLAGS=`echo \
2820     $_WARNINGS_HOST_CXXFLAGS \
2821     $_COMPILATION_HOST_CXXFLAGS \
2822     $HOST_CXXFLAGS`
2824 AC_SUBST(MOZ_SYSTEM_PNG)
2826 AC_SUBST_LIST(MOZ_PNG_CFLAGS)
2827 AC_SUBST_LIST(MOZ_PNG_LIBS)
2829 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
2830 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
2831 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
2832 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
2833 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
2834   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
2835   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
2837 AC_SUBST(HOST_CMFLAGS)
2838 AC_SUBST(HOST_CMMFLAGS)
2839 AC_SUBST(OS_COMPILE_CMFLAGS)
2840 AC_SUBST(OS_COMPILE_CMMFLAGS)
2842 OS_CFLAGS="$CFLAGS"
2843 OS_CXXFLAGS="$CXXFLAGS"
2844 OS_CPPFLAGS="$CPPFLAGS"
2845 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
2846 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
2847 OS_LDFLAGS="$LDFLAGS"
2848 OS_LIBS="$LIBS"
2849 AC_SUBST_LIST(OS_CFLAGS)
2850 AC_SUBST_LIST(OS_CXXFLAGS)
2851 AC_SUBST_LIST(OS_CPPFLAGS)
2852 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
2853 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
2854 AC_SUBST_LIST(OS_LDFLAGS)
2855 AC_SUBST(OS_LIBS)
2857 AC_SUBST(HOST_CC)
2858 AC_SUBST(HOST_CXX)
2859 AC_SUBST_LIST(HOST_CFLAGS)
2860 AC_SUBST_LIST(HOST_CPPFLAGS)
2861 AC_SUBST_LIST(HOST_CXXFLAGS)
2862 AC_SUBST(HOST_LDFLAGS)
2863 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
2864 AC_SUBST(HOST_BIN_SUFFIX)
2866 AC_SUBST(TARGET_XPCOM_ABI)
2867 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
2868 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
2869 AC_SUBST(HAVE_X86_AVX2)
2870 AC_SUBST(HAVE_ALTIVEC)
2872 AC_SUBST_LIST(DSO_CFLAGS)
2873 AC_SUBST_LIST(DSO_PIC_CFLAGS)
2874 AC_SUBST(DSO_LDOPTS)
2875 AC_SUBST(BIN_SUFFIX)
2876 AC_SUBST(USE_N32)
2877 AC_SUBST(NS_ENABLE_TSF)
2878 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
2879 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
2881 AC_SUBST(MOZ_DEVTOOLS)
2883 AC_SUBST(MOZ_PACKAGE_JSSHELL)
2885 AC_SUBST(DMG_TOOL)
2887 dnl Host JavaScript runtime, if any, to use during cross compiles.
2888 AC_SUBST(JS_BINARY)
2890 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
2892 if test -n "$COMPILE_ENVIRONMENT"; then
2893 AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
2895 dnl Check for missing components
2896 if test "$MOZ_X11"; then
2897     dnl ====================================================
2898     dnl = Check if X headers exist
2899     dnl ====================================================
2900     _SAVE_CFLAGS=$CFLAGS
2901     CFLAGS="$CFLAGS $XCFLAGS"
2902     AC_TRY_COMPILE([
2903         #include <stdio.h>
2904         #include <stdlib.h>
2905         #include <X11/Xlib.h>
2906         #include <X11/Intrinsic.h>
2907         #include <X11/extensions/XShm.h>
2908     ],
2909     [
2910         Display *dpy = 0;
2911         if ((dpy = XOpenDisplay(NULL)) == NULL) {
2912             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
2913             exit(1);
2914         }
2915     ], [],
2916     [ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
2917     CFLAGS="$_SAVE_CFLAGS"
2919     if test -n "$MISSING_X"; then
2920         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
2921     fi
2923 fi # MOZ_X11
2925 fi # COMPILE_ENVIRONMENT
2927 dnl Set various defines and substitutions
2928 dnl ========================================================
2930 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
2931     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
2932     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
2933     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
2934     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
2935     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
2936     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
2937     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
2938     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
2941 AC_SUBST(MOZ_DEV_EDITION)
2942 if test -n "$MOZ_DEV_EDITION"; then
2943     AC_DEFINE(MOZ_DEV_EDITION)
2946 if test "$MOZ_DEBUG" -o "$DEVELOPER_OPTIONS"; then
2947     A11Y_LOG=1
2949 AC_SUBST(A11Y_LOG)
2950 if test -n "$A11Y_LOG"; then
2951     AC_DEFINE(A11Y_LOG)
2954 dnl Spit out some output
2955 dnl ========================================================
2957 dnl The following defines are used by xpcom
2958 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
2959 HAVE_GETPAGESIZE
2960 HAVE_STATVFS64
2961 HAVE_STATVFS
2962 HAVE_STATFS64
2963 HAVE_STATFS
2964 HAVE_SYS_STATVFS_H
2965 HAVE_SYS_STATFS_H
2966 HAVE_SYS_VFS_H
2967 HAVE_SYS_MOUNT_H
2970 # Avoid using obsolete NSPR features
2971 AC_DEFINE(NO_NSPR_10_SUPPORT)
2973 MOZ_CREATE_CONFIG_STATUS()
2975 rm -fr confdefs* $ac_clean_files