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 "$TARGET_CPU" != "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 now option to ld])
226 _SAVE_LDFLAGS=$LDFLAGS
227 LDFLAGS="$LDFLAGS -Wl,-z,now"
228 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
230 LDFLAGS=$_SAVE_LDFLAGS)
232 AC_MSG_CHECKING([for -z nocopyreloc option to ld])
233 _SAVE_LDFLAGS=$LDFLAGS
234 LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
235 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
237 LDFLAGS=$_SAVE_LDFLAGS)
239 AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
240 _SAVE_LDFLAGS=$LDFLAGS
241 LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
242 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
244 LDFLAGS=$_SAVE_LDFLAGS)
246 # While sha1 is deterministic, it is slower.
247 if test -z "$DEVELOPER_OPTIONS"; then
252 AC_MSG_CHECKING([for --build-id=$build_id option to ld])
253 _SAVE_LDFLAGS=$LDFLAGS
254 LDFLAGS="$LDFLAGS -Wl,--build-id=$build_id"
255 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
257 LDFLAGS=$_SAVE_LDFLAGS)
259 _DEFINES_CFLAGS="-include $jsconfdefs -DMOZILLA_CLIENT"
262 if test "$GNU_CXX"; then
263 _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $jsconfdefs"
266 dnl ========================================================
267 dnl System overrides of the defaults for host
268 dnl ========================================================
271 if test -n "$_WIN32_MSVC"; then
272 HOST_CFLAGS="$HOST_CFLAGS"
274 HOST_CFLAGS="$HOST_CFLAGS -mwindows"
276 HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
277 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
280 case "${host_cpu}" in
282 if test -n "$_WIN32_MSVC"; then
283 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
287 if test -n "$_WIN32_MSVC"; then
288 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
290 HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
296 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
297 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
300 *-linux*|*-kfreebsd*-gnu|*-gnu*)
301 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
302 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
306 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
307 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
311 dnl ========================================================
312 dnl System overrides of the defaults for target
313 dnl ========================================================
317 MOZ_OPTIMIZE_FLAGS="-O3"
320 dnl DTrace and -dead_strip don't interact well. See bug 403132.
321 dnl ===================================================================
322 if test "x$enable_dtrace" = "xyes"; then
323 echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
325 dnl check for the presence of the -dead_strip linker flag
326 AC_MSG_CHECKING([for -dead_strip option to ld])
327 _SAVE_LDFLAGS=$LDFLAGS
328 LDFLAGS="$LDFLAGS -Wl,-dead_strip"
329 AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
330 if test -n "$_HAVE_DEAD_STRIP" ; then
332 MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
337 LDFLAGS=$_SAVE_LDFLAGS
342 *-android*|*-linuxandroid*)
343 MOZ_OPTIMIZE_FLAGS="-O3"
344 if test -z "$CLANG_CC"; then
345 MOZ_OPTIMIZE_FLAGS="-fno-reorder-functions $MOZ_OPTIMIZE_FLAGS"
350 if test "$GNU_CC" -o "$GNU_CXX"; then
351 MOZ_PGO_OPTIMIZE_FLAGS="-O3"
352 MOZ_OPTIMIZE_FLAGS="-O3"
355 case "${target_cpu}" in
357 CFLAGS="$CFLAGS -mieee"
358 CXXFLAGS="$CXXFLAGS -mieee"
365 if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
366 # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
367 if test -z "$CLANG_CC"; then
368 AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
374 # Silence problematic clang warnings
375 CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
376 LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
378 MOZ_OPTIMIZE_FLAGS="-O2"
380 WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
381 WIN32_GUI_EXE_LDFLAGS=-mwindows
383 TARGET_COMPILER_ABI=msvc
384 WIN32_SUBSYSTEM_VERSION=10.0
385 WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
386 WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
387 DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
388 _DEFINES_CFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
389 _DEFINES_CXXFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
390 CFLAGS="$CFLAGS -Gy -Zc:inline"
391 CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
392 if test "$TARGET_CPU" = "x86";then
393 dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
394 dnl more recent, so set that explicitly here unless another
395 dnl target arch has already been set.
397 if test -z `echo $CFLAGS | grep -i [-/]arch:` ; then
398 CFLAGS="$CFLAGS -arch:SSE2"
400 if test -z `echo $CXXFLAGS | grep -i [-/]arch:` ; then
401 CXXFLAGS="$CXXFLAGS -arch:SSE2"
405 dnl VS2013+ supports -Gw for better linker optimizations.
406 dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
407 dnl Disabled on ASan because it causes false-positive ODR violations.
408 if test -z "$MOZ_ASAN"; then
410 CXXFLAGS="$CXXFLAGS -Gw"
412 # String tail merging doesn't play nice with ASan's ODR checker.
413 LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
415 MOZ_DEBUG_LDFLAGS='-DEBUG'
416 if test "$HOST_OS_ARCH" != "WINNT"; then
417 # %_PDB% is a special signal to emit only the PDB basename. This
418 # avoids problems in Windows tools that don't like forward-slashes.
419 MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
421 MOZ_OPTIMIZE_FLAGS="-O2"
423 LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
425 AC_DEFINE(HAVE__MSIZE)
426 AC_DEFINE(WIN32_LEAN_AND_MEAN)
427 dnl See http://support.microsoft.com/kb/143208 to use STL
433 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.])
439 if test -n "$GNU_CC"; then
440 CFLAGS="$CFLAGS -mstackrealign"
441 CXXFLAGS="$CXXFLAGS -mstackrealign"
442 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
444 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
445 LDFLAGS="$LDFLAGS -SAFESEH"
451 if test -n "$_WIN32_MSVC"; then
452 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
457 if test -n "$_WIN32_MSVC"; then
458 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
463 AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
469 CFLAGS="$CFLAGS -Dunix"
470 CXXFLAGS="$CXXFLAGS -Dunix"
471 if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
472 DSO_PIC_CFLAGS='-fPIC -DPIC'
474 MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
476 DSO_PIC_CFLAGS='-fPIC -DPIC'
479 # This will fail on a.out systems prior to 1.5.1_ALPHA.
480 if test "$LIBRUNPATH"; then
481 DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
486 DSO_PIC_CFLAGS='-fPIC'
487 DSO_LDOPTS='-shared -fPIC'
488 if test "$LIBRUNPATH"; then
489 DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
494 MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
498 CXXFLAGS="$CXXFLAGS -mthread-model single"
504 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
505 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
507 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
508 MOZ_OPTIMIZE_FLAGS="-O"
511 if test -z "$COMPILE_ENVIRONMENT"; then
512 SKIP_COMPILER_CHECKS=1
513 SKIP_LIBRARY_CHECKS=1
516 if test -n "$COMPILE_ENVIRONMENT"; then
520 if test -z "$SKIP_COMPILER_CHECKS"; then
521 dnl Checks for typedefs, structures, and compiler characteristics.
522 dnl ========================================================
530 AC_MSG_CHECKING(for ssize_t)
531 AC_CACHE_VAL(ac_cv_type_ssize_t,
532 [AC_TRY_COMPILE([#include <stdio.h>
533 #include <sys/types.h>],
535 [ac_cv_type_ssize_t=true],
536 [ac_cv_type_ssize_t=false])])
537 if test "$ac_cv_type_ssize_t" = true ; then
538 AC_DEFINE(HAVE_SSIZE_T)
548 dnl Checks for header files.
549 dnl ========================================================
552 dnl Checks for libraries.
553 dnl ========================================================
554 AC_CHECK_LIB(c_r, gethostbyname_r)
556 dnl We don't want to link with libdl even if it's present on OS X, since
557 dnl it's not used and not part of the default installation. OS/2 has dlfcn
559 dnl We don't want to link against libm or libpthread on Darwin since
560 dnl they both are just symlinks to libSystem and explicitly linking
561 dnl against libSystem causes issues when debugging (see bug 299601).
566 AC_SEARCH_LIBS(dlopen, dl,
567 MOZ_CHECK_HEADER(dlfcn.h,
568 AC_DEFINE(HAVE_DLOPEN)))
572 _SAVE_CFLAGS="$CFLAGS"
573 CFLAGS="$CFLAGS -D_GNU_SOURCE"
574 AC_CHECK_FUNCS(dladdr)
575 CFLAGS="$_SAVE_CFLAGS"
577 if test ! "$GNU_CXX"; then
578 AC_CHECK_LIB(C, demangle)
581 AC_CHECK_LIB(socket, socket)
583 dnl ========================================================
584 dnl = pthread support
585 dnl = Start by checking whether the system support pthreads
586 dnl ========================================================
592 AC_CHECK_LIB(pthreads, pthread_create,
593 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
594 AC_CHECK_LIB(pthread, pthread_create,
595 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
596 AC_CHECK_LIB(c_r, pthread_create,
597 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
598 AC_CHECK_LIB(c, pthread_create,
607 dnl ========================================================
608 dnl Do the platform specific pthread hackery
609 dnl ========================================================
610 if test "$USE_PTHREADS"x != x
613 dnl See if -pthread is supported.
616 ac_cv_have_dash_pthread=no
617 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
618 echo 'int main() { return 0; }' | cat > conftest.c
619 ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
620 if test $? -eq 0; then
621 if test -z "`grep -E -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`grep -E -i '(error|incorrect)' conftest.out`" ; then
622 ac_cv_have_dash_pthread=yes
625 # Freebsd doesn't use -pthread for compiles, it uses them for linking
628 CFLAGS="$CFLAGS -pthread"
629 CXXFLAGS="$CXXFLAGS -pthread"
635 AC_MSG_RESULT($ac_cv_have_dash_pthread)
638 dnl See if -pthreads is supported.
640 ac_cv_have_dash_pthreads=no
641 if test "$ac_cv_have_dash_pthread" = "no"; then
642 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
643 echo 'int main() { return 0; }' | cat > conftest.c
644 ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
645 if test $? -eq 0; then
646 if test -z "`grep -E -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`grep -E -i '(error|incorrect)' conftest.out`" ; then
647 ac_cv_have_dash_pthreads=yes
648 CFLAGS="$CFLAGS -pthreads"
649 CXXFLAGS="$CXXFLAGS -pthreads"
653 AC_MSG_RESULT($ac_cv_have_dash_pthreads)
658 AC_DEFINE(_REENTRANT)
659 AC_DEFINE(_THREAD_SAFE)
660 dnl -pthread links in -lpthread, so don't specify it explicitly.
661 if test "$ac_cv_have_dash_pthread" = "yes"; then
662 _PTHREAD_LDFLAGS="-pthread"
666 *-*-openbsd*|*-*-bsdi*)
667 AC_DEFINE(_REENTRANT)
668 AC_DEFINE(_THREAD_SAFE)
669 dnl -pthread links in -lc_r, so don't specify it explicitly.
670 if test "$ac_cv_have_dash_pthread" = "yes"; then
671 _PTHREAD_LDFLAGS="-pthread"
675 *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
676 AC_DEFINE(_REENTRANT)
680 LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
684 dnl Checks for library functions.
685 dnl ========================================================
687 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
688 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
689 ac_cv_clock_monotonic,
690 [for libs in "" -lrt; do
693 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
694 dnl we should or not be able to use it. To detect if we can, we need to make the
695 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
696 AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
698 [ struct timespec ts;
699 clock_gettime(CLOCK_MONOTONIC, &ts); ],
700 ac_cv_clock_monotonic=$libs
703 ac_cv_clock_monotonic=no)
706 if test "$ac_cv_clock_monotonic" != "no"; then
707 HAVE_CLOCK_MONOTONIC=1
708 REALTIME_LIBS=$ac_cv_clock_monotonic
709 AC_DEFINE(HAVE_CLOCK_MONOTONIC)
710 AC_SUBST(HAVE_CLOCK_MONOTONIC)
711 AC_SUBST_LIST(REALTIME_LIBS)
714 dnl Checks for math functions.
715 dnl ========================================================
720 ac_cv_func_res_ninit,
721 [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
722 dnl no need for res_ninit() on NetBSD and OpenBSD
723 ac_cv_func_res_ninit=no
727 #define _BSD_SOURCE 1
729 #include <sys/types.h>
730 #include <netinet/in.h>
731 #include <arpa/nameser.h>
734 [int foo = res_ninit(&_res);],
735 [ac_cv_func_res_ninit=yes],
736 [ac_cv_func_res_ninit=no])
740 if test "$ac_cv_func_res_ninit" = "yes"; then
741 AC_DEFINE(HAVE_RES_NINIT)
742 dnl must add the link line we do something as foolish as this... dougt
744 dnl AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
745 dnl AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
752 dnl ===================================================================
753 dnl ========================================================
754 dnl Put your C++ language/feature checks below
755 dnl ========================================================
759 if test "$GNU_CC"; then
760 if test "$TARGET_CPU" = "arm" ; then
761 AC_CACHE_CHECK(for ARM EABI,
765 #if defined(__ARM_EABI__)
771 ac_cv_gcc_arm_eabi="yes",
772 ac_cv_gcc_arm_eabi="no")])
773 if test "$ac_cv_gcc_arm_eabi" = "yes"; then
781 TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
784 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
785 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
786 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
788 _SAVE_LDFLAGS=$LDFLAGS
789 LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
790 AC_CACHE_CHECK(for __thread keyword for TLS variables,
791 ac_cv_thread_keyword,
792 [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
793 [return tlsIsMainThread;],
794 ac_cv_thread_keyword=yes,
795 ac_cv_thread_keyword=no)])
796 LDFLAGS=$_SAVE_LDFLAGS
797 if test "$ac_cv_thread_keyword" = yes; then
798 # mips builds fail with TLS variables because of a binutils bug.
804 *-android*|*-linuxandroid*)
808 AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
813 dnl End of C++ language/feature checks
816 fi # ! SKIP_COMPILER_CHECKS
819 if test -n "${TARGET_CPU}" -a -n "${TARGET_COMPILER_ABI}"; then
820 TARGET_XPCOM_ABI="${TARGET_CPU}-${TARGET_COMPILER_ABI}"
823 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
824 dnl features that Windows actually does support.
826 if test -n "$SKIP_COMPILER_CHECKS"; then
827 dnl Windows has malloc.h
828 AC_DEFINE(MALLOC_H, [<malloc.h>])
829 AC_DEFINE(HAVE_FORCEINLINE)
830 fi # SKIP_COMPILER_CHECKS
832 dnl Mozilla specific options
833 dnl ========================================================
834 dnl The macros used for command line options
835 dnl are defined in build/autoconf/altoptions.m4.
837 dnl ========================================================
838 dnl = Enable code optimization. ON by default.
839 dnl ========================================================
841 # Use value from moz.configure if one is defined. Else use our computed
843 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
844 MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
847 if test "$COMPILE_ENVIRONMENT"; then
848 if test -n "$MOZ_OPTIMIZE"; then
849 AC_MSG_CHECKING([for valid optimization flags])
851 CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
852 AC_TRY_COMPILE([#include <stdio.h>],
853 [printf("Hello World\n");],
856 AC_MSG_RESULT([$_results])
857 if test "$_results" = "no"; then
858 AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
861 if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
862 # When using llvm-based LTO, non numeric optimization levels are
863 # not supported by the linker, so force the linker to use -O2 (
864 # which doesn't influence the level compilation units are actually
866 case " $MOZ_OPTIMIZE_FLAGS " in
868 MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
873 fi # COMPILE_ENVIRONMENT
875 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
876 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
877 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
879 dnl ========================================================
880 dnl = Enable jemalloc
881 dnl ========================================================
883 if test "$JS_STANDALONE" -a -z "$MOZ_MEMORY"; then
886 case "${OS_TARGET}" in
887 Android|WINNT|Darwin)
891 dnl On !Android !Windows !OSX, we only want to link executables against mozglue
892 MOZ_GLUE_IN_PROGRAM=1
893 AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
898 if test "$MOZ_MEMORY"; then
899 dnl The generic feature tests that determine how to compute ncpus are long and
900 dnl complicated. Therefore, simply define special cpp variables for the
901 dnl platforms we have special knowledge of.
904 export MOZ_NO_DEBUG_RTL=1
908 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
910 dnl ========================================================
912 dnl ========================================================
913 if test -n "$MOZ_INSTRUMENTS"; then
914 LIBS="$LIBS -framework CoreFoundation"
917 dnl ========================================================
918 dnl = Enable using the clang plugin to build
919 dnl ========================================================
921 if test -n "$COMPILE_ENVIRONMENT"; then
922 MOZ_CONFIG_CLANG_PLUGIN
923 fi # COMPILE_ENVIRONMENT
925 if test -z "$SKIP_COMPILER_CHECKS"; then
927 dnl ========================================================
928 dnl Check for gcc -pipe support
929 dnl ========================================================
930 AC_MSG_CHECKING([for -pipe support])
931 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
932 dnl Any gcc that supports firefox supports -pipe.
933 CFLAGS="$CFLAGS -pipe"
934 CXXFLAGS="$CXXFLAGS -pipe"
940 fi # ! SKIP_COMPILER_CHECKS
944 dnl ========================================================
946 dnl = Maintainer debug option (no --enable equivalent)
948 dnl ========================================================
950 AC_SUBST_LIST(ASFLAGS)
951 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
953 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
955 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
957 AC_SUBST(MOZ_APP_DISPLAYNAME)
959 AC_SUBST(MOZ_PKG_SPECIAL)
961 dnl Echo the CFLAGS to remove extra whitespace.
963 $_COMPILATION_CFLAGS \
967 $_COMPILATION_CXXFLAGS \
970 COMPILE_CFLAGS=`echo \
974 COMPILE_CXXFLAGS=`echo \
979 $_COMPILATION_HOST_CFLAGS \
982 HOST_CXXFLAGS=`echo \
983 $_COMPILATION_HOST_CXXFLAGS \
987 OS_CXXFLAGS="$CXXFLAGS"
988 OS_CPPFLAGS="$CPPFLAGS"
989 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
990 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
991 OS_LDFLAGS="$LDFLAGS"
993 AC_SUBST_LIST(OS_CFLAGS)
994 AC_SUBST_LIST(OS_CXXFLAGS)
995 AC_SUBST_LIST(OS_CPPFLAGS)
996 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
997 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
998 AC_SUBST_LIST(OS_LDFLAGS)
1003 AC_SUBST_LIST(HOST_CFLAGS)
1004 AC_SUBST_LIST(HOST_CPPFLAGS)
1005 AC_SUBST_LIST(HOST_CXXFLAGS)
1006 AC_SUBST(HOST_LDFLAGS)
1007 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1008 AC_SUBST(HOST_BIN_SUFFIX)
1010 AC_SUBST(TARGET_XPCOM_ABI)
1012 AC_SUBST(DSO_LDOPTS)
1013 AC_SUBST(BIN_SUFFIX)
1015 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1016 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1018 dnl Set various defines and substitutions
1019 dnl ========================================================
1021 AC_SUBST(MOZ_DEV_EDITION)
1022 if test -n "$MOZ_DEV_EDITION"; then
1023 AC_DEFINE(MOZ_DEV_EDITION)
1026 dnl ========================================================
1027 dnl JavaScript shell
1028 dnl ========================================================
1032 if test -n "$JS_STANDALONE"; then
1033 JS_LIBRARY_NAME="mozjs-$MOZILLA_SYMBOLVERSION"
1035 JS_LIBRARY_NAME="mozjs"
1037 JS_CONFIG_LIBS="$NSPR_LIBS $LIBS"
1038 if test -n "$GNU_CC"; then
1039 JS_CONFIG_MOZ_JS_LIBS='-L${libdir} -l${JS_LIBRARY_NAME}'
1041 JS_CONFIG_MOZ_JS_LIBS='${libdir}/${JS_LIBRARY_NAME}.lib'
1043 AC_SUBST(JS_LIBRARY_NAME)
1044 AC_SUBST(JS_CONFIG_MOZ_JS_LIBS)
1045 AC_SUBST(JS_CONFIG_LIBS)
1047 # Avoid using obsolete NSPR features
1048 AC_DEFINE(NO_NSPR_10_SUPPORT)
1050 dnl Spit out some output
1051 dnl ========================================================
1052 MOZ_CREATE_CONFIG_STATUS()
1054 rm -fr confdefs* $ac_clean_files