Bug 1637473 [wpt PR 23557] - De-flaky pointerevents/pointerevent_capture_mouse.html...
[gecko.git] / old-configure.in
blob5b3cd2dbab2a8a41c272cf6609c47109cea697f8
1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2 dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4:
3 dnl This Source Code Form is subject to the terms of the Mozilla Public
4 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
5 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 dnl Process this file with autoconf to produce a configure script.
8 dnl ========================================================
9 AC_PREREQ(2.13)
10 AC_INIT(config/config.mk)
11 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
12 AC_CANONICAL_SYSTEM
14 dnl ========================================================
15 dnl =
16 dnl = Don't change the following lines. Doing so breaks:
17 dnl =
18 dnl = CFLAGS="-foo" ./configure
19 dnl =
20 dnl ========================================================
21 CFLAGS="${CFLAGS=}"
22 CPPFLAGS="${CPPFLAGS=}"
23 CXXFLAGS="${CXXFLAGS=}"
24 LDFLAGS="${LDFLAGS=}"
25 HOST_CFLAGS="${HOST_CFLAGS=}"
26 HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
27 HOST_LDFLAGS="${HOST_LDFLAGS=}"
29 dnl ========================================================
30 dnl = Preserve certain environment flags passed to configure
31 dnl = We want sub projects to receive the same flags
32 dnl = untainted by this configure script
33 dnl ========================================================
34 _SUBDIR_CC="$CC"
35 _SUBDIR_CXX="$CXX"
36 _SUBDIR_CFLAGS="$CFLAGS"
37 _SUBDIR_CPPFLAGS="$CPPFLAGS"
38 _SUBDIR_CXXFLAGS="$CXXFLAGS"
39 _SUBDIR_LDFLAGS="$LDFLAGS"
40 _SUBDIR_HOST_CC="$HOST_CC"
41 _SUBDIR_HOST_CFLAGS="$HOST_CFLAGS"
42 _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
43 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
44 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
46 dnl Set the version number of the libs included with mozilla
47 dnl ========================================================
48 MOZPNG=10635
49 NSPR_VERSION=4
50 NSPR_MINVER=4.25
51 NSS_VERSION=3
53 dnl Set the minimum version of toolkit libs used by mozilla
54 dnl ========================================================
55 GLIB_VERSION=2.22
56 # 2_26 is the earliest version we can set GLIB_VERSION_MIN_REQUIRED.
57 # The macro won't be used when compiling with earlier versions anyway.
58 GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26
59 CAIRO_VERSION=1.10
60 GTK2_VERSION=2.18.0
61 GTK3_VERSION=3.4.0
62 GDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4
63 W32API_VERSION=3.14
64 DBUS_VERSION=0.60
66 dnl Set various checks
67 dnl ========================================================
68 MISSING_X=
70 dnl Initialize the Pthread test variables early so they can be
71 dnl  overridden by each platform.
72 dnl ========================================================
73 MOZ_USE_PTHREADS=
74 _PTHREAD_LDFLAGS=""
76 LDFLAGS="$LDFLAGS $LINKER_LDFLAGS"
78 if test "$COMPILE_ENVIRONMENT"; then
79     MOZ_ANDROID_NDK
80 fi # COMPILE_ENVIRONMENT
82 case "$target" in
83 *-android*|*-linuxandroid*)
84     ;;
85 *-linux*)
86     AC_PATH_PROG(OBJCOPY,objcopy)
87     ;;
88 esac
90 AC_SUBST(ANDROID_PACKAGE_NAME)
91 AC_SUBST(OBJCOPY)
93 dnl ========================================================
94 dnl Checks for compilers.
95 dnl ========================================================
97 if test "$COMPILE_ENVIRONMENT"; then
99 if test "$target" != "$host"; then
100     MOZ_CROSS_COMPILER
101 else
102     AC_PROG_CC
103     case "$target" in
104     *-mingw*)
105       # Work around the conftest.exe access problem on Windows
106       sleep 2
107     esac
108     AC_PROG_CXX
109     AC_PROG_RANLIB
110     MOZ_PATH_PROGS(AS, $AS as, $CC)
111     AC_CHECK_PROGS(STRIP, strip, :)
112     AC_CHECK_PROGS(OTOOL, otool, :)
115 if test -n "$MOZ_WINCONSOLE"; then
116     AC_DEFINE(MOZ_WINCONSOLE)
119 MOZ_TOOL_VARIABLES
121 dnl ========================================================
122 dnl Special win32 checks
123 dnl ========================================================
125 WINVER=601
127 case "$target" in
128 *-mingw*)
129     if test "$GCC" != "yes"; then
130         # Check to see if we are really running in a msvc environemnt
131         _WIN32_MSVC=1
133         # Make sure compilers are valid
134         CXXFLAGS="$CXXFLAGS -TP"
135         AC_LANG_SAVE
136         AC_LANG_C
137         AC_TRY_COMPILE([#include <stdio.h>],
138             [ printf("Hello World\n"); ],,
139             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
141         AC_LANG_CPLUSPLUS
142         AC_TRY_COMPILE([#include <new.h>],
143             [ unsigned *test = new unsigned(42); ],,
144             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
145         AC_LANG_RESTORE
147         changequote(,)
148         _MSVC_VER_FILTER='s|.*[^!-~]([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p'
149         changequote([,])
151         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
152         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
153         AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
155         _CC_SUITE=14
156         MSVC_C_RUNTIME_DLL=vcruntime140.dll
157         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
159         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
160         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
162         if test -n "$WIN_UCRT_REDIST_DIR"; then
163           if test ! -d "$WIN_UCRT_REDIST_DIR"; then
164             AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
165           fi
166           WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
167         fi
169         AC_SUBST(MSVC_C_RUNTIME_DLL)
170         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
172         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
174         if test -n "$WIN32_REDIST_DIR"; then
175           if test ! -d "$WIN32_REDIST_DIR"; then
176             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
177           fi
178           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
179         fi
181         # Check linker version, except in lld builds
182         case "$LINKER" in
183         *lld*)
184             ;;
185         *)
186             _LD_FULL_VERSION=`"${LINKER}" -v 2>&1 | sed -nre "$_MSVC_VER_FILTER"`
187             _LD_MAJOR_VERSION=`echo ${_LD_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
188             if test "$_LD_MAJOR_VERSION" != "$_CC_SUITE"; then
189                 AC_MSG_ERROR([The linker major version, $_LD_FULL_VERSION,  does not match the compiler suite version, $_CC_SUITE.])
190             fi
191             ;;
192         esac
194         INCREMENTAL_LINKER=1
196         unset _MSVC_VER_FILTER
198         WRAP_STL_INCLUDES=1
199         STL_FLAGS="-I${DIST}/stl_wrappers"
200     else
201         # Check w32api version
202         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
203         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
204         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
205         AC_TRY_COMPILE([#include <w32api.h>],
206             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
207                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
208                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
209                 #error "test failed."
210             #endif
211             , [ res=yes ], [ res=no ])
212         AC_MSG_RESULT([$res])
213         if test "$res" != "yes"; then
214             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
215         fi
216         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
217         # causing problems with local implementations with the same name.
218         AC_DEFINE(STRSAFE_NO_DEPRECATE)
219     fi # !GNU_CC
221     CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
222     CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
224     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
225     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
226     # Require OS features provided by IE 8.0 (Win7)
227     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
229     ;;
230 esac
232 if test -n "$_WIN32_MSVC"; then
233     SKIP_PATH_CHECKS=1
234     SKIP_COMPILER_CHECKS=1
235     SKIP_LIBRARY_CHECKS=1
237     # Since we're skipping compiler and library checks, hard-code
238     # some facts here.
239     AC_DEFINE(HAVE_IO_H)
240     AC_DEFINE(HAVE_ISATTY)
243 fi # COMPILE_ENVIRONMENT
245 AC_SUBST(GNU_CC)
246 AC_SUBST(GNU_CXX)
248 AC_SUBST_LIST(STL_FLAGS)
249 AC_SUBST(WRAP_STL_INCLUDES)
251 dnl ========================================================
252 dnl Checks for programs.
253 dnl ========================================================
254 if test "$COMPILE_ENVIRONMENT"; then
256 AC_PATH_XTRA
258 XCFLAGS="$X_CFLAGS"
260 fi # COMPILE_ENVIRONMENT
262 dnl ========================================================
263 dnl set the defaults first
264 dnl ========================================================
265 MOZ_USER_DIR=".mozilla"
267 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
269 MOZ_FS_LAYOUT=unix
271 dnl Configure platform-specific CPU architecture compiler options.
272 dnl ==============================================================
273 if test "$COMPILE_ENVIRONMENT"; then
274     MOZ_ARCH_OPTS
275 fi # COMPILE_ENVIRONMENT
277 dnl ========================================================
278 dnl Android libstdc++
279 dnl ========================================================
281 MOZ_ANDROID_CPU_ARCH
282 if test "$COMPILE_ENVIRONMENT"; then
283     MOZ_ANDROID_STLPORT
284 fi # COMPILE_ENVIRONMENT
286 dnl ========================================================
287 dnl Suppress Clang Argument Warnings
288 dnl ========================================================
289 WARNINGS_CFLAGS="$_WARNINGS_CFLAGS"
290 if test -n "${CLANG_CC}${CLANG_CL}"; then
291     WARNINGS_CFLAGS="-Qunused-arguments $WARNINGS_CFLAGS"
292     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
294 if test -n "${CLANG_CXX}${CLANG_CL}"; then
295     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
298 if test -n "$COMPILE_ENVIRONMENT"; then
299    MOZ_CONFIG_SANITIZE
302 dnl ========================================================
303 dnl GNU specific defaults
304 dnl ========================================================
305 if test "$GNU_CC"; then
306     MMX_FLAGS="-mmmx"
307     SSE_FLAGS="-msse"
308     SSE2_FLAGS="-msse2"
309     SSSE3_FLAGS="-mssse3"
310     CFLAGS="$CFLAGS -fno-strict-aliasing"
311     DSO_CFLAGS=''
313     if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
314         DSO_PIC_CFLAGS='-fPIC'
315         ASFLAGS="$ASFLAGS -fPIC"
316     fi
318     AC_MSG_CHECKING([for --noexecstack option to as])
319     _SAVE_CFLAGS=$CFLAGS
320     CFLAGS="$CFLAGS -Wa,--noexecstack"
321     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
322                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
323                      AC_MSG_RESULT([no]))
324     CFLAGS=$_SAVE_CFLAGS
325     AC_MSG_CHECKING([for -z noexecstack option to ld])
326     _SAVE_LDFLAGS=$LDFLAGS
327     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
328     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
329                   AC_MSG_RESULT([no])
330                   LDFLAGS=$_SAVE_LDFLAGS)
332     AC_MSG_CHECKING([for -z text option to ld])
333     _SAVE_LDFLAGS=$LDFLAGS
334     LDFLAGS="$LDFLAGS -Wl,-z,text"
335     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
336                   AC_MSG_RESULT([no])
337                   LDFLAGS=$_SAVE_LDFLAGS)
339     AC_MSG_CHECKING([for -z relro option to ld])
340     _SAVE_LDFLAGS=$LDFLAGS
341     LDFLAGS="$LDFLAGS -Wl,-z,relro"
342     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
343                   AC_MSG_RESULT([no])
344                   LDFLAGS=$_SAVE_LDFLAGS)
346     AC_MSG_CHECKING([for -z nocopyreloc option to ld])
347     _SAVE_LDFLAGS=$LDFLAGS
348     LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
349     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
350                   AC_MSG_RESULT([no])
351                   LDFLAGS=$_SAVE_LDFLAGS)
353     AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
354     _SAVE_LDFLAGS=$LDFLAGS
355     LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
356     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
357                   AC_MSG_RESULT([no])
358                   LDFLAGS=$_SAVE_LDFLAGS)
360     AC_MSG_CHECKING([for --build-id=sha1 option to ld])
361     _SAVE_LDFLAGS=$LDFLAGS
362     LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
363     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
364                   AC_MSG_RESULT([no])
365                   LDFLAGS=$_SAVE_LDFLAGS)
367     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
368     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
369     _SAVE_LDFLAGS=$LDFLAGS
370     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
371     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
372                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
373                   AC_MSG_RESULT([no]))
374     LDFLAGS=$_SAVE_LDFLAGS
376     # Check for -mssse3 on $CC
377     AC_MSG_CHECKING([if toolchain supports -mssse3 option])
378     HAVE_TOOLCHAIN_SUPPORT_MSSSE3=
379     _SAVE_CFLAGS=$CFLAGS
380     CFLAGS="$CFLAGS -mssse3"
381     AC_TRY_COMPILE([asm ("pmaddubsw %xmm2,%xmm3");],,AC_MSG_RESULT([yes])
382                      [HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1],
383                      AC_MSG_RESULT([no]))
384     CFLAGS=$_SAVE_CFLAGS
386     # Check for -msse4.1 on $CC
387     AC_MSG_CHECKING([if toolchain supports -msse4.1 option])
388     HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=
389     _SAVE_CFLAGS=$CFLAGS
390     CFLAGS="$CFLAGS -msse4.1"
391     AC_TRY_COMPILE([asm ("pmulld %xmm6,%xmm0");],,AC_MSG_RESULT([yes])
392                      [HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1],
393                      AC_MSG_RESULT([no]))
394     CFLAGS=$_SAVE_CFLAGS
396     case "${CPU_ARCH}" in
397     x86 | x86_64)
398       AC_MSG_CHECKING(for x86 AVX2 asm support in compiler)
399       AC_TRY_COMPILE([],
400                      [asm volatile ("vpermq      \$0xd8,%ymm0,%ymm0 \n");],
401                      result="yes", result="no")
402       AC_MSG_RESULT("$result")
403       if test "$result" = "yes"; then
404           HAVE_X86_AVX2=1
405       fi
406       ;;
408     ppc*)
409       AC_MSG_CHECKING([whether we can enable AltiVec support])
410       HAVE_ALTIVEC=
411       _SAVE_CFLAGS=$CFLAGS
412       CFLAGS="$CFLAGS -maltivec"
413       AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
414                        [HAVE_ALTIVEC=1],
415                        AC_MSG_RESULT([no]))
416       CFLAGS=$_SAVE_CFLAGS
417       ;;
418     esac
420     DSO_LDOPTS='-shared'
421     if test "$GCC_USE_GNU_LD"; then
422         # Some tools like ASan use a runtime library that is only
423         # linked against executables, so we must allow undefined
424         # symbols for shared objects in some cases.
425         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
426             # Don't allow undefined symbols in libraries
427             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
429             # BSDs need `environ' exposed for posix_spawn (bug 753046)
430             case "$OS_TARGET" in
431             DragonFly|FreeBSD|NetBSD|OpenBSD)
432                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
433                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
434                 else
435                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
436                 fi
437                 ;;
438             esac
439         fi
440     fi
442     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
444     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
447 if test "$GNU_CXX"; then
448     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
450     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
453 # For profiling builds keep the symbol information
454 if test "$MOZ_PROFILING" -a -z "$STRIP_FLAGS"; then
455     case "$OS_TARGET" in
456     Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
457         STRIP_FLAGS="--strip-debug"
458         ;;
459     esac
462 dnl ========================================================
463 dnl = Enable DMD
464 dnl ========================================================
466 if test "$MOZ_DMD"; then
467     if test "${CPU_ARCH}" = "arm"; then
468         CFLAGS="$CFLAGS -funwind-tables"
469         CXXFLAGS="$CXXFLAGS -funwind-tables"
470     fi
473 dnl ========================================================
474 dnl System overrides of the defaults for host
475 dnl ========================================================
476 case "$host" in
477 *mingw*)
478     if test -n "$_WIN32_MSVC"; then
479         HOST_CFLAGS="$HOST_CFLAGS"
480     else
481         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
482     fi
483     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
484     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
485     HOST_BIN_SUFFIX=.exe
487     case "${host_cpu}" in
488     i*86)
489         if test -n "$_WIN32_MSVC"; then
490             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
491         fi
492         ;;
493     x86_64)
494         if test -n "$_WIN32_MSVC"; then
495             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
496         fi
497         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
498         ;;
499     esac
500     ;;
502 *-darwin*)
503     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
504     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
505     ;;
507 *-linux*|*-kfreebsd*-gnu|*-gnu*)
508     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
509     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
510     ;;
513     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
514     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
515     ;;
516 esac
518 dnl ========================================================
519 dnl System overrides of the defaults for target
520 dnl ========================================================
522 case "$target" in
523 *-darwin*)
524     MOZ_OPTIMIZE_FLAGS="-O3"
525     CXXFLAGS="$CXXFLAGS -stdlib=libc++"
526     DSO_LDOPTS=''
527     STRIP_FLAGS="$STRIP_FLAGS -x -S"
528     # The ExceptionHandling framework is needed for Objective-C exception
529     # logging code in nsObjCExceptions.h. Currently we only use that in debug
530     # builds.
531     MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
533     dnl DTrace and -dead_strip don't interact well. See bug 403132.
534     dnl ===================================================================
535     if test "x$enable_dtrace" = "xyes"; then
536         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
537     else
538         dnl check for the presence of the -dead_strip linker flag
539         AC_MSG_CHECKING([for -dead_strip option to ld])
540         _SAVE_LDFLAGS=$LDFLAGS
541         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
542         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
543         if test -n "$_HAVE_DEAD_STRIP" ; then
544             AC_MSG_RESULT([yes])
545             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
546         else
547             AC_MSG_RESULT([no])
548         fi
550         LDFLAGS=$_SAVE_LDFLAGS
551     fi
553     MOZ_FIX_LINK_PATHS="-Wl,-executable_path,${DIST}/bin"
554     ;;
556 *-android*|*-linuxandroid*)
557     if test "$COMPILE_ENVIRONMENT" -a -n "$MOZ_MEMORY"; then
558         MOZ_LINKER=1
559     fi
561     MOZ_GFX_OPTIMIZE_MOBILE=1
562     if test -z "$CLANG_CC"; then
563         MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
564     elif test -n "$RELEASE_OR_BETA"; then
565         # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
566         # -Oz is smaller than -Os on clang.
567         MOZ_OPTIMIZE_FLAGS="-Oz"
568         # Disable the outliner, which causes performance regressions, and is
569         # enabled on some platforms at -Oz.
570         if test -z "$MOZ_LTO"; then
571             DISABLE_OUTLINER="-mno-outline"
572             _SAVE_CFLAGS=$CFLAGS
573             CFLAGS="$CFLAGS $DISABLE_OUTLINER"
574             AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
575             CFLAGS="$_SAVE_CFLAGS"
576         else
577             DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
578             _SAVE_LDFLAGS=$LDFLAGS
579             LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
580             AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
581             LDFLAGS="$_SAVE_LDFLAGS"
582         fi
583     else
584         MOZ_OPTIMIZE_FLAGS="-O2"
585     fi
586     ;;
588 *-*linux*)
589     if test "$GNU_CC" -o "$GNU_CXX"; then
590         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
591         if test -n "$MOZ_DEBUG"; then
592             MOZ_OPTIMIZE_FLAGS="-Os"
593         else
594             MOZ_OPTIMIZE_FLAGS="-O2"
595         fi
596         if test -z "$CLANG_CC"; then
597            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
598         fi
599     fi
601     case "${target_cpu}" in
602     alpha*)
603         CFLAGS="$CFLAGS -mieee"
604         CXXFLAGS="$CXXFLAGS -mieee"
605     ;;
606     esac
607     ;;
608 *-mingw*)
609     DSO_CFLAGS=
610     DSO_PIC_CFLAGS=
611     # certain versions of cygwin's makedepend barf on the
612     # #include <string> vs -I./dist/include/string issue so don't use it
613     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
614         # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
615         if test -z "$CLANG_CC"; then
616             AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
617         fi
619         DSO_LDOPTS='-shared'
620         # Use temp file for windres (bug 213281)
621         RCFLAGS='-O coff --use-temp-file'
622         # mingw doesn't require kernel32, user32, and advapi32 explicitly
623         LIBS="$LIBS -luuid -lusp10 -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32"
624         MOZ_FIX_LINK_PATHS=
626         MOZ_OPTIMIZE_FLAGS="-O2"
628         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
629         WIN32_GUI_EXE_LDFLAGS=-mwindows
631         # Silence problematic clang warnings
632         CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
633         LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
634     else
635         TARGET_COMPILER_ABI=msvc
636         RANLIB='echo not_ranlib'
637         STRIP='echo not_strip'
638         # aarch64 doesn't support subsystems below 6.02
639         if test "$CPU_ARCH" = "aarch64"; then
640             WIN32_SUBSYSTEM_VERSION=6.02
641         else
642             WIN32_SUBSYSTEM_VERSION=6.01
643         fi
644         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
645         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
646         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
647         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
648         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
649         CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
650         CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
651         if test -z "$CLANG_CL"; then
652             CPPFLAGS="$CPPFLAGS -utf-8"
653         fi
654         if test "$CPU_ARCH" = "x86"; then
655             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
656             dnl more recent, so set that explicitly here unless another
657             dnl target arch has already been set.
658             changequote(,)
659             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
660               CFLAGS="$CFLAGS -arch:SSE2"
661             fi
662             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
663               CXXFLAGS="$CXXFLAGS -arch:SSE2"
664             fi
665             changequote([,])
666             SSE_FLAGS="-arch:SSE"
667             SSE2_FLAGS="-arch:SSE2"
668             dnl MSVC allows the use of intrinsics without any flags
669             dnl and doesn't have a separate arch for SSSE3
670             SSSE3_FLAGS="-arch:SSE2"
671         fi
672         dnl clang-cl requires appropriate flags to enable SSSE3 support
673         dnl on all architectures.
674         if test -n "$CLANG_CL"; then
675             SSSE3_FLAGS="-mssse3"
676         fi
677         dnl VS2013+ supports -Gw for better linker optimizations.
678         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
679         dnl Disabled on ASan because it causes false-positive ODR violations.
680         if test -z "$MOZ_ASAN"; then
681             CFLAGS="$CFLAGS -Gw"
682             CXXFLAGS="$CXXFLAGS -Gw"
683         else
684             # String tail merging doesn't play nice with ASan's ODR checker.
685             LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
686         fi
687         if test -n "$CLANG_CL"; then
688             # XXX We should combine some of these with our generic GCC-style
689             # warning checks.
690             #
691             # Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
692             CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
693             # We use offsetof on non-POD objects all the time.
694             # We also suppress this warning on other platforms.
695             CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
696             # This warns for reasonable things like:
697             #   enum { X = 0xffffffffU };
698             # which is annoying for IDL headers.
699             CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
700             # This warns for cases that would be reached by the Microsoft
701             # #include rules, but also currently warns on cases that would
702             # *also* be reached by standard C++ include rules.  That
703             # behavior doesn't seem useful, so we turn it off.
704             CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
705             # We normally error out on unknown pragmas, but since clang-cl
706             # claims to be MSVC, it would be difficult to add
707             # #if defined(_MSC_VER) && !defined(__clang__) everywhere we
708             # use such pragmas, so just ignore them.
709             CFLAGS="$CFLAGS -Wno-unknown-pragmas"
710             CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
711             # We get errors about various #pragma intrinsic directives from
712             # clang-cl, and we don't need to hear about those.
713             CFLAGS="$CFLAGS -Wno-ignored-pragmas"
714             CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
715             # clang-cl's Intrin.h marks things like _ReadWriteBarrier
716             # as __attribute((__deprecated__)).  This is nice to know,
717             # but since we don't get the equivalent warning from MSVC,
718             # let's just ignore it.
719             CFLAGS="$CFLAGS -Wno-deprecated-declarations"
720             CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
721             # We use a function like:
722             #   __declspec(noreturn) __inline void f() {}
723             # which -Winvalid-noreturn complains about.  Again, MSVC seems
724             # OK with it, so let's silence the warning.
725             CFLAGS="$CFLAGS -Wno-invalid-noreturn"
726             CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
727             # Missing |override| on virtual function declarations isn't
728             # something that MSVC currently warns about.
729             CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
730             # We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
731             # declaration on |operator delete(void*)|.  However, clang-cl
732             # must internally declare |operator delete(void*)| differently,
733             # which causes this warning for virtually every file in the
734             # tree.  clang-cl doesn't support -fno-exceptions or equivalent,
735             # so there doesn't seem to be any way to convince clang-cl to
736             # declare |delete| differently.  Therefore, suppress this
737             # warning.
738             CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
739             # Macros like STDMETHOD() and IFACEMETHOD() can declare
740             # __attribute__((nothrow)) on their respective method declarations,
741             # while the definitions are left without the matching attribute.
742             CXXFLAGS="$CXXFLAGS -Wno-microsoft-exception-spec"
743             # At least one MSVC header and several headers in-tree have
744             # unused typedefs, so turn this on.
745             CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
746             # jemalloc uses __declspec(allocator) as a profiler hint,
747             # which clang-cl doesn't understand.
748             CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
749             # __attribute__((unused)) really means "might be unused" and
750             # we use it to avoid warnings about things that are unused
751             # in some compilation units, but used in many others.  This
752             # warning insists on complaining about the latter case, which
753             # is annoying, and rather noisy.
754             CXXFLAGS="$CXXFLAGS -Wno-used-but-marked-unused"
755         fi
756         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
757         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
758         LIBS="$LIBS user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib"
759         MOZ_DEBUG_LDFLAGS='-DEBUG'
760         # Use a higher optimization level for clang-cl, so we can come closer
761         # to MSVC's performance numbers (see bug 1443590).
762         if test -n "$CLANG_CL"; then
763             MOZ_OPTIMIZE_FLAGS='-O2'
764         else
765             MOZ_OPTIMIZE_FLAGS='-O1 -Oi'
766         fi
767         MOZ_FIX_LINK_PATHS=
768         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
769         if test -z "$DEVELOPER_OPTIONS"; then
770             LDFLAGS="$LDFLAGS -RELEASE"
771         fi
772         RCFLAGS="-nologo"
773         dnl Minimum reqiurement of Gecko is VS2015 or later which supports
774         dnl both SSSE3 and SSE4.1.
775         HAVE_TOOLCHAIN_SUPPORT_MSSSE3=1
776         HAVE_TOOLCHAIN_SUPPORT_MSSE4_1=1
777         dnl allow AVX2 code from VS2015
778         HAVE_X86_AVX2=1
779     fi
780     AC_DEFINE(WIN32_LEAN_AND_MEAN)
781     dnl See http://support.microsoft.com/kb/143208 to use STL
782     AC_DEFINE(NOMINMAX)
783     BIN_SUFFIX='.exe'
784     MOZ_USER_DIR="Mozilla"
786     case "$host_os" in
787     cygwin*|msvc*|mks*)
788         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.])
789         ;;
790     esac
792     case "$target" in
793     i*86-*)
794         if test -n "$GNU_CC"; then
795             CFLAGS="$CFLAGS -mstackrealign"
796             CXXFLAGS="$CXXFLAGS -mstackrealign"
797             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
798         else
799             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
800             LDFLAGS="$LDFLAGS -SAFESEH"
801         fi
803         AC_DEFINE(_X86_)
804         ;;
805     x86_64-*)
806         if test -n "$_WIN32_MSVC"; then
807             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
808         fi
809         AC_DEFINE(_AMD64_)
810         ;;
811     aarch64-*)
812         if test -n "$_WIN32_MSVC"; then
813             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
814         fi
815         AC_DEFINE(_ARM64_)
816         ;;
817     *)
818         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
819         ;;
820     esac
821     ;;
823 *-netbsd*)
824     DSO_CFLAGS=''
825     CFLAGS="$CFLAGS -Dunix"
826     CXXFLAGS="$CXXFLAGS -Dunix"
827     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
828         DSO_PIC_CFLAGS='-fPIC -DPIC'
829         DSO_LDOPTS='-shared'
830         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
831     else
832         DSO_PIC_CFLAGS='-fPIC -DPIC'
833         DSO_LDOPTS='-shared'
834     fi
835     # This will fail on a.out systems prior to 1.5.1_ALPHA.
836     if test "$LIBRUNPATH"; then
837         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
838     fi
839     ;;
841 *-openbsd*)
842     if test -z "$X11BASE"; then
843         X11BASE=/usr/X11R6
844     fi
845     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
846     DSO_CFLAGS=''
847     DSO_PIC_CFLAGS='-fPIC'
848     DSO_LDOPTS='-shared -fPIC'
849     if test "$LIBRUNPATH"; then
850         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
851     fi
852     ;;
854 *-solaris*)
855     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
856     ;;
858 esac
860 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
861     MOZ_OPTIMIZE_FLAGS="-O"
864 AC_SUBST_LIST(MMX_FLAGS)
865 AC_SUBST_LIST(SSE_FLAGS)
866 AC_SUBST_LIST(SSE2_FLAGS)
867 AC_SUBST_LIST(SSSE3_FLAGS)
869 AC_SUBST(MOZ_LINKER)
870 if test -n "$MOZ_LINKER"; then
871   AC_DEFINE(MOZ_LINKER)
872   MOZ_LINKER_EXTRACT=1
873   AC_CHECK_PROGS(XZ, xz)
876 if test -z "$COMPILE_ENVIRONMENT"; then
877     SKIP_COMPILER_CHECKS=1
878     SKIP_LIBRARY_CHECKS=1
879     MOZ_DEBUGGING_OPTS
880 else
881     MOZ_COMPILER_OPTS
882 fi # COMPILE_ENVIRONMENT
884 if test -z "$SKIP_COMPILER_CHECKS"; then
885 dnl Checks for typedefs, structures, and compiler characteristics.
886 dnl ========================================================
887 AC_C_CONST
888 AC_TYPE_MODE_T
889 AC_TYPE_OFF_T
890 AC_TYPE_PID_T
891 AC_TYPE_SIZE_T
892 AC_LANG_CPLUSPLUS
893 AC_LANG_C
895 AC_LANG_CPLUSPLUS
897 MOZ_CXX11
899 AC_LANG_C
901 case "${OS_TARGET}" in
902 Darwin)
903   ;;
905   STL_FLAGS="-I${DIST}/stl_wrappers"
906   WRAP_STL_INCLUDES=1
907   ;;
908 esac
910 if test "$MOZ_BUILD_APP" = "tools/crashreporter"; then
911     WRAP_STL_INCLUDES=
914 dnl Checks for header files.
915 dnl ========================================================
916 AC_HEADER_DIRENT
917 case "$target_os" in
918 bitrig*|dragonfly*|freebsd*|openbsd*)
919 # for stuff like -lXshm
920     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
921     ;;
922 esac
924 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
925 AC_CACHE_CHECK(for sockaddr_in.sin_len,
926                    ac_cv_sockaddr_in_sin_len,
927                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
928                                     #include <sys/types.h>
929                                     #endif
930                                     #include <netinet/in.h>
931                                     struct sockaddr_in x;
932                                     void *foo = (void*) &x.sin_len;],
933                                    [],
934                                    [ac_cv_sockaddr_in_sin_len=true],
935                                    [ac_cv_sockaddr_in_sin_len=false])])
936 if test "$ac_cv_sockaddr_in_sin_len" = true ; then
937   AC_DEFINE(HAVE_SIN_LEN)
938 dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
939   AC_DEFINE(HAVE_SCONN_LEN)
942 AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
943                ac_cv_sockaddr_in6_sin6_len,
944                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
945                                 #include <sys/types.h>
946                                 #endif
947                                 #include <netinet/in.h>
948                                 struct sockaddr_in6 x;
949                                 void *foo = (void*) &x.sin6_len;],
950                                [],
951                                [ac_cv_sockaddr_in6_sin6_len=true],
952                                [ac_cv_sockaddr_in6_sin6_len=false])])
953 if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
954   AC_DEFINE(HAVE_SIN6_LEN)
957 AC_CACHE_CHECK(for sockaddr.sa_len,
958                ac_cv_sockaddr_sa_len,
959                [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
960                                 #include <sys/types.h>
961                                 #endif
962                                 #include <sys/socket.h>
963                                 struct sockaddr x;
964                                 void *foo = (void*) &x.sa_len;],
965                                [],
966                                [ac_cv_sockaddr_sa_len=true],
967                                [ac_cv_sockaddr_sa_len=false])])
968 if test "$ac_cv_sockaddr_sa_len" = true ; then
969   AC_DEFINE(HAVE_SA_LEN)
972 dnl Checks for libraries.
973 dnl ========================================================
974 AC_CHECK_LIB(c_r, gethostbyname_r)
976 dnl We don't want to link with libdl even if it's present on OS X, since
977 dnl it's not used and not part of the default installation. OS/2 has dlfcn
978 dnl in libc.
979 dnl We don't want to link against libm or libpthread on Darwin since
980 dnl they both are just symlinks to libSystem and explicitly linking
981 dnl against libSystem causes issues when debugging (see bug 299601).
982 case $target in
983 *-darwin*)
984     ;;
986     AC_SEARCH_LIBS(dlopen, dl,
987         MOZ_CHECK_HEADER(dlfcn.h,
988         AC_DEFINE(HAVE_DLOPEN)))
989     ;;
990 esac
992 _SAVE_CFLAGS="$CFLAGS"
993 CFLAGS="$CFLAGS -D_GNU_SOURCE"
994 AC_CHECK_FUNCS(dladdr memmem)
995 CFLAGS="$_SAVE_CFLAGS"
997 if test ! "$GNU_CXX"; then
998     AC_CHECK_LIB(C, demangle)
1001 AC_CHECK_LIB(socket, socket)
1003 XLDFLAGS="$X_LIBS"
1004 XLIBS="$X_EXTRA_LIBS"
1006 dnl ========================================================
1007 dnl Checks for X libraries.
1008 dnl Ordering is important.
1009 dnl Xt is dependent upon SM as of X11R6
1010 dnl ========================================================
1011 if test -n "$MOZ_X11"; then
1012     AC_DEFINE_UNQUOTED(FUNCPROTO,15)
1013     _SAVE_LDFLAGS="$LDFLAGS"
1014     _SAVE_LIBS="$LIBS"
1015     LDFLAGS="$XLDFLAGS $LDFLAGS"
1016     AC_CHECK_LIB(X11, XDrawLines, [XLIBS="-lX11 $XLIBS"],
1017         [MISSING_X="$MISSING_X -lX11"], $XLIBS)
1018     AC_CHECK_LIB(Xext, XextAddDisplay, [XEXT_LIBS="-lXext"],
1019         [MISSING_X="$MISSING_X -lXext"], $XLIBS)
1021     AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt"], [
1022         unset ac_cv_lib_Xt_XtFree
1023         AC_CHECK_LIB(ICE, IceFlush, [XT_LIBS="-lICE $XT_LIBS"],, $XT_LIBS $XLIBS)
1024         AC_CHECK_LIB(SM, SmcCloseConnection, [XT_LIBS="-lSM $XT_LIBS"],, $XT_LIBS $XLIBS)
1025         AC_CHECK_LIB(Xt, XtFree, [ XT_LIBS="-lXt $XT_LIBS"],
1026             [MISSING_X="$MISSING_X -lXt"], $X_PRE_LIBS $XT_LIBS $XLIBS)
1027         ])
1029     dnl ========================================================
1030     dnl = Check for xcb
1031     dnl ========================================================
1032     AC_CHECK_LIB(xcb, xcb_connect, [XLIBS="-lxcb $XLIBS"],
1033         [MISSING_X="$MISSING_X -lxcb"], $XLIBS)
1034     AC_CHECK_LIB(xcb-shm, xcb_shm_query_version, [XLIBS="-lxcb-shm $XLIBS"],
1035         [MISSING_X="$MISSING_X -lxcb-shm"], $XLIBS)
1036     AC_CHECK_LIB(X11-xcb, XGetXCBConnection, [XLIBS="-lX11-xcb $XLIBS"],
1037         [MISSING_X="$MISSING_X -lX11-xcb"], $XLIBS)
1039     LDFLAGS="$_SAVE_LDFLAGS"
1040     LIBS="$_SAVE_LIBS"
1041 fi # $MOZ_X11
1043 AC_SUBST_LIST(XCFLAGS)
1044 AC_SUBST_LIST(XLDFLAGS)
1045 AC_SUBST_LIST(XLIBS)
1046 AC_SUBST_LIST(XEXT_LIBS)
1047 AC_SUBST_LIST(XT_LIBS)
1049 dnl ========================================================
1050 dnl = pthread support
1051 dnl = Start by checking whether the system support pthreads
1052 dnl ========================================================
1053 case "$target_os" in
1054 darwin*)
1055     MOZ_USE_PTHREADS=1
1056     ;;
1058     AC_CHECK_LIB(pthreads, pthread_create,
1059         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
1060         AC_CHECK_LIB(pthread, pthread_create,
1061             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
1062             AC_CHECK_LIB(c_r, pthread_create,
1063                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
1064                 AC_CHECK_LIB(c, pthread_create,
1065                     MOZ_USE_PTHREADS=1
1066                 )
1067             )
1068         )
1069     )
1070     ;;
1071 esac
1073 dnl ========================================================
1074 dnl Do the platform specific pthread hackery
1075 dnl ========================================================
1076 if test "$MOZ_USE_PTHREADS"x != x
1077 then
1078     dnl
1079     dnl See if -pthread is supported.
1080     dnl
1081     rm -f conftest*
1082     ac_cv_have_dash_pthread=no
1083     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
1084     echo 'int main() { return 0; }' | cat > conftest.c
1085     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
1086     if test $? -eq 0; then
1087         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1088             ac_cv_have_dash_pthread=yes
1089             case "$target_os" in
1090             freebsd*)
1091 # Freebsd doesn't use -pthread for compiles, it uses them for linking
1092                 ;;
1093             *)
1094                 CFLAGS="$CFLAGS -pthread"
1095                 CXXFLAGS="$CXXFLAGS -pthread"
1096                 ;;
1097             esac
1098         fi
1099     fi
1100     rm -f conftest*
1101     AC_MSG_RESULT($ac_cv_have_dash_pthread)
1103     dnl
1104     dnl See if -pthreads is supported.
1105     dnl
1106     ac_cv_have_dash_pthreads=no
1107     if test "$ac_cv_have_dash_pthread" = "no"; then
1108         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
1109         echo 'int main() { return 0; }' | cat > conftest.c
1110         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
1111         if test $? -eq 0; then
1112             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
1113                 ac_cv_have_dash_pthreads=yes
1114                 CFLAGS="$CFLAGS -pthreads"
1115                 CXXFLAGS="$CXXFLAGS -pthreads"
1116             fi
1117         fi
1118         rm -f conftest*
1119         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
1120     fi
1122     case "$target" in
1123         *-*-freebsd*)
1124             AC_DEFINE(_REENTRANT)
1125             AC_DEFINE(_THREAD_SAFE)
1126             dnl -pthread links in -lpthread, so don't specify it explicitly.
1127             if test "$ac_cv_have_dash_pthread" = "yes"; then
1128                 _PTHREAD_LDFLAGS="-pthread"
1129             fi
1130             ;;
1132         *-*-openbsd*|*-*-bsdi*)
1133             AC_DEFINE(_REENTRANT)
1134             AC_DEFINE(_THREAD_SAFE)
1135             dnl -pthread links in -lc_r, so don't specify it explicitly.
1136             if test "$ac_cv_have_dash_pthread" = "yes"; then
1137                 _PTHREAD_LDFLAGS="-pthread"
1138             fi
1139             ;;
1141         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
1142             AC_DEFINE(_REENTRANT)
1143             ;;
1145     esac
1146     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
1147     AC_SUBST(MOZ_USE_PTHREADS)
1148     MOZ_CHECK_HEADERS(pthread.h)
1152 dnl Checks for library functions.
1153 dnl ========================================================
1154 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall)
1156 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
1157 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
1158                ac_cv_clock_monotonic,
1159                [for libs in "" -lrt; do
1160                     _SAVE_LIBS="$LIBS"
1161                     _SAVE_CFLAGS="$CFLAGS"
1162                     LIBS="$LIBS $libs"
1163                     CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
1164 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
1165 dnl we should or not be able to use it. To detect if we can, we need to make the
1166 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
1167                     AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
1168                                  #include <time.h>],
1169                                  [ struct timespec ts;
1170                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
1171                                  ac_cv_clock_monotonic=$libs
1172                                  LIBS="$_SAVE_LIBS"
1173                                  CFLAGS="$_SAVE_CFLAGS"
1174                                  break,
1175                                  ac_cv_clock_monotonic=no)
1176                     LIBS="$_SAVE_LIBS"
1177                     CFLAGS="$_SAVE_CFLAGS"
1178                 done])
1179 if test "$ac_cv_clock_monotonic" != "no"; then
1180     HAVE_CLOCK_MONOTONIC=1
1181     REALTIME_LIBS=$ac_cv_clock_monotonic
1182     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
1183     AC_SUBST(HAVE_CLOCK_MONOTONIC)
1184     AC_SUBST_LIST(REALTIME_LIBS)
1187 dnl Turn on warnings-as-errors to prevent implicit declaration of
1188 dnl pthread_cond_timedwait_monotonic_np, which can cause this test to
1189 dnl inadvertently pass even if the function does not really exist.
1190 _SAVE_CFLAGS="$CFLAGS"
1191 CFLAGS="$CFLAGS $WARNINGS_AS_ERRORS"
1192 AC_CACHE_CHECK(for pthread_cond_timedwait_monotonic_np,
1193                ac_cv_pthread_cond_timedwait_monotonic_np,
1194                AC_TRY_LINK([#include <pthread.h>],
1195                            [pthread_cond_timedwait_monotonic_np(0, 0, 0);],
1196                            ac_cv_pthread_cond_timewait_monotonic_np=yes,
1197                            ac_cv_pthread_cond_timewait_monotonic_np=no))
1198 if test "$ac_cv_pthread_cond_timewait_monotonic_np" != "no"; then
1199     AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
1201 CFLAGS=$_SAVE_CFLAGS
1203 AC_CACHE_CHECK(
1204     [for res_ninit()],
1205     ac_cv_func_res_ninit,
1206     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
1207         dnl no need for res_ninit() on NetBSD and OpenBSD
1208         ac_cv_func_res_ninit=no
1209      else
1210         AC_TRY_LINK([
1211             #ifdef linux
1212             #define _BSD_SOURCE 1
1213             #endif
1214             #include <sys/types.h>
1215             #include <netinet/in.h>
1216             #include <arpa/nameser.h>
1217             #include <resolv.h>
1218             ],
1219             [int foo = res_ninit(&_res);],
1220             [ac_cv_func_res_ninit=yes],
1221             [ac_cv_func_res_ninit=no])
1222      fi
1223     ])
1225 if test "$ac_cv_func_res_ninit" = "yes"; then
1226     AC_DEFINE(HAVE_RES_NINIT)
1227 dnl must add the link line we do something as foolish as this... dougt
1228 dnl else
1229 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
1230 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
1233 AC_LANG_C
1235 dnl **********************
1236 dnl *** va_copy checks ***
1237 AC_CACHE_CHECK([for an implementation of va_copy()],
1238                ac_cv_va_copy,
1239     [AC_TRY_COMPILE([#include <stdarg.h>
1240                      #include <stdlib.h>
1241         void f (int i, ...) {
1242             va_list args1, args2;
1243             va_start (args1, i);
1244             va_copy (args2, args1);
1245             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1246                 exit (1);
1247             va_end (args1); va_end (args2);
1248         }],
1249         [f(0, 42); return 0],
1250         [ac_cv_va_copy=yes],
1251         [ac_cv_va_copy=no]
1252     )]
1254 AC_CACHE_CHECK([whether va_list can be copied by value],
1255                ac_cv_va_val_copy,
1256     [AC_TRY_COMPILE([#include <stdarg.h>
1257                      #include <stdlib.h>
1258         void f (int i, ...) {
1259             va_list args1, args2;
1260             va_start (args1, i);
1261             args2 = args1;
1262             if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1263                 exit (1);
1264             va_end (args1); va_end (args2);
1265         }],
1266         [f(0, 42); return 0],
1267         [ac_cv_va_val_copy=yes],
1268         [ac_cv_va_val_copy=no],
1269     )]
1271 if test "x$ac_cv_va_copy" = "xyes"; then
1272     AC_DEFINE(VA_COPY, va_copy)
1273     AC_DEFINE(HAVE_VA_COPY)
1276 if test "x$ac_cv_va_val_copy" = "xno"; then
1277    AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
1280 dnl ===================================================================
1281 dnl ========================================================
1282 dnl Put your C++ language/feature checks below
1283 dnl ========================================================
1284 AC_LANG_CPLUSPLUS
1286 ARM_ABI_PREFIX=
1287 if test "$GNU_CC"; then
1288   if test "$CPU_ARCH" = "arm" ; then
1289     AC_CACHE_CHECK(for ARM EABI,
1290         ac_cv_gcc_arm_eabi,
1291         [AC_TRY_COMPILE([],
1292                         [
1293 #if defined(__ARM_EABI__)
1294   return 0;
1295 #else
1296 #error Not ARM EABI.
1297 #endif
1298                         ],
1299                         ac_cv_gcc_arm_eabi="yes",
1300                         ac_cv_gcc_arm_eabi="no")])
1301     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
1302         HAVE_ARM_EABI=1
1303         ARM_ABI_PREFIX=eabi-
1304     else
1305         ARM_ABI_PREFIX=oabi-
1306     fi
1307   fi
1309   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
1312 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
1313 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
1314 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
1315 # linking XUL.
1316 _SAVE_LDFLAGS=$LDFLAGS
1317 LDFLAGS="$LDFLAGS $DSO_PIC_CFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
1318 AC_CACHE_CHECK(for __thread keyword for TLS variables,
1319                ac_cv_thread_keyword,
1320                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
1321                             [return tlsIsMainThread;],
1322                             ac_cv_thread_keyword=yes,
1323                             ac_cv_thread_keyword=no)])
1324 LDFLAGS=$_SAVE_LDFLAGS
1325 # The custom dynamic linker doesn't support TLS variables
1326 MOZ_TLS=
1327 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
1328   # mips builds fail with TLS variables because of a binutils bug.
1329   # See bug 528687
1330   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
1331   case "${target}" in
1332     mips*-*)
1333       :
1334       ;;
1335     *-android*|*-linuxandroid*)
1336       :
1337       ;;
1338     *-openbsd*)
1339       :
1340       ;;
1341     *)
1342       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
1343       MOZ_TLS=1
1344       ;;
1345   esac
1348 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
1349 if test -n "$MOZ_LINKER"; then
1350   if test "$CPU_ARCH" = arm; then
1351     dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
1352     if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
1353       LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1354       _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1355     fi
1356   fi
1358 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
1359 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
1360 dnl Since the linker only understands the sysv ones, no need to build the
1361 dnl gnu style tables anyways.
1362   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
1365 dnl End of C++ language/feature checks
1366 AC_LANG_C
1368 dnl ========================================================
1369 dnl =  Internationalization checks
1370 dnl ========================================================
1372 dnl Internationalization and Locale support is different
1373 dnl on various UNIX platforms.  Checks for specific i18n
1374 dnl features go here.
1376 AC_HAVE_FUNCS(localeconv)
1378 fi # ! SKIP_COMPILER_CHECKS
1380 if test -n "${COMPILE_ENVIRONMENT}"; then
1381   MOZ_CHECK_ALLOCATOR
1384 TARGET_XPCOM_ABI=
1385 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1386     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1387     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
1390 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1391 dnl features that Windows actually does support.
1393 if test -n "$SKIP_COMPILER_CHECKS"; then
1394    dnl Windows has malloc.h
1395    AC_DEFINE(MALLOC_H, [<malloc.h>])
1396    AC_DEFINE(HAVE_FORCEINLINE)
1397    AC_DEFINE(HAVE_LOCALECONV)
1398 fi # SKIP_COMPILER_CHECKS
1400 dnl Mozilla specific options
1401 dnl ========================================================
1402 dnl The macros used for command line options
1403 dnl are defined in build/autoconf/altoptions.m4.
1405 dnl ========================================================
1406 dnl =
1407 dnl = Check for external package dependencies
1408 dnl =
1409 dnl ========================================================
1410 MOZ_ARG_HEADER(External Packages)
1412 case "$OS_TARGET" in
1413 WINNT|Darwin|Android)
1414   MOZ_FOLD_LIBS=1
1415   ;;
1417   MOZ_FOLD_LIBS=
1418   ;;
1419 esac
1421 MOZ_CONFIG_NSPR()
1423 dnl ========================================================
1424 dnl system libevent Support
1425 dnl ========================================================
1426 MOZ_ARG_WITH_STRING(system-libevent,
1427 [  --with-system-libevent[=PFX]
1428                           Use system libevent [installed at prefix PFX]],
1429     LIBEVENT_DIR=$withval)
1431 _SAVE_CFLAGS=$CFLAGS
1432 _SAVE_LDFLAGS=$LDFLAGS
1433 _SAVE_LIBS=$LIBS
1434 if test "$LIBEVENT_DIR" = yes; then
1435     PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent,
1436         MOZ_SYSTEM_LIBEVENT=1,
1437         LIBEVENT_DIR=/usr)
1439 if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
1440     MOZ_SYSTEM_LIBEVENT=
1441 elif test -z "$MOZ_SYSTEM_LIBEVENT"; then
1442     CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
1443     LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
1444     MOZ_CHECK_HEADER(event.h,
1445         [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
1446              AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
1447          fi],
1448         AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
1449     AC_CHECK_LIB(event, event_init,
1450                  [MOZ_SYSTEM_LIBEVENT=1
1451                   MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include"
1452                   MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
1453                  [MOZ_SYSTEM_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=])
1455 CFLAGS=$_SAVE_CFLAGS
1456 LDFLAGS=$_SAVE_LDFLAGS
1457 LIBS=$_SAVE_LIBS
1459 AC_SUBST(MOZ_SYSTEM_LIBEVENT)
1461 dnl ========================================================
1462 dnl = If NSS was not detected in the system,
1463 dnl = use the one in the source tree (mozilla/security/nss)
1464 dnl ========================================================
1466 MOZ_ARG_WITH_BOOL(system-nss,
1467 [  --with-system-nss       Use system installed NSS],
1468     _USE_SYSTEM_NSS=1 )
1470 if test -n "$_USE_SYSTEM_NSS"; then
1471     AM_PATH_NSS(3.53, [MOZ_SYSTEM_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])])
1474 NSS_CFLAGS="$NSS_CFLAGS -I${DIST}/include/nss"
1475 if test -z "$MOZ_SYSTEM_NSS"; then
1476    case "${OS_ARCH}" in
1477         # Only few platforms have been tested with GYP
1478         WINNT|Darwin|Linux|DragonFly|FreeBSD|NetBSD|OpenBSD|SunOS)
1479             ;;
1480         *)
1481             AC_MSG_ERROR([building in-tree NSS is not supported on this platform. Use --with-system-nss])
1482             ;;
1483    esac
1486 dnl system ZLIB support
1487 dnl ========================================================
1488 MOZ_ZLIB_CHECK([1.2.3])
1490 if test -z "$SKIP_LIBRARY_CHECKS"; then
1492 dnl ========================================================
1493 dnl system PNG Support
1494 dnl ========================================================
1495 MOZ_ARG_WITH_STRING(system-png,
1496 [  --with-system-png[=PFX]
1497                           Use system libpng [installed at prefix PFX]],
1498     PNG_DIR=$withval)
1500 _SAVE_CFLAGS=$CFLAGS
1501 _SAVE_LDFLAGS=$LDFLAGS
1502 _SAVE_LIBS=$LIBS
1503 if test -n "${PNG_DIR}" -a "${PNG_DIR}" != "yes"; then
1504     CFLAGS="-I${PNG_DIR}/include $CFLAGS"
1505     LDFLAGS="-L${PNG_DIR}/lib $LDFLAGS"
1507 if test -z "$PNG_DIR" -o "$PNG_DIR" = no; then
1508     MOZ_SYSTEM_PNG=
1509 else
1510     AC_CHECK_LIB(png, png_get_valid, [MOZ_SYSTEM_PNG=1 MOZ_PNG_LIBS="-lpng"],
1511                  AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1512     AC_CHECK_LIB(png, png_get_acTL, ,
1513                  AC_MSG_ERROR([--with-system-png won't work because the system's libpng doesn't have APNG support]))
1515 if test "$MOZ_SYSTEM_PNG" = 1; then
1516     AC_TRY_COMPILE([ #include <stdio.h>
1517                      #include <sys/types.h>
1518                      #include <png.h> ],
1519                    [ #if PNG_LIBPNG_VER < $MOZPNG
1520                      #error "Insufficient libpng version ($MOZPNG required)."
1521                      #endif
1522                      #ifndef PNG_UINT_31_MAX
1523                      #error "Insufficient libpng version."
1524                      #endif ],
1525                    MOZ_SYSTEM_PNG=1,
1526                    AC_MSG_ERROR([--with-system-png requested but no working libpng found]))
1528 CFLAGS=$_SAVE_CFLAGS
1529 LDFLAGS=$_SAVE_LDFLAGS
1530 LIBS=$_SAVE_LIBS
1532 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$MOZ_SYSTEM_PNG" = 1; then
1533     MOZ_PNG_CFLAGS="-I${PNG_DIR}/include"
1534     MOZ_PNG_LIBS="-L${PNG_DIR}/lib ${MOZ_PNG_LIBS}"
1537 fi # SKIP_LIBRARY_CHECKS
1539 dnl ========================================================
1540 dnl =
1541 dnl = Application
1542 dnl =
1543 dnl ========================================================
1545 MOZ_ARG_HEADER(Application)
1547 ENABLE_SYSTEM_EXTENSION_DIRS=1
1548 MOZ_BRANDING_DIRECTORY=
1549 MOZ_OFFICIAL_BRANDING=
1550 MOZ_AUTH_EXTENSION=1
1551 MOZ_PREF_EXTENSIONS=1
1552 MOZ_SPELLCHECK=1
1553 MOZ_UNIVERSALCHARDET=1
1554 MOZ_XUL=1
1555 MOZ_ZIPWRITER=1
1556 MOZ_NO_SMART_CARDS=
1557 MOZ_USE_NATIVE_POPUP_WINDOWS=
1558 MOZ_EXCLUDE_HYPHENATION_DICTIONARIES=
1559 MOZ_SANDBOX=1
1560 MOZ_BINARY_EXTENSIONS=
1561 MOZ_DEVTOOLS=server
1563 case "$target_os" in
1564     mingw*)
1565         NS_ENABLE_TSF=1
1566         AC_DEFINE(NS_ENABLE_TSF)
1567         ;;
1568 esac
1570 # Optional Firefox for Android partner distribution directory.
1571 MOZ_ARG_WITH_STRING(android-distribution-directory,
1572 [  --with-android-distribution-directory=dir
1573                           Optional Firefox for Android partner distribution directory.],
1574   MOZ_ANDROID_DISTRIBUTION_DIRECTORY=$withval)
1576 if test -n "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY"; then
1577   # A distribution directory must have an assets/distribution directory.
1578   # See https://wiki.mozilla.org/Mobile/Distribution_Files.
1579   if test ! -d "$MOZ_ANDROID_DISTRIBUTION_DIRECTORY/assets/distribution" ; then
1580     AC_MSG_ERROR([--with-android-distribution-directory does not contain assets/distribution;
1581                   (looked for ${MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets/distribution).])
1582   fi
1584 AC_SUBST(MOZ_ANDROID_DISTRIBUTION_DIRECTORY)
1586 dnl ========================================================
1587 dnl = Trademarked Branding
1588 dnl ========================================================
1589 MOZ_ARG_ENABLE_BOOL(official-branding,
1590 [  --enable-official-branding
1591                           Enable Official mozilla.org Branding
1592                           Do not distribute builds with
1593                           --enable-official-branding unless you have
1594                           permission to use trademarks per
1595                           http://www.mozilla.org/foundation/trademarks/ .],
1596     MOZ_OFFICIAL_BRANDING=1,
1597     MOZ_OFFICIAL_BRANDING=)
1599 # Allow the application to influence configure with a confvars.sh script.
1600 AC_MSG_CHECKING([if app-specific confvars.sh exists])
1601 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
1602   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
1603   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
1604 else
1605   AC_MSG_RESULT([no])
1608 # Allow someone to change MOZ_APP_NAME and MOZ_APP_BASENAME in mozconfig
1609 MOZ_ARG_WITH_STRING(app-name,
1610 [--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME],
1611 WITH_APP_NAME=$withval,
1614 if test -n "$WITH_APP_NAME" ; then
1615     MOZ_APP_NAME="$WITH_APP_NAME"
1618 MOZ_ARG_WITH_STRING(app-basename,
1619 [--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME],
1620 WITH_APP_BASENAME=$withval,
1623 if test -n "$WITH_APP_BASENAME" ; then
1624     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
1627 dnl ========================================================
1628 dnl Ensure Android SDK and build-tools versions depending on
1629 dnl mobile target.
1630 dnl ========================================================
1632 case "$MOZ_BUILD_APP" in
1633 mobile/android)
1634     MOZ_ANDROID_SDK
1635     ;;
1636 esac
1638 dnl ========================================================
1639 dnl =
1640 dnl = Toolkit Options
1641 dnl =
1642 dnl ========================================================
1643 MOZ_ARG_HEADER(Toolkit Options)
1645 dnl ========================================================
1646 dnl = Enable the toolkit as needed                         =
1647 dnl ========================================================
1649 case "$MOZ_WIDGET_TOOLKIT" in
1651 cocoa)
1652     LDFLAGS="$LDFLAGS -framework Cocoa"
1653     # Use -Wl as a trick to avoid -framework and framework names from
1654     # being separated by AC_SUBST_LIST.
1655     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'
1656     TK_CFLAGS=""
1657     CFLAGS="$CFLAGS $TK_CFLAGS"
1658     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
1659     MOZ_USER_DIR="Mozilla"
1660     MOZ_FS_LAYOUT=bundle
1661     ;;
1663 uikit)
1664     LDFLAGS="$LDFLAGS -framework UIKit"
1665     TK_CFLAGS=""
1666     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'
1667     CFLAGS="$CFLAGS $TK_CFLAGS"
1668     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
1669     MOZ_USER_DIR="Mozilla"
1670     MOZ_FS_LAYOUT=bundle
1671     ;;
1673 esac
1675 if test "$OS_TARGET" = Darwin; then
1676     LDFLAGS="$LDFLAGS -lobjc"
1679 dnl there are a lot of tests on MOZ_ENABLE_GTK below, that are more convenient
1680 dnl to keep that way than testing against MOZ_WIDGET_TOOLKIT
1681 case "$MOZ_WIDGET_TOOLKIT" in
1682 gtk*)
1683     MOZ_ENABLE_GTK=1
1684     ;;
1685 esac
1687 if test "$COMPILE_ENVIRONMENT"; then
1688   if test "$MOZ_WIDGET_TOOLKIT" = gtk; then
1689     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)
1690     MOZ_GTK3_CFLAGS="-I${_topsrcdir}/widget/gtk/compat-gtk3 $MOZ_GTK3_CFLAGS"
1691     TK_CFLAGS=$MOZ_GTK3_CFLAGS
1692     TK_LIBS=$MOZ_GTK3_LIBS
1693     dnl GDK_VERSION_MIN_REQUIRED is not set here as GDK3 deprecated warnings
1694     dnl are suppressed by widget/gtk/compat-gtk3/gdk/gdkversionmacros.h.
1695     AC_DEFINE_UNQUOTED(GDK_VERSION_MAX_ALLOWED,$GDK_VERSION_MAX_ALLOWED)
1696     GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32
1697   fi
1698   if test "$MOZ_ENABLE_GTK"; then
1699     if test "$MOZ_X11"; then
1700       GDK_PACKAGES=gdk-x11-2.0
1701     fi
1702     AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
1703     AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)
1705     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)
1706     MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
1707   fi
1708 fi # COMPILE_ENVIRONMENT
1710 AC_SUBST(MOZ_FS_LAYOUT)
1712 AC_SUBST_LIST(TK_CFLAGS)
1713 AC_SUBST_LIST(TK_LIBS)
1715 dnl ========================================================
1716 dnl =
1717 dnl = Components & Features
1718 dnl =
1719 dnl ========================================================
1720 MOZ_ARG_HEADER(Components and Features)
1722 AC_SUBST(MOZ_OFFICIAL_BRANDING)
1723 if test -n "$MOZ_OFFICIAL_BRANDING"; then
1724   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
1725     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
1726   else
1727     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
1728     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
1729   fi
1732 MOZ_ARG_WITH_STRING(branding,
1733 [  --with-branding=dir     Use branding from the specified directory.],
1734     MOZ_BRANDING_DIRECTORY=$withval)
1736 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
1737 if test -z "$REAL_BRANDING_DIRECTORY"; then
1738   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
1741 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
1742   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
1743 elif test -f "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
1744   . "${EXTERNAL_SOURCE_DIR}/$REAL_BRANDING_DIRECTORY/configure.sh"
1747 AC_SUBST(MOZ_BRANDING_DIRECTORY)
1749 dnl ========================================================
1750 dnl = Distribution ID
1751 dnl ========================================================
1752 MOZ_ARG_WITH_STRING(distribution-id,
1753 [  --with-distribution-id=ID
1754                           Set distribution-specific id (default=org.mozilla)],
1755 [ val=`echo $withval`
1756     MOZ_DISTRIBUTION_ID="$val"])
1758 if test -z "$MOZ_DISTRIBUTION_ID"; then
1759    MOZ_DISTRIBUTION_ID="org.mozilla"
1762 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
1763 AC_SUBST(MOZ_DISTRIBUTION_ID)
1765 dnl ========================================================
1766 dnl = libproxy support
1767 dnl ========================================================
1769 if test "$MOZ_ENABLE_GTK"
1770 then
1771     MOZ_ENABLE_LIBPROXY=
1773     MOZ_ARG_ENABLE_BOOL(libproxy,
1774     [  --enable-libproxy         Enable libproxy support ],
1775     MOZ_ENABLE_LIBPROXY=1,
1776     MOZ_ENABLE_LIBPROXY=)
1778     if test "$MOZ_ENABLE_LIBPROXY"
1779     then
1780         PKG_CHECK_MODULES(MOZ_LIBPROXY, libproxy-1.0)
1781         AC_DEFINE(MOZ_ENABLE_LIBPROXY)
1782     fi
1784 AC_SUBST(MOZ_ENABLE_LIBPROXY)
1786 dnl ========================================================
1787 dnl = dbus support
1788 dnl ========================================================
1790 if test "$MOZ_ENABLE_GTK"
1791 then
1792     MOZ_ENABLE_DBUS=1
1794     MOZ_ARG_DISABLE_BOOL(dbus,
1795     [  --disable-dbus          Disable dbus support ],
1796         MOZ_ENABLE_DBUS=,
1797         MOZ_ENABLE_DBUS=1)
1799     if test "$MOZ_ENABLE_DBUS"
1800     then
1801         PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
1802         PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
1803         AC_DEFINE(MOZ_ENABLE_DBUS)
1804     fi
1806 AC_SUBST(MOZ_ENABLE_DBUS)
1808 dnl =========================================================
1809 dnl = Whether to exclude hyphenations files in the build
1810 dnl =========================================================
1811 if test -n "$MOZ_EXCLUDE_HYPHENATION_DICTIONARIES"; then
1812     AC_DEFINE(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
1815 AC_TRY_COMPILE([#include <linux/ethtool.h>],
1816                [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
1817                MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
1819 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
1821 if test -n "$MOZ_WEBRTC"; then
1822     if test -n "$MOZ_X11"; then
1823       MOZ_WEBRTC_X11_LIBS="-lXext -lXdamage -lXfixes -lXcomposite"
1824     fi
1827 AC_SUBST_LIST(MOZ_WEBRTC_X11_LIBS)
1829 dnl ========================================================
1830 dnl = Apple platform decoder support
1831 dnl ========================================================
1832 if test "$COMPILE_ENVIRONMENT"; then
1833 if test -n "$MOZ_APPLEMEDIA"; then
1834   # hack in frameworks for fmp4 - see bug 1029974
1835   # We load VideoToolbox and CoreMedia dynamically, so they don't appear here.
1836   LDFLAGS="$LDFLAGS -framework AudioToolbox"
1837   dnl Verify CoreMedia is available.
1838   AC_CHECK_HEADERS([CoreMedia/CoreMedia.h VideoToolbox/VideoToolbox.h], [],
1839     [AC_MSG_ERROR([MacOS X 10.9 SDK or later is required])])
1841 fi # COMPILE_ENVIRONMENT
1843 dnl ========================================================
1844 dnl = Handle dependent MEDIA defines
1845 dnl ========================================================
1847 MOZ_WEBM_ENCODER=1
1848 AC_DEFINE(MOZ_WEBM_ENCODER)
1849 AC_SUBST(MOZ_WEBM_ENCODER)
1851 dnl ========================================================
1852 dnl NegotiateAuth
1853 dnl ========================================================
1855 MOZ_ARG_DISABLE_BOOL(negotiateauth,
1856 [  --disable-negotiateauth Disable GSS-API negotiation ],
1857     MOZ_AUTH_EXTENSION=,
1858     MOZ_AUTH_EXTENSION=1 )
1860 dnl ========================================================
1861 dnl Pref extensions (autoconfig)
1862 dnl ========================================================
1863 MOZ_ARG_DISABLE_BOOL(pref-extensions,
1864 [  --disable-pref-extensions
1865                           Disable pref extensions such as autoconfig],
1866   MOZ_PREF_EXTENSIONS=,
1867   MOZ_PREF_EXTENSIONS=1 )
1869 dnl ========================================================
1870 dnl Searching of system directories for extensions.
1871 dnl Note: this switch is meant to be used for test builds
1872 dnl whose behavior should not depend on what happens to be
1873 dnl installed on the local machine.
1874 dnl ========================================================
1875 MOZ_ARG_DISABLE_BOOL(system-extension-dirs,
1876 [  --disable-system-extension-dirs
1877                           Disable searching system- and account-global
1878                           directories for extensions of any kind; use
1879                           only profile-specific extension directories],
1880   ENABLE_SYSTEM_EXTENSION_DIRS=,
1881   ENABLE_SYSTEM_EXTENSION_DIRS=1 )
1882 if test "$ENABLE_SYSTEM_EXTENSION_DIRS"; then
1883   AC_DEFINE(ENABLE_SYSTEM_EXTENSION_DIRS)
1886 dnl ========================================================
1887 dnl = Universalchardet
1888 dnl ========================================================
1889 MOZ_ARG_DISABLE_BOOL(universalchardet,
1890 [  --disable-universalchardet
1891                           Disable universal encoding detection],
1892   MOZ_UNIVERSALCHARDET=,
1893   MOZ_UNIVERSALCHARDET=1 )
1895 dnl ========================================================
1896 dnl Gamepad support
1897 dnl ========================================================
1899 if test "$COMPILE_ENVIRONMENT" ; then
1901 dnl Moved gamepad platform check to moz.build, linux header check still needed here.
1902 if test "$OS_TARGET" = "Linux"; then
1903     MOZ_CHECK_HEADER([linux/joystick.h])
1904     if test "$ac_cv_header_linux_joystick_h" != "yes"; then
1905       AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers.])
1906     fi
1909 fi # COMPILE_ENVIRONMENT
1912 dnl ========================================================
1913 dnl = Breakpad crash reporting (on by default on supported platforms)
1914 dnl ========================================================
1916 case $target in
1917 i?86-*-mingw*|x86_64-*-mingw*|aarch64-*-mingw*)
1918   MOZ_CRASHREPORTER=1
1919   ;;
1920 i?86-apple-darwin*|x86_64-apple-darwin*)
1921   MOZ_CRASHREPORTER=1
1922   ;;
1923 *-android*|*-linuxandroid*)
1924   dnl Android/arm is arm-unknown-linux-androideabi, so android condition should
1925   dnl be before Linux condition
1926   MOZ_CRASHREPORTER=1
1927   ;;
1928 i?86-*-linux*|x86_64-*-linux*|arm-*-linux*)
1929   if test "$MOZ_ENABLE_GTK"; then
1930     MOZ_CRASHREPORTER=1
1931   fi
1932   ;;
1933 esac
1935 MOZ_ARG_DISABLE_BOOL(crashreporter,
1936 [  --disable-crashreporter Disable breakpad crash reporting],
1937     [MOZ_CRASHREPORTER=],
1938     [MOZ_CRASHREPORTER=F # Force enable breakpad])
1940 if test "$OS_ARCH" != "$HOST_OS_ARCH" -a "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "Darwin" -a "$MOZ_WIDGET_TOOLKIT" != "android"; then
1941   if test "$MOZ_CRASHREPORTER" = F; then
1942     AC_MSG_ERROR([Cannot --enable-crashreporter, as breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH.])
1943   fi
1944   MOZ_CRASHREPORTER=
1947 if test -n "$MOZ_CRASHREPORTER"; then
1948    AC_DEFINE(MOZ_CRASHREPORTER)
1950   if test "$OS_TARGET" = "Linux" && \
1951     test -z "$SKIP_LIBRARY_CHECKS"; then
1952     PKG_CHECK_MODULES(MOZ_GTHREAD, gthread-2.0)
1953   fi
1955   if test "$OS_ARCH" = "WINNT"; then
1956     if test -z "$HAVE_64BIT_BUILD" -a -n "$COMPILE_ENVIRONMENT"; then
1957       MOZ_CRASHREPORTER_INJECTOR=1
1958       AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
1959     fi
1960   fi
1963 dnl ========================================================
1964 dnl = Enable compilation of specific extension modules
1965 dnl ========================================================
1967 MOZ_ARG_ENABLE_STRING(extensions,
1968 [  --enable-extensions     Enable extensions],
1969 [ for option in `echo $enableval | sed 's/,/ /g'`; do
1970     if test "$option" = "yes" -o "$option" = "all"; then
1971         AC_MSG_ERROR([--enable-extensions=$option is no longer supported.])
1972     elif test "$option" = "no" -o "$option" = "none"; then
1973         MOZ_EXTENSIONS=""
1974     elif test "$option" = "default"; then
1975         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $MOZ_EXTENSIONS_DEFAULT"
1976     elif test `echo "$option" | grep -c \^-` != 0; then
1977         option=`echo $option | sed 's/^-//'`
1978         MOZ_EXTENSIONS=`echo "$MOZ_EXTENSIONS" | sed "s/ ${option}//"`
1979     else
1980         MOZ_EXTENSIONS="$MOZ_EXTENSIONS $option"
1981     fi
1982 done],
1983     MOZ_EXTENSIONS="$MOZ_EXTENSIONS_DEFAULT")
1985 dnl Ensure every extension exists, to avoid mostly-inscrutable error messages
1986 dnl when trying to build a nonexistent extension.
1987 for extension in $MOZ_EXTENSIONS; do
1988     if test ! -d "${srcdir}/extensions/${extension}"; then
1989         AC_MSG_ERROR([Unrecognized extension provided to --enable-extensions: ${extension}.])
1990     fi
1991 done
1993 if test -n "$MOZ_USE_NATIVE_POPUP_WINDOWS"; then
1994   AC_DEFINE(MOZ_USE_NATIVE_POPUP_WINDOWS)
1997 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
1998 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
1999 if test -n "$MOZ_TREE_FREETYPE" -a "$OS_TARGET" != WINNT; then
2000    MOZ_ENABLE_CAIRO_FT=1
2001    FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
2002    CAIRO_FT_CFLAGS="-I$_topsrcdir/modules/freetype2/include"
2003    AC_SUBST_LIST(CAIRO_FT_CFLAGS)
2006 AC_CHECK_PROGS(WGET, wget, "")
2007 AC_SUBST(WGET)
2009 dnl ========================================================
2010 dnl Updater
2011 dnl ========================================================
2013 MOZ_ARG_DISABLE_BOOL(updater,
2014 [  --disable-updater       Disable building of updater],
2015     MOZ_UPDATER=,
2016     MOZ_UPDATER=1 )
2018 if test -n "$MOZ_UPDATER"; then
2019     AC_DEFINE(MOZ_UPDATER)
2022 dnl ========================================================
2023 dnl parental controls (for Windows Vista)
2024 dnl ========================================================
2025 MOZ_ARG_DISABLE_BOOL(parental-controls,
2026 [  --disable-parental-controls
2027                           Do not build parental controls],
2028    MOZ_DISABLE_PARENTAL_CONTROLS=1,
2029    MOZ_DISABLE_PARENTAL_CONTROLS=)
2030 if test -n "$MOZ_DISABLE_PARENTAL_CONTROLS"; then
2031     AC_DEFINE(MOZ_DISABLE_PARENTAL_CONTROLS)
2034 AC_SUBST(MOZ_DISABLE_PARENTAL_CONTROLS)
2036 dnl ========================================================
2037 dnl = Disable smartcard support
2038 dnl ========================================================
2039 if test -n "$MOZ_NO_SMART_CARDS"; then
2040     AC_DEFINE(MOZ_NO_SMART_CARDS)
2042 AC_SUBST(MOZ_NO_SMART_CARDS)
2044 dnl ========================================================
2045 dnl = Sandboxing support
2046 dnl ========================================================
2047 if test -n "$MOZ_TSAN" -o -n "$MOZ_ASAN"; then
2048     # Bug 1182565: TSan conflicts with sandboxing on Linux.
2049     # Bug 1287971: LSan also conflicts with sandboxing on Linux.
2050     case $OS_TARGET in
2051     Linux|Android)
2052         MOZ_SANDBOX=
2053         ;;
2054     esac
2057 MOZ_ARG_DISABLE_BOOL(sandbox,
2058 [  --disable-sandbox        Disable sandboxing support],
2059     MOZ_SANDBOX=,
2060     MOZ_SANDBOX=1)
2062 case "$OS_TARGET" in
2063 WINNT|Darwin|OpenBSD)
2065 Linux)
2066     case $CPU_ARCH in
2067         x86_64|x86)
2068         ;;
2069         # Linux sandbox is only available on x86 and x86_64.
2070         *)
2071             MOZ_SANDBOX=
2072         ;;
2073     esac
2074     ;;
2076     # Only enable the sandbox by default on Linux, OpenBSD, macOS, and Windows
2077     MOZ_SANDBOX=
2079 esac
2081 if test -n "$MOZ_SANDBOX"; then
2082     AC_DEFINE(MOZ_SANDBOX)
2085 AC_SUBST(MOZ_SANDBOX)
2088 dnl ========================================================
2089 dnl =
2090 dnl = Module specific options
2091 dnl =
2092 dnl ========================================================
2093 MOZ_ARG_HEADER(Individual module options)
2095 dnl ==============================
2096 dnl === SQLite fdatasync check ===
2097 dnl ==============================
2098 dnl Check to see if fdatasync is available and make use of it
2099 AC_CHECK_FUNC(fdatasync)
2101 dnl ========================================================
2102 dnl = Disable zipwriter
2103 dnl ========================================================
2104 MOZ_ARG_DISABLE_BOOL(zipwriter,
2105 [  --disable-zipwriter     Disable zipwriter component],
2106     MOZ_ZIPWRITER=,
2107     MOZ_ZIPWRITER=1 )
2108 AC_SUBST(MOZ_ZIPWRITER)
2110 dnl ========================================================
2111 dnl =
2112 dnl = Feature options that require extra sources to be pulled
2113 dnl =
2114 dnl ========================================================
2115 dnl MOZ_ARG_HEADER(Features that require extra sources)
2117 dnl ========================================================
2118 dnl =
2119 dnl = Runtime debugging and Optimization Options
2120 dnl =
2121 dnl ========================================================
2122 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
2124 dnl ========================================================
2125 dnl enable mobile optimizations
2126 dnl ========================================================
2127 MOZ_ARG_ENABLE_BOOL(mobile-optimize,
2128 [  --enable-mobile-optimize
2129                           Enable mobile optimizations],
2130     MOZ_GFX_OPTIMIZE_MOBILE=1)
2132 AC_SUBST(MOZ_GFX_OPTIMIZE_MOBILE)
2134 if test "$MOZ_GFX_OPTIMIZE_MOBILE"; then
2135     # We ignore paint will resample on mobile for performance.
2136     # We may want to revisit this later.
2137     MOZ_IGNORE_PAINT_WILL_RESAMPLE=1
2139     AC_DEFINE(MOZ_GFX_OPTIMIZE_MOBILE)
2140     AC_DEFINE(MOZ_IGNORE_PAINT_WILL_RESAMPLE)
2143 dnl ========================================================
2144 dnl = Enable code optimization. ON by default.
2145 dnl ========================================================
2147 # Use value from moz.configure if one is defined. Else use our computed
2148 # value.
2149 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
2150     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
2153 if test "$COMPILE_ENVIRONMENT"; then
2154 if test -n "$MOZ_OPTIMIZE"; then
2155     AC_MSG_CHECKING([for valid C compiler optimization flags])
2156     _SAVE_CFLAGS=$CFLAGS
2157     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
2158     AC_TRY_COMPILE([#include <stdio.h>],
2159         [printf("Hello World\n");],
2160         _results=yes,
2161         _results=no)
2162     AC_MSG_RESULT([$_results])
2163     if test "$_results" = "no"; then
2164         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
2165     fi
2166     CFLAGS=$_SAVE_CFLAGS
2167     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
2168         # When using llvm-based LTO, non numeric optimization levels are
2169         # not supported by the linker, so force the linker to use -O2 (
2170         # which doesn't influence the level compilation units are actually
2171         # compiled at).
2172         case " $MOZ_OPTIMIZE_FLAGS " in
2173         *\ -Os\ *|*\ -Oz\ *)
2174             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
2175             ;;
2176         esac
2177     fi
2179 fi # COMPILE_ENVIRONMENT
2181 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
2182 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
2183 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
2185 dnl ========================================================
2186 dnl = Enable runtime logging
2187 dnl ========================================================
2188 AC_DEFINE(MOZ_LOGGING)
2189 AC_DEFINE(FORCE_PR_LOG)
2191 dnl ========================================================
2192 dnl = This will enable logging of addref, release, ctor, dtor.
2193 dnl ========================================================
2194 _ENABLE_LOGREFCNT=42
2195 MOZ_ARG_ENABLE_BOOL(logrefcnt,
2196 [  --enable-logrefcnt      Enable logging of refcounts (default=debug) ],
2197     _ENABLE_LOGREFCNT=1,
2198     _ENABLE_LOGREFCNT= )
2199 if test "$_ENABLE_LOGREFCNT" = "1"; then
2200     AC_DEFINE(FORCE_BUILD_REFCNT_LOGGING)
2201 elif test -z "$_ENABLE_LOGREFCNT"; then
2202     AC_DEFINE(NO_BUILD_REFCNT_LOGGING)
2205 dnl ========================================================
2206 dnl moz_dump_painting
2207 dnl ========================================================
2208 MOZ_ARG_ENABLE_BOOL(dump-painting,
2209 [  --enable-dump-painting          Enable paint debugging.],
2210     MOZ_DUMP_PAINTING=1,
2211     MOZ_DUMP_PAINTING= )
2212 if test -n "$MOZ_DUMP_PAINTING"; then
2213     AC_DEFINE(MOZ_DUMP_PAINTING)
2214     AC_DEFINE(MOZ_LAYERS_HAVE_LOG)
2216 if test -n "$MOZ_DEBUG"; then
2217     AC_DEFINE(MOZ_DUMP_PAINTING)
2220 case "${OS_TARGET}" in
2221 Android|WINNT|Darwin)
2222   MOZ_GLUE_IN_PROGRAM=
2223   ;;
2225   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
2226   MOZ_GLUE_IN_PROGRAM=1
2227   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
2228   ;;
2229 esac
2231 dnl ========================================================
2232 dnl = Jemalloc build setup
2233 dnl ========================================================
2234 if test -z "$MOZ_MEMORY"; then
2235   case "${target}" in
2236     *-mingw*)
2237       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
2238         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.])
2239       fi
2240       ;;
2241   esac
2242 else
2243   dnl The generic feature tests that determine how to compute ncpus are long and
2244   dnl complicated.  Therefore, simply define special cpp variables for the
2245   dnl platforms we have special knowledge of.
2246   case "${target}" in
2247   *-mingw*)
2248     export MOZ_NO_DEBUG_RTL=1
2249     ;;
2250   esac
2251 fi # MOZ_MEMORY
2252 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
2254 dnl ========================================================
2255 dnl = Enable using the clang plugin to build
2256 dnl ========================================================
2258 if test -n "$COMPILE_ENVIRONMENT"; then
2259 MOZ_CONFIG_CLANG_PLUGIN
2260 fi # COMPILE_ENVIRONMENT
2262 dnl ========================================================
2263 dnl = frontend JS debug mode
2264 dnl ========================================================
2266 MOZ_ARG_ENABLE_BOOL(debug-js-modules,
2267 [  --enable-debug-js-modules  Enable debug mode for frontend JS libraries],
2268    DEBUG_JS_MODULES=1,
2269    DEBUG_JS_MODULES=)
2271 AC_SUBST(DEBUG_JS_MODULES)
2273 dnl ========================================================
2274 dnl =
2275 dnl = Profiling and Instrumenting
2276 dnl =
2277 dnl ========================================================
2278 MOZ_ARG_HEADER(Profiling and Instrumenting)
2280 dnl ========================================================
2281 dnl = Offer a way to disable the startup cache
2282 dnl ========================================================
2284 MOZ_ARG_DISABLE_BOOL(startupcache,
2285 [  --disable-startupcache          Disable startup cache ],
2286     MOZ_DISABLE_STARTUPCACHE=1,
2287     MOZ_DISABLE_STARTUPCACHE=)
2289 if test -n "$MOZ_DISABLE_STARTUPCACHE"; then
2290   AC_DEFINE(MOZ_DISABLE_STARTUPCACHE)
2292 AC_SUBST(MOZ_DISABLE_STARTUPCACHE)
2294 dnl ========================================================
2295 dnl = Support for demangling undefined symbols
2296 dnl ========================================================
2297 if test -z "$SKIP_LIBRARY_CHECKS"; then
2298     AC_LANG_SAVE
2299     AC_LANG_CPLUSPLUS
2300     AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
2301     AC_LANG_RESTORE
2304 # Demangle only for debug or DMD builds
2305 MOZ_DEMANGLE_SYMBOLS=
2306 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
2307     MOZ_DEMANGLE_SYMBOLS=1
2308     AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
2310 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
2312 dnl ========================================================
2313 dnl = Support for gcc stack unwinding (from gcc 3.3)
2314 dnl ========================================================
2315 if test -z "$SKIP_LIBRARY_CHECKS"; then
2316     AC_LANG_SAVE
2317     AC_LANG_CPLUSPLUS
2318     MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
2319     AC_LANG_RESTORE
2322 dnl ========================================================
2323 dnl JIT observers
2324 dnl ========================================================
2326 MOZ_ARG_WITH_STRING(jitreport-granularity,
2327 [  --jitreport-granularity=N
2328                            Default granularity at which to report JIT code
2329                            to external tools
2330                              0 - no info
2331                              1 - code ranges for whole functions only
2332                              2 - per-line information
2333                              3 - per-op information],
2334   JITREPORT_GRANULARITY=$withval,
2335   JITREPORT_GRANULARITY=3)
2337 AC_DEFINE_UNQUOTED(JS_DEFAULT_JITREPORT_GRANULARITY, $JITREPORT_GRANULARITY)
2339 dnl ========================================================
2340 dnl =
2341 dnl = Misc. Options
2342 dnl =
2343 dnl ========================================================
2344 MOZ_ARG_HEADER(Misc. Options)
2346 dnl ========================================================
2347 dnl = Location of the mozilla user directory (default is ~/.mozilla).],
2348 dnl ========================================================
2349 MOZ_ARG_WITH_STRING(user-appdir,
2350 [  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)],
2351 [ val=`echo $withval`
2352 if echo "$val" | grep "\/" >/dev/null; then
2353     AC_MSG_ERROR("Homedir must be single relative path.")
2354 else
2355     MOZ_USER_DIR="$val"
2356 fi])
2358 AC_DEFINE_UNQUOTED(MOZ_USER_DIR,"$MOZ_USER_DIR")
2360 if test -z "$SKIP_COMPILER_CHECKS"; then
2361 dnl ========================================================
2362 dnl =
2363 dnl = Compiler Options
2364 dnl =
2365 dnl ========================================================
2366 MOZ_ARG_HEADER(Compiler Options)
2368 dnl ========================================================
2369 dnl Check for gcc -pipe support
2370 dnl ========================================================
2371 AC_MSG_CHECKING([for -pipe support])
2372 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
2373     dnl Any gcc that supports firefox supports -pipe.
2374     CFLAGS="$CFLAGS -pipe"
2375     CXXFLAGS="$CXXFLAGS -pipe"
2376     AC_MSG_RESULT([yes])
2377 else
2378     AC_MSG_RESULT([no])
2381 fi # ! SKIP_COMPILER_CHECKS
2383 AC_LANG_C
2385 if test "$COMPILE_ENVIRONMENT"; then
2386 MOZ_EXPAND_LIBS
2387 fi # COMPILE_ENVIRONMENT
2389 dnl ========================================================
2390 dnl =
2391 dnl = Static Build Options
2392 dnl =
2393 dnl ========================================================
2394 MOZ_ARG_HEADER(Static build options)
2396 if test -z "$MOZ_SYSTEM_ZLIB"; then
2397 if test -n "$JS_SHARED_LIBRARY" -o -n "$MOZ_LINKER" -o "$MOZ_WIDGET_TOOLKIT" = android; then
2398   ZLIB_IN_MOZGLUE=1
2399   AC_DEFINE(ZLIB_IN_MOZGLUE)
2403 AC_SUBST(ZLIB_IN_MOZGLUE)
2405 dnl ========================================================
2406 dnl =
2407 dnl = Standalone module options
2408 dnl =
2409 dnl ========================================================
2410 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
2412 dnl Check for GLib.
2413 dnl ========================================================
2415 if test -z "$SKIP_PATH_CHECKS"; then
2416 if test -z "${GLIB_CFLAGS}" -o -z "${GLIB_LIBS}" ; then
2417     if test "$MOZ_ENABLE_GTK" ; then
2418         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
2419     fi
2423 if test -z "${GLIB_GMODULE_LIBS}" \
2424    -a -n "${GLIB_CONFIG}"\
2425     -a "${GLIB_CONFIG}" != no\
2426 ; then
2427     GLIB_GMODULE_LIBS=`$GLIB_CONFIG gmodule --libs`
2430 AC_SUBST_LIST(GLIB_GMODULE_LIBS)
2432 if test "$USE_FC_FREETYPE"; then
2433     if test "$COMPILE_ENVIRONMENT"; then
2434         dnl ========================================================
2435         dnl = Check for freetype2 functionality
2436         dnl ========================================================
2437         if test "$_HAVE_FREETYPE2" -a -z "$MOZ_TREE_FREETYPE"; then
2438             _SAVE_LIBS="$LIBS"
2439             _SAVE_CFLAGS="$CFLAGS"
2440             LIBS="$LIBS $FT2_LIBS"
2441             CFLAGS="$CFLAGS $FT2_CFLAGS"
2443             AC_CACHE_CHECK(for FT_Bitmap_Size.y_ppem,
2444                 ac_cv_member_FT_Bitmap_Size_y_ppem,
2445                 [AC_TRY_COMPILE([#include <ft2build.h>
2446                                  #include FT_FREETYPE_H],
2447                                 [FT_Bitmap_Size s;
2448                                  if (sizeof s.y_ppem) return 0;
2449                                  return 1],
2450                                 ac_cv_member_FT_Bitmap_Size_y_ppem=yes,
2451                                 ac_cv_member_FT_Bitmap_Size_y_ppem=no)])
2452             if test "$ac_cv_member_FT_Bitmap_Size_y_ppem" = yes; then
2453                 HAVE_FT_BITMAP_SIZE_Y_PPEM=1
2454             else
2455                 HAVE_FT_BITMAP_SIZE_Y_PPEM=0
2456             fi
2457             AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,
2458                                $HAVE_FT_BITMAP_SIZE_Y_PPEM,
2459                                [FT_Bitmap_Size structure includes y_ppem field])
2461             AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Load_Sfnt_Table)
2463             LIBS="$_SAVE_LIBS"
2464             CFLAGS="$_SAVE_CFLAGS"
2465         fi
2467         _SAVE_CPPFLAGS="$CPPFLAGS"
2468         CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
2469         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
2470             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
2471         CPPFLAGS="$_SAVE_CPPFLAGS"
2472     fi
2475 dnl ========================================================
2476 dnl Check if we need the 32-bit Linux SSE2 error dialog
2477 dnl ========================================================
2479 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
2481 dnl ========================================================
2482 dnl Check for pixman and cairo
2483 dnl ========================================================
2485 MOZ_TREE_CAIRO=1
2486 MOZ_ARG_ENABLE_BOOL(system-cairo,
2487 [ --enable-system-cairo  Obsolete: do not use this option],
2488 AC_MSG_ERROR(--enable-system-cairo is not supported),
2489 MOZ_TREE_CAIRO=1 )
2491 MOZ_TREE_PIXMAN=1
2492 MOZ_ARG_ENABLE_BOOL(system-pixman,
2493 [ --enable-system-pixman Use system pixman (located with pkgconfig)],
2494 MOZ_TREE_PIXMAN=,
2495 MOZ_TREE_PIXMAN=force,
2496 MOZ_TREE_PIXMAN=1 )
2498 if test "$MOZ_TREE_PIXMAN"; then
2499     AC_DEFINE(MOZ_TREE_PIXMAN)
2500 else
2501     PKG_CHECK_MODULES(MOZ_PIXMAN, pixman-1 >= 0.19.2)
2504 MOZ_CAIRO_CFLAGS="-I${DIST}/include/cairo"
2505 AC_DEFINE(MOZ_TREE_CAIRO)
2507 if test "$OS_ARCH" = "WINNT"; then
2508     # For now we assume that we will have a uint64_t available through
2509     # one of the above headers or mozstdint.h.
2510     AC_DEFINE(HAVE_UINT64_T)
2513 # Define macros for cairo-features.h
2514 TEE_SURFACE_FEATURE="#define CAIRO_HAS_TEE_SURFACE 1"
2515 if test "$MOZ_X11"; then
2516     XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
2517     XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
2518     PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
2520 if test "$_HAVE_FREETYPE2"; then
2521     FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
2522     MOZ_ENABLE_CAIRO_FT=1
2523     CAIRO_FT_CFLAGS="$FT2_CFLAGS"
2526 case "$MOZ_WIDGET_TOOLKIT" in
2527   cocoa | uikit)
2528     QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
2529     QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
2530     QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
2531     ;;
2532   windows)
2533     WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
2534     WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
2535     WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
2537     if test "$COMPILE_ENVIRONMENT"; then
2538       MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
2539     fi
2540     ;;
2541 esac
2542 if test "$USE_FC_FREETYPE"; then
2543     FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
2545 AC_SUBST(MOZ_ENABLE_CAIRO_FT)
2546 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
2548 AC_SUBST(PS_SURFACE_FEATURE)
2549 AC_SUBST(SVG_SURFACE_FEATURE)
2550 AC_SUBST(XLIB_SURFACE_FEATURE)
2551 AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
2552 AC_SUBST(QUARTZ_SURFACE_FEATURE)
2553 AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)
2554 AC_SUBST(WIN32_SURFACE_FEATURE)
2555 AC_SUBST(OS2_SURFACE_FEATURE)
2556 AC_SUBST(DIRECTFB_SURFACE_FEATURE)
2557 AC_SUBST(FT_FONT_FEATURE)
2558 AC_SUBST(FC_FONT_FEATURE)
2559 AC_SUBST(WIN32_FONT_FEATURE)
2560 AC_SUBST(WIN32_DWRITE_FONT_FEATURE)
2561 AC_SUBST(QUARTZ_FONT_FEATURE)
2562 AC_SUBST(PNG_FUNCTIONS_FEATURE)
2563 AC_SUBST(QT_SURFACE_FEATURE)
2564 AC_SUBST(TEE_SURFACE_FEATURE)
2566 if test "$MOZ_X11"; then
2567     MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender"
2570 CAIRO_FEATURES_H=gfx/cairo/cairo/src/cairo-features.h
2572 case "$MOZ_WIDGET_TOOLKIT" in
2573 android)
2574     TK_CFLAGS="$MOZ_CAIRO_CFLAGS $MOZ_PIXMAN_CFLAGS"
2575     TK_LIBS="$MOZ_CAIRO_LIBS $MOZ_PIXMAN_LIBS"
2576     ;;
2577 esac
2579 AC_SUBST(MOZ_TREE_CAIRO)
2580 AC_SUBST_LIST(MOZ_CAIRO_CFLAGS)
2581 AC_SUBST_LIST(MOZ_CAIRO_LIBS)
2582 AC_SUBST_LIST(MOZ_CAIRO_OSLIBS)
2583 AC_SUBST(MOZ_TREE_PIXMAN)
2585 BINDGEN_SYSTEM_FLAGS="$_BINDGEN_CFLAGS $NSPR_CFLAGS $NSS_CFLAGS $MOZ_PIXMAN_CFLAGS $MOZ_CAIRO_CFLAGS"
2586 AC_SUBST(BINDGEN_SYSTEM_FLAGS)
2587 BINDGEN_SYSTEM_TOML_FLAGS="$BINDGEN_SYSTEM_FLAGS"
2588 AC_SUBST_TOML_LIST(BINDGEN_SYSTEM_TOML_FLAGS)
2590 dnl ========================================================
2591 dnl disable xul
2592 dnl ========================================================
2593 MOZ_ARG_DISABLE_BOOL(xul,
2594 [  --disable-xul           Disable XUL],
2595     MOZ_XUL= )
2596 if test "$MOZ_XUL"; then
2597   AC_DEFINE(MOZ_XUL)
2598 else
2599   dnl remove extensions that require XUL
2600   MOZ_EXTENSIONS=`echo $MOZ_EXTENSIONS | sed -e 's/inspector//' -e 's/irc//' -e 's/tasks//'`
2603 AC_SUBST(MOZ_XUL)
2605 dnl ========================================================
2606 dnl necko configuration options
2607 dnl ========================================================
2610 dnl option to disable necko's wifi scanner
2613 if test "$MOZ_WIDGET_TOOLKIT"; then
2615   case "$OS_TARGET" in
2616     Darwin)
2617       NECKO_WIFI=1
2618       ;;
2619     DragonFly|FreeBSD|WINNT)
2620       NECKO_WIFI=1
2621       ;;
2622     Linux)
2623       NECKO_WIFI=1
2624       NECKO_WIFI_DBUS=1
2625       ;;
2626   esac
2630 MOZ_ARG_DISABLE_BOOL(necko-wifi,
2631 [  --disable-necko-wifi    Disable necko wifi scanner],
2632     NECKO_WIFI=,
2633     NECKO_WIFI=1)
2635 if test "$NECKO_WIFI"; then
2636   if test -z "$MOZ_ENABLE_DBUS" -a -n "$NECKO_WIFI_DBUS"; then
2637     AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove --disable-dbus or use --disable-necko-wifi])
2638   fi
2639   AC_DEFINE(NECKO_WIFI)
2640   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
2642 AC_SUBST(NECKO_WIFI)
2643 AC_SUBST(NECKO_WIFI_DBUS)
2645 dnl ========================================================
2646 dnl =
2647 dnl = Maintainer debug option (no --enable equivalent)
2648 dnl =
2649 dnl ========================================================
2651 AC_SUBST(NM)
2652 AC_SUBST_LIST(ASFLAGS)
2653 AC_SUBST(RCFLAGS)
2654 AC_SUBST(IMPLIB)
2655 AC_SUBST(FILTER)
2656 AC_SUBST(MOZ_AUTH_EXTENSION)
2657 AC_SUBST(MOZ_PREF_EXTENSIONS)
2658 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
2659 AC_SUBST_LIST(WARNINGS_CFLAGS)
2660 AC_SUBST_SET(MOZ_EXTENSIONS)
2662 AC_SUBST(MOZ_UNIVERSALCHARDET)
2663 AC_SUBST(MOZ_SPELLCHECK)
2664 AC_SUBST(MOZ_ANDROID_ANR_REPORTER)
2665 AC_SUBST(MOZ_CRASHREPORTER)
2666 AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
2667 AC_SUBST(MOZ_STUB_INSTALLER)
2668 AC_SUBST(MOZ_UPDATER)
2670 AC_SUBST(MOZ_ANDROID_APPLICATION_CLASS)
2671 AC_SUBST(MOZ_ANDROID_BROWSER_INTENT_CLASS)
2672 AC_SUBST(MOZ_EXCLUDE_HYPHENATION_DICTIONARIES)
2673 AC_SUBST(STRIP_FLAGS)
2674 AC_SUBST(INCREMENTAL_LINKER)
2676 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
2678 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
2679 AC_SUBST(MOZ_LINKER_EXTRACT)
2681 if test -n "$MOZ_BINARY_EXTENSIONS"; then
2682   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
2685 AC_SUBST(MOZ_REQUIRE_SIGNING)
2686 if test "$MOZ_REQUIRE_SIGNING" = 1; then
2687   AC_DEFINE(MOZ_REQUIRE_SIGNING)
2690 dnl ========================================================
2691 dnl = Mac bundle name prefix
2692 dnl ========================================================
2693 MOZ_ARG_WITH_STRING(macbundlename-prefix,
2694 [  --with-macbundlename-prefix=prefix
2695                           Prefix for MOZ_MACBUNDLE_NAME],
2696 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
2698 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
2699 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
2700   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
2703 if test "$MOZ_DEBUG"; then
2704   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
2705 else
2706   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
2708 AC_SUBST(MOZ_MACBUNDLE_NAME)
2710 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
2711 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
2712 # Otherwise, use MOZ_APP_DISPLAYNAME
2713 if test -z "$MOZ_MACBUNDLE_ID"; then
2714    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
2716 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
2717 if test "$MOZ_DEBUG"; then
2718   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
2721 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
2722 AC_SUBST(MOZ_MACBUNDLE_ID)
2724 dnl ========================================================
2725 dnl = Child Process Name for IPC
2726 dnl ========================================================
2727 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
2728   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
2729 else
2730   # We want to let Android unpack the file at install time, but it only does
2731   # so if the file is named libsomething.so. The lib/ path is also required
2732   # because the unpacked file will be under the lib/ subdirectory and will
2733   # need to be executed from that path.
2734   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
2736 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
2737 MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
2739 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
2740 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
2741 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
2743 # The following variables are available to branding and application
2744 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
2745 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
2746 # impacts profile location and user-visible fields.
2747 # - MOZ_APP_BASENAME: Typically stays consistent for multiple branded
2748 # versions of a given application (e.g. Aurora and Firefox both use
2749 # "Firefox"), but may vary for full rebrandings (e.g. Iceweasel). Used
2750 # for application.ini's "Name" field, which controls profile location in
2751 # the absence of a "Profile" field (see below), and various system
2752 # integration hooks (Unix remoting, Windows MessageWindow name, etc.)
2753 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
2754 # Mac Bundle name, Updater, Installer), it is typically used for nightly
2755 # builds (e.g. Aurora for Firefox).
2756 # - MOZ_APP_NAME: Used for e.g. the binary program file name. If not set,
2757 # defaults to a lowercase form of MOZ_APP_BASENAME.
2758 # - MOZ_APP_REMOTINGNAME: Used for the internal program name, which affects
2759 # profile name and remoting. If not set, defaults to MOZ_APP_NAME.
2760 # - MOZ_APP_PROFILE: When set, used for application.ini's
2761 # "Profile" field, which controls profile location.
2762 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
2763 # crash reporter server url.
2764 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
2766 # The following environment variables used to have an effect, but don't anymore:
2767 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
2768 # the contents from the version.txt file in the application directory, or
2769 # browser/config/version.txt if there isn't one.
2770 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
2771 # in the "About" window. This was replaced with the contents from the
2772 # version_display.txt or version.txt in the application directory, or
2773 # browser/config/version_display.txt.
2775 if test -z "$MOZ_APP_NAME"; then
2776    MOZ_APP_NAME=`echo $MOZ_APP_BASENAME | tr A-Z a-z`
2779 if test -z "$MOZ_APP_REMOTINGNAME"; then
2780    MOZ_APP_REMOTINGNAME=$MOZ_APP_NAME
2783 if test -z "$ANDROID_PACKAGE_NAME" ; then
2784    # When we got rid of the Aurora channel we decided to replace the old
2785    # Nightly ANDROID_PACKAGE_NAME with Aurora. To make sure this is inherited
2786    # by all mozilla-central based branches we make this the new "default"
2787    # for Fennec. Non mozilla-central based branches set ANDROID_PACKAGE_NAME
2788    # in their mozconfig, so they will never get this. If there are ever
2789    # non-Fennec builds for Android, they will fall into the else block
2790    # and use their own default name.
2791    # https://bugzilla.mozilla.org/show_bug.cgi?id=1357808 has additional
2792    # background on this.
2793    if test "$MOZ_APP_NAME" = "fennec"; then
2794       ANDROID_PACKAGE_NAME="org.mozilla.fennec_aurora"
2795    else
2796       ANDROID_PACKAGE_NAME="org.mozilla.$MOZ_APP_NAME"
2797    fi
2800 # For extensions and langpacks, we require a max version that is compatible
2801 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
2802 # 24.0a1 and 24.0a2 aren't affected
2803 # 24.0 becomes 24.*
2804 # 24.1.1 becomes 24.*
2805 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
2806 if test -z "$IS_ALPHA"; then
2807   changequote(,)
2808   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
2809     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
2810   else
2811     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
2812   fi
2813   changequote([,])
2814 else
2815   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
2818 AC_SUBST(MOZ_APP_NAME)
2819 AC_SUBST(MOZ_APP_REMOTINGNAME)
2820 AC_SUBST(MOZ_APP_DISPLAYNAME)
2821 AC_SUBST(MOZ_APP_BASENAME)
2822 AC_SUBST(MOZ_APP_VENDOR)
2823 AC_SUBST(MOZ_APP_PROFILE)
2824 AC_SUBST(MOZ_APP_ID)
2825 AC_SUBST(MAR_CHANNEL_ID)
2826 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
2827 AC_SUBST(MOZ_PROFILE_MIGRATOR)
2828 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
2829 AC_SUBST(MOZ_APP_UA_NAME)
2830 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
2831 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
2832 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
2834 AC_SUBST(MOZ_APP_MAXVERSION)
2835 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
2836 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
2837   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
2840 AC_SUBST(MOZ_PKG_SPECIAL)
2841 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
2843 if test "$MOZILLA_OFFICIAL"; then
2844     # Build revisions should always be present in official builds
2845     MOZ_INCLUDE_SOURCE_INFO=1
2848 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
2849 # explicitly set the repository and changeset information in.
2850 AC_SUBST(MOZ_SOURCE_REPO)
2851 AC_SUBST(MOZ_SOURCE_CHANGESET)
2852 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
2854 dnl If we have any service that uploads data (and requires data submission
2855 dnl policy alert), set MOZ_DATA_REPORTING.
2856 dnl We need SUBST for build system and DEFINE for xul preprocessor.
2857 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"  || test -n "$MOZ_NORMANDY"; then
2858   MOZ_DATA_REPORTING=1
2859   AC_DEFINE(MOZ_DATA_REPORTING)
2860   AC_SUBST(MOZ_DATA_REPORTING)
2863 dnl win32 options
2864 AC_SUBST(WIN32_REDIST_DIR)
2865 AC_SUBST(WIN_UCRT_REDIST_DIR)
2867 dnl ========================================================
2868 dnl ICU Support
2869 dnl ========================================================
2871 _INTL_API=yes
2873 if test "$MOZ_WIDGET_TOOLKIT" = "cocoa"; then
2874     USE_ICU=1
2877 MOZ_CONFIG_ICU()
2879 dnl Echo the CFLAGS to remove extra whitespace.
2880 CFLAGS=`echo \
2881     $_COMPILATION_CFLAGS \
2882     $CFLAGS`
2884 CXXFLAGS=`echo \
2885     $_WARNINGS_CXXFLAGS \
2886     $_COMPILATION_CXXFLAGS \
2887     $CXXFLAGS`
2889 COMPILE_CFLAGS=`echo \
2890     $_DEFINES_CFLAGS \
2891     $COMPILE_CFLAGS`
2893 COMPILE_CXXFLAGS=`echo \
2894     $_DEFINES_CXXFLAGS \
2895     $COMPILE_CXXFLAGS`
2897 HOST_CFLAGS=`echo \
2898     $_WARNINGS_HOST_CFLAGS \
2899     $_COMPILATION_HOST_CFLAGS \
2900     $HOST_CFLAGS`
2902 HOST_CXXFLAGS=`echo \
2903     $_WARNINGS_HOST_CXXFLAGS \
2904     $_COMPILATION_HOST_CXXFLAGS \
2905     $HOST_CXXFLAGS`
2907 AC_SUBST(MOZ_SYSTEM_PNG)
2909 AC_SUBST_LIST(MOZ_PNG_CFLAGS)
2910 AC_SUBST_LIST(MOZ_PNG_LIBS)
2912 AC_SUBST(MOZ_SYSTEM_NSPR)
2914 AC_SUBST(MOZ_SYSTEM_NSS)
2916 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
2917 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
2918 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
2919 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
2920 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
2921   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
2922   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
2924 AC_SUBST(HOST_CMFLAGS)
2925 AC_SUBST(HOST_CMMFLAGS)
2926 AC_SUBST(OS_COMPILE_CMFLAGS)
2927 AC_SUBST(OS_COMPILE_CMMFLAGS)
2929 OS_CFLAGS="$CFLAGS"
2930 OS_CXXFLAGS="$CXXFLAGS"
2931 OS_CPPFLAGS="$CPPFLAGS"
2932 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
2933 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
2934 OS_LDFLAGS="$LDFLAGS"
2935 OS_LIBS="$LIBS"
2936 AC_SUBST_LIST(OS_CFLAGS)
2937 AC_SUBST_LIST(OS_CXXFLAGS)
2938 AC_SUBST_LIST(OS_CPPFLAGS)
2939 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
2940 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
2941 AC_SUBST_LIST(OS_LDFLAGS)
2942 AC_SUBST(OS_LIBS)
2944 AC_SUBST(HOST_CC)
2945 AC_SUBST(HOST_CXX)
2946 AC_SUBST_LIST(HOST_CFLAGS)
2947 AC_SUBST_LIST(HOST_CPPFLAGS)
2948 AC_SUBST_LIST(HOST_CXXFLAGS)
2949 AC_SUBST(HOST_LDFLAGS)
2950 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
2951 AC_SUBST(HOST_BIN_SUFFIX)
2953 AC_SUBST(TARGET_XPCOM_ABI)
2954 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSSE3)
2955 AC_SUBST(HAVE_TOOLCHAIN_SUPPORT_MSSE4_1)
2956 AC_SUBST(HAVE_X86_AVX2)
2957 AC_SUBST(HAVE_ALTIVEC)
2959 AC_SUBST_LIST(DSO_CFLAGS)
2960 AC_SUBST_LIST(DSO_PIC_CFLAGS)
2961 AC_SUBST(DSO_LDOPTS)
2962 AC_SUBST(BIN_SUFFIX)
2963 AC_SUBST(USE_N32)
2964 AC_SUBST(NS_ENABLE_TSF)
2965 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
2966 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
2968 AC_SUBST(MOZ_DEVTOOLS)
2970 AC_SUBST(MOZ_PACKAGE_JSSHELL)
2971 AC_SUBST(MOZ_FOLD_LIBS)
2972 AC_SUBST_LIST(MOZ_FOLD_LIBS_FLAGS)
2974 AC_SUBST(DMG_TOOL)
2976 dnl Host JavaScript runtime, if any, to use during cross compiles.
2977 AC_SUBST(JS_BINARY)
2979 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
2981 if test -n "$COMPILE_ENVIRONMENT"; then
2982 AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
2984 dnl Check for missing components
2985 if test "$MOZ_X11"; then
2986     dnl ====================================================
2987     dnl = Check if X headers exist
2988     dnl ====================================================
2989     _SAVE_CFLAGS=$CFLAGS
2990     CFLAGS="$CFLAGS $XCFLAGS"
2991     AC_TRY_COMPILE([
2992         #include <stdio.h>
2993         #include <stdlib.h>
2994         #include <X11/Xlib.h>
2995         #include <X11/Intrinsic.h>
2996         #include <X11/extensions/XShm.h>
2997     ],
2998     [
2999         Display *dpy = 0;
3000         if ((dpy = XOpenDisplay(NULL)) == NULL) {
3001             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
3002             exit(1);
3003         }
3004     ], [],
3005     [ AC_MSG_ERROR([Can't find X headers (install libxt-dev (Debian/Ubuntu), libXt-devel (Fedora), or xorg-x11-libXt-devel (SuSE)).]) ])
3006     CFLAGS="$_SAVE_CFLAGS"
3008     if test -n "$MISSING_X"; then
3009         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
3010     fi
3012 fi # MOZ_X11
3014 fi # COMPILE_ENVIRONMENT
3016 dnl Set various defines and substitutions
3017 dnl ========================================================
3019 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK" ; then
3020     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
3021     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
3022     ATK_MAJOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $1 }'`
3023     ATK_MINOR_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $2 }'`
3024     ATK_REV_VERSION=`echo ${ATK_FULL_VERSION} | $AWK -F\. '{ print $3 }'`
3025     AC_DEFINE_UNQUOTED(ATK_MAJOR_VERSION, $ATK_MAJOR_VERSION)
3026     AC_DEFINE_UNQUOTED(ATK_MINOR_VERSION, $ATK_MINOR_VERSION)
3027     AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION)
3030 AC_SUBST(MOZ_DEV_EDITION)
3031 if test -n "$MOZ_DEV_EDITION"; then
3032     AC_DEFINE(MOZ_DEV_EDITION)
3035 if test "$MOZ_DEBUG" -o "$DEVELOPER_OPTIONS"; then
3036     A11Y_LOG=1
3038 AC_SUBST(A11Y_LOG)
3039 if test -n "$A11Y_LOG"; then
3040     AC_DEFINE(A11Y_LOG)
3043 dnl Spit out some output
3044 dnl ========================================================
3046 dnl The following defines are used by xpcom
3047 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
3048 HAVE_GETPAGESIZE
3049 HAVE_STATVFS64
3050 HAVE_STATVFS
3051 HAVE_STATFS64
3052 HAVE_STATFS
3053 HAVE_SYS_STATVFS_H
3054 HAVE_SYS_STATFS_H
3055 HAVE_SYS_VFS_H
3056 HAVE_SYS_MOUNT_H
3059 # Avoid using obsolete NSPR features
3060 AC_DEFINE(NO_NSPR_10_SUPPORT)
3062 MOZ_CREATE_CONFIG_STATUS()
3064 rm -fr confdefs* $ac_clean_files