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