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(js/src/jsapi.h)
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 Set various checks
34 dnl ========================================================
37 dnl Initialize the Pthread test variables early so they can be
38 dnl overridden by each platform.
39 dnl ========================================================
43 LDFLAGS="$LDFLAGS $LINKER_LDFLAGS $PACK_REL_RELOC_FLAGS"
44 HOST_LDFLAGS="$HOST_LDFLAGS $HOST_LINKER_LDFLAGS"
46 if test -z "$JS_STANDALONE"; then
47 autoconfmk=autoconf-js.mk
51 jsconfdefs=$_objdir/js/src/js-confdefs.h
55 dnl ========================================================
56 dnl Checks for compilers.
57 dnl ========================================================
59 if test "$COMPILE_ENVIRONMENT"; then
61 # Run some logic to figure out exe extensions (mostly for mingw's sake)
65 # In Mozilla, we use the names $target, $host and $build incorrectly, but are
66 # too far gone to back out now. See Bug 475488:
67 # - When we say $target, we mean $host, that is, the system on which
68 # Mozilla will be run.
69 # - When we say $host, we mean $build, that is, the system on which Mozilla
71 # - $target (in its correct usage) is for compilers who generate code for a
72 # different platform than $host, so it would not be used by Mozilla.
73 if test "$target" != "$host"; then
82 dnl Special win32 checks
83 dnl ========================================================
89 if test "$GCC" != "yes"; then
90 # Check to see if we are really running in a msvc environemnt
93 # Make sure compilers are valid
94 CXXFLAGS="$CXXFLAGS -TP"
95 # _CRT_SECURE_NO_WARNINGS disables warnings about using MSVC-specific
96 # secure CRT functions.
97 CXXFLAGS="$CXXFLAGS -D_CRT_SECURE_NO_WARNINGS"
100 AC_TRY_COMPILE([#include <stdio.h>],
101 [ printf("Hello World\n"); ],,
102 AC_MSG_ERROR([\$(CC) test failed. You must have MS VC++ in your path to build.]) )
105 AC_TRY_COMPILE([#include <new.h>],
106 [ unsigned *test = new unsigned(42); ],,
107 AC_MSG_ERROR([\$(CXX) test failed. You must have MS VC++ in your path to build.]) )
110 AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
111 AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
113 MSVC_C_RUNTIME_DLL=vcruntime140.dll
114 if test -n "$IS_VS2019_OR_MORE" -a "$CPU_ARCH" != "x86"; then
115 MSVC_C_RUNTIME_1_DLL=vcruntime140_1.dll
117 MSVC_CXX_RUNTIME_DLL=msvcp140.dll
119 # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
120 CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
122 AC_SUBST(MSVC_C_RUNTIME_DLL)
123 AC_SUBST(MSVC_C_RUNTIME_1_DLL)
124 AC_SUBST(MSVC_CXX_RUNTIME_DLL)
126 CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
127 CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
129 # Check w32api version
130 _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
131 _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
132 AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
133 AC_TRY_COMPILE([#include <w32api.h>],
134 #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
135 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
136 __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
137 #error "test failed."
139 , [ res=yes ], [ res=no ])
140 AC_MSG_RESULT([$res])
141 if test "$res" != "yes"; then
142 AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
146 AC_DEFINE(_USE_MATH_DEFINES) # Otherwise Windows' math.h doesn't #define M_PI.
148 AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
149 AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
150 AC_DEFINE_UNQUOTED(_WIN32_IE,0x0A00)
155 if test -n "$_WIN32_MSVC"; then
157 SKIP_COMPILER_CHECKS=1
158 SKIP_LIBRARY_CHECKS=1
161 fi # COMPILE_ENVIRONMENT
166 dnl ========================================================
167 dnl set the defaults first
168 dnl ========================================================
169 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
171 dnl Configure platform-specific CPU architecture compiler options.
172 dnl ==============================================================
177 dnl ========================================================
178 dnl GNU specific defaults
179 dnl ========================================================
180 if test "$GNU_CC"; then
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"
192 if test "$OS_ARCH" != "WINNT"; then
193 DSO_PIC_CFLAGS='-fPIC'
194 ASFLAGS="$ASFLAGS -fPIC"
197 AC_MSG_CHECKING([for --noexecstack option to as])
199 CFLAGS="$CFLAGS -Wa,--noexecstack"
200 AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
201 [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
204 AC_MSG_CHECKING([for -z noexecstack option to ld])
205 _SAVE_LDFLAGS=$LDFLAGS
206 LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
207 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
209 LDFLAGS=$_SAVE_LDFLAGS)
211 AC_MSG_CHECKING([for -z text option to ld])
212 _SAVE_LDFLAGS=$LDFLAGS
213 LDFLAGS="$LDFLAGS -Wl,-z,text"
214 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
216 LDFLAGS=$_SAVE_LDFLAGS)
218 AC_MSG_CHECKING([for -z relro option to ld])
219 _SAVE_LDFLAGS=$LDFLAGS
220 LDFLAGS="$LDFLAGS -Wl,-z,relro"
221 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
223 LDFLAGS=$_SAVE_LDFLAGS)
225 AC_MSG_CHECKING([for -z nocopyreloc option to ld])
226 _SAVE_LDFLAGS=$LDFLAGS
227 LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
228 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
230 LDFLAGS=$_SAVE_LDFLAGS)
232 AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
233 _SAVE_LDFLAGS=$LDFLAGS
234 LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
235 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
237 LDFLAGS=$_SAVE_LDFLAGS)
239 # While sha1 is deterministic, it is slower.
240 if test -z "$DEVELOPER_OPTIONS"; then
245 AC_MSG_CHECKING([for --build-id=$build_id option to ld])
246 _SAVE_LDFLAGS=$LDFLAGS
247 LDFLAGS="$LDFLAGS -Wl,--build-id=$build_id"
248 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
250 LDFLAGS=$_SAVE_LDFLAGS)
252 _DEFINES_CFLAGS="-include $jsconfdefs -DMOZILLA_CLIENT"
255 if test "$GNU_CXX"; then
256 _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $jsconfdefs"
259 dnl ========================================================
260 dnl System overrides of the defaults for host
261 dnl ========================================================
264 if test -n "$_WIN32_MSVC"; then
265 HOST_CFLAGS="$HOST_CFLAGS"
267 HOST_CFLAGS="$HOST_CFLAGS -mwindows"
269 HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
270 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
273 case "${host_cpu}" in
275 if test -n "$_WIN32_MSVC"; then
276 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
280 if test -n "$_WIN32_MSVC"; then
281 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
283 HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
289 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
290 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
293 *-linux*|*-kfreebsd*-gnu|*-gnu*)
294 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
295 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
299 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
300 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
304 dnl ========================================================
305 dnl System overrides of the defaults for target
306 dnl ========================================================
310 MOZ_OPTIMIZE_FLAGS="-O3"
313 dnl DTrace and -dead_strip don't interact well. See bug 403132.
314 dnl ===================================================================
315 if test "x$enable_dtrace" = "xyes"; then
316 echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
318 dnl check for the presence of the -dead_strip linker flag
319 AC_MSG_CHECKING([for -dead_strip option to ld])
320 _SAVE_LDFLAGS=$LDFLAGS
321 LDFLAGS="$LDFLAGS -Wl,-dead_strip"
322 AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
323 if test -n "$_HAVE_DEAD_STRIP" ; then
325 MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
330 LDFLAGS=$_SAVE_LDFLAGS
335 *-android*|*-linuxandroid*)
336 MOZ_OPTIMIZE_FLAGS="-O3"
337 if test -z "$CLANG_CC"; then
338 MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions $MOZ_OPTIMIZE_FLAGS"
343 if test "$GNU_CC" -o "$GNU_CXX"; then
344 MOZ_PGO_OPTIMIZE_FLAGS="-O3"
345 MOZ_OPTIMIZE_FLAGS="-O3"
346 if test -z "$CLANG_CC"; then
347 MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
351 case "${target_cpu}" in
353 CFLAGS="$CFLAGS -mieee"
354 CXXFLAGS="$CXXFLAGS -mieee"
361 if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
362 # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
363 if test -z "$CLANG_CC"; then
364 AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
370 # Silence problematic clang warnings
371 CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
372 LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
374 MOZ_OPTIMIZE_FLAGS="-O2"
376 WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
377 WIN32_GUI_EXE_LDFLAGS=-mwindows
379 TARGET_COMPILER_ABI=msvc
380 WIN32_SUBSYSTEM_VERSION=10.0
381 WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
382 WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
383 DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
384 _DEFINES_CFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
385 _DEFINES_CXXFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
386 CFLAGS="$CFLAGS -Gy -Zc:inline"
387 CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
388 if test "$CPU_ARCH" = "x86";then
389 dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
390 dnl more recent, so set that explicitly here unless another
391 dnl target arch has already been set.
393 if test -z `echo $CFLAGS | grep -i [-/]arch:` ; then
394 CFLAGS="$CFLAGS -arch:SSE2"
396 if test -z `echo $CXXFLAGS | grep -i [-/]arch:` ; then
397 CXXFLAGS="$CXXFLAGS -arch:SSE2"
401 dnl VS2013+ supports -Gw for better linker optimizations.
402 dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
403 dnl Disabled on ASan because it causes false-positive ODR violations.
404 if test -z "$MOZ_ASAN"; then
406 CXXFLAGS="$CXXFLAGS -Gw"
408 # String tail merging doesn't play nice with ASan's ODR checker.
409 LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
411 MOZ_DEBUG_LDFLAGS='-DEBUG'
412 if test "$HOST_OS_ARCH" != "WINNT"; then
413 # %_PDB% is a special signal to emit only the PDB basename. This
414 # avoids problems in Windows tools that don't like forward-slashes.
415 MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
417 MOZ_OPTIMIZE_FLAGS="-O2"
419 LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
421 AC_DEFINE(HAVE__MSIZE)
422 AC_DEFINE(WIN32_LEAN_AND_MEAN)
423 dnl See http://support.microsoft.com/kb/143208 to use STL
429 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.])
435 if test -n "$GNU_CC"; then
436 CFLAGS="$CFLAGS -mstackrealign"
437 CXXFLAGS="$CXXFLAGS -mstackrealign"
438 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
440 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
441 LDFLAGS="$LDFLAGS -SAFESEH"
447 if test -n "$_WIN32_MSVC"; then
448 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
453 if test -n "$_WIN32_MSVC"; then
454 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
459 AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
465 CFLAGS="$CFLAGS -Dunix"
466 CXXFLAGS="$CXXFLAGS -Dunix"
467 if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
468 DSO_PIC_CFLAGS='-fPIC -DPIC'
470 MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
472 DSO_PIC_CFLAGS='-fPIC -DPIC'
475 # This will fail on a.out systems prior to 1.5.1_ALPHA.
476 if test "$LIBRUNPATH"; then
477 DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
482 DSO_PIC_CFLAGS='-fPIC'
483 DSO_LDOPTS='-shared -fPIC'
484 if test "$LIBRUNPATH"; then
485 DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
490 MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
494 CXXFLAGS="$CXXFLAGS -mthread-model single"
500 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
501 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
503 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
504 MOZ_OPTIMIZE_FLAGS="-O"
507 if test -z "$COMPILE_ENVIRONMENT"; then
508 SKIP_COMPILER_CHECKS=1
509 SKIP_LIBRARY_CHECKS=1
512 if test -n "$COMPILE_ENVIRONMENT"; then
516 if test -z "$SKIP_COMPILER_CHECKS"; then
517 dnl Checks for typedefs, structures, and compiler characteristics.
518 dnl ========================================================
526 AC_MSG_CHECKING(for ssize_t)
527 AC_CACHE_VAL(ac_cv_type_ssize_t,
528 [AC_TRY_COMPILE([#include <stdio.h>
529 #include <sys/types.h>],
531 [ac_cv_type_ssize_t=true],
532 [ac_cv_type_ssize_t=false])])
533 if test "$ac_cv_type_ssize_t" = true ; then
534 AC_DEFINE(HAVE_SSIZE_T)
544 dnl Checks for header files.
545 dnl ========================================================
548 dnl Checks for libraries.
549 dnl ========================================================
550 AC_CHECK_LIB(c_r, gethostbyname_r)
552 dnl We don't want to link with libdl even if it's present on OS X, since
553 dnl it's not used and not part of the default installation. OS/2 has dlfcn
555 dnl We don't want to link against libm or libpthread on Darwin since
556 dnl they both are just symlinks to libSystem and explicitly linking
557 dnl against libSystem causes issues when debugging (see bug 299601).
562 AC_SEARCH_LIBS(dlopen, dl,
563 MOZ_CHECK_HEADER(dlfcn.h,
564 AC_DEFINE(HAVE_DLOPEN)))
568 _SAVE_CFLAGS="$CFLAGS"
569 CFLAGS="$CFLAGS -D_GNU_SOURCE"
570 AC_CHECK_FUNCS(dladdr)
571 CFLAGS="$_SAVE_CFLAGS"
573 if test ! "$GNU_CXX"; then
574 AC_CHECK_LIB(C, demangle)
577 AC_CHECK_LIB(socket, socket)
579 dnl ========================================================
580 dnl = pthread support
581 dnl = Start by checking whether the system support pthreads
582 dnl ========================================================
588 AC_CHECK_LIB(pthreads, pthread_create,
589 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
590 AC_CHECK_LIB(pthread, pthread_create,
591 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
592 AC_CHECK_LIB(c_r, pthread_create,
593 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
594 AC_CHECK_LIB(c, pthread_create,
603 dnl ========================================================
604 dnl Do the platform specific pthread hackery
605 dnl ========================================================
606 if test "$USE_PTHREADS"x != x
609 dnl See if -pthread is supported.
612 ac_cv_have_dash_pthread=no
613 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
614 echo 'int main() { return 0; }' | cat > conftest.c
615 ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
616 if test $? -eq 0; then
617 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
618 ac_cv_have_dash_pthread=yes
621 # Freebsd doesn't use -pthread for compiles, it uses them for linking
624 CFLAGS="$CFLAGS -pthread"
625 CXXFLAGS="$CXXFLAGS -pthread"
631 AC_MSG_RESULT($ac_cv_have_dash_pthread)
634 dnl See if -pthreads is supported.
636 ac_cv_have_dash_pthreads=no
637 if test "$ac_cv_have_dash_pthread" = "no"; then
638 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
639 echo 'int main() { return 0; }' | cat > conftest.c
640 ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
641 if test $? -eq 0; then
642 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
643 ac_cv_have_dash_pthreads=yes
644 CFLAGS="$CFLAGS -pthreads"
645 CXXFLAGS="$CXXFLAGS -pthreads"
649 AC_MSG_RESULT($ac_cv_have_dash_pthreads)
654 AC_DEFINE(_REENTRANT)
655 AC_DEFINE(_THREAD_SAFE)
656 dnl -pthread links in -lpthread, so don't specify it explicitly.
657 if test "$ac_cv_have_dash_pthread" = "yes"; then
658 _PTHREAD_LDFLAGS="-pthread"
662 *-*-openbsd*|*-*-bsdi*)
663 AC_DEFINE(_REENTRANT)
664 AC_DEFINE(_THREAD_SAFE)
665 dnl -pthread links in -lc_r, so don't specify it explicitly.
666 if test "$ac_cv_have_dash_pthread" = "yes"; then
667 _PTHREAD_LDFLAGS="-pthread"
671 *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
672 AC_DEFINE(_REENTRANT)
676 LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
680 dnl Checks for library functions.
681 dnl ========================================================
683 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
684 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
685 ac_cv_clock_monotonic,
686 [for libs in "" -lrt; do
689 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
690 dnl we should or not be able to use it. To detect if we can, we need to make the
691 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
692 AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
694 [ struct timespec ts;
695 clock_gettime(CLOCK_MONOTONIC, &ts); ],
696 ac_cv_clock_monotonic=$libs
699 ac_cv_clock_monotonic=no)
702 if test "$ac_cv_clock_monotonic" != "no"; then
703 HAVE_CLOCK_MONOTONIC=1
704 REALTIME_LIBS=$ac_cv_clock_monotonic
705 AC_DEFINE(HAVE_CLOCK_MONOTONIC)
706 AC_SUBST(HAVE_CLOCK_MONOTONIC)
707 AC_SUBST_LIST(REALTIME_LIBS)
710 dnl Checks for math functions.
711 dnl ========================================================
716 ac_cv_func_res_ninit,
717 [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
718 dnl no need for res_ninit() on NetBSD and OpenBSD
719 ac_cv_func_res_ninit=no
723 #define _BSD_SOURCE 1
725 #include <sys/types.h>
726 #include <netinet/in.h>
727 #include <arpa/nameser.h>
730 [int foo = res_ninit(&_res);],
731 [ac_cv_func_res_ninit=yes],
732 [ac_cv_func_res_ninit=no])
736 if test "$ac_cv_func_res_ninit" = "yes"; then
737 AC_DEFINE(HAVE_RES_NINIT)
738 dnl must add the link line we do something as foolish as this... dougt
740 dnl AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
741 dnl AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
748 dnl ===================================================================
749 dnl ========================================================
750 dnl Put your C++ language/feature checks below
751 dnl ========================================================
755 if test "$GNU_CC"; then
756 if test "$CPU_ARCH" = "arm" ; then
757 AC_CACHE_CHECK(for ARM EABI,
761 #if defined(__ARM_EABI__)
767 ac_cv_gcc_arm_eabi="yes",
768 ac_cv_gcc_arm_eabi="no")])
769 if test "$ac_cv_gcc_arm_eabi" = "yes"; then
777 TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
780 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
781 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
782 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
784 _SAVE_LDFLAGS=$LDFLAGS
785 LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
786 AC_CACHE_CHECK(for __thread keyword for TLS variables,
787 ac_cv_thread_keyword,
788 [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
789 [return tlsIsMainThread;],
790 ac_cv_thread_keyword=yes,
791 ac_cv_thread_keyword=no)])
792 LDFLAGS=$_SAVE_LDFLAGS
793 if test "$ac_cv_thread_keyword" = yes; then
794 # mips builds fail with TLS variables because of a binutils bug.
800 *-android*|*-linuxandroid*)
804 AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
809 dnl End of C++ language/feature checks
812 fi # ! SKIP_COMPILER_CHECKS
815 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
816 TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
819 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
820 dnl features that Windows actually does support.
822 if test -n "$SKIP_COMPILER_CHECKS"; then
823 dnl Windows has malloc.h
824 AC_DEFINE(MALLOC_H, [<malloc.h>])
825 AC_DEFINE(HAVE_FORCEINLINE)
826 fi # SKIP_COMPILER_CHECKS
828 dnl Mozilla specific options
829 dnl ========================================================
830 dnl The macros used for command line options
831 dnl are defined in build/autoconf/altoptions.m4.
833 dnl ========================================================
834 dnl = Enable code optimization. ON by default.
835 dnl ========================================================
837 # Use value from moz.configure if one is defined. Else use our computed
839 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
840 MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
843 if test "$COMPILE_ENVIRONMENT"; then
844 if test -n "$MOZ_OPTIMIZE"; then
845 AC_MSG_CHECKING([for valid optimization flags])
847 CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
848 AC_TRY_COMPILE([#include <stdio.h>],
849 [printf("Hello World\n");],
852 AC_MSG_RESULT([$_results])
853 if test "$_results" = "no"; then
854 AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
857 if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
858 # When using llvm-based LTO, non numeric optimization levels are
859 # not supported by the linker, so force the linker to use -O2 (
860 # which doesn't influence the level compilation units are actually
862 case " $MOZ_OPTIMIZE_FLAGS " in
864 MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
869 fi # COMPILE_ENVIRONMENT
871 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
872 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
873 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
875 dnl ========================================================
876 dnl = Enable jemalloc
877 dnl ========================================================
879 if test "$JS_STANDALONE" -a -z "$MOZ_MEMORY"; then
882 case "${OS_TARGET}" in
883 Android|WINNT|Darwin)
887 dnl On !Android !Windows !OSX, we only want to link executables against mozglue
888 MOZ_GLUE_IN_PROGRAM=1
889 AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
894 if test "$MOZ_MEMORY"; then
895 dnl The generic feature tests that determine how to compute ncpus are long and
896 dnl complicated. Therefore, simply define special cpp variables for the
897 dnl platforms we have special knowledge of.
900 export MOZ_NO_DEBUG_RTL=1
904 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
906 dnl ========================================================
908 dnl ========================================================
909 if test -n "$MOZ_INSTRUMENTS"; then
910 LIBS="$LIBS -framework CoreFoundation"
913 dnl ========================================================
914 dnl = Enable using the clang plugin to build
915 dnl ========================================================
917 if test -n "$COMPILE_ENVIRONMENT"; then
918 MOZ_CONFIG_CLANG_PLUGIN
919 fi # COMPILE_ENVIRONMENT
921 if test -z "$SKIP_COMPILER_CHECKS"; then
923 dnl ========================================================
924 dnl Check for gcc -pipe support
925 dnl ========================================================
926 AC_MSG_CHECKING([for -pipe support])
927 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
928 dnl Any gcc that supports firefox supports -pipe.
929 CFLAGS="$CFLAGS -pipe"
930 CXXFLAGS="$CXXFLAGS -pipe"
936 fi # ! SKIP_COMPILER_CHECKS
940 dnl ========================================================
942 dnl = Maintainer debug option (no --enable equivalent)
944 dnl ========================================================
946 AC_SUBST_LIST(ASFLAGS)
947 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
949 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
951 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
953 AC_SUBST(MOZ_APP_DISPLAYNAME)
955 AC_SUBST(MOZ_PKG_SPECIAL)
957 dnl Echo the CFLAGS to remove extra whitespace.
959 $_COMPILATION_CFLAGS \
963 $_COMPILATION_CXXFLAGS \
966 COMPILE_CFLAGS=`echo \
970 COMPILE_CXXFLAGS=`echo \
975 $_COMPILATION_HOST_CFLAGS \
978 HOST_CXXFLAGS=`echo \
979 $_COMPILATION_HOST_CXXFLAGS \
983 OS_CXXFLAGS="$CXXFLAGS"
984 OS_CPPFLAGS="$CPPFLAGS"
985 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
986 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
987 OS_LDFLAGS="$LDFLAGS"
989 AC_SUBST_LIST(OS_CFLAGS)
990 AC_SUBST_LIST(OS_CXXFLAGS)
991 AC_SUBST_LIST(OS_CPPFLAGS)
992 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
993 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
994 AC_SUBST_LIST(OS_LDFLAGS)
999 AC_SUBST_LIST(HOST_CFLAGS)
1000 AC_SUBST_LIST(HOST_CPPFLAGS)
1001 AC_SUBST_LIST(HOST_CXXFLAGS)
1002 AC_SUBST(HOST_LDFLAGS)
1003 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1004 AC_SUBST(HOST_BIN_SUFFIX)
1006 AC_SUBST(TARGET_XPCOM_ABI)
1008 AC_SUBST(DSO_LDOPTS)
1009 AC_SUBST(BIN_SUFFIX)
1011 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1012 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1014 dnl Set various defines and substitutions
1015 dnl ========================================================
1017 AC_SUBST(MOZ_DEV_EDITION)
1018 if test -n "$MOZ_DEV_EDITION"; then
1019 AC_DEFINE(MOZ_DEV_EDITION)
1022 dnl ========================================================
1023 dnl JavaScript shell
1024 dnl ========================================================
1028 if test -n "$JS_STANDALONE"; then
1029 JS_LIBRARY_NAME="mozjs-$MOZILLA_SYMBOLVERSION"
1031 JS_LIBRARY_NAME="mozjs"
1033 JS_CONFIG_LIBS="$NSPR_LIBS $LIBS"
1034 if test -n "$GNU_CC"; then
1035 JS_CONFIG_MOZ_JS_LIBS='-L${libdir} -l${JS_LIBRARY_NAME}'
1037 JS_CONFIG_MOZ_JS_LIBS='${libdir}/${JS_LIBRARY_NAME}.lib'
1039 AC_SUBST(JS_LIBRARY_NAME)
1040 AC_SUBST(JS_CONFIG_MOZ_JS_LIBS)
1041 AC_SUBST(JS_CONFIG_LIBS)
1043 # Avoid using obsolete NSPR features
1044 AC_DEFINE(NO_NSPR_10_SUPPORT)
1046 dnl Spit out some output
1047 dnl ========================================================
1048 MOZ_CREATE_CONFIG_STATUS()
1050 rm -fr confdefs* $ac_clean_files