Bug 1814091 - Move CanvasContext.getPreferredFormat to GPU.getPreferredCanvasFormat...
[gecko.git] / old-configure.in
blob9d995f68f3c8699ccbd09591bd66ab6f2f599d35
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)
102         AC_DEFINE(_USE_MATH_DEFINES) # Otherwise MSVC's math.h doesn't #define M_PI.
104         MSVC_C_RUNTIME_DLL=vcruntime140.dll
105         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
107         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
108         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
110         if test -n "$WIN_UCRT_REDIST_DIR"; then
111           if test ! -d "$WIN_UCRT_REDIST_DIR"; then
112             AC_MSG_ERROR([Invalid Windows UCRT Redist directory: ${WIN_UCRT_REDIST_DIR}])
113           fi
114           WIN_UCRT_REDIST_DIR=`cd "$WIN_UCRT_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
115         fi
117         AC_SUBST(MSVC_C_RUNTIME_DLL)
118         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
120         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
122         if test -n "$WIN32_REDIST_DIR"; then
123           if test ! -d "$WIN32_REDIST_DIR"; then
124             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
125           fi
126           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
127         fi
129         WRAP_STL_INCLUDES=1
130         STL_FLAGS="-I${DIST}/stl_wrappers"
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     CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
153     CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
155     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
156     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
157     # Require OS features provided by IE 8.0 (Win7)
158     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
160     ;;
161 esac
163 if test -n "$_WIN32_MSVC"; then
164     SKIP_PATH_CHECKS=1
165     SKIP_COMPILER_CHECKS=1
166     SKIP_LIBRARY_CHECKS=1
168     # Since we're skipping compiler and library checks, hard-code
169     # some facts here.
170     AC_DEFINE(HAVE_IO_H)
171     AC_DEFINE(HAVE_ISATTY)
174 fi # COMPILE_ENVIRONMENT
176 AC_SUBST(GNU_CC)
177 AC_SUBST(GNU_CXX)
179 AC_SUBST_LIST(STL_FLAGS)
180 AC_SUBST(WRAP_STL_INCLUDES)
182 dnl ========================================================
183 dnl set the defaults first
184 dnl ========================================================
185 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
187 dnl Configure platform-specific CPU architecture compiler options.
188 dnl ==============================================================
189 if test "$COMPILE_ENVIRONMENT"; then
190     MOZ_ARCH_OPTS
191 fi # COMPILE_ENVIRONMENT
193 if test -n "$COMPILE_ENVIRONMENT"; then
194    MOZ_CONFIG_SANITIZE
197 dnl ========================================================
198 dnl GNU specific defaults
199 dnl ========================================================
200 if test "$GNU_CC"; then
201     if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
202         DSO_PIC_CFLAGS='-fPIC'
203         ASFLAGS="$ASFLAGS -fPIC"
204     fi
206     AC_MSG_CHECKING([for --noexecstack option to as])
207     _SAVE_CFLAGS=$CFLAGS
208     CFLAGS="$CFLAGS -Wa,--noexecstack"
209     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
210                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
211                      AC_MSG_RESULT([no]))
212     CFLAGS=$_SAVE_CFLAGS
213     AC_MSG_CHECKING([for -z noexecstack option to ld])
214     _SAVE_LDFLAGS=$LDFLAGS
215     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
216     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
217                   AC_MSG_RESULT([no])
218                   LDFLAGS=$_SAVE_LDFLAGS)
220     AC_MSG_CHECKING([for -z text option to ld])
221     _SAVE_LDFLAGS=$LDFLAGS
222     LDFLAGS="$LDFLAGS -Wl,-z,text"
223     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
224                   AC_MSG_RESULT([no])
225                   LDFLAGS=$_SAVE_LDFLAGS)
227     AC_MSG_CHECKING([for -z relro option to ld])
228     _SAVE_LDFLAGS=$LDFLAGS
229     LDFLAGS="$LDFLAGS -Wl,-z,relro"
230     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
231                   AC_MSG_RESULT([no])
232                   LDFLAGS=$_SAVE_LDFLAGS)
234     AC_MSG_CHECKING([for -z nocopyreloc option to ld])
235     _SAVE_LDFLAGS=$LDFLAGS
236     LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
237     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
238                   AC_MSG_RESULT([no])
239                   LDFLAGS=$_SAVE_LDFLAGS)
241     AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
242     _SAVE_LDFLAGS=$LDFLAGS
243     LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
244     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
245                   AC_MSG_RESULT([no])
246                   LDFLAGS=$_SAVE_LDFLAGS)
248     # While sha1 is deterministic, it is slower.
249     if test -z "$DEVELOPER_OPTIONS" -o "$OS_TARGET" = "Android"; then
250         build_id=sha1
251     else
252         build_id=uuid
253     fi
254     AC_MSG_CHECKING([for --build-id=$build_id option to ld])
255     _SAVE_LDFLAGS=$LDFLAGS
256     LDFLAGS="$LDFLAGS -Wl,--build-id=$build_id"
257     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
258                   AC_MSG_RESULT([no])
259                   LDFLAGS=$_SAVE_LDFLAGS)
261     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
262     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
263     _SAVE_LDFLAGS=$LDFLAGS
264     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
265     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
266                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
267                   AC_MSG_RESULT([no]))
268     LDFLAGS=$_SAVE_LDFLAGS
270     DSO_LDOPTS='-shared'
271     if test "$GCC_USE_GNU_LD"; then
272         # Some tools like ASan use a runtime library that is only
273         # linked against executables, so we must allow undefined
274         # symbols for shared objects in some cases.
275         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
276             # Don't allow undefined symbols in libraries
277             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
279             # BSDs need `environ' exposed for posix_spawn (bug 753046)
280             case "$OS_TARGET" in
281             DragonFly|FreeBSD|NetBSD|OpenBSD)
282                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
283                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
284                 else
285                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
286                 fi
287                 ;;
288             esac
289         fi
290     fi
292     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
294     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
297 if test "$GNU_CXX"; then
298     CXXFLAGS="$CXXFLAGS -fno-exceptions"
300     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
303 dnl ========================================================
304 dnl System overrides of the defaults for host
305 dnl ========================================================
306 case "$host" in
307 *mingw*)
308     if test -n "$_WIN32_MSVC"; then
309         HOST_CFLAGS="$HOST_CFLAGS"
310     else
311         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
312     fi
313     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
314     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
315     HOST_BIN_SUFFIX=.exe
317     case "${host_cpu}" in
318     i*86)
319         if test -n "$_WIN32_MSVC"; then
320             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
321         fi
322         ;;
323     x86_64)
324         if test -n "$_WIN32_MSVC"; then
325             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
326         fi
327         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
328         ;;
329     esac
330     ;;
332 *-darwin*)
333     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
334     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
335     ;;
337 *-linux*|*-kfreebsd*-gnu|*-gnu*)
338     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
339     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
340     ;;
343     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
344     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
345     ;;
346 esac
348 dnl ========================================================
349 dnl System overrides of the defaults for target
350 dnl ========================================================
352 case "$target" in
353 *-darwin*)
354     MOZ_OPTIMIZE_FLAGS="-O3"
355     DSO_LDOPTS=''
357     dnl DTrace and -dead_strip don't interact well. See bug 403132.
358     dnl ===================================================================
359     if test "x$enable_dtrace" = "xyes"; then
360         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
361     else
362         dnl check for the presence of the -dead_strip linker flag
363         AC_MSG_CHECKING([for -dead_strip option to ld])
364         _SAVE_LDFLAGS=$LDFLAGS
365         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
366         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
367         if test -n "$_HAVE_DEAD_STRIP" ; then
368             AC_MSG_RESULT([yes])
369             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
370         else
371             AC_MSG_RESULT([no])
372         fi
374         LDFLAGS=$_SAVE_LDFLAGS
375     fi
377     MOZ_FIX_LINK_PATHS=
378     ;;
380 *-android*|*-linuxandroid*)
381     if test -z "$CLANG_CC"; then
382         MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions -Os"
383     else
384         # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
385         # -Oz is smaller than -Os on clang.
386         MOZ_OPTIMIZE_FLAGS="-Oz"
387         # Disable the outliner, which causes performance regressions, and is
388         # enabled on some platforms at -Oz.
389         if test -z "$MOZ_LTO"; then
390             DISABLE_OUTLINER="-mno-outline"
391             _SAVE_CFLAGS=$CFLAGS
392             CFLAGS="$CFLAGS $DISABLE_OUTLINER"
393             AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
394             CFLAGS="$_SAVE_CFLAGS"
395         else
396             DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
397             _SAVE_LDFLAGS=$LDFLAGS
398             LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
399             AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
400             LDFLAGS="$_SAVE_LDFLAGS"
401         fi
402     fi
403     ;;
405 *-*linux*)
406     if test "$GNU_CC" -o "$GNU_CXX"; then
407         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
408         if test -n "$MOZ_DEBUG"; then
409             MOZ_OPTIMIZE_FLAGS="-Os"
410         else
411             MOZ_OPTIMIZE_FLAGS="-O2"
412         fi
413         if test -z "$CLANG_CC"; then
414            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
415         fi
416     fi
418     case "${target_cpu}" in
419     alpha*)
420         CFLAGS="$CFLAGS -mieee"
421         CXXFLAGS="$CXXFLAGS -mieee"
422     ;;
423     esac
424     ;;
425 *-mingw*)
426     DSO_PIC_CFLAGS=
427     # certain versions of cygwin's makedepend barf on the
428     # #include <string> vs -I./dist/include/string issue so don't use it
429     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
430         # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
431         if test -z "$CLANG_CC"; then
432             AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
433         fi
435         DSO_LDOPTS='-shared'
436         MOZ_FIX_LINK_PATHS=
438         MOZ_OPTIMIZE_FLAGS="-O2"
440         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
441         WIN32_GUI_EXE_LDFLAGS=-mwindows
443         # Silence problematic clang warnings
444         CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
445         LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
446     else
447         TARGET_COMPILER_ABI=msvc
448         # aarch64 doesn't support subsystems below 6.02
449         if test "$CPU_ARCH" = "aarch64"; then
450             WIN32_SUBSYSTEM_VERSION=6.02
451         else
452             WIN32_SUBSYSTEM_VERSION=6.01
453         fi
454         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
455         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
456         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
457         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
458         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
459         CFLAGS="$CFLAGS -Gy -Zc:inline"
460         CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
461         if test "$CPU_ARCH" = "x86"; then
462             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
463             dnl more recent, so set that explicitly here unless another
464             dnl target arch has already been set.
465             changequote(,)
466             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
467               CFLAGS="$CFLAGS -arch:SSE2"
468             fi
469             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
470               CXXFLAGS="$CXXFLAGS -arch:SSE2"
471             fi
472             changequote([,])
473         fi
474         dnl VS2013+ supports -Gw for better linker optimizations.
475         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
476         dnl Disabled on ASan because it causes false-positive ODR violations.
477         if test -z "$MOZ_ASAN"; then
478             CFLAGS="$CFLAGS -Gw"
479             CXXFLAGS="$CXXFLAGS -Gw"
480         else
481             # String tail merging doesn't play nice with ASan's ODR checker.
482             LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
483         fi
484         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
485         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
486         MOZ_DEBUG_LDFLAGS='-DEBUG'
487         if test "$HOST_OS_ARCH" != "WINNT"; then
488           # %_PDB% is a special signal to emit only the PDB basename. This
489           # avoids problems in Windows tools that don't like forward-slashes.
490           MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
491         fi
492         MOZ_OPTIMIZE_FLAGS='-O2'
493         MOZ_FIX_LINK_PATHS=
494         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
495     fi
496     AC_DEFINE(WIN32_LEAN_AND_MEAN)
497     dnl See http://support.microsoft.com/kb/143208 to use STL
498     AC_DEFINE(NOMINMAX)
499     BIN_SUFFIX='.exe'
501     case "$host_os" in
502     cygwin*|msvc*|mks*)
503         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.])
504         ;;
505     esac
507     case "$target" in
508     i*86-*)
509         if test -n "$GNU_CC"; then
510             CFLAGS="$CFLAGS -mstackrealign"
511             CXXFLAGS="$CXXFLAGS -mstackrealign"
512             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
513         else
514             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
515             LDFLAGS="$LDFLAGS -SAFESEH"
516         fi
518         AC_DEFINE(_X86_)
519         ;;
520     x86_64-*)
521         if test -n "$_WIN32_MSVC"; then
522             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
523         fi
524         AC_DEFINE(_AMD64_)
525         ;;
526     aarch64-*)
527         if test -n "$_WIN32_MSVC"; then
528             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
529         fi
530         AC_DEFINE(_ARM64_)
531         ;;
532     *)
533         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
534         ;;
535     esac
536     ;;
538 *-netbsd*)
539     CFLAGS="$CFLAGS -Dunix"
540     CXXFLAGS="$CXXFLAGS -Dunix"
541     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
542         DSO_PIC_CFLAGS='-fPIC -DPIC'
543         DSO_LDOPTS='-shared'
544         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
545     else
546         DSO_PIC_CFLAGS='-fPIC -DPIC'
547         DSO_LDOPTS='-shared'
548     fi
549     # This will fail on a.out systems prior to 1.5.1_ALPHA.
550     if test "$LIBRUNPATH"; then
551         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
552     fi
553     ;;
555 *-openbsd*)
556     if test -z "$X11BASE"; then
557         X11BASE=/usr/X11R6
558     fi
559     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
560     DSO_PIC_CFLAGS='-fPIC'
561     DSO_LDOPTS='-shared -fPIC'
562     if test "$LIBRUNPATH"; then
563         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
564     fi
565     ;;
567 *-solaris*)
568     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
569     ;;
571 esac
573 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
574 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
576 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
577     MOZ_OPTIMIZE_FLAGS="-O"
581 if test -z "$COMPILE_ENVIRONMENT"; then
582     SKIP_COMPILER_CHECKS=1
583     SKIP_LIBRARY_CHECKS=1
584     MOZ_DEBUGGING_OPTS
585 else
586     MOZ_COMPILER_OPTS
587 fi # COMPILE_ENVIRONMENT
589 if test -z "$SKIP_COMPILER_CHECKS"; then
590 dnl Checks for typedefs, structures, and compiler characteristics.
591 dnl ========================================================
592 AC_C_CONST
593 AC_TYPE_MODE_T
594 AC_TYPE_OFF_T
595 AC_TYPE_PID_T
596 AC_TYPE_SIZE_T
597 AC_LANG_CPLUSPLUS
598 AC_LANG_C
600 AC_LANG_CPLUSPLUS
602 MOZ_CXX11
604 AC_LANG_C
606 case "${OS_TARGET}" in
607 Darwin)
608   ;;
610   STL_FLAGS="-I${DIST}/stl_wrappers"
611   WRAP_STL_INCLUDES=1
612   ;;
613 esac
615 if test "$MOZ_BUILD_APP" = "tools/crashreporter/injector"; then
616     WRAP_STL_INCLUDES=
619 dnl Checks for header files.
620 dnl ========================================================
621 AC_HEADER_DIRENT
623 dnl Checks for libraries.
624 dnl ========================================================
625 AC_CHECK_LIB(c_r, gethostbyname_r)
627 dnl We don't want to link with libdl even if it's present on OS X, since
628 dnl it's not used and not part of the default installation. OS/2 has dlfcn
629 dnl in libc.
630 dnl We don't want to link against libm or libpthread on Darwin since
631 dnl they both are just symlinks to libSystem and explicitly linking
632 dnl against libSystem causes issues when debugging (see bug 299601).
633 case $target in
634 *-darwin*)
635     ;;
637     AC_SEARCH_LIBS(dlopen, dl,
638         MOZ_CHECK_HEADER(dlfcn.h,
639         AC_DEFINE(HAVE_DLOPEN)))
640     ;;
641 esac
643 _SAVE_CFLAGS="$CFLAGS"
644 CFLAGS="$CFLAGS -D_GNU_SOURCE"
645 AC_CHECK_FUNCS(dladdr)
646 CFLAGS="$_SAVE_CFLAGS"
648 if test ! "$GNU_CXX"; then
649     AC_CHECK_LIB(C, demangle)
652 AC_CHECK_LIB(socket, socket)
654 dnl ========================================================
655 dnl = pthread support
656 dnl = Start by checking whether the system support pthreads
657 dnl ========================================================
658 case "$target_os" in
659 darwin*)
660     MOZ_USE_PTHREADS=1
661     ;;
663     AC_CHECK_LIB(pthreads, pthread_create,
664         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
665         AC_CHECK_LIB(pthread, pthread_create,
666             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
667             AC_CHECK_LIB(c_r, pthread_create,
668                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
669                 AC_CHECK_LIB(c, pthread_create,
670                     MOZ_USE_PTHREADS=1
671                 )
672             )
673         )
674     )
675     ;;
676 esac
678 dnl ========================================================
679 dnl Do the platform specific pthread hackery
680 dnl ========================================================
681 if test "$MOZ_USE_PTHREADS"x != x
682 then
683     dnl
684     dnl See if -pthread is supported.
685     dnl
686     rm -f conftest*
687     ac_cv_have_dash_pthread=no
688     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
689     echo 'int main() { return 0; }' | cat > conftest.c
690     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
691     if test $? -eq 0; then
692         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
693             ac_cv_have_dash_pthread=yes
694             case "$target_os" in
695             freebsd*)
696 # Freebsd doesn't use -pthread for compiles, it uses them for linking
697                 ;;
698             *)
699                 CFLAGS="$CFLAGS -pthread"
700                 CXXFLAGS="$CXXFLAGS -pthread"
701                 ;;
702             esac
703         fi
704     fi
705     rm -f conftest*
706     AC_MSG_RESULT($ac_cv_have_dash_pthread)
708     dnl
709     dnl See if -pthreads is supported.
710     dnl
711     ac_cv_have_dash_pthreads=no
712     if test "$ac_cv_have_dash_pthread" = "no"; then
713         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
714         echo 'int main() { return 0; }' | cat > conftest.c
715         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
716         if test $? -eq 0; then
717             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
718                 ac_cv_have_dash_pthreads=yes
719                 CFLAGS="$CFLAGS -pthreads"
720                 CXXFLAGS="$CXXFLAGS -pthreads"
721             fi
722         fi
723         rm -f conftest*
724         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
725     fi
727     case "$target" in
728         *-*-freebsd*)
729             AC_DEFINE(_REENTRANT)
730             AC_DEFINE(_THREAD_SAFE)
731             dnl -pthread links in -lpthread, so don't specify it explicitly.
732             if test "$ac_cv_have_dash_pthread" = "yes"; then
733                 _PTHREAD_LDFLAGS="-pthread"
734             fi
735             ;;
737         *-*-openbsd*|*-*-bsdi*)
738             AC_DEFINE(_REENTRANT)
739             AC_DEFINE(_THREAD_SAFE)
740             dnl -pthread links in -lc_r, so don't specify it explicitly.
741             if test "$ac_cv_have_dash_pthread" = "yes"; then
742                 _PTHREAD_LDFLAGS="-pthread"
743             fi
744             ;;
746         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
747             AC_DEFINE(_REENTRANT)
748             ;;
750     esac
751     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
752     AC_SUBST(MOZ_USE_PTHREADS)
753     MOZ_CHECK_HEADERS(pthread.h)
757 dnl Checks for library functions.
758 dnl ========================================================
760 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
761 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
762                ac_cv_clock_monotonic,
763                [for libs in "" -lrt; do
764                     _SAVE_LIBS="$LIBS"
765                     LIBS="$LIBS $libs"
766 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
767 dnl we should or not be able to use it. To detect if we can, we need to make the
768 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
769                     AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
770                                  #include <time.h>],
771                                  [ struct timespec ts;
772                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
773                                  ac_cv_clock_monotonic=$libs
774                                  LIBS="$_SAVE_LIBS"
775                                  break,
776                                  ac_cv_clock_monotonic=no)
777                     LIBS="$_SAVE_LIBS"
778                 done])
779 if test "$ac_cv_clock_monotonic" != "no"; then
780     HAVE_CLOCK_MONOTONIC=1
781     REALTIME_LIBS=$ac_cv_clock_monotonic
782     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
783     AC_SUBST(HAVE_CLOCK_MONOTONIC)
784     AC_SUBST_LIST(REALTIME_LIBS)
787 AC_CACHE_CHECK(
788     [for res_ninit()],
789     ac_cv_func_res_ninit,
790     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
791         dnl no need for res_ninit() on NetBSD and OpenBSD
792         ac_cv_func_res_ninit=no
793      else
794         AC_TRY_LINK([
795             #ifdef linux
796             #define _BSD_SOURCE 1
797             #endif
798             #include <sys/types.h>
799             #include <netinet/in.h>
800             #include <arpa/nameser.h>
801             #include <resolv.h>
802             ],
803             [int foo = res_ninit(&_res);],
804             [ac_cv_func_res_ninit=yes],
805             [ac_cv_func_res_ninit=no])
806      fi
807     ])
809 if test "$ac_cv_func_res_ninit" = "yes"; then
810     AC_DEFINE(HAVE_RES_NINIT)
811 dnl must add the link line we do something as foolish as this... dougt
812 dnl else
813 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
814 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
817 AC_LANG_C
819 dnl ===================================================================
820 dnl ========================================================
821 dnl Put your C++ language/feature checks below
822 dnl ========================================================
823 AC_LANG_CPLUSPLUS
825 ARM_ABI_PREFIX=
826 if test "$GNU_CC"; then
827   if test "$CPU_ARCH" = "arm" ; then
828     AC_CACHE_CHECK(for ARM EABI,
829         ac_cv_gcc_arm_eabi,
830         [AC_TRY_COMPILE([],
831                         [
832 #if defined(__ARM_EABI__)
833   return 0;
834 #else
835 #error Not ARM EABI.
836 #endif
837                         ],
838                         ac_cv_gcc_arm_eabi="yes",
839                         ac_cv_gcc_arm_eabi="no")])
840     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
841         HAVE_ARM_EABI=1
842         ARM_ABI_PREFIX=eabi-
843     else
844         ARM_ABI_PREFIX=oabi-
845     fi
846   fi
848   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
851 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
852 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
853 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
854 # linking XUL.
855 _SAVE_LDFLAGS=$LDFLAGS
856 LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
857 AC_CACHE_CHECK(for __thread keyword for TLS variables,
858                ac_cv_thread_keyword,
859                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
860                             [return tlsIsMainThread;],
861                             ac_cv_thread_keyword=yes,
862                             ac_cv_thread_keyword=no)])
863 LDFLAGS=$_SAVE_LDFLAGS
864 # The custom dynamic linker doesn't support TLS variables
865 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
866   # mips builds fail with TLS variables because of a binutils bug.
867   # See bug 528687
868   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
869   case "${target}" in
870     mips*-*)
871       :
872       ;;
873     *-android*|*-linuxandroid*)
874       :
875       ;;
876     *-openbsd*)
877       :
878       ;;
879     *)
880       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
881       ;;
882   esac
885 if test -n "$MOZ_LINKER"; then
886 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
887 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
888 dnl Since the linker only understands the sysv ones, no need to build the
889 dnl gnu style tables anyways.
890   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
893 dnl End of C++ language/feature checks
894 AC_LANG_C
896 fi # ! SKIP_COMPILER_CHECKS
898 if test -n "${COMPILE_ENVIRONMENT}"; then
899   MOZ_CHECK_ALLOCATOR
902 TARGET_XPCOM_ABI=
903 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
904     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
905     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
908 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
909 dnl features that Windows actually does support.
911 if test -n "$SKIP_COMPILER_CHECKS"; then
912    dnl Windows has malloc.h
913    AC_DEFINE(MALLOC_H, [<malloc.h>])
914    AC_DEFINE(HAVE_FORCEINLINE)
915 fi # SKIP_COMPILER_CHECKS
917 dnl Mozilla specific options
918 dnl ========================================================
919 dnl The macros used for command line options
920 dnl are defined in build/autoconf/altoptions.m4.
922 dnl ========================================================
923 dnl =
924 dnl = Application
925 dnl =
926 dnl ========================================================
928 MOZ_BRANDING_DIRECTORY=
929 MOZ_OFFICIAL_BRANDING=
930 MOZ_NO_SMART_CARDS=
931 MOZ_BINARY_EXTENSIONS=
932 MOZ_DEVTOOLS=server
934 dnl ========================================================
935 dnl = Trademarked Branding
936 dnl ========================================================
937 MOZ_ARG_ENABLE_BOOL(official-branding,
938 [  --enable-official-branding
939                           Enable Official mozilla.org Branding
940                           Do not distribute builds with
941                           --enable-official-branding unless you have
942                           permission to use trademarks per
943                           http://www.mozilla.org/foundation/trademarks/ .],
944     MOZ_OFFICIAL_BRANDING=1,
945     MOZ_OFFICIAL_BRANDING=)
947 # Allow the application to influence configure with a confvars.sh script.
948 AC_MSG_CHECKING([if app-specific confvars.sh exists])
949 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
950   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
951   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
952 else
953   AC_MSG_RESULT([no])
956 AC_SUBST(MOZ_OFFICIAL_BRANDING)
957 if test -n "$MOZ_OFFICIAL_BRANDING"; then
958   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
959     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
960   else
961     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
962     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
963   fi
966 MOZ_ARG_WITH_STRING(branding,
967 [  --with-branding=dir     Use branding from the specified directory.],
968     MOZ_BRANDING_DIRECTORY=$withval)
970 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
971 if test -z "$REAL_BRANDING_DIRECTORY"; then
972   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
975 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
976   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
979 AC_SUBST(MOZ_BRANDING_DIRECTORY)
981 dnl ========================================================
982 dnl = Distribution ID
983 dnl ========================================================
984 MOZ_ARG_WITH_STRING(distribution-id,
985 [  --with-distribution-id=ID
986                           Set distribution-specific id (default=org.mozilla)],
987 [ val=`echo $withval`
988     MOZ_DISTRIBUTION_ID="$val"])
990 if test -z "$MOZ_DISTRIBUTION_ID"; then
991    MOZ_DISTRIBUTION_ID="org.mozilla"
994 AC_SUBST(MOZ_DISTRIBUTION_ID)
996 dnl ========================================================
997 dnl = Enable code optimization. ON by default.
998 dnl ========================================================
1000 # Use value from moz.configure if one is defined. Else use our computed
1001 # value.
1002 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
1003     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
1006 if test "$COMPILE_ENVIRONMENT"; then
1007 if test -n "$MOZ_OPTIMIZE"; then
1008     AC_MSG_CHECKING([for valid C compiler optimization flags])
1009     _SAVE_CFLAGS=$CFLAGS
1010     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
1011     AC_TRY_COMPILE([#include <stdio.h>],
1012         [printf("Hello World\n");],
1013         _results=yes,
1014         _results=no)
1015     AC_MSG_RESULT([$_results])
1016     if test "$_results" = "no"; then
1017         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
1018     fi
1019     CFLAGS=$_SAVE_CFLAGS
1020     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
1021         # When using llvm-based LTO, non numeric optimization levels are
1022         # not supported by the linker, so force the linker to use -O2 (
1023         # which doesn't influence the level compilation units are actually
1024         # compiled at).
1025         case " $MOZ_OPTIMIZE_FLAGS " in
1026         *\ -Os\ *|*\ -Oz\ *)
1027             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
1028             ;;
1029         esac
1030     fi
1032 fi # COMPILE_ENVIRONMENT
1034 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
1035 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
1036 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
1038 case "${OS_TARGET}" in
1039 Android|WINNT|Darwin)
1040   MOZ_GLUE_IN_PROGRAM=
1041   ;;
1043   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
1044   MOZ_GLUE_IN_PROGRAM=1
1045   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
1046   ;;
1047 esac
1049 dnl ========================================================
1050 dnl = Jemalloc build setup
1051 dnl ========================================================
1052 if test -z "$MOZ_MEMORY"; then
1053   case "${target}" in
1054     *-mingw*)
1055       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
1056         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.])
1057       fi
1058       ;;
1059   esac
1060 else
1061   dnl The generic feature tests that determine how to compute ncpus are long and
1062   dnl complicated.  Therefore, simply define special cpp variables for the
1063   dnl platforms we have special knowledge of.
1064   case "${target}" in
1065   *-mingw*)
1066     export MOZ_NO_DEBUG_RTL=1
1067     ;;
1068   esac
1069 fi # MOZ_MEMORY
1070 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
1072 dnl ========================================================
1073 dnl = Enable using the clang plugin to build
1074 dnl ========================================================
1076 if test -n "$COMPILE_ENVIRONMENT"; then
1077 MOZ_CONFIG_CLANG_PLUGIN
1078 fi # COMPILE_ENVIRONMENT
1080 if test -z "$SKIP_COMPILER_CHECKS"; then
1081 dnl ========================================================
1082 dnl Check for gcc -pipe support
1083 dnl ========================================================
1084 AC_MSG_CHECKING([for -pipe support])
1085 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
1086     dnl Any gcc that supports firefox supports -pipe.
1087     CFLAGS="$CFLAGS -pipe"
1088     CXXFLAGS="$CXXFLAGS -pipe"
1089     AC_MSG_RESULT([yes])
1090 else
1091     AC_MSG_RESULT([no])
1094 fi # ! SKIP_COMPILER_CHECKS
1096 AC_LANG_C
1098 if test "$COMPILE_ENVIRONMENT"; then
1099 MOZ_EXPAND_LIBS
1100 fi # COMPILE_ENVIRONMENT
1102 dnl ========================================================
1103 dnl Check if we need the 32-bit Linux SSE2 error dialog
1104 dnl ========================================================
1106 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
1108 dnl ========================================================
1109 dnl Check for cairo
1110 dnl ========================================================
1112 if test "$OS_ARCH" = "WINNT"; then
1113     # For now we assume that we will have a uint64_t available through
1114     # one of the above headers or mozstdint.h.
1115     AC_DEFINE(HAVE_UINT64_T)
1118 case "$MOZ_WIDGET_TOOLKIT" in
1119   windows)
1120     if test "$COMPILE_ENVIRONMENT"; then
1121       MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
1122     fi
1123     ;;
1124 esac
1125 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
1127 dnl ========================================================
1128 dnl =
1129 dnl = Maintainer debug option (no --enable equivalent)
1130 dnl =
1131 dnl ========================================================
1133 AC_SUBST_LIST(ASFLAGS)
1134 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
1136 AC_SUBST(MOZ_STUB_INSTALLER)
1138 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
1140 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
1142 if test -n "$MOZ_BINARY_EXTENSIONS"; then
1143   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
1146 dnl ========================================================
1147 dnl = Mac bundle name prefix
1148 dnl ========================================================
1149 MOZ_ARG_WITH_STRING(macbundlename-prefix,
1150 [  --with-macbundlename-prefix=prefix
1151                           Prefix for MOZ_MACBUNDLE_NAME],
1152 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
1154 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
1155 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
1156   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
1159 if test "$MOZ_DEBUG"; then
1160   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
1161 else
1162   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
1164 AC_SUBST(MOZ_MACBUNDLE_NAME)
1166 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
1167 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
1168 # Otherwise, use MOZ_APP_DISPLAYNAME
1169 if test -z "$MOZ_MACBUNDLE_ID"; then
1170    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
1172 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
1173 if test "$MOZ_DEBUG"; then
1174   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
1177 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
1178 AC_SUBST(MOZ_MACBUNDLE_ID)
1180 dnl ========================================================
1181 dnl = Child Process Name for IPC
1182 dnl ========================================================
1183 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
1184   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
1185 else
1186   # We want to let Android unpack the file at install time, but it only does
1187   # so if the file is named libsomething.so. The lib/ path is also required
1188   # because the unpacked file will be under the lib/ subdirectory and will
1189   # need to be executed from that path.
1190   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
1192 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
1193 MOZ_CHILD_PROCESS_BUNDLENAME="${MOZ_APP_DISPLAYNAME}CP"
1195 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
1196 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
1197 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
1199 # The following variables are available to branding and application
1200 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
1201 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
1202 # impacts profile location and user-visible fields.
1203 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
1204 # Mac Bundle name, Updater, Installer), it is typically used for nightly
1205 # builds (e.g. Aurora for Firefox).
1206 # - MOZ_APP_PROFILE: When set, used for application.ini's
1207 # "Profile" field, which controls profile location.
1208 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
1209 # crash reporter server url.
1210 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
1212 # The following environment variables used to have an effect, but don't anymore:
1213 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
1214 # the contents from the version.txt file in the application directory, or
1215 # browser/config/version.txt if there isn't one.
1216 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
1217 # in the "About" window. This was replaced with the contents from the
1218 # version_display.txt or version.txt in the application directory, or
1219 # browser/config/version_display.txt.
1221 # For extensions and langpacks, we require a max version that is compatible
1222 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
1223 # 24.0a1 and 24.0a2 aren't affected
1224 # 24.0 becomes 24.*
1225 # 24.1.1 becomes 24.*
1226 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
1227 if test -z "$IS_ALPHA"; then
1228   changequote(,)
1229   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
1230     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
1231   else
1232     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
1233   fi
1234   changequote([,])
1235 else
1236   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
1239 AC_SUBST(MOZ_APP_DISPLAYNAME)
1240 AC_SUBST(MOZ_APP_VENDOR)
1241 AC_SUBST(MOZ_APP_PROFILE)
1242 AC_SUBST(MOZ_APP_ID)
1243 AC_SUBST(MAR_CHANNEL_ID)
1244 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
1245 AC_SUBST(MOZ_PROFILE_MIGRATOR)
1246 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
1247 AC_SUBST(MOZ_APP_UA_NAME)
1248 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
1249 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
1250 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
1252 AC_SUBST(MOZ_APP_MAXVERSION)
1253 AC_SUBST(MOZ_PKG_SPECIAL)
1254 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
1256 if test "$MOZILLA_OFFICIAL"; then
1257     # Build revisions should always be present in official builds
1258     MOZ_INCLUDE_SOURCE_INFO=1
1261 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
1262 # explicitly set the repository and changeset information in.
1263 AC_SUBST(MOZ_SOURCE_REPO)
1264 AC_SUBST(MOZ_SOURCE_CHANGESET)
1265 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
1267 dnl win32 options
1268 AC_SUBST(WIN32_REDIST_DIR)
1269 AC_SUBST(WIN_UCRT_REDIST_DIR)
1271 dnl Echo the CFLAGS to remove extra whitespace.
1272 CFLAGS=`echo \
1273     $_COMPILATION_CFLAGS \
1274     $CFLAGS`
1276 CXXFLAGS=`echo \
1277     $_COMPILATION_CXXFLAGS \
1278     $CXXFLAGS`
1280 COMPILE_CFLAGS=`echo \
1281     $_DEFINES_CFLAGS \
1282     $COMPILE_CFLAGS`
1284 COMPILE_CXXFLAGS=`echo \
1285     $_DEFINES_CXXFLAGS \
1286     $COMPILE_CXXFLAGS`
1288 HOST_CFLAGS=`echo \
1289     $_COMPILATION_HOST_CFLAGS \
1290     $HOST_CFLAGS`
1292 HOST_CXXFLAGS=`echo \
1293     $_COMPILATION_HOST_CXXFLAGS \
1294     $HOST_CXXFLAGS`
1296 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
1297 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1298 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
1299 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1300 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
1301   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1302   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1304 AC_SUBST(HOST_CMFLAGS)
1305 AC_SUBST(HOST_CMMFLAGS)
1306 AC_SUBST(OS_COMPILE_CMFLAGS)
1307 AC_SUBST(OS_COMPILE_CMMFLAGS)
1309 OS_CFLAGS="$CFLAGS"
1310 OS_CXXFLAGS="$CXXFLAGS"
1311 OS_CPPFLAGS="$CPPFLAGS"
1312 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1313 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1314 OS_LDFLAGS="$LDFLAGS"
1315 OS_LIBS="$LIBS"
1316 AC_SUBST_LIST(OS_CFLAGS)
1317 AC_SUBST_LIST(OS_CXXFLAGS)
1318 AC_SUBST_LIST(OS_CPPFLAGS)
1319 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1320 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1321 AC_SUBST_LIST(OS_LDFLAGS)
1322 AC_SUBST(OS_LIBS)
1324 AC_SUBST(HOST_CC)
1325 AC_SUBST(HOST_CXX)
1326 AC_SUBST_LIST(HOST_CFLAGS)
1327 AC_SUBST_LIST(HOST_CPPFLAGS)
1328 AC_SUBST_LIST(HOST_CXXFLAGS)
1329 AC_SUBST(HOST_LDFLAGS)
1330 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1331 AC_SUBST(HOST_BIN_SUFFIX)
1333 AC_SUBST(TARGET_XPCOM_ABI)
1335 AC_SUBST(DSO_LDOPTS)
1336 AC_SUBST(BIN_SUFFIX)
1337 AC_SUBST(USE_N32)
1338 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1339 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1341 AC_SUBST(MOZ_DEVTOOLS)
1343 AC_SUBST(MOZ_PACKAGE_JSSHELL)
1345 AC_SUBST(DMG_TOOL)
1347 dnl Host JavaScript runtime, if any, to use during cross compiles.
1348 AC_SUBST(JS_BINARY)
1350 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
1352 dnl Set various defines and substitutions
1353 dnl ========================================================
1355 AC_SUBST(MOZ_DEV_EDITION)
1356 if test -n "$MOZ_DEV_EDITION"; then
1357     AC_DEFINE(MOZ_DEV_EDITION)
1360 dnl Windows AccessibilityHandler
1361 dnl ========================================================
1363 if test -z "$MOZ_HANDLER_CLSID"; then
1364     MOZ_HANDLER_CLSID="4a195748-dca2-45fb-9295-0a139e76a9e7"
1365     MOZ_IHANDLERCONTROL_IID="3316ce35-f892-4832-97c5-06c52c03cdba"
1366     MOZ_ASYNCIHANDLERCONTROL_IID="15b48b76-ad38-4ad3-bd1a-d3c48a5a9947"
1367     MOZ_IGECKOBACKCHANNEL_IID="dd2e4a89-999e-4d65-8b65-440c923ddb61"
1370 AC_SUBST(MOZ_HANDLER_CLSID)
1371 AC_SUBST(MOZ_IHANDLERCONTROL_IID)
1372 AC_SUBST(MOZ_ASYNCIHANDLERCONTROL_IID)
1373 AC_SUBST(MOZ_IGECKOBACKCHANNEL_IID)
1375 dnl Spit out some output
1376 dnl ========================================================
1378 # Avoid using obsolete NSPR features
1379 AC_DEFINE(NO_NSPR_10_SUPPORT)
1381 MOZ_CREATE_CONFIG_STATUS()
1383 rm -fr confdefs* $ac_clean_files