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 "$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 _DEFINES_CFLAGS="-include $jsconfdefs -DMOZILLA_CLIENT"
200 if test "$GNU_CXX"; then
201 _DEFINES_CXXFLAGS="-DMOZILLA_CLIENT -include $jsconfdefs"
204 dnl ========================================================
205 dnl System overrides of the defaults for host
206 dnl ========================================================
209 if test -n "$_WIN32_MSVC"; then
210 HOST_CFLAGS="$HOST_CFLAGS"
212 HOST_CFLAGS="$HOST_CFLAGS -mwindows"
214 HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN -DWIN32 -D_WIN32 -D_CRT_SECURE_NO_WARNINGS"
215 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
218 case "${host_cpu}" in
220 if test -n "$_WIN32_MSVC"; then
221 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X86"
225 if test -n "$_WIN32_MSVC"; then
226 HOST_LDFLAGS="$HOST_LDFLAGS -MACHINE:X64"
228 HOST_CFLAGS="$HOST_CFLAGS -D_AMD64_"
234 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX"
235 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
238 *-linux*|*-kfreebsd*-gnu|*-gnu*)
239 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
240 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
244 HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
245 HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
249 dnl ========================================================
250 dnl System overrides of the defaults for target
251 dnl ========================================================
255 MOZ_OPTIMIZE_FLAGS="-O3"
258 dnl DTrace and -dead_strip don't interact well. See bug 403132.
259 dnl ===================================================================
260 if test "x$enable_dtrace" = "xyes"; then
261 echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
263 dnl check for the presence of the -dead_strip linker flag
264 AC_MSG_CHECKING([for -dead_strip option to ld])
265 _SAVE_LDFLAGS=$LDFLAGS
266 LDFLAGS="$LDFLAGS -Wl,-dead_strip"
267 AC_TRY_LINK(,[return 0;],_HAVE_DEAD_STRIP=1,_HAVE_DEAD_STRIP=)
268 if test -n "$_HAVE_DEAD_STRIP" ; then
270 MOZ_OPTIMIZE_LDFLAGS="-Wl,-dead_strip"
275 LDFLAGS=$_SAVE_LDFLAGS
280 *-android*|*-linuxandroid*)
281 MOZ_OPTIMIZE_FLAGS="-O3"
282 if test -z "$CLANG_CC"; then
283 MOZ_OPTIMIZE_FLAGS="-fno-reorder-functions $MOZ_OPTIMIZE_FLAGS"
288 if test "$GNU_CC" -o "$GNU_CXX"; then
289 MOZ_PGO_OPTIMIZE_FLAGS="-O3"
290 MOZ_OPTIMIZE_FLAGS="-O3"
293 case "${target_cpu}" in
295 CFLAGS="$CFLAGS -mieee"
296 CXXFLAGS="$CXXFLAGS -mieee"
303 if test -n "$GNU_CC" -o -n "$CLANG_CC"; then
304 # $GNU_CC will match gcc and clang; while $CLANG_CC will match only clang
305 if test -z "$CLANG_CC"; then
306 AC_MSG_ERROR(Firefox cannot be built with mingw-gcc and requires a mingw-clang toolchain to work)
312 # Silence problematic clang warnings
313 CXXFLAGS="$CXXFLAGS -Wno-incompatible-ms-struct"
314 LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"
316 MOZ_OPTIMIZE_FLAGS="-O2"
318 WIN32_CONSOLE_EXE_LDFLAGS=-mconsole
319 WIN32_GUI_EXE_LDFLAGS=-mwindows
321 TARGET_COMPILER_ABI=msvc
322 WIN32_SUBSYSTEM_VERSION=10.0
323 WIN32_CONSOLE_EXE_LDFLAGS=-SUBSYSTEM:CONSOLE,$WIN32_SUBSYSTEM_VERSION
324 WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
325 DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
326 _DEFINES_CFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
327 _DEFINES_CXXFLAGS="-FI $jsconfdefs -DMOZILLA_CLIENT"
328 CFLAGS="$CFLAGS -Gy -Zc:inline"
329 CXXFLAGS="$CXXFLAGS -Gy -Zc:inline"
330 if test "$TARGET_CPU" = "x86";then
331 dnl VS2012+ defaults to -arch:SSE2. We want to target nothing
332 dnl more recent, so set that explicitly here unless another
333 dnl target arch has already been set.
335 if test -z `echo $CFLAGS | grep -i [-/]arch:` ; then
336 CFLAGS="$CFLAGS -arch:SSE2"
338 if test -z `echo $CXXFLAGS | grep -i [-/]arch:` ; then
339 CXXFLAGS="$CXXFLAGS -arch:SSE2"
343 dnl VS2013+ supports -Gw for better linker optimizations.
344 dnl http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
345 dnl Disabled on ASan because it causes false-positive ODR violations.
346 if test -z "$MOZ_ASAN"; then
348 CXXFLAGS="$CXXFLAGS -Gw"
350 # String tail merging doesn't play nice with ASan's ODR checker.
351 LDFLAGS="$LDFLAGS -opt:nolldtailmerge"
353 MOZ_DEBUG_LDFLAGS='-DEBUG'
354 if test "$HOST_OS_ARCH" != "WINNT"; then
355 # %_PDB% is a special signal to emit only the PDB basename. This
356 # avoids problems in Windows tools that don't like forward-slashes.
357 MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -PDBALTPATH:%_PDB%"
359 MOZ_OPTIMIZE_FLAGS="-O2"
361 LDFLAGS="$LDFLAGS -LARGEADDRESSAWARE"
363 AC_DEFINE(HAVE__MSIZE)
364 AC_DEFINE(WIN32_LEAN_AND_MEAN)
365 dnl See http://support.microsoft.com/kb/143208 to use STL
371 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.])
377 if test -n "$GNU_CC"; then
378 CFLAGS="$CFLAGS -mstackrealign"
379 CXXFLAGS="$CXXFLAGS -mstackrealign"
380 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
382 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X86"
383 LDFLAGS="$LDFLAGS -SAFESEH"
389 if test -n "$_WIN32_MSVC"; then
390 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:X64"
395 if test -n "$_WIN32_MSVC"; then
396 DSO_LDOPTS="$DSO_LDOPTS -MACHINE:ARM64"
401 AC_DEFINE(_CPU_ARCH_NOT_DEFINED)
407 CFLAGS="$CFLAGS -Dunix"
408 CXXFLAGS="$CXXFLAGS -Dunix"
409 if $CC -E - -dM </dev/null | grep __ELF__ >/dev/null; then
410 DSO_PIC_CFLAGS='-fPIC -DPIC'
412 MOZ_PROGRAM_LDFLAGS="$MOZ_PROGRAM_LDFLAGS -Wl,--export-dynamic"
414 DSO_PIC_CFLAGS='-fPIC -DPIC'
417 # This will fail on a.out systems prior to 1.5.1_ALPHA.
418 if test "$LIBRUNPATH"; then
419 DSO_LDOPTS="-Wl,-R$LIBRUNPATH $DSO_LDOPTS"
424 DSO_PIC_CFLAGS='-fPIC'
425 DSO_LDOPTS='-shared -fPIC'
426 if test "$LIBRUNPATH"; then
427 DSO_LDOPTS="-R$LIBRUNPATH $DSO_LDOPTS"
432 MOZ_FIX_LINK_PATHS="-L${DIST}/bin"
436 CXXFLAGS="$CXXFLAGS -mthread-model single"
442 CFLAGS="$CFLAGS $DSO_PIC_CFLAGS"
443 CXXFLAGS="$CXXFLAGS $DSO_PIC_CFLAGS"
445 if test -z "$MOZ_OPTIMIZE_FLAGS"; then
446 MOZ_OPTIMIZE_FLAGS="-O"
449 if test -z "$COMPILE_ENVIRONMENT"; then
450 SKIP_COMPILER_CHECKS=1
451 SKIP_LIBRARY_CHECKS=1
454 if test -n "$COMPILE_ENVIRONMENT"; then
458 if test -z "$SKIP_COMPILER_CHECKS"; then
459 dnl Checks for typedefs, structures, and compiler characteristics.
460 dnl ========================================================
468 AC_MSG_CHECKING(for ssize_t)
469 AC_CACHE_VAL(ac_cv_type_ssize_t,
470 [AC_TRY_COMPILE([#include <stdio.h>
471 #include <sys/types.h>],
473 [ac_cv_type_ssize_t=true],
474 [ac_cv_type_ssize_t=false])])
475 if test "$ac_cv_type_ssize_t" = true ; then
476 AC_DEFINE(HAVE_SSIZE_T)
486 dnl Checks for header files.
487 dnl ========================================================
490 dnl Checks for libraries.
491 dnl ========================================================
492 AC_CHECK_LIB(c_r, gethostbyname_r)
494 dnl We don't want to link with libdl even if it's present on OS X, since
495 dnl it's not used and not part of the default installation. OS/2 has dlfcn
497 dnl We don't want to link against libm or libpthread on Darwin since
498 dnl they both are just symlinks to libSystem and explicitly linking
499 dnl against libSystem causes issues when debugging (see bug 299601).
504 AC_SEARCH_LIBS(dlopen, dl,
505 MOZ_CHECK_HEADER(dlfcn.h,
506 AC_DEFINE(HAVE_DLOPEN)))
510 _SAVE_CFLAGS="$CFLAGS"
511 CFLAGS="$CFLAGS -D_GNU_SOURCE"
512 AC_CHECK_FUNCS(dladdr)
513 CFLAGS="$_SAVE_CFLAGS"
515 if test ! "$GNU_CXX"; then
516 AC_CHECK_LIB(C, demangle)
519 AC_CHECK_LIB(socket, socket)
521 dnl ========================================================
522 dnl = pthread support
523 dnl = Start by checking whether the system support pthreads
524 dnl ========================================================
530 AC_CHECK_LIB(pthreads, pthread_create,
531 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads",
532 AC_CHECK_LIB(pthread, pthread_create,
533 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread",
534 AC_CHECK_LIB(c_r, pthread_create,
535 USE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r",
536 AC_CHECK_LIB(c, pthread_create,
545 dnl ========================================================
546 dnl Do the platform specific pthread hackery
547 dnl ========================================================
548 if test "$USE_PTHREADS"x != x
551 dnl See if -pthread is supported.
554 ac_cv_have_dash_pthread=no
555 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthread)
556 echo 'int main() { return 0; }' | cat > conftest.c
557 ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
558 if test $? -eq 0; then
559 if test -z "`grep -E -i '(unrecognize|unknown)' conftest.out | grep pthread`" -a -z "`grep -E -i '(error|incorrect)' conftest.out`" ; then
560 ac_cv_have_dash_pthread=yes
563 # Freebsd doesn't use -pthread for compiles, it uses them for linking
566 CFLAGS="$CFLAGS -pthread"
567 CXXFLAGS="$CXXFLAGS -pthread"
573 AC_MSG_RESULT($ac_cv_have_dash_pthread)
576 dnl See if -pthreads is supported.
578 ac_cv_have_dash_pthreads=no
579 if test "$ac_cv_have_dash_pthread" = "no"; then
580 AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads)
581 echo 'int main() { return 0; }' | cat > conftest.c
582 ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
583 if test $? -eq 0; then
584 if test -z "`grep -E -i '(unrecognize|unknown)' conftest.out | grep pthreads`" -a -z "`grep -E -i '(error|incorrect)' conftest.out`" ; then
585 ac_cv_have_dash_pthreads=yes
586 CFLAGS="$CFLAGS -pthreads"
587 CXXFLAGS="$CXXFLAGS -pthreads"
591 AC_MSG_RESULT($ac_cv_have_dash_pthreads)
596 AC_DEFINE(_REENTRANT)
597 AC_DEFINE(_THREAD_SAFE)
598 dnl -pthread links in -lpthread, so don't specify it explicitly.
599 if test "$ac_cv_have_dash_pthread" = "yes"; then
600 _PTHREAD_LDFLAGS="-pthread"
604 *-*-openbsd*|*-*-bsdi*)
605 AC_DEFINE(_REENTRANT)
606 AC_DEFINE(_THREAD_SAFE)
607 dnl -pthread links in -lc_r, so don't specify it explicitly.
608 if test "$ac_cv_have_dash_pthread" = "yes"; then
609 _PTHREAD_LDFLAGS="-pthread"
613 *-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
614 AC_DEFINE(_REENTRANT)
618 LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
622 dnl Checks for library functions.
623 dnl ========================================================
625 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
626 AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
627 ac_cv_clock_monotonic,
628 [for libs in "" -lrt; do
631 AC_TRY_LINK([#include <time.h>],
632 [ struct timespec ts;
633 clock_gettime(CLOCK_MONOTONIC, &ts); ],
634 ac_cv_clock_monotonic=$libs
637 ac_cv_clock_monotonic=no)
640 if test "$ac_cv_clock_monotonic" != "no"; then
641 HAVE_CLOCK_MONOTONIC=1
642 REALTIME_LIBS=$ac_cv_clock_monotonic
643 AC_DEFINE(HAVE_CLOCK_MONOTONIC)
644 AC_SUBST(HAVE_CLOCK_MONOTONIC)
645 AC_SUBST_LIST(REALTIME_LIBS)
648 dnl Checks for math functions.
649 dnl ========================================================
654 ac_cv_func_res_ninit,
655 [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
656 dnl no need for res_ninit() on NetBSD and OpenBSD
657 ac_cv_func_res_ninit=no
661 #define _BSD_SOURCE 1
663 #include <sys/types.h>
664 #include <netinet/in.h>
665 #include <arpa/nameser.h>
668 [int foo = res_ninit(&_res);],
669 [ac_cv_func_res_ninit=yes],
670 [ac_cv_func_res_ninit=no])
674 if test "$ac_cv_func_res_ninit" = "yes"; then
675 AC_DEFINE(HAVE_RES_NINIT)
676 dnl must add the link line we do something as foolish as this... dougt
678 dnl AC_CHECK_LIB(bind, res_ninit, AC_DEFINE(HAVE_RES_NINIT),
679 dnl AC_CHECK_LIB(resolv, res_ninit, AC_DEFINE(HAVE_RES_NINIT)))
686 dnl ===================================================================
687 dnl ========================================================
688 dnl Put your C++ language/feature checks below
689 dnl ========================================================
693 if test "$GNU_CC"; then
694 if test "$TARGET_CPU" = "arm" ; then
695 AC_CACHE_CHECK(for ARM EABI,
699 #if defined(__ARM_EABI__)
705 ac_cv_gcc_arm_eabi="yes",
706 ac_cv_gcc_arm_eabi="no")])
707 if test "$ac_cv_gcc_arm_eabi" = "yes"; then
715 TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
718 # try harder, when checking for __thread support, see bug 521750 comment #33 and below
719 # We pass MOZ_OPTIMIZE_LDFLAGS to the linker because if dead_strip is
720 # enabled, the linker in xcode 4.1 will crash. Without this it would crash when
722 _SAVE_LDFLAGS=$LDFLAGS
723 LDFLAGS="$LDFLAGS $DSO_LDOPTS $MOZ_OPTIMIZE_LDFLAGS"
724 AC_CACHE_CHECK(for __thread keyword for TLS variables,
725 ac_cv_thread_keyword,
726 [AC_TRY_LINK([__thread bool tlsIsMainThread = false;],
727 [return tlsIsMainThread;],
728 ac_cv_thread_keyword=yes,
729 ac_cv_thread_keyword=no)])
730 LDFLAGS=$_SAVE_LDFLAGS
731 if test "$ac_cv_thread_keyword" = yes; then
732 # mips builds fail with TLS variables because of a binutils bug.
738 *-android*|*-linuxandroid*)
742 AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
747 dnl End of C++ language/feature checks
750 fi # ! SKIP_COMPILER_CHECKS
753 if test -n "${TARGET_CPU}" -a -n "${TARGET_COMPILER_ABI}"; then
754 TARGET_XPCOM_ABI="${TARGET_CPU}-${TARGET_COMPILER_ABI}"
757 dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
758 dnl features that Windows actually does support.
760 if test -n "$SKIP_COMPILER_CHECKS"; then
761 dnl Windows has malloc.h
762 AC_DEFINE(MALLOC_H, [<malloc.h>])
763 AC_DEFINE(HAVE_FORCEINLINE)
764 fi # SKIP_COMPILER_CHECKS
766 dnl Mozilla specific options
767 dnl ========================================================
768 dnl The macros used for command line options
769 dnl are defined in build/autoconf/altoptions.m4.
771 dnl ========================================================
772 dnl = Enable code optimization. ON by default.
773 dnl ========================================================
775 # Use value from moz.configure if one is defined. Else use our computed
777 if test -n "${MOZ_CONFIGURE_OPTIMIZE_FLAGS}"; then
778 MOZ_OPTIMIZE_FLAGS=${MOZ_CONFIGURE_OPTIMIZE_FLAGS}
781 if test "$COMPILE_ENVIRONMENT"; then
782 if test -n "$MOZ_OPTIMIZE"; then
783 AC_MSG_CHECKING([for valid optimization flags])
785 CFLAGS="$CFLAGS $MOZ_OPTIMIZE_FLAGS"
786 AC_TRY_COMPILE([#include <stdio.h>],
787 [printf("Hello World\n");],
790 AC_MSG_RESULT([$_results])
791 if test "$_results" = "no"; then
792 AC_MSG_ERROR([These compiler flags are invalid: $MOZ_OPTIMIZE_FLAGS])
795 if test -n "$MOZ_LTO" -a -n "$CLANG_CC"; then
796 # When using llvm-based LTO, non numeric optimization levels are
797 # not supported by the linker, so force the linker to use -O2 (
798 # which doesn't influence the level compilation units are actually
800 case " $MOZ_OPTIMIZE_FLAGS " in
802 MOZ_OPTIMIZE_LDFLAGS="$MOZ_OPTIMIZE_LDFLAGS -O2"
807 fi # COMPILE_ENVIRONMENT
809 AC_SUBST_LIST(MOZ_OPTIMIZE_FLAGS)
810 AC_SUBST_LIST(MOZ_OPTIMIZE_LDFLAGS)
811 AC_SUBST_LIST(MOZ_PGO_OPTIMIZE_FLAGS)
813 dnl ========================================================
814 dnl = Enable jemalloc
815 dnl ========================================================
817 if test "$JS_STANDALONE" -a -z "$MOZ_MEMORY"; then
820 case "${OS_TARGET}" in
821 Android|WINNT|Darwin)
825 dnl On !Android !Windows !OSX, we only want to link executables against mozglue
826 MOZ_GLUE_IN_PROGRAM=1
827 AC_DEFINE(MOZ_GLUE_IN_PROGRAM)
832 if test "$MOZ_MEMORY"; then
835 export MOZ_NO_DEBUG_RTL=1
839 AC_SUBST(MOZ_GLUE_IN_PROGRAM)
841 dnl ========================================================
843 dnl ========================================================
844 if test -n "$MOZ_INSTRUMENTS"; then
845 LIBS="$LIBS -framework CoreFoundation"
848 dnl ========================================================
849 dnl = Enable using the clang plugin to build
850 dnl ========================================================
852 if test -n "$COMPILE_ENVIRONMENT"; then
853 MOZ_CONFIG_CLANG_PLUGIN
854 fi # COMPILE_ENVIRONMENT
858 dnl ========================================================
860 dnl = Maintainer debug option (no --enable equivalent)
862 dnl ========================================================
864 AC_SUBST_LIST(ASFLAGS)
865 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
867 AC_SUBST_LIST(MOZ_FIX_LINK_PATHS)
869 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
871 AC_SUBST(MOZ_APP_DISPLAYNAME)
873 AC_SUBST(MOZ_PKG_SPECIAL)
875 dnl Echo the CFLAGS to remove extra whitespace.
877 $_COMPILATION_CFLAGS \
881 $_COMPILATION_CXXFLAGS \
885 $_COMPILATION_ASFLAGS \
888 COMPILE_CFLAGS=`echo \
892 COMPILE_CXXFLAGS=`echo \
897 $_COMPILATION_HOST_CFLAGS \
900 HOST_CXXFLAGS=`echo \
901 $_COMPILATION_HOST_CXXFLAGS \
906 $_COMPILATION_LDFLAGS`
910 $_COMPILATION_HOST_LDFLAGS`
913 OS_CXXFLAGS="$CXXFLAGS"
914 OS_CPPFLAGS="$CPPFLAGS"
915 OS_COMPILE_CFLAGS="$COMPILE_CFLAGS"
916 OS_COMPILE_CXXFLAGS="$COMPILE_CXXFLAGS"
917 OS_LDFLAGS="$LDFLAGS"
919 AC_SUBST_LIST(OS_CFLAGS)
920 AC_SUBST_LIST(OS_CXXFLAGS)
921 AC_SUBST_LIST(OS_CPPFLAGS)
922 AC_SUBST_LIST(OS_COMPILE_CFLAGS)
923 AC_SUBST_LIST(OS_COMPILE_CXXFLAGS)
924 AC_SUBST_LIST(OS_LDFLAGS)
929 AC_SUBST_LIST(HOST_CFLAGS)
930 AC_SUBST_LIST(HOST_CPPFLAGS)
931 AC_SUBST_LIST(HOST_CXXFLAGS)
932 AC_SUBST(HOST_LDFLAGS)
933 AC_SUBST_LIST(HOST_OPTIMIZE_FLAGS)
934 AC_SUBST(HOST_BIN_SUFFIX)
936 AC_SUBST(TARGET_XPCOM_ABI)
941 AC_SUBST(WIN32_CONSOLE_EXE_LDFLAGS)
942 AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
944 dnl Set various defines and substitutions
945 dnl ========================================================
947 AC_SUBST(MOZ_DEV_EDITION)
948 if test -n "$MOZ_DEV_EDITION"; then
949 AC_DEFINE(MOZ_DEV_EDITION)
952 dnl ========================================================
954 dnl ========================================================
958 if test -n "$JS_STANDALONE"; then
959 JS_LIBRARY_NAME="mozjs-$MOZILLA_SYMBOLVERSION"
961 JS_LIBRARY_NAME="mozjs"
963 JS_CONFIG_LIBS="$NSPR_LIBS $LIBS"
964 if test -n "$GNU_CC"; then
965 JS_CONFIG_MOZ_JS_LIBS='-L${libdir} -l${JS_LIBRARY_NAME}'
967 JS_CONFIG_MOZ_JS_LIBS='${libdir}/${JS_LIBRARY_NAME}.lib'
969 AC_SUBST(JS_LIBRARY_NAME)
970 AC_SUBST(JS_CONFIG_MOZ_JS_LIBS)
971 AC_SUBST(JS_CONFIG_LIBS)
973 # Avoid using obsolete NSPR features
974 AC_DEFINE(NO_NSPR_10_SUPPORT)
976 dnl Spit out some output
977 dnl ========================================================
978 MOZ_CREATE_CONFIG_STATUS()
980 rm -fr confdefs* $ac_clean_files