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"
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 ========================================================
85 # Target the Windows 8.1 SDK by default
90 if test "$GCC" != "yes"; then
91 # Check to see if we are really running in a msvc environemnt
94 # Make sure compilers are valid
95 CXXFLAGS="$CXXFLAGS -TP"
96 # _CRT_SECURE_NO_WARNINGS disables warnings about using MSVC-specific
97 # secure CRT functions.
98 CXXFLAGS="$CXXFLAGS -D_CRT_SECURE_NO_WARNINGS"
101 AC_TRY_COMPILE([#include <stdio.h>],
102 [ printf("Hello World\n"); ],,
103 AC_MSG_ERROR([\$(CC) test failed. You must have MS VC++ in your path to build.]) )
106 AC_TRY_COMPILE([#include <new.h>],
107 [ unsigned *test = new unsigned(42); ],,
108 AC_MSG_ERROR([\$(CXX) test failed. You must have MS VC++ in your path to build.]) )
111 AC_DEFINE(_CRT_SECURE_NO_WARNINGS)
112 AC_DEFINE(_CRT_NONSTDC_NO_WARNINGS)
114 MSVC_C_RUNTIME_DLL=vcruntime140.dll
115 if test -n "$IS_VS2019_OR_MORE" -a "$CPU_ARCH" != "x86"; then
116 MSVC_C_RUNTIME_1_DLL=vcruntime140_1.dll
118 MSVC_CXX_RUNTIME_DLL=msvcp140.dll
120 # -Zc:sizedDealloc- disables C++14 global sized deallocation (see bug 1160146)
121 CXXFLAGS="$CXXFLAGS -Zc:sizedDealloc-"
123 AC_SUBST(MSVC_C_RUNTIME_DLL)
124 AC_SUBST(MSVC_C_RUNTIME_1_DLL)
125 AC_SUBST(MSVC_CXX_RUNTIME_DLL)
127 CFLAGS="$CFLAGS -D_HAS_EXCEPTIONS=0"
128 CXXFLAGS="$CXXFLAGS -D_HAS_EXCEPTIONS=0"
130 # Check w32api version
131 _W32API_MAJOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $1 }'`
132 _W32API_MINOR_VERSION=`echo $W32API_VERSION | $AWK -F\. '{ print $2 }'`
133 AC_MSG_CHECKING([for w32api version >= $W32API_VERSION])
134 AC_TRY_COMPILE([#include <w32api.h>],
135 #if (__W32API_MAJOR_VERSION < $_W32API_MAJOR_VERSION) || \
136 (__W32API_MAJOR_VERSION == $_W32API_MAJOR_VERSION && \
137 __W32API_MINOR_VERSION < $_W32API_MINOR_VERSION)
138 #error "test failed."
140 , [ res=yes ], [ res=no ])
141 AC_MSG_RESULT([$res])
142 if test "$res" != "yes"; then
143 AC_MSG_ERROR([w32api version $W32API_VERSION or higher required.])
147 AC_DEFINE(_USE_MATH_DEFINES) # Otherwise Windows' math.h doesn't #define M_PI.
149 AC_DEFINE_UNQUOTED(WINVER,0x$WINVER)
150 AC_DEFINE_UNQUOTED(_WIN32_WINNT,0x$WINVER)
151 # Require OS features provided by IE 8.0 (Win7)
152 AC_DEFINE_UNQUOTED(_WIN32_IE,0x0800)
157 if test -n "$_WIN32_MSVC"; then
159 SKIP_COMPILER_CHECKS=1
160 SKIP_LIBRARY_CHECKS=1
163 fi # COMPILE_ENVIRONMENT
168 dnl ========================================================
169 dnl set the defaults first
170 dnl ========================================================
171 MOZ_FIX_LINK_PATHS="-Wl,-rpath-link,${DIST}/bin -Wl,-rpath-link,${prefix}/lib"
173 dnl Configure platform-specific CPU architecture compiler options.
174 dnl ==============================================================
179 dnl ========================================================
180 dnl GNU specific defaults
181 dnl ========================================================
182 if test "$GNU_CC"; then
184 if test "$GCC_USE_GNU_LD"; then
185 # Some tools like ASan use a runtime library that is only
186 # linked against executables, so we must allow undefined
187 # symbols for shared objects in some cases.
188 if test -z "$MOZ_ASAN$MOZ_MSAN$MOZ_UBSAN$MOZ_TSAN$FUZZING_INTERFACES"; then
189 # Don't allow undefined symbols in libraries
190 DSO_LDOPTS="$DSO_LDOPTS -Wl,-z,defs"
194 if test "$OS_ARCH" != "WINNT"; then
195 DSO_PIC_CFLAGS='-fPIC'
196 ASFLAGS="$ASFLAGS -fPIC"
199 AC_MSG_CHECKING([for --noexecstack option to as])
201 CFLAGS="$CFLAGS -Wa,--noexecstack"
202 AC_TRY_COMPILE(,,AC_MSG_RESULT([yes])
203 [ASFLAGS="$ASFLAGS -Wa,--noexecstack"],
206 AC_MSG_CHECKING([for -z noexecstack option to ld])
207 _SAVE_LDFLAGS=$LDFLAGS
208 LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"
209 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
211 LDFLAGS=$_SAVE_LDFLAGS)
213 AC_MSG_CHECKING([for -z text option to ld])
214 _SAVE_LDFLAGS=$LDFLAGS
215 LDFLAGS="$LDFLAGS -Wl,-z,text"
216 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
218 LDFLAGS=$_SAVE_LDFLAGS)
220 AC_MSG_CHECKING([for -z relro option to ld])
221 _SAVE_LDFLAGS=$LDFLAGS
222 LDFLAGS="$LDFLAGS -Wl,-z,relro"
223 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
225 LDFLAGS=$_SAVE_LDFLAGS)
227 AC_MSG_CHECKING([for -z nocopyreloc option to ld])
228 _SAVE_LDFLAGS=$LDFLAGS
229 LDFLAGS="$LDFLAGS -Wl,-z,nocopyreloc"
230 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
232 LDFLAGS=$_SAVE_LDFLAGS)
234 AC_MSG_CHECKING([for -Bsymbolic-functions option to ld])
235 _SAVE_LDFLAGS=$LDFLAGS
236 LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
237 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
239 LDFLAGS=$_SAVE_LDFLAGS)
241 # While sha1 is deterministic, it is slower.
242 if test -z "$DEVELOPER_OPTIONS"; then
247 AC_MSG_CHECKING([for --build-id=$build_id option to ld])
248 _SAVE_LDFLAGS=$LDFLAGS
249 LDFLAGS="$LDFLAGS -Wl,--build-id=$build_id"
250 AC_TRY_LINK(,,AC_MSG_RESULT([yes]),
252 LDFLAGS=$_SAVE_LDFLAGS)
254 _DEFINES_CFLAGS="-include $jsconfdefs -DMOZILLA_CLIENT"
257 if test "$GNU_CXX"; then
258 _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $jsconfdefs"
261 dnl ========================================================
262 dnl System overrides of the defaults for host
263 dnl ========================================================
266 if test -n "$_WIN32_MSVC"; then
267 HOST_CFLAGS="$HOST_CFLAGS"
269 HOST_CFLAGS="$HOST_CFLAGS -mwindows"
271 HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
272 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
275 case "${host_cpu}" in
277 if test -n "$_WIN32_MSVC"; then
278 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
282 if test -n "$_WIN32_MSVC"; then
283 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
285 HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
291 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
292 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
295 *-linux*|*-kfreebsd*-gnu|*-gnu*)
296 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
297 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
301 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
302 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
306 dnl ========================================================
307 dnl System overrides of the defaults for target
308 dnl ========================================================
312 MOZ_OPTIMIZE_FLAGS="-O3"
315 dnl DTrace and -dead_strip don't interact well. See bug 403132.
316 dnl ===================================================================
317 if test "x$enable_dtrace" = "xyes"; then
318 echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
320 dnl check for the presence of the -dead_strip linker flag
321 AC_MSG_CHECKING([for -dead_strip option to ld])
322 _SAVE_LDFLAGS=$LDFLAGS
323 LDFLAGS="$LDFLAGS -Wl,-dead_strip"
324 AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
325 if test -n "$_HAVE_DEAD_STRIP" ; then
327 MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
332 LDFLAGS=$_SAVE_LDFLAGS
337 *-android*|*-linuxandroid*)
338 MOZ_OPTIMIZE_FLAGS="-O3"
339 if test -z "$CLANG_CC"; then
340 MOZ_OPTIMIZE_FLAGS="-freorder-blocks -fno-reorder-functions $MOZ_OPTIMIZE_FLAGS"
345 if test "$GNU_CC" -o "$GNU_CXX"; then
346 MOZ_PGO_OPTIMIZE_FLAGS="-O3"
347 MOZ_OPTIMIZE_FLAGS="-O3"
348 if test -z "$CLANG_CC"; then
349 MOZ_OPTIMIZE_FLAGS="-freorder-blocks $MOZ_OPTIMIZE_FLAGS"
353 case "${target_cpu}" in
355 CFLAGS="$CFLAGS -mieee"
356 CXXFLAGS="$CXXFLAGS -mieee"
363 if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
364 # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
365 if test -z "$CLANG_CC"; then
366 AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
372 # Silence problematic clang warnings
373 CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
374 LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
376 MOZ_OPTIMIZE_FLAGS="-O2"
378 WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
379 WIN32_GUI_EXE_LDFLAGS=-mwindows
381 TARGET_COMPILER_ABI=msvc
382 # aarch64 doesn't support subsystems below 6.02
383 if test "$CPU_ARCH" = "aarch64"; then
384 WIN32_SUBSYSTEM_VERSION=6.02
386 WIN32_SUBSYSTEM_VERSION=6.01
388 WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
389 WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
390 DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
391 _DEFINES_CFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
392 _DEFINES_CXXFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
393 CFLAGS="$CFLAGS -Gy -Zc:inline"
394 CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
395 if test "$CPU_ARCH" = "x86";then
396 dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
397 dnl more recent, so set that explicitly here unless another
398 dnl target arch has already been set.
400 if test -z `echo $CFLAGS | grep -i [-/]arch:` ; then
401 CFLAGS="$CFLAGS -arch:SSE2"
403 if test -z `echo $CXXFLAGS | grep -i [-/]arch:` ; then
404 CXXFLAGS="$CXXFLAGS -arch:SSE2"
408 dnl VS2013+ supports -Gw for better linker optimizations.
409 dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
410 dnl Disabled on ASan because it causes false-positive ODR violations.
411 if test -z "$MOZ_ASAN"; then
413 CXXFLAGS="$CXXFLAGS -Gw"
415 # String tail merging doesn't play nice with ASan's ODR checker.
416 LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
418 MOZ_DEBUG_LDFLAGS='-DEBUG'
419 if test "$HOST_OS_ARCH" != "WINNT"; then
420 # %_PDB% is a special signal to emit only the PDB basename. This
421 # avoids problems in Windows tools that don't like forward-slashes.
422 MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
424 MOZ_OPTIMIZE_FLAGS="-O2"
426 LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
428 AC_DEFINE(HAVE__MSIZE)
429 AC_DEFINE(WIN32_LEAN_AND_MEAN)
430 dnl See http://support.microsoft.com/kb/143208 to use STL
436 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.])
442 if test -n "$GNU_CC"; then
443 CFLAGS="$CFLAGS -mstackrealign"
444 CXXFLAGS="$CXXFLAGS -mstackrealign"
445 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
447 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
448 LDFLAGS="$LDFLAGS -SAFESEH"
454 if test -n "$_WIN32_MSVC"; then
455 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
460 if test -n "$_WIN32_MSVC"; then
461 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
466 AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
472 CFLAGS="$CFLAGS -Dunix"
473 CXXFLAGS="$CXXFLAGS -Dunix"
474 if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
475 DSO_PIC_CFLAGS='-fPIC -DPIC'
477 MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
479 DSO_PIC_CFLAGS='-fPIC -DPIC'
482 # This will fail on a.out systems prior to 1.5.1_ALPHA.
483 if test "$LIBRUNPATH"; then
484 DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
489 DSO_PIC_CFLAGS='-fPIC'
490 DSO_LDOPTS='-shared -fPIC'
491 if test "$LIBRUNPATH"; then
492 DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
497 MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
501 CXXFLAGS="$CXXFLAGS -mthread-model single"
507 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
508 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
510 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
511 MOZ_OPTIMIZE_FLAGS="-O"
514 if test -z "$COMPILE_ENVIRONMENT"; then
515 SKIP_COMPILER_CHECKS=1
516 SKIP_LIBRARY_CHECKS=1
519 if test -n "$COMPILE_ENVIRONMENT"; then
523 if test -z "$SKIP_COMPILER_CHECKS"; then
524 dnl Checks for typedefs, structures, and compiler characteristics.
525 dnl ========================================================
533 AC_MSG_CHECKING(for ssize_t)
534 AC_CACHE_VAL(ac_cv_type_ssize_t,
535 [AC_TRY_COMPILE([#include <stdio.h>
536 #include <sys/types.h>],
538 [ac_cv_type_ssize_t=true],
539 [ac_cv_type_ssize_t=false])])
540 if test "$ac_cv_type_ssize_t" = true ; then
541 AC_DEFINE(HAVE_SSIZE_T)
551 dnl Checks for header files.
552 dnl ========================================================
555 dnl Checks for libraries.
556 dnl ========================================================
557 AC_CHECK_LIB(c_r, gethostbyname_r)
559 dnl We don't want to link with libdl even if it's present on OS X, since
560 dnl it's not used and not part of the default installation. OS/2 has dlfcn
562 dnl We don't want to link against libm or libpthread on Darwin since
563 dnl they both are just symlinks to libSystem and explicitly linking
564 dnl against libSystem causes issues when debugging (see bug 299601).
569 AC_SEARCH_LIBS(dlopen, dl,
570 MOZ_CHECK_HEADER(dlfcn.h,
571 AC_DEFINE(HAVE_DLOPEN)))
575 _SAVE_CFLAGS="$CFLAGS"
576 CFLAGS="$CFLAGS -D_GNU_SOURCE"
577 AC_CHECK_FUNCS(dladdr)
578 CFLAGS="$_SAVE_CFLAGS"
580 if test ! "$GNU_CXX"; then
581 AC_CHECK_LIB(C, demangle)
584 AC_CHECK_LIB(socket, socket)
586 dnl ========================================================
587 dnl = pthread support
588 dnl = Start by checking whether the system support pthreads
589 dnl ========================================================
595 AC_CHECK_LIB(pthreads, pthread_create,
596 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
597 AC_CHECK_LIB(pthread, pthread_create,
598 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
599 AC_CHECK_LIB(c_r, pthread_create,
600 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
601 AC_CHECK_LIB(c, pthread_create,
610 dnl ========================================================
611 dnl Do the platform specific pthread hackery
612 dnl ========================================================
613 if test "$USE_PTHREADS"x != x
616 dnl See if -pthread is supported.
619 ac_cv_have_dash_pthread=no
620 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
621 echo 'int main() { return 0; }' | cat > conftest.c
622 ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
623 if test $? -eq 0; then
624 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
625 ac_cv_have_dash_pthread=yes
628 # Freebsd doesn't use -pthread for compiles, it uses them for linking
631 CFLAGS="$CFLAGS -pthread"
632 CXXFLAGS="$CXXFLAGS -pthread"
638 AC_MSG_RESULT($ac_cv_have_dash_pthread)
641 dnl See if -pthreads is supported.
643 ac_cv_have_dash_pthreads=no
644 if test "$ac_cv_have_dash_pthread" = "no"; then
645 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
646 echo 'int main() { return 0; }' | cat > conftest.c
647 ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
648 if test $? -eq 0; then
649 if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
650 ac_cv_have_dash_pthreads=yes
651 CFLAGS="$CFLAGS -pthreads"
652 CXXFLAGS="$CXXFLAGS -pthreads"
656 AC_MSG_RESULT($ac_cv_have_dash_pthreads)
661 AC_DEFINE(_REENTRANT)
662 AC_DEFINE(_THREAD_SAFE)
663 dnl -pthread links in -lpthread, so don't specify it explicitly.
664 if test "$ac_cv_have_dash_pthread" = "yes"; then
665 _PTHREAD_LDFLAGS="-pthread"
669 *-*-openbsd*|*-*-bsdi*)
670 AC_DEFINE(_REENTRANT)
671 AC_DEFINE(_THREAD_SAFE)
672 dnl -pthread links in -lc_r, so don't specify it explicitly.
673 if test "$ac_cv_have_dash_pthread" = "yes"; then
674 _PTHREAD_LDFLAGS="-pthread"
678 *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
679 AC_DEFINE(_REENTRANT)
683 LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
687 dnl Checks for library functions.
688 dnl ========================================================
690 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
691 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
692 ac_cv_clock_monotonic,
693 [for libs in "" -lrt; do
696 dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
697 dnl we should or not be able to use it. To detect if we can, we need to make the
698 dnl availability attribute strict, so that compilation fails when the target is < 10.12.
699 AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
701 [ struct timespec ts;
702 clock_gettime(CLOCK_MONOTONIC, &ts); ],
703 ac_cv_clock_monotonic=$libs
706 ac_cv_clock_monotonic=no)
709 if test "$ac_cv_clock_monotonic" != "no"; then
710 HAVE_CLOCK_MONOTONIC=1
711 REALTIME_LIBS=$ac_cv_clock_monotonic
712 AC_DEFINE(HAVE_CLOCK_MONOTONIC)
713 AC_SUBST(HAVE_CLOCK_MONOTONIC)
714 AC_SUBST_LIST(REALTIME_LIBS)
717 dnl Checks for math functions.
718 dnl ========================================================
723 ac_cv_func_res_ninit,
724 [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
725 dnl no need for res_ninit() on NetBSD and OpenBSD
726 ac_cv_func_res_ninit=no
730 #define _BSD_SOURCE 1
732 #include <sys/types.h>
733 #include <netinet/in.h>
734 #include <arpa/nameser.h>
737 [int foo = res_ninit(&_res);],
738 [ac_cv_func_res_ninit=yes],
739 [ac_cv_func_res_ninit=no])
743 if test "$ac_cv_func_res_ninit" = "yes"; then
744 AC_DEFINE(HAVE_RES_NINIT)
745 dnl must add the link line we do something as foolish as this... dougt
747 dnl AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
748 dnl AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
755 dnl ===================================================================
756 dnl ========================================================
757 dnl Put your C++ language/feature checks below
758 dnl ========================================================
762 if test "$GNU_CC"; then
763 if test "$CPU_ARCH" = "arm" ; then
764 AC_CACHE_CHECK(for ARM EABI,
768 #if defined(__ARM_EABI__)
774 ac_cv_gcc_arm_eabi="yes",
775 ac_cv_gcc_arm_eabi="no")])
776 if test "$ac_cv_gcc_arm_eabi" = "yes"; then
784 TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
787 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
788 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
789 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
791 _SAVE_LDFLAGS=$LDFLAGS
792 LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
793 AC_CACHE_CHECK(for __thread keyword for TLS variables,
794 ac_cv_thread_keyword,
795 [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
796 [return tlsIsMainThread;],
797 ac_cv_thread_keyword=yes,
798 ac_cv_thread_keyword=no)])
799 LDFLAGS=$_SAVE_LDFLAGS
800 if test "$ac_cv_thread_keyword" = yes; then
801 # mips builds fail with TLS variables because of a binutils bug.
807 *-android*|*-linuxandroid*)
811 AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
816 dnl End of C++ language/feature checks
819 fi # ! SKIP_COMPILER_CHECKS
822 if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
823 TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
826 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
827 dnl features that Windows actually does support.
829 if test -n "$SKIP_COMPILER_CHECKS"; then
830 dnl Windows has malloc.h
831 AC_DEFINE(MALLOC_H, [<malloc.h>])
832 AC_DEFINE(HAVE_FORCEINLINE)
833 fi # SKIP_COMPILER_CHECKS
835 dnl Mozilla specific options
836 dnl ========================================================
837 dnl The macros used for command line options
838 dnl are defined in build/autoconf/altoptions.m4.
840 dnl ========================================================
841 dnl = Enable code optimization. ON by default.
842 dnl ========================================================
844 # Use value from moz.configure if one is defined. Else use our computed
846 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
847 MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
850 if test "$COMPILE_ENVIRONMENT"; then
851 if test -n "$MOZ_OPTIMIZE"; then
852 AC_MSG_CHECKING([for valid optimization flags])
854 CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
855 AC_TRY_COMPILE([#include <stdio.h>],
856 [printf("Hello World\n");],
859 AC_MSG_RESULT([$_results])
860 if test "$_results" = "no"; then
861 AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
864 if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
865 # When using llvm-based LTO, non numeric optimization levels are
866 # not supported by the linker, so force the linker to use -O2 (
867 # which doesn't influence the level compilation units are actually
869 case " $MOZ_OPTIMIZE_FLAGS " in
871 MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
876 fi # COMPILE_ENVIRONMENT
878 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
879 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
880 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
882 dnl ========================================================
883 dnl = Enable jemalloc
884 dnl ========================================================
886 if test "$JS_STANDALONE" -a -z "$MOZ_MEMORY"; then
889 case "${OS_TARGET}" in
890 Android|WINNT|Darwin)
894 dnl On !Android !Windows !OSX, we only want to link executables against mozglue
895 MOZ_GLUE_IN_PROGRAM=1
896 AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
901 if test "$MOZ_MEMORY"; then
902 dnl The generic feature tests that determine how to compute ncpus are long and
903 dnl complicated. Therefore, simply define special cpp variables for the
904 dnl platforms we have special knowledge of.
907 export MOZ_NO_DEBUG_RTL=1
911 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
913 dnl ========================================================
915 dnl ========================================================
916 if test -n "$MOZ_INSTRUMENTS"; then
917 LIBS="$LIBS -framework CoreFoundation"
920 dnl ========================================================
921 dnl = Enable using the clang plugin to build
922 dnl ========================================================
924 if test -n "$COMPILE_ENVIRONMENT"; then
925 MOZ_CONFIG_CLANG_PLUGIN
926 fi # COMPILE_ENVIRONMENT
928 if test -z "$SKIP_COMPILER_CHECKS"; then
930 dnl ========================================================
931 dnl Check for gcc -pipe support
932 dnl ========================================================
933 AC_MSG_CHECKING([for -pipe support])
934 if test -n "$GNU_CC" -a -n "$GNU_CXX"; then
935 dnl Any gcc that supports firefox supports -pipe.
936 CFLAGS="$CFLAGS -pipe"
937 CXXFLAGS="$CXXFLAGS -pipe"
943 fi # ! SKIP_COMPILER_CHECKS
947 dnl ========================================================
949 dnl = Maintainer debug option (no --enable equivalent)
951 dnl ========================================================
953 AC_SUBST_LIST(ASFLAGS)
954 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
956 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
958 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
960 AC_SUBST(MOZ_APP_DISPLAYNAME)
962 AC_SUBST(MOZ_PKG_SPECIAL)
964 dnl Echo the CFLAGS to remove extra whitespace.
966 $_COMPILATION_CFLAGS \
970 $_COMPILATION_CXXFLAGS \
973 COMPILE_CFLAGS=`echo \
977 COMPILE_CXXFLAGS=`echo \
982 $_COMPILATION_HOST_CFLAGS \
985 HOST_CXXFLAGS=`echo \
986 $_COMPILATION_HOST_CXXFLAGS \
990 OS_CXXFLAGS="$CXXFLAGS"
991 OS_CPPFLAGS="$CPPFLAGS"
992 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
993 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
994 OS_LDFLAGS="$LDFLAGS"
996 AC_SUBST_LIST(OS_CFLAGS)
997 AC_SUBST_LIST(OS_CXXFLAGS)
998 AC_SUBST_LIST(OS_CPPFLAGS)
999 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
1000 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
1001 AC_SUBST_LIST(OS_LDFLAGS)
1006 AC_SUBST_LIST(HOST_CFLAGS)
1007 AC_SUBST_LIST(HOST_CPPFLAGS)
1008 AC_SUBST_LIST(HOST_CXXFLAGS)
1009 AC_SUBST(HOST_LDFLAGS)
1010 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
1011 AC_SUBST(HOST_BIN_SUFFIX)
1013 AC_SUBST(TARGET_XPCOM_ABI)
1015 AC_SUBST(DSO_LDOPTS)
1016 AC_SUBST(BIN_SUFFIX)
1018 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
1019 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
1021 dnl Set various defines and substitutions
1022 dnl ========================================================
1024 AC_SUBST(MOZ_DEV_EDITION)
1025 if test -n "$MOZ_DEV_EDITION"; then
1026 AC_DEFINE(MOZ_DEV_EDITION)
1029 dnl ========================================================
1030 dnl JavaScript shell
1031 dnl ========================================================
1035 if test -n "$JS_STANDALONE"; then
1036 JS_LIBRARY_NAME="mozjs-$MOZILLA_SYMBOLVERSION"
1038 JS_LIBRARY_NAME="mozjs"
1040 JS_CONFIG_LIBS="$NSPR_LIBS $LIBS"
1041 if test -n "$GNU_CC"; then
1042 JS_CONFIG_MOZ_JS_LIBS='-L${libdir} -l${JS_LIBRARY_NAME}'
1044 JS_CONFIG_MOZ_JS_LIBS='${libdir}/${JS_LIBRARY_NAME}.lib'
1046 AC_SUBST(JS_LIBRARY_NAME)
1047 AC_SUBST(JS_CONFIG_MOZ_JS_LIBS)
1048 AC_SUBST(JS_CONFIG_LIBS)
1050 # Avoid using obsolete NSPR features
1051 AC_DEFINE(NO_NSPR_10_SUPPORT)
1053 dnl Spit out some output
1054 dnl ========================================================
1055 MOZ_CREATE_CONFIG_STATUS()
1057 rm -fr confdefs* $ac_clean_files