Bug 1794939 [wpt PR 36423] - [GridFragmentation] OOF static position when CB is outsi...
[gecko.git] / old-configure.in
blobbb650af545316ecc6b315dfde19de573eef606f6
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 if test -n "$COMPILE_ENVIRONMENT"; then
218    MOZ_CONFIG_SANITIZE
221 dnl ========================================================
222 dnl GNU specific defaults
223 dnl ========================================================
224 if test "$GNU_CC"; then
225     if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
226         DSO_PIC_CFLAGS='-fPIC'
227         ASFLAGS="$ASFLAGS -fPIC"
228     fi
230     AC_MSG_CHECKING([for --noexecstack option to as])
231     _SAVE_CFLAGS=$CFLAGS
232     CFLAGS="$CFLAGS -Wa,--noexecstack"
233     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
234                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
235                      AC_MSG_RESULT([no]))
236     CFLAGS=$_SAVE_CFLAGS
237     AC_MSG_CHECKING([for -z noexecstack option to ld])
238     _SAVE_LDFLAGS=$LDFLAGS
239     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
240     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
241                   AC_MSG_RESULT([no])
242                   LDFLAGS=$_SAVE_LDFLAGS)
244     AC_MSG_CHECKING([for -z text option to ld])
245     _SAVE_LDFLAGS=$LDFLAGS
246     LDFLAGS="$LDFLAGS -Wl,-z,text"
247     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
248                   AC_MSG_RESULT([no])
249                   LDFLAGS=$_SAVE_LDFLAGS)
251     AC_MSG_CHECKING([for -z relro option to ld])
252     _SAVE_LDFLAGS=$LDFLAGS
253     LDFLAGS="$LDFLAGS -Wl,-z,relro"
254     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
255                   AC_MSG_RESULT([no])
256                   LDFLAGS=$_SAVE_LDFLAGS)
258     AC_MSG_CHECKING([for -z nocopyreloc option to ld])
259     _SAVE_LDFLAGS=$LDFLAGS
260     LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
261     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
262                   AC_MSG_RESULT([no])
263                   LDFLAGS=$_SAVE_LDFLAGS)
265     AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
266     _SAVE_LDFLAGS=$LDFLAGS
267     LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
268     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
269                   AC_MSG_RESULT([no])
270                   LDFLAGS=$_SAVE_LDFLAGS)
272     AC_MSG_CHECKING([for --build-id=sha1 option to ld])
273     _SAVE_LDFLAGS=$LDFLAGS
274     LDFLAGS="$LDFLAGS -Wl,--build-id=sha1"
275     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
276                   AC_MSG_RESULT([no])
277                   LDFLAGS=$_SAVE_LDFLAGS)
279     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
280     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
281     _SAVE_LDFLAGS=$LDFLAGS
282     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
283     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
284                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
285                   AC_MSG_RESULT([no]))
286     LDFLAGS=$_SAVE_LDFLAGS
288     DSO_LDOPTS='-shared'
289     if test "$GCC_USE_GNU_LD"; then
290         # Some tools like ASan use a runtime library that is only
291         # linked against executables, so we must allow undefined
292         # symbols for shared objects in some cases.
293         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
294             # Don't allow undefined symbols in libraries
295             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
297             # BSDs need `environ' exposed for posix_spawn (bug 753046)
298             case "$OS_TARGET" in
299             DragonFly|FreeBSD|NetBSD|OpenBSD)
300                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
301                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
302                 else
303                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
304                 fi
305                 ;;
306             esac
307         fi
308     fi
310     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
312     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
315 if test "$GNU_CXX"; then
316     CXXFLAGS="$CXXFLAGS -fno-exceptions"
318     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
321 dnl ========================================================
322 dnl System overrides of the defaults for host
323 dnl ========================================================
324 case "$host" in
325 *mingw*)
326     if test -n "$_WIN32_MSVC"; then
327         HOST_CFLAGS="$HOST_CFLAGS"
328     else
329         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
330     fi
331     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
332     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
333     HOST_BIN_SUFFIX=.exe
335     case "${host_cpu}" in
336     i*86)
337         if test -n "$_WIN32_MSVC"; then
338             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
339         fi
340         ;;
341     x86_64)
342         if test -n "$_WIN32_MSVC"; then
343             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
344         fi
345         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
346         ;;
347     esac
348     ;;
350 *-darwin*)
351     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
352     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
353     ;;
355 *-linux*|*-kfreebsd*-gnu|*-gnu*)
356     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
357     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
358     ;;
361     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
362     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
363     ;;
364 esac
366 dnl ========================================================
367 dnl System overrides of the defaults for target
368 dnl ========================================================
370 case "$target" in
371 *-darwin*)
372     MOZ_OPTIMIZE_FLAGS="-O3"
373     DSO_LDOPTS=''
375     dnl DTrace and -dead_strip don't interact well. See bug 403132.
376     dnl ===================================================================
377     if test "x$enable_dtrace" = "xyes"; then
378         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
379     else
380         dnl check for the presence of the -dead_strip linker flag
381         AC_MSG_CHECKING([for -dead_strip option to ld])
382         _SAVE_LDFLAGS=$LDFLAGS
383         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
384         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
385         if test -n "$_HAVE_DEAD_STRIP" ; then
386             AC_MSG_RESULT([yes])
387             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
388         else
389             AC_MSG_RESULT([no])
390         fi
392         LDFLAGS=$_SAVE_LDFLAGS
393     fi
395     MOZ_FIX_LINK_PATHS=
396     ;;
398 *-android*|*-linuxandroid*)
399     if test -z "$CLANG_CC"; then
400         MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
401     else
402         # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
403         # -Oz is smaller than -Os on clang.
404         MOZ_OPTIMIZE_FLAGS="-Oz"
405         # Disable the outliner, which causes performance regressions, and is
406         # enabled on some platforms at -Oz.
407         if test -z "$MOZ_LTO"; then
408             DISABLE_OUTLINER="-mno-outline"
409             _SAVE_CFLAGS=$CFLAGS
410             CFLAGS="$CFLAGS $DISABLE_OUTLINER"
411             AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
412             CFLAGS="$_SAVE_CFLAGS"
413         else
414             DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
415             _SAVE_LDFLAGS=$LDFLAGS
416             LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
417             AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
418             LDFLAGS="$_SAVE_LDFLAGS"
419         fi
420     fi
421     ;;
423 *-*linux*)
424     if test "$GNU_CC" -o "$GNU_CXX"; then
425         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
426         if test -n "$MOZ_DEBUG"; then
427             MOZ_OPTIMIZE_FLAGS="-Os"
428         else
429             MOZ_OPTIMIZE_FLAGS="-O2"
430         fi
431         if test -z "$CLANG_CC"; then
432            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
433         fi
434     fi
436     case "${target_cpu}" in
437     alpha*)
438         CFLAGS="$CFLAGS -mieee"
439         CXXFLAGS="$CXXFLAGS -mieee"
440     ;;
441     esac
442     ;;
443 *-mingw*)
444     DSO_PIC_CFLAGS=
445     # certain versions of cygwin's makedepend barf on the
446     # #include <string> vs -I./dist/include/string issue so don't use it
447     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
448         # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
449         if test -z "$CLANG_CC"; then
450             AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
451         fi
453         DSO_LDOPTS='-shared'
454         MOZ_FIX_LINK_PATHS=
456         MOZ_OPTIMIZE_FLAGS="-O2"
458         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
459         WIN32_GUI_EXE_LDFLAGS=-mwindows
461         # Silence problematic clang warnings
462         CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
463         LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
464     else
465         TARGET_COMPILER_ABI=msvc
466         # aarch64 doesn't support subsystems below 6.02
467         if test "$CPU_ARCH" = "aarch64"; then
468             WIN32_SUBSYSTEM_VERSION=6.02
469         else
470             WIN32_SUBSYSTEM_VERSION=6.01
471         fi
472         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
473         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
474         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
475         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
476         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
477         CFLAGS="$CFLAGS -Gy -Zc:inline"
478         CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
479         if test "$CPU_ARCH" = "x86"; then
480             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
481             dnl more recent, so set that explicitly here unless another
482             dnl target arch has already been set.
483             changequote(,)
484             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
485               CFLAGS="$CFLAGS -arch:SSE2"
486             fi
487             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
488               CXXFLAGS="$CXXFLAGS -arch:SSE2"
489             fi
490             changequote([,])
491         fi
492         dnl VS2013+ supports -Gw for better linker optimizations.
493         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
494         dnl Disabled on ASan because it causes false-positive ODR violations.
495         if test -z "$MOZ_ASAN"; then
496             CFLAGS="$CFLAGS -Gw"
497             CXXFLAGS="$CXXFLAGS -Gw"
498         else
499             # String tail merging doesn't play nice with ASan's ODR checker.
500             LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
501         fi
502         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
503         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
504         MOZ_DEBUG_LDFLAGS='-DEBUG'
505         if test "$HOST_OS_ARCH" != "WINNT"; then
506           # %_PDB% is a special signal to emit only the PDB basename. This
507           # avoids problems in Windows tools that don't like forward-slashes.
508           MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
509         fi
510         MOZ_OPTIMIZE_FLAGS='-O2'
511         MOZ_FIX_LINK_PATHS=
512         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
513     fi
514     AC_DEFINE(WIN32_LEAN_AND_MEAN)
515     dnl See http://support.microsoft.com/kb/143208 to use STL
516     AC_DEFINE(NOMINMAX)
517     BIN_SUFFIX='.exe'
519     case "$host_os" in
520     cygwin*|msvc*|mks*)
521         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.])
522         ;;
523     esac
525     case "$target" in
526     i*86-*)
527         if test -n "$GNU_CC"; then
528             CFLAGS="$CFLAGS -mstackrealign"
529             CXXFLAGS="$CXXFLAGS -mstackrealign"
530             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
531         else
532             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
533             LDFLAGS="$LDFLAGS -SAFESEH"
534         fi
536         AC_DEFINE(_X86_)
537         ;;
538     x86_64-*)
539         if test -n "$_WIN32_MSVC"; then
540             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
541         fi
542         AC_DEFINE(_AMD64_)
543         ;;
544     aarch64-*)
545         if test -n "$_WIN32_MSVC"; then
546             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
547         fi
548         AC_DEFINE(_ARM64_)
549         ;;
550     *)
551         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
552         ;;
553     esac
554     ;;
556 *-netbsd*)
557     CFLAGS="$CFLAGS -Dunix"
558     CXXFLAGS="$CXXFLAGS -Dunix"
559     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
560         DSO_PIC_CFLAGS='-fPIC -DPIC'
561         DSO_LDOPTS='-shared'
562         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
563     else
564         DSO_PIC_CFLAGS='-fPIC -DPIC'
565         DSO_LDOPTS='-shared'
566     fi
567     # This will fail on a.out systems prior to 1.5.1_ALPHA.
568     if test "$LIBRUNPATH"; then
569         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
570     fi
571     ;;
573 *-openbsd*)
574     if test -z "$X11BASE"; then
575         X11BASE=/usr/X11R6
576     fi
577     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
578     DSO_PIC_CFLAGS='-fPIC'
579     DSO_LDOPTS='-shared -fPIC'
580     if test "$LIBRUNPATH"; then
581         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
582     fi
583     ;;
585 *-solaris*)
586     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
587     ;;
589 esac
591 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
592 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
594 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
595     MOZ_OPTIMIZE_FLAGS="-O"
599 if test -z "$COMPILE_ENVIRONMENT"; then
600     SKIP_COMPILER_CHECKS=1
601     SKIP_LIBRARY_CHECKS=1
602     MOZ_DEBUGGING_OPTS
603 else
604     MOZ_COMPILER_OPTS
605 fi # COMPILE_ENVIRONMENT
607 if test -z "$SKIP_COMPILER_CHECKS"; then
608 dnl Checks for typedefs, structures, and compiler characteristics.
609 dnl ========================================================
610 AC_C_CONST
611 AC_TYPE_MODE_T
612 AC_TYPE_OFF_T
613 AC_TYPE_PID_T
614 AC_TYPE_SIZE_T
615 AC_LANG_CPLUSPLUS
616 AC_LANG_C
618 AC_LANG_CPLUSPLUS
620 MOZ_CXX11
622 AC_LANG_C
624 case "${OS_TARGET}" in
625 Darwin)
626   ;;
628   STL_FLAGS="-I${DIST}/stl_wrappers"
629   WRAP_STL_INCLUDES=1
630   ;;
631 esac
633 if test "$MOZ_BUILD_APP" = "tools/crashreporter/injector"; then
634     WRAP_STL_INCLUDES=
637 dnl Checks for header files.
638 dnl ========================================================
639 AC_HEADER_DIRENT
641 dnl Checks for libraries.
642 dnl ========================================================
643 AC_CHECK_LIB(c_r, gethostbyname_r)
645 dnl We don't want to link with libdl even if it's present on OS X, since
646 dnl it's not used and not part of the default installation. OS/2 has dlfcn
647 dnl in libc.
648 dnl We don't want to link against libm or libpthread on Darwin since
649 dnl they both are just symlinks to libSystem and explicitly linking
650 dnl against libSystem causes issues when debugging (see bug 299601).
651 case $target in
652 *-darwin*)
653     ;;
655     AC_SEARCH_LIBS(dlopen, dl,
656         MOZ_CHECK_HEADER(dlfcn.h,
657         AC_DEFINE(HAVE_DLOPEN)))
658     ;;
659 esac
661 _SAVE_CFLAGS="$CFLAGS"
662 CFLAGS="$CFLAGS -D_GNU_SOURCE"
663 AC_CHECK_FUNCS(dladdr)
664 CFLAGS="$_SAVE_CFLAGS"
666 if test ! "$GNU_CXX"; then
667     AC_CHECK_LIB(C, demangle)
670 AC_CHECK_LIB(socket, socket)
672 dnl ========================================================
673 dnl = pthread support
674 dnl = Start by checking whether the system support pthreads
675 dnl ========================================================
676 case "$target_os" in
677 darwin*)
678     MOZ_USE_PTHREADS=1
679     ;;
681     AC_CHECK_LIB(pthreads, pthread_create,
682         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
683         AC_CHECK_LIB(pthread, pthread_create,
684             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
685             AC_CHECK_LIB(c_r, pthread_create,
686                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
687                 AC_CHECK_LIB(c, pthread_create,
688                     MOZ_USE_PTHREADS=1
689                 )
690             )
691         )
692     )
693     ;;
694 esac
696 dnl ========================================================
697 dnl Do the platform specific pthread hackery
698 dnl ========================================================
699 if test "$MOZ_USE_PTHREADS"x != x
700 then
701     dnl
702     dnl See if -pthread is supported.
703     dnl
704     rm -f conftest*
705     ac_cv_have_dash_pthread=no
706     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
707     echo 'int main() { return 0; }' | cat > conftest.c
708     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
709     if test $? -eq 0; then
710         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
711             ac_cv_have_dash_pthread=yes
712             case "$target_os" in
713             freebsd*)
714 # Freebsd doesn't use -pthread for compiles, it uses them for linking
715                 ;;
716             *)
717                 CFLAGS="$CFLAGS -pthread"
718                 CXXFLAGS="$CXXFLAGS -pthread"
719                 ;;
720             esac
721         fi
722     fi
723     rm -f conftest*
724     AC_MSG_RESULT($ac_cv_have_dash_pthread)
726     dnl
727     dnl See if -pthreads is supported.
728     dnl
729     ac_cv_have_dash_pthreads=no
730     if test "$ac_cv_have_dash_pthread" = "no"; then
731         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
732         echo 'int main() { return 0; }' | cat > conftest.c
733         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
734         if test $? -eq 0; then
735             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
736                 ac_cv_have_dash_pthreads=yes
737                 CFLAGS="$CFLAGS -pthreads"
738                 CXXFLAGS="$CXXFLAGS -pthreads"
739             fi
740         fi
741         rm -f conftest*
742         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
743     fi
745     case "$target" in
746         *-*-freebsd*)
747             AC_DEFINE(_REENTRANT)
748             AC_DEFINE(_THREAD_SAFE)
749             dnl -pthread links in -lpthread, so don't specify it explicitly.
750             if test "$ac_cv_have_dash_pthread" = "yes"; then
751                 _PTHREAD_LDFLAGS="-pthread"
752             fi
753             ;;
755         *-*-openbsd*|*-*-bsdi*)
756             AC_DEFINE(_REENTRANT)
757             AC_DEFINE(_THREAD_SAFE)
758             dnl -pthread links in -lc_r, so don't specify it explicitly.
759             if test "$ac_cv_have_dash_pthread" = "yes"; then
760                 _PTHREAD_LDFLAGS="-pthread"
761             fi
762             ;;
764         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
765             AC_DEFINE(_REENTRANT)
766             ;;
768     esac
769     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
770     AC_SUBST(MOZ_USE_PTHREADS)
771     MOZ_CHECK_HEADERS(pthread.h)
775 dnl Checks for library functions.
776 dnl ========================================================
778 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
779 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
780                ac_cv_clock_monotonic,
781                [for libs in "" -lrt; do
782                     _SAVE_LIBS="$LIBS"
783                     LIBS="$LIBS $libs"
784 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
785 dnl we should or not be able to use it. To detect if we can, we need to make the
786 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
787                     AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
788                                  #include <time.h>],
789                                  [ struct timespec ts;
790                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
791                                  ac_cv_clock_monotonic=$libs
792                                  LIBS="$_SAVE_LIBS"
793                                  break,
794                                  ac_cv_clock_monotonic=no)
795                     LIBS="$_SAVE_LIBS"
796                 done])
797 if test "$ac_cv_clock_monotonic" != "no"; then
798     HAVE_CLOCK_MONOTONIC=1
799     REALTIME_LIBS=$ac_cv_clock_monotonic
800     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
801     AC_SUBST(HAVE_CLOCK_MONOTONIC)
802     AC_SUBST_LIST(REALTIME_LIBS)
805 AC_CACHE_CHECK(
806     [for res_ninit()],
807     ac_cv_func_res_ninit,
808     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
809         dnl no need for res_ninit() on NetBSD and OpenBSD
810         ac_cv_func_res_ninit=no
811      else
812         AC_TRY_LINK([
813             #ifdef linux
814             #define _BSD_SOURCE 1
815             #endif
816             #include <sys/types.h>
817             #include <netinet/in.h>
818             #include <arpa/nameser.h>
819             #include <resolv.h>
820             ],
821             [int foo = res_ninit(&_res);],
822             [ac_cv_func_res_ninit=yes],
823             [ac_cv_func_res_ninit=no])
824      fi
825     ])
827 if test "$ac_cv_func_res_ninit" = "yes"; then
828     AC_DEFINE(HAVE_RES_NINIT)
829 dnl must add the link line we do something as foolish as this... dougt
830 dnl else
831 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
832 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
835 AC_LANG_C
837 dnl ===================================================================
838 dnl ========================================================
839 dnl Put your C++ language/feature checks below
840 dnl ========================================================
841 AC_LANG_CPLUSPLUS
843 ARM_ABI_PREFIX=
844 if test "$GNU_CC"; then
845   if test "$CPU_ARCH" = "arm" ; then
846     AC_CACHE_CHECK(for ARM EABI,
847         ac_cv_gcc_arm_eabi,
848         [AC_TRY_COMPILE([],
849                         [
850 #if defined(__ARM_EABI__)
851   return 0;
852 #else
853 #error Not ARM EABI.
854 #endif
855                         ],
856                         ac_cv_gcc_arm_eabi="yes",
857                         ac_cv_gcc_arm_eabi="no")])
858     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
859         HAVE_ARM_EABI=1
860         ARM_ABI_PREFIX=eabi-
861     else
862         ARM_ABI_PREFIX=oabi-
863     fi
864   fi
866   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
869 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
870 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
871 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
872 # linking XUL.
873 _SAVE_LDFLAGS=$LDFLAGS
874 LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
875 AC_CACHE_CHECK(for __thread keyword for TLS variables,
876                ac_cv_thread_keyword,
877                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
878                             [return tlsIsMainThread;],
879                             ac_cv_thread_keyword=yes,
880                             ac_cv_thread_keyword=no)])
881 LDFLAGS=$_SAVE_LDFLAGS
882 # The custom dynamic linker doesn't support TLS variables
883 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
884   # mips builds fail with TLS variables because of a binutils bug.
885   # See bug 528687
886   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
887   case "${target}" in
888     mips*-*)
889       :
890       ;;
891     *-android*|*-linuxandroid*)
892       :
893       ;;
894     *-openbsd*)
895       :
896       ;;
897     *)
898       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
899       ;;
900   esac
903 if test -n "$MOZ_LINKER"; then
904 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
905 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
906 dnl Since the linker only understands the sysv ones, no need to build the
907 dnl gnu style tables anyways.
908   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
911 dnl End of C++ language/feature checks
912 AC_LANG_C
914 fi # ! SKIP_COMPILER_CHECKS
916 if test -n "${COMPILE_ENVIRONMENT}"; then
917   MOZ_CHECK_ALLOCATOR
920 TARGET_XPCOM_ABI=
921 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
922     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
923     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
926 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
927 dnl features that Windows actually does support.
929 if test -n "$SKIP_COMPILER_CHECKS"; then
930    dnl Windows has malloc.h
931    AC_DEFINE(MALLOC_H, [<malloc.h>])
932    AC_DEFINE(HAVE_FORCEINLINE)
933 fi # SKIP_COMPILER_CHECKS
935 dnl Mozilla specific options
936 dnl ========================================================
937 dnl The macros used for command line options
938 dnl are defined in build/autoconf/altoptions.m4.
940 dnl ========================================================
941 dnl =
942 dnl = Application
943 dnl =
944 dnl ========================================================
946 MOZ_BRANDING_DIRECTORY=
947 MOZ_OFFICIAL_BRANDING=
948 MOZ_NO_SMART_CARDS=
949 MOZ_BINARY_EXTENSIONS=
950 MOZ_DEVTOOLS=server
952 dnl ========================================================
953 dnl = Trademarked Branding
954 dnl ========================================================
955 MOZ_ARG_ENABLE_BOOL(official-branding,
956 [  --enable-official-branding
957                           Enable Official mozilla.org Branding
958                           Do not distribute builds with
959                           --enable-official-branding unless you have
960                           permission to use trademarks per
961                           http://www.mozilla.org/foundation/trademarks/ .],
962     MOZ_OFFICIAL_BRANDING=1,
963     MOZ_OFFICIAL_BRANDING=)
965 # Allow the application to influence configure with a confvars.sh script.
966 AC_MSG_CHECKING([if app-specific confvars.sh exists])
967 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
968   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
969   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
970 else
971   AC_MSG_RESULT([no])
974 AC_SUBST(MOZ_OFFICIAL_BRANDING)
975 if test -n "$MOZ_OFFICIAL_BRANDING"; then
976   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
977     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
978   else
979     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
980     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
981   fi
984 MOZ_ARG_WITH_STRING(branding,
985 [  --with-branding=dir     Use branding from the specified directory.],
986     MOZ_BRANDING_DIRECTORY=$withval)
988 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
989 if test -z "$REAL_BRANDING_DIRECTORY"; then
990   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
993 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
994   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
997 AC_SUBST(MOZ_BRANDING_DIRECTORY)
999 dnl ========================================================
1000 dnl = Distribution ID
1001 dnl ========================================================
1002 MOZ_ARG_WITH_STRING(distribution-id,
1003 [  --with-distribution-id=ID
1004                           Set distribution-specific id (default=org.mozilla)],
1005 [ val=`echo $withval`
1006     MOZ_DISTRIBUTION_ID="$val"])
1008 if test -z "$MOZ_DISTRIBUTION_ID"; then
1009    MOZ_DISTRIBUTION_ID="org.mozilla"
1012 AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
1013 AC_SUBST(MOZ_DISTRIBUTION_ID)
1015 dnl ========================================================
1016 dnl = Enable code optimization. ON by default.
1017 dnl ========================================================
1019 # Use value from moz.configure if one is defined. Else use our computed
1020 # value.
1021 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
1022     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
1025 if test "$COMPILE_ENVIRONMENT"; then
1026 if test -n "$MOZ_OPTIMIZE"; then
1027     AC_MSG_CHECKING([for valid C compiler optimization flags])
1028     _SAVE_CFLAGS=$CFLAGS
1029     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
1030     AC_TRY_COMPILE([#include <stdio.h>],
1031         [printf("Hello World\n");],
1032         _results=yes,
1033         _results=no)
1034     AC_MSG_RESULT([$_results])
1035     if test "$_results" = "no"; then
1036         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
1037     fi
1038     CFLAGS=$_SAVE_CFLAGS
1039     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
1040         # When using llvm-based LTO, non numeric optimization levels are
1041         # not supported by the linker, so force the linker to use -O2 (
1042         # which doesn't influence the level compilation units are actually
1043         # compiled at).
1044         case " $MOZ_OPTIMIZE_FLAGS " in
1045         *\ -Os\ *|*\ -Oz\ *)
1046             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
1047             ;;
1048         esac
1049     fi
1051 fi # COMPILE_ENVIRONMENT
1053 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
1054 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
1055 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
1057 case "${OS_TARGET}" in
1058 Android|WINNT|Darwin)
1059   MOZ_GLUE_IN_PROGRAM=
1060   ;;
1062   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
1063   MOZ_GLUE_IN_PROGRAM=1
1064   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
1065   ;;
1066 esac
1068 dnl ========================================================
1069 dnl = Jemalloc build setup
1070 dnl ========================================================
1071 if test -z "$MOZ_MEMORY"; then
1072   case "${target}" in
1073     *-mingw*)
1074       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
1075         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.])
1076       fi
1077       ;;
1078   esac
1079 else
1080   dnl The generic feature tests that determine how to compute ncpus are long and
1081   dnl complicated.  Therefore, simply define special cpp variables for the
1082   dnl platforms we have special knowledge of.
1083   case "${target}" in
1084   *-mingw*)
1085     export MOZ_NO_DEBUG_RTL=1
1086     ;;
1087   esac
1088 fi # MOZ_MEMORY
1089 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
1091 dnl ========================================================
1092 dnl = Enable using the clang plugin to build
1093 dnl ========================================================
1095 if test -n "$COMPILE_ENVIRONMENT"; then
1096 MOZ_CONFIG_CLANG_PLUGIN
1097 fi # COMPILE_ENVIRONMENT
1099 if test -z "$SKIP_COMPILER_CHECKS"; then
1100 dnl ========================================================
1101 dnl Check for gcc -pipe support
1102 dnl ========================================================
1103 AC_MSG_CHECKING([for -pipe support])
1104 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
1105     dnl Any gcc that supports firefox supports -pipe.
1106     CFLAGS="$CFLAGS -pipe"
1107     CXXFLAGS="$CXXFLAGS -pipe"
1108     AC_MSG_RESULT([yes])
1109 else
1110     AC_MSG_RESULT([no])
1113 fi # ! SKIP_COMPILER_CHECKS
1115 AC_LANG_C
1117 if test "$COMPILE_ENVIRONMENT"; then
1118 MOZ_EXPAND_LIBS
1119 fi # COMPILE_ENVIRONMENT
1121 dnl ========================================================
1122 dnl Check if we need the 32-bit Linux SSE2 error dialog
1123 dnl ========================================================
1125 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
1127 dnl ========================================================
1128 dnl Check for cairo
1129 dnl ========================================================
1131 if test "$OS_ARCH" = "WINNT"; then
1132     # For now we assume that we will have a uint64_t available through
1133     # one of the above headers or mozstdint.h.
1134     AC_DEFINE(HAVE_UINT64_T)
1137 case "$MOZ_WIDGET_TOOLKIT" in
1138   windows)
1139     if test "$COMPILE_ENVIRONMENT"; then
1140       MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
1141     fi
1142     ;;
1143 esac
1144 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
1146 dnl ========================================================
1147 dnl =
1148 dnl = Maintainer debug option (no --enable equivalent)
1149 dnl =
1150 dnl ========================================================
1152 AC_SUBST_LIST(ASFLAGS)
1153 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
1155 AC_SUBST(MOZ_STUB_INSTALLER)
1157 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
1159 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
1161 if test -n "$MOZ_BINARY_EXTENSIONS"; then
1162   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
1165 dnl ========================================================
1166 dnl = Mac bundle name prefix
1167 dnl ========================================================
1168 MOZ_ARG_WITH_STRING(macbundlename-prefix,
1169 [  --with-macbundlename-prefix=prefix
1170                           Prefix for MOZ_MACBUNDLE_NAME],
1171 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
1173 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
1174 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
1175   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
1178 if test "$MOZ_DEBUG"; then
1179   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
1180 else
1181   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
1183 AC_SUBST(MOZ_MACBUNDLE_NAME)
1185 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
1186 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
1187 # Otherwise, use MOZ_APP_DISPLAYNAME
1188 if test -z "$MOZ_MACBUNDLE_ID"; then
1189    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
1191 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
1192 if test "$MOZ_DEBUG"; then
1193   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
1196 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
1197 AC_SUBST(MOZ_MACBUNDLE_ID)
1199 dnl ========================================================
1200 dnl = Child Process Name for IPC
1201 dnl ========================================================
1202 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
1203   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
1204 else
1205   # We want to let Android unpack the file at install time, but it only does
1206   # so if the file is named libsomething.so. The lib/ path is also required
1207   # because the unpacked file will be under the lib/ subdirectory and will
1208   # need to be executed from that path.
1209   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
1211 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
1212 MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
1214 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
1215 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
1216 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
1218 # The following variables are available to branding and application
1219 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
1220 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
1221 # impacts profile location and user-visible fields.
1222 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
1223 # Mac Bundle name, Updater, Installer), it is typically used for nightly
1224 # builds (e.g. Aurora for Firefox).
1225 # - MOZ_APP_PROFILE: When set, used for application.ini's
1226 # "Profile" field, which controls profile location.
1227 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
1228 # crash reporter server url.
1229 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
1231 # The following environment variables used to have an effect, but don't anymore:
1232 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
1233 # the contents from the version.txt file in the application directory, or
1234 # browser/config/version.txt if there isn't one.
1235 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
1236 # in the "About" window. This was replaced with the contents from the
1237 # version_display.txt or version.txt in the application directory, or
1238 # browser/config/version_display.txt.
1240 # For extensions and langpacks, we require a max version that is compatible
1241 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
1242 # 24.0a1 and 24.0a2 aren't affected
1243 # 24.0 becomes 24.*
1244 # 24.1.1 becomes 24.*
1245 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
1246 if test -z "$IS_ALPHA"; then
1247   changequote(,)
1248   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
1249     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
1250   else
1251     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
1252   fi
1253   changequote([,])
1254 else
1255   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
1258 AC_SUBST(MOZ_APP_DISPLAYNAME)
1259 AC_SUBST(MOZ_APP_VENDOR)
1260 AC_SUBST(MOZ_APP_PROFILE)
1261 AC_SUBST(MOZ_APP_ID)
1262 AC_SUBST(MAR_CHANNEL_ID)
1263 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
1264 AC_SUBST(MOZ_PROFILE_MIGRATOR)
1265 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
1266 AC_SUBST(MOZ_APP_UA_NAME)
1267 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
1268 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
1269 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
1271 AC_SUBST(MOZ_APP_MAXVERSION)
1272 AC_SUBST(MOZ_PKG_SPECIAL)
1273 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
1275 if test "$MOZILLA_OFFICIAL"; then
1276     # Build revisions should always be present in official builds
1277     MOZ_INCLUDE_SOURCE_INFO=1
1280 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
1281 # explicitly set the repository and changeset information in.
1282 AC_SUBST(MOZ_SOURCE_REPO)
1283 AC_SUBST(MOZ_SOURCE_CHANGESET)
1284 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
1286 dnl If we have any service that uploads data (and requires data submission
1287 dnl policy alert), set MOZ_DATA_REPORTING.
1288 dnl We need SUBST for build system and DEFINE for xul preprocessor.
1289 if test -n "$MOZ_TELEMETRY_REPORTING" || test -n "$MOZ_SERVICES_HEALTHREPORT" || test -n "$MOZ_CRASHREPORTER"  || test -n "$MOZ_NORMANDY"; then
1290   MOZ_DATA_REPORTING=1
1291   AC_DEFINE(MOZ_DATA_REPORTING)
1292   AC_SUBST(MOZ_DATA_REPORTING)
1295 dnl win32 options
1296 AC_SUBST(WIN32_REDIST_DIR)
1297 AC_SUBST(WIN_UCRT_REDIST_DIR)
1299 dnl Echo the CFLAGS to remove extra whitespace.
1300 CFLAGS=`echo \
1301     $_COMPILATION_CFLAGS \
1302     $CFLAGS`
1304 CXXFLAGS=`echo \
1305     $_COMPILATION_CXXFLAGS \
1306     $CXXFLAGS`
1308 COMPILE_CFLAGS=`echo \
1309     $_DEFINES_CFLAGS \
1310     $COMPILE_CFLAGS`
1312 COMPILE_CXXFLAGS=`echo \
1313     $_DEFINES_CXXFLAGS \
1314     $COMPILE_CXXFLAGS`
1316 HOST_CFLAGS=`echo \
1317     $_COMPILATION_HOST_CFLAGS \
1318     $HOST_CFLAGS`
1320 HOST_CXXFLAGS=`echo \
1321     $_COMPILATION_HOST_CXXFLAGS \
1322     $HOST_CXXFLAGS`
1324 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
1325 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1326 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
1327 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1328 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
1329   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1330   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1332 AC_SUBST(HOST_CMFLAGS)
1333 AC_SUBST(HOST_CMMFLAGS)
1334 AC_SUBST(OS_COMPILE_CMFLAGS)
1335 AC_SUBST(OS_COMPILE_CMMFLAGS)
1337 OS_CFLAGS="$CFLAGS"
1338 OS_CXXFLAGS="$CXXFLAGS"
1339 OS_CPPFLAGS="$CPPFLAGS"
1340 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1341 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1342 OS_LDFLAGS="$LDFLAGS"
1343 OS_LIBS="$LIBS"
1344 AC_SUBST_LIST(OS_CFLAGS)
1345 AC_SUBST_LIST(OS_CXXFLAGS)
1346 AC_SUBST_LIST(OS_CPPFLAGS)
1347 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1348 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1349 AC_SUBST_LIST(OS_LDFLAGS)
1350 AC_SUBST(OS_LIBS)
1352 AC_SUBST(HOST_CC)
1353 AC_SUBST(HOST_CXX)
1354 AC_SUBST_LIST(HOST_CFLAGS)
1355 AC_SUBST_LIST(HOST_CPPFLAGS)
1356 AC_SUBST_LIST(HOST_CXXFLAGS)
1357 AC_SUBST(HOST_LDFLAGS)
1358 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1359 AC_SUBST(HOST_BIN_SUFFIX)
1361 AC_SUBST(TARGET_XPCOM_ABI)
1363 AC_SUBST(DSO_LDOPTS)
1364 AC_SUBST(BIN_SUFFIX)
1365 AC_SUBST(USE_N32)
1366 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1367 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1369 AC_SUBST(MOZ_DEVTOOLS)
1371 AC_SUBST(MOZ_PACKAGE_JSSHELL)
1373 AC_SUBST(DMG_TOOL)
1375 dnl Host JavaScript runtime, if any, to use during cross compiles.
1376 AC_SUBST(JS_BINARY)
1378 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
1380 dnl Set various defines and substitutions
1381 dnl ========================================================
1383 AC_SUBST(MOZ_DEV_EDITION)
1384 if test -n "$MOZ_DEV_EDITION"; then
1385     AC_DEFINE(MOZ_DEV_EDITION)
1388 dnl Windows AccessibilityHandler
1389 dnl ========================================================
1391 if test -z "$MOZ_HANDLER_CLSID"; then
1392     MOZ_HANDLER_CLSID="4a195748-dca2-45fb-9295-0a139e76a9e7"
1393     MOZ_IHANDLERCONTROL_IID="3316ce35-f892-4832-97c5-06c52c03cdba"
1394     MOZ_ASYNCIHANDLERCONTROL_IID="15b48b76-ad38-4ad3-bd1a-d3c48a5a9947"
1395     MOZ_IGECKOBACKCHANNEL_IID="dd2e4a89-999e-4d65-8b65-440c923ddb61"
1398 AC_SUBST(MOZ_HANDLER_CLSID)
1399 AC_SUBST(MOZ_IHANDLERCONTROL_IID)
1400 AC_SUBST(MOZ_ASYNCIHANDLERCONTROL_IID)
1401 AC_SUBST(MOZ_IGECKOBACKCHANNEL_IID)
1403 dnl Spit out some output
1404 dnl ========================================================
1406 # Avoid using obsolete NSPR features
1407 AC_DEFINE(NO_NSPR_10_SUPPORT)
1409 MOZ_CREATE_CONFIG_STATUS()
1411 rm -fr confdefs* $ac_clean_files