Bug 1750871 - run mochitest-remote on fission everywhere. r=releng-reviewers,aki
[gecko.git] / old-configure.in
blobc65b9f781e999356f89ec63fafd35cd4057ac0f0
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 minimum version of toolkit libs used by mozilla
47 dnl ========================================================
48 W32API_VERSION=3.14
50 dnl Set various checks
51 dnl ========================================================
52 MISSING_X=
54 dnl Initialize the Pthread test variables early so they can be
55 dnl  overridden by each platform.
56 dnl ========================================================
57 MOZ_USE_PTHREADS=
58 _PTHREAD_LDFLAGS=""
60 LDFLAGS="$LDFLAGS $LINKER_LDFLAGS"
62 if test "$COMPILE_ENVIRONMENT"; then
63     MOZ_ANDROID_NDK
64 fi # COMPILE_ENVIRONMENT
66 dnl ========================================================
67 dnl Checks for compilers.
68 dnl ========================================================
70 if test "$COMPILE_ENVIRONMENT"; then
72 # Run some logic to figure out exe extensions (mostly for mingw's sake)
73 AC_EXEEXT
75 if test "$target" != "$host"; then
76     MOZ_CROSS_COMPILER
77 else
78     AC_PROG_CC
79     case "$target" in
80     *-mingw*)
81       # Work around the conftest.exe access problem on Windows
82       sleep 2
83     esac
84     AC_PROG_CXX
85     MOZ_PATH_PROGS(AS, $AS as, $CC)
86     AC_CHECK_PROGS(OTOOL, otool, :)
89 MOZ_TOOL_VARIABLES
91 dnl ========================================================
92 dnl Special win32 checks
93 dnl ========================================================
95 WINVER=601
97 case "$target" in
98 *-mingw*)
99     if test "$GCC" != "yes"; then
100         # Check to see if we are really running in a msvc environemnt
101         _WIN32_MSVC=1
103         # Make sure compilers are valid
104         CXXFLAGS="$CXXFLAGS -TP"
105         AC_LANG_SAVE
106         AC_LANG_C
107         AC_TRY_COMPILE([#include <stdio.h>],
108             [ printf("Hello World\n"); ],,
109             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
111         AC_LANG_CPLUSPLUS
112         AC_TRY_COMPILE([#include <new.h>],
113             [ unsigned *test = new unsigned(42); ],,
114             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
115         AC_LANG_RESTORE
117         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
118         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
119         AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
121         MSVC_C_RUNTIME_DLL=vcruntime140.dll
122         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
124         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
125         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
127         if test -n "$WIN_UCRT_REDIST_DIR"; then
128           if test ! -d "$WIN_UCRT_REDIST_DIR"; then
129             AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
130           fi
131           WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
132         fi
134         AC_SUBST(MSVC_C_RUNTIME_DLL)
135         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
137         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
139         if test -n "$WIN32_REDIST_DIR"; then
140           if test ! -d "$WIN32_REDIST_DIR"; then
141             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
142           fi
143           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
144         fi
146         WRAP_STL_INCLUDES=1
147         STL_FLAGS="-I${DIST}/stl_wrappers"
148     else
149         # Check w32api version
150         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
151         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
152         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
153         AC_TRY_COMPILE([#include <w32api.h>],
154             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
155                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
156                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
157                 #error "test failed."
158             #endif
159             , [ res=yes ], [ res=no ])
160         AC_MSG_RESULT([$res])
161         if test "$res" != "yes"; then
162             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
163         fi
164         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
165         # causing problems with local implementations with the same name.
166         AC_DEFINE(STRSAFE_NO_DEPRECATE)
167     fi # !GNU_CC
169     CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
170     CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
172     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
173     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
174     # Require OS features provided by IE 8.0 (Win7)
175     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
177     ;;
178 esac
180 if test -n "$_WIN32_MSVC"; then
181     SKIP_PATH_CHECKS=1
182     SKIP_COMPILER_CHECKS=1
183     SKIP_LIBRARY_CHECKS=1
185     # Since we're skipping compiler and library checks, hard-code
186     # some facts here.
187     AC_DEFINE(HAVE_IO_H)
188     AC_DEFINE(HAVE_ISATTY)
191 fi # COMPILE_ENVIRONMENT
193 AC_SUBST(GNU_CC)
194 AC_SUBST(GNU_CXX)
196 AC_SUBST_LIST(STL_FLAGS)
197 AC_SUBST(WRAP_STL_INCLUDES)
199 dnl ========================================================
200 dnl set the defaults first
201 dnl ========================================================
202 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
204 dnl Configure platform-specific CPU architecture compiler options.
205 dnl ==============================================================
206 if test "$COMPILE_ENVIRONMENT"; then
207     MOZ_ARCH_OPTS
208 fi # COMPILE_ENVIRONMENT
210 dnl ========================================================
211 dnl Android libstdc++
212 dnl ========================================================
214 if test "$COMPILE_ENVIRONMENT"; then
215     MOZ_ANDROID_STLPORT
216 fi # COMPILE_ENVIRONMENT
218 dnl ========================================================
219 dnl Suppress Clang Argument Warnings
220 dnl ========================================================
221 WARNINGS_CFLAGS="$_WARNINGS_CFLAGS"
222 if test -n "${CLANG_CC}${CLANG_CL}"; then
223     WARNINGS_CFLAGS="-Qunused-arguments $WARNINGS_CFLAGS"
224     CPPFLAGS="-Qunused-arguments ${CPPFLAGS}"
226 if test -n "${CLANG_CXX}${CLANG_CL}"; then
227     _WARNINGS_CXXFLAGS="-Qunused-arguments ${_WARNINGS_CXXFLAGS}"
230 if test -n "$COMPILE_ENVIRONMENT"; then
231    MOZ_CONFIG_SANITIZE
234 dnl ========================================================
235 dnl GNU specific defaults
236 dnl ========================================================
237 if test "$GNU_CC"; then
238     if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
239         DSO_PIC_CFLAGS='-fPIC'
240         ASFLAGS="$ASFLAGS -fPIC"
241     fi
243     AC_MSG_CHECKING([for --noexecstack option to as])
244     _SAVE_CFLAGS=$CFLAGS
245     CFLAGS="$CFLAGS -Wa,--noexecstack"
246     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
247                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
248                      AC_MSG_RESULT([no]))
249     CFLAGS=$_SAVE_CFLAGS
250     AC_MSG_CHECKING([for -z noexecstack option to ld])
251     _SAVE_LDFLAGS=$LDFLAGS
252     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
253     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
254                   AC_MSG_RESULT([no])
255                   LDFLAGS=$_SAVE_LDFLAGS)
257     AC_MSG_CHECKING([for -z text option to ld])
258     _SAVE_LDFLAGS=$LDFLAGS
259     LDFLAGS="$LDFLAGS -Wl,-z,text"
260     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
261                   AC_MSG_RESULT([no])
262                   LDFLAGS=$_SAVE_LDFLAGS)
264     AC_MSG_CHECKING([for -z relro option to ld])
265     _SAVE_LDFLAGS=$LDFLAGS
266     LDFLAGS="$LDFLAGS -Wl,-z,relro"
267     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
268                   AC_MSG_RESULT([no])
269                   LDFLAGS=$_SAVE_LDFLAGS)
271     AC_MSG_CHECKING([for -z nocopyreloc option to ld])
272     _SAVE_LDFLAGS=$LDFLAGS
273     LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
274     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
275                   AC_MSG_RESULT([no])
276                   LDFLAGS=$_SAVE_LDFLAGS)
278     AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
279     _SAVE_LDFLAGS=$LDFLAGS
280     LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
281     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
282                   AC_MSG_RESULT([no])
283                   LDFLAGS=$_SAVE_LDFLAGS)
285     AC_MSG_CHECKING([for --build-id=sha1 option to ld])
286     _SAVE_LDFLAGS=$LDFLAGS
287     LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
288     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
289                   AC_MSG_RESULT([no])
290                   LDFLAGS=$_SAVE_LDFLAGS)
292     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
293     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
294     _SAVE_LDFLAGS=$LDFLAGS
295     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
296     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
297                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
298                   AC_MSG_RESULT([no]))
299     LDFLAGS=$_SAVE_LDFLAGS
301     DSO_LDOPTS='-shared'
302     if test "$GCC_USE_GNU_LD"; then
303         # Some tools like ASan use a runtime library that is only
304         # linked against executables, so we must allow undefined
305         # symbols for shared objects in some cases.
306         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
307             # Don't allow undefined symbols in libraries
308             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
310             # BSDs need `environ' exposed for posix_spawn (bug 753046)
311             case "$OS_TARGET" in
312             DragonFly|FreeBSD|NetBSD|OpenBSD)
313                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
314                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
315                 else
316                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
317                 fi
318                 ;;
319             esac
320         fi
321     fi
323     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
325     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
328 if test "$GNU_CXX"; then
329     CXXFLAGS="$CXXFLAGS -fno-exceptions"
331     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
334 dnl ========================================================
335 dnl System overrides of the defaults for host
336 dnl ========================================================
337 case "$host" in
338 *mingw*)
339     if test -n "$_WIN32_MSVC"; then
340         HOST_CFLAGS="$HOST_CFLAGS"
341     else
342         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
343     fi
344     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
345     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
346     HOST_BIN_SUFFIX=.exe
348     case "${host_cpu}" in
349     i*86)
350         if test -n "$_WIN32_MSVC"; then
351             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
352         fi
353         ;;
354     x86_64)
355         if test -n "$_WIN32_MSVC"; then
356             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
357         fi
358         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
359         ;;
360     esac
361     ;;
363 *-darwin*)
364     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
365     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
366     ;;
368 *-linux*|*-kfreebsd*-gnu|*-gnu*)
369     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
370     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
371     ;;
374     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
375     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
376     ;;
377 esac
379 dnl ========================================================
380 dnl System overrides of the defaults for target
381 dnl ========================================================
383 case "$target" in
384 *-darwin*)
385     MOZ_OPTIMIZE_FLAGS="-O3"
386     DSO_LDOPTS=''
388     dnl DTrace and -dead_strip don't interact well. See bug 403132.
389     dnl ===================================================================
390     if test "x$enable_dtrace" = "xyes"; then
391         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
392     else
393         dnl check for the presence of the -dead_strip linker flag
394         AC_MSG_CHECKING([for -dead_strip option to ld])
395         _SAVE_LDFLAGS=$LDFLAGS
396         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
397         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
398         if test -n "$_HAVE_DEAD_STRIP" ; then
399             AC_MSG_RESULT([yes])
400             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
401         else
402             AC_MSG_RESULT([no])
403         fi
405         LDFLAGS=$_SAVE_LDFLAGS
406     fi
408     MOZ_FIX_LINK_PATHS=
409     ;;
411 *-android*|*-linuxandroid*)
412     if test -z "$CLANG_CC"; then
413         MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
414     else
415         # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
416         # -Oz is smaller than -Os on clang.
417         MOZ_OPTIMIZE_FLAGS="-Oz"
418         # Disable the outliner, which causes performance regressions, and is
419         # enabled on some platforms at -Oz.
420         if test -z "$MOZ_LTO"; then
421             DISABLE_OUTLINER="-mno-outline"
422             _SAVE_CFLAGS=$CFLAGS
423             CFLAGS="$CFLAGS $DISABLE_OUTLINER"
424             AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
425             CFLAGS="$_SAVE_CFLAGS"
426         else
427             DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
428             _SAVE_LDFLAGS=$LDFLAGS
429             LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
430             AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
431             LDFLAGS="$_SAVE_LDFLAGS"
432         fi
433     fi
434     ;;
436 *-*linux*)
437     if test "$GNU_CC" -o "$GNU_CXX"; then
438         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
439         if test -n "$MOZ_DEBUG"; then
440             MOZ_OPTIMIZE_FLAGS="-Os"
441         else
442             MOZ_OPTIMIZE_FLAGS="-O2"
443         fi
444         if test -z "$CLANG_CC"; then
445            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
446         fi
447     fi
449     case "${target_cpu}" in
450     alpha*)
451         CFLAGS="$CFLAGS -mieee"
452         CXXFLAGS="$CXXFLAGS -mieee"
453     ;;
454     esac
455     ;;
456 *-mingw*)
457     DSO_PIC_CFLAGS=
458     # certain versions of cygwin's makedepend barf on the
459     # #include <string> vs -I./dist/include/string issue so don't use it
460     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
461         # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
462         if test -z "$CLANG_CC"; then
463             AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
464         fi
466         DSO_LDOPTS='-shared'
467         MOZ_FIX_LINK_PATHS=
469         MOZ_OPTIMIZE_FLAGS="-O2"
471         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
472         WIN32_GUI_EXE_LDFLAGS=-mwindows
474         # Silence problematic clang warnings
475         CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
476         LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
477     else
478         TARGET_COMPILER_ABI=msvc
479         # aarch64 doesn't support subsystems below 6.02
480         if test "$CPU_ARCH" = "aarch64"; then
481             WIN32_SUBSYSTEM_VERSION=6.02
482         else
483             WIN32_SUBSYSTEM_VERSION=6.01
484         fi
485         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
486         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
487         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
488         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
489         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
490         CFLAGS="$CFLAGS -W3 -Gy -Zc:inline"
491         CXXFLAGS="$CXXFLAGS -W3 -Gy -Zc:inline"
492         if test "$CPU_ARCH" = "x86"; then
493             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
494             dnl more recent, so set that explicitly here unless another
495             dnl target arch has already been set.
496             changequote(,)
497             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
498               CFLAGS="$CFLAGS -arch:SSE2"
499             fi
500             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
501               CXXFLAGS="$CXXFLAGS -arch:SSE2"
502             fi
503             changequote([,])
504         fi
505         dnl VS2013+ supports -Gw for better linker optimizations.
506         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
507         dnl Disabled on ASan because it causes false-positive ODR violations.
508         if test -z "$MOZ_ASAN"; then
509             CFLAGS="$CFLAGS -Gw"
510             CXXFLAGS="$CXXFLAGS -Gw"
511         else
512             # String tail merging doesn't play nice with ASan's ODR checker.
513             LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
514         fi
515         # XXX We should combine some of these with our generic GCC-style
516         # warning checks.
517         #
518         # Suppress the clang-cl warning for the inline 'new' and 'delete' in mozalloc
519         CXXFLAGS="$CXXFLAGS -Wno-inline-new-delete"
520         # We use offsetof on non-POD objects all the time.
521         # We also suppress this warning on other platforms.
522         CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
523         # This warns for reasonable things like:
524         #   enum { X = 0xffffffffU };
525         # which is annoying for IDL headers.
526         CXXFLAGS="$CXXFLAGS -Wno-microsoft-enum-value"
527         # This warns for cases that would be reached by the Microsoft
528         # #include rules, but also currently warns on cases that would
529         # *also* be reached by standard C++ include rules.  That
530         # behavior doesn't seem useful, so we turn it off.
531         CXXFLAGS="$CXXFLAGS -Wno-microsoft-include"
532         # We normally error out on unknown pragmas, but since clang-cl
533         # claims to be MSVC, it would be difficult to add
534         # #if defined(_MSC_VER) && !defined(__clang__) everywhere we
535         # use such pragmas, so just ignore them.
536         CFLAGS="$CFLAGS -Wno-unknown-pragmas"
537         CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas"
538         # We get errors about various #pragma intrinsic directives from
539         # clang-cl, and we don't need to hear about those.
540         CFLAGS="$CFLAGS -Wno-ignored-pragmas"
541         CXXFLAGS="$CXXFLAGS -Wno-ignored-pragmas"
542         # clang-cl's Intrin.h marks things like _ReadWriteBarrier
543         # as __attribute((__deprecated__)).  This is nice to know,
544         # but since we don't get the equivalent warning from MSVC,
545         # let's just ignore it.
546         CFLAGS="$CFLAGS -Wno-deprecated-declarations"
547         CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"
548         # We use a function like:
549         #   __declspec(noreturn) __inline void f() {}
550         # which -Winvalid-noreturn complains about.  Again, MSVC seems
551         # OK with it, so let's silence the warning.
552         CFLAGS="$CFLAGS -Wno-invalid-noreturn"
553         CXXFLAGS="$CXXFLAGS -Wno-invalid-noreturn"
554         # Missing |override| on virtual function declarations isn't
555         # something that MSVC currently warns about.
556         CXXFLAGS="$CXXFLAGS -Wno-inconsistent-missing-override"
557         # We use -DHAS_EXCEPTIONS=0, which removes the |throw()|
558         # declaration on |operator delete(void*)|.  However, clang-cl
559         # must internally declare |operator delete(void*)| differently,
560         # which causes this warning for virtually every file in the
561         # tree.  clang-cl doesn't support -fno-exceptions or equivalent,
562         # so there doesn't seem to be any way to convince clang-cl to
563         # declare |delete| differently.  Therefore, suppress this
564         # warning.
565         CXXFLAGS="$CXXFLAGS -Wno-implicit-exception-spec-mismatch"
566         # Macros like STDMETHOD() and IFACEMETHOD() can declare
567         # __attribute__((nothrow)) on their respective method declarations,
568         # while the definitions are left without the matching attribute.
569         CXXFLAGS="$CXXFLAGS -Wno-microsoft-exception-spec"
570         # At least one MSVC header and several headers in-tree have
571         # unused typedefs, so turn this on.
572         CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"
573         # jemalloc uses __declspec(allocator) as a profiler hint,
574         # which clang-cl doesn't understand.
575         CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"
576         # __attribute__((unused)) really means "might be unused" and
577         # we use it to avoid warnings about things that are unused
578         # in some compilation units, but used in many others.  This
579         # warning insists on complaining about the latter case, which
580         # is annoying, and rather noisy.
581         CXXFLAGS="$CXXFLAGS -Wno-used-but-marked-unused"
582         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
583         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
584         MOZ_DEBUG_LDFLAGS='-DEBUG'
585         if test "$HOST_OS_ARCH" != "WINNT"; then
586           # %_PDB% is a special signal to emit only the PDB basename. This
587           # avoids problems in Windows tools that don't like forward-slashes.
588           MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
589         fi
590         MOZ_OPTIMIZE_FLAGS='-O2'
591         MOZ_FIX_LINK_PATHS=
592         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
593     fi
594     AC_DEFINE(WIN32_LEAN_AND_MEAN)
595     dnl See http://support.microsoft.com/kb/143208 to use STL
596     AC_DEFINE(NOMINMAX)
597     BIN_SUFFIX='.exe'
599     case "$host_os" in
600     cygwin*|msvc*|mks*)
601         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.])
602         ;;
603     esac
605     case "$target" in
606     i*86-*)
607         if test -n "$GNU_CC"; then
608             CFLAGS="$CFLAGS -mstackrealign"
609             CXXFLAGS="$CXXFLAGS -mstackrealign"
610             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
611         else
612             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
613             LDFLAGS="$LDFLAGS -SAFESEH"
614         fi
616         AC_DEFINE(_X86_)
617         ;;
618     x86_64-*)
619         if test -n "$_WIN32_MSVC"; then
620             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
621         fi
622         AC_DEFINE(_AMD64_)
623         ;;
624     aarch64-*)
625         if test -n "$_WIN32_MSVC"; then
626             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
627         fi
628         AC_DEFINE(_ARM64_)
629         ;;
630     *)
631         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
632         ;;
633     esac
634     ;;
636 *-netbsd*)
637     CFLAGS="$CFLAGS -Dunix"
638     CXXFLAGS="$CXXFLAGS -Dunix"
639     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
640         DSO_PIC_CFLAGS='-fPIC -DPIC'
641         DSO_LDOPTS='-shared'
642         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
643     else
644         DSO_PIC_CFLAGS='-fPIC -DPIC'
645         DSO_LDOPTS='-shared'
646     fi
647     # This will fail on a.out systems prior to 1.5.1_ALPHA.
648     if test "$LIBRUNPATH"; then
649         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
650     fi
651     ;;
653 *-openbsd*)
654     if test -z "$X11BASE"; then
655         X11BASE=/usr/X11R6
656     fi
657     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
658     DSO_PIC_CFLAGS='-fPIC'
659     DSO_LDOPTS='-shared -fPIC'
660     if test "$LIBRUNPATH"; then
661         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
662     fi
663     ;;
665 *-solaris*)
666     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
667     ;;
669 esac
671 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
672 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
674 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
675     MOZ_OPTIMIZE_FLAGS="-O"
679 if test -z "$COMPILE_ENVIRONMENT"; then
680     SKIP_COMPILER_CHECKS=1
681     SKIP_LIBRARY_CHECKS=1
682     MOZ_DEBUGGING_OPTS
683 else
684     MOZ_COMPILER_OPTS
685 fi # COMPILE_ENVIRONMENT
687 if test -z "$SKIP_COMPILER_CHECKS"; then
688 dnl Checks for typedefs, structures, and compiler characteristics.
689 dnl ========================================================
690 AC_C_CONST
691 AC_TYPE_MODE_T
692 AC_TYPE_OFF_T
693 AC_TYPE_PID_T
694 AC_TYPE_SIZE_T
695 AC_LANG_CPLUSPLUS
696 AC_LANG_C
698 AC_LANG_CPLUSPLUS
700 MOZ_CXX11
702 AC_LANG_C
704 case "${OS_TARGET}" in
705 Darwin)
706   ;;
708   STL_FLAGS="-I${DIST}/stl_wrappers"
709   WRAP_STL_INCLUDES=1
710   ;;
711 esac
713 if test "$MOZ_BUILD_APP" = "tools/crashreporter/injector"; then
714     WRAP_STL_INCLUDES=
717 dnl Checks for header files.
718 dnl ========================================================
719 AC_HEADER_DIRENT
721 dnl Checks for libraries.
722 dnl ========================================================
723 AC_CHECK_LIB(c_r, gethostbyname_r)
725 dnl We don't want to link with libdl even if it's present on OS X, since
726 dnl it's not used and not part of the default installation. OS/2 has dlfcn
727 dnl in libc.
728 dnl We don't want to link against libm or libpthread on Darwin since
729 dnl they both are just symlinks to libSystem and explicitly linking
730 dnl against libSystem causes issues when debugging (see bug 299601).
731 case $target in
732 *-darwin*)
733     ;;
735     AC_SEARCH_LIBS(dlopen, dl,
736         MOZ_CHECK_HEADER(dlfcn.h,
737         AC_DEFINE(HAVE_DLOPEN)))
738     ;;
739 esac
741 _SAVE_CFLAGS="$CFLAGS"
742 CFLAGS="$CFLAGS -D_GNU_SOURCE"
743 AC_CHECK_FUNCS(dladdr)
744 CFLAGS="$_SAVE_CFLAGS"
746 if test ! "$GNU_CXX"; then
747     AC_CHECK_LIB(C, demangle)
750 AC_CHECK_LIB(socket, socket)
752 dnl ========================================================
753 dnl = pthread support
754 dnl = Start by checking whether the system support pthreads
755 dnl ========================================================
756 case "$target_os" in
757 darwin*)
758     MOZ_USE_PTHREADS=1
759     ;;
761     AC_CHECK_LIB(pthreads, pthread_create,
762         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
763         AC_CHECK_LIB(pthread, pthread_create,
764             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
765             AC_CHECK_LIB(c_r, pthread_create,
766                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
767                 AC_CHECK_LIB(c, pthread_create,
768                     MOZ_USE_PTHREADS=1
769                 )
770             )
771         )
772     )
773     ;;
774 esac
776 dnl ========================================================
777 dnl Do the platform specific pthread hackery
778 dnl ========================================================
779 if test "$MOZ_USE_PTHREADS"x != x
780 then
781     dnl
782     dnl See if -pthread is supported.
783     dnl
784     rm -f conftest*
785     ac_cv_have_dash_pthread=no
786     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
787     echo 'int main() { return 0; }' | cat > conftest.c
788     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
789     if test $? -eq 0; then
790         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
791             ac_cv_have_dash_pthread=yes
792             case "$target_os" in
793             freebsd*)
794 # Freebsd doesn't use -pthread for compiles, it uses them for linking
795                 ;;
796             *)
797                 CFLAGS="$CFLAGS -pthread"
798                 CXXFLAGS="$CXXFLAGS -pthread"
799                 ;;
800             esac
801         fi
802     fi
803     rm -f conftest*
804     AC_MSG_RESULT($ac_cv_have_dash_pthread)
806     dnl
807     dnl See if -pthreads is supported.
808     dnl
809     ac_cv_have_dash_pthreads=no
810     if test "$ac_cv_have_dash_pthread" = "no"; then
811         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
812         echo 'int main() { return 0; }' | cat > conftest.c
813         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
814         if test $? -eq 0; then
815             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
816                 ac_cv_have_dash_pthreads=yes
817                 CFLAGS="$CFLAGS -pthreads"
818                 CXXFLAGS="$CXXFLAGS -pthreads"
819             fi
820         fi
821         rm -f conftest*
822         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
823     fi
825     case "$target" in
826         *-*-freebsd*)
827             AC_DEFINE(_REENTRANT)
828             AC_DEFINE(_THREAD_SAFE)
829             dnl -pthread links in -lpthread, so don't specify it explicitly.
830             if test "$ac_cv_have_dash_pthread" = "yes"; then
831                 _PTHREAD_LDFLAGS="-pthread"
832             fi
833             ;;
835         *-*-openbsd*|*-*-bsdi*)
836             AC_DEFINE(_REENTRANT)
837             AC_DEFINE(_THREAD_SAFE)
838             dnl -pthread links in -lc_r, so don't specify it explicitly.
839             if test "$ac_cv_have_dash_pthread" = "yes"; then
840                 _PTHREAD_LDFLAGS="-pthread"
841             fi
842             ;;
844         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
845             AC_DEFINE(_REENTRANT)
846             ;;
848     esac
849     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
850     AC_SUBST(MOZ_USE_PTHREADS)
851     MOZ_CHECK_HEADERS(pthread.h)
855 dnl Checks for library functions.
856 dnl ========================================================
858 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
859 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
860                ac_cv_clock_monotonic,
861                [for libs in "" -lrt; do
862                     _SAVE_LIBS="$LIBS"
863                     LIBS="$LIBS $libs"
864 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
865 dnl we should or not be able to use it. To detect if we can, we need to make the
866 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
867                     AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
868                                  #include <time.h>],
869                                  [ struct timespec ts;
870                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
871                                  ac_cv_clock_monotonic=$libs
872                                  LIBS="$_SAVE_LIBS"
873                                  break,
874                                  ac_cv_clock_monotonic=no)
875                     LIBS="$_SAVE_LIBS"
876                 done])
877 if test "$ac_cv_clock_monotonic" != "no"; then
878     HAVE_CLOCK_MONOTONIC=1
879     REALTIME_LIBS=$ac_cv_clock_monotonic
880     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
881     AC_SUBST(HAVE_CLOCK_MONOTONIC)
882     AC_SUBST_LIST(REALTIME_LIBS)
885 AC_CACHE_CHECK(
886     [for res_ninit()],
887     ac_cv_func_res_ninit,
888     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
889         dnl no need for res_ninit() on NetBSD and OpenBSD
890         ac_cv_func_res_ninit=no
891      else
892         AC_TRY_LINK([
893             #ifdef linux
894             #define _BSD_SOURCE 1
895             #endif
896             #include <sys/types.h>
897             #include <netinet/in.h>
898             #include <arpa/nameser.h>
899             #include <resolv.h>
900             ],
901             [int foo = res_ninit(&_res);],
902             [ac_cv_func_res_ninit=yes],
903             [ac_cv_func_res_ninit=no])
904      fi
905     ])
907 if test "$ac_cv_func_res_ninit" = "yes"; then
908     AC_DEFINE(HAVE_RES_NINIT)
909 dnl must add the link line we do something as foolish as this... dougt
910 dnl else
911 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
912 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
915 AC_LANG_C
917 dnl ===================================================================
918 dnl ========================================================
919 dnl Put your C++ language/feature checks below
920 dnl ========================================================
921 AC_LANG_CPLUSPLUS
923 ARM_ABI_PREFIX=
924 if test "$GNU_CC"; then
925   if test "$CPU_ARCH" = "arm" ; then
926     AC_CACHE_CHECK(for ARM EABI,
927         ac_cv_gcc_arm_eabi,
928         [AC_TRY_COMPILE([],
929                         [
930 #if defined(__ARM_EABI__)
931   return 0;
932 #else
933 #error Not ARM EABI.
934 #endif
935                         ],
936                         ac_cv_gcc_arm_eabi="yes",
937                         ac_cv_gcc_arm_eabi="no")])
938     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
939         HAVE_ARM_EABI=1
940         ARM_ABI_PREFIX=eabi-
941     else
942         ARM_ABI_PREFIX=oabi-
943     fi
944   fi
946   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
949 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
950 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
951 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
952 # linking XUL.
953 _SAVE_LDFLAGS=$LDFLAGS
954 LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
955 AC_CACHE_CHECK(for __thread keyword for TLS variables,
956                ac_cv_thread_keyword,
957                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
958                             [return tlsIsMainThread;],
959                             ac_cv_thread_keyword=yes,
960                             ac_cv_thread_keyword=no)])
961 LDFLAGS=$_SAVE_LDFLAGS
962 # The custom dynamic linker doesn't support TLS variables
963 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
964   # mips builds fail with TLS variables because of a binutils bug.
965   # See bug 528687
966   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
967   case "${target}" in
968     mips*-*)
969       :
970       ;;
971     *-android*|*-linuxandroid*)
972       :
973       ;;
974     *-openbsd*)
975       :
976       ;;
977     *)
978       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
979       ;;
980   esac
983 if test -n "$MOZ_LINKER"; then
984 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
985 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
986 dnl Since the linker only understands the sysv ones, no need to build the
987 dnl gnu style tables anyways.
988   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
991 dnl End of C++ language/feature checks
992 AC_LANG_C
994 fi # ! SKIP_COMPILER_CHECKS
996 if test -n "${COMPILE_ENVIRONMENT}"; then
997   MOZ_CHECK_ALLOCATOR
1000 TARGET_XPCOM_ABI=
1001 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
1002     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
1003     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
1006 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
1007 dnl features that Windows actually does support.
1009 if test -n "$SKIP_COMPILER_CHECKS"; then
1010    dnl Windows has malloc.h
1011    AC_DEFINE(MALLOC_H, [<malloc.h>])
1012    AC_DEFINE(HAVE_FORCEINLINE)
1013 fi # SKIP_COMPILER_CHECKS
1015 dnl Mozilla specific options
1016 dnl ========================================================
1017 dnl The macros used for command line options
1018 dnl are defined in build/autoconf/altoptions.m4.
1020 dnl ========================================================
1021 dnl =
1022 dnl = Application
1023 dnl =
1024 dnl ========================================================
1026 MOZ_BRANDING_DIRECTORY=
1027 MOZ_OFFICIAL_BRANDING=
1028 MOZ_NO_SMART_CARDS=
1029 MOZ_BINARY_EXTENSIONS=
1030 MOZ_DEVTOOLS=server
1032 dnl ========================================================
1033 dnl = Trademarked Branding
1034 dnl ========================================================
1035 MOZ_ARG_ENABLE_BOOL(official-branding,
1036 [  --enable-official-branding
1037                           Enable Official mozilla.org Branding
1038                           Do not distribute builds with
1039                           --enable-official-branding unless you have
1040                           permission to use trademarks per
1041                           http://www.mozilla.org/foundation/trademarks/ .],
1042     MOZ_OFFICIAL_BRANDING=1,
1043     MOZ_OFFICIAL_BRANDING=)
1045 # Allow the application to influence configure with a confvars.sh script.
1046 AC_MSG_CHECKING([if app-specific confvars.sh exists])
1047 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
1048   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
1049   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
1050 else
1051   AC_MSG_RESULT([no])
1054 AC_SUBST(MOZ_OFFICIAL_BRANDING)
1055 if test -n "$MOZ_OFFICIAL_BRANDING"; then
1056   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
1057     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
1058   else
1059     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
1060     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
1061   fi
1064 MOZ_ARG_WITH_STRING(branding,
1065 [  --with-branding=dir     Use branding from the specified directory.],
1066     MOZ_BRANDING_DIRECTORY=$withval)
1068 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
1069 if test -z "$REAL_BRANDING_DIRECTORY"; then
1070   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
1073 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
1074   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
1077 AC_SUBST(MOZ_BRANDING_DIRECTORY)
1079 dnl ========================================================
1080 dnl = Distribution ID
1081 dnl ========================================================
1082 MOZ_ARG_WITH_STRING(distribution-id,
1083 [  --with-distribution-id=ID
1084                           Set distribution-specific id (default=org.mozilla)],
1085 [ val=`echo $withval`
1086     MOZ_DISTRIBUTION_ID="$val"])
1088 if test -z "$MOZ_DISTRIBUTION_ID"; then
1089    MOZ_DISTRIBUTION_ID="org.mozilla"
1092 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
1093 AC_SUBST(MOZ_DISTRIBUTION_ID)
1095 dnl ========================================================
1096 dnl = Enable code optimization. ON by default.
1097 dnl ========================================================
1099 # Use value from moz.configure if one is defined. Else use our computed
1100 # value.
1101 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
1102     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
1105 if test "$COMPILE_ENVIRONMENT"; then
1106 if test -n "$MOZ_OPTIMIZE"; then
1107     AC_MSG_CHECKING([for valid C compiler optimization flags])
1108     _SAVE_CFLAGS=$CFLAGS
1109     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
1110     AC_TRY_COMPILE([#include <stdio.h>],
1111         [printf("Hello World\n");],
1112         _results=yes,
1113         _results=no)
1114     AC_MSG_RESULT([$_results])
1115     if test "$_results" = "no"; then
1116         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
1117     fi
1118     CFLAGS=$_SAVE_CFLAGS
1119     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
1120         # When using llvm-based LTO, non numeric optimization levels are
1121         # not supported by the linker, so force the linker to use -O2 (
1122         # which doesn't influence the level compilation units are actually
1123         # compiled at).
1124         case " $MOZ_OPTIMIZE_FLAGS " in
1125         *\ -Os\ *|*\ -Oz\ *)
1126             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
1127             ;;
1128         esac
1129     fi
1131 fi # COMPILE_ENVIRONMENT
1133 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
1134 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
1135 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
1137 case "${OS_TARGET}" in
1138 Android|WINNT|Darwin)
1139   MOZ_GLUE_IN_PROGRAM=
1140   ;;
1142   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
1143   MOZ_GLUE_IN_PROGRAM=1
1144   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
1145   ;;
1146 esac
1148 dnl ========================================================
1149 dnl = Jemalloc build setup
1150 dnl ========================================================
1151 if test -z "$MOZ_MEMORY"; then
1152   case "${target}" in
1153     *-mingw*)
1154       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
1155         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.])
1156       fi
1157       ;;
1158   esac
1159 else
1160   dnl The generic feature tests that determine how to compute ncpus are long and
1161   dnl complicated.  Therefore, simply define special cpp variables for the
1162   dnl platforms we have special knowledge of.
1163   case "${target}" in
1164   *-mingw*)
1165     export MOZ_NO_DEBUG_RTL=1
1166     ;;
1167   esac
1168 fi # MOZ_MEMORY
1169 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
1171 dnl ========================================================
1172 dnl = Enable using the clang plugin to build
1173 dnl ========================================================
1175 if test -n "$COMPILE_ENVIRONMENT"; then
1176 MOZ_CONFIG_CLANG_PLUGIN
1177 fi # COMPILE_ENVIRONMENT
1179 if test -z "$SKIP_COMPILER_CHECKS"; then
1180 dnl ========================================================
1181 dnl Check for gcc -pipe support
1182 dnl ========================================================
1183 AC_MSG_CHECKING([for -pipe support])
1184 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
1185     dnl Any gcc that supports firefox supports -pipe.
1186     CFLAGS="$CFLAGS -pipe"
1187     CXXFLAGS="$CXXFLAGS -pipe"
1188     AC_MSG_RESULT([yes])
1189 else
1190     AC_MSG_RESULT([no])
1193 fi # ! SKIP_COMPILER_CHECKS
1195 AC_LANG_C
1197 if test "$COMPILE_ENVIRONMENT"; then
1198 MOZ_EXPAND_LIBS
1199 fi # COMPILE_ENVIRONMENT
1201 dnl ========================================================
1202 dnl Check if we need the 32-bit Linux SSE2 error dialog
1203 dnl ========================================================
1205 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
1207 dnl ========================================================
1208 dnl Check for cairo
1209 dnl ========================================================
1211 if test "$OS_ARCH" = "WINNT"; then
1212     # For now we assume that we will have a uint64_t available through
1213     # one of the above headers or mozstdint.h.
1214     AC_DEFINE(HAVE_UINT64_T)
1217 case "$MOZ_WIDGET_TOOLKIT" in
1218   windows)
1219     if test "$COMPILE_ENVIRONMENT"; then
1220       MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
1221     fi
1222     ;;
1223 esac
1224 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
1226 dnl ========================================================
1227 dnl =
1228 dnl = Maintainer debug option (no --enable equivalent)
1229 dnl =
1230 dnl ========================================================
1232 AC_SUBST_LIST(ASFLAGS)
1233 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
1234 AC_SUBST_LIST(WARNINGS_CFLAGS)
1236 AC_SUBST(MOZ_STUB_INSTALLER)
1238 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
1240 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
1242 if test -n "$MOZ_BINARY_EXTENSIONS"; then
1243   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
1246 dnl ========================================================
1247 dnl = Mac bundle name prefix
1248 dnl ========================================================
1249 MOZ_ARG_WITH_STRING(macbundlename-prefix,
1250 [  --with-macbundlename-prefix=prefix
1251                           Prefix for MOZ_MACBUNDLE_NAME],
1252 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
1254 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
1255 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
1256   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
1259 if test "$MOZ_DEBUG"; then
1260   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
1261 else
1262   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
1264 AC_SUBST(MOZ_MACBUNDLE_NAME)
1266 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
1267 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
1268 # Otherwise, use MOZ_APP_DISPLAYNAME
1269 if test -z "$MOZ_MACBUNDLE_ID"; then
1270    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
1272 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
1273 if test "$MOZ_DEBUG"; then
1274   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
1277 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
1278 AC_SUBST(MOZ_MACBUNDLE_ID)
1280 dnl ========================================================
1281 dnl = Child Process Name for IPC
1282 dnl ========================================================
1283 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
1284   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
1285 else
1286   # We want to let Android unpack the file at install time, but it only does
1287   # so if the file is named libsomething.so. The lib/ path is also required
1288   # because the unpacked file will be under the lib/ subdirectory and will
1289   # need to be executed from that path.
1290   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
1292 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
1293 MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
1295 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
1296 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
1297 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
1299 # The following variables are available to branding and application
1300 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
1301 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
1302 # impacts profile location and user-visible fields.
1303 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
1304 # Mac Bundle name, Updater, Installer), it is typically used for nightly
1305 # builds (e.g. Aurora for Firefox).
1306 # - MOZ_APP_PROFILE: When set, used for application.ini's
1307 # "Profile" field, which controls profile location.
1308 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
1309 # crash reporter server url.
1310 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
1312 # The following environment variables used to have an effect, but don't anymore:
1313 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
1314 # the contents from the version.txt file in the application directory, or
1315 # browser/config/version.txt if there isn't one.
1316 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
1317 # in the "About" window. This was replaced with the contents from the
1318 # version_display.txt or version.txt in the application directory, or
1319 # browser/config/version_display.txt.
1321 # For extensions and langpacks, we require a max version that is compatible
1322 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
1323 # 24.0a1 and 24.0a2 aren't affected
1324 # 24.0 becomes 24.*
1325 # 24.1.1 becomes 24.*
1326 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
1327 if test -z "$IS_ALPHA"; then
1328   changequote(,)
1329   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
1330     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
1331   else
1332     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
1333   fi
1334   changequote([,])
1335 else
1336   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
1339 AC_SUBST(MOZ_APP_DISPLAYNAME)
1340 AC_SUBST(MOZ_APP_VENDOR)
1341 AC_SUBST(MOZ_APP_PROFILE)
1342 AC_SUBST(MOZ_APP_ID)
1343 AC_SUBST(MAR_CHANNEL_ID)
1344 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
1345 AC_SUBST(MOZ_PROFILE_MIGRATOR)
1346 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
1347 AC_SUBST(MOZ_APP_UA_NAME)
1348 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
1349 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
1350 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
1352 AC_SUBST(MOZ_APP_MAXVERSION)
1353 AC_SUBST(MOZ_PKG_SPECIAL)
1354 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
1356 if test "$MOZILLA_OFFICIAL"; then
1357     # Build revisions should always be present in official builds
1358     MOZ_INCLUDE_SOURCE_INFO=1
1361 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
1362 # explicitly set the repository and changeset information in.
1363 AC_SUBST(MOZ_SOURCE_REPO)
1364 AC_SUBST(MOZ_SOURCE_CHANGESET)
1365 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
1367 dnl If we have any service that uploads data (and requires data submission
1368 dnl policy alert), set MOZ_DATA_REPORTING.
1369 dnl We need SUBST for build system and DEFINE for xul preprocessor.
1370 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"  || test -n "$MOZ_NORMANDY"; then
1371   MOZ_DATA_REPORTING=1
1372   AC_DEFINE(MOZ_DATA_REPORTING)
1373   AC_SUBST(MOZ_DATA_REPORTING)
1376 dnl win32 options
1377 AC_SUBST(WIN32_REDIST_DIR)
1378 AC_SUBST(WIN_UCRT_REDIST_DIR)
1380 dnl Echo the CFLAGS to remove extra whitespace.
1381 CFLAGS=`echo \
1382     $_COMPILATION_CFLAGS \
1383     $CFLAGS`
1385 CXXFLAGS=`echo \
1386     $_WARNINGS_CXXFLAGS \
1387     $_COMPILATION_CXXFLAGS \
1388     $CXXFLAGS`
1390 COMPILE_CFLAGS=`echo \
1391     $_DEFINES_CFLAGS \
1392     $COMPILE_CFLAGS`
1394 COMPILE_CXXFLAGS=`echo \
1395     $_DEFINES_CXXFLAGS \
1396     $COMPILE_CXXFLAGS`
1398 HOST_CFLAGS=`echo \
1399     $_WARNINGS_HOST_CFLAGS \
1400     $_COMPILATION_HOST_CFLAGS \
1401     $HOST_CFLAGS`
1403 HOST_CXXFLAGS=`echo \
1404     $_WARNINGS_HOST_CXXFLAGS \
1405     $_COMPILATION_HOST_CXXFLAGS \
1406     $HOST_CXXFLAGS`
1408 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
1409 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1410 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
1411 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1412 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
1413   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1414   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1416 AC_SUBST(HOST_CMFLAGS)
1417 AC_SUBST(HOST_CMMFLAGS)
1418 AC_SUBST(OS_COMPILE_CMFLAGS)
1419 AC_SUBST(OS_COMPILE_CMMFLAGS)
1421 OS_CFLAGS="$CFLAGS"
1422 OS_CXXFLAGS="$CXXFLAGS"
1423 OS_CPPFLAGS="$CPPFLAGS"
1424 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1425 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1426 OS_LDFLAGS="$LDFLAGS"
1427 OS_LIBS="$LIBS"
1428 AC_SUBST_LIST(OS_CFLAGS)
1429 AC_SUBST_LIST(OS_CXXFLAGS)
1430 AC_SUBST_LIST(OS_CPPFLAGS)
1431 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1432 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1433 AC_SUBST_LIST(OS_LDFLAGS)
1434 AC_SUBST(OS_LIBS)
1436 AC_SUBST(HOST_CC)
1437 AC_SUBST(HOST_CXX)
1438 AC_SUBST_LIST(HOST_CFLAGS)
1439 AC_SUBST_LIST(HOST_CPPFLAGS)
1440 AC_SUBST_LIST(HOST_CXXFLAGS)
1441 AC_SUBST(HOST_LDFLAGS)
1442 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1443 AC_SUBST(HOST_BIN_SUFFIX)
1445 AC_SUBST(TARGET_XPCOM_ABI)
1447 AC_SUBST(DSO_LDOPTS)
1448 AC_SUBST(BIN_SUFFIX)
1449 AC_SUBST(USE_N32)
1450 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1451 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1453 AC_SUBST(MOZ_DEVTOOLS)
1455 AC_SUBST(MOZ_PACKAGE_JSSHELL)
1457 AC_SUBST(DMG_TOOL)
1459 dnl Host JavaScript runtime, if any, to use during cross compiles.
1460 AC_SUBST(JS_BINARY)
1462 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
1464 dnl Set various defines and substitutions
1465 dnl ========================================================
1467 AC_SUBST(MOZ_DEV_EDITION)
1468 if test -n "$MOZ_DEV_EDITION"; then
1469     AC_DEFINE(MOZ_DEV_EDITION)
1472 dnl Windows AccessibilityHandler
1473 dnl ========================================================
1475 if test -z "$MOZ_HANDLER_CLSID"; then
1476     MOZ_HANDLER_CLSID="4a195748-dca2-45fb-9295-0a139e76a9e7"
1477     MOZ_IHANDLERCONTROL_IID="3316ce35-f892-4832-97c5-06c52c03cdba"
1478     MOZ_ASYNCIHANDLERCONTROL_IID="15b48b76-ad38-4ad3-bd1a-d3c48a5a9947"
1479     MOZ_IGECKOBACKCHANNEL_IID="dd2e4a89-999e-4d65-8b65-440c923ddb61"
1482 AC_SUBST(MOZ_HANDLER_CLSID)
1483 AC_SUBST(MOZ_IHANDLERCONTROL_IID)
1484 AC_SUBST(MOZ_ASYNCIHANDLERCONTROL_IID)
1485 AC_SUBST(MOZ_IGECKOBACKCHANNEL_IID)
1487 dnl Spit out some output
1488 dnl ========================================================
1490 # Avoid using obsolete NSPR features
1491 AC_DEFINE(NO_NSPR_10_SUPPORT)
1493 MOZ_CREATE_CONFIG_STATUS()
1495 rm -fr confdefs* $ac_clean_files