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