implemented Setup.hs to build boehm cpp libs and install them;
[hs-boehmgc.git] / gc-7.2 / configure.ac
1 # Copyright (c) 1999-2001 by Red Hat, Inc. All rights reserved.
2 #
3 # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
4 # OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
5 #
6 # Permission is hereby granted to use or copy this program
7 # for any purpose,  provided the above notices are retained on all copies.
8 # Permission to modify the code and to distribute modified code is granted,
9 # provided the above notices are retained, and a notice that the code was
10 # modified is included with the above copyright notice.
11 #
12 # Original author: Tom Tromey
13 # Modified by: Grzegorz Jakacki <jakacki at acm dot org>
14
15 dnl Process this file with autoconf to produce configure.
16
17 # Initialization
18 # ==============
19
20 AC_INIT(gc,7.2,gc@linux.hpl.hp.com)
21     ## version must conform to [0-9]+[.][0-9]+(alpha[0-9]+)?
22 AC_CONFIG_SRCDIR(gcj_mlc.c)
23 AC_CONFIG_MACRO_DIR([m4])
24 AC_CANONICAL_TARGET
25 AC_PREREQ(2.64)
26 AC_REVISION($Revision: 1.69 $)
27 GC_SET_VERSION
28 AM_INIT_AUTOMAKE([foreign dist-bzip2 nostdinc])
29 AM_CONFIG_HEADER([include/private/config.h])
30 AM_MAINTAINER_MODE
31
32 AC_SUBST(PACKAGE)
33 AC_SUBST(GC_VERSION)
34
35 AM_PROG_CC_C_O
36 AC_PROG_CXX
37
38 AM_PROG_AS
39
40 AC_PROG_INSTALL
41
42 . ${srcdir}/configure.host
43
44 GC_CFLAGS=${gc_cflags}
45 AC_SUBST(GC_CFLAGS)
46
47 AC_ARG_ENABLE(threads,
48   [AC_HELP_STRING([--enable-threads=TYPE], [choose threading package])],
49   THREADS=$enableval,
50   [ AC_MSG_CHECKING([for thread model used by GCC])
51     THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
52     if test -z "$THREADS"; then
53       THREADS=no
54     fi
55     if test "$THREADS" = "posix"; then
56       case "$host" in
57         *-*-mingw*)
58           # Adjust thread model if cross-compiling for MinGW.
59           THREADS=win32
60           ;;
61       esac
62     fi
63     AC_MSG_RESULT([$THREADS]) ])
64
65 AC_ARG_ENABLE(parallel-mark,
66    [AC_HELP_STRING([--enable-parallel-mark],
67         [parallelize marking and free list construction])],
68    [case "$THREADS" in
69       no | none | single)
70         AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec])
71         ;;
72     esac ]
73 )
74
75 AC_ARG_ENABLE(cplusplus,
76     [AC_HELP_STRING([--enable-cplusplus], [install C++ support])])
77
78 dnl Features which may be selected in the following thread-detection switch.
79 AH_TEMPLATE([PARALLEL_MARK], [Define to enable parallel marking.])
80 AH_TEMPLATE([THREAD_LOCAL_ALLOC],
81             [Define to enable thread-local allocation optimisation.])
82 AH_TEMPLATE([USE_COMPILER_TLS],
83             [Define to use of compiler-support for thread-local variables.])
84
85 dnl Thread selection macros.
86 AH_TEMPLATE([GC_THREADS],           [Define to support platform-specific \
87                                      threads.])
88 AH_TEMPLATE([GC_AIX_THREADS],       [Define to support IBM AIX threads.])
89 AH_TEMPLATE([GC_DARWIN_THREADS],    [Define to support Darwin pthreads.])
90 AH_TEMPLATE([GC_FREEBSD_THREADS],   [Define to support FreeBSD pthreads.])
91 AH_TEMPLATE([GC_GNU_THREADS],       [Define to support GNU pthreads.])
92 AH_TEMPLATE([GC_HPUX_THREADS],      [Define to support HP/UX 11 pthreads.])
93 AH_TEMPLATE([GC_IRIX_THREADS],      [Define to support Irix pthreads.])
94 AH_TEMPLATE([GC_LINUX_THREADS],     [Define to support pthreads on Linux.])
95 AH_TEMPLATE([GC_NETBSD_THREADS],    [Define to support NetBSD pthreads.])
96 AH_TEMPLATE([GC_OPENBSD_THREADS],   [Define to support OpenBSD pthreads.])
97 AH_TEMPLATE([GC_OSF1_THREADS],      [Define to support Tru64 pthreads.])
98 AH_TEMPLATE([GC_SOLARIS_THREADS],   [Define to support Solaris pthreads.])
99 AH_TEMPLATE([GC_WIN32_THREADS],     [Define to support Win32 threads.])
100 AH_TEMPLATE([GC_WIN32_PTHREADS],    [Define to support win32-pthreads.])
101 AH_TEMPLATE([GC_RTEMS_PTHREADS],    [Define to support rtems-pthreads.])
102
103 dnl System header feature requests.
104 AH_TEMPLATE([_POSIX_C_SOURCE], [The POSIX feature macro.])
105 AH_TEMPLATE([_PTHREADS], [Indicates the use of pthreads (NetBSD).])
106
107 dnl GC API symbols export control.
108 AH_TEMPLATE([GC_DLL],
109         [Define to build dynamic libraries with only API symbols exposed.])
110
111 dnl Check for a flavor of supported inline keyword.
112 AC_C_INLINE
113
114 THREADDLLIBS=
115 need_atomic_ops_asm=false
116 ## Libraries needed to support dynamic loading and/or threads.
117 case "$THREADS" in
118  no | none | single)
119     THREADS=none
120     ;;
121  posix | pthreads)
122     THREADS=posix
123     AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
124     case "$host" in
125      x86-*-linux* | ia64-*-linux* | i586-*-linux* | i686-*-linux* \
126      | x86_64-*-linux* | alpha-*-linux* | sparc*-*-linux*)
127         AC_DEFINE(GC_LINUX_THREADS)
128         AC_DEFINE(_REENTRANT)
129         if test "${enable_parallel_mark}" = yes; then
130           AC_DEFINE(PARALLEL_MARK)
131         fi
132         AC_DEFINE(THREAD_LOCAL_ALLOC)
133         AC_MSG_WARN("Explicit GC_INIT() calls may be required.");
134         ;;
135      *-*-linux*)
136         AC_DEFINE(GC_LINUX_THREADS)
137         AC_DEFINE(_REENTRANT)
138         ;;
139      *-*-aix*)
140         AC_DEFINE(GC_AIX_THREADS)
141         AC_DEFINE(_REENTRANT)
142         ;;
143      *-*-hpux11*)
144         AC_MSG_WARN("Only HP/UX 11 POSIX threads are supported.")
145         AC_DEFINE(GC_HPUX_THREADS)
146         AC_DEFINE(_POSIX_C_SOURCE,199506L)
147         if test "${enable_parallel_mark}" = yes; then
148           AC_DEFINE(PARALLEL_MARK)
149         fi
150         AC_DEFINE(THREAD_LOCAL_ALLOC)
151         AC_MSG_WARN("Explicit GC_INIT() calls may be required.");
152         THREADDLLIBS="-lpthread -lrt"
153         # HPUX needs REENTRANT for the _r calls.
154         AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads.])
155         ;;
156      *-*-hpux10*)
157         AC_MSG_WARN("Only HP-UX 11 POSIX threads are supported.")
158         ;;
159      *-*-openbsd*)
160         AC_DEFINE(GC_OPENBSD_THREADS)
161         THREADDLLIBS=-pthread
162         INCLUDES="$INCLUDES -pthread"
163         openbsd_threads=true
164         ;;
165      *-*-freebsd*)
166         AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
167         AC_DEFINE(GC_FREEBSD_THREADS)
168         INCLUDES="$INCLUDES -pthread"
169         ;;
170      *-*-kfreebsd*-gnu)
171         AC_DEFINE(GC_FREEBSD_THREADS)
172         INCLUDES="$INCLUDES -pthread"
173         THREADDLLIBS=-pthread
174         AC_DEFINE(_REENTRANT)
175         if test "${enable_parallel_mark}" = yes; then
176           AC_DEFINE(PARALLEL_MARK)
177         fi
178         AC_DEFINE(THREAD_LOCAL_ALLOC)
179         AC_DEFINE(USE_COMPILER_TLS)
180         ;;
181      *-*-gnu*)
182         AC_DEFINE(GC_GNU_THREADS)
183         AC_DEFINE(_REENTRANT)
184         AC_DEFINE(THREAD_LOCAL_ALLOC)
185         ;;
186      *-*-netbsd*)
187         AC_MSG_WARN("Only on NetBSD 2.0 or later.")
188         AC_DEFINE(GC_NETBSD_THREADS)
189         AC_DEFINE(_REENTRANT)
190         AC_DEFINE(_PTHREADS)
191         THREADDLLIBS="-lpthread -lrt"
192         ;;
193      *-*-solaris*)
194         AC_DEFINE(GC_SOLARIS_THREADS)
195         if test "${enable_parallel_mark}" = yes; then
196           AC_DEFINE(PARALLEL_MARK)
197         fi
198         AC_DEFINE(THREAD_LOCAL_ALLOC)
199         # Need to use alternate thread library, otherwise gctest hangs
200         # on Solaris 8.
201         multi_os_directory=`$CC -print-multi-os-directory`
202         THREADDLLIBS="-L/usr/lib/lwp/$multi_os_directory \
203                       -R/usr/lib/lwp/$multi_os_directory -lpthread -lrt"
204         ;;
205      *-*-irix*)
206         AC_DEFINE(GC_IRIX_THREADS)
207         ;;
208      *-*-cygwin*)
209         AC_DEFINE(GC_WIN32_THREADS)
210         if test "${enable_parallel_mark}" = yes; then
211           AC_DEFINE(PARALLEL_MARK)
212         fi
213         AC_DEFINE(THREAD_LOCAL_ALLOC)
214         # Cygwin doesn't have a real libpthread, so Libtool can't link
215         # against it.
216         THREADDLLIBS=""
217         win32_threads=true
218         ;;
219      *-*-mingw*)
220         AC_DEFINE(GC_WIN32_PTHREADS)
221         # Using win32-pthreads
222         if test "${enable_parallel_mark}" = yes; then
223           AC_DEFINE(PARALLEL_MARK)
224         fi
225         AC_DEFINE(THREAD_LOCAL_ALLOC)
226         THREADDLLIBS="-lpthread"
227         win32_threads=true
228         ;;
229      *-*-darwin*)
230         AC_DEFINE(GC_DARWIN_THREADS)
231         AC_MSG_WARN("Explicit GC_INIT() calls may be required.");
232         # Parallel-mark is not well-tested on Darwin
233         if test "${enable_parallel_mark}" = yes; then
234           AC_DEFINE(PARALLEL_MARK)
235         fi
236         AC_DEFINE(THREAD_LOCAL_ALLOC)
237         darwin_threads=true
238         ;;
239      *-*-osf*)
240         AC_DEFINE(GC_OSF1_THREADS)
241         if test "${enable_parallel_mark}" = yes; then
242           AC_DEFINE(PARALLEL_MARK)
243           AC_DEFINE(THREAD_LOCAL_ALLOC)
244           AC_MSG_WARN("Explicit GC_INIT() calls may be required.");
245           # May want to enable it in other cases, too.
246           # Measurements have not yet been done.
247         fi
248         INCLUDES="$INCLUDES -pthread"
249         THREADDLLIBS="-lpthread -lrt"
250         ;;
251       *)
252         AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
253         ;;
254     esac
255     case "$host" in
256      sparc*-*-solaris*)
257         if test "$GCC" != yes; then
258           CFLAGS="$CFLAGS -O"
259           need_atomic_ops_asm=true
260         fi
261         ;;
262     esac
263     ;;
264  win32)
265     AC_DEFINE(GC_WIN32_THREADS)
266     if test "${enable_parallel_mark}" = yes; then
267       AC_DEFINE(PARALLEL_MARK)
268       AC_DEFINE(THREAD_LOCAL_ALLOC)
269     else
270       if test "${enable_shared}" != yes || test "${enable_static}" != no; then
271         # Imply THREAD_LOCAL_ALLOC unless GC_DLL.
272         AC_DEFINE(THREAD_LOCAL_ALLOC)
273       fi
274     fi
275     win32_threads=true
276     AC_DEFINE([EMPTY_GETENV_RESULTS], [1],
277               [Wine getenv may not return NULL for missing entry.])
278     ;;
279  dgux386)
280     THREADS=dgux386
281     AC_MSG_RESULT($THREADDLLIBS)
282     # Use pthread GCC switch
283     THREADDLLIBS=-pthread
284     if test "${enable_parallel_mark}" = yes; then
285         AC_DEFINE(PARALLEL_MARK)
286     fi
287     AC_DEFINE(THREAD_LOCAL_ALLOC)
288     AC_MSG_WARN("Explicit GC_INIT() calls may be required.");
289     AC_DEFINE([GC_DGUX386_THREADS], 1,
290               [Define to enable support for DB/UX threads on i386.])
291     AC_DEFINE([DGUX_THREADS], 1,
292               [Define to enable support for DB/UX threads.])
293     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
294     INCLUDES="-pthread $INCLUDES"
295     ;;
296  aix)
297     THREADS=posix
298     THREADDLLIBS=-lpthread
299     AC_DEFINE(GC_AIX_THREADS)
300     AC_DEFINE(_REENTRANT)
301     ;;
302  rtems)
303     THREADS=posix
304     AC_DEFINE(GC_RTEMS_PTHREADS)
305     AC_DEFINE(THREAD_LOCAL_ALLOC)
306     ;;
307  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
308     AC_MSG_ERROR(thread package $THREADS not yet supported)
309     ;;
310  *)
311     AC_MSG_ERROR($THREADS is an unknown thread package)
312     ;;
313 esac
314 AC_SUBST(THREADDLLIBS)
315 AM_CONDITIONAL(THREADS, test x$THREADS != xnone)
316 AM_CONDITIONAL(PTHREADS, test x$THREADS = xposix)
317 AM_CONDITIONAL(DARWIN_THREADS, test x$darwin_threads = xtrue)
318 AM_CONDITIONAL(WIN32_THREADS, test x$win32_threads = xtrue)
319 AM_CONDITIONAL(OPENBSD_THREADS, test x$openbsd_threads = xtrue)
320
321 case "$host" in
322    powerpc-*-darwin*)
323       powerpc_darwin=true
324       ;;
325 esac
326
327 AC_MSG_CHECKING(for xlc)
328 AC_TRY_COMPILE([],[
329  #ifndef __xlC__
330  # error
331  #endif
332 ], [compiler_xlc=yes], [compiler_xlc=no])
333 AC_MSG_RESULT($compiler_xlc)
334 AM_CONDITIONAL(COMPILER_XLC,test $compiler_xlc = yes)
335 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
336   # the darwin stack-frame-walking code is completely broken on xlc
337   AC_DEFINE([DARWIN_DONT_PARSE_STACK], 1, [See doc/README.macros.])
338 fi
339
340 if test "$GCC" == yes; then
341   # Disable aliasing optimization unless forced to.
342   AC_MSG_CHECKING([whether gcc supports -fno-strict-aliasing])
343   ac_cv_fno_strict_aliasing=no
344   for cflag in $CFLAGS; do
345     case "$cflag" in
346       -fstrict-aliasing)
347         # Opposite option already present
348         ac_cv_fno_strict_aliasing=skipped
349         break
350         ;;
351     esac
352   done
353   if test "$ac_cv_fno_strict_aliasing" != skipped; then
354     old_CFLAGS="$CFLAGS"
355     CFLAGS="$CFLAGS -fno-strict-aliasing"
356     AC_TRY_COMPILE([],[], [ac_cv_fno_strict_aliasing=yes], [])
357     CFLAGS="$old_CFLAGS"
358     AS_IF([test "$ac_cv_fno_strict_aliasing" = yes],
359           [CFLAGS="$CFLAGS -fno-strict-aliasing"], [])
360   fi
361   AC_MSG_RESULT($ac_cv_fno_strict_aliasing)
362 fi
363
364 case "$host" in
365 # While IRIX 6 has libdl for the O32 and N32 ABIs, it's missing for N64
366 # and unnecessary everywhere.
367   mips-sgi-irix6*) ;;
368 # We never want libdl on darwin. It is a fake libdl that just ends up making
369 # dyld calls anyway.  The same applies to Cygwin.
370   *-*-darwin*) ;;
371   *-*-cygwin*) ;;
372   *)
373     AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
374     ;;
375 esac
376
377 case "$host" in
378   *-*-hpux*)
379     avoid_cpp_lib=yes;;
380   *)
381     avoid_cpp_lib=no;
382     ;;
383 esac
384 AM_CONDITIONAL(AVOID_CPP_LIB,test $avoid_cpp_lib = yes)
385
386 # extra LD Flags which are required for targets
387 case "${host}" in
388   *-*-darwin*)
389     extra_ldflags_libgc=-Wl,-single_module
390     ;;
391 esac
392 AC_SUBST(extra_ldflags_libgc)
393
394 AC_SUBST(EXTRA_TEST_LIBS)
395
396 target_all=libgc.la
397 AC_SUBST(target_all)
398
399 dnl If the target is an eCos system, use the appropriate eCos
400 dnl I/O routines.
401 dnl FIXME: this should not be a local option but a global target
402 dnl system; at present there is no eCos target.
403 TARGET_ECOS="no"
404 AC_ARG_WITH(ecos,
405 [  --with-ecos             enable runtime eCos target support],
406 TARGET_ECOS="$with_ecos"
407 )
408
409 addobjs=
410 addlibs=
411 CXXINCLUDES=
412 case "$TARGET_ECOS" in
413    no)
414       ;;
415    *)
416       AC_DEFINE([ECOS], 1, [Define to enable eCos target support.])
417       CXXINCLUDES="-I${TARGET_ECOS}/include"
418       addobjs="$addobjs ecos.lo"
419       ;;
420 esac
421
422 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
423
424 AC_SUBST(CXX)
425
426 AC_SUBST(INCLUDES)
427 AC_SUBST(CXXINCLUDES)
428
429 # Configuration of shared libraries
430 #
431 AC_MSG_CHECKING(whether to build shared libraries)
432 AC_ENABLE_SHARED
433
434 case "$host" in
435  alpha-*-openbsd*)
436      enable_shared=no
437      ;;
438  *)
439      ;;
440 esac
441
442 AC_MSG_RESULT($enable_shared)
443
444 # Compile with GC_DLL defined unless building static libraries.
445 if test "${enable_shared}" == yes; then
446   if test "${enable_static}" == no; then
447     AC_DEFINE(GC_DLL)
448     # FIXME: Also pass -fvisibility=hidden option if GCC v4+ and not Win32.
449   fi
450 fi
451
452 # Configuration of machine-dependent code
453 #
454 AC_MSG_CHECKING(which machine-dependent code should be used)
455 machdep=
456 case "$host" in
457  alpha-*-openbsd*)
458     machdep="mach_dep.lo"
459     if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
460        AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
461     fi
462     ;;
463  alpha*-*-linux*)
464     machdep="mach_dep.lo"
465     ;;
466  i?86-*-solaris2.[[89]])
467     # PROC_VDB appears to work in 2.8 and 2.9 but not in 2.10+ (for now).
468     AC_DEFINE([SOLARIS25_PROC_VDB_BUG_FIXED], 1,
469               [See the comment in gcconfig.h.])
470     ;;
471  mipstx39-*-elf*)
472     machdep="mach_dep.lo"
473     ;;
474  mips-dec-ultrix*)
475     machdep="mach-dep.lo"
476     ;;
477  mips-nec-sysv*|mips-unknown-sysv*)
478     ;;
479  mips*-*-linux*)
480     ;;
481  mips-*-*)
482     machdep="mach_dep.lo"
483     dnl AC_DEFINE(NO_EXECUTE_PERMISSION)
484     dnl This is now redundant, but it is also important for incremental GC
485     dnl performance under Irix.
486     ;;
487  sparc*-*-linux*)
488     machdep="mach_dep.lo sparc_mach_dep.lo"
489     ;;
490  sparc-*-netbsd*)
491     machdep="mach_dep.lo sparc_netbsd_mach_dep.lo"
492     ;;
493  sparc64-*-netbsd*)
494     machdep="mach_dep.lo sparc_mach_dep.lo"
495     ;;
496  sparc*-*-openbsd*)
497     machdep="mach_dep.lo sparc_mach_dep.lo"
498     ;;
499  sparc-sun-solaris2.3)
500     machdep="mach_dep.lo sparc_mach_dep.lo"
501     AC_DEFINE(SUNOS53_SHARED_LIB, 1,
502               [Define to work around a Solaris 5.3 bug (see dyn_load.c).])
503     ;;
504  sparc*-sun-solaris2*)
505     machdep="mach_dep.lo sparc_mach_dep.lo"
506     ;;
507  ia64-*-*)
508     machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
509     ;;
510 esac
511 if test x"$machdep" = x; then
512 AC_MSG_RESULT($machdep)
513    machdep="mach_dep.lo"
514 fi
515 addobjs="$addobjs $machdep"
516 AC_SUBST(addobjs)
517 AC_SUBST(addlibs)
518
519 AC_PROG_LIBTOOL
520
521 dnl We use these options to decide which functions to include.
522 AC_ARG_WITH(target-subdir,
523 [  --with-target-subdir=SUBDIR
524                           configuring with a cross compiler])
525 AC_ARG_WITH(cross-host,
526 [  --with-cross-host=HOST  configuring with a cross compiler])
527
528 # automake wants to see AC_EXEEXT.  But we don't need it.  And having
529 # it is actually a problem, because the compiler we're passed can't
530 # necessarily do a full link.  So we fool automake here.
531 if false; then
532   # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
533   # to nothing, so nothing would remain between `then' and `fi' if it
534   # were not for the `:' below.
535   :
536   AC_EXEEXT
537 fi
538
539 dnl As of 4.13a2, the collector will not properly work on Solaris when
540 dnl built with gcc and -O.  So we remove -O in the appropriate case.
541 dnl Not needed anymore on Solaris.
542 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
543 case "$host" in
544  *aix*)
545     if test "$GCC" = yes; then
546        AC_MSG_RESULT(yes)
547        new_CFLAGS=
548        for i in $CFLAGS; do
549           case "$i" in
550            -O*)
551               ;;
552            *)
553               new_CFLAGS="$new_CFLAGS $i"
554               ;;
555           esac
556        done
557        CFLAGS="$new_CFLAGS"
558     else
559        AC_MSG_RESULT(no)
560     fi
561     ;;
562  *) AC_MSG_RESULT(no) ;;
563 esac
564
565 dnl Include defines that have become de facto standard.
566 dnl ALL_INTERIOR_POINTERS and NO_EXECUTE_PERMISSION can be overridden in the startup code.
567 AC_DEFINE([NO_EXECUTE_PERMISSION], [1],
568           [Define to make the collector not allocate executable memory by default.])
569 AC_DEFINE([ALL_INTERIOR_POINTERS], [1],
570           [Define to recognise all pointers to the interior of objects.])
571
572
573 dnl Interface Selection
574 dnl -------------------
575 dnl
576 dnl By default, make the library as general as possible.
577 dnl enable_gcj_support=no
578 AC_ARG_ENABLE(gcj-support,
579     [AC_HELP_STRING([--disable-gcj-support],
580         [Disable support for gcj.])])
581 AM_CONDITIONAL(ENABLE_GCJ_SUPPORT,
582     [test x"$enable_gcj_support" != xno])
583 if test x"$enable_gcj_support" != xno; then
584     AC_DEFINE(GC_GCJ_SUPPORT, 1, [Define to include support for gcj.])
585 fi
586
587 dnl Debugging
588 dnl ---------
589
590 AH_TEMPLATE([GC_HAVE_BUILTIN_BACKTRACE],
591             [Define if backtrace information is supported.])
592 AH_TEMPLATE([MAKE_BACK_GRAPH], [See doc/README.macros.])
593 AH_TEMPLATE([SAVE_CALL_COUNT],
594             [The number of caller frames saved when allocating with the
595              debugging API.])
596 UNWINDLIBS=
597 AC_ARG_ENABLE(gc-debug,
598 [AC_HELP_STRING([--enable-gc-debug],
599     [include full support for pointer backtracing etc.])],
600 [ if test "$enable_gc_debug" = "yes"; then
601     AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.")
602     AC_DEFINE([KEEP_BACK_PTRS], 1,
603               [Define to save back-pointers in debugging headers.])
604     keep_back_ptrs=true
605     AC_DEFINE([DBG_HDRS_ALL], 1,
606               [Define to force debug headers on all objects.])
607     case $host in
608       ia64-*-linux* )
609         AC_DEFINE(MAKE_BACK_GRAPH)
610         AC_DEFINE(SAVE_CALL_COUNT, 8)
611         AC_CHECK_LIB(unwind, backtrace, [
612           AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
613           UNWINDLIBS=-lunwind
614           AC_MSG_WARN("Client code may need to link against libunwind.")
615         ])
616       ;;
617       x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
618         AC_DEFINE(MAKE_BACK_GRAPH)
619         AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
620         AC_DEFINE(SAVE_CALL_COUNT, 8)
621       ;;
622       i[3456]86-*-dgux*)
623         AC_DEFINE(MAKE_BACK_GRAPH)
624       ;;
625     esac ]
626   fi)
627 AM_CONDITIONAL([KEEP_BACK_PTRS], [test x"$keep_back_ptrs" = xtrue])
628
629 # Check for AViiON Machines running DGUX
630 ac_is_dgux=no
631 AC_CHECK_HEADER(sys/dg_sys_info.h,
632 [ac_is_dgux=yes;])
633
634     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
635 if test $ac_is_dgux = yes; then
636     dgux_spec_opts="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
637     CFLAGS="$dgux_spec_opts $CFLAGS"
638     CXXFLAGS="$dgux_spec_opts $CXXFLAGS"
639     if test "$enable_gc_debug" = "yes"; then
640       CFLAGS="-g -mstandard $CFLAGS"
641       CXXFLAGS="-g -mstandard $CXXFLAGS"
642     fi
643     AC_SUBST(CFLAGS)
644     AC_SUBST(CXXFLAGS)
645 fi
646
647 AC_ARG_ENABLE(java-finalization,
648     [AC_HELP_STRING([--disable-java-finalization],
649         [Disable support for java finalization.])])
650 if test x"$enable_java_finalization" != xno; then
651     AC_DEFINE([JAVA_FINALIZATION], 1, [See doc/README.macros.])
652 fi
653
654 AC_ARG_ENABLE(atomic-uncollectable,
655     [AC_HELP_STRING([--disable-atomic-uncollectible],
656         [Disable support for atomic uncollectible allocation.])])
657 if test x"$enable_atomic_uncollectible" != x"no"; then
658     AC_DEFINE(ATOMIC_UNCOLLECTABLE, 1,
659         [Define to enable atomic uncollectible allocation.])
660 fi
661
662 AC_ARG_ENABLE(redirect-malloc,
663     [AC_HELP_STRING([--enable-redirect-malloc],
664         [Redirect malloc and friends to GC routines])])
665
666 if test "${enable_redirect_malloc}" = yes; then
667     if test "${enable_gc_debug}" = yes; then
668         AC_DEFINE([REDIRECT_MALLOC], GC_debug_malloc_replacement,
669                   [If defined, redirect malloc to this function.])
670         AC_DEFINE([REDIRECT_REALLOC], GC_debug_realloc_replacement,
671                   [If defined, redirect GC_realloc to this function.])
672         AC_DEFINE([REDIRECT_FREE], GC_debug_free,
673                   [If defined, redirect free to this function.])
674     else
675         AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
676     fi
677     AC_DEFINE([GC_USE_DLOPEN_WRAP], 1, [See doc/README.macros.])
678 fi
679
680 AC_ARG_ENABLE(large-config,
681     [AC_HELP_STRING([--enable-large-config],
682         [Optimize for large (> 100 MB) heap or root set])])
683
684 if test "${enable_large_config}" = yes; then
685     AC_DEFINE(LARGE_CONFIG, 1, [Define to optimize for large heaps or root sets.])
686 fi
687
688 AC_ARG_ENABLE(handle-fork,
689     [AC_HELP_STRING([--enable-handle-fork],
690         [Attempt to ensure a usable collector after fork() in multi-threaded
691          programs.])])
692
693 if test "${enable_handle_fork}" = yes; then
694     AC_DEFINE(HANDLE_FORK, 1,
695               [Define to install pthread_atfork() handlers by default.])
696 elif test "${enable_handle_fork}" = no; then
697     AC_DEFINE(NO_HANDLE_FORK, 1,
698               [Prohibit installation of pthread_atfork() handlers.])
699 fi
700
701 dnl This is something of a hack.  When cross-compiling we turn off
702 dnl some functionality.  We also enable the "small" configuration.
703 dnl These is only correct when targetting an embedded system.  FIXME.
704 if test -n "${with_cross_host}"; then
705    AC_DEFINE([NO_CLOCK], 1, [Define to not use system clock (cross compiling).])
706    AC_DEFINE([SMALL_CONFIG], 1,
707              [Define to tune the collector for small heap sizes.])
708 fi
709
710 if test "$enable_gc_debug" == "no"; then
711    AC_DEFINE([NO_DEBUGGING], 1,
712              [Disable debugging, like GC_dump and its callees.])
713 fi
714
715 AC_SUBST(UNWINDLIBS)
716
717 AC_ARG_ENABLE(gc-assertions,
718     [AC_HELP_STRING([--enable-gc-assertions],
719         [collector-internal assertion checking])])
720 if test "${enable_gc_assertions}" = yes; then
721     AC_DEFINE([GC_ASSERTIONS], 1, [Define to enable internal debug assertions.])
722 fi
723
724 AC_ARG_ENABLE(munmap,
725     [AC_HELP_STRING([--enable-munmap=N],
726         [return page to the os if empty for N collections])],
727   MUNMAP_THRESHOLD=$enableval;
728    [case "$MMAP" in
729       no)
730         AC_MSG_ERROR([--enable-munmap requires --enable-mmap])
731         ;;
732     esac]
733    )
734 if test "${enable_munmap}" != ""; then
735     AC_DEFINE([USE_MMAP], 1,
736               [Define to use mmap instead of sbrk to expand the heap.])
737     AC_DEFINE([USE_MUNMAP], 1,
738               [Define to return memory to OS with munmap calls
739                (see doc/README.macros).])
740     if test "${MUNMAP_THRESHOLD}" = "yes"; then
741       MUNMAP_THRESHOLD=6
742     fi
743     AC_DEFINE_UNQUOTED([MUNMAP_THRESHOLD], [${MUNMAP_THRESHOLD}],
744         [Number of GC cycles to wait before unmapping an unused block.])
745 fi
746
747 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
748
749
750 # Atomic Ops
751 # ----------
752
753 # Do we want to use an external libatomic_ops?  By default use it if it's
754 # found.
755 AC_ARG_WITH([libatomic-ops],
756     [AS_HELP_STRING([--with-libatomic-ops[=yes|no|check]],
757                     [Use a external libatomic_ops? (default: check)])],
758     [], [with_libatomic_ops=check])
759
760 # Check for an external libatomic_ops if the answer was yes or check.  If not
761 # found, fail on yes, and convert check to no.
762 AS_IF([test x"$with_libatomic_ops" != xno],
763   [ PKG_CHECK_MODULES([ATOMIC_OPS], [atomic_ops], [],
764       [ AS_IF([test x"$with_libatomic_ops" != xcheck],
765               [AC_MSG_ERROR([A external libatomic_ops was not found.])])
766         with_libatomic_ops=no ]) ])
767
768 # If we have neither an external or an internal version, offer a useful hint
769 # and exit.
770 AS_IF([test x"$with_libatomic_ops" = xno -a ! -e "$srcdir/libatomic_ops"],
771   [ AC_MSG_ERROR([libatomic_ops is required.  You can either install it on your system, or fetch and unpack a recent version into the source directory and link or rename it to libatomic_ops.]) ])
772
773 # Finally, emit the definitions for bundled or external AO.
774 AC_MSG_CHECKING([which libatomic_ops to use])
775 AS_IF([test x"$with_libatomic_ops" != xno],
776   [ AC_MSG_RESULT([external]) ],
777   [ AC_MSG_RESULT([internal])
778     ATOMIC_OPS_CFLAGS='-I$(top_builddir)/libatomic_ops/src -I$(top_srcdir)/libatomic_ops/src'
779     ATOMIC_OPS_LIBS=""
780     AC_SUBST([ATOMIC_OPS_CFLAGS])
781     AC_CONFIG_SUBDIRS([libatomic_ops])
782   ])
783 AM_CONDITIONAL([USE_INTERNAL_LIBATOMIC_OPS],
784     [test x$with_libatomic_ops = xno -a x"$THREADS" != xnone])
785 AM_CONDITIONAL([NEED_ATOMIC_OPS_ASM],
786     [test x$with_libatomic_ops = xno -a x$need_atomic_ops_asm = xtrue])
787
788 dnl Produce the Files
789 dnl -----------------
790
791 AC_CONFIG_FILES([Makefile bdw-gc.pc])
792
793 AC_CONFIG_COMMANDS([default],,
794   [ srcdir="${srcdir}"
795     host=${host}
796     CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
797     CC="${CC}"
798     DEFS="$DEFS" ])
799
800 AC_OUTPUT