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 # This prevents mingw from adding .exe when generating executable. Internal use
56 if test "$target" != "$host"; then
62 # Work around the conftest.exe access problem on Windows
70 dnl ========================================================
71 dnl Special win32 checks
72 dnl ========================================================
78 if test "$GCC" != "yes"; then
79 # Check to see if we are really running in a msvc environemnt
82 # Make sure compilers are valid
83 CXXFLAGS="$CXXFLAGS -TP"
86 AC_TRY_COMPILE([#include <stdio.h>],
87 [ printf("Hello World\n"); ],,
88 AC_MSG_ERROR([\$(CC) test failed. You must have MS VC++ in your path to build.]) )
91 AC_TRY_COMPILE([#include <new.h>],
92 [ unsigned *test = new unsigned(42); ],,
93 AC_MSG_ERROR([\$(CXX) test failed. You must have MS VC++ in your path to build.]) )
96 AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
97 AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
99 MSVC_C_RUNTIME_DLL=vcruntime140.dll
100 if test "$TARGET_CPU" != "x86"; then
101 MSVC_C_RUNTIME_1_DLL=vcruntime140_1.dll
103 MSVC_CXX_RUNTIME_DLL=msvcp140.dll
105 # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
106 CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
108 AC_SUBST(MSVC_C_RUNTIME_DLL)
109 AC_SUBST(MSVC_C_RUNTIME_1_DLL)
110 AC_SUBST(MSVC_CXX_RUNTIME_DLL)
112 AC_DEFINE(HAVE_SEH_EXCEPTIONS)
114 # Check w32api version
115 _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
116 _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
117 AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
118 AC_TRY_COMPILE([#include <w32api.h>],
119 #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
120 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
121 __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
122 #error "test failed."
124 , [ res=yes ], [ res=no ])
125 AC_MSG_RESULT([$res])
126 if test "$res" != "yes"; then
127 AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
129 # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
130 # causing problems with local implementations with the same name.
131 AC_DEFINE(STRSAFE_NO_DEPRECATE)
134 AC_DEFINE(_USE_MATH_DEFINES) # Otherwise Windows' math.h doesn't #define M_PI.
136 CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
137 CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
139 AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
140 AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
141 AC_DEFINE_UNQUOTED(_WIN32_IE,0x0A00)
146 if test -n "$_WIN32_MSVC"; then
148 SKIP_COMPILER_CHECKS=1
149 SKIP_LIBRARY_CHECKS=1
151 # Since we're skipping compiler and library checks, hard-code
154 AC_DEFINE(HAVE_ISATTY)
157 fi # COMPILE_ENVIRONMENT
162 dnl ========================================================
163 dnl set the defaults first
164 dnl ========================================================
165 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
167 dnl Configure platform-specific CPU architecture compiler options.
168 dnl ==============================================================
169 if test "$COMPILE_ENVIRONMENT"; then
171 fi # COMPILE_ENVIRONMENT
173 if test -n "$COMPILE_ENVIRONMENT"; then
177 dnl ========================================================
178 dnl GNU specific defaults
179 dnl ========================================================
180 if test "$GNU_CC"; then
181 if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
182 DSO_PIC_CFLAGS='-fPIC'
183 ASFLAGS="$ASFLAGS -fPIC"
187 if test "$GCC_USE_GNU_LD"; then
188 # Some tools like ASan use a runtime library that is only
189 # linked against executables, so we must allow undefined
190 # symbols for shared objects in some cases.
191 if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
192 # Don't allow undefined symbols in libraries
193 DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
195 # BSDs need `environ' exposed for posix_spawn (bug 753046)
197 DragonFly|FreeBSD|NetBSD|OpenBSD)
198 if test "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED" = 1; then
199 DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
201 DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
208 _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
210 ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
213 if test "$GNU_CXX"; then
214 CXXFLAGS="$CXXFLAGS -fno-exceptions"
216 _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
219 dnl ========================================================
220 dnl System overrides of the defaults for host
221 dnl ========================================================
224 if test -n "$_WIN32_MSVC"; then
225 HOST_CFLAGS="$HOST_CFLAGS"
227 HOST_CFLAGS="$HOST_CFLAGS -mwindows"
229 HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
230 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
233 case "${host_cpu}" in
235 if test -n "$_WIN32_MSVC"; then
236 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
240 if test -n "$_WIN32_MSVC"; then
241 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
243 HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
249 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
250 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
253 *-linux*|*-kfreebsd*-gnu|*-gnu*)
254 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
255 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
259 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
260 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
264 dnl ========================================================
265 dnl System overrides of the defaults for target
266 dnl ========================================================
268 MOZ_OPTIMIZE_LDFLAGS="${_COMPILATION_OPTIMIZE_LDFLAGS} ${MOZ_OPTIMIZE_FLAGS}"
272 MOZ_OPTIMIZE_FLAGS="-O3"
277 *-android*|*-linuxandroid*)
278 # From https://github.com/android-ndk/ndk/issues/133#issuecomment-308549264
279 # -Oz is smaller than -Os on clang.
280 MOZ_OPTIMIZE_FLAGS="-Oz"
281 # Disable the outliner, which causes performance regressions, and is
282 # enabled on some platforms at -Oz.
283 if test -z "$MOZ_LTO"; then
284 DISABLE_OUTLINER="-mno-outline"
286 CFLAGS="$CFLAGS $DISABLE_OUTLINER"
287 AC_TRY_COMPILE(,,[MOZ_OPTIMIZE_FLAGS="$MOZ_OPTIMIZE_FLAGS $DISABLE_OUTLINER"])
288 CFLAGS="$_SAVE_CFLAGS"
290 DISABLE_OUTLINER="-Wl,-plugin-opt=-enable-machine-outliner=never"
291 _SAVE_LDFLAGS=$LDFLAGS
292 LDFLAGS="$LDFLAGS $MOZ_LTO_LDFLAGS $DISABLE_OUTLINER"
293 AC_TRY_LINK(,,[MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS $DISABLE_OUTLINER"])
294 LDFLAGS="$_SAVE_LDFLAGS"
299 if test "$GNU_CC" -o "$GNU_CXX"; then
300 MOZ_PGO_OPTIMIZE_FLAGS="-O3"
301 MOZ_OPTIMIZE_FLAGS="-O2"
304 case "${target_cpu}" in
306 CFLAGS="$CFLAGS -mieee"
307 CXXFLAGS="$CXXFLAGS -mieee"
313 # certain versions of cygwin's makedepend barf on the
314 # #include <string> vs -I./dist/include/string issue so don't use it
315 if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
316 # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
317 if test -z "$CLANG_CC"; then
318 AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
324 MOZ_OPTIMIZE_FLAGS="-O2"
326 WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
327 WIN32_GUI_EXE_LDFLAGS=-mwindows
329 # Silence problematic clang warnings
330 CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
331 LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
333 TARGET_COMPILER_ABI=msvc
334 WIN32_SUBSYSTEM_VERSION=10.0
335 WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
336 WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
337 DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
338 _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
339 _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
340 CFLAGS="$CFLAGS -Gy -Zc:inline"
341 CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
342 if test "$TARGET_CPU" = "x86"; then
343 dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
344 dnl more recent, so set that explicitly here unless another
345 dnl target arch has already been set.
347 if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
348 CFLAGS="$CFLAGS -arch:SSE2"
350 if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
351 CXXFLAGS="$CXXFLAGS -arch:SSE2"
355 dnl VS2013+ supports -Gw for better linker optimizations.
356 dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
357 dnl Disabled on ASan because it causes false-positive ODR violations.
358 if test -z "$MOZ_ASAN"; then
360 CXXFLAGS="$CXXFLAGS -Gw"
362 # String tail merging doesn't play nice with ASan's ODR checker.
363 LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
365 # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
366 CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
367 MOZ_DEBUG_LDFLAGS='-DEBUG'
368 if test "$HOST_OS_ARCH" != "WINNT"; then
369 # %_PDB% is a special signal to emit only the PDB basename. This
370 # avoids problems in Windows tools that don't like forward-slashes.
371 MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
373 MOZ_OPTIMIZE_FLAGS='-O2'
375 LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
377 AC_DEFINE(WIN32_LEAN_AND_MEAN)
378 dnl See http://support.microsoft.com/kb/143208 to use STL
384 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.])
390 if test -n "$GNU_CC"; then
391 CFLAGS="$CFLAGS -mstackrealign"
392 CXXFLAGS="$CXXFLAGS -mstackrealign"
393 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
395 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
396 LDFLAGS="$LDFLAGS -SAFESEH"
402 if test -n "$_WIN32_MSVC"; then
403 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
408 if test -n "$_WIN32_MSVC"; then
409 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
414 AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
420 CFLAGS="$CFLAGS -Dunix"
421 CXXFLAGS="$CXXFLAGS -Dunix"
422 if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
423 DSO_PIC_CFLAGS='-fPIC -DPIC'
425 MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
427 DSO_PIC_CFLAGS='-fPIC -DPIC'
430 # This will fail on a.out systems prior to 1.5.1_ALPHA.
431 if test "$LIBRUNPATH"; then
432 DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
437 if test -z "$X11BASE"; then
440 MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
441 DSO_PIC_CFLAGS='-fPIC'
442 DSO_LDOPTS='-shared -fPIC'
443 if test "$LIBRUNPATH"; then
444 DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
449 MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
454 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
455 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
457 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
458 MOZ_OPTIMIZE_FLAGS="-O"
462 if test -z "$COMPILE_ENVIRONMENT"; then
463 SKIP_COMPILER_CHECKS=1
464 SKIP_LIBRARY_CHECKS=1
468 fi # COMPILE_ENVIRONMENT
470 if test -z "$SKIP_COMPILER_CHECKS"; then
471 dnl Checks for typedefs, structures, and compiler characteristics.
472 dnl ========================================================
479 dnl Checks for libraries.
480 dnl ========================================================
481 AC_CHECK_LIB(c_r, gethostbyname_r)
483 dnl We don't want to link with libdl even if it's present on OS X, since
484 dnl it's not used and not part of the default installation. OS/2 has dlfcn
486 dnl We don't want to link against libm or libpthread on Darwin since
487 dnl they both are just symlinks to libSystem and explicitly linking
488 dnl against libSystem causes issues when debugging (see bug 299601).
493 AC_SEARCH_LIBS(dlopen, dl,
494 MOZ_CHECK_HEADER(dlfcn.h,
495 AC_DEFINE(HAVE_DLOPEN)))
499 _SAVE_CFLAGS="$CFLAGS"
500 CFLAGS="$CFLAGS -D_GNU_SOURCE"
501 AC_CHECK_FUNCS(dladdr)
502 CFLAGS="$_SAVE_CFLAGS"
504 if test ! "$GNU_CXX"; then
505 AC_CHECK_LIB(C, demangle)
508 AC_CHECK_LIB(socket, socket)
510 dnl ========================================================
511 dnl = pthread support
512 dnl = Start by checking whether the system support pthreads
513 dnl ========================================================
519 AC_CHECK_LIB(pthreads, pthread_create,
520 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
521 AC_CHECK_LIB(pthread, pthread_create,
522 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
523 AC_CHECK_LIB(c_r, pthread_create,
524 MOZ_USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
525 AC_CHECK_LIB(c, pthread_create,
534 dnl ========================================================
535 dnl Do the platform specific pthread hackery
536 dnl ========================================================
537 if test "$MOZ_USE_PTHREADS"x != x
540 dnl See if -pthread is supported.
543 ac_cv_have_dash_pthread=no
544 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
545 echo 'int main() { return 0; }' | cat > conftest.c
546 ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
547 if test $? -eq 0; then
548 if test -z "`grep -E -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`grep -E -i '(error|incorrect)' conftest.out`" ; then
549 ac_cv_have_dash_pthread=yes
552 # Freebsd doesn't use -pthread for compiles, it uses them for linking
555 CFLAGS="$CFLAGS -pthread"
556 CXXFLAGS="$CXXFLAGS -pthread"
562 AC_MSG_RESULT($ac_cv_have_dash_pthread)
565 dnl See if -pthreads is supported.
567 ac_cv_have_dash_pthreads=no
568 if test "$ac_cv_have_dash_pthread" = "no"; then
569 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
570 echo 'int main() { return 0; }' | cat > conftest.c
571 ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
572 if test $? -eq 0; then
573 if test -z "`grep -E -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`grep -E -i '(error|incorrect)' conftest.out`" ; then
574 ac_cv_have_dash_pthreads=yes
575 CFLAGS="$CFLAGS -pthreads"
576 CXXFLAGS="$CXXFLAGS -pthreads"
580 AC_MSG_RESULT($ac_cv_have_dash_pthreads)
585 AC_DEFINE(_REENTRANT)
586 AC_DEFINE(_THREAD_SAFE)
587 dnl -pthread links in -lpthread, so don't specify it explicitly.
588 if test "$ac_cv_have_dash_pthread" = "yes"; then
589 _PTHREAD_LDFLAGS="-pthread"
593 *-*-openbsd*|*-*-bsdi*)
594 AC_DEFINE(_REENTRANT)
595 AC_DEFINE(_THREAD_SAFE)
596 dnl -pthread links in -lc_r, so don't specify it explicitly.
597 if test "$ac_cv_have_dash_pthread" = "yes"; then
598 _PTHREAD_LDFLAGS="-pthread"
602 *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
603 AC_DEFINE(_REENTRANT)
607 LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
608 AC_SUBST(MOZ_USE_PTHREADS)
609 MOZ_CHECK_HEADERS(pthread.h)
613 dnl ========================================================
614 dnl Put your C++ language/feature checks below
615 dnl ========================================================
619 if test "$GNU_CC"; then
620 if test "$TARGET_CPU" = "arm" ; then
621 AC_CACHE_CHECK(for ARM EABI,
625 #if defined(__ARM_EABI__)
631 ac_cv_gcc_arm_eabi="yes",
632 ac_cv_gcc_arm_eabi="no")])
633 if test "$ac_cv_gcc_arm_eabi" = "yes"; then
641 TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
644 if test -n "$MOZ_LINKER"; then
645 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
646 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
647 dnl Since the linker only understands the sysv ones, no need to build the
648 dnl gnu style tables anyways.
649 LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
652 dnl End of C++ language/feature checks
655 fi # ! SKIP_COMPILER_CHECKS
657 if test -n "${COMPILE_ENVIRONMENT}"; then
662 if test -n "${TARGET_CPU}" -a -n "${TARGET_COMPILER_ABI}"; then
663 TARGET_XPCOM_ABI="${TARGET_CPU}-${TARGET_COMPILER_ABI}"
664 AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
667 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
668 dnl features that Windows actually does support.
670 if test -n "$SKIP_COMPILER_CHECKS"; then
671 dnl Windows has malloc.h
672 AC_DEFINE(MALLOC_H, [<malloc.h>])
673 AC_DEFINE(HAVE_FORCEINLINE)
674 fi # SKIP_COMPILER_CHECKS
676 dnl Mozilla specific options
677 dnl ========================================================
678 dnl The macros used for command line options
679 dnl are defined in build/autoconf/altoptions.m4.
681 dnl ========================================================
685 dnl ========================================================
687 MOZ_BRANDING_DIRECTORY=
688 MOZ_OFFICIAL_BRANDING=
690 MOZ_BINARY_EXTENSIONS=
693 dnl ========================================================
694 dnl = Trademarked Branding
695 dnl ========================================================
696 MOZ_ARG_ENABLE_BOOL(official-branding,
697 [ --enable-official-branding
698 Enable Official mozilla.org Branding
699 Do not distribute builds with
700 --enable-official-branding unless you have
701 permission to use trademarks per
702 http://www.mozilla.org/foundation/trademarks/ .],
703 MOZ_OFFICIAL_BRANDING=1,
704 MOZ_OFFICIAL_BRANDING=)
706 # Allow the application to influence configure with a confvars.sh script.
707 AC_MSG_CHECKING([if app-specific confvars.sh exists])
708 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
709 AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
710 . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
715 AC_SUBST(MOZ_OFFICIAL_BRANDING)
716 if test -n "$MOZ_OFFICIAL_BRANDING"; then
717 if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
718 AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
720 MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
721 AC_DEFINE(MOZ_OFFICIAL_BRANDING)
725 MOZ_ARG_WITH_STRING(branding,
726 [ --with-branding=dir Use branding from the specified directory.],
727 MOZ_BRANDING_DIRECTORY=$withval)
729 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
730 if test -z "$REAL_BRANDING_DIRECTORY"; then
731 REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
734 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
735 . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
738 AC_SUBST(MOZ_BRANDING_DIRECTORY)
740 dnl ========================================================
741 dnl = Distribution ID
742 dnl ========================================================
743 MOZ_ARG_WITH_STRING(distribution-id,
744 [ --with-distribution-id=ID
745 Set distribution-specific id (default=org.mozilla)],
746 [ val=`echo $withval`
747 MOZ_DISTRIBUTION_ID="$val"])
749 if test -z "$MOZ_DISTRIBUTION_ID"; then
750 MOZ_DISTRIBUTION_ID="org.mozilla"
753 AC_SUBST(MOZ_DISTRIBUTION_ID)
755 dnl ========================================================
756 dnl = Enable code optimization. ON by default.
757 dnl ========================================================
759 # Use value from moz.configure if one is defined. Else use our computed
761 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
762 MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
765 if test "$COMPILE_ENVIRONMENT"; then
766 if test -n "$MOZ_OPTIMIZE"; then
767 AC_MSG_CHECKING([for valid C compiler optimization flags])
769 CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
770 AC_TRY_COMPILE([#include <stdio.h>],
771 [printf("Hello World\n");],
774 AC_MSG_RESULT([$_results])
775 if test "$_results" = "no"; then
776 AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
779 if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
780 # When using llvm-based LTO, non numeric optimization levels are
781 # not supported by the linker, so force the linker to use -O2 (
782 # which doesn't influence the level compilation units are actually
784 case " $MOZ_OPTIMIZE_FLAGS " in
786 MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
791 fi # COMPILE_ENVIRONMENT
793 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
794 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
795 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
797 case "${OS_TARGET}" in
798 Android|WINNT|Darwin)
802 dnl On !Android !Windows !OSX, we only want to link executables against mozglue
803 MOZ_GLUE_IN_PROGRAM=1
804 AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
808 dnl ========================================================
809 dnl = Jemalloc build setup
810 dnl ========================================================
811 if test -n "$MOZ_MEMORY"; then
814 export MOZ_NO_DEBUG_RTL=1
818 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
820 dnl ========================================================
821 dnl = Enable using the clang plugin to build
822 dnl ========================================================
824 if test -n "$COMPILE_ENVIRONMENT"; then
825 MOZ_CONFIG_CLANG_PLUGIN
826 fi # COMPILE_ENVIRONMENT
830 if test "$COMPILE_ENVIRONMENT"; then
832 fi # COMPILE_ENVIRONMENT
834 dnl ========================================================
835 dnl Check if we need the 32-bit Linux SSE2 error dialog
836 dnl ========================================================
838 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
840 dnl ========================================================
842 dnl ========================================================
844 if test "$OS_ARCH" = "WINNT"; then
845 # For now we assume that we will have a uint64_t available through
846 # one of the above headers or mozstdint.h.
847 AC_DEFINE(HAVE_UINT64_T)
850 case "$MOZ_WIDGET_TOOLKIT" in
852 if test "$COMPILE_ENVIRONMENT"; then
853 MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
857 AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
859 dnl ========================================================
861 dnl = Maintainer debug option (no --enable equivalent)
863 dnl ========================================================
865 AC_SUBST_LIST(ASFLAGS)
866 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
868 AC_SUBST(MOZ_STUB_INSTALLER)
870 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
872 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
874 if test -n "$MOZ_BINARY_EXTENSIONS"; then
875 AC_DEFINE(MOZ_BINARY_EXTENSIONS)
878 dnl ========================================================
879 dnl = Mac bundle name prefix
880 dnl ========================================================
881 MOZ_ARG_WITH_STRING(macbundlename-prefix,
882 [ --with-macbundlename-prefix=prefix
883 Prefix for MOZ_MACBUNDLE_NAME],
884 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
886 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
887 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
888 MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
891 if test "$MOZ_DEBUG"; then
892 MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
894 MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
896 AC_SUBST(MOZ_MACBUNDLE_NAME)
898 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
899 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
900 # Otherwise, use MOZ_APP_DISPLAYNAME
901 if test -z "$MOZ_MACBUNDLE_ID"; then
902 MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
904 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
905 if test "$MOZ_DEBUG"; then
906 MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
909 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
910 AC_SUBST(MOZ_MACBUNDLE_ID)
912 dnl ========================================================
913 dnl = Child Process Name for IPC
914 dnl ========================================================
915 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
916 MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
918 # We want to let Android unpack the file at install time, but it only does
919 # so if the file is named libsomething.so. The lib/ path is also required
920 # because the unpacked file will be under the lib/ subdirectory and will
921 # need to be executed from that path.
922 MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
924 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
925 MOZ_CHILD_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.plugincontainer
926 MOZ_CHILD_PROCESS_BUNDLENAME="plugin-container.app"
927 MOZ_CHILD_PROCESS_APPNAME="${MOZ_APP_DISPLAYNAME}CP"
929 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
930 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
931 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLEID)
932 AC_SUBST(MOZ_CHILD_PROCESS_APPNAME)
933 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
935 dnl ==========================================================
936 dnl = Mac Media Plugin Helper (GMP Child) Process Name for IPC
937 dnl ==========================================================
938 MOZ_EME_PROCESS_NAME="media-plugin-helper"
939 MOZ_EME_PROCESS_NAME_BRANDED="$MOZ_APP_DISPLAYNAME Media Plugin Helper"
940 MOZ_EME_PROCESS_BUNDLENAME="${MOZ_EME_PROCESS_NAME}.app"
941 # Generate a lower case string with no spaces to be used as the bundle ID
942 # for the EME helper .app of the form org.mozilla.<executable-name>.
943 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_APP_DISPLAYNAME" | tr ' ' '-'`
944 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_EME_PROCESS_BUNDLEID" | tr 'A-Z' 'a-z'`
945 MOZ_EME_PROCESS_BUNDLEID=${MOZ_EME_PROCESS_BUNDLEID}-${MOZ_EME_PROCESS_NAME}
946 MOZ_EME_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.${MOZ_EME_PROCESS_BUNDLEID}
948 AC_SUBST(MOZ_EME_PROCESS_NAME)
949 AC_SUBST(MOZ_EME_PROCESS_NAME_BRANDED)
950 AC_SUBST(MOZ_EME_PROCESS_BUNDLENAME)
951 AC_SUBST(MOZ_EME_PROCESS_BUNDLEID)
953 # The following variables are available to branding and application
954 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
955 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
956 # impacts profile location and user-visible fields.
957 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
958 # Mac Bundle name, Updater, Installer), it is typically used for nightly
959 # builds (e.g. Aurora for Firefox).
960 # - MOZ_APP_PROFILE: When set, used for application.ini's
961 # "Profile" field, which controls profile location.
962 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
963 # crash reporter server url.
964 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
966 # The following environment variables used to have an effect, but don't anymore:
967 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
968 # the contents from the version.txt file in the application directory, or
969 # browser/config/version.txt if there isn't one.
970 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
971 # in the "About" window. This was replaced with the contents from the
972 # version_display.txt or version.txt in the application directory, or
973 # browser/config/version_display.txt.
975 # For extensions and langpacks, we require a max version that is compatible
976 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
977 # 24.0a1 and 24.0a2 aren't affected
979 # 24.1.1 becomes 24.*
980 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
981 if test -z "$IS_ALPHA"; then
983 if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
984 MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
986 MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
990 MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
993 AC_SUBST(MOZ_APP_DISPLAYNAME)
994 AC_SUBST(MOZ_APP_VENDOR)
995 AC_SUBST(MOZ_APP_PROFILE)
997 AC_SUBST(MAR_CHANNEL_ID)
998 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
999 AC_SUBST(MOZ_PROFILE_MIGRATOR)
1000 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
1001 AC_SUBST(MOZ_APP_UA_NAME)
1002 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
1003 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
1004 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
1006 AC_SUBST(MOZ_APP_MAXVERSION)
1007 AC_SUBST(MOZ_PKG_SPECIAL)
1008 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
1010 if test "$MOZILLA_OFFICIAL"; then
1011 # Build revisions should always be present in official builds
1012 MOZ_INCLUDE_SOURCE_INFO=1
1015 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
1016 # explicitly set the repository and changeset information in.
1017 AC_SUBST(MOZ_SOURCE_REPO)
1018 AC_SUBST(MOZ_SOURCE_CHANGESET)
1019 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
1021 dnl Echo the CFLAGS to remove extra whitespace.
1023 $_COMPILATION_CFLAGS \
1027 $_COMPILATION_CXXFLAGS \
1031 $_COMPILATION_ASFLAGS \
1034 COMPILE_CFLAGS=`echo \
1038 COMPILE_CXXFLAGS=`echo \
1039 $_DEFINES_CXXFLAGS \
1043 $_COMPILATION_HOST_CFLAGS \
1046 HOST_CXXFLAGS=`echo \
1047 $_COMPILATION_HOST_CXXFLAGS \
1052 $_COMPILATION_LDFLAGS`
1054 HOST_LDFLAGS=`echo \
1056 $_COMPILATION_HOST_LDFLAGS`
1058 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
1059 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1060 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
1061 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
1062 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
1063 OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1064 OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
1066 AC_SUBST(HOST_CMFLAGS)
1067 AC_SUBST(HOST_CMMFLAGS)
1068 AC_SUBST(OS_COMPILE_CMFLAGS)
1069 AC_SUBST(OS_COMPILE_CMMFLAGS)
1072 OS_CXXFLAGS="$CXXFLAGS"
1073 OS_CPPFLAGS="$CPPFLAGS"
1074 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
1075 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
1076 OS_LDFLAGS="$LDFLAGS"
1078 AC_SUBST_LIST(OS_CFLAGS)
1079 AC_SUBST_LIST(OS_CXXFLAGS)
1080 AC_SUBST_LIST(OS_CPPFLAGS)
1081 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1082 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1083 AC_SUBST_LIST(OS_LDFLAGS)
1088 AC_SUBST_LIST(HOST_CFLAGS)
1089 AC_SUBST_LIST(HOST_CPPFLAGS)
1090 AC_SUBST_LIST(HOST_CXXFLAGS)
1091 AC_SUBST(HOST_LDFLAGS)
1092 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1093 AC_SUBST(HOST_BIN_SUFFIX)
1095 AC_SUBST(TARGET_XPCOM_ABI)
1097 AC_SUBST(DSO_LDOPTS)
1098 AC_SUBST(BIN_SUFFIX)
1100 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1101 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1103 AC_SUBST(MOZ_DEVTOOLS)
1105 AC_SUBST(MOZ_PACKAGE_JSSHELL)
1109 dnl Host JavaScript runtime, if any, to use during cross compiles.
1112 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
1114 dnl Set various defines and substitutions
1115 dnl ========================================================
1117 AC_SUBST(MOZ_DEV_EDITION)
1118 if test -n "$MOZ_DEV_EDITION"; then
1119 AC_DEFINE(MOZ_DEV_EDITION)
1122 dnl Spit out some output
1123 dnl ========================================================
1125 # Avoid using obsolete NSPR features
1126 AC_DEFINE(NO_NSPR_10_SUPPORT)
1128 MOZ_CREATE_CONFIG_STATUS()
1130 rm -fr confdefs* $ac_clean_files