Bug 1859964 - --enable-phc doesn't always imply --enable-frame-pointers r=glandium
[gecko.git] / old-configure.in
blob57a41cb1b28592b761c51d6fbdc6ec0ce4a54936
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 "$CPU_ARCH" != "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 nocopyreloc option to ld])
225     _SAVE_LDFLAGS=$LDFLAGS
226     LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
227     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
228                   AC_MSG_RESULT([no])
229                   LDFLAGS=$_SAVE_LDFLAGS)
231     AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
232     _SAVE_LDFLAGS=$LDFLAGS
233     LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
234     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
235                   AC_MSG_RESULT([no])
236                   LDFLAGS=$_SAVE_LDFLAGS)
238     # While sha1 is deterministic, it is slower.
239     if test -z "$DEVELOPER_OPTIONS"; then
240         build_id=sha1
241     else
242         build_id=uuid
243     fi
244     AC_MSG_CHECKING([for --build-id=$build_id option to ld])
245     _SAVE_LDFLAGS=$LDFLAGS
246     LDFLAGS="$LDFLAGS -Wl,--build-id=$build_id"
247     AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
248                   AC_MSG_RESULT([no])
249                   LDFLAGS=$_SAVE_LDFLAGS)
251     AC_MSG_CHECKING([for --ignore-unresolved-symbol option to ld])
252     HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=
253     _SAVE_LDFLAGS=$LDFLAGS
254     LDFLAGS="$LDFLAGS -Wl,--ignore-unresolved-symbol,environ"
255     AC_TRY_LINK(,,AC_MSG_RESULT([yes])
256                   [HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED=1],
257                   AC_MSG_RESULT([no]))
258     LDFLAGS=$_SAVE_LDFLAGS
260     DSO_LDOPTS='-shared'
261     if test "$GCC_USE_GNU_LD"; then
262         # Some tools like ASan use a runtime library that is only
263         # linked against executables, so we must allow undefined
264         # symbols for shared objects in some cases.
265         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
266             # Don't allow undefined symbols in libraries
267             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
269             # BSDs need `environ' exposed for posix_spawn (bug 753046)
270             case "$OS_TARGET" in
271             DragonFly|FreeBSD|NetBSD|OpenBSD)
272                 if test -n "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED"; then
273                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
274                 else
275                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
276                 fi
277                 ;;
278             esac
279         fi
280     fi
282     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
284     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
287 if test "$GNU_CXX"; then
288     CXXFLAGS="$CXXFLAGS -fno-exceptions"
290     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
293 dnl ========================================================
294 dnl System overrides of the defaults for host
295 dnl ========================================================
296 case "$host" in
297 *mingw*)
298     if test -n "$_WIN32_MSVC"; then
299         HOST_CFLAGS="$HOST_CFLAGS"
300     else
301         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
302     fi
303     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
304     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
305     HOST_BIN_SUFFIX=.exe
307     case "${host_cpu}" in
308     i*86)
309         if test -n "$_WIN32_MSVC"; then
310             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
311         fi
312         ;;
313     x86_64)
314         if test -n "$_WIN32_MSVC"; then
315             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
316         fi
317         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
318         ;;
319     esac
320     ;;
322 *-darwin*)
323     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
324     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
325     ;;
327 *-linux*|*-kfreebsd*-gnu|*-gnu*)
328     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
329     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
330     ;;
333     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
334     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
335     ;;
336 esac
338 dnl ========================================================
339 dnl System overrides of the defaults for target
340 dnl ========================================================
342 case "$target" in
343 *-darwin*)
344     MOZ_OPTIMIZE_FLAGS="-O3"
345     DSO_LDOPTS=''
347     dnl DTrace and -dead_strip don't interact well. See bug 403132.
348     dnl ===================================================================
349     if test "x$enable_dtrace" = "xyes"; then
350         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
351     else
352         dnl check for the presence of the -dead_strip linker flag
353         AC_MSG_CHECKING([for -dead_strip option to ld])
354         _SAVE_LDFLAGS=$LDFLAGS
355         LDFLAGS="$LDFLAGS -Wl,-dead_strip"
356         AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
357         if test -n "$_HAVE_DEAD_STRIP" ; then
358             AC_MSG_RESULT([yes])
359             MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
360         else
361             AC_MSG_RESULT([no])
362         fi
364         LDFLAGS=$_SAVE_LDFLAGS
365     fi
367     MOZ_FIX_LINK_PATHS=
368     ;;
370 *-android*|*-linuxandroid*)
371     # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
372     # -Oz is smaller than -Os on clang.
373     MOZ_OPTIMIZE_FLAGS="-Oz"
374     # Disable the outliner, which causes performance regressions, and is
375     # enabled on some platforms at -Oz.
376     if test -z "$MOZ_LTO"; then
377         DISABLE_OUTLINER="-mno-outline"
378         _SAVE_CFLAGS=$CFLAGS
379         CFLAGS="$CFLAGS $DISABLE_OUTLINER"
380         AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
381         CFLAGS="$_SAVE_CFLAGS"
382    else
383         DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
384         _SAVE_LDFLAGS=$LDFLAGS
385         LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
386         AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
387         LDFLAGS="$_SAVE_LDFLAGS"
388     fi
389     ;;
391 *-*linux*)
392     if test "$GNU_CC" -o "$GNU_CXX"; then
393         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
394         MOZ_OPTIMIZE_FLAGS="-O2"
395         if test -z "$CLANG_CC"; then
396            MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
397         fi
398     fi
400     case "${target_cpu}" in
401     alpha*)
402         CFLAGS="$CFLAGS -mieee"
403         CXXFLAGS="$CXXFLAGS -mieee"
404     ;;
405     esac
406     ;;
407 *-mingw*)
408     DSO_PIC_CFLAGS=
409     # certain versions of cygwin's makedepend barf on the
410     # #include <string> vs -I./dist/include/string issue so don't use it
411     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
412         # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
413         if test -z "$CLANG_CC"; then
414             AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
415         fi
417         DSO_LDOPTS='-shared'
418         MOZ_FIX_LINK_PATHS=
420         MOZ_OPTIMIZE_FLAGS="-O2"
422         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
423         WIN32_GUI_EXE_LDFLAGS=-mwindows
425         # Silence problematic clang warnings
426         CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
427         LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
428     else
429         TARGET_COMPILER_ABI=msvc
430         WIN32_SUBSYSTEM_VERSION=10.0
431         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
432         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
433         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
434         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
435         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
436         CFLAGS="$CFLAGS -Gy -Zc:inline"
437         CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
438         if test "$CPU_ARCH" = "x86"; then
439             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
440             dnl more recent, so set that explicitly here unless another
441             dnl target arch has already been set.
442             changequote(,)
443             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
444               CFLAGS="$CFLAGS -arch:SSE2"
445             fi
446             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
447               CXXFLAGS="$CXXFLAGS -arch:SSE2"
448             fi
449             changequote([,])
450         fi
451         dnl VS2013+ supports -Gw for better linker optimizations.
452         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
453         dnl Disabled on ASan because it causes false-positive ODR violations.
454         if test -z "$MOZ_ASAN"; then
455             CFLAGS="$CFLAGS -Gw"
456             CXXFLAGS="$CXXFLAGS -Gw"
457         else
458             # String tail merging doesn't play nice with ASan's ODR checker.
459             LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
460         fi
461         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
462         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
463         MOZ_DEBUG_LDFLAGS='-DEBUG'
464         if test "$HOST_OS_ARCH" != "WINNT"; then
465           # %_PDB% is a special signal to emit only the PDB basename. This
466           # avoids problems in Windows tools that don't like forward-slashes.
467           MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
468         fi
469         MOZ_OPTIMIZE_FLAGS='-O2'
470         MOZ_FIX_LINK_PATHS=
471         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
472     fi
473     AC_DEFINE(WIN32_LEAN_AND_MEAN)
474     dnl See http://support.microsoft.com/kb/143208 to use STL
475     AC_DEFINE(NOMINMAX)
476     BIN_SUFFIX='.exe'
478     case "$host_os" in
479     cygwin*|msvc*|mks*)
480         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.])
481         ;;
482     esac
484     case "$target" in
485     i*86-*)
486         if test -n "$GNU_CC"; then
487             CFLAGS="$CFLAGS -mstackrealign"
488             CXXFLAGS="$CXXFLAGS -mstackrealign"
489             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
490         else
491             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
492             LDFLAGS="$LDFLAGS -SAFESEH"
493         fi
495         AC_DEFINE(_X86_)
496         ;;
497     x86_64-*)
498         if test -n "$_WIN32_MSVC"; then
499             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
500         fi
501         AC_DEFINE(_AMD64_)
502         ;;
503     aarch64-*)
504         if test -n "$_WIN32_MSVC"; then
505             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
506         fi
507         AC_DEFINE(_ARM64_)
508         ;;
509     *)
510         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
511         ;;
512     esac
513     ;;
515 *-netbsd*)
516     CFLAGS="$CFLAGS -Dunix"
517     CXXFLAGS="$CXXFLAGS -Dunix"
518     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
519         DSO_PIC_CFLAGS='-fPIC -DPIC'
520         DSO_LDOPTS='-shared'
521         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
522     else
523         DSO_PIC_CFLAGS='-fPIC -DPIC'
524         DSO_LDOPTS='-shared'
525     fi
526     # This will fail on a.out systems prior to 1.5.1_ALPHA.
527     if test "$LIBRUNPATH"; then
528         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
529     fi
530     ;;
532 *-openbsd*)
533     if test -z "$X11BASE"; then
534         X11BASE=/usr/X11R6
535     fi
536     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
537     DSO_PIC_CFLAGS='-fPIC'
538     DSO_LDOPTS='-shared -fPIC'
539     if test "$LIBRUNPATH"; then
540         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
541     fi
542     ;;
544 *-solaris*)
545     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
546     ;;
548 esac
550 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
551 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
553 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
554     MOZ_OPTIMIZE_FLAGS="-O"
558 if test -z "$COMPILE_ENVIRONMENT"; then
559     SKIP_COMPILER_CHECKS=1
560     SKIP_LIBRARY_CHECKS=1
561     MOZ_DEBUGGING_OPTS
562 else
563     MOZ_COMPILER_OPTS
564 fi # COMPILE_ENVIRONMENT
566 if test -z "$SKIP_COMPILER_CHECKS"; then
567 dnl Checks for typedefs, structures, and compiler characteristics.
568 dnl ========================================================
569 AC_C_CONST
570 AC_TYPE_MODE_T
571 AC_TYPE_OFF_T
572 AC_TYPE_PID_T
573 AC_TYPE_SIZE_T
574 AC_LANG_CPLUSPLUS
575 AC_LANG_C
577 AC_LANG_CPLUSPLUS
579 MOZ_CXX11
581 AC_LANG_C
583 dnl Checks for header files.
584 dnl ========================================================
585 AC_HEADER_DIRENT
587 dnl Checks for libraries.
588 dnl ========================================================
589 AC_CHECK_LIB(c_r, gethostbyname_r)
591 dnl We don't want to link with libdl even if it's present on OS X, since
592 dnl it's not used and not part of the default installation. OS/2 has dlfcn
593 dnl in libc.
594 dnl We don't want to link against libm or libpthread on Darwin since
595 dnl they both are just symlinks to libSystem and explicitly linking
596 dnl against libSystem causes issues when debugging (see bug 299601).
597 case $target in
598 *-darwin*)
599     ;;
601     AC_SEARCH_LIBS(dlopen, dl,
602         MOZ_CHECK_HEADER(dlfcn.h,
603         AC_DEFINE(HAVE_DLOPEN)))
604     ;;
605 esac
607 _SAVE_CFLAGS="$CFLAGS"
608 CFLAGS="$CFLAGS -D_GNU_SOURCE"
609 AC_CHECK_FUNCS(dladdr)
610 CFLAGS="$_SAVE_CFLAGS"
612 if test ! "$GNU_CXX"; then
613     AC_CHECK_LIB(C, demangle)
616 AC_CHECK_LIB(socket, socket)
618 dnl ========================================================
619 dnl = pthread support
620 dnl = Start by checking whether the system support pthreads
621 dnl ========================================================
622 case "$target_os" in
623 darwin*)
624     MOZ_USE_PTHREADS=1
625     ;;
627     AC_CHECK_LIB(pthreads, pthread_create,
628         MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
629         AC_CHECK_LIB(pthread, pthread_create,
630             MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
631             AC_CHECK_LIB(c_r, pthread_create,
632                 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
633                 AC_CHECK_LIB(c, pthread_create,
634                     MOZ_USE_PTHREADS=1
635                 )
636             )
637         )
638     )
639     ;;
640 esac
642 dnl ========================================================
643 dnl Do the platform specific pthread hackery
644 dnl ========================================================
645 if test "$MOZ_USE_PTHREADS"x != x
646 then
647     dnl
648     dnl See if -pthread is supported.
649     dnl
650     rm -f conftest*
651     ac_cv_have_dash_pthread=no
652     AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
653     echo 'int main() { return 0; }' | cat > conftest.c
654     ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
655     if test $? -eq 0; then
656         if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
657             ac_cv_have_dash_pthread=yes
658             case "$target_os" in
659             freebsd*)
660 # Freebsd doesn't use -pthread for compiles, it uses them for linking
661                 ;;
662             *)
663                 CFLAGS="$CFLAGS -pthread"
664                 CXXFLAGS="$CXXFLAGS -pthread"
665                 ;;
666             esac
667         fi
668     fi
669     rm -f conftest*
670     AC_MSG_RESULT($ac_cv_have_dash_pthread)
672     dnl
673     dnl See if -pthreads is supported.
674     dnl
675     ac_cv_have_dash_pthreads=no
676     if test "$ac_cv_have_dash_pthread" = "no"; then
677         AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
678         echo 'int main() { return 0; }' | cat > conftest.c
679         ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
680         if test $? -eq 0; then
681             if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
682                 ac_cv_have_dash_pthreads=yes
683                 CFLAGS="$CFLAGS -pthreads"
684                 CXXFLAGS="$CXXFLAGS -pthreads"
685             fi
686         fi
687         rm -f conftest*
688         AC_MSG_RESULT($ac_cv_have_dash_pthreads)
689     fi
691     case "$target" in
692         *-*-freebsd*)
693             AC_DEFINE(_REENTRANT)
694             AC_DEFINE(_THREAD_SAFE)
695             dnl -pthread links in -lpthread, so don't specify it explicitly.
696             if test "$ac_cv_have_dash_pthread" = "yes"; then
697                 _PTHREAD_LDFLAGS="-pthread"
698             fi
699             ;;
701         *-*-openbsd*|*-*-bsdi*)
702             AC_DEFINE(_REENTRANT)
703             AC_DEFINE(_THREAD_SAFE)
704             dnl -pthread links in -lc_r, so don't specify it explicitly.
705             if test "$ac_cv_have_dash_pthread" = "yes"; then
706                 _PTHREAD_LDFLAGS="-pthread"
707             fi
708             ;;
710         *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
711             AC_DEFINE(_REENTRANT)
712             ;;
714     esac
715     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
716     AC_SUBST(MOZ_USE_PTHREADS)
717     MOZ_CHECK_HEADERS(pthread.h)
721 dnl Checks for library functions.
722 dnl ========================================================
724 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
725 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
726                ac_cv_clock_monotonic,
727                [for libs in "" -lrt; do
728                     _SAVE_LIBS="$LIBS"
729                     LIBS="$LIBS $libs"
730 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
731 dnl we should or not be able to use it. To detect if we can, we need to make the
732 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
733                     AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
734                                  #include <time.h>],
735                                  [ struct timespec ts;
736                                    clock_gettime(CLOCK_MONOTONIC, &ts); ],
737                                  ac_cv_clock_monotonic=$libs
738                                  LIBS="$_SAVE_LIBS"
739                                  break,
740                                  ac_cv_clock_monotonic=no)
741                     LIBS="$_SAVE_LIBS"
742                 done])
743 if test "$ac_cv_clock_monotonic" != "no"; then
744     HAVE_CLOCK_MONOTONIC=1
745     REALTIME_LIBS=$ac_cv_clock_monotonic
746     AC_DEFINE(HAVE_CLOCK_MONOTONIC)
747     AC_SUBST(HAVE_CLOCK_MONOTONIC)
748     AC_SUBST_LIST(REALTIME_LIBS)
751 AC_CACHE_CHECK(
752     [for res_ninit()],
753     ac_cv_func_res_ninit,
754     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
755         dnl no need for res_ninit() on NetBSD and OpenBSD
756         ac_cv_func_res_ninit=no
757      else
758         AC_TRY_LINK([
759             #ifdef linux
760             #define _BSD_SOURCE 1
761             #endif
762             #include <sys/types.h>
763             #include <netinet/in.h>
764             #include <arpa/nameser.h>
765             #include <resolv.h>
766             ],
767             [int foo = res_ninit(&_res);],
768             [ac_cv_func_res_ninit=yes],
769             [ac_cv_func_res_ninit=no])
770      fi
771     ])
773 if test "$ac_cv_func_res_ninit" = "yes"; then
774     AC_DEFINE(HAVE_RES_NINIT)
775 dnl must add the link line we do something as foolish as this... dougt
776 dnl else
777 dnl    AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
778 dnl        AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
781 AC_LANG_C
783 dnl ===================================================================
784 dnl ========================================================
785 dnl Put your C++ language/feature checks below
786 dnl ========================================================
787 AC_LANG_CPLUSPLUS
789 ARM_ABI_PREFIX=
790 if test "$GNU_CC"; then
791   if test "$CPU_ARCH" = "arm" ; then
792     AC_CACHE_CHECK(for ARM EABI,
793         ac_cv_gcc_arm_eabi,
794         [AC_TRY_COMPILE([],
795                         [
796 #if defined(__ARM_EABI__)
797   return 0;
798 #else
799 #error Not ARM EABI.
800 #endif
801                         ],
802                         ac_cv_gcc_arm_eabi="yes",
803                         ac_cv_gcc_arm_eabi="no")])
804     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
805         HAVE_ARM_EABI=1
806         ARM_ABI_PREFIX=eabi-
807     else
808         ARM_ABI_PREFIX=oabi-
809     fi
810   fi
812   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
815 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
816 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
817 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
818 # linking XUL.
819 _SAVE_LDFLAGS=$LDFLAGS
820 LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
821 AC_CACHE_CHECK(for __thread keyword for TLS variables,
822                ac_cv_thread_keyword,
823                [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
824                             [return tlsIsMainThread;],
825                             ac_cv_thread_keyword=yes,
826                             ac_cv_thread_keyword=no)])
827 LDFLAGS=$_SAVE_LDFLAGS
828 # The custom dynamic linker doesn't support TLS variables
829 if test "$ac_cv_thread_keyword" = yes -a "$MOZ_LINKER" != 1; then
830   # mips builds fail with TLS variables because of a binutils bug.
831   # See bug 528687
832   # OpenBSD doesn't have TLS support, and the test succeeds with clang++
833   case "${target}" in
834     mips*-*)
835       :
836       ;;
837     *-android*|*-linuxandroid*)
838       :
839       ;;
840     *-openbsd*)
841       :
842       ;;
843     *)
844       AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
845       ;;
846   esac
849 if test -n "$MOZ_LINKER"; then
850 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
851 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
852 dnl Since the linker only understands the sysv ones, no need to build the
853 dnl gnu style tables anyways.
854   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
857 dnl End of C++ language/feature checks
858 AC_LANG_C
860 fi # ! SKIP_COMPILER_CHECKS
862 if test -n "${COMPILE_ENVIRONMENT}"; then
863   MOZ_CHECK_ALLOCATOR
866 TARGET_XPCOM_ABI=
867 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
868     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
869     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
872 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
873 dnl features that Windows actually does support.
875 if test -n "$SKIP_COMPILER_CHECKS"; then
876    dnl Windows has malloc.h
877    AC_DEFINE(MALLOC_H, [<malloc.h>])
878    AC_DEFINE(HAVE_FORCEINLINE)
879 fi # SKIP_COMPILER_CHECKS
881 dnl Mozilla specific options
882 dnl ========================================================
883 dnl The macros used for command line options
884 dnl are defined in build/autoconf/altoptions.m4.
886 dnl ========================================================
887 dnl =
888 dnl = Application
889 dnl =
890 dnl ========================================================
892 MOZ_BRANDING_DIRECTORY=
893 MOZ_OFFICIAL_BRANDING=
894 MOZ_NO_SMART_CARDS=
895 MOZ_BINARY_EXTENSIONS=
896 MOZ_DEVTOOLS=server
898 dnl ========================================================
899 dnl = Trademarked Branding
900 dnl ========================================================
901 MOZ_ARG_ENABLE_BOOL(official-branding,
902 [  --enable-official-branding
903                           Enable Official mozilla.org Branding
904                           Do not distribute builds with
905                           --enable-official-branding unless you have
906                           permission to use trademarks per
907                           http://www.mozilla.org/foundation/trademarks/ .],
908     MOZ_OFFICIAL_BRANDING=1,
909     MOZ_OFFICIAL_BRANDING=)
911 # Allow the application to influence configure with a confvars.sh script.
912 AC_MSG_CHECKING([if app-specific confvars.sh exists])
913 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
914   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
915   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
916 else
917   AC_MSG_RESULT([no])
920 AC_SUBST(MOZ_OFFICIAL_BRANDING)
921 if test -n "$MOZ_OFFICIAL_BRANDING"; then
922   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
923     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
924   else
925     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
926     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
927   fi
930 MOZ_ARG_WITH_STRING(branding,
931 [  --with-branding=dir     Use branding from the specified directory.],
932     MOZ_BRANDING_DIRECTORY=$withval)
934 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
935 if test -z "$REAL_BRANDING_DIRECTORY"; then
936   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
939 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
940   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
943 AC_SUBST(MOZ_BRANDING_DIRECTORY)
945 dnl ========================================================
946 dnl = Distribution ID
947 dnl ========================================================
948 MOZ_ARG_WITH_STRING(distribution-id,
949 [  --with-distribution-id=ID
950                           Set distribution-specific id (default=org.mozilla)],
951 [ val=`echo $withval`
952     MOZ_DISTRIBUTION_ID="$val"])
954 if test -z "$MOZ_DISTRIBUTION_ID"; then
955    MOZ_DISTRIBUTION_ID="org.mozilla"
958 AC_SUBST(MOZ_DISTRIBUTION_ID)
960 dnl ========================================================
961 dnl = Enable code optimization. ON by default.
962 dnl ========================================================
964 # Use value from moz.configure if one is defined. Else use our computed
965 # value.
966 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
967     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
970 if test "$COMPILE_ENVIRONMENT"; then
971 if test -n "$MOZ_OPTIMIZE"; then
972     AC_MSG_CHECKING([for valid C compiler optimization flags])
973     _SAVE_CFLAGS=$CFLAGS
974     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
975     AC_TRY_COMPILE([#include <stdio.h>],
976         [printf("Hello World\n");],
977         _results=yes,
978         _results=no)
979     AC_MSG_RESULT([$_results])
980     if test "$_results" = "no"; then
981         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
982     fi
983     CFLAGS=$_SAVE_CFLAGS
984     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
985         # When using llvm-based LTO, non numeric optimization levels are
986         # not supported by the linker, so force the linker to use -O2 (
987         # which doesn't influence the level compilation units are actually
988         # compiled at).
989         case " $MOZ_OPTIMIZE_FLAGS " in
990         *\ -Os\ *|*\ -Oz\ *)
991             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
992             ;;
993         esac
994     fi
996 fi # COMPILE_ENVIRONMENT
998 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
999 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
1000 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
1002 case "${OS_TARGET}" in
1003 Android|WINNT|Darwin)
1004   MOZ_GLUE_IN_PROGRAM=
1005   ;;
1007   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
1008   MOZ_GLUE_IN_PROGRAM=1
1009   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
1010   ;;
1011 esac
1013 dnl ========================================================
1014 dnl = Jemalloc build setup
1015 dnl ========================================================
1016 if test -z "$MOZ_MEMORY"; then
1017   case "${target}" in
1018     *-mingw*)
1019       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
1020         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.])
1021       fi
1022       ;;
1023   esac
1024 else
1025   dnl The generic feature tests that determine how to compute ncpus are long and
1026   dnl complicated.  Therefore, simply define special cpp variables for the
1027   dnl platforms we have special knowledge of.
1028   case "${target}" in
1029   *-mingw*)
1030     export MOZ_NO_DEBUG_RTL=1
1031     ;;
1032   esac
1033 fi # MOZ_MEMORY
1034 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
1036 dnl ========================================================
1037 dnl = Enable using the clang plugin to build
1038 dnl ========================================================
1040 if test -n "$COMPILE_ENVIRONMENT"; then
1041 MOZ_CONFIG_CLANG_PLUGIN
1042 fi # COMPILE_ENVIRONMENT
1044 if test -z "$SKIP_COMPILER_CHECKS"; then
1045 dnl ========================================================
1046 dnl Check for gcc -pipe support
1047 dnl ========================================================
1048 AC_MSG_CHECKING([for -pipe support])
1049 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
1050     dnl Any gcc that supports firefox supports -pipe.
1051     CFLAGS="$CFLAGS -pipe"
1052     CXXFLAGS="$CXXFLAGS -pipe"
1053     AC_MSG_RESULT([yes])
1054 else
1055     AC_MSG_RESULT([no])
1058 fi # ! SKIP_COMPILER_CHECKS
1060 AC_LANG_C
1062 if test "$COMPILE_ENVIRONMENT"; then
1063 MOZ_EXPAND_LIBS
1064 fi # COMPILE_ENVIRONMENT
1066 dnl ========================================================
1067 dnl Check if we need the 32-bit Linux SSE2 error dialog
1068 dnl ========================================================
1070 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
1072 dnl ========================================================
1073 dnl Check for cairo
1074 dnl ========================================================
1076 if test "$OS_ARCH" = "WINNT"; then
1077     # For now we assume that we will have a uint64_t available through
1078     # one of the above headers or mozstdint.h.
1079     AC_DEFINE(HAVE_UINT64_T)
1082 case "$MOZ_WIDGET_TOOLKIT" in
1083   windows)
1084     if test "$COMPILE_ENVIRONMENT"; then
1085       MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
1086     fi
1087     ;;
1088 esac
1089 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
1091 dnl ========================================================
1092 dnl =
1093 dnl = Maintainer debug option (no --enable equivalent)
1094 dnl =
1095 dnl ========================================================
1097 AC_SUBST_LIST(ASFLAGS)
1098 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
1100 AC_SUBST(MOZ_STUB_INSTALLER)
1102 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
1104 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
1106 if test -n "$MOZ_BINARY_EXTENSIONS"; then
1107   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
1110 dnl ========================================================
1111 dnl = Mac bundle name prefix
1112 dnl ========================================================
1113 MOZ_ARG_WITH_STRING(macbundlename-prefix,
1114 [  --with-macbundlename-prefix=prefix
1115                           Prefix for MOZ_MACBUNDLE_NAME],
1116 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
1118 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
1119 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
1120   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
1123 if test "$MOZ_DEBUG"; then
1124   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
1125 else
1126   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
1128 AC_SUBST(MOZ_MACBUNDLE_NAME)
1130 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
1131 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
1132 # Otherwise, use MOZ_APP_DISPLAYNAME
1133 if test -z "$MOZ_MACBUNDLE_ID"; then
1134    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
1136 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
1137 if test "$MOZ_DEBUG"; then
1138   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
1141 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
1142 AC_SUBST(MOZ_MACBUNDLE_ID)
1144 dnl ========================================================
1145 dnl = Child Process Name for IPC
1146 dnl ========================================================
1147 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
1148   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
1149 else
1150   # We want to let Android unpack the file at install time, but it only does
1151   # so if the file is named libsomething.so. The lib/ path is also required
1152   # because the unpacked file will be under the lib/ subdirectory and will
1153   # need to be executed from that path.
1154   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
1156 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
1157 MOZ_CHILD_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.plugincontainer
1158 MOZ_CHILD_PROCESS_BUNDLENAME="plugin-container.app"
1159 MOZ_CHILD_PROCESS_APPNAME="${MOZ_APP_DISPLAYNAME}CP"
1161 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
1162 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
1163 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLEID)
1164 AC_SUBST(MOZ_CHILD_PROCESS_APPNAME)
1165 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
1167 dnl ==========================================================
1168 dnl = Mac Media Plugin Helper (GMP Child) Process Name for IPC
1169 dnl ==========================================================
1170 MOZ_EME_PROCESS_NAME="media-plugin-helper"
1171 MOZ_EME_PROCESS_NAME_BRANDED="$MOZ_APP_DISPLAYNAME Media Plugin Helper"
1172 MOZ_EME_PROCESS_BUNDLENAME="${MOZ_EME_PROCESS_NAME}.app"
1173 # Generate a lower case string with no spaces to be used as the bundle ID
1174 # for the EME helper .app of the form org.mozilla.<executable-name>.
1175 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_APP_DISPLAYNAME" | tr ' ' '-'`
1176 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_EME_PROCESS_BUNDLEID" | tr 'A-Z' 'a-z'`
1177 MOZ_EME_PROCESS_BUNDLEID=${MOZ_EME_PROCESS_BUNDLEID}-${MOZ_EME_PROCESS_NAME}
1178 MOZ_EME_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.${MOZ_EME_PROCESS_BUNDLEID}
1180 AC_SUBST(MOZ_EME_PROCESS_NAME)
1181 AC_SUBST(MOZ_EME_PROCESS_NAME_BRANDED)
1182 AC_SUBST(MOZ_EME_PROCESS_BUNDLENAME)
1183 AC_SUBST(MOZ_EME_PROCESS_BUNDLEID)
1185 # The following variables are available to branding and application
1186 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
1187 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
1188 # impacts profile location and user-visible fields.
1189 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
1190 # Mac Bundle name, Updater, Installer), it is typically used for nightly
1191 # builds (e.g. Aurora for Firefox).
1192 # - MOZ_APP_PROFILE: When set, used for application.ini's
1193 # "Profile" field, which controls profile location.
1194 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
1195 # crash reporter server url.
1196 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
1198 # The following environment variables used to have an effect, but don't anymore:
1199 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
1200 # the contents from the version.txt file in the application directory, or
1201 # browser/config/version.txt if there isn't one.
1202 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
1203 # in the "About" window. This was replaced with the contents from the
1204 # version_display.txt or version.txt in the application directory, or
1205 # browser/config/version_display.txt.
1207 # For extensions and langpacks, we require a max version that is compatible
1208 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
1209 # 24.0a1 and 24.0a2 aren't affected
1210 # 24.0 becomes 24.*
1211 # 24.1.1 becomes 24.*
1212 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
1213 if test -z "$IS_ALPHA"; then
1214   changequote(,)
1215   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
1216     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
1217   else
1218     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
1219   fi
1220   changequote([,])
1221 else
1222   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
1225 AC_SUBST(MOZ_APP_DISPLAYNAME)
1226 AC_SUBST(MOZ_APP_VENDOR)
1227 AC_SUBST(MOZ_APP_PROFILE)
1228 AC_SUBST(MOZ_APP_ID)
1229 AC_SUBST(MAR_CHANNEL_ID)
1230 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
1231 AC_SUBST(MOZ_PROFILE_MIGRATOR)
1232 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
1233 AC_SUBST(MOZ_APP_UA_NAME)
1234 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
1235 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
1236 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
1238 AC_SUBST(MOZ_APP_MAXVERSION)
1239 AC_SUBST(MOZ_PKG_SPECIAL)
1240 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
1242 if test "$MOZILLA_OFFICIAL"; then
1243     # Build revisions should always be present in official builds
1244     MOZ_INCLUDE_SOURCE_INFO=1
1247 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
1248 # explicitly set the repository and changeset information in.
1249 AC_SUBST(MOZ_SOURCE_REPO)
1250 AC_SUBST(MOZ_SOURCE_CHANGESET)
1251 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
1253 dnl win32 options
1254 AC_SUBST(WIN32_REDIST_DIR)
1256 dnl Echo the CFLAGS to remove extra whitespace.
1257 CFLAGS=`echo \
1258     $_COMPILATION_CFLAGS \
1259     $CFLAGS`
1261 CXXFLAGS=`echo \
1262     $_COMPILATION_CXXFLAGS \
1263     $CXXFLAGS`
1265 COMPILE_CFLAGS=`echo \
1266     $_DEFINES_CFLAGS \
1267     $COMPILE_CFLAGS`
1269 COMPILE_CXXFLAGS=`echo \
1270     $_DEFINES_CXXFLAGS \
1271     $COMPILE_CXXFLAGS`
1273 HOST_CFLAGS=`echo \
1274     $_COMPILATION_HOST_CFLAGS \
1275     $HOST_CFLAGS`
1277 HOST_CXXFLAGS=`echo \
1278     $_COMPILATION_HOST_CXXFLAGS \
1279     $HOST_CXXFLAGS`
1281 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
1282 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1283 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
1284 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1285 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
1286   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1287   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1289 AC_SUBST(HOST_CMFLAGS)
1290 AC_SUBST(HOST_CMMFLAGS)
1291 AC_SUBST(OS_COMPILE_CMFLAGS)
1292 AC_SUBST(OS_COMPILE_CMMFLAGS)
1294 OS_CFLAGS="$CFLAGS"
1295 OS_CXXFLAGS="$CXXFLAGS"
1296 OS_CPPFLAGS="$CPPFLAGS"
1297 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1298 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1299 OS_LDFLAGS="$LDFLAGS"
1300 OS_LIBS="$LIBS"
1301 AC_SUBST_LIST(OS_CFLAGS)
1302 AC_SUBST_LIST(OS_CXXFLAGS)
1303 AC_SUBST_LIST(OS_CPPFLAGS)
1304 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1305 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1306 AC_SUBST_LIST(OS_LDFLAGS)
1307 AC_SUBST(OS_LIBS)
1309 AC_SUBST(HOST_CC)
1310 AC_SUBST(HOST_CXX)
1311 AC_SUBST_LIST(HOST_CFLAGS)
1312 AC_SUBST_LIST(HOST_CPPFLAGS)
1313 AC_SUBST_LIST(HOST_CXXFLAGS)
1314 AC_SUBST(HOST_LDFLAGS)
1315 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1316 AC_SUBST(HOST_BIN_SUFFIX)
1318 AC_SUBST(TARGET_XPCOM_ABI)
1320 AC_SUBST(DSO_LDOPTS)
1321 AC_SUBST(BIN_SUFFIX)
1322 AC_SUBST(USE_N32)
1323 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1324 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1326 AC_SUBST(MOZ_DEVTOOLS)
1328 AC_SUBST(MOZ_PACKAGE_JSSHELL)
1330 AC_SUBST(DMG_TOOL)
1332 dnl Host JavaScript runtime, if any, to use during cross compiles.
1333 AC_SUBST(JS_BINARY)
1335 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
1337 dnl Set various defines and substitutions
1338 dnl ========================================================
1340 AC_SUBST(MOZ_DEV_EDITION)
1341 if test -n "$MOZ_DEV_EDITION"; then
1342     AC_DEFINE(MOZ_DEV_EDITION)
1345 dnl Spit out some output
1346 dnl ========================================================
1348 # Avoid using obsolete NSPR features
1349 AC_DEFINE(NO_NSPR_10_SUPPORT)
1351 MOZ_CREATE_CONFIG_STATUS()
1353 rm -fr confdefs* $ac_clean_files