Backed out changeset 2d88daa2e4bc (bug 1899848) for conflicting with the backout...
[gecko.git] / old-configure.in
blob29a313c05582ea5ccab5a187fd8d3c5b05fff4bd
1 dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; -*-
2 dnl vi: set tabstop=4 shiftwidth=4 expandtab syntax=m4:
3 dnl This Source Code Form is subject to the terms of the Mozilla Public
4 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
5 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 dnl Process this file with autoconf to produce a configure script.
8 dnl ========================================================
9 AC_PREREQ(2.13)
10 AC_INIT(config/config.mk)
11 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
12 AC_CANONICAL_SYSTEM
14 dnl ========================================================
15 dnl =
16 dnl = Don't change the following lines. Doing so breaks:
17 dnl =
18 dnl = CFLAGS="-foo" ./configure
19 dnl =
20 dnl ========================================================
21 CFLAGS="${CFLAGS=}"
22 CPPFLAGS="${CPPFLAGS=}"
23 CXXFLAGS="${CXXFLAGS=}"
24 LDFLAGS="${LDFLAGS=}"
25 HOST_CFLAGS="${HOST_CFLAGS=}"
26 HOST_CXXFLAGS="${HOST_CXXFLAGS=}"
27 HOST_LDFLAGS="${HOST_LDFLAGS=}"
29 dnl Set the minimum version of toolkit libs used by mozilla
30 dnl ========================================================
31 W32API_VERSION=3.14
34 LDFLAGS="$LDFLAGS $LINKER_LDFLAGS $PACK_REL_RELOC_FLAGS"
35 HOST_LDFLAGS="$HOST_LDFLAGS $HOST_LINKER_LDFLAGS"
37 if test "$COMPILE_ENVIRONMENT"; then
38     MOZ_ANDROID_NDK
39 fi # COMPILE_ENVIRONMENT
41 dnl ========================================================
42 dnl Checks for compilers.
43 dnl ========================================================
45 if test "$COMPILE_ENVIRONMENT"; then
47 # This prevents mingw from adding .exe when generating executable. Internal use
48 # only.
49 ac_exeext=.out
51 if test "$target" != "$host"; then
52     MOZ_CROSS_COMPILER
53 else
54     AC_PROG_CC
55     case "$target" in
56     *-mingw*)
57       # Work around the conftest.exe access problem on Windows
58       sleep 2
59     esac
60     AC_PROG_CXX
63 MOZ_TOOL_VARIABLES
65 dnl ========================================================
66 dnl Special win32 checks
67 dnl ========================================================
69 WINVER=0A00
71 case "$target" in
72 *-mingw*)
73     if test "$GCC" != "yes"; then
74         # Check to see if we are really running in a msvc environemnt
75         _WIN32_MSVC=1
77         # Make sure compilers are valid
78         CXXFLAGS="$CXXFLAGS -TP"
79         AC_LANG_SAVE
80         AC_LANG_C
81         AC_TRY_COMPILE([#include <stdio.h>],
82             [ printf("Hello World\n"); ],,
83             AC_MSG_ERROR([\$(CC) test failed.  You must have MS VC++ in your path to build.]) )
85         AC_LANG_CPLUSPLUS
86         AC_TRY_COMPILE([#include <new.h>],
87             [ unsigned *test = new unsigned(42); ],,
88             AC_MSG_ERROR([\$(CXX) test failed.  You must have MS VC++ in your path to build.]) )
89         AC_LANG_RESTORE
91         AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
92         AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
94         MSVC_C_RUNTIME_DLL=vcruntime140.dll
95         if test "$TARGET_CPU" != "x86"; then
96             MSVC_C_RUNTIME_1_DLL=vcruntime140_1.dll
97         fi
98         MSVC_CXX_RUNTIME_DLL=msvcp140.dll
100         # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
101         CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
103         AC_SUBST(MSVC_C_RUNTIME_DLL)
104         AC_SUBST(MSVC_C_RUNTIME_1_DLL)
105         AC_SUBST(MSVC_CXX_RUNTIME_DLL)
107         AC_DEFINE(HAVE_SEH_EXCEPTIONS)
108     else
109         # Check w32api version
110         _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
111         _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
112         AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
113         AC_TRY_COMPILE([#include <w32api.h>],
114             #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
115                 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
116                  __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
117                 #error "test failed."
118             #endif
119             , [ res=yes ], [ res=no ])
120         AC_MSG_RESULT([$res])
121         if test "$res" != "yes"; then
122             AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
123         fi
124         # strsafe.h on mingw uses macros for function deprecation that pollutes namespace
125         # causing problems with local implementations with the same name.
126         AC_DEFINE(STRSAFE_NO_DEPRECATE)
127     fi # !GNU_CC
129     AC_DEFINE(_USE_MATH_DEFINES) # Otherwise Windows' math.h doesn't #define M_PI.
131     CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
132     CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
134     AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
135     AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
136     AC_DEFINE_UNQUOTED(_WIN32_IE,0x0A00)
138     ;;
139 esac
141 if test -n "$_WIN32_MSVC"; then
142     SKIP_PATH_CHECKS=1
143     SKIP_COMPILER_CHECKS=1
144     SKIP_LIBRARY_CHECKS=1
146     # Since we're skipping compiler and library checks, hard-code
147     # some facts here.
148     AC_DEFINE(HAVE_IO_H)
149     AC_DEFINE(HAVE_ISATTY)
152 fi # COMPILE_ENVIRONMENT
154 AC_SUBST(GNU_CC)
155 AC_SUBST(GNU_CXX)
157 dnl ========================================================
158 dnl set the defaults first
159 dnl ========================================================
160 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
162 dnl Configure platform-specific CPU architecture compiler options.
163 dnl ==============================================================
164 if test "$COMPILE_ENVIRONMENT"; then
165     MOZ_ARCH_OPTS
166 fi # COMPILE_ENVIRONMENT
168 if test -n "$COMPILE_ENVIRONMENT"; then
169    MOZ_CONFIG_SANITIZE
172 dnl ========================================================
173 dnl GNU specific defaults
174 dnl ========================================================
175 if test "$GNU_CC"; then
176     if test "$OS_ARCH" != "WINNT" -o -z "$CLANG_CC"; then
177         DSO_PIC_CFLAGS='-fPIC'
178         ASFLAGS="$ASFLAGS -fPIC"
179     fi
181     DSO_LDOPTS='-shared'
182     if test "$GCC_USE_GNU_LD"; then
183         # Some tools like ASan use a runtime library that is only
184         # linked against executables, so we must allow undefined
185         # symbols for shared objects in some cases.
186         if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
187             # Don't allow undefined symbols in libraries
188             DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
190             # BSDs need `environ' exposed for posix_spawn (bug 753046)
191             case "$OS_TARGET" in
192             DragonFly|FreeBSD|NetBSD|OpenBSD)
193                 if test "$HAVE_LINKER_SUPPORT_IGNORE_UNRESOLVED" = 1; then
194                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--ignore-unresolved-symbol,environ"
195                 else
196                     DSO_LDOPTS="$DSO_LDOPTS -Wl,--warn-unresolved-symbols"
197                 fi
198                 ;;
199             esac
200         fi
201     fi
203     _DEFINES_CFLAGS="-include $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
205     ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
208 if test "$GNU_CXX"; then
209     CXXFLAGS="$CXXFLAGS -fno-exceptions"
211     _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $_objdir/mozilla-config.h"
214 dnl ========================================================
215 dnl System overrides of the defaults for host
216 dnl ========================================================
217 case "$host" in
218 *mingw*)
219     if test "$HOST_CC_TYPE" = clang-cl; then
220         HOST_CFLAGS="$HOST_CFLAGS"
221     else
222         HOST_CFLAGS="$HOST_CFLAGS -mwindows"
223     fi
224     HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
225     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
226     HOST_BIN_SUFFIX=.exe
228     case "${host_cpu}" in
229     i*86)
230         if test "$HOST_CC_TYPE" = clang-cl; then
231             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
232         fi
233         ;;
234     x86_64)
235         if test "$HOST_CC_TYPE" = clang-cl; then
236             HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
237         fi
238         HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
239         ;;
240     esac
241     ;;
243 *-darwin*)
244     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
245     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
246     ;;
248 *-linux*|*-kfreebsd*-gnu|*-gnu*)
249     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
250     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
251     ;;
254     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
255     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
256     ;;
257 esac
259 dnl ========================================================
260 dnl System overrides of the defaults for target
261 dnl ========================================================
263 MOZ_OPTIMIZE_LDFLAGS="${_COMPILATION_OPTIMIZE_LDFLAGS} ${MOZ_OPTIMIZE_FLAGS}"
265 case "$target" in
266 *-darwin*)
267     MOZ_OPTIMIZE_FLAGS="-O3"
268     DSO_LDOPTS=''
269     MOZ_FIX_LINK_PATHS=
270     ;;
272 *-android*|*-linuxandroid*)
273     MOZ_OPTIMIZE_FLAGS="-O2"
274     ;;
276 *-*linux*)
277     if test "$GNU_CC" -o "$GNU_CXX"; then
278         MOZ_PGO_OPTIMIZE_FLAGS="-O3"
279         MOZ_OPTIMIZE_FLAGS="-O2"
280     fi
282     case "${target_cpu}" in
283     alpha*)
284         CFLAGS="$CFLAGS -mieee"
285         CXXFLAGS="$CXXFLAGS -mieee"
286     ;;
287     esac
288     ;;
289 *-mingw*)
290     DSO_PIC_CFLAGS=
291     # certain versions of cygwin's makedepend barf on the
292     # #include <string> vs -I./dist/include/string issue so don't use it
293     if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
294         # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
295         if test -z "$CLANG_CC"; then
296             AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
297         fi
299         DSO_LDOPTS='-shared'
300         MOZ_FIX_LINK_PATHS=
302         MOZ_OPTIMIZE_FLAGS="-O2"
304         WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
305         WIN32_GUI_EXE_LDFLAGS=-mwindows
307         # Silence problematic clang warnings
308         CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
309         LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
310     else
311         TARGET_COMPILER_ABI=msvc
312         WIN32_SUBSYSTEM_VERSION=10.0
313         WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
314         WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
315         DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
316         _DEFINES_CFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
317         _DEFINES_CXXFLAGS="-FI $_objdir/mozilla-config.h -DMOZILLA_CLIENT"
318         CFLAGS="$CFLAGS -Gy -Zc:inline"
319         CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
320         if test "$TARGET_CPU" = "x86"; then
321             dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
322             dnl more recent, so set that explicitly here unless another
323             dnl target arch has already been set.
324             changequote(,)
325             if test -z `echo $CFLAGS | grep -i [-/]arch:`; then
326               CFLAGS="$CFLAGS -arch:SSE2"
327             fi
328             if test -z `echo $CXXFLAGS | grep -i [-/]arch:`; then
329               CXXFLAGS="$CXXFLAGS -arch:SSE2"
330             fi
331             changequote([,])
332         fi
333         dnl VS2013+ supports -Gw for better linker optimizations.
334         dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
335         dnl Disabled on ASan because it causes false-positive ODR violations.
336         if test -z "$MOZ_ASAN"; then
337             CFLAGS="$CFLAGS -Gw"
338             CXXFLAGS="$CXXFLAGS -Gw"
339         else
340             # String tail merging doesn't play nice with ASan's ODR checker.
341             LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
342         fi
343         # Silence VS2017 15.5+ TR1 deprecation warnings hit by older gtest versions
344         CXXFLAGS="$CXXFLAGS -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING"
345         MOZ_DEBUG_LDFLAGS='-DEBUG'
346         if test "$HOST_OS_ARCH" != "WINNT"; then
347           # %_PDB% is a special signal to emit only the PDB basename. This
348           # avoids problems in Windows tools that don't like forward-slashes.
349           MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
350         fi
351         MOZ_OPTIMIZE_FLAGS='-O2'
352         MOZ_FIX_LINK_PATHS=
353         LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
354     fi
355     AC_DEFINE(WIN32_LEAN_AND_MEAN)
356     dnl See http://support.microsoft.com/kb/143208 to use STL
357     AC_DEFINE(NOMINMAX)
358     BIN_SUFFIX='.exe'
360     case "$host_os" in
361     cygwin*|msvc*|mks*)
362         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.])
363         ;;
364     esac
366     case "$target" in
367     i*86-*)
368         if test -n "$GNU_CC"; then
369             CFLAGS="$CFLAGS -mstackrealign"
370             CXXFLAGS="$CXXFLAGS -mstackrealign"
371             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
372         else
373             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
374             LDFLAGS="$LDFLAGS -SAFESEH"
375         fi
377         AC_DEFINE(_X86_)
378         ;;
379     x86_64-*)
380         if test -n "$_WIN32_MSVC"; then
381             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
382         fi
383         AC_DEFINE(_AMD64_)
384         ;;
385     aarch64-*)
386         if test -n "$_WIN32_MSVC"; then
387             DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
388         fi
389         AC_DEFINE(_ARM64_)
390         ;;
391     *)
392         AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
393         ;;
394     esac
395     ;;
397 *-netbsd*)
398     CFLAGS="$CFLAGS -Dunix"
399     CXXFLAGS="$CXXFLAGS -Dunix"
400     if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
401         DSO_PIC_CFLAGS='-fPIC -DPIC'
402         DSO_LDOPTS='-shared'
403         MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
404     else
405         DSO_PIC_CFLAGS='-fPIC -DPIC'
406         DSO_LDOPTS='-shared'
407     fi
408     # This will fail on a.out systems prior to 1.5.1_ALPHA.
409     if test "$LIBRUNPATH"; then
410         DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
411     fi
412     ;;
414 *-openbsd*)
415     if test -z "$X11BASE"; then
416         X11BASE=/usr/X11R6
417     fi
418     MOZ_FIX_LINK_PATHS="$MOZ_FIX_LINK_PATHS -Wl,-rpath-link,${X11BASE}/lib"
419     DSO_PIC_CFLAGS='-fPIC'
420     DSO_LDOPTS='-shared -fPIC'
421     if test "$LIBRUNPATH"; then
422         DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
423     fi
424     ;;
426 *-solaris*)
427     MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
428     ;;
430 esac
432 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
433 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
435 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
436     MOZ_OPTIMIZE_FLAGS="-O"
440 if test -z "$COMPILE_ENVIRONMENT"; then
441     SKIP_COMPILER_CHECKS=1
442     SKIP_LIBRARY_CHECKS=1
443 else
444     MOZ_COMPILER_OPTS
445 fi # COMPILE_ENVIRONMENT
447 if test -z "$SKIP_COMPILER_CHECKS"; then
449 dnl ========================================================
450 dnl Put your C++ language/feature checks below
451 dnl ========================================================
452 AC_LANG_CPLUSPLUS
454 ARM_ABI_PREFIX=
455 if test "$GNU_CC"; then
456   if test "$TARGET_CPU" = "arm" ; then
457     AC_CACHE_CHECK(for ARM EABI,
458         ac_cv_gcc_arm_eabi,
459         [AC_TRY_COMPILE([],
460                         [
461 #if defined(__ARM_EABI__)
462   return 0;
463 #else
464 #error Not ARM EABI.
465 #endif
466                         ],
467                         ac_cv_gcc_arm_eabi="yes",
468                         ac_cv_gcc_arm_eabi="no")])
469     if test "$ac_cv_gcc_arm_eabi" = "yes"; then
470         HAVE_ARM_EABI=1
471         ARM_ABI_PREFIX=eabi-
472     else
473         ARM_ABI_PREFIX=oabi-
474     fi
475   fi
477   TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
480 if test -n "$MOZ_LINKER"; then
481 dnl gold emits wrong sysv-style elf hash tables when building both sysv and
482 dnl style tables. https://sourceware.org/bugzilla/show_bug.cgi?id=13597
483 dnl Since the linker only understands the sysv ones, no need to build the
484 dnl gnu style tables anyways.
485   LDFLAGS="$LDFLAGS -Wl,--hash-style=sysv"
488 dnl End of C++ language/feature checks
489 AC_LANG_C
491 fi # ! SKIP_COMPILER_CHECKS
493 TARGET_XPCOM_ABI=
494 if test -n "${TARGET_CPU}" -a -n "${TARGET_COMPILER_ABI}"; then
495     TARGET_XPCOM_ABI="${TARGET_CPU}-${TARGET_COMPILER_ABI}"
496     AC_DEFINE_UNQUOTED(TARGET_XPCOM_ABI, ["${TARGET_XPCOM_ABI}"])
499 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
500 dnl features that Windows actually does support.
502 if test -n "$SKIP_COMPILER_CHECKS"; then
503    AC_DEFINE(HAVE_FORCEINLINE)
504 fi # SKIP_COMPILER_CHECKS
506 dnl Mozilla specific options
507 dnl ========================================================
508 dnl The macros used for command line options
509 dnl are defined in build/autoconf/altoptions.m4.
511 dnl ========================================================
512 dnl =
513 dnl = Application
514 dnl =
515 dnl ========================================================
517 MOZ_BRANDING_DIRECTORY=
518 MOZ_OFFICIAL_BRANDING=
519 MOZ_NO_SMART_CARDS=
520 MOZ_BINARY_EXTENSIONS=
521 MOZ_DEVTOOLS=server
523 dnl ========================================================
524 dnl = Trademarked Branding
525 dnl ========================================================
526 MOZ_ARG_ENABLE_BOOL(official-branding,
527 [  --enable-official-branding
528                           Enable Official mozilla.org Branding
529                           Do not distribute builds with
530                           --enable-official-branding unless you have
531                           permission to use trademarks per
532                           http://www.mozilla.org/foundation/trademarks/ .],
533     MOZ_OFFICIAL_BRANDING=1,
534     MOZ_OFFICIAL_BRANDING=)
536 # Allow the application to influence configure with a confvars.sh script.
537 AC_MSG_CHECKING([if app-specific confvars.sh exists])
538 if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
539   AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
540   . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
541 else
542   AC_MSG_RESULT([no])
545 AC_SUBST(MOZ_OFFICIAL_BRANDING)
546 if test -n "$MOZ_OFFICIAL_BRANDING"; then
547   if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
548     AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
549   else
550     MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
551     AC_DEFINE(MOZ_OFFICIAL_BRANDING)
552   fi
555 MOZ_ARG_WITH_STRING(branding,
556 [  --with-branding=dir     Use branding from the specified directory.],
557     MOZ_BRANDING_DIRECTORY=$withval)
559 REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
560 if test -z "$REAL_BRANDING_DIRECTORY"; then
561   REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
564 if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
565   . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
568 AC_SUBST(MOZ_BRANDING_DIRECTORY)
570 dnl ========================================================
571 dnl = Distribution ID
572 dnl ========================================================
573 MOZ_ARG_WITH_STRING(distribution-id,
574 [  --with-distribution-id=ID
575                           Set distribution-specific id (default=org.mozilla)],
576 [ val=`echo $withval`
577     MOZ_DISTRIBUTION_ID="$val"])
579 if test -z "$MOZ_DISTRIBUTION_ID"; then
580    MOZ_DISTRIBUTION_ID="org.mozilla"
583 AC_SUBST(MOZ_DISTRIBUTION_ID)
585 dnl ========================================================
586 dnl = Enable code optimization. ON by default.
587 dnl ========================================================
589 # Use value from moz.configure if one is defined. Else use our computed
590 # value.
591 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
592     MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
595 if test "$COMPILE_ENVIRONMENT"; then
596 if test -n "$MOZ_OPTIMIZE"; then
597     AC_MSG_CHECKING([for valid C compiler optimization flags])
598     _SAVE_CFLAGS=$CFLAGS
599     CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
600     AC_TRY_COMPILE([#include <stdio.h>],
601         [printf("Hello World\n");],
602         _results=yes,
603         _results=no)
604     AC_MSG_RESULT([$_results])
605     if test "$_results" = "no"; then
606         AC_MSG_ERROR([These compiler flags for C are invalid: $MOZ_OPTIMIZE_FLAGS])
607     fi
608     CFLAGS=$_SAVE_CFLAGS
609     if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
610         # When using llvm-based LTO, non numeric optimization levels are
611         # not supported by the linker, so force the linker to use -O2 (
612         # which doesn't influence the level compilation units are actually
613         # compiled at).
614         case " $MOZ_OPTIMIZE_FLAGS " in
615         *\ -Os\ *|*\ -Oz\ *)
616             MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
617             ;;
618         esac
619     fi
621 fi # COMPILE_ENVIRONMENT
623 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
624 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
625 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
627 case "${OS_TARGET}" in
628 Android|WINNT|Darwin)
629   MOZ_GLUE_IN_PROGRAM=
630   ;;
632   dnl On !Android !Windows !OSX, we only want to link executables against mozglue
633   MOZ_GLUE_IN_PROGRAM=1
634   AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
635   ;;
636 esac
637 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
639 dnl ========================================================
640 dnl = Enable using the clang plugin to build
641 dnl ========================================================
643 if test -n "$COMPILE_ENVIRONMENT"; then
644 MOZ_CONFIG_CLANG_PLUGIN
645 fi # COMPILE_ENVIRONMENT
647 AC_LANG_C
649 dnl ========================================================
650 dnl =
651 dnl = Maintainer debug option (no --enable equivalent)
652 dnl =
653 dnl ========================================================
655 AC_SUBST_LIST(ASFLAGS)
656 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
658 AC_SUBST(MOZ_STUB_INSTALLER)
660 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
662 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
664 if test -n "$MOZ_BINARY_EXTENSIONS"; then
665   AC_DEFINE(MOZ_BINARY_EXTENSIONS)
668 dnl ========================================================
669 dnl = Mac bundle name prefix
670 dnl ========================================================
671 MOZ_ARG_WITH_STRING(macbundlename-prefix,
672 [  --with-macbundlename-prefix=prefix
673                           Prefix for MOZ_MACBUNDLE_NAME],
674 [ MOZ_MACBUNDLE_NAME_PREFIX="$withval"])
676 MOZ_MACBUNDLE_NAME=$MOZ_APP_DISPLAYNAME
677 if test "$MOZ_MACBUNDLE_NAME_PREFIX"; then
678   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME_PREFIX}${MOZ_MACBUNDLE_NAME}"
681 if test "$MOZ_DEBUG"; then
682   MOZ_MACBUNDLE_NAME="${MOZ_MACBUNDLE_NAME}Debug.app"
683 else
684   MOZ_MACBUNDLE_NAME=${MOZ_MACBUNDLE_NAME}.app
686 AC_SUBST(MOZ_MACBUNDLE_NAME)
688 dnl Mac bundle identifier (based on MOZ_APP_DISPLAYNAME)
689 # If the MOZ_MACBUNDLE_ID is defined in the configure.sh, use it
690 # Otherwise, use MOZ_APP_DISPLAYNAME
691 if test -z "$MOZ_MACBUNDLE_ID"; then
692    MOZ_MACBUNDLE_ID=`echo $MOZ_APP_DISPLAYNAME | tr 'A-Z' 'a-z' | tr -dc 'a-z-'`
694 MOZ_MACBUNDLE_ID=${MOZ_DISTRIBUTION_ID}.${MOZ_MACBUNDLE_ID}
695 if test "$MOZ_DEBUG"; then
696   MOZ_MACBUNDLE_ID=${MOZ_MACBUNDLE_ID}debug
699 AC_DEFINE_UNQUOTED(MOZ_MACBUNDLE_ID,$MOZ_MACBUNDLE_ID)
700 AC_SUBST(MOZ_MACBUNDLE_ID)
702 dnl ========================================================
703 dnl = Child Process Name for IPC
704 dnl ========================================================
705 if test "$MOZ_WIDGET_TOOLKIT" != "android"; then
706   MOZ_CHILD_PROCESS_NAME="plugin-container${BIN_SUFFIX}"
707 else
708   # We want to let Android unpack the file at install time, but it only does
709   # so if the file is named libsomething.so. The lib/ path is also required
710   # because the unpacked file will be under the lib/ subdirectory and will
711   # need to be executed from that path.
712   MOZ_CHILD_PROCESS_NAME="libplugin-container.so"
714 MOZ_CHILD_PROCESS_BUNDLE="plugin-container.app/Contents/MacOS/"
715 MOZ_CHILD_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.plugincontainer
716 MOZ_CHILD_PROCESS_BUNDLENAME="plugin-container.app"
717 MOZ_CHILD_PROCESS_APPNAME="${MOZ_APP_DISPLAYNAME}CP"
719 AC_SUBST(MOZ_CHILD_PROCESS_NAME)
720 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLE)
721 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLEID)
722 AC_SUBST(MOZ_CHILD_PROCESS_APPNAME)
723 AC_SUBST(MOZ_CHILD_PROCESS_BUNDLENAME)
725 dnl ==========================================================
726 dnl = Mac Media Plugin Helper (GMP Child) Process Name for IPC
727 dnl ==========================================================
728 MOZ_EME_PROCESS_NAME="media-plugin-helper"
729 MOZ_EME_PROCESS_NAME_BRANDED="$MOZ_APP_DISPLAYNAME Media Plugin Helper"
730 MOZ_EME_PROCESS_BUNDLENAME="${MOZ_EME_PROCESS_NAME}.app"
731 # Generate a lower case string with no spaces to be used as the bundle ID
732 # for the EME helper .app of the form org.mozilla.<executable-name>.
733 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_APP_DISPLAYNAME" | tr ' ' '-'`
734 MOZ_EME_PROCESS_BUNDLEID=`echo "$MOZ_EME_PROCESS_BUNDLEID" | tr 'A-Z' 'a-z'`
735 MOZ_EME_PROCESS_BUNDLEID=${MOZ_EME_PROCESS_BUNDLEID}-${MOZ_EME_PROCESS_NAME}
736 MOZ_EME_PROCESS_BUNDLEID=${MOZ_DISTRIBUTION_ID}.${MOZ_EME_PROCESS_BUNDLEID}
738 AC_SUBST(MOZ_EME_PROCESS_NAME)
739 AC_SUBST(MOZ_EME_PROCESS_NAME_BRANDED)
740 AC_SUBST(MOZ_EME_PROCESS_BUNDLENAME)
741 AC_SUBST(MOZ_EME_PROCESS_BUNDLEID)
743 # The following variables are available to branding and application
744 # configuration ($BRANDING/configure.sh and $APPLICATION/confvars.sh):
745 # - MOZ_APP_VENDOR: Used for application.ini's "Vendor" field, which also
746 # impacts profile location and user-visible fields.
747 # - MOZ_APP_DISPLAYNAME: Used in user-visible fields (DLL properties,
748 # Mac Bundle name, Updater, Installer), it is typically used for nightly
749 # builds (e.g. Aurora for Firefox).
750 # - MOZ_APP_PROFILE: When set, used for application.ini's
751 # "Profile" field, which controls profile location.
752 # - MOZ_APP_ID: When set, used for application.ini's "ID" field, and
753 # crash reporter server url.
754 # - MOZ_PROFILE_MIGRATOR: When set, enables profile migrator.
756 # The following environment variables used to have an effect, but don't anymore:
757 # - MOZ_APP_VERSION: Defines the application version number. This was replaced with
758 # the contents from the version.txt file in the application directory, or
759 # browser/config/version.txt if there isn't one.
760 # - MOZ_APP_VERSION_DISPLAY: Defines the application version number. Used
761 # in the "About" window. This was replaced with the contents from the
762 # version_display.txt or version.txt in the application directory, or
763 # browser/config/version_display.txt.
765 # For extensions and langpacks, we require a max version that is compatible
766 # across security releases. MOZ_APP_MAXVERSION is our method for doing that.
767 # 24.0a1 and 24.0a2 aren't affected
768 # 24.0 becomes 24.*
769 # 24.1.1 becomes 24.*
770 IS_ALPHA=`echo $MOZ_APP_VERSION | grep a`
771 if test -z "$IS_ALPHA"; then
772   changequote(,)
773   if test "$(basename $MOZ_BUILD_APP)" = "suite"; then
774     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\.[0-9]*\).*|\1|"`.*
775   else
776     MOZ_APP_MAXVERSION=`echo $MOZ_APP_VERSION | sed "s|\(^[0-9]*\).*|\1|"`.*
777   fi
778   changequote([,])
779 else
780   MOZ_APP_MAXVERSION=$MOZ_APP_VERSION
783 AC_SUBST(MOZ_APP_DISPLAYNAME)
784 AC_SUBST(MOZ_APP_VENDOR)
785 AC_SUBST(MOZ_APP_PROFILE)
786 AC_SUBST(MOZ_APP_ID)
787 AC_SUBST(MAR_CHANNEL_ID)
788 AC_SUBST(ACCEPTED_MAR_CHANNEL_IDS)
789 AC_SUBST(MOZ_PROFILE_MIGRATOR)
790 AC_DEFINE_UNQUOTED(MOZ_APP_UA_NAME, "$MOZ_APP_UA_NAME")
791 AC_SUBST(MOZ_APP_UA_NAME)
792 AC_DEFINE_UNQUOTED(MOZ_APP_UA_VERSION, "$MOZ_APP_VERSION")
793 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL, $BROWSER_CHROME_URL)
794 AC_DEFINE_UNQUOTED(BROWSER_CHROME_URL_QUOTED, "$BROWSER_CHROME_URL")
796 AC_SUBST(MOZ_APP_MAXVERSION)
797 AC_SUBST(MOZ_PKG_SPECIAL)
798 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
800 if test "$MOZILLA_OFFICIAL"; then
801     # Build revisions should always be present in official builds
802     MOZ_INCLUDE_SOURCE_INFO=1
805 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
806 # explicitly set the repository and changeset information in.
807 AC_SUBST(MOZ_SOURCE_REPO)
808 AC_SUBST(MOZ_SOURCE_CHANGESET)
809 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
811 dnl Echo the CFLAGS to remove extra whitespace.
812 CFLAGS=`echo \
813     $_COMPILATION_CFLAGS \
814     $CFLAGS`
816 CXXFLAGS=`echo \
817     $_COMPILATION_CXXFLAGS \
818     $CXXFLAGS`
820 ASFLAGS=`echo \
821     $_COMPILATION_ASFLAGS \
822     $ASFLAGS`
824 COMPILE_CFLAGS=`echo \
825     $_DEFINES_CFLAGS \
826     $COMPILE_CFLAGS`
828 COMPILE_CXXFLAGS=`echo \
829     $_DEFINES_CXXFLAGS \
830     $COMPILE_CXXFLAGS`
832 HOST_CFLAGS=`echo \
833     $_COMPILATION_HOST_CFLAGS \
834     $HOST_CFLAGS`
836 HOST_CXXFLAGS=`echo \
837     $_COMPILATION_HOST_CXXFLAGS \
838     $HOST_CXXFLAGS`
840 LDFLAGS=`echo \
841     $LDFLAGS \
842     $_COMPILATION_LDFLAGS`
844 HOST_LDFLAGS=`echo \
845     $HOST_LDFLAGS \
846     $_COMPILATION_HOST_LDFLAGS`
848 HOST_CMFLAGS="-x objective-c -fobjc-exceptions"
849 HOST_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
850 OS_COMPILE_CMFLAGS="-x objective-c -fobjc-exceptions"
851 OS_COMPILE_CMMFLAGS="-x objective-c++ -fobjc-exceptions"
852 if test "$MOZ_WIDGET_TOOLKIT" = uikit; then
853   OS_COMPILE_CMFLAGS="$OS_COMPILE_CMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
854   OS_COMPILE_CMMFLAGS="$OS_COMPILE_CMMFLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch"
856 AC_SUBST(HOST_CMFLAGS)
857 AC_SUBST(HOST_CMMFLAGS)
858 AC_SUBST(OS_COMPILE_CMFLAGS)
859 AC_SUBST(OS_COMPILE_CMMFLAGS)
861 OS_CFLAGS="$CFLAGS"
862 OS_CXXFLAGS="$CXXFLAGS"
863 OS_CPPFLAGS="$CPPFLAGS"
864 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
865 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
866 OS_LDFLAGS="$LDFLAGS"
867 OS_LIBS="$LIBS"
868 AC_SUBST_LIST(OS_CFLAGS)
869 AC_SUBST_LIST(OS_CXXFLAGS)
870 AC_SUBST_LIST(OS_CPPFLAGS)
871 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
872 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
873 AC_SUBST_LIST(OS_LDFLAGS)
874 AC_SUBST(OS_LIBS)
876 AC_SUBST(HOST_CC)
877 AC_SUBST(HOST_CXX)
878 AC_SUBST_LIST(HOST_CFLAGS)
879 AC_SUBST_LIST(HOST_CPPFLAGS)
880 AC_SUBST_LIST(HOST_CXXFLAGS)
881 AC_SUBST(HOST_LDFLAGS)
882 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
883 AC_SUBST(HOST_BIN_SUFFIX)
885 AC_SUBST(TARGET_XPCOM_ABI)
887 AC_SUBST(DSO_LDOPTS)
888 AC_SUBST(BIN_SUFFIX)
889 AC_SUBST(USE_N32)
890 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
891 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
893 AC_SUBST(MOZ_DEVTOOLS)
895 AC_SUBST(MOZ_PACKAGE_JSSHELL)
897 AC_SUBST(DMG_TOOL)
899 dnl Host JavaScript runtime, if any, to use during cross compiles.
900 AC_SUBST(JS_BINARY)
902 AC_SUBST(NSS_EXTRA_SYMBOLS_FILE)
904 dnl Set various defines and substitutions
905 dnl ========================================================
907 AC_SUBST(MOZ_DEV_EDITION)
908 if test -n "$MOZ_DEV_EDITION"; then
909     AC_DEFINE(MOZ_DEV_EDITION)
912 dnl Spit out some output
913 dnl ========================================================
915 # Avoid using obsolete NSPR features
916 AC_DEFINE(NO_NSPR_10_SUPPORT)
918 MOZ_CREATE_CONFIG_STATUS()
920 rm -fr confdefs* $ac_clean_files