Bug 1832937 - Always track nursery string allocations in compiled code r=jandem
[gecko.git] / old-configure.in
bloba35a2e6b5a6a4bedee4ad5f32a7000e75fb0c2f0
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 Set the minimum version of toolkit libs used by mozilla
30 dnl ========================================================
31 W32API_VERSION=3.14
33 dnl Set various checks
34 dnl ========================================================
35 MISSING_X=
37 dnl Initialize the Pthread test variables early so they can be
38 dnl  overridden by each platform.
39 dnl ========================================================
40 MOZ_USE_PTHREADS=
41 _PTHREAD_LDFLAGS=""
43 LDFLAGS="$LDFLAGS $LINKER_LDFLAGS"
44 HOST_LDFLAGS="$HOST_LDFLAGS $HOST_LINKER_LDFLAGS"
46 if test "$COMPILE_ENVIRONMENT"; then
47     MOZ_ANDROID_NDK
48 fi # COMPILE_ENVIRONMENT
50 dnl ========================================================
51 dnl Checks for compilers.
52 dnl ========================================================
54 if test "$COMPILE_ENVIRONMENT"; then
56 # Run some logic to figure out exe extensions (mostly for mingw's sake)
57 AC_EXEEXT
59 if test "$target" != "$host"; then
60     MOZ_CROSS_COMPILER
61 else
62     AC_PROG_CC
63     case "$target" in
64     *-mingw*)
65       # Work around the conftest.exe access problem on Windows
66       sleep 2
67     esac
68     AC_PROG_CXX
69     AC_CHECK_PROGS(OTOOL, otool, :)
72 MOZ_TOOL_VARIABLES
74 dnl ========================================================
75 dnl Special win32 checks
76 dnl ========================================================
78 WINVER=601
80 case "$target" in
81 *-mingw*)
82     if test "$GCC" != "yes"; then
83         # Check to see if we are really running in a msvc environemnt
84         _WIN32_MSVC=1
86         # Make sure compilers are valid
87         CXXFLAGS="$CXXFLAGS -TP"
88         AC_LANG_SAVE
89         AC_LANG_C
90         AC_TRY_COMPILE([#include <stdio.h>],
91             [ printf("Hello World\n"); ],,
92             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
94         AC_LANG_CPLUSPLUS
95         AC_TRY_COMPILE([#include <new.h>],
96             [ unsigned *test = new unsigned(42); ],,
97             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
98         AC_LANG_RESTORE
100         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
101         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
103         MSVC_C_RUNTIME_DLL=vcruntime140.dll
104         if test -n "$IS_VS2019_OR_MORE" -a "$CPU_ARCH" != "x86"; then
105             MSVC_C_RUNTIME_1_DLL=vcruntime140_1.dll
106         fi
107         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
109         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
110         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
112         if test -n "$WIN_UCRT_REDIST_DIR"; then
113           if test ! -d "$WIN_UCRT_REDIST_DIR"; then
114             AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
115           fi
116           WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
117         fi
119         AC_SUBST(MSVC_C_RUNTIME_DLL)
120         AC_SUBST(MSVC_C_RUNTIME_1_DLL)
121         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
123         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
125         if test -n "$WIN32_REDIST_DIR"; then
126           if test ! -d "$WIN32_REDIST_DIR"; then
127             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
128           fi
129           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
130         fi
131     else
132         # Check w32api version
133         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
134         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
135         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
136         AC_TRY_COMPILE([#include <w32api.h>],
137             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
138                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
139                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
140                 #error "test failed."
141             #endif
142             , [ res=yes ], [ res=no ])
143         AC_MSG_RESULT([$res])
144         if test "$res" != "yes"; then
145             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
146         fi
147         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
148         # causing problems with local implementations with the same name.
149         AC_DEFINE(STRSAFE_NO_DEPRECATE)
150     fi # !GNU_CC
152     AC_DEFINE(_USE_MATH_DEFINES) # Otherwise Windows' math.h doesn't #define M_PI.
154     CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
155     CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
157     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
158     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
159     # Require OS features provided by IE 8.0 (Win7)
160     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
162     ;;
163 esac
165 if test -n "$_WIN32_MSVC"; then
166     SKIP_PATH_CHECKS=1
167     SKIP_COMPILER_CHECKS=1
168     SKIP_LIBRARY_CHECKS=1
170     # Since we're skipping compiler and library checks, hard-code
171     # some facts here.
172     AC_DEFINE(HAVE_IO_H)
173     AC_DEFINE(HAVE_ISATTY)
176 fi # COMPILE_ENVIRONMENT
178 AC_SUBST(GNU_CC)
179 AC_SUBST(GNU_CXX)
181 dnl ========================================================
182 dnl set the defaults first
183 dnl ========================================================
184 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
186 dnl Configure platform-specific CPU architecture compiler options.
187 dnl ==============================================================
188 if test "$COMPILE_ENVIRONMENT"; then
189     MOZ_ARCH_OPTS
190 fi # COMPILE_ENVIRONMENT
192 if test -n "$COMPILE_ENVIRONMENT"; then
193    MOZ_CONFIG_SANITIZE
196 dnl ========================================================
197 dnl GNU specific defaults
198 dnl ========================================================
199 if test "$GNU_CC"; then
200     if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
201         DSO_PIC_CFLAGS='-fPIC'
202         ASFLAGS="$ASFLAGS -fPIC"
203     fi
205     AC_MSG_CHECKING([for --noexecstack option to as])
206     _SAVE_CFLAGS=$CFLAGS
207     CFLAGS="$CFLAGS -Wa,--noexecstack"
208     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
209                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
210                      AC_MSG_RESULT([no]))
211     CFLAGS=$_SAVE_CFLAGS
212     AC_MSG_CHECKING([for -z noexecstack option to ld])
213     _SAVE_LDFLAGS=$LDFLAGS
214     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
215     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
216                   AC_MSG_RESULT([no])
217                   LDFLAGS=$_SAVE_LDFLAGS)
219     AC_MSG_CHECKING([for -z text option to ld])
220     _SAVE_LDFLAGS=$LDFLAGS
221     LDFLAGS="$LDFLAGS -Wl,-z,text"
222     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
223                   AC_MSG_RESULT([no])
224                   LDFLAGS=$_SAVE_LDFLAGS)
226     AC_MSG_CHECKING([for -z relro option to ld])
227     _SAVE_LDFLAGS=$LDFLAGS
228     LDFLAGS="$LDFLAGS -Wl,-z,relro"
229     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
230                   AC_MSG_RESULT([no])
231                   LDFLAGS=$_SAVE_LDFLAGS)
233     AC_MSG_CHECKING([for -z nocopyreloc option to ld])
234     _SAVE_LDFLAGS=$LDFLAGS
235     LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
236     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
237                   AC_MSG_RESULT([no])
238                   LDFLAGS=$_SAVE_LDFLAGS)
240     AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
241     _SAVE_LDFLAGS=$LDFLAGS
242     LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
243     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
244                   AC_MSG_RESULT([no])
245                   LDFLAGS=$_SAVE_LDFLAGS)
247     # While sha1 is deterministic, it is slower.
248     if test -z "$DEVELOPER_OPTIONS"; then
249         build_id=sha1
250     else
251         build_id=uuid
252     fi
253     AC_MSG_CHECKING([for --build-id=$build_id option to ld])
254     _SAVE_LDFLAGS=$LDFLAGS
255     LDFLAGS="$LDFLAGS -Wl,--build-id=$build_id"
256     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
257                   AC_MSG_RESULT([no])
258                   LDFLAGS=$_SAVE_LDFLAGS)
260     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
261     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
262     _SAVE_LDFLAGS=$LDFLAGS
263     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
264     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
265                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
266                   AC_MSG_RESULT([no]))
267     LDFLAGS=$_SAVE_LDFLAGS
269     DSO_LDOPTS='-shared'
270     if test "$GCC_USE_GNU_LD"; then
271         # Some tools like ASan use a runtime library that is only
272         # linked against executables, so we must allow undefined
273         # symbols for shared objects in some cases.
274         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
275             # Don't allow undefined symbols in libraries
276             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
278             # BSDs need `environ' exposed for posix_spawn (bug 753046)
279             case "$OS_TARGET" in
280             DragonFly|FreeBSD|NetBSD|OpenBSD)
281                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
282                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
283                 else
284                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
285                 fi
286                 ;;
287             esac
288         fi
289     fi
291     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
293     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
296 if test "$GNU_CXX"; then
297     CXXFLAGS="$CXXFLAGS -fno-exceptions"
299     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
302 dnl ========================================================
303 dnl System overrides of the defaults for host
304 dnl ========================================================
305 case "$host" in
306 *mingw*)
307     if test -n "$_WIN32_MSVC"; then
308         HOST_CFLAGS="$HOST_CFLAGS"
309     else
310         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
311     fi
312     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
313     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
314     HOST_BIN_SUFFIX=.exe
316     case "${host_cpu}" in
317     i*86)
318         if test -n "$_WIN32_MSVC"; then
319             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
320         fi
321         ;;
322     x86_64)
323         if test -n "$_WIN32_MSVC"; then
324             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
325         fi
326         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
327         ;;
328     esac
329     ;;
331 *-darwin*)
332     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
333     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
334     ;;
336 *-linux*|*-kfreebsd*-gnu|*-gnu*)
337     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
338     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
339     ;;
342     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
343     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
344     ;;
345 esac
347 dnl ========================================================
348 dnl System overrides of the defaults for target
349 dnl ========================================================
351 case "$target" in
352 *-darwin*)
353     MOZ_OPTIMIZE_FLAGS="-O3"
354     DSO_LDOPTS=''
356     dnl DTrace and -dead_strip don't interact well. See bug 403132.
357     dnl ===================================================================
358     if test "x$enable_dtrace" = "xyes"; then
359         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
360     else
361         dnl check for the presence of the -dead_strip linker flag
362         AC_MSG_CHECKING([for -dead_strip option to ld])
363         _SAVE_LDFLAGS=$LDFLAGS
364         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
365         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
366         if test -n "$_HAVE_DEAD_STRIP" ; then
367             AC_MSG_RESULT([yes])
368             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
369         else
370             AC_MSG_RESULT([no])
371         fi
373         LDFLAGS=$_SAVE_LDFLAGS
374     fi
376     MOZ_FIX_LINK_PATHS=
377     ;;
379 *-android*|*-linuxandroid*)
380     if test -z "$CLANG_CC"; then
381         MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
382     else
383         # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
384         # -Oz is smaller than -Os on clang.
385         MOZ_OPTIMIZE_FLAGS="-Oz"
386         # Disable the outliner, which causes performance regressions, and is
387         # enabled on some platforms at -Oz.
388         if test -z "$MOZ_LTO"; then
389             DISABLE_OUTLINER="-mno-outline"
390             _SAVE_CFLAGS=$CFLAGS
391             CFLAGS="$CFLAGS $DISABLE_OUTLINER"
392             AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
393             CFLAGS="$_SAVE_CFLAGS"
394         else
395             DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
396             _SAVE_LDFLAGS=$LDFLAGS
397             LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
398             AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
399             LDFLAGS="$_SAVE_LDFLAGS"
400         fi
401     fi
402     ;;
404 *-*linux*)
405     if test "$GNU_CC" -o "$GNU_CXX"; then
406         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
407         if test -n "$MOZ_DEBUG"; then
408             MOZ_OPTIMIZE_FLAGS="-Os"
409         else
410             MOZ_OPTIMIZE_FLAGS="-O2"
411         fi
412         if test -z "$CLANG_CC"; then
413            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
414         fi
415     fi
417     case "${target_cpu}" in
418     alpha*)
419         CFLAGS="$CFLAGS -mieee"
420         CXXFLAGS="$CXXFLAGS -mieee"
421     ;;
422     esac
423     ;;
424 *-mingw*)
425     DSO_PIC_CFLAGS=
426     # certain versions of cygwin's makedepend barf on the
427     # #include <string> vs -I./dist/include/string issue so don't use it
428     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
429         # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
430         if test -z "$CLANG_CC"; then
431             AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
432         fi
434         DSO_LDOPTS='-shared'
435         MOZ_FIX_LINK_PATHS=
437         MOZ_OPTIMIZE_FLAGS="-O2"
439         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
440         WIN32_GUI_EXE_LDFLAGS=-mwindows
442         # Silence problematic clang warnings
443         CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
444         LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
445     else
446         TARGET_COMPILER_ABI=msvc
447         # aarch64 doesn't support subsystems below 6.02
448         if test "$CPU_ARCH" = "aarch64"; then
449             WIN32_SUBSYSTEM_VERSION=6.02
450         else
451             WIN32_SUBSYSTEM_VERSION=6.01
452         fi
453         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
454         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
455         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
456         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
457         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
458         CFLAGS="$CFLAGS -Gy -Zc:inline"
459         CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
460         if test "$CPU_ARCH" = "x86"; then
461             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
462             dnl more recent, so set that explicitly here unless another
463             dnl target arch has already been set.
464             changequote(,)
465             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
466               CFLAGS="$CFLAGS -arch:SSE2"
467             fi
468             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
469               CXXFLAGS="$CXXFLAGS -arch:SSE2"
470             fi
471             changequote([,])
472         fi
473         dnl VS2013+ supports -Gw for better linker optimizations.
474         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
475         dnl Disabled on ASan because it causes false-positive ODR violations.
476         if test -z "$MOZ_ASAN"; then
477             CFLAGS="$CFLAGS -Gw"
478             CXXFLAGS="$CXXFLAGS -Gw"
479         else
480             # String tail merging doesn't play nice with ASan's ODR checker.
481             LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
482         fi
483         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
484         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
485         MOZ_DEBUG_LDFLAGS='-DEBUG'
486         if test "$HOST_OS_ARCH" != "WINNT"; then
487           # %_PDB% is a special signal to emit only the PDB basename. This
488           # avoids problems in Windows tools that don't like forward-slashes.
489           MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
490         fi
491         MOZ_OPTIMIZE_FLAGS='-O2'
492         MOZ_FIX_LINK_PATHS=
493         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
494     fi
495     AC_DEFINE(WIN32_LEAN_AND_MEAN)
496     dnl See http://support.microsoft.com/kb/143208 to use STL
497     AC_DEFINE(NOMINMAX)
498     BIN_SUFFIX='.exe'
500     case "$host_os" in
501     cygwin*|msvc*|mks*)
502         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.])
503         ;;
504     esac
506     case "$target" in
507     i*86-*)
508         if test -n "$GNU_CC"; then
509             CFLAGS="$CFLAGS -mstackrealign"
510             CXXFLAGS="$CXXFLAGS -mstackrealign"
511             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
512         else
513             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
514             LDFLAGS="$LDFLAGS -SAFESEH"
515         fi
517         AC_DEFINE(_X86_)
518         ;;
519     x86_64-*)
520         if test -n "$_WIN32_MSVC"; then
521             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
522         fi
523         AC_DEFINE(_AMD64_)
524         ;;
525     aarch64-*)
526         if test -n "$_WIN32_MSVC"; then
527             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
528         fi
529         AC_DEFINE(_ARM64_)
530         ;;
531     *)
532         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
533         ;;
534     esac
535     ;;
537 *-netbsd*)
538     CFLAGS="$CFLAGS -Dunix"
539     CXXFLAGS="$CXXFLAGS -Dunix"
540     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
541         DSO_PIC_CFLAGS='-fPIC -DPIC'
542         DSO_LDOPTS='-shared'
543         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
544     else
545         DSO_PIC_CFLAGS='-fPIC -DPIC'
546         DSO_LDOPTS='-shared'
547     fi
548     # This will fail on a.out systems prior to 1.5.1_ALPHA.
549     if test "$LIBRUNPATH"; then
550         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
551     fi
552     ;;
554 *-openbsd*)
555     if test -z "$X11BASE"; then
556         X11BASE=/usr/X11R6
557     fi
558     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
559     DSO_PIC_CFLAGS='-fPIC'
560     DSO_LDOPTS='-shared -fPIC'
561     if test "$LIBRUNPATH"; then
562         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
563     fi
564     ;;
566 *-solaris*)
567     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
568     ;;
570 esac
572 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
573 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
575 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
576     MOZ_OPTIMIZE_FLAGS="-O"
580 if test -z "$COMPILE_ENVIRONMENT"; then
581     SKIP_COMPILER_CHECKS=1
582     SKIP_LIBRARY_CHECKS=1
583     MOZ_DEBUGGING_OPTS
584 else
585     MOZ_COMPILER_OPTS
586 fi # COMPILE_ENVIRONMENT
588 if test -z "$SKIP_COMPILER_CHECKS"; then
589 dnl Checks for typedefs, structures, and compiler characteristics.
590 dnl ========================================================
591 AC_C_CONST
592 AC_TYPE_MODE_T
593 AC_TYPE_OFF_T
594 AC_TYPE_PID_T
595 AC_TYPE_SIZE_T
596 AC_LANG_CPLUSPLUS
597 AC_LANG_C
599 AC_LANG_CPLUSPLUS
601 MOZ_CXX11
603 AC_LANG_C
605 dnl Checks for header files.
606 dnl ========================================================
607 AC_HEADER_DIRENT
609 dnl Checks for libraries.
610 dnl ========================================================
611 AC_CHECK_LIB(c_r, gethostbyname_r)
613 dnl We don't want to link with libdl even if it's present on OS X, since
614 dnl it's not used and not part of the default installation. OS/2 has dlfcn
615 dnl in libc.
616 dnl We don't want to link against libm or libpthread on Darwin since
617 dnl they both are just symlinks to libSystem and explicitly linking
618 dnl against libSystem causes issues when debugging (see bug 299601).
619 case $target in
620 *-darwin*)
621     ;;
623     AC_SEARCH_LIBS(dlopen, dl,
624         MOZ_CHECK_HEADER(dlfcn.h,
625         AC_DEFINE(HAVE_DLOPEN)))
626     ;;
627 esac
629 _SAVE_CFLAGS="$CFLAGS"
630 CFLAGS="$CFLAGS -D_GNU_SOURCE"
631 AC_CHECK_FUNCS(dladdr)
632 CFLAGS="$_SAVE_CFLAGS"
634 if test ! "$GNU_CXX"; then
635     AC_CHECK_LIB(C, demangle)
638 AC_CHECK_LIB(socket, socket)
640 dnl ========================================================
641 dnl = pthread support
642 dnl = Start by checking whether the system support pthreads
643 dnl ========================================================
644 case "$target_os" in
645 darwin*)
646     MOZ_USE_PTHREADS=1
647     ;;
649     AC_CHECK_LIB(pthreads, pthread_create,
650         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
651         AC_CHECK_LIB(pthread, pthread_create,
652             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
653             AC_CHECK_LIB(c_r, pthread_create,
654                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
655                 AC_CHECK_LIB(c, pthread_create,
656                     MOZ_USE_PTHREADS=1
657                 )
658             )
659         )
660     )
661     ;;
662 esac
664 dnl ========================================================
665 dnl Do the platform specific pthread hackery
666 dnl ========================================================
667 if test "$MOZ_USE_PTHREADS"x != x
668 then
669     dnl
670     dnl See if -pthread is supported.
671     dnl
672     rm -f conftest*
673     ac_cv_have_dash_pthread=no
674     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
675     echo 'int main() { return 0; }' | cat > conftest.c
676     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
677     if test $? -eq 0; then
678         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
679             ac_cv_have_dash_pthread=yes
680             case "$target_os" in
681             freebsd*)
682 # Freebsd doesn't use -pthread for compiles, it uses them for linking
683                 ;;
684             *)
685                 CFLAGS="$CFLAGS -pthread"
686                 CXXFLAGS="$CXXFLAGS -pthread"
687                 ;;
688             esac
689         fi
690     fi
691     rm -f conftest*
692     AC_MSG_RESULT($ac_cv_have_dash_pthread)
694     dnl
695     dnl See if -pthreads is supported.
696     dnl
697     ac_cv_have_dash_pthreads=no
698     if test "$ac_cv_have_dash_pthread" = "no"; then
699         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
700         echo 'int main() { return 0; }' | cat > conftest.c
701         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
702         if test $? -eq 0; then
703             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
704                 ac_cv_have_dash_pthreads=yes
705                 CFLAGS="$CFLAGS -pthreads"
706                 CXXFLAGS="$CXXFLAGS -pthreads"
707             fi
708         fi
709         rm -f conftest*
710         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
711     fi
713     case "$target" in
714         *-*-freebsd*)
715             AC_DEFINE(_REENTRANT)
716             AC_DEFINE(_THREAD_SAFE)
717             dnl -pthread links in -lpthread, so don't specify it explicitly.
718             if test "$ac_cv_have_dash_pthread" = "yes"; then
719                 _PTHREAD_LDFLAGS="-pthread"
720             fi
721             ;;
723         *-*-openbsd*|*-*-bsdi*)
724             AC_DEFINE(_REENTRANT)
725             AC_DEFINE(_THREAD_SAFE)
726             dnl -pthread links in -lc_r, so don't specify it explicitly.
727             if test "$ac_cv_have_dash_pthread" = "yes"; then
728                 _PTHREAD_LDFLAGS="-pthread"
729             fi
730             ;;
732         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
733             AC_DEFINE(_REENTRANT)
734             ;;
736     esac
737     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
738     AC_SUBST(MOZ_USE_PTHREADS)
739     MOZ_CHECK_HEADERS(pthread.h)
743 dnl Checks for library functions.
744 dnl ========================================================
746 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
747 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
748                ac_cv_clock_monotonic,
749                [for libs in "" -lrt; do
750                     _SAVE_LIBS="$LIBS"
751                     LIBS="$LIBS $libs"
752 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
753 dnl we should or not be able to use it. To detect if we can, we need to make the
754 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
755                     AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
756                                  #include <time.h>],
757                                  [ struct timespec ts;
758                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
759                                  ac_cv_clock_monotonic=$libs
760                                  LIBS="$_SAVE_LIBS"
761                                  break,
762                                  ac_cv_clock_monotonic=no)
763                     LIBS="$_SAVE_LIBS"
764                 done])
765 if test "$ac_cv_clock_monotonic" != "no"; then
766     HAVE_CLOCK_MONOTONIC=1
767     REALTIME_LIBS=$ac_cv_clock_monotonic
768     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
769     AC_SUBST(HAVE_CLOCK_MONOTONIC)
770     AC_SUBST_LIST(REALTIME_LIBS)
773 AC_CACHE_CHECK(
774     [for res_ninit()],
775     ac_cv_func_res_ninit,
776     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
777         dnl no need for res_ninit() on NetBSD and OpenBSD
778         ac_cv_func_res_ninit=no
779      else
780         AC_TRY_LINK([
781             #ifdef linux
782             #define _BSD_SOURCE 1
783             #endif
784             #include <sys/types.h>
785             #include <netinet/in.h>
786             #include <arpa/nameser.h>
787             #include <resolv.h>
788             ],
789             [int foo = res_ninit(&_res);],
790             [ac_cv_func_res_ninit=yes],
791             [ac_cv_func_res_ninit=no])
792      fi
793     ])
795 if test "$ac_cv_func_res_ninit" = "yes"; then
796     AC_DEFINE(HAVE_RES_NINIT)
797 dnl must add the link line we do something as foolish as this... dougt
798 dnl else
799 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
800 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
803 AC_LANG_C
805 dnl ===================================================================
806 dnl ========================================================
807 dnl Put your C++ language/feature checks below
808 dnl ========================================================
809 AC_LANG_CPLUSPLUS
811 ARM_ABI_PREFIX=
812 if test "$GNU_CC"; then
813   if test "$CPU_ARCH" = "arm" ; then
814     AC_CACHE_CHECK(for ARM EABI,
815         ac_cv_gcc_arm_eabi,
816         [AC_TRY_COMPILE([],
817                         [
818 #if defined(__ARM_EABI__)
819   return 0;
820 #else
821 #error Not ARM EABI.
822 #endif
823                         ],
824                         ac_cv_gcc_arm_eabi="yes",
825                         ac_cv_gcc_arm_eabi="no")])
826     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
827         HAVE_ARM_EABI=1
828         ARM_ABI_PREFIX=eabi-
829     else
830         ARM_ABI_PREFIX=oabi-
831     fi
832   fi
834   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
837 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
838 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
839 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
840 # linking XUL.
841 _SAVE_LDFLAGS=$LDFLAGS
842 LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
843 AC_CACHE_CHECK(for __thread keyword for TLS variables,
844                ac_cv_thread_keyword,
845                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
846                             [return tlsIsMainThread;],
847                             ac_cv_thread_keyword=yes,
848                             ac_cv_thread_keyword=no)])
849 LDFLAGS=$_SAVE_LDFLAGS
850 # The custom dynamic linker doesn't support TLS variables
851 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
852   # mips builds fail with TLS variables because of a binutils bug.
853   # See bug 528687
854   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
855   case "${target}" in
856     mips*-*)
857       :
858       ;;
859     *-android*|*-linuxandroid*)
860       :
861       ;;
862     *-openbsd*)
863       :
864       ;;
865     *)
866       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
867       ;;
868   esac
871 if test -n "$MOZ_LINKER"; then
872 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
873 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
874 dnl Since the linker only understands the sysv ones, no need to build the
875 dnl gnu style tables anyways.
876   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
879 dnl End of C++ language/feature checks
880 AC_LANG_C
882 fi # ! SKIP_COMPILER_CHECKS
884 if test -n "${COMPILE_ENVIRONMENT}"; then
885   MOZ_CHECK_ALLOCATOR
888 TARGET_XPCOM_ABI=
889 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
890     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
891     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
894 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
895 dnl features that Windows actually does support.
897 if test -n "$SKIP_COMPILER_CHECKS"; then
898    dnl Windows has malloc.h
899    AC_DEFINE(MALLOC_H, [<malloc.h>])
900    AC_DEFINE(HAVE_FORCEINLINE)
901 fi # SKIP_COMPILER_CHECKS
903 dnl Mozilla specific options
904 dnl ========================================================
905 dnl The macros used for command line options
906 dnl are defined in build/autoconf/altoptions.m4.
908 dnl ========================================================
909 dnl =
910 dnl = Application
911 dnl =
912 dnl ========================================================
914 MOZ_BRANDING_DIRECTORY=
915 MOZ_OFFICIAL_BRANDING=
916 MOZ_NO_SMART_CARDS=
917 MOZ_BINARY_EXTENSIONS=
918 MOZ_DEVTOOLS=server
920 dnl ========================================================
921 dnl = Trademarked Branding
922 dnl ========================================================
923 MOZ_ARG_ENABLE_BOOL(official-branding,
924 [  --enable-official-branding
925                           Enable Official mozilla.org Branding
926                           Do not distribute builds with
927                           --enable-official-branding unless you have
928                           permission to use trademarks per
929                           http://www.mozilla.org/foundation/trademarks/ .],
930     MOZ_OFFICIAL_BRANDING=1,
931     MOZ_OFFICIAL_BRANDING=)
933 # Allow the application to influence configure with a confvars.sh script.
934 AC_MSG_CHECKING([if app-specific confvars.sh exists])
935 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
936   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
937   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
938 else
939   AC_MSG_RESULT([no])
942 AC_SUBST(MOZ_OFFICIAL_BRANDING)
943 if test -n "$MOZ_OFFICIAL_BRANDING"; then
944   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
945     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
946   else
947     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
948     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
949   fi
952 MOZ_ARG_WITH_STRING(branding,
953 [  --with-branding=dir     Use branding from the specified directory.],
954     MOZ_BRANDING_DIRECTORY=$withval)
956 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
957 if test -z "$REAL_BRANDING_DIRECTORY"; then
958   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
961 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
962   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
965 AC_SUBST(MOZ_BRANDING_DIRECTORY)
967 dnl ========================================================
968 dnl = Distribution ID
969 dnl ========================================================
970 MOZ_ARG_WITH_STRING(distribution-id,
971 [  --with-distribution-id=ID
972                           Set distribution-specific id (default=org.mozilla)],
973 [ val=`echo $withval`
974     MOZ_DISTRIBUTION_ID="$val"])
976 if test -z "$MOZ_DISTRIBUTION_ID"; then
977    MOZ_DISTRIBUTION_ID="org.mozilla"
980 AC_SUBST(MOZ_DISTRIBUTION_ID)
982 dnl ========================================================
983 dnl = Enable code optimization. ON by default.
984 dnl ========================================================
986 # Use value from moz.configure if one is defined. Else use our computed
987 # value.
988 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
989     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
992 if test "$COMPILE_ENVIRONMENT"; then
993 if test -n "$MOZ_OPTIMIZE"; then
994     AC_MSG_CHECKING([for valid C compiler optimization flags])
995     _SAVE_CFLAGS=$CFLAGS
996     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
997     AC_TRY_COMPILE([#include <stdio.h>],
998         [printf("Hello World\n");],
999         _results=yes,
1000         _results=no)
1001     AC_MSG_RESULT([$_results])
1002     if test "$_results" = "no"; then
1003         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
1004     fi
1005     CFLAGS=$_SAVE_CFLAGS
1006     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
1007         # When using llvm-based LTO, non numeric optimization levels are
1008         # not supported by the linker, so force the linker to use -O2 (
1009         # which doesn't influence the level compilation units are actually
1010         # compiled at).
1011         case " $MOZ_OPTIMIZE_FLAGS " in
1012         *\ -Os\ *|*\ -Oz\ *)
1013             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
1014             ;;
1015         esac
1016     fi
1018 fi # COMPILE_ENVIRONMENT
1020 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
1021 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
1022 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
1024 case "${OS_TARGET}" in
1025 Android|WINNT|Darwin)
1026   MOZ_GLUE_IN_PROGRAM=
1027   ;;
1029   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
1030   MOZ_GLUE_IN_PROGRAM=1
1031   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
1032   ;;
1033 esac
1035 dnl ========================================================
1036 dnl = Jemalloc build setup
1037 dnl ========================================================
1038 if test -z "$MOZ_MEMORY"; then
1039   case "${target}" in
1040     *-mingw*)
1041       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
1042         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.])
1043       fi
1044       ;;
1045   esac
1046 else
1047   dnl The generic feature tests that determine how to compute ncpus are long and
1048   dnl complicated.  Therefore, simply define special cpp variables for the
1049   dnl platforms we have special knowledge of.
1050   case "${target}" in
1051   *-mingw*)
1052     export MOZ_NO_DEBUG_RTL=1
1053     ;;
1054   esac
1055 fi # MOZ_MEMORY
1056 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
1058 dnl ========================================================
1059 dnl = Enable using the clang plugin to build
1060 dnl ========================================================
1062 if test -n "$COMPILE_ENVIRONMENT"; then
1063 MOZ_CONFIG_CLANG_PLUGIN
1064 fi # COMPILE_ENVIRONMENT
1066 if test -z "$SKIP_COMPILER_CHECKS"; then
1067 dnl ========================================================
1068 dnl Check for gcc -pipe support
1069 dnl ========================================================
1070 AC_MSG_CHECKING([for -pipe support])
1071 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
1072     dnl Any gcc that supports firefox supports -pipe.
1073     CFLAGS="$CFLAGS -pipe"
1074     CXXFLAGS="$CXXFLAGS -pipe"
1075     AC_MSG_RESULT([yes])
1076 else
1077     AC_MSG_RESULT([no])
1080 fi # ! SKIP_COMPILER_CHECKS
1082 AC_LANG_C
1084 if test "$COMPILE_ENVIRONMENT"; then
1085 MOZ_EXPAND_LIBS
1086 fi # COMPILE_ENVIRONMENT
1088 dnl ========================================================
1089 dnl Check if we need the 32-bit Linux SSE2 error dialog
1090 dnl ========================================================
1092 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
1094 dnl ========================================================
1095 dnl Check for cairo
1096 dnl ========================================================
1098 if test "$OS_ARCH" = "WINNT"; then
1099     # For now we assume that we will have a uint64_t available through
1100     # one of the above headers or mozstdint.h.
1101     AC_DEFINE(HAVE_UINT64_T)
1104 case "$MOZ_WIDGET_TOOLKIT" in
1105   windows)
1106     if test "$COMPILE_ENVIRONMENT"; then
1107       MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
1108     fi
1109     ;;
1110 esac
1111 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
1113 dnl ========================================================
1114 dnl =
1115 dnl = Maintainer debug option (no --enable equivalent)
1116 dnl =
1117 dnl ========================================================
1119 AC_SUBST_LIST(ASFLAGS)
1120 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
1122 AC_SUBST(MOZ_STUB_INSTALLER)
1124 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
1126 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
1128 if test -n "$MOZ_BINARY_EXTENSIONS"; then
1129   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
1132 dnl ========================================================
1133 dnl = Mac bundle name prefix
1134 dnl ========================================================
1135 MOZ_ARG_WITH_STRING(macbundlename-prefix,
1136 [  --with-macbundlename-prefix=prefix
1137                           Prefix for MOZ_MACBUNDLE_NAME],
1138 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
1140 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
1141 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
1142   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
1145 if test "$MOZ_DEBUG"; then
1146   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
1147 else
1148   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
1150 AC_SUBST(MOZ_MACBUNDLE_NAME)
1152 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
1153 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
1154 # Otherwise, use MOZ_APP_DISPLAYNAME
1155 if test -z "$MOZ_MACBUNDLE_ID"; then
1156    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
1158 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
1159 if test "$MOZ_DEBUG"; then
1160   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
1163 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
1164 AC_SUBST(MOZ_MACBUNDLE_ID)
1166 dnl ========================================================
1167 dnl = Child Process Name for IPC
1168 dnl ========================================================
1169 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
1170   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
1171 else
1172   # We want to let Android unpack the file at install time, but it only does
1173   # so if the file is named libsomething.so. The lib/ path is also required
1174   # because the unpacked file will be under the lib/ subdirectory and will
1175   # need to be executed from that path.
1176   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
1178 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
1179 MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
1181 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
1182 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
1183 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
1185 # The following variables are available to branding and application
1186 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
1187 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
1188 # impacts profile location and user-visible fields.
1189 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
1190 # Mac Bundle name, Updater, Installer), it is typically used for nightly
1191 # builds (e.g. Aurora for Firefox).
1192 # - MOZ_APP_PROFILE: When set, used for application.ini's
1193 # "Profile" field, which controls profile location.
1194 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
1195 # crash reporter server url.
1196 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
1198 # The following environment variables used to have an effect, but don't anymore:
1199 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
1200 # the contents from the version.txt file in the application directory, or
1201 # browser/config/version.txt if there isn't one.
1202 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
1203 # in the "About" window. This was replaced with the contents from the
1204 # version_display.txt or version.txt in the application directory, or
1205 # browser/config/version_display.txt.
1207 # For extensions and langpacks, we require a max version that is compatible
1208 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
1209 # 24.0a1 and 24.0a2 aren't affected
1210 # 24.0 becomes 24.*
1211 # 24.1.1 becomes 24.*
1212 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
1213 if test -z "$IS_ALPHA"; then
1214   changequote(,)
1215   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
1216     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
1217   else
1218     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
1219   fi
1220   changequote([,])
1221 else
1222   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
1225 AC_SUBST(MOZ_APP_DISPLAYNAME)
1226 AC_SUBST(MOZ_APP_VENDOR)
1227 AC_SUBST(MOZ_APP_PROFILE)
1228 AC_SUBST(MOZ_APP_ID)
1229 AC_SUBST(MAR_CHANNEL_ID)
1230 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
1231 AC_SUBST(MOZ_PROFILE_MIGRATOR)
1232 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
1233 AC_SUBST(MOZ_APP_UA_NAME)
1234 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
1235 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
1236 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
1238 AC_SUBST(MOZ_APP_MAXVERSION)
1239 AC_SUBST(MOZ_PKG_SPECIAL)
1240 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
1242 if test "$MOZILLA_OFFICIAL"; then
1243     # Build revisions should always be present in official builds
1244     MOZ_INCLUDE_SOURCE_INFO=1
1247 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
1248 # explicitly set the repository and changeset information in.
1249 AC_SUBST(MOZ_SOURCE_REPO)
1250 AC_SUBST(MOZ_SOURCE_CHANGESET)
1251 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
1253 dnl win32 options
1254 AC_SUBST(WIN32_REDIST_DIR)
1255 AC_SUBST(WIN_UCRT_REDIST_DIR)
1257 dnl Echo the CFLAGS to remove extra whitespace.
1258 CFLAGS=`echo \
1259     $_COMPILATION_CFLAGS \
1260     $CFLAGS`
1262 CXXFLAGS=`echo \
1263     $_COMPILATION_CXXFLAGS \
1264     $CXXFLAGS`
1266 COMPILE_CFLAGS=`echo \
1267     $_DEFINES_CFLAGS \
1268     $COMPILE_CFLAGS`
1270 COMPILE_CXXFLAGS=`echo \
1271     $_DEFINES_CXXFLAGS \
1272     $COMPILE_CXXFLAGS`
1274 HOST_CFLAGS=`echo \
1275     $_COMPILATION_HOST_CFLAGS \
1276     $HOST_CFLAGS`
1278 HOST_CXXFLAGS=`echo \
1279     $_COMPILATION_HOST_CXXFLAGS \
1280     $HOST_CXXFLAGS`
1282 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
1283 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1284 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
1285 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1286 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
1287   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1288   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1290 AC_SUBST(HOST_CMFLAGS)
1291 AC_SUBST(HOST_CMMFLAGS)
1292 AC_SUBST(OS_COMPILE_CMFLAGS)
1293 AC_SUBST(OS_COMPILE_CMMFLAGS)
1295 OS_CFLAGS="$CFLAGS"
1296 OS_CXXFLAGS="$CXXFLAGS"
1297 OS_CPPFLAGS="$CPPFLAGS"
1298 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1299 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1300 OS_LDFLAGS="$LDFLAGS"
1301 OS_LIBS="$LIBS"
1302 AC_SUBST_LIST(OS_CFLAGS)
1303 AC_SUBST_LIST(OS_CXXFLAGS)
1304 AC_SUBST_LIST(OS_CPPFLAGS)
1305 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1306 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1307 AC_SUBST_LIST(OS_LDFLAGS)
1308 AC_SUBST(OS_LIBS)
1310 AC_SUBST(HOST_CC)
1311 AC_SUBST(HOST_CXX)
1312 AC_SUBST_LIST(HOST_CFLAGS)
1313 AC_SUBST_LIST(HOST_CPPFLAGS)
1314 AC_SUBST_LIST(HOST_CXXFLAGS)
1315 AC_SUBST(HOST_LDFLAGS)
1316 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1317 AC_SUBST(HOST_BIN_SUFFIX)
1319 AC_SUBST(TARGET_XPCOM_ABI)
1321 AC_SUBST(DSO_LDOPTS)
1322 AC_SUBST(BIN_SUFFIX)
1323 AC_SUBST(USE_N32)
1324 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1325 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1327 AC_SUBST(MOZ_DEVTOOLS)
1329 AC_SUBST(MOZ_PACKAGE_JSSHELL)
1331 AC_SUBST(DMG_TOOL)
1333 dnl Host JavaScript runtime, if any, to use during cross compiles.
1334 AC_SUBST(JS_BINARY)
1336 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
1338 dnl Set various defines and substitutions
1339 dnl ========================================================
1341 AC_SUBST(MOZ_DEV_EDITION)
1342 if test -n "$MOZ_DEV_EDITION"; then
1343     AC_DEFINE(MOZ_DEV_EDITION)
1346 dnl Windows AccessibilityHandler
1347 dnl ========================================================
1349 if test -z "$MOZ_HANDLER_CLSID"; then
1350     MOZ_HANDLER_CLSID="4a195748-dca2-45fb-9295-0a139e76a9e7"
1351     MOZ_IHANDLERCONTROL_IID="3316ce35-f892-4832-97c5-06c52c03cdba"
1352     MOZ_ASYNCIHANDLERCONTROL_IID="15b48b76-ad38-4ad3-bd1a-d3c48a5a9947"
1353     MOZ_IGECKOBACKCHANNEL_IID="dd2e4a89-999e-4d65-8b65-440c923ddb61"
1356 AC_SUBST(MOZ_HANDLER_CLSID)
1357 AC_SUBST(MOZ_IHANDLERCONTROL_IID)
1358 AC_SUBST(MOZ_ASYNCIHANDLERCONTROL_IID)
1359 AC_SUBST(MOZ_IGECKOBACKCHANNEL_IID)
1361 dnl Spit out some output
1362 dnl ========================================================
1364 # Avoid using obsolete NSPR features
1365 AC_DEFINE(NO_NSPR_10_SUPPORT)
1367 MOZ_CREATE_CONFIG_STATUS()
1369 rm -fr confdefs* $ac_clean_files