]> granicus.if.org Git - gc/blob - configure.ac
Refactoring of CMake script to use ANDROID/APPLE/CYGWIN/MSYS variables
[gc] / configure.ac
1 # Copyright (c) 1999-2001 by Red Hat, Inc. All rights reserved.
2 # Copyright (c) 2005-2009 Hewlett-Packard Development Company, L.P.
3 # Copyright (c) 2009-2019 Ivan Maidanski
4 #
5 # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
6 # OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
7 #
8 # Permission is hereby granted to use or copy this program
9 # for any purpose,  provided the above notices are retained on all copies.
10 # Permission to modify the code and to distribute modified code is granted,
11 # provided the above notices are retained, and a notice that the code was
12 # modified is included with the above copyright notice.
13
14 dnl Process this file with autoconf to produce configure.
15
16 dnl Initialization.
17 AC_INIT(gc,8.1.0,https://github.com/ivmai/bdwgc/issues)
18 dnl Version must conform to: [0-9]+[.][0-9]+[.][0-9]+
19
20 AC_CONFIG_SRCDIR(gcj_mlc.c)
21 AC_CONFIG_MACRO_DIR([m4])
22 AC_CANONICAL_TARGET
23 AC_PREREQ(2.61)
24 GC_SET_VERSION
25 AM_INIT_AUTOMAKE([foreign nostdinc subdir-objects])
26 AC_CONFIG_HEADERS([include/config.h])
27 AM_MAINTAINER_MODE
28
29 AC_SUBST(PACKAGE)
30 AC_SUBST(GC_VERSION)
31
32 AM_PROG_CC_C_O
33 AC_PROG_CXX
34 AM_PROG_AS
35 AC_PROG_INSTALL
36 LT_INIT([disable-static])
37 # Only the shared libraries are produced by default, use "--enable-static"
38 # option to override it.
39 dnl Note: If Autoconf reports that LIBTOOL (or AC_ENABLE_SHARED, or
40 dnl AC_PROG_LIBTOOL) is undefined, Libtool installation should be checked.
41
42 # Special CFLAGS to use when building
43 gc_cflags=""
44
45 # gc_use_mmap   Set to "yes" on platforms where mmap should be used instead
46 #               of sbrk. This will define USE_MMAP.
47 gc_use_mmap=""
48
49 # We should set -fexceptions if we are using gcc and might be used
50 # inside something like gcj.  This is the zeroth approximation:
51 if test :"$GCC": = :yes: ; then
52     gc_cflags="${gc_cflags} -fexceptions"
53 else
54     case "$host" in
55         hppa*-*-hpux* )
56         if test :$GCC: != :"yes": ; then
57             gc_cflags="${gc_flags} +ESdbgasm"
58         fi
59         # :TODO: actually we should check using Autoconf if
60         #     the compiler supports this option.
61         ;;
62     esac
63 fi
64
65 case "${host}" in
66   *-linux*)
67     # FIXME: This seems to be no longer needed as configured in gcconfig.h
68     #gc_use_mmap=yes
69     ;;
70 esac
71
72 #   target_optspace     --enable-target-optspace ("yes", "no", "")
73 case "${target_optspace}:${host}" in
74   yes:*)
75     gc_cflags="${gc_cflags} -Os"
76     ;;
77   :m32r-* | :d10v-* | :d30v-*)
78     gc_cflags="${gc_cflags} -Os"
79     ;;
80   no:* | :*)
81     # Nothing.
82     ;;
83 esac
84
85 # Set any host dependent compiler flags.
86 case "${host}" in
87   mips-tx39-*|mipstx39-unknown-*)
88         gc_cflags="${gc_cflags} -G 0"
89         ;;
90   *)
91         ;;
92 esac
93
94
95 GC_CFLAGS=${gc_cflags}
96 AC_SUBST(GC_CFLAGS)
97
98 dnl Extra user-defined flags to pass both to C and C++ compilers.
99 AC_SUBST([CFLAGS_EXTRA])
100
101 AC_ARG_ENABLE(threads,
102   [AC_HELP_STRING([--enable-threads=TYPE], [choose threading package])],
103   THREADS=$enableval,
104   [ AC_MSG_CHECKING([for thread model used by GCC])
105     THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
106     if test -z "$THREADS"; then
107       THREADS=no
108     fi
109     if test "$THREADS" = "posix"; then
110       case "$host" in
111         *-*-mingw*)
112           # Adjust thread model if cross-compiling for MinGW.
113           THREADS=win32
114           ;;
115       esac
116     fi
117     AC_MSG_RESULT([$THREADS]) ])
118
119 AC_ARG_ENABLE(parallel-mark,
120    [AC_HELP_STRING([--disable-parallel-mark],
121         [do not parallelize marking and free list construction])],
122    [case "$THREADS" in
123       no | none | single)
124         if test "${enable_parallel_mark}" != no; then
125           AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec])
126         fi
127         ;;
128     esac ]
129 )
130
131 AC_ARG_ENABLE(thread-local-alloc,
132    [AS_HELP_STRING([--disable-thread-local-alloc],
133         [turn off thread-local allocation optimization])],
134    [case "$THREADS" in
135       no | none | single)
136         if test "${enable_thread_local_alloc}" = yes; then
137           AC_MSG_ERROR(
138                 [Thread-local allocation requires --enable-threads=x spec])
139         fi
140         ;;
141     esac])
142
143 AC_ARG_ENABLE(threads-discovery,
144     [AS_HELP_STRING([--disable-threads-discovery],
145                     [disable threads discovery in GC])])
146 if test "${enable_threads_discovery}" = no; then
147     AC_DEFINE([GC_NO_THREADS_DISCOVERY], 1,
148               [Disable threads discovery in GC.])
149 fi
150
151 AC_ARG_ENABLE(cplusplus,
152     [AC_HELP_STRING([--enable-cplusplus], [install C++ support])])
153
154 dnl Features which may be selected in the following thread-detection switch.
155 AH_TEMPLATE([PARALLEL_MARK], [Define to enable parallel marking.])
156 AH_TEMPLATE([THREAD_LOCAL_ALLOC],
157             [Define to enable thread-local allocation optimization.])
158 AH_TEMPLATE([USE_COMPILER_TLS],
159             [Define to use of compiler-support for thread-local variables.])
160
161 dnl Thread selection macros.
162 AH_TEMPLATE([GC_THREADS],           [Define to support platform-specific
163                                      threads.])
164 AH_TEMPLATE([GC_WIN32_PTHREADS],
165                 [Define to support pthreads-win32 or winpthreads.])
166
167 dnl System header feature requests.
168 AH_TEMPLATE([_POSIX_C_SOURCE], [The POSIX feature macro.])
169 AH_TEMPLATE([_PTHREADS], [Indicates the use of pthreads (NetBSD).])
170
171 dnl Win32-specific API usage controls.
172 AH_TEMPLATE([GC_UNDERSCORE_STDCALL],
173         [Explicitly prefix exported/imported WINAPI symbols with '_'.])
174 AH_TEMPLATE([UNICODE],
175         [Use Unicode (W) variant of Win32 API instead of ASCII (A) one.])
176
177 dnl GC API symbols export control.
178 AH_TEMPLATE([GC_DLL],
179         [Define to build dynamic libraries with only API symbols exposed.])
180
181 dnl Check for a flavor of supported inline keyword.
182 old_CFLAGS="$CFLAGS"
183 CFLAGS="$CFLAGS $CFLAGS_EXTRA"
184 AC_C_INLINE
185 CFLAGS="$old_CFLAGS"
186
187 THREADDLLIBS=
188 need_atomic_ops_asm=false
189 use_parallel_mark=no
190 use_thread_local_alloc=no
191 # Libraries needed to support dynamic loading and/or threads.
192 case "$THREADS" in
193  no | none | single)
194     THREADS=none
195     ;;
196  posix | pthreads)
197     THREADS=posix
198     default_threadlibs=false
199     # Common defines for most POSIX platforms.
200     case "$host" in
201       *-*-aix* | *-*-android* | *-*-cygwin* | *-*-darwin* | *-*-dragonfly* | \
202       *-*-freebsd* | *-*-haiku* | *-*-hpux11* | *-*-irix* | \
203       *-*-kfreebsd*-gnu | *-*-gnu* | *-*-*linux* | *-*-msys* | *-*-nacl* | \
204       *-*-netbsd* | *-*-openbsd* | *-*-osf* | *-*-solaris*)
205         AC_DEFINE(GC_THREADS)
206         AC_DEFINE([_REENTRANT], [1],
207                   [Required define if using POSIX threads.])
208         use_parallel_mark=$enable_parallel_mark
209         use_thread_local_alloc=$enable_thread_local_alloc
210         default_threadlibs=true
211         AC_MSG_WARN("Explicit GC_INIT() calls may be required.")
212         ;;
213     esac
214     AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
215     case "$host" in
216       *-*-hpux11*)
217         AC_MSG_WARN("Only HP/UX 11 POSIX threads are supported.")
218         AC_DEFINE(_POSIX_C_SOURCE,199506L)
219         THREADDLLIBS="-lpthread -lrt"
220         # HPUX needs REENTRANT for the _r calls.
221         ;;
222       *-*-openbsd*)
223         AM_CFLAGS="$AM_CFLAGS -pthread"
224         THREADDLLIBS=-pthread
225         ;;
226       *-*-freebsd*)
227         AM_CFLAGS="$AM_CFLAGS -pthread"
228         ;;
229       *-*-kfreebsd*-gnu)
230         AM_CFLAGS="$AM_CFLAGS -pthread"
231         THREADDLLIBS=-pthread
232         ;;
233       *-*-gnu*) # E.g. linux but excluding kfreebsd.
234         # The default THREADDLLIBS.
235         ;;
236       *-*-netbsd*)
237         AC_MSG_WARN("Only on NetBSD 2.0 or later.")
238         AC_DEFINE(_PTHREADS)
239         THREADDLLIBS="-lpthread -lrt"
240         ;;
241       *-*-solaris*)
242         THREADDLLIBS="-lpthread -lrt"
243         ;;
244       *-*-cygwin* | *-*-msys*)
245         # Cygwin doesn't have a real libpthread, so Libtool can't link
246         # against it.
247         THREADDLLIBS=""
248         win32_threads=true
249         ;;
250       *-*-mingw*)
251         AC_DEFINE(GC_WIN32_PTHREADS)
252         # Using pthreads-win32 (or other non-Cygwin pthreads) library.
253         THREADDLLIBS="-lpthread"
254         use_parallel_mark=$enable_parallel_mark
255         use_thread_local_alloc=$enable_thread_local_alloc
256         win32_threads=true
257         ;;
258       *-*-darwin*)
259         darwin_threads=true
260         ;;
261       *-*-osf*)
262         AM_CFLAGS="$AM_CFLAGS -pthread"
263         THREADDLLIBS="-lpthread -lrt"
264         ;;
265       *)
266         AS_IF([test x$default_threadlibs != xtrue],
267               [ AC_MSG_ERROR(
268                     [Pthreads not supported by the GC on this platform]) ])
269         # The default THREADDLLIBS.
270         ;;
271     esac
272     case "$host" in
273       sparc*-*-solaris*)
274         if test "$GCC" != yes; then
275           need_atomic_ops_asm=true
276         fi
277         ;;
278     esac
279     ;;
280  win32)
281     AC_DEFINE(GC_THREADS)
282     use_parallel_mark=$enable_parallel_mark
283     if test "${enable_parallel_mark}" != no \
284             -o "${enable_shared}" != yes -o "${enable_static}" != no; then
285       # Imply THREAD_LOCAL_ALLOC unless GC_DLL.
286       use_thread_local_alloc=$enable_thread_local_alloc
287     fi
288     if test "${enable_win32_dllmain}" = yes; then
289       AC_DEFINE(GC_INSIDE_DLL, 1,
290                 [Enable Win32 DllMain-based approach of threads registering.])
291     fi
292     win32_threads=true
293     AC_DEFINE([EMPTY_GETENV_RESULTS], [1],
294               [Wine getenv may not return NULL for missing entry.])
295     ;;
296  dgux386)
297     AC_DEFINE(GC_THREADS)
298     THREADS=dgux386
299     AC_MSG_RESULT($THREADDLLIBS)
300     # Use pthread GCC switch
301     THREADDLLIBS=-pthread
302     use_parallel_mark=$enable_parallel_mark
303     use_thread_local_alloc=$enable_thread_local_alloc
304     AC_MSG_WARN("Explicit GC_INIT() calls may be required.")
305     AM_CFLAGS="-pthread $AM_CFLAGS"
306     ;;
307  aix)
308     THREADS=posix
309     THREADDLLIBS=-lpthread
310     AC_DEFINE(GC_THREADS)
311     AC_DEFINE(_REENTRANT)
312     use_parallel_mark=$enable_parallel_mark
313     use_thread_local_alloc=$enable_thread_local_alloc
314     ;;
315  rtems)
316     THREADS=posix
317     AC_DEFINE(GC_THREADS)
318     use_parallel_mark=$enable_parallel_mark
319     use_thread_local_alloc=$enable_thread_local_alloc
320     ;;
321  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
322     AC_MSG_ERROR(thread package $THREADS not yet supported)
323     ;;
324  *)
325     AC_MSG_ERROR($THREADS is an unknown thread package)
326     ;;
327 esac
328 AC_SUBST(THREADDLLIBS)
329 AM_CONDITIONAL(THREADS, test x$THREADS != xnone)
330 AM_CONDITIONAL(PTHREADS, test x$THREADS = xposix)
331 AM_CONDITIONAL(DARWIN_THREADS, test x$darwin_threads = xtrue)
332 AM_CONDITIONAL(WIN32_THREADS, test x$win32_threads = xtrue)
333
334 compiler_suncc=no
335 pthread_start_standalone=no
336 case "$host" in
337   *-*-*linux*)
338       # Turn on the workaround described in pthread_start.c.
339       AS_IF([test "$THREADS" = posix], [pthread_start_standalone=yes])
340       ;;
341   powerpc-*-darwin*)
342       powerpc_darwin=true
343       ;;
344   *-*-solaris*)
345       if test "$GCC" != yes; then
346         # Solaris SunCC
347         compiler_suncc=yes
348         CFLAGS="-O $CFLAGS"
349       fi
350       ;;
351   *-*-wince*)
352       if test "$enable_gc_debug" != "no"; then
353         AC_DEFINE([GC_READ_ENV_FILE], 1,
354                   [Read environment variables from the GC 'env' file.])
355       fi
356       ;;
357 esac
358 AM_CONDITIONAL(PTHREAD_START_STANDALONE,
359                test x$pthread_start_standalone = xyes)
360
361 if test "$GCC" = yes; then
362   # Output all warnings.
363   AC_MSG_CHECKING([whether compiler supports -Wextra])
364   old_CFLAGS="$CFLAGS"
365   CFLAGS="-Wextra $CFLAGS"
366   AC_TRY_COMPILE([],[], [ac_cv_cc_wextra=yes], [ac_cv_cc_wextra=no])
367   CFLAGS="$old_CFLAGS"
368   AC_MSG_RESULT($ac_cv_cc_wextra)
369   AS_IF([test "$ac_cv_cc_wextra" = yes], [WEXTRA="-Wextra"], [WEXTRA="-W"])
370   AC_MSG_CHECKING([whether compiler supports -Wpedantic])
371   CFLAGS="-Wpedantic -Wno-long-long $CFLAGS"
372   AC_TRY_COMPILE([],[
373     extern int quiet;
374   ], [ac_cv_cc_pedantic=yes], [ac_cv_cc_pedantic=no])
375   CFLAGS="$old_CFLAGS"
376   AC_MSG_RESULT($ac_cv_cc_pedantic)
377   WPEDANTIC=
378   AS_IF([test "$ac_cv_cc_pedantic" = yes],
379         [WPEDANTIC="-Wpedantic -Wno-long-long"])
380   CFLAGS="-Wall $WEXTRA $WPEDANTIC $CFLAGS"
381   CXXFLAGS="-Wall $WEXTRA $WPEDANTIC $CXXFLAGS"
382 fi
383
384 AC_MSG_CHECKING(for xlc)
385 AC_TRY_COMPILE([],[
386  #ifndef __xlC__
387  # error
388  #endif
389 ], [compiler_xlc=yes], [compiler_xlc=no])
390 AC_MSG_RESULT($compiler_xlc)
391 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
392   # the darwin stack-frame-walking code is completely broken on xlc
393   AC_DEFINE([DARWIN_DONT_PARSE_STACK], 1, [See doc/README.macros.])
394 fi
395
396 # XLC neither requires nor tolerates the unnecessary assembler goop.
397 # Similar for the Sun C compiler.
398 AM_CONDITIONAL([ASM_WITH_CPP_UNSUPPORTED],
399     [test $compiler_xlc = yes -o $compiler_suncc = yes])
400
401 if test "$GCC" = yes; then
402   # Disable aliasing optimization unless forced to.
403   AC_MSG_CHECKING([whether compiler supports -fno-strict-aliasing])
404   ac_cv_fno_strict_aliasing=no
405   for cflag in $CFLAGS; do
406     case "$cflag" in
407       -fstrict-aliasing)
408         # Opposite option already present
409         ac_cv_fno_strict_aliasing=skipped
410         break
411         ;;
412     esac
413   done
414   if test "$ac_cv_fno_strict_aliasing" != skipped; then
415     old_CFLAGS="$CFLAGS"
416     CFLAGS="$CFLAGS -fno-strict-aliasing"
417     AC_TRY_COMPILE([],[], [ac_cv_fno_strict_aliasing=yes], [])
418     CFLAGS="$old_CFLAGS"
419     AS_IF([test "$ac_cv_fno_strict_aliasing" = yes],
420           [CFLAGS="$CFLAGS -fno-strict-aliasing"], [])
421   fi
422   AC_MSG_RESULT($ac_cv_fno_strict_aliasing)
423 fi
424
425 # Check for getcontext (uClibc can be configured without it, for example)
426 AC_CHECK_FUNC([getcontext], [],
427     [ AC_DEFINE([NO_GETCONTEXT], [1], [Missing getcontext function.]) ])
428
429 # Check whether dl_iterate_phdr exists (as a strong symbol).
430 AC_CHECK_FUNCS([dl_iterate_phdr])
431
432 case "$host" in
433 # While IRIX 6 has libdl for the O32 and N32 ABIs, it's missing for N64
434 # and unnecessary everywhere.
435   mips-sgi-irix6*) ;;
436 # We never want libdl on darwin. It is a fake libdl that just ends up making
437 # dyld calls anyway.  The same applies to Cygwin.
438   *-*-cygwin* | *-*-darwin* | *-*-msys*)
439     ;;
440   *)
441     AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
442     ;;
443 esac
444
445 case "$host" in
446   *-*-hpux*)
447     avoid_cpp_lib=yes;;
448   *)
449     avoid_cpp_lib=no;
450     ;;
451 esac
452 AM_CONDITIONAL(AVOID_CPP_LIB,test $avoid_cpp_lib = yes)
453
454 # Check for various headers.
455 AC_CHECK_HEADER([execinfo.h], [],
456     [ AC_DEFINE([GC_MISSING_EXECINFO_H], [1], [Missing execinfo.h header.]) ])
457
458 # extra LD Flags which are required for targets
459 case "${host}" in
460   *-*-darwin*)
461     extra_ldflags_libgc=-Wl,-single_module
462     ;;
463 esac
464 AC_SUBST(extra_ldflags_libgc)
465
466 AC_SUBST(EXTRA_TEST_LIBS)
467
468 target_all=libgc.la
469 AC_SUBST(target_all)
470
471 dnl If the target is an eCos system, use the appropriate eCos
472 dnl I/O routines.
473 dnl FIXME: this should not be a local option but a global target
474 dnl system; at present there is no eCos target.
475 TARGET_ECOS="no"
476 AC_ARG_WITH(ecos,
477 [  --with-ecos             enable runtime eCos target support],
478 TARGET_ECOS="$with_ecos"
479 )
480
481 addobjs=
482 addlibs=
483 CXXLIBS=
484
485 case "$TARGET_ECOS" in
486    no)
487       ;;
488    *)
489       AC_DEFINE([ECOS], 1, [Define to enable eCos target support.])
490       AM_CPPFLAGS="-I${TARGET_ECOS}/include $AM_CPPFLAGS"
491       addobjs="$addobjs ecos.lo"
492       ;;
493 esac
494
495 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
496
497 if test "$GCC" = yes; then
498   if test "${enable_cplusplus}" = yes; then
499     case "$host" in
500       *-*-cygwin* | *-*-mingw* | *-*-msys*)
501         AC_MSG_CHECKING([whether libsupc++ required])
502         SUPC="`$CXX -print-file-name=libsupc++.a 2>/dev/null`"
503         if test -n "$SUPC" -a "$SUPC" != "libsupc++.a"; then
504           AC_MSG_RESULT(yes)
505           CXXLIBS="-lsupc++"
506         else
507           AC_MSG_RESULT(no)
508         fi
509         ;;
510     esac
511   fi
512 fi
513
514 AC_SUBST(CXX)
515 AC_SUBST(AM_CFLAGS)
516 AC_SUBST(AM_CPPFLAGS)
517 AC_SUBST(CXXLIBS)
518
519 # Configuration of shared libraries
520 #
521 AC_MSG_CHECKING(whether to build shared libraries)
522 AC_ENABLE_SHARED
523
524 case "$host" in
525  alpha-*-openbsd*)
526      enable_shared=no
527      ;;
528  *)
529      ;;
530 esac
531
532 AC_MSG_RESULT($enable_shared)
533
534 # Compile with GC_DLL defined unless building static libraries.
535 if test "${enable_shared}" != no -a "${enable_static}" != yes; then
536     AC_DEFINE(GC_DLL)
537     if test "$GCC" = yes; then
538       # Pass -fvisibility=hidden option if supported
539       AC_MSG_CHECKING([whether compiler supports -fvisibility])
540       old_CFLAGS="$CFLAGS"
541       CFLAGS="-Werror -fvisibility=hidden $CFLAGS"
542       AC_TRY_COMPILE([],[], [ac_cv_fvisibility_hidden=yes],
543                      [ac_cv_fvisibility_hidden=no])
544       CFLAGS="$old_CFLAGS"
545       AS_IF([test "$ac_cv_fvisibility_hidden" = yes],
546             [CFLAGS="-DGC_VISIBILITY_HIDDEN_SET -fvisibility=hidden $CFLAGS"],
547             [CFLAGS="-DGC_NO_VISIBILITY $CFLAGS"])
548       AC_MSG_RESULT($ac_cv_fvisibility_hidden)
549     fi
550 else
551
552   case "$host" in
553     *-*-cygwin* | *-*-mingw* | *-*-msys*)
554       # Do not require the clients to link with "user32" system library.
555       AC_DEFINE([DONT_USE_USER32_DLL], 1,
556                 [Do not use user32.dll import library (Win32).])
557       # Use inline version of GC new and delete operators in test_cpp
558       # otherwise the system ones might be used instead because of arbitrary
559       # ordering of object files when linking.
560       CXXFLAGS="$CXXFLAGS -DGC_NOT_DLL"
561       ;;
562   esac
563 fi
564
565 # Configuration of machine-dependent code
566 #
567 AC_MSG_CHECKING(which machine-dependent code should be used)
568 machdep=
569 case "$host" in
570  alpha-*-openbsd*)
571     if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
572        AC_MSG_WARN(
573          "OpenBSD/Alpha without dlopen(). Shared library support is disabled.")
574     fi
575     ;;
576  i?86-*-solaris2.[[89]])
577     # PROC_VDB appears to work in 2.8 and 2.9 but not in 2.10+ (for now).
578     AC_DEFINE([SOLARIS25_PROC_VDB_BUG_FIXED], 1,
579               [See the comment in gcconfig.h.])
580     ;;
581  mips-*-*)
582     dnl AC_DEFINE(NO_EXECUTE_PERMISSION)
583     dnl This is now redundant, but it is also important for incremental GC
584     dnl performance under Irix.
585     ;;
586  sparc-*-netbsd*)
587     machdep="sparc_netbsd_mach_dep.lo"
588     ;;
589  sparc*-*-linux* | sparc*-*-openbsd* | sparc64-*-freebsd* | sparc64-*-netbsd*)
590     machdep="sparc_mach_dep.lo"
591     ;;
592  sparc-sun-solaris2.3)
593     machdep="sparc_mach_dep.lo"
594     AC_DEFINE(SUNOS53_SHARED_LIB, 1,
595               [Define to work around a Solaris 5.3 bug (see dyn_load.c).])
596     ;;
597  sparc*-sun-solaris2*)
598     machdep="sparc_mach_dep.lo"
599     ;;
600  ia64-*-*)
601     machdep="ia64_save_regs_in_stack.lo"
602     ;;
603  *-*-nacl*)
604     AC_DEFINE(NO_EXECUTE_PERMISSION)
605     ;;
606 esac
607 AC_MSG_RESULT($machdep)
608 addobjs="$addobjs $machdep"
609 AC_SUBST(addobjs)
610 AC_SUBST(addlibs)
611
612 AC_PROG_LIBTOOL
613
614 dnl We use these options to decide which functions to include.
615 AC_ARG_WITH(target-subdir,
616 [  --with-target-subdir=SUBDIR
617                           configuring with a cross compiler])
618 AC_ARG_WITH(cross-host,
619 [  --with-cross-host=HOST  configuring with a cross compiler])
620
621 dnl automake wants to see AC_EXEEXT.  But we don't need it.  And having
622 dnl it is actually a problem, because the compiler we're passed can't
623 dnl necessarily do a full link.  So we fool automake here.
624 if false; then
625   dnl autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
626   dnl to nothing, so nothing would remain between `then' and `fi' if it
627   dnl were not for the `:' below.
628   :
629   AC_EXEEXT
630 fi
631
632 dnl The collector might not properly work on IBM AIX when
633 dnl built with gcc and -O.  So we remove -O in the appropriate case.
634 AC_MSG_CHECKING(whether AIX gcc optimization fix is necessary)
635 case "$host" in
636  *aix*)
637     if test "$GCC" = yes; then
638        AC_MSG_RESULT(yes)
639        new_CFLAGS=
640        for i in $CFLAGS; do
641           case "$i" in
642            -O*)
643               ;;
644            *)
645               new_CFLAGS="$new_CFLAGS $i"
646               ;;
647           esac
648        done
649        CFLAGS="$new_CFLAGS"
650     else
651        AC_MSG_RESULT(no)
652     fi
653     ;;
654  *) AC_MSG_RESULT(no) ;;
655 esac
656
657 dnl Include defines that have become de facto standard.
658 dnl ALL_INTERIOR_POINTERS and NO_EXECUTE_PERMISSION can be overridden
659 dnl in the startup code.
660 AC_DEFINE([NO_EXECUTE_PERMISSION], [1],
661           [Define to make the collector not allocate executable memory
662            by default.])
663 AC_DEFINE([ALL_INTERIOR_POINTERS], [1],
664           [Define to recognise all pointers to the interior of objects.])
665
666
667 dnl Interface Selection
668 dnl -------------------
669 dnl
670 dnl By default, make the library as general as possible.
671 dnl enable_gcj_support=no
672 AC_ARG_ENABLE(gcj-support,
673     [AC_HELP_STRING([--disable-gcj-support], [disable support for gcj])])
674 if test x"$enable_gcj_support" != xno; then
675     AC_DEFINE(GC_GCJ_SUPPORT, 1, [Define to include support for gcj.])
676     case "$host" in
677       *-*-kfreebsd*-gnu)
678         # FIXME: For a reason, gctest hangs up on kFreeBSD if both of
679         # THREAD_LOCAL_ALLOC and GC_ENABLE_SUSPEND_THREAD are defined.
680         if test "${enable_thread_local_alloc}" = no; then
681           AC_DEFINE(GC_ENABLE_SUSPEND_THREAD)
682         fi
683         ;;
684       *)
685         AC_DEFINE([GC_ENABLE_SUSPEND_THREAD], 1,
686               [Define to turn on GC_suspend_thread support.])
687         ;;
688     esac
689 fi
690
691 dnl Interaction with other programs that might use signals.
692 AC_ARG_ENABLE(sigrt-signals,
693     [AC_HELP_STRING([--enable-sigrt-signals],
694         [force GC to use SIGRTMIN-based signals for thread suspend/resume])])
695 if test x"${enable_sigrt_signals}" = xyes; then
696     AC_DEFINE([GC_USESIGRT_SIGNALS], 1,
697               [Force the GC to use signals based on SIGRTMIN+k.])
698 fi
699
700
701 dnl Debugging
702 dnl ---------
703
704 AH_TEMPLATE([GC_HAVE_BUILTIN_BACKTRACE],
705             [Define if backtrace information is supported.])
706 AH_TEMPLATE([MAKE_BACK_GRAPH], [See doc/README.macros.])
707 AH_TEMPLATE([SAVE_CALL_COUNT],
708             [The number of caller frames saved when allocating with the
709              debugging API.])
710 UNWINDLIBS=
711 AC_ARG_ENABLE(gc-debug,
712 [AC_HELP_STRING([--enable-gc-debug],
713     [include full support for pointer backtracing etc.])],
714 [ if test "$enable_gc_debug" = "yes"; then
715     AC_MSG_WARN("Should define GC_DEBUG and use debug alloc in clients.")
716     AC_DEFINE([KEEP_BACK_PTRS], 1,
717               [Define to save back-pointers in debugging headers.])
718     keep_back_ptrs=true
719     AC_DEFINE([DBG_HDRS_ALL], 1,
720               [Define to force debug headers on all objects.])
721     AH_TEMPLATE([SHORT_DBG_HDRS],
722                 [Shorten the headers to minimize object size at the expense
723                  of checking for writes past the end (see doc/README.macros).])
724
725     case $host in
726       ia64-*-linux* )
727         AC_DEFINE(MAKE_BACK_GRAPH)
728         AC_DEFINE(SAVE_CALL_COUNT, 8)
729         AC_CHECK_LIB(unwind, backtrace, [
730           AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
731           UNWINDLIBS=-lunwind
732           AC_MSG_WARN("Client code may need to link against libunwind.")
733         ])
734       ;;
735       x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
736         AC_DEFINE(MAKE_BACK_GRAPH)
737         AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
738         AC_DEFINE(SAVE_CALL_COUNT, 8)
739       ;;
740       i[3456]86-*-dgux*)
741         AC_DEFINE(MAKE_BACK_GRAPH)
742       ;;
743     esac ]
744   fi)
745 AM_CONDITIONAL([MAKE_BACK_GRAPH], [test x"$enable_gc_debug" = xyes])
746 AM_CONDITIONAL([KEEP_BACK_PTRS], [test x"$keep_back_ptrs" = xtrue])
747
748 # Check for dladdr (used for debugging).
749 AC_MSG_CHECKING(for dladdr)
750 have_dladdr=no
751 old_CFLAGS="$CFLAGS"
752 CFLAGS="$CFLAGS $CFLAGS_EXTRA"
753 AC_TRY_COMPILE([
754 #define _GNU_SOURCE 1
755 #include <dlfcn.h>], [{
756     Dl_info info;
757     (void)dladdr("", &info);
758 }], [ have_dladdr=yes ])
759 CFLAGS="$old_CFLAGS"
760 AC_MSG_RESULT($have_dladdr)
761 if test x"$have_dladdr" = xyes; then
762   AC_DEFINE([HAVE_DLADDR], 1, [Define to use 'dladdr' function.])
763 fi
764
765 # sigsetjmp could be a macro (thus AC_CHECK_FUNCS cannot be used).
766 AC_MSG_CHECKING(for sigsetjmp)
767 old_CFLAGS="$CFLAGS"
768 CFLAGS="$CFLAGS $CFLAGS_EXTRA"
769 AC_TRY_LINK([#include <setjmp.h>],
770             [sigjmp_buf t; sigsetjmp(t, 0)],
771   [AC_MSG_RESULT(yes)],
772   [AC_MSG_RESULT(no)
773    AC_DEFINE([GC_NO_SIGSETJMP], [1], [Missing sigsetjmp function.])])
774 CFLAGS="$old_CFLAGS"
775
776 # Check for AViiON Machines running DGUX
777 ac_is_dgux=no
778 AC_CHECK_HEADER(sys/dg_sys_info.h,
779 [ac_is_dgux=yes;])
780
781 dnl :GOTCHA: we do not check anything but sys/dg_sys_info.h
782 if test $ac_is_dgux = yes; then
783     dgux_spec_opts="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
784     CFLAGS="$dgux_spec_opts $CFLAGS"
785     CXXFLAGS="$dgux_spec_opts $CXXFLAGS"
786     if test "$enable_gc_debug" = "yes"; then
787       CFLAGS="-g -mstandard $CFLAGS"
788       CXXFLAGS="-g -mstandard $CXXFLAGS"
789     fi
790     AC_SUBST(CFLAGS)
791     AC_SUBST(CXXFLAGS)
792 fi
793
794 AC_ARG_ENABLE(java-finalization,
795     [AC_HELP_STRING([--disable-java-finalization],
796                     [disable support for java finalization])])
797 if test x"$enable_java_finalization" != xno; then
798     AC_DEFINE([JAVA_FINALIZATION], 1, [See doc/README.macros.])
799 fi
800
801 AC_ARG_ENABLE(atomic-uncollectable,
802     [AC_HELP_STRING([--disable-atomic-uncollectible],
803                     [disable support for atomic uncollectible allocation])])
804 if test x"$enable_atomic_uncollectible" != x"no"; then
805     AC_DEFINE([GC_ATOMIC_UNCOLLECTABLE], 1,
806         [Define to enable atomic uncollectible allocation.])
807 fi
808
809 AC_ARG_ENABLE(redirect-malloc,
810     [AC_HELP_STRING([--enable-redirect-malloc],
811                     [redirect malloc and friends to GC routines])])
812
813 if test "${enable_redirect_malloc}" = yes; then
814     if test "${enable_gc_debug}" = yes; then
815         AC_DEFINE([REDIRECT_MALLOC], GC_debug_malloc_replacement,
816                   [If defined, redirect malloc to this function.])
817         AC_DEFINE([REDIRECT_REALLOC], GC_debug_realloc_replacement,
818                   [If defined, redirect GC_realloc to this function.])
819         AC_DEFINE([REDIRECT_FREE], GC_debug_free,
820                   [If defined, redirect free to this function.])
821     else
822         AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
823     fi
824     AC_DEFINE([GC_USE_DLOPEN_WRAP], 1, [See doc/README.macros.])
825 fi
826
827 AC_ARG_ENABLE(disclaim,
828     [AC_HELP_STRING([--disable-disclaim],
829         [disable alternative (more efficient) finalization interface])])
830 if test x"$enable_disclaim" != xno; then
831     AC_DEFINE(ENABLE_DISCLAIM, 1,
832         [Define to enable alternative finalization interface.])
833 fi
834 AM_CONDITIONAL(ENABLE_DISCLAIM,
835     [test x"$enable_disclaim" != xno])
836
837 AC_ARG_ENABLE(large-config,
838     [AC_HELP_STRING([--enable-large-config],
839         [optimize for large (> 100 MB) heap or root set])])
840 if test "${enable_large_config}" = yes; then
841     AC_DEFINE(LARGE_CONFIG, 1,
842               [Define to optimize for large heaps or root sets.])
843 fi
844
845 dnl This is something of a hack.  When cross-compiling we turn off
846 dnl some functionality.  We also enable the "small" configuration.
847 dnl These is only correct when targeting an embedded system.  FIXME.
848 if test -n "${with_cross_host}"; then
849    AC_DEFINE([NO_CLOCK], 1, [Define to not use system clock (cross compiling).])
850    AC_DEFINE([SMALL_CONFIG], 1,
851              [Define to tune the collector for small heap sizes.])
852 fi
853
854 if test "$enable_gc_debug" = "no"; then
855    AC_DEFINE([NO_DEBUGGING], 1,
856              [Disable debugging, like GC_dump and its callees.])
857 fi
858
859 AC_SUBST(UNWINDLIBS)
860
861 AC_ARG_ENABLE(gc-assertions,
862     [AC_HELP_STRING([--enable-gc-assertions],
863         [collector-internal assertion checking])])
864 if test "${enable_gc_assertions}" = yes; then
865     AC_DEFINE([GC_ASSERTIONS], 1,
866               [Define to enable internal debug assertions.])
867 fi
868
869 AC_ARG_ENABLE(mmap,
870     [AS_HELP_STRING([--enable-mmap],
871                     [use mmap instead of sbrk to expand the heap])],
872     gc_use_mmap=$enableval)
873
874 AC_ARG_ENABLE(munmap,
875     [AC_HELP_STRING([--enable-munmap=N],
876                     [return page to the OS if empty for N collections
877                      (default: 6)])],
878     MUNMAP_THRESHOLD=$enableval)
879 if test x$enable_munmap != xno; then
880     AC_DEFINE([USE_MMAP], 1,
881               [Define to use mmap instead of sbrk to expand the heap.])
882     AH_TEMPLATE([USE_WINALLOC],
883                   [Define to use Win32 VirtualAlloc (instead of sbrk or
884                    mmap) to expand the heap.])
885     AC_DEFINE([USE_MUNMAP], 1,
886               [Define to return memory to OS with munmap calls
887                (see doc/README.macros).])
888     if test x$MUNMAP_THRESHOLD = x -o x$MUNMAP_THRESHOLD = xyes; then
889       MUNMAP_THRESHOLD=6
890     fi
891     AC_DEFINE_UNQUOTED([MUNMAP_THRESHOLD], [${MUNMAP_THRESHOLD}],
892         [Number of GC cycles to wait before unmapping an unused block.])
893 else
894     if test "${gc_use_mmap}" = "yes"; then
895       AC_DEFINE([USE_MMAP], 1,
896                 [Define to use mmap instead of sbrk to expand the heap.])
897     fi
898 fi
899
900 AC_ARG_ENABLE(dynamic-loading,
901     [AS_HELP_STRING([--disable-dynamic-loading],
902                     [build the collector with disabled tracing
903                      of dynamic library data roots])])
904 if test "${enable_dynamic_loading}" = "no"; then
905   AC_DEFINE([IGNORE_DYNAMIC_LOADING], 1,
906             [Do not define DYNAMIC_LOADING even if supported (i.e., build the
907              collector with disabled tracing of dynamic library data roots).])
908 fi
909
910 AC_ARG_ENABLE(register-main-static-data,
911     [AS_HELP_STRING([--disable-register-main-static-data],
912                     [skip the initial guess of data root sets])])
913 if test "${enable_register_main_static_data}" = "no"; then
914     AC_DEFINE([GC_DONT_REGISTER_MAIN_STATIC_DATA], 1,
915               [Skip the initial guess of data root sets.])
916 fi
917
918 AC_ARG_ENABLE(checksums,
919     [AS_HELP_STRING([--enable-checksums],
920                     [report on erroneously cleared dirty bits at
921                      substantial performance cost; use only for
922                      debugging of the incremental collector])])
923 if test x$enable_checksums = xyes; then
924     if test x$enable_munmap != xno -o x$THREADS != xnone; then
925         AC_MSG_ERROR([CHECKSUMS not compatible with USE_MUNMAP or threads])
926     fi
927     AC_DEFINE([CHECKSUMS], 1,
928               [Erroneously cleared dirty bits checking.  Use only for
929                debugging of the incremental collector.])
930 fi
931 AM_CONDITIONAL([CHECKSUMS], test x$enable_checksums = xyes)
932
933 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
934
935 AC_ARG_ENABLE(werror,
936     [AS_HELP_STRING([--enable-werror], [pass -Werror to the C compiler])],
937     werror_flag=$enableval, werror_flag=no)
938 if test x$werror_flag = xyes; then
939     WERROR_CFLAGS="-Werror"
940     case "$host" in
941       # _dyld_bind_fully_image_containing_address is deprecated in OS X 10.5+
942       *-*-darwin*)
943         WERROR_CFLAGS="$WERROR_CFLAGS -Wno-deprecated-declarations"
944         ;;
945     esac
946 fi
947 AC_SUBST([WERROR_CFLAGS])
948
949 AC_ARG_ENABLE(single-obj-compilation,
950    [AC_HELP_STRING([--enable-single-obj-compilation],
951                    [compile all libgc source files into single .o
952                     (default: yes if static libraries are disabled)])],
953    [], [ AS_IF([test x"$enable_static" = xno],
954                [enable_single_obj_compilation=yes]) ])
955 AM_CONDITIONAL([SINGLE_GC_OBJ],
956                [test x"$enable_single_obj_compilation" = xyes])
957
958 AC_ARG_ENABLE(gcov,
959     [AS_HELP_STRING([--enable-gcov], [turn on code coverage analysis])])
960 if test "$enable_gcov" = "yes"; then
961   CFLAGS="$CFLAGS --coverage"
962   if test "${enable_shared}" = no; then
963     # FIXME: As of g++-4.8.4/x86_64, in case of shared library build, test_cpp
964     # linkage fails with "hidden symbol atexit is referenced by DSO" message.
965     CXXFLAGS="$CXXFLAGS --coverage"
966   fi
967   # Turn off optimization to get accurate line numbers.
968   CFLAGS=`echo "$CFLAGS" | sed -e 's/-O\(1\|2\|3\|4\|s\|fast\)\?//g'`
969   CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-O\(1\|2\|3\|4\|s\|fast\)\?//g'`
970 fi
971
972 AC_ARG_ENABLE(docs,
973         [AC_HELP_STRING([--disable-docs],
974                         [do not build and install documentation])])
975 AM_CONDITIONAL(ENABLE_DOCS, test x$enable_docs != xno)
976
977 AM_CONDITIONAL(ENABLE_SHARED, test x$enable_shared = xyes)
978
979 # Atomic Ops
980 # ----------
981
982 # Do we want to use an external libatomic_ops?  By default use it if it's
983 # found.
984 AC_ARG_WITH([libatomic-ops],
985     [AS_HELP_STRING([--with-libatomic-ops[=yes|no|check|none]],
986                     [Use an external libatomic_ops? (default: check;
987                      none: use compiler intrinsics or no thread support)])],
988     [], [ AS_IF([test x"$THREADS" != xnone],
989                 [with_libatomic_ops=check], [with_libatomic_ops=none]) ])
990
991 # Check whether compiler atomic intrinsics can be used.
992 if test x"$with_libatomic_ops" = xcheck; then
993   AC_MSG_CHECKING(for compiler intrinsics support)
994   old_CFLAGS="$CFLAGS"
995   CFLAGS="$CFLAGS $CFLAGS_EXTRA -DGC_BUILTIN_ATOMIC"
996   CFLAGS="$CFLAGS -I${srcdir}/include -I${srcdir}/tests"
997   AC_TRY_RUN([#include "test_atomic_ops.c"],
998     [AC_MSG_RESULT(yes)
999      with_libatomic_ops=none],
1000     [AC_MSG_RESULT(no)], [AC_MSG_RESULT(skipped because cross-compiling)])
1001   CFLAGS="$old_CFLAGS"
1002 fi
1003
1004 # Check for an external libatomic_ops if the above answer is "yes" or "check".
1005 # If not found, fail on "yes", and convert "check" to "no".
1006 # First, check that libatomic_ops usage is not disabled explicitly.
1007 missing_libatomic_ops=false
1008 AS_IF([test x"$with_libatomic_ops" != xno -a x"$with_libatomic_ops" != xnone],
1009   [ missing_libatomic_ops=true ])
1010
1011 dnl To avoid "syntax error near unexpected token ATOMIC_OPS" configure error
1012 dnl observed by some clients, the following 3 code lines are commented out:
1013 dnl
1014 dnl AS_IF([test x$missing_libatomic_ops = xtrue],
1015 dnl  [ PKG_CHECK_MODULES([ATOMIC_OPS], [atomic_ops],
1016 dnl    [ missing_libatomic_ops=false ], [ [] ]) ])
1017
1018 dnl Retry with AC_CHECK_HEADER if PKG_CHECK_MODULES failed.
1019 AS_IF([test x$missing_libatomic_ops = xtrue],
1020       [ AC_CHECK_HEADER([atomic_ops.h], [missing_libatomic_ops=false]) ])
1021 AS_IF([test x$missing_libatomic_ops = xtrue],
1022       [ AS_IF([test x"$with_libatomic_ops" != xcheck],
1023               [ AC_MSG_ERROR([An external libatomic_ops was not found]) ])
1024         with_libatomic_ops=no ])
1025
1026 # If we have neither an external or an internal version, offer a useful hint
1027 # and exit.
1028 AS_IF([test x"$with_libatomic_ops" = xno \
1029             -a ! -e "$srcdir/libatomic_ops/src/atomic_ops.h"],
1030   [ AC_MSG_ERROR([libatomic_ops is required.  You can either install it on
1031                   your system, or fetch and unpack a recent version into the
1032                   source directory and link or rename it to libatomic_ops.]) ])
1033
1034 # Finally, emit the definitions for bundled or external AO.
1035 AC_MSG_CHECKING([which libatomic_ops to use])
1036 AS_IF([test x"$with_libatomic_ops" != xno],
1037   [ AS_IF([test x"$with_libatomic_ops" != xnone -a x"$THREADS" != xnone],
1038           [ AC_MSG_RESULT([external])
1039             ATOMIC_OPS_LIBS="-latomic_ops"
1040             AC_SUBST([ATOMIC_OPS_LIBS]) ],
1041           [ AC_MSG_RESULT([none])
1042             AS_IF([test x"$THREADS" != xnone],
1043                   [ AC_DEFINE([GC_BUILTIN_ATOMIC], [1],
1044                               [Use C11 (GCC) atomic intrinsics instead of
1045                                libatomic_ops primitives.]) ]) ])
1046     AO_TRYLINK_CFLAGS="" ],
1047   [ AC_MSG_RESULT([internal])
1048     AO_TRYLINK_CFLAGS="-I${srcdir}/libatomic_ops/src"
1049     ATOMIC_OPS_CFLAGS='-I$(top_builddir)/libatomic_ops/src -I$(top_srcdir)/libatomic_ops/src'
1050     ATOMIC_OPS_LIBS=""
1051     AC_SUBST([ATOMIC_OPS_CFLAGS])
1052     AC_CONFIG_SUBDIRS([libatomic_ops])
1053   ])
1054 AM_CONDITIONAL([USE_INTERNAL_LIBATOMIC_OPS],
1055     [test x$with_libatomic_ops = xno -a x"$THREADS" != xnone])
1056 AM_CONDITIONAL([NEED_ATOMIC_OPS_ASM],
1057     [test x$with_libatomic_ops = xno -a x$need_atomic_ops_asm = xtrue])
1058
1059 # Check whether particular AO primitives are emulated with locks.
1060 # The check below is based on the fact that linking with the libatomic_ops
1061 # binary file is not needed in case of absence of the emulation (except for
1062 # Solaris SPARC).
1063 AS_IF([test x$with_libatomic_ops != xnone -a x$need_atomic_ops_asm != xtrue],
1064     [ old_CFLAGS="$CFLAGS"
1065       CFLAGS="$CFLAGS $AO_TRYLINK_CFLAGS $CFLAGS_EXTRA"
1066       AC_MSG_CHECKING([for lock-free AO_or primitive])
1067       AC_TRY_LINK([#include "atomic_ops.h"],
1068                   [AO_t x=0;AO_or(&x,1)],
1069         [ AC_MSG_RESULT(yes)
1070           AC_DEFINE([HAVE_LOCKFREE_AO_OR], [1],
1071             [libatomic_ops AO_or primitive implementation is lock-free.]) ],
1072         [ AC_MSG_RESULT(no) ])
1073       AC_MSG_CHECKING([for lock-free AO load/store, test-and-set primitives])
1074       AC_TRY_LINK([#include "atomic_ops.h"],
1075  [AO_t x=0;unsigned char c=0;AO_TS_t z=AO_TS_INITIALIZER;
1076   (void)AO_test_and_set_acquire(&z);AO_CLEAR(&z);AO_compiler_barrier();
1077   AO_store(&x,AO_load(&x)+1);AO_char_store(&c,AO_char_load(&c)+1);
1078   AO_store_release(&x,AO_load_acquire(&x)+1)],
1079         [ AC_MSG_RESULT(yes) ],
1080         [ AC_MSG_RESULT(no)
1081           use_thread_local_alloc=no
1082           AC_DEFINE([BASE_ATOMIC_OPS_EMULATED], [1],
1083                     [AO load, store and/or test-and-set primitives are
1084                      implemented in libatomic_ops using locks.]) ])
1085       AS_IF([test x$use_parallel_mark != xno],
1086         [ AC_MSG_CHECKING(
1087                 [for lock-free compare-and-swap and fetch-and-add primitives])
1088           AC_TRY_LINK(
1089  [#define AO_REQUIRE_CAS
1090   #include "atomic_ops.h"],
1091  [AO_t x=0;(void)AO_fetch_and_add(&x,1);(void)AO_compare_and_swap(&x,1,2)],
1092                     [ AC_MSG_RESULT(yes) ],
1093                     [ AC_MSG_RESULT(no)
1094                       use_parallel_mark=no ]) ])
1095       CFLAGS="$old_CFLAGS" ])
1096
1097 AS_IF([test x$use_parallel_mark != xno],
1098       [ AC_DEFINE(PARALLEL_MARK) ])
1099 AS_IF([test x$use_thread_local_alloc != xno],
1100       [ AC_DEFINE(THREAD_LOCAL_ALLOC) ])
1101 AM_CONDITIONAL(THREAD_LOCAL_ALLOC, test x$use_thread_local_alloc != xno)
1102
1103 AC_ARG_ENABLE(handle-fork,
1104     [ AC_HELP_STRING([--enable-handle-fork[=yes|no|auto|manual]],
1105                      [attempt to ensure a usable collector after fork()
1106                       in multi-threaded programs (default: auto;
1107                       manual: GC_atfork_prepare/parent/child should be
1108                       called by the client)]) ])
1109 if test "${enable_handle_fork}" = yes; then
1110     AC_DEFINE(HANDLE_FORK, 1,
1111               [Define to install pthread_atfork() handlers by default.])
1112 elif test "${enable_handle_fork}" = no; then
1113     AC_DEFINE(NO_HANDLE_FORK, 1,
1114               [Prohibit installation of pthread_atfork() handlers.])
1115 elif test "${enable_handle_fork}" != manual -a x$THREADS = xposix; then
1116     # If the option is omitted, pthread_atfork handlers are installed
1117     # by default for the targets where pthread_atfork is known to work.
1118     case "$host" in
1119       *-*-android*)
1120         # Android NDK does not provide pthread_atfork.
1121         ;;
1122       *-*-darwin*)
1123         # The incremental mode (which is off if parallel marking) conflicts
1124         # with fork handling on Darwin.
1125         if test x$use_parallel_mark != xno; then
1126           AC_DEFINE(HANDLE_FORK)
1127         fi
1128         ;;
1129       *-*-aix* | *-*-cygwin* | *-*-freebsd* | *-*-haiku* | \
1130       *-*-hpux11* | *-*-irix* | *-*-kfreebsd*-gnu | \
1131       *-*-*linux* | *-*-netbsd* | *-*-openbsd* | *-*-osf* | *-*-solaris*)
1132         AC_DEFINE(HANDLE_FORK)
1133         ;;
1134     esac
1135 fi
1136
1137 dnl Produce the Files
1138 dnl -----------------
1139
1140 AC_CONFIG_FILES([Makefile bdw-gc.pc])
1141
1142 AC_CONFIG_COMMANDS([default],,
1143   [ srcdir="${srcdir}"
1144     host=${host}
1145     CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
1146     CC="${CC}"
1147     DEFS="$DEFS" ])
1148
1149 AC_OUTPUT