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 # Run some logic to figure out exe extensions (mostly for mingw's sake)
55 if test "$target" != "$host"; then
61 # Work around the conftest.exe access problem on Windows
69 dnl ========================================================
70 dnl Special win32 checks
71 dnl ========================================================
77 if test "$GCC" != "yes"; then
78 # Check to see if we are really running in a msvc environemnt
81 # Make sure compilers are valid
82 CXXFLAGS="$CXXFLAGS -TP"
85 AC_TRY_COMPILE([#include <stdio.h>],
86 [ printf("Hello World\n"); ],,
87 AC_MSG_ERROR([\$(CC) test failed. You must have MS VC++ in your path to build.]) )
90 AC_TRY_COMPILE([#include <new.h>],
91 [ unsigned *test = new unsigned(42); ],,
92 AC_MSG_ERROR([\$(CXX) test failed. You must have MS VC++ in your path to build.]) )
95 AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
96 AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
98 MSVC_C_RUNTIME_DLL=vcruntime140.dll
99 if test "$TARGET_CPU" != "x86"; then
100 MSVC_C_RUNTIME_1_DLL=vcruntime140_1.dll
102 MSVC_CXX_RUNTIME_DLL=msvcp140.dll
104 # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
105 CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
107 AC_SUBST(MSVC_C_RUNTIME_DLL)
108 AC_SUBST(MSVC_C_RUNTIME_1_DLL)
109 AC_SUBST(MSVC_CXX_RUNTIME_DLL)
111 AC_DEFINE(HAVE_SEH_EXCEPTIONS)
113 # Check w32api version
114 _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
115 _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
116 AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
117 AC_TRY_COMPILE([#include <w32api.h>],
118 #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
119 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
120 __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
121 #error "test failed."
123 , [ res=yes ], [ res=no ])
124 AC_MSG_RESULT([$res])
125 if test "$res" != "yes"; then
126 AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
128 # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
129 # causing problems with local implementations with the same name.
130 AC_DEFINE(STRSAFE_NO_DEPRECATE)
133 AC_DEFINE(_USE_MATH_DEFINES) # Otherwise Windows' math.h doesn't #define M_PI.
135 CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
136 CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
138 AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
139 AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
140 AC_DEFINE_UNQUOTED(_WIN32_IE,0x0A00)
145 if test -n "$_WIN32_MSVC"; then
147 SKIP_COMPILER_CHECKS=1
148 SKIP_LIBRARY_CHECKS=1
150 # Since we're skipping compiler and library checks, hard-code
153 AC_DEFINE(HAVE_ISATTY)
156 fi # COMPILE_ENVIRONMENT
161 dnl ========================================================
162 dnl set the defaults first
163 dnl ========================================================
164 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
166 dnl Configure platform-specific CPU architecture compiler options.
167 dnl ==============================================================
168 if test "$COMPILE_ENVIRONMENT"; then
170 fi # COMPILE_ENVIRONMENT
172 if test -n "$COMPILE_ENVIRONMENT"; then
176 dnl ========================================================
177 dnl GNU specific defaults
178 dnl ========================================================
179 if test "$GNU_CC"; then
180 if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
181 DSO_PIC_CFLAGS='-fPIC'
182 ASFLAGS="$ASFLAGS -fPIC"
186 if test "$GCC_USE_GNU_LD"; then
187 # Some tools like ASan use a runtime library that is only
188 # linked against executables, so we must allow undefined
189 # symbols for shared objects in some cases.
190 if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
191 # Don't allow undefined symbols in libraries
192 DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
194 # BSDs need `environ' exposed for posix_spawn (bug 753046)
196 DragonFly|FreeBSD|NetBSD|OpenBSD)
197 if test "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED" = 1; then
198 DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
200 DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
207 _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
209 ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
212 if test "$GNU_CXX"; then
213 CXXFLAGS="$CXXFLAGS -fno-exceptions"
215 _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
218 dnl ========================================================
219 dnl System overrides of the defaults for host
220 dnl ========================================================
223 if test -n "$_WIN32_MSVC"; then
224 HOST_CFLAGS="$HOST_CFLAGS"
226 HOST_CFLAGS="$HOST_CFLAGS -mwindows"
228 HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
229 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
232 case "${host_cpu}" in
234 if test -n "$_WIN32_MSVC"; then
235 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
239 if test -n "$_WIN32_MSVC"; then
240 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
242 HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
248 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
249 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
252 *-linux*|*-kfreebsd*-gnu|*-gnu*)
253 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
254 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
258 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
259 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
263 dnl ========================================================
264 dnl System overrides of the defaults for target
265 dnl ========================================================
267 MOZ_OPTIMIZE_LDFLAGS="${_COMPILATION_OPTIMIZE_LDFLAGS} ${MOZ_OPTIMIZE_FLAGS}"
271 MOZ_OPTIMIZE_FLAGS="-O3"
276 *-android*|*-linuxandroid*)
277 # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
278 # -Oz is smaller than -Os on clang.
279 MOZ_OPTIMIZE_FLAGS="-Oz"
280 # Disable the outliner, which causes performance regressions, and is
281 # enabled on some platforms at -Oz.
282 if test -z "$MOZ_LTO"; then
283 DISABLE_OUTLINER="-mno-outline"
285 CFLAGS="$CFLAGS $DISABLE_OUTLINER"
286 AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
287 CFLAGS="$_SAVE_CFLAGS"
289 DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
290 _SAVE_LDFLAGS=$LDFLAGS
291 LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
292 AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
293 LDFLAGS="$_SAVE_LDFLAGS"
298 if test "$GNU_CC" -o "$GNU_CXX"; then
299 MOZ_PGO_OPTIMIZE_FLAGS="-O3"
300 MOZ_OPTIMIZE_FLAGS="-O2"
303 case "${target_cpu}" in
305 CFLAGS="$CFLAGS -mieee"
306 CXXFLAGS="$CXXFLAGS -mieee"
312 # certain versions of cygwin's makedepend barf on the
313 # #include <string> vs -I./dist/include/string issue so don't use it
314 if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
315 # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
316 if test -z "$CLANG_CC"; then
317 AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
323 MOZ_OPTIMIZE_FLAGS="-O2"
325 WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
326 WIN32_GUI_EXE_LDFLAGS=-mwindows
328 # Silence problematic clang warnings
329 CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
330 LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
332 TARGET_COMPILER_ABI=msvc
333 WIN32_SUBSYSTEM_VERSION=10.0
334 WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
335 WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
336 DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
337 _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
338 _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
339 CFLAGS="$CFLAGS -Gy -Zc:inline"
340 CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
341 if test "$TARGET_CPU" = "x86"; then
342 dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
343 dnl more recent, so set that explicitly here unless another
344 dnl target arch has already been set.
346 if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
347 CFLAGS="$CFLAGS -arch:SSE2"
349 if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
350 CXXFLAGS="$CXXFLAGS -arch:SSE2"
354 dnl VS2013+ supports -Gw for better linker optimizations.
355 dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
356 dnl Disabled on ASan because it causes false-positive ODR violations.
357 if test -z "$MOZ_ASAN"; then
359 CXXFLAGS="$CXXFLAGS -Gw"
361 # String tail merging doesn't play nice with ASan's ODR checker.
362 LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
364 # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
365 CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
366 MOZ_DEBUG_LDFLAGS='-DEBUG'
367 if test "$HOST_OS_ARCH" != "WINNT"; then
368 # %_PDB% is a special signal to emit only the PDB basename. This
369 # avoids problems in Windows tools that don't like forward-slashes.
370 MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
372 MOZ_OPTIMIZE_FLAGS='-O2'
374 LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
376 AC_DEFINE(WIN32_LEAN_AND_MEAN)
377 dnl See http://support.microsoft.com/kb/143208 to use STL
383 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.])
389 if test -n "$GNU_CC"; then
390 CFLAGS="$CFLAGS -mstackrealign"
391 CXXFLAGS="$CXXFLAGS -mstackrealign"
392 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
394 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
395 LDFLAGS="$LDFLAGS -SAFESEH"
401 if test -n "$_WIN32_MSVC"; then
402 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
407 if test -n "$_WIN32_MSVC"; then
408 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
413 AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
419 CFLAGS="$CFLAGS -Dunix"
420 CXXFLAGS="$CXXFLAGS -Dunix"
421 if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
422 DSO_PIC_CFLAGS='-fPIC -DPIC'
424 MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
426 DSO_PIC_CFLAGS='-fPIC -DPIC'
429 # This will fail on a.out systems prior to 1.5.1_ALPHA.
430 if test "$LIBRUNPATH"; then
431 DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
436 if test -z "$X11BASE"; then
439 MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
440 DSO_PIC_CFLAGS='-fPIC'
441 DSO_LDOPTS='-shared -fPIC'
442 if test "$LIBRUNPATH"; then
443 DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
448 MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
453 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
454 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
456 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
457 MOZ_OPTIMIZE_FLAGS="-O"
461 if test -z "$COMPILE_ENVIRONMENT"; then
462 SKIP_COMPILER_CHECKS=1
463 SKIP_LIBRARY_CHECKS=1
467 fi # COMPILE_ENVIRONMENT
469 if test -z "$SKIP_COMPILER_CHECKS"; then
470 dnl Checks for typedefs, structures, and compiler characteristics.
471 dnl ========================================================
478 dnl Checks for libraries.
479 dnl ========================================================
480 AC_CHECK_LIB(c_r, gethostbyname_r)
482 dnl We don't want to link with libdl even if it's present on OS X, since
483 dnl it's not used and not part of the default installation. OS/2 has dlfcn
485 dnl We don't want to link against libm or libpthread on Darwin since
486 dnl they both are just symlinks to libSystem and explicitly linking
487 dnl against libSystem causes issues when debugging (see bug 299601).
492 AC_SEARCH_LIBS(dlopen, dl,
493 MOZ_CHECK_HEADER(dlfcn.h,
494 AC_DEFINE(HAVE_DLOPEN)))
498 _SAVE_CFLAGS="$CFLAGS"
499 CFLAGS="$CFLAGS -D_GNU_SOURCE"
500 AC_CHECK_FUNCS(dladdr)
501 CFLAGS="$_SAVE_CFLAGS"
503 if test ! "$GNU_CXX"; then
504 AC_CHECK_LIB(C, demangle)
507 AC_CHECK_LIB(socket, socket)
509 dnl ========================================================
510 dnl = pthread support
511 dnl = Start by checking whether the system support pthreads
512 dnl ========================================================
518 AC_CHECK_LIB(pthreads, pthread_create,
519 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
520 AC_CHECK_LIB(pthread, pthread_create,
521 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
522 AC_CHECK_LIB(c_r, pthread_create,
523 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
524 AC_CHECK_LIB(c, pthread_create,
533 dnl ========================================================
534 dnl Do the platform specific pthread hackery
535 dnl ========================================================
536 if test "$MOZ_USE_PTHREADS"x != x
539 dnl See if -pthread is supported.
542 ac_cv_have_dash_pthread=no
543 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
544 echo 'int main() { return 0; }' | cat > conftest.c
545 ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
546 if test $? -eq 0; then
547 if test -z "`grep -E -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`grep -E -i '(error|incorrect)' conftest.out`" ; then
548 ac_cv_have_dash_pthread=yes
551 # Freebsd doesn't use -pthread for compiles, it uses them for linking
554 CFLAGS="$CFLAGS -pthread"
555 CXXFLAGS="$CXXFLAGS -pthread"
561 AC_MSG_RESULT($ac_cv_have_dash_pthread)
564 dnl See if -pthreads is supported.
566 ac_cv_have_dash_pthreads=no
567 if test "$ac_cv_have_dash_pthread" = "no"; then
568 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
569 echo 'int main() { return 0; }' | cat > conftest.c
570 ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
571 if test $? -eq 0; then
572 if test -z "`grep -E -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`grep -E -i '(error|incorrect)' conftest.out`" ; then
573 ac_cv_have_dash_pthreads=yes
574 CFLAGS="$CFLAGS -pthreads"
575 CXXFLAGS="$CXXFLAGS -pthreads"
579 AC_MSG_RESULT($ac_cv_have_dash_pthreads)
584 AC_DEFINE(_REENTRANT)
585 AC_DEFINE(_THREAD_SAFE)
586 dnl -pthread links in -lpthread, so don't specify it explicitly.
587 if test "$ac_cv_have_dash_pthread" = "yes"; then
588 _PTHREAD_LDFLAGS="-pthread"
592 *-*-openbsd*|*-*-bsdi*)
593 AC_DEFINE(_REENTRANT)
594 AC_DEFINE(_THREAD_SAFE)
595 dnl -pthread links in -lc_r, so don't specify it explicitly.
596 if test "$ac_cv_have_dash_pthread" = "yes"; then
597 _PTHREAD_LDFLAGS="-pthread"
601 *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
602 AC_DEFINE(_REENTRANT)
606 LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
607 AC_SUBST(MOZ_USE_PTHREADS)
608 MOZ_CHECK_HEADERS(pthread.h)
612 dnl ========================================================
613 dnl Put your C++ language/feature checks below
614 dnl ========================================================
618 if test "$GNU_CC"; then
619 if test "$TARGET_CPU" = "arm" ; then
620 AC_CACHE_CHECK(for ARM EABI,
624 #if defined(__ARM_EABI__)
630 ac_cv_gcc_arm_eabi="yes",
631 ac_cv_gcc_arm_eabi="no")])
632 if test "$ac_cv_gcc_arm_eabi" = "yes"; then
640 TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
643 if test -n "$MOZ_LINKER"; then
644 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
645 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
646 dnl Since the linker only understands the sysv ones, no need to build the
647 dnl gnu style tables anyways.
648 LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
651 dnl End of C++ language/feature checks
654 fi # ! SKIP_COMPILER_CHECKS
656 if test -n "${COMPILE_ENVIRONMENT}"; then
661 if test -n "${TARGET_CPU}" -a -n "${TARGET_COMPILER_ABI}"; then
662 TARGET_XPCOM_ABI="${TARGET_CPU}-${TARGET_COMPILER_ABI}"
663 AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
666 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
667 dnl features that Windows actually does support.
669 if test -n "$SKIP_COMPILER_CHECKS"; then
670 dnl Windows has malloc.h
671 AC_DEFINE(MALLOC_H, [<malloc.h>])
672 AC_DEFINE(HAVE_FORCEINLINE)
673 fi # SKIP_COMPILER_CHECKS
675 dnl Mozilla specific options
676 dnl ========================================================
677 dnl The macros used for command line options
678 dnl are defined in build/autoconf/altoptions.m4.
680 dnl ========================================================
684 dnl ========================================================
686 MOZ_BRANDING_DIRECTORY=
687 MOZ_OFFICIAL_BRANDING=
689 MOZ_BINARY_EXTENSIONS=
692 dnl ========================================================
693 dnl = Trademarked Branding
694 dnl ========================================================
695 MOZ_ARG_ENABLE_BOOL(official-branding,
696 [ --enable-official-branding
697 Enable Official mozilla.org Branding
698 Do not distribute builds with
699 --enable-official-branding unless you have
700 permission to use trademarks per
701 http://www.mozilla.org/foundation/trademarks/ .],
702 MOZ_OFFICIAL_BRANDING=1,
703 MOZ_OFFICIAL_BRANDING=)
705 # Allow the application to influence configure with a confvars.sh script.
706 AC_MSG_CHECKING([if app-specific confvars.sh exists])
707 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
708 AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
709 . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
714 AC_SUBST(MOZ_OFFICIAL_BRANDING)
715 if test -n "$MOZ_OFFICIAL_BRANDING"; then
716 if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
717 AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
719 MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
720 AC_DEFINE(MOZ_OFFICIAL_BRANDING)
724 MOZ_ARG_WITH_STRING(branding,
725 [ --with-branding=dir Use branding from the specified directory.],
726 MOZ_BRANDING_DIRECTORY=$withval)
728 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
729 if test -z "$REAL_BRANDING_DIRECTORY"; then
730 REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
733 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
734 . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
737 AC_SUBST(MOZ_BRANDING_DIRECTORY)
739 dnl ========================================================
740 dnl = Distribution ID
741 dnl ========================================================
742 MOZ_ARG_WITH_STRING(distribution-id,
743 [ --with-distribution-id=ID
744 Set distribution-specific id (default=org.mozilla)],
745 [ val=`echo $withval`
746 MOZ_DISTRIBUTION_ID="$val"])
748 if test -z "$MOZ_DISTRIBUTION_ID"; then
749 MOZ_DISTRIBUTION_ID="org.mozilla"
752 AC_SUBST(MOZ_DISTRIBUTION_ID)
754 dnl ========================================================
755 dnl = Enable code optimization. ON by default.
756 dnl ========================================================
758 # Use value from moz.configure if one is defined. Else use our computed
760 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
761 MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
764 if test "$COMPILE_ENVIRONMENT"; then
765 if test -n "$MOZ_OPTIMIZE"; then
766 AC_MSG_CHECKING([for valid C compiler optimization flags])
768 CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
769 AC_TRY_COMPILE([#include <stdio.h>],
770 [printf("Hello World\n");],
773 AC_MSG_RESULT([$_results])
774 if test "$_results" = "no"; then
775 AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
778 if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
779 # When using llvm-based LTO, non numeric optimization levels are
780 # not supported by the linker, so force the linker to use -O2 (
781 # which doesn't influence the level compilation units are actually
783 case " $MOZ_OPTIMIZE_FLAGS " in
785 MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
790 fi # COMPILE_ENVIRONMENT
792 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
793 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
794 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
796 case "${OS_TARGET}" in
797 Android|WINNT|Darwin)
801 dnl On !Android !Windows !OSX, we only want to link executables against mozglue
802 MOZ_GLUE_IN_PROGRAM=1
803 AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
807 dnl ========================================================
808 dnl = Jemalloc build setup
809 dnl ========================================================
810 if test -n "$MOZ_MEMORY"; then
813 export MOZ_NO_DEBUG_RTL=1
817 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
819 dnl ========================================================
820 dnl = Enable using the clang plugin to build
821 dnl ========================================================
823 if test -n "$COMPILE_ENVIRONMENT"; then
824 MOZ_CONFIG_CLANG_PLUGIN
825 fi # COMPILE_ENVIRONMENT
829 if test "$COMPILE_ENVIRONMENT"; then
831 fi # COMPILE_ENVIRONMENT
833 dnl ========================================================
834 dnl Check if we need the 32-bit Linux SSE2 error dialog
835 dnl ========================================================
837 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
839 dnl ========================================================
841 dnl ========================================================
843 if test "$OS_ARCH" = "WINNT"; then
844 # For now we assume that we will have a uint64_t available through
845 # one of the above headers or mozstdint.h.
846 AC_DEFINE(HAVE_UINT64_T)
849 case "$MOZ_WIDGET_TOOLKIT" in
851 if test "$COMPILE_ENVIRONMENT"; then
852 MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
856 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
858 dnl ========================================================
860 dnl = Maintainer debug option (no --enable equivalent)
862 dnl ========================================================
864 AC_SUBST_LIST(ASFLAGS)
865 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
867 AC_SUBST(MOZ_STUB_INSTALLER)
869 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
871 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
873 if test -n "$MOZ_BINARY_EXTENSIONS"; then
874 AC_DEFINE(MOZ_BINARY_EXTENSIONS)
877 dnl ========================================================
878 dnl = Mac bundle name prefix
879 dnl ========================================================
880 MOZ_ARG_WITH_STRING(macbundlename-prefix,
881 [ --with-macbundlename-prefix=prefix
882 Prefix for MOZ_MACBUNDLE_NAME],
883 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
885 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
886 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
887 MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
890 if test "$MOZ_DEBUG"; then
891 MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
893 MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
895 AC_SUBST(MOZ_MACBUNDLE_NAME)
897 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
898 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
899 # Otherwise, use MOZ_APP_DISPLAYNAME
900 if test -z "$MOZ_MACBUNDLE_ID"; then
901 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
903 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
904 if test "$MOZ_DEBUG"; then
905 MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
908 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
909 AC_SUBST(MOZ_MACBUNDLE_ID)
911 dnl ========================================================
912 dnl = Child Process Name for IPC
913 dnl ========================================================
914 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
915 MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
917 # We want to let Android unpack the file at install time, but it only does
918 # so if the file is named libsomething.so. The lib/ path is also required
919 # because the unpacked file will be under the lib/ subdirectory and will
920 # need to be executed from that path.
921 MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
923 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
924 MOZ_CHILD_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.plugincontainer
925 MOZ_CHILD_PROCESS_BUNDLENAME="plugin-container.app"
926 MOZ_CHILD_PROCESS_APPNAME="${MOZ_APP_DISPLAYNAME}CP"
928 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
929 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
930 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLEID)
931 AC_SUBST(MOZ_CHILD_PROCESS_APPNAME)
932 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
934 dnl ==========================================================
935 dnl = Mac Media Plugin Helper (GMP Child) Process Name for IPC
936 dnl ==========================================================
937 MOZ_EME_PROCESS_NAME="media-plugin-helper"
938 MOZ_EME_PROCESS_NAME_BRANDED="$MOZ_APP_DISPLAYNAME Media Plugin Helper"
939 MOZ_EME_PROCESS_BUNDLENAME="${MOZ_EME_PROCESS_NAME}.app"
940 # Generate a lower case string with no spaces to be used as the bundle ID
941 # for the EME helper .app of the form org.mozilla.<executable-name>.
942 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_APP_DISPLAYNAME" | tr ' ' '-'`
943 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_EME_PROCESS_BUNDLEID" | tr 'A-Z' 'a-z'`
944 MOZ_EME_PROCESS_BUNDLEID=${MOZ_EME_PROCESS_BUNDLEID}-${MOZ_EME_PROCESS_NAME}
945 MOZ_EME_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.${MOZ_EME_PROCESS_BUNDLEID}
947 AC_SUBST(MOZ_EME_PROCESS_NAME)
948 AC_SUBST(MOZ_EME_PROCESS_NAME_BRANDED)
949 AC_SUBST(MOZ_EME_PROCESS_BUNDLENAME)
950 AC_SUBST(MOZ_EME_PROCESS_BUNDLEID)
952 # The following variables are available to branding and application
953 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
954 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
955 # impacts profile location and user-visible fields.
956 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
957 # Mac Bundle name, Updater, Installer), it is typically used for nightly
958 # builds (e.g. Aurora for Firefox).
959 # - MOZ_APP_PROFILE: When set, used for application.ini's
960 # "Profile" field, which controls profile location.
961 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
962 # crash reporter server url.
963 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
965 # The following environment variables used to have an effect, but don't anymore:
966 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
967 # the contents from the version.txt file in the application directory, or
968 # browser/config/version.txt if there isn't one.
969 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
970 # in the "About" window. This was replaced with the contents from the
971 # version_display.txt or version.txt in the application directory, or
972 # browser/config/version_display.txt.
974 # For extensions and langpacks, we require a max version that is compatible
975 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
976 # 24.0a1 and 24.0a2 aren't affected
978 # 24.1.1 becomes 24.*
979 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
980 if test -z "$IS_ALPHA"; then
982 if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
983 MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
985 MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
989 MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
992 AC_SUBST(MOZ_APP_DISPLAYNAME)
993 AC_SUBST(MOZ_APP_VENDOR)
994 AC_SUBST(MOZ_APP_PROFILE)
996 AC_SUBST(MAR_CHANNEL_ID)
997 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
998 AC_SUBST(MOZ_PROFILE_MIGRATOR)
999 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
1000 AC_SUBST(MOZ_APP_UA_NAME)
1001 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
1002 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
1003 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
1005 AC_SUBST(MOZ_APP_MAXVERSION)
1006 AC_SUBST(MOZ_PKG_SPECIAL)
1007 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
1009 if test "$MOZILLA_OFFICIAL"; then
1010 # Build revisions should always be present in official builds
1011 MOZ_INCLUDE_SOURCE_INFO=1
1014 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
1015 # explicitly set the repository and changeset information in.
1016 AC_SUBST(MOZ_SOURCE_REPO)
1017 AC_SUBST(MOZ_SOURCE_CHANGESET)
1018 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
1020 dnl Echo the CFLAGS to remove extra whitespace.
1022 $_COMPILATION_CFLAGS \
1026 $_COMPILATION_CXXFLAGS \
1030 $_COMPILATION_ASFLAGS \
1033 COMPILE_CFLAGS=`echo \
1037 COMPILE_CXXFLAGS=`echo \
1038 $_DEFINES_CXXFLAGS \
1042 $_COMPILATION_HOST_CFLAGS \
1045 HOST_CXXFLAGS=`echo \
1046 $_COMPILATION_HOST_CXXFLAGS \
1051 $_COMPILATION_LDFLAGS`
1053 HOST_LDFLAGS=`echo \
1055 $_COMPILATION_HOST_LDFLAGS`
1057 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
1058 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1059 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
1060 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1061 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
1062 OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1063 OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1065 AC_SUBST(HOST_CMFLAGS)
1066 AC_SUBST(HOST_CMMFLAGS)
1067 AC_SUBST(OS_COMPILE_CMFLAGS)
1068 AC_SUBST(OS_COMPILE_CMMFLAGS)
1071 OS_CXXFLAGS="$CXXFLAGS"
1072 OS_CPPFLAGS="$CPPFLAGS"
1073 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1074 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1075 OS_LDFLAGS="$LDFLAGS"
1077 AC_SUBST_LIST(OS_CFLAGS)
1078 AC_SUBST_LIST(OS_CXXFLAGS)
1079 AC_SUBST_LIST(OS_CPPFLAGS)
1080 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1081 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1082 AC_SUBST_LIST(OS_LDFLAGS)
1087 AC_SUBST_LIST(HOST_CFLAGS)
1088 AC_SUBST_LIST(HOST_CPPFLAGS)
1089 AC_SUBST_LIST(HOST_CXXFLAGS)
1090 AC_SUBST(HOST_LDFLAGS)
1091 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1092 AC_SUBST(HOST_BIN_SUFFIX)
1094 AC_SUBST(TARGET_XPCOM_ABI)
1096 AC_SUBST(DSO_LDOPTS)
1097 AC_SUBST(BIN_SUFFIX)
1099 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1100 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1102 AC_SUBST(MOZ_DEVTOOLS)
1104 AC_SUBST(MOZ_PACKAGE_JSSHELL)
1108 dnl Host JavaScript runtime, if any, to use during cross compiles.
1111 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
1113 dnl Set various defines and substitutions
1114 dnl ========================================================
1116 AC_SUBST(MOZ_DEV_EDITION)
1117 if test -n "$MOZ_DEV_EDITION"; then
1118 AC_DEFINE(MOZ_DEV_EDITION)
1121 dnl Spit out some output
1122 dnl ========================================================
1124 # Avoid using obsolete NSPR features
1125 AC_DEFINE(NO_NSPR_10_SUPPORT)
1127 MOZ_CREATE_CONFIG_STATUS()
1129 rm -fr confdefs* $ac_clean_files