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 ========================================================
10 AC_INIT(config/config.mk)
11 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
14 dnl ========================================================
16 dnl = Don't change the following lines. Doing so breaks:
18 dnl = CFLAGS="-foo" ./configure
20 dnl ========================================================
22 CPPFLAGS="${CPPFLAGS=}"
23 CXXFLAGS="${CXXFLAGS=}"
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 ========================================================
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 minimum version of toolkit libs used by mozilla
47 dnl ========================================================
50 dnl Set various checks
51 dnl ========================================================
54 dnl Initialize the Pthread test variables early so they can be
55 dnl overridden by each platform.
56 dnl ========================================================
60 LDFLAGS="$LDFLAGS $LINKER_LDFLAGS"
62 if test "$COMPILE_ENVIRONMENT"; then
64 fi # COMPILE_ENVIRONMENT
67 *-android*|*-linuxandroid*)
70 AC_PATH_PROG(OBJCOPY,objcopy)
76 dnl ========================================================
77 dnl Checks for compilers.
78 dnl ========================================================
80 if test "$COMPILE_ENVIRONMENT"; then
82 # Run some logic to figure out exe extensions (mostly for mingw's sake)
85 if test "$target" != "$host"; then
91 # Work around the conftest.exe access problem on Windows
95 MOZ_PATH_PROGS(AS, $AS as, $CC)
96 AC_CHECK_PROGS(STRIP, strip, :)
97 AC_CHECK_PROGS(OTOOL, otool, :)
102 dnl ========================================================
103 dnl Special win32 checks
104 dnl ========================================================
110 if test "$GCC" != "yes"; then
111 # Check to see if we are really running in a msvc environemnt
114 # Make sure compilers are valid
115 CXXFLAGS="$CXXFLAGS -TP"
118 AC_TRY_COMPILE([#include <stdio.h>],
119 [ printf("Hello World\n"); ],,
120 AC_MSG_ERROR([\$(CC) test failed. You must have MS VC++ in your path to build.]) )
123 AC_TRY_COMPILE([#include <new.h>],
124 [ unsigned *test = new unsigned(42); ],,
125 AC_MSG_ERROR([\$(CXX) test failed. You must have MS VC++ in your path to build.]) )
128 AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
129 AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
130 AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
132 MSVC_C_RUNTIME_DLL=vcruntime140.dll
133 MSVC_CXX_RUNTIME_DLL=msvcp140.dll
135 # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
136 CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
138 if test -n "$WIN_UCRT_REDIST_DIR"; then
139 if test ! -d "$WIN_UCRT_REDIST_DIR"; then
140 AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
142 WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
145 AC_SUBST(MSVC_C_RUNTIME_DLL)
146 AC_SUBST(MSVC_CXX_RUNTIME_DLL)
148 AC_DEFINE(HAVE_SEH_EXCEPTIONS)
150 if test -n "$WIN32_REDIST_DIR"; then
151 if test ! -d "$WIN32_REDIST_DIR"; then
152 AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
154 WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
158 STL_FLAGS="-I${DIST}/stl_wrappers"
160 # Check w32api version
161 _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
162 _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
163 AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
164 AC_TRY_COMPILE([#include <w32api.h>],
165 #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
166 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
167 __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
168 #error "test failed."
170 , [ res=yes ], [ res=no ])
171 AC_MSG_RESULT([$res])
172 if test "$res" != "yes"; then
173 AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
175 # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
176 # causing problems with local implementations with the same name.
177 AC_DEFINE(STRSAFE_NO_DEPRECATE)
180 CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
181 CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
183 AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
184 AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
185 # Require OS features provided by IE 8.0 (Win7)
186 AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
191 if test -n "$_WIN32_MSVC"; then
193 SKIP_COMPILER_CHECKS=1
194 SKIP_LIBRARY_CHECKS=1
196 # Since we're skipping compiler and library checks, hard-code
199 AC_DEFINE(HAVE_ISATTY)
202 fi # COMPILE_ENVIRONMENT
207 AC_SUBST_LIST(STL_FLAGS)
208 AC_SUBST(WRAP_STL_INCLUDES)
210 dnl ========================================================
211 dnl set the defaults first
212 dnl ========================================================
213 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
215 dnl Configure platform-specific CPU architecture compiler options.
216 dnl ==============================================================
217 if test "$COMPILE_ENVIRONMENT"; then
219 fi # COMPILE_ENVIRONMENT
221 dnl ========================================================
222 dnl Android libstdc++
223 dnl ========================================================
226 if test "$COMPILE_ENVIRONMENT"; then
228 fi # COMPILE_ENVIRONMENT
230 dnl ========================================================
231 dnl Suppress Clang Argument Warnings
232 dnl ========================================================
233 WARNINGS_CFLAGS="$_WARNINGS_CFLAGS"
234 if test -n "${CLANG_CC}${CLANG_CL}"; then
235 WARNINGS_CFLAGS="-Qunused-arguments $WARNINGS_CFLAGS"
236 CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
238 if test -n "${CLANG_CXX}${CLANG_CL}"; then
239 _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
242 if test -n "$COMPILE_ENVIRONMENT"; then
246 dnl ========================================================
247 dnl GNU specific defaults
248 dnl ========================================================
249 if test "$GNU_CC"; then
253 SSSE3_FLAGS="-mssse3"
254 CFLAGS="$CFLAGS -fno-strict-aliasing"
256 if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
257 DSO_PIC_CFLAGS='-fPIC'
258 ASFLAGS="$ASFLAGS -fPIC"
261 AC_MSG_CHECKING([for --noexecstack option to as])
263 CFLAGS="$CFLAGS -Wa,--noexecstack"
264 AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
265 [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
268 AC_MSG_CHECKING([for -z noexecstack option to ld])
269 _SAVE_LDFLAGS=$LDFLAGS
270 LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
271 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
273 LDFLAGS=$_SAVE_LDFLAGS)
275 AC_MSG_CHECKING([for -z text option to ld])
276 _SAVE_LDFLAGS=$LDFLAGS
277 LDFLAGS="$LDFLAGS -Wl,-z,text"
278 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
280 LDFLAGS=$_SAVE_LDFLAGS)
282 AC_MSG_CHECKING([for -z relro option to ld])
283 _SAVE_LDFLAGS=$LDFLAGS
284 LDFLAGS="$LDFLAGS -Wl,-z,relro"
285 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
287 LDFLAGS=$_SAVE_LDFLAGS)
289 AC_MSG_CHECKING([for -z nocopyreloc option to ld])
290 _SAVE_LDFLAGS=$LDFLAGS
291 LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
292 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
294 LDFLAGS=$_SAVE_LDFLAGS)
296 AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
297 _SAVE_LDFLAGS=$LDFLAGS
298 LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
299 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
301 LDFLAGS=$_SAVE_LDFLAGS)
303 AC_MSG_CHECKING([for --build-id=sha1 option to ld])
304 _SAVE_LDFLAGS=$LDFLAGS
305 LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
306 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
308 LDFLAGS=$_SAVE_LDFLAGS)
310 AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
311 HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
312 _SAVE_LDFLAGS=$LDFLAGS
313 LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
314 AC_TRY_LINK(,,AC_MSG_RESULT([yes])
315 [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
317 LDFLAGS=$_SAVE_LDFLAGS
320 if test "$GCC_USE_GNU_LD"; then
321 # Some tools like ASan use a runtime library that is only
322 # linked against executables, so we must allow undefined
323 # symbols for shared objects in some cases.
324 if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
325 # Don't allow undefined symbols in libraries
326 DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
328 # BSDs need `environ' exposed for posix_spawn (bug 753046)
330 DragonFly|FreeBSD|NetBSD|OpenBSD)
331 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
332 DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
334 DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
341 _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
343 ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
346 if test "$GNU_CXX"; then
347 CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
349 _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
352 dnl ========================================================
353 dnl System overrides of the defaults for host
354 dnl ========================================================
357 if test -n "$_WIN32_MSVC"; then
358 HOST_CFLAGS="$HOST_CFLAGS"
360 HOST_CFLAGS="$HOST_CFLAGS -mwindows"
362 HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
363 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
366 case "${host_cpu}" in
368 if test -n "$_WIN32_MSVC"; then
369 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
373 if test -n "$_WIN32_MSVC"; then
374 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
376 HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
382 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
383 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
386 *-linux*|*-kfreebsd*-gnu|*-gnu*)
387 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
388 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
392 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
393 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
397 dnl ========================================================
398 dnl System overrides of the defaults for target
399 dnl ========================================================
403 MOZ_OPTIMIZE_FLAGS="-O3"
406 dnl DTrace and -dead_strip don't interact well. See bug 403132.
407 dnl ===================================================================
408 if test "x$enable_dtrace" = "xyes"; then
409 echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
411 dnl check for the presence of the -dead_strip linker flag
412 AC_MSG_CHECKING([for -dead_strip option to ld])
413 _SAVE_LDFLAGS=$LDFLAGS
414 LDFLAGS="$LDFLAGS -Wl,-dead_strip"
415 AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
416 if test -n "$_HAVE_DEAD_STRIP" ; then
418 MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
423 LDFLAGS=$_SAVE_LDFLAGS
429 *-android*|*-linuxandroid*)
430 if test "$COMPILE_ENVIRONMENT" -a -n "$MOZ_MEMORY"; then
434 if test -z "$CLANG_CC"; then
435 MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
437 # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
438 # -Oz is smaller than -Os on clang.
439 MOZ_OPTIMIZE_FLAGS="-Oz"
440 # Disable the outliner, which causes performance regressions, and is
441 # enabled on some platforms at -Oz.
442 if test -z "$MOZ_LTO"; then
443 DISABLE_OUTLINER="-mno-outline"
445 CFLAGS="$CFLAGS $DISABLE_OUTLINER"
446 AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
447 CFLAGS="$_SAVE_CFLAGS"
449 DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
450 _SAVE_LDFLAGS=$LDFLAGS
451 LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
452 AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
453 LDFLAGS="$_SAVE_LDFLAGS"
459 if test "$GNU_CC" -o "$GNU_CXX"; then
460 MOZ_PGO_OPTIMIZE_FLAGS="-O3"
461 if test -n "$MOZ_DEBUG"; then
462 MOZ_OPTIMIZE_FLAGS="-Os"
464 MOZ_OPTIMIZE_FLAGS="-O2"
466 if test -z "$CLANG_CC"; then
467 MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
471 case "${target_cpu}" in
473 CFLAGS="$CFLAGS -mieee"
474 CXXFLAGS="$CXXFLAGS -mieee"
480 # certain versions of cygwin's makedepend barf on the
481 # #include <string> vs -I./dist/include/string issue so don't use it
482 if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
483 # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
484 if test -z "$CLANG_CC"; then
485 AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
489 # mingw doesn't require kernel32, user32, and advapi32 explicitly
490 LIBS="$LIBS -luuid -lusp10 -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32"
493 MOZ_OPTIMIZE_FLAGS="-O2"
495 WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
496 WIN32_GUI_EXE_LDFLAGS=-mwindows
498 # Silence problematic clang warnings
499 CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
500 LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
502 TARGET_COMPILER_ABI=msvc
503 STRIP='echo not_strip'
504 # aarch64 doesn't support subsystems below 6.02
505 if test "$CPU_ARCH" = "aarch64"; then
506 WIN32_SUBSYSTEM_VERSION=6.02
508 WIN32_SUBSYSTEM_VERSION=6.01
510 WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
511 WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
512 DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
513 _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
514 _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
515 CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
516 CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
517 if test "$CPU_ARCH" = "x86"; then
518 dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
519 dnl more recent, so set that explicitly here unless another
520 dnl target arch has already been set.
522 if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
523 CFLAGS="$CFLAGS -arch:SSE2"
525 if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
526 CXXFLAGS="$CXXFLAGS -arch:SSE2"
529 SSE_FLAGS="-arch:SSE"
530 SSE2_FLAGS="-arch:SSE2"
531 dnl MSVC allows the use of intrinsics without any flags
532 dnl and doesn't have a separate arch for SSSE3
533 SSSE3_FLAGS="-arch:SSE2"
535 dnl clang-cl requires appropriate flags to enable SSSE3 support
536 dnl on all architectures.
537 SSSE3_FLAGS="-mssse3"
538 dnl VS2013+ supports -Gw for better linker optimizations.
539 dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
540 dnl Disabled on ASan because it causes false-positive ODR violations.
541 if test -z "$MOZ_ASAN"; then
543 CXXFLAGS="$CXXFLAGS -Gw"
545 # String tail merging doesn't play nice with ASan's ODR checker.
546 LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
548 # XXX We should combine some of these with our generic GCC-style
551 # Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
552 CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
553 # We use offsetof on non-POD objects all the time.
554 # We also suppress this warning on other platforms.
555 CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
556 # This warns for reasonable things like:
557 # enum { X = 0xffffffffU };
558 # which is annoying for IDL headers.
559 CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
560 # This warns for cases that would be reached by the Microsoft
561 # #include rules, but also currently warns on cases that would
562 # *also* be reached by standard C++ include rules. That
563 # behavior doesn't seem useful, so we turn it off.
564 CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
565 # We normally error out on unknown pragmas, but since clang-cl
566 # claims to be MSVC, it would be difficult to add
567 # #if defined(_MSC_VER) && !defined(__clang__) everywhere we
568 # use such pragmas, so just ignore them.
569 CFLAGS="$CFLAGS -Wno-unknown-pragmas"
570 CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
571 # We get errors about various #pragma intrinsic directives from
572 # clang-cl, and we don't need to hear about those.
573 CFLAGS="$CFLAGS -Wno-ignored-pragmas"
574 CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
575 # clang-cl's Intrin.h marks things like _ReadWriteBarrier
576 # as __attribute((__deprecated__)). This is nice to know,
577 # but since we don't get the equivalent warning from MSVC,
578 # let's just ignore it.
579 CFLAGS="$CFLAGS -Wno-deprecated-declarations"
580 CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
581 # We use a function like:
582 # __declspec(noreturn) __inline void f() {}
583 # which -Winvalid-noreturn complains about. Again, MSVC seems
584 # OK with it, so let's silence the warning.
585 CFLAGS="$CFLAGS -Wno-invalid-noreturn"
586 CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
587 # Missing |override| on virtual function declarations isn't
588 # something that MSVC currently warns about.
589 CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
590 # We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
591 # declaration on |operator delete(void*)|. However, clang-cl
592 # must internally declare |operator delete(void*)| differently,
593 # which causes this warning for virtually every file in the
594 # tree. clang-cl doesn't support -fno-exceptions or equivalent,
595 # so there doesn't seem to be any way to convince clang-cl to
596 # declare |delete| differently. Therefore, suppress this
598 CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
599 # Macros like STDMETHOD() and IFACEMETHOD() can declare
600 # __attribute__((nothrow)) on their respective method declarations,
601 # while the definitions are left without the matching attribute.
602 CXXFLAGS="$CXXFLAGS -Wno-microsoft-exception-spec"
603 # At least one MSVC header and several headers in-tree have
604 # unused typedefs, so turn this on.
605 CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
606 # jemalloc uses __declspec(allocator) as a profiler hint,
607 # which clang-cl doesn't understand.
608 CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
609 # __attribute__((unused)) really means "might be unused" and
610 # we use it to avoid warnings about things that are unused
611 # in some compilation units, but used in many others. This
612 # warning insists on complaining about the latter case, which
613 # is annoying, and rather noisy.
614 CXXFLAGS="$CXXFLAGS -Wno-used-but-marked-unused"
615 # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
616 CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
617 LIBS="$LIBS user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib secur32.lib"
618 MOZ_DEBUG_LDFLAGS='-DEBUG'
619 if test "$HOST_OS_ARCH" != "WINNT"; then
620 # %_PDB% is a special signal to emit only the PDB basename. This
621 # avoids problems in Windows tools that don't like forward-slashes.
622 MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
624 MOZ_OPTIMIZE_FLAGS='-O2'
626 LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
628 AC_DEFINE(WIN32_LEAN_AND_MEAN)
629 dnl See http://support.microsoft.com/kb/143208 to use STL
635 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.])
641 if test -n "$GNU_CC"; then
642 CFLAGS="$CFLAGS -mstackrealign"
643 CXXFLAGS="$CXXFLAGS -mstackrealign"
644 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
646 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
647 LDFLAGS="$LDFLAGS -SAFESEH"
653 if test -n "$_WIN32_MSVC"; then
654 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
659 if test -n "$_WIN32_MSVC"; then
660 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
665 AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
671 CFLAGS="$CFLAGS -Dunix"
672 CXXFLAGS="$CXXFLAGS -Dunix"
673 if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
674 DSO_PIC_CFLAGS='-fPIC -DPIC'
676 MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
678 DSO_PIC_CFLAGS='-fPIC -DPIC'
681 # This will fail on a.out systems prior to 1.5.1_ALPHA.
682 if test "$LIBRUNPATH"; then
683 DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
688 if test -z "$X11BASE"; then
691 MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
692 DSO_PIC_CFLAGS='-fPIC'
693 DSO_LDOPTS='-shared -fPIC'
694 if test "$LIBRUNPATH"; then
695 DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
700 MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
705 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
706 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
708 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
709 MOZ_OPTIMIZE_FLAGS="-O"
712 AC_SUBST_LIST(MMX_FLAGS)
713 AC_SUBST_LIST(SSE_FLAGS)
714 AC_SUBST_LIST(SSE2_FLAGS)
715 AC_SUBST_LIST(SSSE3_FLAGS)
718 if test -n "$MOZ_LINKER"; then
719 AC_DEFINE(MOZ_LINKER)
722 if test -z "$COMPILE_ENVIRONMENT"; then
723 SKIP_COMPILER_CHECKS=1
724 SKIP_LIBRARY_CHECKS=1
728 fi # COMPILE_ENVIRONMENT
730 if test -z "$SKIP_COMPILER_CHECKS"; then
731 dnl Checks for typedefs, structures, and compiler characteristics.
732 dnl ========================================================
747 case "${OS_TARGET}" in
751 STL_FLAGS="-I${DIST}/stl_wrappers"
756 if test "$MOZ_BUILD_APP" = "tools/crashreporter"; then
759 if test "$MOZ_BUILD_APP" = "tools/crashreporter/injector"; then
763 dnl Checks for header files.
764 dnl ========================================================
767 dnl Checks for libraries.
768 dnl ========================================================
769 AC_CHECK_LIB(c_r, gethostbyname_r)
771 dnl We don't want to link with libdl even if it's present on OS X, since
772 dnl it's not used and not part of the default installation. OS/2 has dlfcn
774 dnl We don't want to link against libm or libpthread on Darwin since
775 dnl they both are just symlinks to libSystem and explicitly linking
776 dnl against libSystem causes issues when debugging (see bug 299601).
781 AC_SEARCH_LIBS(dlopen, dl,
782 MOZ_CHECK_HEADER(dlfcn.h,
783 AC_DEFINE(HAVE_DLOPEN)))
787 _SAVE_CFLAGS="$CFLAGS"
788 CFLAGS="$CFLAGS -D_GNU_SOURCE"
789 AC_CHECK_FUNCS(dladdr)
790 CFLAGS="$_SAVE_CFLAGS"
792 if test ! "$GNU_CXX"; then
793 AC_CHECK_LIB(C, demangle)
796 AC_CHECK_LIB(socket, socket)
798 dnl ========================================================
799 dnl = pthread support
800 dnl = Start by checking whether the system support pthreads
801 dnl ========================================================
807 AC_CHECK_LIB(pthreads, pthread_create,
808 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
809 AC_CHECK_LIB(pthread, pthread_create,
810 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
811 AC_CHECK_LIB(c_r, pthread_create,
812 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
813 AC_CHECK_LIB(c, pthread_create,
822 dnl ========================================================
823 dnl Do the platform specific pthread hackery
824 dnl ========================================================
825 if test "$MOZ_USE_PTHREADS"x != x
828 dnl See if -pthread is supported.
831 ac_cv_have_dash_pthread=no
832 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
833 echo 'int main() { return 0; }' | cat > conftest.c
834 ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
835 if test $? -eq 0; then
836 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
837 ac_cv_have_dash_pthread=yes
840 # Freebsd doesn't use -pthread for compiles, it uses them for linking
843 CFLAGS="$CFLAGS -pthread"
844 CXXFLAGS="$CXXFLAGS -pthread"
850 AC_MSG_RESULT($ac_cv_have_dash_pthread)
853 dnl See if -pthreads is supported.
855 ac_cv_have_dash_pthreads=no
856 if test "$ac_cv_have_dash_pthread" = "no"; then
857 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
858 echo 'int main() { return 0; }' | cat > conftest.c
859 ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
860 if test $? -eq 0; then
861 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
862 ac_cv_have_dash_pthreads=yes
863 CFLAGS="$CFLAGS -pthreads"
864 CXXFLAGS="$CXXFLAGS -pthreads"
868 AC_MSG_RESULT($ac_cv_have_dash_pthreads)
873 AC_DEFINE(_REENTRANT)
874 AC_DEFINE(_THREAD_SAFE)
875 dnl -pthread links in -lpthread, so don't specify it explicitly.
876 if test "$ac_cv_have_dash_pthread" = "yes"; then
877 _PTHREAD_LDFLAGS="-pthread"
881 *-*-openbsd*|*-*-bsdi*)
882 AC_DEFINE(_REENTRANT)
883 AC_DEFINE(_THREAD_SAFE)
884 dnl -pthread links in -lc_r, so don't specify it explicitly.
885 if test "$ac_cv_have_dash_pthread" = "yes"; then
886 _PTHREAD_LDFLAGS="-pthread"
890 *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
891 AC_DEFINE(_REENTRANT)
895 LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
896 AC_SUBST(MOZ_USE_PTHREADS)
897 MOZ_CHECK_HEADERS(pthread.h)
901 dnl Checks for library functions.
902 dnl ========================================================
903 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall lutimes)
905 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
906 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
907 ac_cv_clock_monotonic,
908 [for libs in "" -lrt; do
911 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
912 dnl we should or not be able to use it. To detect if we can, we need to make the
913 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
914 AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
916 [ struct timespec ts;
917 clock_gettime(CLOCK_MONOTONIC, &ts); ],
918 ac_cv_clock_monotonic=$libs
921 ac_cv_clock_monotonic=no)
924 if test "$ac_cv_clock_monotonic" != "no"; then
925 HAVE_CLOCK_MONOTONIC=1
926 REALTIME_LIBS=$ac_cv_clock_monotonic
927 AC_DEFINE(HAVE_CLOCK_MONOTONIC)
928 AC_SUBST(HAVE_CLOCK_MONOTONIC)
929 AC_SUBST_LIST(REALTIME_LIBS)
932 dnl Turn on warnings-as-errors to prevent implicit declaration of
933 dnl pthread_cond_timedwait_monotonic_np, which can cause this test to
934 dnl inadvertently pass even if the function does not really exist.
935 _SAVE_CFLAGS="$CFLAGS"
936 CFLAGS="$CFLAGS $WARNINGS_AS_ERRORS"
937 AC_CACHE_CHECK(for pthread_cond_timedwait_monotonic_np,
938 ac_cv_pthread_cond_timedwait_monotonic_np,
939 AC_TRY_LINK([#include <pthread.h>],
940 [pthread_cond_timedwait_monotonic_np(0, 0, 0);],
941 ac_cv_pthread_cond_timewait_monotonic_np=yes,
942 ac_cv_pthread_cond_timewait_monotonic_np=no))
943 if test "$ac_cv_pthread_cond_timewait_monotonic_np" != "no"; then
944 AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
950 ac_cv_func_res_ninit,
951 [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
952 dnl no need for res_ninit() on NetBSD and OpenBSD
953 ac_cv_func_res_ninit=no
957 #define _BSD_SOURCE 1
959 #include <sys/types.h>
960 #include <netinet/in.h>
961 #include <arpa/nameser.h>
964 [int foo = res_ninit(&_res);],
965 [ac_cv_func_res_ninit=yes],
966 [ac_cv_func_res_ninit=no])
970 if test "$ac_cv_func_res_ninit" = "yes"; then
971 AC_DEFINE(HAVE_RES_NINIT)
972 dnl must add the link line we do something as foolish as this... dougt
974 dnl AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
975 dnl AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
980 dnl ===================================================================
981 dnl ========================================================
982 dnl Put your C++ language/feature checks below
983 dnl ========================================================
987 if test "$GNU_CC"; then
988 if test "$CPU_ARCH" = "arm" ; then
989 AC_CACHE_CHECK(for ARM EABI,
993 #if defined(__ARM_EABI__)
999 ac_cv_gcc_arm_eabi="yes",
1000 ac_cv_gcc_arm_eabi="no")])
1001 if test "$ac_cv_gcc_arm_eabi" = "yes"; then
1003 ARM_ABI_PREFIX=eabi-
1005 ARM_ABI_PREFIX=oabi-
1009 TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
1012 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
1013 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
1014 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
1016 _SAVE_LDFLAGS=$LDFLAGS
1017 LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
1018 AC_CACHE_CHECK(for __thread keyword for TLS variables,
1019 ac_cv_thread_keyword,
1020 [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
1021 [return tlsIsMainThread;],
1022 ac_cv_thread_keyword=yes,
1023 ac_cv_thread_keyword=no)])
1024 LDFLAGS=$_SAVE_LDFLAGS
1025 # The custom dynamic linker doesn't support TLS variables
1026 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
1027 # mips builds fail with TLS variables because of a binutils bug.
1029 # OpenBSD doesn't have TLS support, and the test succeeds with clang++
1034 *-android*|*-linuxandroid*)
1041 AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
1046 dnl Using the custom linker on ARMv6 requires 16k alignment of ELF segments.
1047 if test -n "$MOZ_LINKER"; then
1048 if test "$CPU_ARCH" = arm; then
1049 dnl When building for < ARMv7, we need to ensure 16k alignment of ELF segments
1050 if test -n "$ARM_ARCH" && test "$ARM_ARCH" -lt 7; then
1051 LDFLAGS="$LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1052 _SUBDIR_LDFLAGS="$_SUBDIR_LDFLAGS -Wl,-z,max-page-size=0x4000 -Wl,-z,common-page-size=0x4000"
1056 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
1057 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
1058 dnl Since the linker only understands the sysv ones, no need to build the
1059 dnl gnu style tables anyways.
1060 LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
1063 dnl End of C++ language/feature checks
1066 dnl ========================================================
1067 dnl = Internationalization checks
1068 dnl ========================================================
1070 dnl Internationalization and Locale support is different
1071 dnl on various UNIX platforms. Checks for specific i18n
1072 dnl features go here.
1074 AC_HAVE_FUNCS(localeconv)
1076 fi # ! SKIP_COMPILER_CHECKS
1078 if test -n "${COMPILE_ENVIRONMENT}"; then
1083 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1084 TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1085 AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
1088 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1089 dnl features that Windows actually does support.
1091 if test -n "$SKIP_COMPILER_CHECKS"; then
1092 dnl Windows has malloc.h
1093 AC_DEFINE(MALLOC_H, [<malloc.h>])
1094 AC_DEFINE(HAVE_FORCEINLINE)
1095 AC_DEFINE(HAVE_LOCALECONV)
1096 fi # SKIP_COMPILER_CHECKS
1098 dnl Mozilla specific options
1099 dnl ========================================================
1100 dnl The macros used for command line options
1101 dnl are defined in build/autoconf/altoptions.m4.
1103 dnl ========================================================
1107 dnl ========================================================
1109 MOZ_ARG_HEADER(Application)
1111 MOZ_BRANDING_DIRECTORY=
1112 MOZ_OFFICIAL_BRANDING=
1114 MOZ_BINARY_EXTENSIONS=
1117 dnl ========================================================
1118 dnl = Trademarked Branding
1119 dnl ========================================================
1120 MOZ_ARG_ENABLE_BOOL(official-branding,
1121 [ --enable-official-branding
1122 Enable Official mozilla.org Branding
1123 Do not distribute builds with
1124 --enable-official-branding unless you have
1125 permission to use trademarks per
1126 http://www.mozilla.org/foundation/trademarks/ .],
1127 MOZ_OFFICIAL_BRANDING=1,
1128 MOZ_OFFICIAL_BRANDING=)
1130 # Allow the application to influence configure with a confvars.sh script.
1131 AC_MSG_CHECKING([if app-specific confvars.sh exists])
1132 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
1133 AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
1134 . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
1139 dnl ========================================================
1140 dnl Ensure Android SDK and build-tools versions depending on
1142 dnl ========================================================
1144 case "$MOZ_BUILD_APP" in
1150 dnl ========================================================
1152 dnl = Toolkit Options
1154 dnl ========================================================
1155 MOZ_ARG_HEADER(Toolkit Options)
1157 dnl ========================================================
1159 dnl = Components & Features
1161 dnl ========================================================
1162 MOZ_ARG_HEADER(Components and Features)
1164 AC_SUBST(MOZ_OFFICIAL_BRANDING)
1165 if test -n "$MOZ_OFFICIAL_BRANDING"; then
1166 if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
1167 AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
1169 MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
1170 AC_DEFINE(MOZ_OFFICIAL_BRANDING)
1174 MOZ_ARG_WITH_STRING(branding,
1175 [ --with-branding=dir Use branding from the specified directory.],
1176 MOZ_BRANDING_DIRECTORY=$withval)
1178 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
1179 if test -z "$REAL_BRANDING_DIRECTORY"; then
1180 REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
1183 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
1184 . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
1187 AC_SUBST(MOZ_BRANDING_DIRECTORY)
1189 dnl ========================================================
1190 dnl = Distribution ID
1191 dnl ========================================================
1192 MOZ_ARG_WITH_STRING(distribution-id,
1193 [ --with-distribution-id=ID
1194 Set distribution-specific id (default=org.mozilla)],
1195 [ val=`echo $withval`
1196 MOZ_DISTRIBUTION_ID="$val"])
1198 if test -z "$MOZ_DISTRIBUTION_ID"; then
1199 MOZ_DISTRIBUTION_ID="org.mozilla"
1202 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
1203 AC_SUBST(MOZ_DISTRIBUTION_ID)
1205 AC_TRY_COMPILE([#include <linux/ethtool.h>],
1206 [ struct ethtool_cmd cmd; cmd.speed_hi = 0; ],
1207 MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI=1)
1209 AC_SUBST(MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI)
1211 dnl ========================================================
1213 dnl ========================================================
1215 if test "$COMPILE_ENVIRONMENT" ; then
1217 dnl Moved gamepad platform check to moz.build, linux header check still needed here.
1218 if test "$OS_TARGET" = "Linux"; then
1219 MOZ_CHECK_HEADER([linux/joystick.h])
1220 if test "$ac_cv_header_linux_joystick_h" != "yes"; then
1221 AC_MSG_ERROR([Can't find header linux/joystick.h, needed for gamepad support. Please install Linux kernel headers.])
1225 fi # COMPILE_ENVIRONMENT
1228 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
1229 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
1230 if test -n "$MOZ_TREE_FREETYPE" -a "$OS_TARGET" != WINNT; then
1231 MOZ_ENABLE_CAIRO_FT=1
1232 CAIRO_FT_CFLAGS="-I$_topsrcdir/modules/freetype2/include"
1233 AC_SUBST_LIST(CAIRO_FT_CFLAGS)
1236 dnl ========================================================
1238 dnl ========================================================
1240 MOZ_ARG_DISABLE_BOOL(updater,
1241 [ --disable-updater Disable building of updater],
1245 if test -n "$MOZ_UPDATER"; then
1246 AC_DEFINE(MOZ_UPDATER)
1249 dnl ========================================================
1250 dnl = Disable smartcard support
1251 dnl ========================================================
1252 if test -n "$MOZ_NO_SMART_CARDS"; then
1253 AC_DEFINE(MOZ_NO_SMART_CARDS)
1255 AC_SUBST(MOZ_NO_SMART_CARDS)
1257 dnl ========================================================
1259 dnl = Module specific options
1261 dnl ========================================================
1262 MOZ_ARG_HEADER(Individual module options)
1264 dnl ==============================
1265 dnl === SQLite fdatasync check ===
1266 dnl ==============================
1267 dnl Check to see if fdatasync is available and make use of it
1268 AC_CHECK_FUNC(fdatasync)
1270 dnl ========================================================
1272 dnl = Feature options that require extra sources to be pulled
1274 dnl ========================================================
1275 dnl MOZ_ARG_HEADER(Features that require extra sources)
1277 dnl ========================================================
1279 dnl = Runtime debugging and Optimization Options
1281 dnl ========================================================
1282 MOZ_ARG_HEADER(Runtime debugging and Optimizations)
1284 dnl ========================================================
1285 dnl = Enable code optimization. ON by default.
1286 dnl ========================================================
1288 # Use value from moz.configure if one is defined. Else use our computed
1290 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
1291 MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
1294 if test "$COMPILE_ENVIRONMENT"; then
1295 if test -n "$MOZ_OPTIMIZE"; then
1296 AC_MSG_CHECKING([for valid C compiler optimization flags])
1297 _SAVE_CFLAGS=$CFLAGS
1298 CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
1299 AC_TRY_COMPILE([#include <stdio.h>],
1300 [printf("Hello World\n");],
1303 AC_MSG_RESULT([$_results])
1304 if test "$_results" = "no"; then
1305 AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
1307 CFLAGS=$_SAVE_CFLAGS
1308 if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
1309 # When using llvm-based LTO, non numeric optimization levels are
1310 # not supported by the linker, so force the linker to use -O2 (
1311 # which doesn't influence the level compilation units are actually
1313 case " $MOZ_OPTIMIZE_FLAGS " in
1314 *\ -Os\ *|*\ -Oz\ *)
1315 MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
1320 fi # COMPILE_ENVIRONMENT
1322 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
1323 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
1324 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
1326 case "${OS_TARGET}" in
1327 Android|WINNT|Darwin)
1328 MOZ_GLUE_IN_PROGRAM=
1331 dnl On !Android !Windows !OSX, we only want to link executables against mozglue
1332 MOZ_GLUE_IN_PROGRAM=1
1333 AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
1337 dnl ========================================================
1338 dnl = Jemalloc build setup
1339 dnl ========================================================
1340 if test -z "$MOZ_MEMORY"; then
1343 if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
1344 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.])
1349 dnl The generic feature tests that determine how to compute ncpus are long and
1350 dnl complicated. Therefore, simply define special cpp variables for the
1351 dnl platforms we have special knowledge of.
1354 export MOZ_NO_DEBUG_RTL=1
1358 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
1360 dnl ========================================================
1361 dnl = Enable using the clang plugin to build
1362 dnl ========================================================
1364 if test -n "$COMPILE_ENVIRONMENT"; then
1365 MOZ_CONFIG_CLANG_PLUGIN
1366 fi # COMPILE_ENVIRONMENT
1368 dnl ========================================================
1370 dnl = Profiling and Instrumenting
1372 dnl ========================================================
1373 MOZ_ARG_HEADER(Profiling and Instrumenting)
1375 dnl ========================================================
1376 dnl = Support for demangling undefined symbols
1377 dnl ========================================================
1378 if test -z "$SKIP_LIBRARY_CHECKS"; then
1381 AC_CHECK_FUNCS(__cxa_demangle, HAVE_DEMANGLE=1, HAVE_DEMANGLE=)
1385 # Demangle only for debug or DMD builds
1386 MOZ_DEMANGLE_SYMBOLS=
1387 if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
1388 MOZ_DEMANGLE_SYMBOLS=1
1389 AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
1391 AC_SUBST(MOZ_DEMANGLE_SYMBOLS)
1393 dnl ========================================================
1394 dnl = Support for gcc stack unwinding (from gcc 3.3)
1395 dnl ========================================================
1396 if test -z "$SKIP_LIBRARY_CHECKS"; then
1399 MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace))
1403 dnl ========================================================
1407 dnl ========================================================
1408 MOZ_ARG_HEADER(Misc. Options)
1410 if test -z "$SKIP_COMPILER_CHECKS"; then
1411 dnl ========================================================
1413 dnl = Compiler Options
1415 dnl ========================================================
1416 MOZ_ARG_HEADER(Compiler Options)
1418 dnl ========================================================
1419 dnl Check for gcc -pipe support
1420 dnl ========================================================
1421 AC_MSG_CHECKING([for -pipe support])
1422 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
1423 dnl Any gcc that supports firefox supports -pipe.
1424 CFLAGS="$CFLAGS -pipe"
1425 CXXFLAGS="$CXXFLAGS -pipe"
1426 AC_MSG_RESULT([yes])
1431 fi # ! SKIP_COMPILER_CHECKS
1435 if test "$COMPILE_ENVIRONMENT"; then
1437 fi # COMPILE_ENVIRONMENT
1439 dnl ========================================================
1441 dnl = Static Build Options
1443 dnl ========================================================
1444 MOZ_ARG_HEADER(Static build options)
1446 if test -z "$MOZ_SYSTEM_ZLIB"; then
1447 if test -n "$JS_SHARED_LIBRARY" -o -n "$MOZ_LINKER" -o "$MOZ_WIDGET_TOOLKIT" = android; then
1449 AC_DEFINE(ZLIB_IN_MOZGLUE)
1453 AC_SUBST(ZLIB_IN_MOZGLUE)
1455 dnl ========================================================
1457 dnl = Standalone module options
1459 dnl ========================================================
1460 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
1462 dnl ========================================================
1463 dnl Check if we need the 32-bit Linux SSE2 error dialog
1464 dnl ========================================================
1466 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
1468 dnl ========================================================
1470 dnl ========================================================
1472 if test "$OS_ARCH" = "WINNT"; then
1473 # For now we assume that we will have a uint64_t available through
1474 # one of the above headers or mozstdint.h.
1475 AC_DEFINE(HAVE_UINT64_T)
1478 if test "$_HAVE_FREETYPE2"; then
1479 MOZ_ENABLE_CAIRO_FT=1
1480 CAIRO_FT_CFLAGS="$FT2_CFLAGS"
1483 case "$MOZ_WIDGET_TOOLKIT" in
1485 if test "$COMPILE_ENVIRONMENT"; then
1486 MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
1490 AC_SUBST(MOZ_ENABLE_CAIRO_FT)
1491 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
1493 dnl ========================================================
1495 dnl = Maintainer debug option (no --enable equivalent)
1497 dnl ========================================================
1499 AC_SUBST_LIST(ASFLAGS)
1500 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
1501 AC_SUBST_LIST(WARNINGS_CFLAGS)
1503 AC_SUBST(MOZ_STUB_INSTALLER)
1504 AC_SUBST(MOZ_UPDATER)
1506 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
1508 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
1510 if test -n "$MOZ_BINARY_EXTENSIONS"; then
1511 AC_DEFINE(MOZ_BINARY_EXTENSIONS)
1514 dnl ========================================================
1515 dnl = Mac bundle name prefix
1516 dnl ========================================================
1517 MOZ_ARG_WITH_STRING(macbundlename-prefix,
1518 [ --with-macbundlename-prefix=prefix
1519 Prefix for MOZ_MACBUNDLE_NAME],
1520 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
1522 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
1523 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
1524 MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
1527 if test "$MOZ_DEBUG"; then
1528 MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
1530 MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
1532 AC_SUBST(MOZ_MACBUNDLE_NAME)
1534 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
1535 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
1536 # Otherwise, use MOZ_APP_DISPLAYNAME
1537 if test -z "$MOZ_MACBUNDLE_ID"; then
1538 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
1540 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
1541 if test "$MOZ_DEBUG"; then
1542 MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
1545 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
1546 AC_SUBST(MOZ_MACBUNDLE_ID)
1548 dnl ========================================================
1549 dnl = Child Process Name for IPC
1550 dnl ========================================================
1551 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
1552 MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
1554 # We want to let Android unpack the file at install time, but it only does
1555 # so if the file is named libsomething.so. The lib/ path is also required
1556 # because the unpacked file will be under the lib/ subdirectory and will
1557 # need to be executed from that path.
1558 MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
1560 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
1561 MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
1563 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
1564 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
1565 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
1567 # The following variables are available to branding and application
1568 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
1569 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
1570 # impacts profile location and user-visible fields.
1571 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
1572 # Mac Bundle name, Updater, Installer), it is typically used for nightly
1573 # builds (e.g. Aurora for Firefox).
1574 # - MOZ_APP_PROFILE: When set, used for application.ini's
1575 # "Profile" field, which controls profile location.
1576 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
1577 # crash reporter server url.
1578 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
1580 # The following environment variables used to have an effect, but don't anymore:
1581 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
1582 # the contents from the version.txt file in the application directory, or
1583 # browser/config/version.txt if there isn't one.
1584 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
1585 # in the "About" window. This was replaced with the contents from the
1586 # version_display.txt or version.txt in the application directory, or
1587 # browser/config/version_display.txt.
1589 # For extensions and langpacks, we require a max version that is compatible
1590 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
1591 # 24.0a1 and 24.0a2 aren't affected
1593 # 24.1.1 becomes 24.*
1594 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
1595 if test -z "$IS_ALPHA"; then
1597 if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
1598 MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
1600 MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
1604 MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
1607 AC_SUBST(MOZ_APP_DISPLAYNAME)
1608 AC_SUBST(MOZ_APP_VENDOR)
1609 AC_SUBST(MOZ_APP_PROFILE)
1610 AC_SUBST(MOZ_APP_ID)
1611 AC_SUBST(MAR_CHANNEL_ID)
1612 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
1613 AC_SUBST(MOZ_PROFILE_MIGRATOR)
1614 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
1615 AC_SUBST(MOZ_APP_UA_NAME)
1616 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
1617 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
1618 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
1620 AC_SUBST(MOZ_APP_MAXVERSION)
1621 AC_SUBST(MOZ_PKG_SPECIAL)
1622 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
1624 if test "$MOZILLA_OFFICIAL"; then
1625 # Build revisions should always be present in official builds
1626 MOZ_INCLUDE_SOURCE_INFO=1
1629 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
1630 # explicitly set the repository and changeset information in.
1631 AC_SUBST(MOZ_SOURCE_REPO)
1632 AC_SUBST(MOZ_SOURCE_CHANGESET)
1633 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
1635 dnl If we have any service that uploads data (and requires data submission
1636 dnl policy alert), set MOZ_DATA_REPORTING.
1637 dnl We need SUBST for build system and DEFINE for xul preprocessor.
1638 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER" || test -n "$MOZ_NORMANDY"; then
1639 MOZ_DATA_REPORTING=1
1640 AC_DEFINE(MOZ_DATA_REPORTING)
1641 AC_SUBST(MOZ_DATA_REPORTING)
1645 AC_SUBST(WIN32_REDIST_DIR)
1646 AC_SUBST(WIN_UCRT_REDIST_DIR)
1648 dnl Echo the CFLAGS to remove extra whitespace.
1650 $_COMPILATION_CFLAGS \
1654 $_WARNINGS_CXXFLAGS \
1655 $_COMPILATION_CXXFLAGS \
1658 COMPILE_CFLAGS=`echo \
1662 COMPILE_CXXFLAGS=`echo \
1663 $_DEFINES_CXXFLAGS \
1667 $_WARNINGS_HOST_CFLAGS \
1668 $_COMPILATION_HOST_CFLAGS \
1671 HOST_CXXFLAGS=`echo \
1672 $_WARNINGS_HOST_CXXFLAGS \
1673 $_COMPILATION_HOST_CXXFLAGS \
1676 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
1677 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1678 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
1679 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1680 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
1681 OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1682 OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1684 AC_SUBST(HOST_CMFLAGS)
1685 AC_SUBST(HOST_CMMFLAGS)
1686 AC_SUBST(OS_COMPILE_CMFLAGS)
1687 AC_SUBST(OS_COMPILE_CMMFLAGS)
1690 OS_CXXFLAGS="$CXXFLAGS"
1691 OS_CPPFLAGS="$CPPFLAGS"
1692 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1693 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1694 OS_LDFLAGS="$LDFLAGS"
1696 AC_SUBST_LIST(OS_CFLAGS)
1697 AC_SUBST_LIST(OS_CXXFLAGS)
1698 AC_SUBST_LIST(OS_CPPFLAGS)
1699 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1700 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1701 AC_SUBST_LIST(OS_LDFLAGS)
1706 AC_SUBST_LIST(HOST_CFLAGS)
1707 AC_SUBST_LIST(HOST_CPPFLAGS)
1708 AC_SUBST_LIST(HOST_CXXFLAGS)
1709 AC_SUBST(HOST_LDFLAGS)
1710 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1711 AC_SUBST(HOST_BIN_SUFFIX)
1713 AC_SUBST(TARGET_XPCOM_ABI)
1715 AC_SUBST(DSO_LDOPTS)
1716 AC_SUBST(BIN_SUFFIX)
1718 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1719 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1721 AC_SUBST(MOZ_DEVTOOLS)
1723 AC_SUBST(MOZ_PACKAGE_JSSHELL)
1727 dnl Host JavaScript runtime, if any, to use during cross compiles.
1730 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
1732 if test -n "$COMPILE_ENVIRONMENT"; then
1733 AC_CHECK_FUNCS(posix_fadvise posix_fallocate)
1734 fi # COMPILE_ENVIRONMENT
1736 dnl Set various defines and substitutions
1737 dnl ========================================================
1739 AC_SUBST(MOZ_DEV_EDITION)
1740 if test -n "$MOZ_DEV_EDITION"; then
1741 AC_DEFINE(MOZ_DEV_EDITION)
1744 if test "$MOZ_DEBUG" -o "$DEVELOPER_OPTIONS"; then
1748 if test -n "$A11Y_LOG"; then
1752 dnl Windows AccessibilityHandler
1753 dnl ========================================================
1755 if test -z "$MOZ_HANDLER_CLSID"; then
1756 MOZ_HANDLER_CLSID="4a195748-dca2-45fb-9295-0a139e76a9e7"
1757 MOZ_IHANDLERCONTROL_IID="3316ce35-f892-4832-97c5-06c52c03cdba"
1758 MOZ_ASYNCIHANDLERCONTROL_IID="15b48b76-ad38-4ad3-bd1a-d3c48a5a9947"
1759 MOZ_IGECKOBACKCHANNEL_IID="dd2e4a89-999e-4d65-8b65-440c923ddb61"
1762 AC_SUBST(MOZ_HANDLER_CLSID)
1763 AC_SUBST(MOZ_IHANDLERCONTROL_IID)
1764 AC_SUBST(MOZ_ASYNCIHANDLERCONTROL_IID)
1765 AC_SUBST(MOZ_IGECKOBACKCHANNEL_IID)
1767 dnl Spit out some output
1768 dnl ========================================================
1770 # Avoid using obsolete NSPR features
1771 AC_DEFINE(NO_NSPR_10_SUPPORT)
1773 MOZ_CREATE_CONFIG_STATUS()
1775 rm -fr confdefs* $ac_clean_files