Bug 1872003 uninline AudioSegment::Resample() to remove MediaTrackGraph.h include...
[gecko.git] / old-configure.in
blob4e8ab79448320f20cd02642064601edff090c1b7
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 $PACK_REL_RELOC_FLAGS"
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
71 MOZ_TOOL_VARIABLES
73 dnl ========================================================
74 dnl Special win32 checks
75 dnl ========================================================
77 WINVER=0A00
79 case "$target" in
80 *-mingw*)
81     if test "$GCC" != "yes"; then
82         # Check to see if we are really running in a msvc environemnt
83         _WIN32_MSVC=1
85         # Make sure compilers are valid
86         CXXFLAGS="$CXXFLAGS -TP"
87         AC_LANG_SAVE
88         AC_LANG_C
89         AC_TRY_COMPILE([#include <stdio.h>],
90             [ printf("Hello World\n"); ],,
91             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
93         AC_LANG_CPLUSPLUS
94         AC_TRY_COMPILE([#include <new.h>],
95             [ unsigned *test = new unsigned(42); ],,
96             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
97         AC_LANG_RESTORE
99         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
100         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
102         MSVC_C_RUNTIME_DLL=vcruntime140.dll
103         if test -n "$IS_VS2019_OR_MORE" -a "$TARGET_CPU" != "x86"; then
104             MSVC_C_RUNTIME_1_DLL=vcruntime140_1.dll
105         fi
106         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
108         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
109         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
111         AC_SUBST(MSVC_C_RUNTIME_DLL)
112         AC_SUBST(MSVC_C_RUNTIME_1_DLL)
113         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
115         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
117         if test -n "$WIN32_REDIST_DIR"; then
118           if test ! -d "$WIN32_REDIST_DIR"; then
119             AC_MSG_ERROR([Invalid Win32 Redist directory: ${WIN32_REDIST_DIR}])
120           fi
121           WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && (pwd -W 2>/dev/null || pwd)`
122         fi
123     else
124         # Check w32api version
125         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
126         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
127         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
128         AC_TRY_COMPILE([#include <w32api.h>],
129             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
130                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
131                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
132                 #error "test failed."
133             #endif
134             , [ res=yes ], [ res=no ])
135         AC_MSG_RESULT([$res])
136         if test "$res" != "yes"; then
137             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
138         fi
139         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
140         # causing problems with local implementations with the same name.
141         AC_DEFINE(STRSAFE_NO_DEPRECATE)
142     fi # !GNU_CC
144     AC_DEFINE(_USE_MATH_DEFINES) # Otherwise Windows' math.h doesn't #define M_PI.
146     CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
147     CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
149     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
150     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
151     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0A00)
153     ;;
154 esac
156 if test -n "$_WIN32_MSVC"; then
157     SKIP_PATH_CHECKS=1
158     SKIP_COMPILER_CHECKS=1
159     SKIP_LIBRARY_CHECKS=1
161     # Since we're skipping compiler and library checks, hard-code
162     # some facts here.
163     AC_DEFINE(HAVE_IO_H)
164     AC_DEFINE(HAVE_ISATTY)
167 fi # COMPILE_ENVIRONMENT
169 AC_SUBST(GNU_CC)
170 AC_SUBST(GNU_CXX)
172 dnl ========================================================
173 dnl set the defaults first
174 dnl ========================================================
175 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
177 dnl Configure platform-specific CPU architecture compiler options.
178 dnl ==============================================================
179 if test "$COMPILE_ENVIRONMENT"; then
180     MOZ_ARCH_OPTS
181 fi # COMPILE_ENVIRONMENT
183 if test -n "$COMPILE_ENVIRONMENT"; then
184    MOZ_CONFIG_SANITIZE
187 dnl ========================================================
188 dnl GNU specific defaults
189 dnl ========================================================
190 if test "$GNU_CC"; then
191     if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
192         DSO_PIC_CFLAGS='-fPIC'
193         ASFLAGS="$ASFLAGS -fPIC"
194     fi
196     AC_MSG_CHECKING([for --noexecstack option to as])
197     _SAVE_CFLAGS=$CFLAGS
198     CFLAGS="$CFLAGS -Wa,--noexecstack"
199     AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
200                      [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
201                      AC_MSG_RESULT([no]))
202     CFLAGS=$_SAVE_CFLAGS
203     AC_MSG_CHECKING([for -z noexecstack option to ld])
204     _SAVE_LDFLAGS=$LDFLAGS
205     LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
206     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
207                   AC_MSG_RESULT([no])
208                   LDFLAGS=$_SAVE_LDFLAGS)
210     AC_MSG_CHECKING([for -z text option to ld])
211     _SAVE_LDFLAGS=$LDFLAGS
212     LDFLAGS="$LDFLAGS -Wl,-z,text"
213     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
214                   AC_MSG_RESULT([no])
215                   LDFLAGS=$_SAVE_LDFLAGS)
217     AC_MSG_CHECKING([for -z relro option to ld])
218     _SAVE_LDFLAGS=$LDFLAGS
219     LDFLAGS="$LDFLAGS -Wl,-z,relro"
220     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
221                   AC_MSG_RESULT([no])
222                   LDFLAGS=$_SAVE_LDFLAGS)
224     AC_MSG_CHECKING([for -z now option to ld])
225     _SAVE_LDFLAGS=$LDFLAGS
226     LDFLAGS="$LDFLAGS -Wl,-z,now"
227     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
228                   AC_MSG_RESULT([no])
229                   LDFLAGS=$_SAVE_LDFLAGS)
231     AC_MSG_CHECKING([for -z nocopyreloc option to ld])
232     _SAVE_LDFLAGS=$LDFLAGS
233     LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
234     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
235                   AC_MSG_RESULT([no])
236                   LDFLAGS=$_SAVE_LDFLAGS)
238     AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
239     _SAVE_LDFLAGS=$LDFLAGS
240     LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
241     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
242                   AC_MSG_RESULT([no])
243                   LDFLAGS=$_SAVE_LDFLAGS)
245     # While sha1 is deterministic, it is slower.
246     if test -z "$DEVELOPER_OPTIONS"; then
247         build_id=sha1
248     else
249         build_id=uuid
250     fi
251     AC_MSG_CHECKING([for --build-id=$build_id option to ld])
252     _SAVE_LDFLAGS=$LDFLAGS
253     LDFLAGS="$LDFLAGS -Wl,--build-id=$build_id"
254     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
255                   AC_MSG_RESULT([no])
256                   LDFLAGS=$_SAVE_LDFLAGS)
258     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
259     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
260     _SAVE_LDFLAGS=$LDFLAGS
261     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
262     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
263                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
264                   AC_MSG_RESULT([no]))
265     LDFLAGS=$_SAVE_LDFLAGS
267     DSO_LDOPTS='-shared'
268     if test "$GCC_USE_GNU_LD"; then
269         # Some tools like ASan use a runtime library that is only
270         # linked against executables, so we must allow undefined
271         # symbols for shared objects in some cases.
272         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
273             # Don't allow undefined symbols in libraries
274             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
276             # BSDs need `environ' exposed for posix_spawn (bug 753046)
277             case "$OS_TARGET" in
278             DragonFly|FreeBSD|NetBSD|OpenBSD)
279                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
280                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
281                 else
282                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
283                 fi
284                 ;;
285             esac
286         fi
287     fi
289     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
291     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
294 if test "$GNU_CXX"; then
295     CXXFLAGS="$CXXFLAGS -fno-exceptions"
297     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
300 dnl ========================================================
301 dnl System overrides of the defaults for host
302 dnl ========================================================
303 case "$host" in
304 *mingw*)
305     if test -n "$_WIN32_MSVC"; then
306         HOST_CFLAGS="$HOST_CFLAGS"
307     else
308         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
309     fi
310     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
311     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
312     HOST_BIN_SUFFIX=.exe
314     case "${host_cpu}" in
315     i*86)
316         if test -n "$_WIN32_MSVC"; then
317             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
318         fi
319         ;;
320     x86_64)
321         if test -n "$_WIN32_MSVC"; then
322             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
323         fi
324         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
325         ;;
326     esac
327     ;;
329 *-darwin*)
330     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
331     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
332     ;;
334 *-linux*|*-kfreebsd*-gnu|*-gnu*)
335     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
336     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
337     ;;
340     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
341     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
342     ;;
343 esac
345 dnl ========================================================
346 dnl System overrides of the defaults for target
347 dnl ========================================================
349 case "$target" in
350 *-darwin*)
351     MOZ_OPTIMIZE_FLAGS="-O3"
352     DSO_LDOPTS=''
354     dnl DTrace and -dead_strip don't interact well. See bug 403132.
355     dnl ===================================================================
356     if test "x$enable_dtrace" = "xyes"; then
357         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
358     else
359         dnl check for the presence of the -dead_strip linker flag
360         AC_MSG_CHECKING([for -dead_strip option to ld])
361         _SAVE_LDFLAGS=$LDFLAGS
362         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
363         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
364         if test -n "$_HAVE_DEAD_STRIP" ; then
365             AC_MSG_RESULT([yes])
366             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
367         else
368             AC_MSG_RESULT([no])
369         fi
371         LDFLAGS=$_SAVE_LDFLAGS
372     fi
374     MOZ_FIX_LINK_PATHS=
375     ;;
377 *-android*|*-linuxandroid*)
378     # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
379     # -Oz is smaller than -Os on clang.
380     MOZ_OPTIMIZE_FLAGS="-Oz"
381     # Disable the outliner, which causes performance regressions, and is
382     # enabled on some platforms at -Oz.
383     if test -z "$MOZ_LTO"; then
384         DISABLE_OUTLINER="-mno-outline"
385         _SAVE_CFLAGS=$CFLAGS
386         CFLAGS="$CFLAGS $DISABLE_OUTLINER"
387         AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
388         CFLAGS="$_SAVE_CFLAGS"
389    else
390         DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
391         _SAVE_LDFLAGS=$LDFLAGS
392         LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
393         AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
394         LDFLAGS="$_SAVE_LDFLAGS"
395     fi
396     ;;
398 *-*linux*)
399     if test "$GNU_CC" -o "$GNU_CXX"; then
400         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
401         MOZ_OPTIMIZE_FLAGS="-O2"
402         if test -z "$CLANG_CC"; then
403            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
404         fi
405     fi
407     case "${target_cpu}" in
408     alpha*)
409         CFLAGS="$CFLAGS -mieee"
410         CXXFLAGS="$CXXFLAGS -mieee"
411     ;;
412     esac
413     ;;
414 *-mingw*)
415     DSO_PIC_CFLAGS=
416     # certain versions of cygwin's makedepend barf on the
417     # #include <string> vs -I./dist/include/string issue so don't use it
418     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
419         # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
420         if test -z "$CLANG_CC"; then
421             AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
422         fi
424         DSO_LDOPTS='-shared'
425         MOZ_FIX_LINK_PATHS=
427         MOZ_OPTIMIZE_FLAGS="-O2"
429         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
430         WIN32_GUI_EXE_LDFLAGS=-mwindows
432         # Silence problematic clang warnings
433         CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
434         LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
435     else
436         TARGET_COMPILER_ABI=msvc
437         WIN32_SUBSYSTEM_VERSION=10.0
438         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
439         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
440         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
441         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
442         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
443         CFLAGS="$CFLAGS -Gy -Zc:inline"
444         CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
445         if test "$TARGET_CPU" = "x86"; then
446             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
447             dnl more recent, so set that explicitly here unless another
448             dnl target arch has already been set.
449             changequote(,)
450             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
451               CFLAGS="$CFLAGS -arch:SSE2"
452             fi
453             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
454               CXXFLAGS="$CXXFLAGS -arch:SSE2"
455             fi
456             changequote([,])
457         fi
458         dnl VS2013+ supports -Gw for better linker optimizations.
459         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
460         dnl Disabled on ASan because it causes false-positive ODR violations.
461         if test -z "$MOZ_ASAN"; then
462             CFLAGS="$CFLAGS -Gw"
463             CXXFLAGS="$CXXFLAGS -Gw"
464         else
465             # String tail merging doesn't play nice with ASan's ODR checker.
466             LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
467         fi
468         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
469         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
470         MOZ_DEBUG_LDFLAGS='-DEBUG'
471         if test "$HOST_OS_ARCH" != "WINNT"; then
472           # %_PDB% is a special signal to emit only the PDB basename. This
473           # avoids problems in Windows tools that don't like forward-slashes.
474           MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
475         fi
476         MOZ_OPTIMIZE_FLAGS='-O2'
477         MOZ_FIX_LINK_PATHS=
478         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
479     fi
480     AC_DEFINE(WIN32_LEAN_AND_MEAN)
481     dnl See http://support.microsoft.com/kb/143208 to use STL
482     AC_DEFINE(NOMINMAX)
483     BIN_SUFFIX='.exe'
485     case "$host_os" in
486     cygwin*|msvc*|mks*)
487         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.])
488         ;;
489     esac
491     case "$target" in
492     i*86-*)
493         if test -n "$GNU_CC"; then
494             CFLAGS="$CFLAGS -mstackrealign"
495             CXXFLAGS="$CXXFLAGS -mstackrealign"
496             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
497         else
498             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
499             LDFLAGS="$LDFLAGS -SAFESEH"
500         fi
502         AC_DEFINE(_X86_)
503         ;;
504     x86_64-*)
505         if test -n "$_WIN32_MSVC"; then
506             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
507         fi
508         AC_DEFINE(_AMD64_)
509         ;;
510     aarch64-*)
511         if test -n "$_WIN32_MSVC"; then
512             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
513         fi
514         AC_DEFINE(_ARM64_)
515         ;;
516     *)
517         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
518         ;;
519     esac
520     ;;
522 *-netbsd*)
523     CFLAGS="$CFLAGS -Dunix"
524     CXXFLAGS="$CXXFLAGS -Dunix"
525     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
526         DSO_PIC_CFLAGS='-fPIC -DPIC'
527         DSO_LDOPTS='-shared'
528         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
529     else
530         DSO_PIC_CFLAGS='-fPIC -DPIC'
531         DSO_LDOPTS='-shared'
532     fi
533     # This will fail on a.out systems prior to 1.5.1_ALPHA.
534     if test "$LIBRUNPATH"; then
535         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
536     fi
537     ;;
539 *-openbsd*)
540     if test -z "$X11BASE"; then
541         X11BASE=/usr/X11R6
542     fi
543     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
544     DSO_PIC_CFLAGS='-fPIC'
545     DSO_LDOPTS='-shared -fPIC'
546     if test "$LIBRUNPATH"; then
547         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
548     fi
549     ;;
551 *-solaris*)
552     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
553     ;;
555 esac
557 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
558 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
560 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
561     MOZ_OPTIMIZE_FLAGS="-O"
565 if test -z "$COMPILE_ENVIRONMENT"; then
566     SKIP_COMPILER_CHECKS=1
567     SKIP_LIBRARY_CHECKS=1
568     MOZ_DEBUGGING_OPTS
569 else
570     MOZ_COMPILER_OPTS
571 fi # COMPILE_ENVIRONMENT
573 if test -z "$SKIP_COMPILER_CHECKS"; then
574 dnl Checks for typedefs, structures, and compiler characteristics.
575 dnl ========================================================
576 AC_C_CONST
577 AC_TYPE_MODE_T
578 AC_TYPE_OFF_T
579 AC_TYPE_PID_T
580 AC_TYPE_SIZE_T
581 AC_LANG_CPLUSPLUS
582 AC_LANG_C
584 AC_LANG_CPLUSPLUS
586 MOZ_CXX11
588 AC_LANG_C
590 dnl Checks for header files.
591 dnl ========================================================
592 AC_HEADER_DIRENT
594 dnl Checks for libraries.
595 dnl ========================================================
596 AC_CHECK_LIB(c_r, gethostbyname_r)
598 dnl We don't want to link with libdl even if it's present on OS X, since
599 dnl it's not used and not part of the default installation. OS/2 has dlfcn
600 dnl in libc.
601 dnl We don't want to link against libm or libpthread on Darwin since
602 dnl they both are just symlinks to libSystem and explicitly linking
603 dnl against libSystem causes issues when debugging (see bug 299601).
604 case $target in
605 *-darwin*)
606     ;;
608     AC_SEARCH_LIBS(dlopen, dl,
609         MOZ_CHECK_HEADER(dlfcn.h,
610         AC_DEFINE(HAVE_DLOPEN)))
611     ;;
612 esac
614 _SAVE_CFLAGS="$CFLAGS"
615 CFLAGS="$CFLAGS -D_GNU_SOURCE"
616 AC_CHECK_FUNCS(dladdr)
617 CFLAGS="$_SAVE_CFLAGS"
619 if test ! "$GNU_CXX"; then
620     AC_CHECK_LIB(C, demangle)
623 AC_CHECK_LIB(socket, socket)
625 dnl ========================================================
626 dnl = pthread support
627 dnl = Start by checking whether the system support pthreads
628 dnl ========================================================
629 case "$target_os" in
630 darwin*)
631     MOZ_USE_PTHREADS=1
632     ;;
634     AC_CHECK_LIB(pthreads, pthread_create,
635         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
636         AC_CHECK_LIB(pthread, pthread_create,
637             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
638             AC_CHECK_LIB(c_r, pthread_create,
639                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
640                 AC_CHECK_LIB(c, pthread_create,
641                     MOZ_USE_PTHREADS=1
642                 )
643             )
644         )
645     )
646     ;;
647 esac
649 dnl ========================================================
650 dnl Do the platform specific pthread hackery
651 dnl ========================================================
652 if test "$MOZ_USE_PTHREADS"x != x
653 then
654     dnl
655     dnl See if -pthread is supported.
656     dnl
657     rm -f conftest*
658     ac_cv_have_dash_pthread=no
659     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
660     echo 'int main() { return 0; }' | cat > conftest.c
661     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
662     if test $? -eq 0; then
663         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
664             ac_cv_have_dash_pthread=yes
665             case "$target_os" in
666             freebsd*)
667 # Freebsd doesn't use -pthread for compiles, it uses them for linking
668                 ;;
669             *)
670                 CFLAGS="$CFLAGS -pthread"
671                 CXXFLAGS="$CXXFLAGS -pthread"
672                 ;;
673             esac
674         fi
675     fi
676     rm -f conftest*
677     AC_MSG_RESULT($ac_cv_have_dash_pthread)
679     dnl
680     dnl See if -pthreads is supported.
681     dnl
682     ac_cv_have_dash_pthreads=no
683     if test "$ac_cv_have_dash_pthread" = "no"; then
684         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
685         echo 'int main() { return 0; }' | cat > conftest.c
686         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
687         if test $? -eq 0; then
688             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
689                 ac_cv_have_dash_pthreads=yes
690                 CFLAGS="$CFLAGS -pthreads"
691                 CXXFLAGS="$CXXFLAGS -pthreads"
692             fi
693         fi
694         rm -f conftest*
695         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
696     fi
698     case "$target" in
699         *-*-freebsd*)
700             AC_DEFINE(_REENTRANT)
701             AC_DEFINE(_THREAD_SAFE)
702             dnl -pthread links in -lpthread, so don't specify it explicitly.
703             if test "$ac_cv_have_dash_pthread" = "yes"; then
704                 _PTHREAD_LDFLAGS="-pthread"
705             fi
706             ;;
708         *-*-openbsd*|*-*-bsdi*)
709             AC_DEFINE(_REENTRANT)
710             AC_DEFINE(_THREAD_SAFE)
711             dnl -pthread links in -lc_r, so don't specify it explicitly.
712             if test "$ac_cv_have_dash_pthread" = "yes"; then
713                 _PTHREAD_LDFLAGS="-pthread"
714             fi
715             ;;
717         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
718             AC_DEFINE(_REENTRANT)
719             ;;
721     esac
722     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
723     AC_SUBST(MOZ_USE_PTHREADS)
724     MOZ_CHECK_HEADERS(pthread.h)
728 dnl Checks for library functions.
729 dnl ========================================================
731 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
732 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
733                ac_cv_clock_monotonic,
734                [for libs in "" -lrt; do
735                     _SAVE_LIBS="$LIBS"
736                     LIBS="$LIBS $libs"
737 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
738 dnl we should or not be able to use it. To detect if we can, we need to make the
739 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
740                     AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
741                                  #include <time.h>],
742                                  [ struct timespec ts;
743                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
744                                  ac_cv_clock_monotonic=$libs
745                                  LIBS="$_SAVE_LIBS"
746                                  break,
747                                  ac_cv_clock_monotonic=no)
748                     LIBS="$_SAVE_LIBS"
749                 done])
750 if test "$ac_cv_clock_monotonic" != "no"; then
751     HAVE_CLOCK_MONOTONIC=1
752     REALTIME_LIBS=$ac_cv_clock_monotonic
753     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
754     AC_SUBST(HAVE_CLOCK_MONOTONIC)
755     AC_SUBST_LIST(REALTIME_LIBS)
758 AC_CACHE_CHECK(
759     [for res_ninit()],
760     ac_cv_func_res_ninit,
761     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
762         dnl no need for res_ninit() on NetBSD and OpenBSD
763         ac_cv_func_res_ninit=no
764      else
765         AC_TRY_LINK([
766             #ifdef linux
767             #define _BSD_SOURCE 1
768             #endif
769             #include <sys/types.h>
770             #include <netinet/in.h>
771             #include <arpa/nameser.h>
772             #include <resolv.h>
773             ],
774             [int foo = res_ninit(&_res);],
775             [ac_cv_func_res_ninit=yes],
776             [ac_cv_func_res_ninit=no])
777      fi
778     ])
780 if test "$ac_cv_func_res_ninit" = "yes"; then
781     AC_DEFINE(HAVE_RES_NINIT)
782 dnl must add the link line we do something as foolish as this... dougt
783 dnl else
784 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
785 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
788 AC_LANG_C
790 dnl ===================================================================
791 dnl ========================================================
792 dnl Put your C++ language/feature checks below
793 dnl ========================================================
794 AC_LANG_CPLUSPLUS
796 ARM_ABI_PREFIX=
797 if test "$GNU_CC"; then
798   if test "$TARGET_CPU" = "arm" ; then
799     AC_CACHE_CHECK(for ARM EABI,
800         ac_cv_gcc_arm_eabi,
801         [AC_TRY_COMPILE([],
802                         [
803 #if defined(__ARM_EABI__)
804   return 0;
805 #else
806 #error Not ARM EABI.
807 #endif
808                         ],
809                         ac_cv_gcc_arm_eabi="yes",
810                         ac_cv_gcc_arm_eabi="no")])
811     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
812         HAVE_ARM_EABI=1
813         ARM_ABI_PREFIX=eabi-
814     else
815         ARM_ABI_PREFIX=oabi-
816     fi
817   fi
819   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
822 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
823 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
824 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
825 # linking XUL.
826 _SAVE_LDFLAGS=$LDFLAGS
827 LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
828 AC_CACHE_CHECK(for __thread keyword for TLS variables,
829                ac_cv_thread_keyword,
830                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
831                             [return tlsIsMainThread;],
832                             ac_cv_thread_keyword=yes,
833                             ac_cv_thread_keyword=no)])
834 LDFLAGS=$_SAVE_LDFLAGS
835 # The custom dynamic linker doesn't support TLS variables
836 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
837   # mips builds fail with TLS variables because of a binutils bug.
838   # See bug 528687
839   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
840   case "${target}" in
841     mips*-*)
842       :
843       ;;
844     *-android*|*-linuxandroid*)
845       :
846       ;;
847     *-openbsd*)
848       :
849       ;;
850     *)
851       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
852       ;;
853   esac
856 if test -n "$MOZ_LINKER"; then
857 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
858 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
859 dnl Since the linker only understands the sysv ones, no need to build the
860 dnl gnu style tables anyways.
861   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
864 dnl End of C++ language/feature checks
865 AC_LANG_C
867 fi # ! SKIP_COMPILER_CHECKS
869 if test -n "${COMPILE_ENVIRONMENT}"; then
870   MOZ_CHECK_ALLOCATOR
873 TARGET_XPCOM_ABI=
874 if test -n "${TARGET_CPU}" -a -n "${TARGET_COMPILER_ABI}"; then
875     TARGET_XPCOM_ABI="${TARGET_CPU}-${TARGET_COMPILER_ABI}"
876     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
879 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
880 dnl features that Windows actually does support.
882 if test -n "$SKIP_COMPILER_CHECKS"; then
883    dnl Windows has malloc.h
884    AC_DEFINE(MALLOC_H, [<malloc.h>])
885    AC_DEFINE(HAVE_FORCEINLINE)
886 fi # SKIP_COMPILER_CHECKS
888 dnl Mozilla specific options
889 dnl ========================================================
890 dnl The macros used for command line options
891 dnl are defined in build/autoconf/altoptions.m4.
893 dnl ========================================================
894 dnl =
895 dnl = Application
896 dnl =
897 dnl ========================================================
899 MOZ_BRANDING_DIRECTORY=
900 MOZ_OFFICIAL_BRANDING=
901 MOZ_NO_SMART_CARDS=
902 MOZ_BINARY_EXTENSIONS=
903 MOZ_DEVTOOLS=server
905 dnl ========================================================
906 dnl = Trademarked Branding
907 dnl ========================================================
908 MOZ_ARG_ENABLE_BOOL(official-branding,
909 [  --enable-official-branding
910                           Enable Official mozilla.org Branding
911                           Do not distribute builds with
912                           --enable-official-branding unless you have
913                           permission to use trademarks per
914                           http://www.mozilla.org/foundation/trademarks/ .],
915     MOZ_OFFICIAL_BRANDING=1,
916     MOZ_OFFICIAL_BRANDING=)
918 # Allow the application to influence configure with a confvars.sh script.
919 AC_MSG_CHECKING([if app-specific confvars.sh exists])
920 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
921   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
922   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
923 else
924   AC_MSG_RESULT([no])
927 AC_SUBST(MOZ_OFFICIAL_BRANDING)
928 if test -n "$MOZ_OFFICIAL_BRANDING"; then
929   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
930     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
931   else
932     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
933     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
934   fi
937 MOZ_ARG_WITH_STRING(branding,
938 [  --with-branding=dir     Use branding from the specified directory.],
939     MOZ_BRANDING_DIRECTORY=$withval)
941 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
942 if test -z "$REAL_BRANDING_DIRECTORY"; then
943   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
946 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
947   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
950 AC_SUBST(MOZ_BRANDING_DIRECTORY)
952 dnl ========================================================
953 dnl = Distribution ID
954 dnl ========================================================
955 MOZ_ARG_WITH_STRING(distribution-id,
956 [  --with-distribution-id=ID
957                           Set distribution-specific id (default=org.mozilla)],
958 [ val=`echo $withval`
959     MOZ_DISTRIBUTION_ID="$val"])
961 if test -z "$MOZ_DISTRIBUTION_ID"; then
962    MOZ_DISTRIBUTION_ID="org.mozilla"
965 AC_SUBST(MOZ_DISTRIBUTION_ID)
967 dnl ========================================================
968 dnl = Enable code optimization. ON by default.
969 dnl ========================================================
971 # Use value from moz.configure if one is defined. Else use our computed
972 # value.
973 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
974     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
977 if test "$COMPILE_ENVIRONMENT"; then
978 if test -n "$MOZ_OPTIMIZE"; then
979     AC_MSG_CHECKING([for valid C compiler optimization flags])
980     _SAVE_CFLAGS=$CFLAGS
981     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
982     AC_TRY_COMPILE([#include <stdio.h>],
983         [printf("Hello World\n");],
984         _results=yes,
985         _results=no)
986     AC_MSG_RESULT([$_results])
987     if test "$_results" = "no"; then
988         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
989     fi
990     CFLAGS=$_SAVE_CFLAGS
991     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
992         # When using llvm-based LTO, non numeric optimization levels are
993         # not supported by the linker, so force the linker to use -O2 (
994         # which doesn't influence the level compilation units are actually
995         # compiled at).
996         case " $MOZ_OPTIMIZE_FLAGS " in
997         *\ -Os\ *|*\ -Oz\ *)
998             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
999             ;;
1000         esac
1001     fi
1003 fi # COMPILE_ENVIRONMENT
1005 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
1006 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
1007 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
1009 case "${OS_TARGET}" in
1010 Android|WINNT|Darwin)
1011   MOZ_GLUE_IN_PROGRAM=
1012   ;;
1014   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
1015   MOZ_GLUE_IN_PROGRAM=1
1016   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
1017   ;;
1018 esac
1020 dnl ========================================================
1021 dnl = Jemalloc build setup
1022 dnl ========================================================
1023 if test -z "$MOZ_MEMORY"; then
1024   case "${target}" in
1025     *-mingw*)
1026       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
1027         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.])
1028       fi
1029       ;;
1030   esac
1031 else
1032   dnl The generic feature tests that determine how to compute ncpus are long and
1033   dnl complicated.  Therefore, simply define special cpp variables for the
1034   dnl platforms we have special knowledge of.
1035   case "${target}" in
1036   *-mingw*)
1037     export MOZ_NO_DEBUG_RTL=1
1038     ;;
1039   esac
1040 fi # MOZ_MEMORY
1041 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
1043 dnl ========================================================
1044 dnl = Enable using the clang plugin to build
1045 dnl ========================================================
1047 if test -n "$COMPILE_ENVIRONMENT"; then
1048 MOZ_CONFIG_CLANG_PLUGIN
1049 fi # COMPILE_ENVIRONMENT
1051 if test -z "$SKIP_COMPILER_CHECKS"; then
1052 dnl ========================================================
1053 dnl Check for gcc -pipe support
1054 dnl ========================================================
1055 AC_MSG_CHECKING([for -pipe support])
1056 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
1057     dnl Any gcc that supports firefox supports -pipe.
1058     CFLAGS="$CFLAGS -pipe"
1059     CXXFLAGS="$CXXFLAGS -pipe"
1060     AC_MSG_RESULT([yes])
1061 else
1062     AC_MSG_RESULT([no])
1065 fi # ! SKIP_COMPILER_CHECKS
1067 AC_LANG_C
1069 if test "$COMPILE_ENVIRONMENT"; then
1070 MOZ_EXPAND_LIBS
1071 fi # COMPILE_ENVIRONMENT
1073 dnl ========================================================
1074 dnl Check if we need the 32-bit Linux SSE2 error dialog
1075 dnl ========================================================
1077 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
1079 dnl ========================================================
1080 dnl Check for cairo
1081 dnl ========================================================
1083 if test "$OS_ARCH" = "WINNT"; then
1084     # For now we assume that we will have a uint64_t available through
1085     # one of the above headers or mozstdint.h.
1086     AC_DEFINE(HAVE_UINT64_T)
1089 case "$MOZ_WIDGET_TOOLKIT" in
1090   windows)
1091     if test "$COMPILE_ENVIRONMENT"; then
1092       MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
1093     fi
1094     ;;
1095 esac
1096 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
1098 dnl ========================================================
1099 dnl =
1100 dnl = Maintainer debug option (no --enable equivalent)
1101 dnl =
1102 dnl ========================================================
1104 AC_SUBST_LIST(ASFLAGS)
1105 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
1107 AC_SUBST(MOZ_STUB_INSTALLER)
1109 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
1111 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
1113 if test -n "$MOZ_BINARY_EXTENSIONS"; then
1114   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
1117 dnl ========================================================
1118 dnl = Mac bundle name prefix
1119 dnl ========================================================
1120 MOZ_ARG_WITH_STRING(macbundlename-prefix,
1121 [  --with-macbundlename-prefix=prefix
1122                           Prefix for MOZ_MACBUNDLE_NAME],
1123 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
1125 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
1126 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
1127   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
1130 if test "$MOZ_DEBUG"; then
1131   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
1132 else
1133   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
1135 AC_SUBST(MOZ_MACBUNDLE_NAME)
1137 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
1138 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
1139 # Otherwise, use MOZ_APP_DISPLAYNAME
1140 if test -z "$MOZ_MACBUNDLE_ID"; then
1141    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
1143 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
1144 if test "$MOZ_DEBUG"; then
1145   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
1148 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
1149 AC_SUBST(MOZ_MACBUNDLE_ID)
1151 dnl ========================================================
1152 dnl = Child Process Name for IPC
1153 dnl ========================================================
1154 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
1155   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
1156 else
1157   # We want to let Android unpack the file at install time, but it only does
1158   # so if the file is named libsomething.so. The lib/ path is also required
1159   # because the unpacked file will be under the lib/ subdirectory and will
1160   # need to be executed from that path.
1161   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
1163 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
1164 MOZ_CHILD_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.plugincontainer
1165 MOZ_CHILD_PROCESS_BUNDLENAME="plugin-container.app"
1166 MOZ_CHILD_PROCESS_APPNAME="${MOZ_APP_DISPLAYNAME}CP"
1168 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
1169 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
1170 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLEID)
1171 AC_SUBST(MOZ_CHILD_PROCESS_APPNAME)
1172 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
1174 dnl ==========================================================
1175 dnl = Mac Media Plugin Helper (GMP Child) Process Name for IPC
1176 dnl ==========================================================
1177 MOZ_EME_PROCESS_NAME="media-plugin-helper"
1178 MOZ_EME_PROCESS_NAME_BRANDED="$MOZ_APP_DISPLAYNAME Media Plugin Helper"
1179 MOZ_EME_PROCESS_BUNDLENAME="${MOZ_EME_PROCESS_NAME}.app"
1180 # Generate a lower case string with no spaces to be used as the bundle ID
1181 # for the EME helper .app of the form org.mozilla.<executable-name>.
1182 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_APP_DISPLAYNAME" | tr ' ' '-'`
1183 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_EME_PROCESS_BUNDLEID" | tr 'A-Z' 'a-z'`
1184 MOZ_EME_PROCESS_BUNDLEID=${MOZ_EME_PROCESS_BUNDLEID}-${MOZ_EME_PROCESS_NAME}
1185 MOZ_EME_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.${MOZ_EME_PROCESS_BUNDLEID}
1187 AC_SUBST(MOZ_EME_PROCESS_NAME)
1188 AC_SUBST(MOZ_EME_PROCESS_NAME_BRANDED)
1189 AC_SUBST(MOZ_EME_PROCESS_BUNDLENAME)
1190 AC_SUBST(MOZ_EME_PROCESS_BUNDLEID)
1192 # The following variables are available to branding and application
1193 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
1194 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
1195 # impacts profile location and user-visible fields.
1196 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
1197 # Mac Bundle name, Updater, Installer), it is typically used for nightly
1198 # builds (e.g. Aurora for Firefox).
1199 # - MOZ_APP_PROFILE: When set, used for application.ini's
1200 # "Profile" field, which controls profile location.
1201 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
1202 # crash reporter server url.
1203 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
1205 # The following environment variables used to have an effect, but don't anymore:
1206 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
1207 # the contents from the version.txt file in the application directory, or
1208 # browser/config/version.txt if there isn't one.
1209 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
1210 # in the "About" window. This was replaced with the contents from the
1211 # version_display.txt or version.txt in the application directory, or
1212 # browser/config/version_display.txt.
1214 # For extensions and langpacks, we require a max version that is compatible
1215 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
1216 # 24.0a1 and 24.0a2 aren't affected
1217 # 24.0 becomes 24.*
1218 # 24.1.1 becomes 24.*
1219 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
1220 if test -z "$IS_ALPHA"; then
1221   changequote(,)
1222   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
1223     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
1224   else
1225     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
1226   fi
1227   changequote([,])
1228 else
1229   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
1232 AC_SUBST(MOZ_APP_DISPLAYNAME)
1233 AC_SUBST(MOZ_APP_VENDOR)
1234 AC_SUBST(MOZ_APP_PROFILE)
1235 AC_SUBST(MOZ_APP_ID)
1236 AC_SUBST(MAR_CHANNEL_ID)
1237 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
1238 AC_SUBST(MOZ_PROFILE_MIGRATOR)
1239 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
1240 AC_SUBST(MOZ_APP_UA_NAME)
1241 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
1242 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
1243 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
1245 AC_SUBST(MOZ_APP_MAXVERSION)
1246 AC_SUBST(MOZ_PKG_SPECIAL)
1247 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
1249 if test "$MOZILLA_OFFICIAL"; then
1250     # Build revisions should always be present in official builds
1251     MOZ_INCLUDE_SOURCE_INFO=1
1254 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
1255 # explicitly set the repository and changeset information in.
1256 AC_SUBST(MOZ_SOURCE_REPO)
1257 AC_SUBST(MOZ_SOURCE_CHANGESET)
1258 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
1260 dnl win32 options
1261 AC_SUBST(WIN32_REDIST_DIR)
1263 dnl Echo the CFLAGS to remove extra whitespace.
1264 CFLAGS=`echo \
1265     $_COMPILATION_CFLAGS \
1266     $CFLAGS`
1268 CXXFLAGS=`echo \
1269     $_COMPILATION_CXXFLAGS \
1270     $CXXFLAGS`
1272 COMPILE_CFLAGS=`echo \
1273     $_DEFINES_CFLAGS \
1274     $COMPILE_CFLAGS`
1276 COMPILE_CXXFLAGS=`echo \
1277     $_DEFINES_CXXFLAGS \
1278     $COMPILE_CXXFLAGS`
1280 HOST_CFLAGS=`echo \
1281     $_COMPILATION_HOST_CFLAGS \
1282     $HOST_CFLAGS`
1284 HOST_CXXFLAGS=`echo \
1285     $_COMPILATION_HOST_CXXFLAGS \
1286     $HOST_CXXFLAGS`
1288 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
1289 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1290 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
1291 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1292 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
1293   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1294   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1296 AC_SUBST(HOST_CMFLAGS)
1297 AC_SUBST(HOST_CMMFLAGS)
1298 AC_SUBST(OS_COMPILE_CMFLAGS)
1299 AC_SUBST(OS_COMPILE_CMMFLAGS)
1301 OS_CFLAGS="$CFLAGS"
1302 OS_CXXFLAGS="$CXXFLAGS"
1303 OS_CPPFLAGS="$CPPFLAGS"
1304 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1305 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1306 OS_LDFLAGS="$LDFLAGS"
1307 OS_LIBS="$LIBS"
1308 AC_SUBST_LIST(OS_CFLAGS)
1309 AC_SUBST_LIST(OS_CXXFLAGS)
1310 AC_SUBST_LIST(OS_CPPFLAGS)
1311 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1312 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1313 AC_SUBST_LIST(OS_LDFLAGS)
1314 AC_SUBST(OS_LIBS)
1316 AC_SUBST(HOST_CC)
1317 AC_SUBST(HOST_CXX)
1318 AC_SUBST_LIST(HOST_CFLAGS)
1319 AC_SUBST_LIST(HOST_CPPFLAGS)
1320 AC_SUBST_LIST(HOST_CXXFLAGS)
1321 AC_SUBST(HOST_LDFLAGS)
1322 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1323 AC_SUBST(HOST_BIN_SUFFIX)
1325 AC_SUBST(TARGET_XPCOM_ABI)
1327 AC_SUBST(DSO_LDOPTS)
1328 AC_SUBST(BIN_SUFFIX)
1329 AC_SUBST(USE_N32)
1330 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1331 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1333 AC_SUBST(MOZ_DEVTOOLS)
1335 AC_SUBST(MOZ_PACKAGE_JSSHELL)
1337 AC_SUBST(DMG_TOOL)
1339 dnl Host JavaScript runtime, if any, to use during cross compiles.
1340 AC_SUBST(JS_BINARY)
1342 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
1344 dnl Set various defines and substitutions
1345 dnl ========================================================
1347 AC_SUBST(MOZ_DEV_EDITION)
1348 if test -n "$MOZ_DEV_EDITION"; then
1349     AC_DEFINE(MOZ_DEV_EDITION)
1352 dnl Spit out some output
1353 dnl ========================================================
1355 # Avoid using obsolete NSPR features
1356 AC_DEFINE(NO_NSPR_10_SUPPORT)
1358 MOZ_CREATE_CONFIG_STATUS()
1360 rm -fr confdefs* $ac_clean_files