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