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 ========================================================
10 AC_INIT(config/config.mk)
11 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
14 dnl ========================================================
16 dnl = Don't change the following lines. Doing so breaks:
18 dnl = CFLAGS="-foo" ./configure
20 dnl ========================================================
22 CPPFLAGS="${CPPFLAGS=}"
23 CXXFLAGS="${CXXFLAGS=}"
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 ========================================================
33 dnl Initialize the Pthread test variables early so they can be
34 dnl overridden by each platform.
35 dnl ========================================================
39 LDFLAGS="$LDFLAGS $LINKER_LDFLAGS $PACK_REL_RELOC_FLAGS"
40 HOST_LDFLAGS="$HOST_LDFLAGS $HOST_LINKER_LDFLAGS"
42 if test "$COMPILE_ENVIRONMENT"; then
44 fi # COMPILE_ENVIRONMENT
46 dnl ========================================================
47 dnl Checks for compilers.
48 dnl ========================================================
50 if test "$COMPILE_ENVIRONMENT"; then
52 if test "$target" != "$host"; then
58 # Work around the conftest.exe access problem on Windows
66 dnl ========================================================
67 dnl Special win32 checks
68 dnl ========================================================
74 if test "$GCC" != "yes"; then
75 # Check to see if we are really running in a msvc environemnt
78 # Make sure compilers are valid
79 CXXFLAGS="$CXXFLAGS -TP"
82 AC_TRY_COMPILE([#include <stdio.h>],
83 [ printf("Hello World\n"); ],,
84 AC_MSG_ERROR([\$(CC) test failed. You must have MS VC++ in your path to build.]) )
87 AC_TRY_COMPILE([#include <new.h>],
88 [ unsigned *test = new unsigned(42); ],,
89 AC_MSG_ERROR([\$(CXX) test failed. You must have MS VC++ in your path to build.]) )
92 AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
93 AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
95 MSVC_C_RUNTIME_DLL=vcruntime140.dll
96 if test "$TARGET_CPU" != "x86"; then
97 MSVC_C_RUNTIME_1_DLL=vcruntime140_1.dll
99 MSVC_CXX_RUNTIME_DLL=msvcp140.dll
101 # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
102 CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
104 AC_SUBST(MSVC_C_RUNTIME_DLL)
105 AC_SUBST(MSVC_C_RUNTIME_1_DLL)
106 AC_SUBST(MSVC_CXX_RUNTIME_DLL)
108 AC_DEFINE(HAVE_SEH_EXCEPTIONS)
110 # Check w32api version
111 _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
112 _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
113 AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
114 AC_TRY_COMPILE([#include <w32api.h>],
115 #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
116 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
117 __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
118 #error "test failed."
120 , [ res=yes ], [ res=no ])
121 AC_MSG_RESULT([$res])
122 if test "$res" != "yes"; then
123 AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
125 # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
126 # causing problems with local implementations with the same name.
127 AC_DEFINE(STRSAFE_NO_DEPRECATE)
130 AC_DEFINE(_USE_MATH_DEFINES) # Otherwise Windows' math.h doesn't #define M_PI.
132 CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
133 CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
135 AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
136 AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
137 AC_DEFINE_UNQUOTED(_WIN32_IE,0x0A00)
142 if test -n "$_WIN32_MSVC"; then
144 SKIP_COMPILER_CHECKS=1
145 SKIP_LIBRARY_CHECKS=1
147 # Since we're skipping compiler and library checks, hard-code
150 AC_DEFINE(HAVE_ISATTY)
153 fi # COMPILE_ENVIRONMENT
158 dnl ========================================================
159 dnl set the defaults first
160 dnl ========================================================
161 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
163 dnl Configure platform-specific CPU architecture compiler options.
164 dnl ==============================================================
165 if test "$COMPILE_ENVIRONMENT"; then
167 fi # COMPILE_ENVIRONMENT
169 if test -n "$COMPILE_ENVIRONMENT"; then
173 dnl ========================================================
174 dnl GNU specific defaults
175 dnl ========================================================
176 if test "$GNU_CC"; then
177 if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
178 DSO_PIC_CFLAGS='-fPIC'
179 ASFLAGS="$ASFLAGS -fPIC"
183 if test "$GCC_USE_GNU_LD"; then
184 # Some tools like ASan use a runtime library that is only
185 # linked against executables, so we must allow undefined
186 # symbols for shared objects in some cases.
187 if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
188 # Don't allow undefined symbols in libraries
189 DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
191 # BSDs need `environ' exposed for posix_spawn (bug 753046)
193 DragonFly|FreeBSD|NetBSD|OpenBSD)
194 if test "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED" = 1; then
195 DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
197 DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
204 _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
206 ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
209 if test "$GNU_CXX"; then
210 CXXFLAGS="$CXXFLAGS -fno-exceptions"
212 _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
215 dnl ========================================================
216 dnl System overrides of the defaults for host
217 dnl ========================================================
220 if test -n "$_WIN32_MSVC"; then
221 HOST_CFLAGS="$HOST_CFLAGS"
223 HOST_CFLAGS="$HOST_CFLAGS -mwindows"
225 HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
226 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
229 case "${host_cpu}" in
231 if test -n "$_WIN32_MSVC"; then
232 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
236 if test -n "$_WIN32_MSVC"; then
237 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
239 HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
245 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
246 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
249 *-linux*|*-kfreebsd*-gnu|*-gnu*)
250 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
251 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
255 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
256 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
260 dnl ========================================================
261 dnl System overrides of the defaults for target
262 dnl ========================================================
264 MOZ_OPTIMIZE_LDFLAGS="${_COMPILATION_OPTIMIZE_LDFLAGS} ${MOZ_OPTIMIZE_FLAGS}"
268 MOZ_OPTIMIZE_FLAGS="-O3"
273 *-android*|*-linuxandroid*)
274 # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
275 # -Oz is smaller than -Os on clang.
276 MOZ_OPTIMIZE_FLAGS="-Oz"
277 # Disable the outliner, which causes performance regressions, and is
278 # enabled on some platforms at -Oz.
279 if test -z "$MOZ_LTO"; then
280 DISABLE_OUTLINER="-mno-outline"
282 CFLAGS="$CFLAGS $DISABLE_OUTLINER"
283 AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
284 CFLAGS="$_SAVE_CFLAGS"
286 DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
287 _SAVE_LDFLAGS=$LDFLAGS
288 LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
289 AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
290 LDFLAGS="$_SAVE_LDFLAGS"
295 if test "$GNU_CC" -o "$GNU_CXX"; then
296 MOZ_PGO_OPTIMIZE_FLAGS="-O3"
297 MOZ_OPTIMIZE_FLAGS="-O2"
300 case "${target_cpu}" in
302 CFLAGS="$CFLAGS -mieee"
303 CXXFLAGS="$CXXFLAGS -mieee"
309 # certain versions of cygwin's makedepend barf on the
310 # #include <string> vs -I./dist/include/string issue so don't use it
311 if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
312 # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
313 if test -z "$CLANG_CC"; then
314 AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
320 MOZ_OPTIMIZE_FLAGS="-O2"
322 WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
323 WIN32_GUI_EXE_LDFLAGS=-mwindows
325 # Silence problematic clang warnings
326 CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
327 LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
329 TARGET_COMPILER_ABI=msvc
330 WIN32_SUBSYSTEM_VERSION=10.0
331 WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
332 WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
333 DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
334 _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
335 _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
336 CFLAGS="$CFLAGS -Gy -Zc:inline"
337 CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
338 if test "$TARGET_CPU" = "x86"; then
339 dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
340 dnl more recent, so set that explicitly here unless another
341 dnl target arch has already been set.
343 if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
344 CFLAGS="$CFLAGS -arch:SSE2"
346 if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
347 CXXFLAGS="$CXXFLAGS -arch:SSE2"
351 dnl VS2013+ supports -Gw for better linker optimizations.
352 dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
353 dnl Disabled on ASan because it causes false-positive ODR violations.
354 if test -z "$MOZ_ASAN"; then
356 CXXFLAGS="$CXXFLAGS -Gw"
358 # String tail merging doesn't play nice with ASan's ODR checker.
359 LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
361 # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
362 CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
363 MOZ_DEBUG_LDFLAGS='-DEBUG'
364 if test "$HOST_OS_ARCH" != "WINNT"; then
365 # %_PDB% is a special signal to emit only the PDB basename. This
366 # avoids problems in Windows tools that don't like forward-slashes.
367 MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
369 MOZ_OPTIMIZE_FLAGS='-O2'
371 LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
373 AC_DEFINE(WIN32_LEAN_AND_MEAN)
374 dnl See http://support.microsoft.com/kb/143208 to use STL
380 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.])
386 if test -n "$GNU_CC"; then
387 CFLAGS="$CFLAGS -mstackrealign"
388 CXXFLAGS="$CXXFLAGS -mstackrealign"
389 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
391 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
392 LDFLAGS="$LDFLAGS -SAFESEH"
398 if test -n "$_WIN32_MSVC"; then
399 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
404 if test -n "$_WIN32_MSVC"; then
405 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
410 AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
416 CFLAGS="$CFLAGS -Dunix"
417 CXXFLAGS="$CXXFLAGS -Dunix"
418 if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
419 DSO_PIC_CFLAGS='-fPIC -DPIC'
421 MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
423 DSO_PIC_CFLAGS='-fPIC -DPIC'
426 # This will fail on a.out systems prior to 1.5.1_ALPHA.
427 if test "$LIBRUNPATH"; then
428 DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
433 if test -z "$X11BASE"; then
436 MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
437 DSO_PIC_CFLAGS='-fPIC'
438 DSO_LDOPTS='-shared -fPIC'
439 if test "$LIBRUNPATH"; then
440 DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
445 MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
450 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
451 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
453 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
454 MOZ_OPTIMIZE_FLAGS="-O"
458 if test -z "$COMPILE_ENVIRONMENT"; then
459 SKIP_COMPILER_CHECKS=1
460 SKIP_LIBRARY_CHECKS=1
464 fi # COMPILE_ENVIRONMENT
466 if test -z "$SKIP_COMPILER_CHECKS"; then
467 dnl Checks for typedefs, structures, and compiler characteristics.
468 dnl ========================================================
479 dnl Checks for header files.
480 dnl ========================================================
483 dnl Checks for libraries.
484 dnl ========================================================
485 AC_CHECK_LIB(c_r, gethostbyname_r)
487 dnl We don't want to link with libdl even if it's present on OS X, since
488 dnl it's not used and not part of the default installation. OS/2 has dlfcn
490 dnl We don't want to link against libm or libpthread on Darwin since
491 dnl they both are just symlinks to libSystem and explicitly linking
492 dnl against libSystem causes issues when debugging (see bug 299601).
497 AC_SEARCH_LIBS(dlopen, dl,
498 MOZ_CHECK_HEADER(dlfcn.h,
499 AC_DEFINE(HAVE_DLOPEN)))
503 _SAVE_CFLAGS="$CFLAGS"
504 CFLAGS="$CFLAGS -D_GNU_SOURCE"
505 AC_CHECK_FUNCS(dladdr)
506 CFLAGS="$_SAVE_CFLAGS"
508 if test ! "$GNU_CXX"; then
509 AC_CHECK_LIB(C, demangle)
512 AC_CHECK_LIB(socket, socket)
514 dnl ========================================================
515 dnl = pthread support
516 dnl = Start by checking whether the system support pthreads
517 dnl ========================================================
523 AC_CHECK_LIB(pthreads, pthread_create,
524 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
525 AC_CHECK_LIB(pthread, pthread_create,
526 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
527 AC_CHECK_LIB(c_r, pthread_create,
528 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
529 AC_CHECK_LIB(c, pthread_create,
538 dnl ========================================================
539 dnl Do the platform specific pthread hackery
540 dnl ========================================================
541 if test "$MOZ_USE_PTHREADS"x != x
544 dnl See if -pthread is supported.
547 ac_cv_have_dash_pthread=no
548 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
549 echo 'int main() { return 0; }' | cat > conftest.c
550 ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
551 if test $? -eq 0; then
552 if test -z "`grep -E -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`grep -E -i '(error|incorrect)' conftest.out`" ; then
553 ac_cv_have_dash_pthread=yes
556 # Freebsd doesn't use -pthread for compiles, it uses them for linking
559 CFLAGS="$CFLAGS -pthread"
560 CXXFLAGS="$CXXFLAGS -pthread"
566 AC_MSG_RESULT($ac_cv_have_dash_pthread)
569 dnl See if -pthreads is supported.
571 ac_cv_have_dash_pthreads=no
572 if test "$ac_cv_have_dash_pthread" = "no"; then
573 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
574 echo 'int main() { return 0; }' | cat > conftest.c
575 ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
576 if test $? -eq 0; then
577 if test -z "`grep -E -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`grep -E -i '(error|incorrect)' conftest.out`" ; then
578 ac_cv_have_dash_pthreads=yes
579 CFLAGS="$CFLAGS -pthreads"
580 CXXFLAGS="$CXXFLAGS -pthreads"
584 AC_MSG_RESULT($ac_cv_have_dash_pthreads)
589 AC_DEFINE(_REENTRANT)
590 AC_DEFINE(_THREAD_SAFE)
591 dnl -pthread links in -lpthread, so don't specify it explicitly.
592 if test "$ac_cv_have_dash_pthread" = "yes"; then
593 _PTHREAD_LDFLAGS="-pthread"
597 *-*-openbsd*|*-*-bsdi*)
598 AC_DEFINE(_REENTRANT)
599 AC_DEFINE(_THREAD_SAFE)
600 dnl -pthread links in -lc_r, so don't specify it explicitly.
601 if test "$ac_cv_have_dash_pthread" = "yes"; then
602 _PTHREAD_LDFLAGS="-pthread"
606 *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
607 AC_DEFINE(_REENTRANT)
611 LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
612 AC_SUBST(MOZ_USE_PTHREADS)
613 MOZ_CHECK_HEADERS(pthread.h)
617 dnl ========================================================
618 dnl Put your C++ language/feature checks below
619 dnl ========================================================
623 if test "$GNU_CC"; then
624 if test "$TARGET_CPU" = "arm" ; then
625 AC_CACHE_CHECK(for ARM EABI,
629 #if defined(__ARM_EABI__)
635 ac_cv_gcc_arm_eabi="yes",
636 ac_cv_gcc_arm_eabi="no")])
637 if test "$ac_cv_gcc_arm_eabi" = "yes"; then
645 TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
648 if test -n "$MOZ_LINKER"; then
649 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
650 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
651 dnl Since the linker only understands the sysv ones, no need to build the
652 dnl gnu style tables anyways.
653 LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
656 dnl End of C++ language/feature checks
659 fi # ! SKIP_COMPILER_CHECKS
661 if test -n "${COMPILE_ENVIRONMENT}"; then
666 if test -n "${TARGET_CPU}" -a -n "${TARGET_COMPILER_ABI}"; then
667 TARGET_XPCOM_ABI="${TARGET_CPU}-${TARGET_COMPILER_ABI}"
668 AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
671 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
672 dnl features that Windows actually does support.
674 if test -n "$SKIP_COMPILER_CHECKS"; then
675 dnl Windows has malloc.h
676 AC_DEFINE(MALLOC_H, [<malloc.h>])
677 AC_DEFINE(HAVE_FORCEINLINE)
678 fi # SKIP_COMPILER_CHECKS
680 dnl Mozilla specific options
681 dnl ========================================================
682 dnl The macros used for command line options
683 dnl are defined in build/autoconf/altoptions.m4.
685 dnl ========================================================
689 dnl ========================================================
691 MOZ_BRANDING_DIRECTORY=
692 MOZ_OFFICIAL_BRANDING=
694 MOZ_BINARY_EXTENSIONS=
697 dnl ========================================================
698 dnl = Trademarked Branding
699 dnl ========================================================
700 MOZ_ARG_ENABLE_BOOL(official-branding,
701 [ --enable-official-branding
702 Enable Official mozilla.org Branding
703 Do not distribute builds with
704 --enable-official-branding unless you have
705 permission to use trademarks per
706 http://www.mozilla.org/foundation/trademarks/ .],
707 MOZ_OFFICIAL_BRANDING=1,
708 MOZ_OFFICIAL_BRANDING=)
710 # Allow the application to influence configure with a confvars.sh script.
711 AC_MSG_CHECKING([if app-specific confvars.sh exists])
712 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
713 AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
714 . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
719 AC_SUBST(MOZ_OFFICIAL_BRANDING)
720 if test -n "$MOZ_OFFICIAL_BRANDING"; then
721 if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
722 AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
724 MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
725 AC_DEFINE(MOZ_OFFICIAL_BRANDING)
729 MOZ_ARG_WITH_STRING(branding,
730 [ --with-branding=dir Use branding from the specified directory.],
731 MOZ_BRANDING_DIRECTORY=$withval)
733 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
734 if test -z "$REAL_BRANDING_DIRECTORY"; then
735 REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
738 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
739 . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
742 AC_SUBST(MOZ_BRANDING_DIRECTORY)
744 dnl ========================================================
745 dnl = Distribution ID
746 dnl ========================================================
747 MOZ_ARG_WITH_STRING(distribution-id,
748 [ --with-distribution-id=ID
749 Set distribution-specific id (default=org.mozilla)],
750 [ val=`echo $withval`
751 MOZ_DISTRIBUTION_ID="$val"])
753 if test -z "$MOZ_DISTRIBUTION_ID"; then
754 MOZ_DISTRIBUTION_ID="org.mozilla"
757 AC_SUBST(MOZ_DISTRIBUTION_ID)
759 dnl ========================================================
760 dnl = Enable code optimization. ON by default.
761 dnl ========================================================
763 # Use value from moz.configure if one is defined. Else use our computed
765 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
766 MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
769 if test "$COMPILE_ENVIRONMENT"; then
770 if test -n "$MOZ_OPTIMIZE"; then
771 AC_MSG_CHECKING([for valid C compiler optimization flags])
773 CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
774 AC_TRY_COMPILE([#include <stdio.h>],
775 [printf("Hello World\n");],
778 AC_MSG_RESULT([$_results])
779 if test "$_results" = "no"; then
780 AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
783 if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
784 # When using llvm-based LTO, non numeric optimization levels are
785 # not supported by the linker, so force the linker to use -O2 (
786 # which doesn't influence the level compilation units are actually
788 case " $MOZ_OPTIMIZE_FLAGS " in
790 MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
795 fi # COMPILE_ENVIRONMENT
797 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
798 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
799 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
801 case "${OS_TARGET}" in
802 Android|WINNT|Darwin)
806 dnl On !Android !Windows !OSX, we only want to link executables against mozglue
807 MOZ_GLUE_IN_PROGRAM=1
808 AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
812 dnl ========================================================
813 dnl = Jemalloc build setup
814 dnl ========================================================
815 if test -n "$MOZ_MEMORY"; then
818 export MOZ_NO_DEBUG_RTL=1
822 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
824 dnl ========================================================
825 dnl = Enable using the clang plugin to build
826 dnl ========================================================
828 if test -n "$COMPILE_ENVIRONMENT"; then
829 MOZ_CONFIG_CLANG_PLUGIN
830 fi # COMPILE_ENVIRONMENT
834 if test "$COMPILE_ENVIRONMENT"; then
836 fi # COMPILE_ENVIRONMENT
838 dnl ========================================================
839 dnl Check if we need the 32-bit Linux SSE2 error dialog
840 dnl ========================================================
842 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
844 dnl ========================================================
846 dnl ========================================================
848 if test "$OS_ARCH" = "WINNT"; then
849 # For now we assume that we will have a uint64_t available through
850 # one of the above headers or mozstdint.h.
851 AC_DEFINE(HAVE_UINT64_T)
854 case "$MOZ_WIDGET_TOOLKIT" in
856 if test "$COMPILE_ENVIRONMENT"; then
857 MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
861 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
863 dnl ========================================================
865 dnl = Maintainer debug option (no --enable equivalent)
867 dnl ========================================================
869 AC_SUBST_LIST(ASFLAGS)
870 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
872 AC_SUBST(MOZ_STUB_INSTALLER)
874 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
876 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
878 if test -n "$MOZ_BINARY_EXTENSIONS"; then
879 AC_DEFINE(MOZ_BINARY_EXTENSIONS)
882 dnl ========================================================
883 dnl = Mac bundle name prefix
884 dnl ========================================================
885 MOZ_ARG_WITH_STRING(macbundlename-prefix,
886 [ --with-macbundlename-prefix=prefix
887 Prefix for MOZ_MACBUNDLE_NAME],
888 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
890 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
891 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
892 MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
895 if test "$MOZ_DEBUG"; then
896 MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
898 MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
900 AC_SUBST(MOZ_MACBUNDLE_NAME)
902 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
903 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
904 # Otherwise, use MOZ_APP_DISPLAYNAME
905 if test -z "$MOZ_MACBUNDLE_ID"; then
906 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
908 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
909 if test "$MOZ_DEBUG"; then
910 MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
913 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
914 AC_SUBST(MOZ_MACBUNDLE_ID)
916 dnl ========================================================
917 dnl = Child Process Name for IPC
918 dnl ========================================================
919 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
920 MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
922 # We want to let Android unpack the file at install time, but it only does
923 # so if the file is named libsomething.so. The lib/ path is also required
924 # because the unpacked file will be under the lib/ subdirectory and will
925 # need to be executed from that path.
926 MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
928 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
929 MOZ_CHILD_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.plugincontainer
930 MOZ_CHILD_PROCESS_BUNDLENAME="plugin-container.app"
931 MOZ_CHILD_PROCESS_APPNAME="${MOZ_APP_DISPLAYNAME}CP"
933 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
934 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
935 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLEID)
936 AC_SUBST(MOZ_CHILD_PROCESS_APPNAME)
937 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
939 dnl ==========================================================
940 dnl = Mac Media Plugin Helper (GMP Child) Process Name for IPC
941 dnl ==========================================================
942 MOZ_EME_PROCESS_NAME="media-plugin-helper"
943 MOZ_EME_PROCESS_NAME_BRANDED="$MOZ_APP_DISPLAYNAME Media Plugin Helper"
944 MOZ_EME_PROCESS_BUNDLENAME="${MOZ_EME_PROCESS_NAME}.app"
945 # Generate a lower case string with no spaces to be used as the bundle ID
946 # for the EME helper .app of the form org.mozilla.<executable-name>.
947 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_APP_DISPLAYNAME" | tr ' ' '-'`
948 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_EME_PROCESS_BUNDLEID" | tr 'A-Z' 'a-z'`
949 MOZ_EME_PROCESS_BUNDLEID=${MOZ_EME_PROCESS_BUNDLEID}-${MOZ_EME_PROCESS_NAME}
950 MOZ_EME_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.${MOZ_EME_PROCESS_BUNDLEID}
952 AC_SUBST(MOZ_EME_PROCESS_NAME)
953 AC_SUBST(MOZ_EME_PROCESS_NAME_BRANDED)
954 AC_SUBST(MOZ_EME_PROCESS_BUNDLENAME)
955 AC_SUBST(MOZ_EME_PROCESS_BUNDLEID)
957 # The following variables are available to branding and application
958 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
959 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
960 # impacts profile location and user-visible fields.
961 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
962 # Mac Bundle name, Updater, Installer), it is typically used for nightly
963 # builds (e.g. Aurora for Firefox).
964 # - MOZ_APP_PROFILE: When set, used for application.ini's
965 # "Profile" field, which controls profile location.
966 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
967 # crash reporter server url.
968 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
970 # The following environment variables used to have an effect, but don't anymore:
971 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
972 # the contents from the version.txt file in the application directory, or
973 # browser/config/version.txt if there isn't one.
974 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
975 # in the "About" window. This was replaced with the contents from the
976 # version_display.txt or version.txt in the application directory, or
977 # browser/config/version_display.txt.
979 # For extensions and langpacks, we require a max version that is compatible
980 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
981 # 24.0a1 and 24.0a2 aren't affected
983 # 24.1.1 becomes 24.*
984 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
985 if test -z "$IS_ALPHA"; then
987 if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
988 MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
990 MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
994 MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
997 AC_SUBST(MOZ_APP_DISPLAYNAME)
998 AC_SUBST(MOZ_APP_VENDOR)
999 AC_SUBST(MOZ_APP_PROFILE)
1000 AC_SUBST(MOZ_APP_ID)
1001 AC_SUBST(MAR_CHANNEL_ID)
1002 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
1003 AC_SUBST(MOZ_PROFILE_MIGRATOR)
1004 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
1005 AC_SUBST(MOZ_APP_UA_NAME)
1006 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
1007 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
1008 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
1010 AC_SUBST(MOZ_APP_MAXVERSION)
1011 AC_SUBST(MOZ_PKG_SPECIAL)
1012 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
1014 if test "$MOZILLA_OFFICIAL"; then
1015 # Build revisions should always be present in official builds
1016 MOZ_INCLUDE_SOURCE_INFO=1
1019 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
1020 # explicitly set the repository and changeset information in.
1021 AC_SUBST(MOZ_SOURCE_REPO)
1022 AC_SUBST(MOZ_SOURCE_CHANGESET)
1023 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
1025 dnl Echo the CFLAGS to remove extra whitespace.
1027 $_COMPILATION_CFLAGS \
1031 $_COMPILATION_CXXFLAGS \
1035 $_COMPILATION_ASFLAGS \
1038 COMPILE_CFLAGS=`echo \
1042 COMPILE_CXXFLAGS=`echo \
1043 $_DEFINES_CXXFLAGS \
1047 $_COMPILATION_HOST_CFLAGS \
1050 HOST_CXXFLAGS=`echo \
1051 $_COMPILATION_HOST_CXXFLAGS \
1056 $_COMPILATION_LDFLAGS`
1058 HOST_LDFLAGS=`echo \
1060 $_COMPILATION_HOST_LDFLAGS`
1062 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
1063 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1064 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
1065 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1066 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
1067 OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1068 OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1070 AC_SUBST(HOST_CMFLAGS)
1071 AC_SUBST(HOST_CMMFLAGS)
1072 AC_SUBST(OS_COMPILE_CMFLAGS)
1073 AC_SUBST(OS_COMPILE_CMMFLAGS)
1076 OS_CXXFLAGS="$CXXFLAGS"
1077 OS_CPPFLAGS="$CPPFLAGS"
1078 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1079 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1080 OS_LDFLAGS="$LDFLAGS"
1082 AC_SUBST_LIST(OS_CFLAGS)
1083 AC_SUBST_LIST(OS_CXXFLAGS)
1084 AC_SUBST_LIST(OS_CPPFLAGS)
1085 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1086 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1087 AC_SUBST_LIST(OS_LDFLAGS)
1092 AC_SUBST_LIST(HOST_CFLAGS)
1093 AC_SUBST_LIST(HOST_CPPFLAGS)
1094 AC_SUBST_LIST(HOST_CXXFLAGS)
1095 AC_SUBST(HOST_LDFLAGS)
1096 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1097 AC_SUBST(HOST_BIN_SUFFIX)
1099 AC_SUBST(TARGET_XPCOM_ABI)
1101 AC_SUBST(DSO_LDOPTS)
1102 AC_SUBST(BIN_SUFFIX)
1104 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1105 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1107 AC_SUBST(MOZ_DEVTOOLS)
1109 AC_SUBST(MOZ_PACKAGE_JSSHELL)
1113 dnl Host JavaScript runtime, if any, to use during cross compiles.
1116 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
1118 dnl Set various defines and substitutions
1119 dnl ========================================================
1121 AC_SUBST(MOZ_DEV_EDITION)
1122 if test -n "$MOZ_DEV_EDITION"; then
1123 AC_DEFINE(MOZ_DEV_EDITION)
1126 dnl Spit out some output
1127 dnl ========================================================
1129 # Avoid using obsolete NSPR features
1130 AC_DEFINE(NO_NSPR_10_SUPPORT)
1132 MOZ_CREATE_CONFIG_STATUS()
1134 rm -fr confdefs* $ac_clean_files