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