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