* configure.ac: Define ENABLE_ESCAPE if ENABLE_SSA is defined.
[cacao.git] / src / mm / boehm-gc / configure.in
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,6.8,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: 5268 $)
26 GC_SET_VERSION
27 AM_INIT_AUTOMAKE
28
29 AM_CONFIG_HEADER([include/config.h])
30
31 AC_SUBST(PACKAGE)
32 AC_SUBST(GC_VERSION)
33
34 AC_PROG_CC
35 AC_PROG_CXX
36
37 dnl temporary set the CFLAGS for configure tests (e.g. inline keyword)
38 dnl we set it properly later in this file
39 CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
40 AC_C_INLINE
41
42 AM_PROG_AS
43 AC_CHECK_TOOL(AR, ar)
44 AC_CHECK_TOOL(RANLIB, ranlib, :)  # :)
45
46 AC_PROG_LIBTOOL
47 AC_PROG_INSTALL
48
49 AM_MAINTAINER_MODE
50
51 . [$]{srcdir}/configure.host
52
53 GC_CFLAGS=${gc_cflags}
54 AC_SUBST(GC_CFLAGS)
55
56 AC_ARG_ENABLE(boehm-threads, [  --enable-boehm-threads=TYPE   choose threading package],
57   THREADS=$enableval,
58   [ AC_MSG_CHECKING([for thread model used by GCC])
59     THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
60     if test -z "$THREADS"; then
61       THREADS=no
62     fi
63     AC_MSG_RESULT([$THREADS])])
64
65 AC_ARG_ENABLE(parallel-mark,
66 [  --enable-parallel-mark       parallelize marking and free list construction],
67    [case "$THREADS" in
68       no | none | single)
69         AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec])
70         ;;
71     esac]
72 )
73
74 AC_ARG_ENABLE(cplusplus,
75 [  --enable-cplusplus           install C++ support],
76 )
77
78 INCLUDES=-I${srcdir}/include
79 THREADDLLIBS=
80 ## Libraries needed to support dynamic loading and/or threads.
81 case "$THREADS" in
82  no | none | single)
83     THREADS=none
84     ;;
85  posix | pthreads)
86     THREADS=posix
87     THREADDLLIBS=-lpthread
88     case "$host" in
89      x86-*-linux* | ia64-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | alpha-*-linux*)
90         AC_DEFINE([GC_LINUX_THREADS], 1, [gc linux threads])
91         AC_DEFINE([_REENTRANT], 1, [reentrant])
92         if test "${enable_parallel_mark}" = yes; then
93           AC_DEFINE([PARALLEL_MARK], 1, [parallel mark])
94         fi
95         AC_DEFINE([THREAD_LOCAL_ALLOC], 1, [thread local alloc])
96         ;;
97      *-*-linux*)
98         AC_DEFINE([GC_LINUX_THREADS], 1, [gc linux threads])
99         AC_DEFINE([_REENTRANT], 1, [reentrant])
100         ;;
101      *-*-aix*)
102         AC_DEFINE([GC_AIX_THREADS], 1, [gc aix threads])
103         AC_DEFINE([_REENTRANT], 1, [reentrant])
104         ;;
105      *-*-hpux11*)
106         AC_MSG_WARN("Only HP/UX 11 POSIX threads are supported.")
107         AC_DEFINE([GC_HPUX_THREADS], 1, [gc hpux threads])
108         AC_DEFINE([_POSIX_C_SOURCE], 199506L, [posix c source])
109         if test "${enable_parallel_mark}" = yes; then
110           AC_DEFINE([PARALLEL_MARK], 1, [parallel mark])
111         fi
112         AC_DEFINE([THREAD_LOCAL_ALLOC], 1, [thread local alloc])
113         THREADDLLIBS="-lpthread -lrt"
114         # HPUX needs REENTRANT for the _r calls.
115         AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads])
116         ;;
117      *-*-hpux10*)
118         AC_MSG_WARN("Only HP-UX 11 POSIX threads are supported.")
119         ;;
120      *-*-freebsd*)
121         AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
122         AC_DEFINE([GC_FREEBSD_THREADS], 1, [gc freebsd threads])
123         INCLUDES="$INCLUDES -pthread"
124         THREADDLLIBS=-pthread
125         ;;
126      *-*-kfreebsd*-gnu)
127         AC_DEFINE([GC_FREEBSD_THREADS], 1, [gc freebsd threads])
128         INCLUDES="$INCLUDES -pthread"
129         THREADDLLIBS=-pthread
130         AC_DEFINE([_REENTRANT], 1, [reentrant])
131         if test "${enable_parallel_mark}" = yes; then
132           AC_DEFINE([PARALLEL_MARK], 1, [parallel mark])
133         fi
134         AC_DEFINE([THREAD_LOCAL_ALLOC], 1, [thread local alloc])
135         AC_DEFINE([USE_COMPILER_TLS], 1, [use compiler tls])
136         ;;
137      *-*-netbsd*)
138         AC_MSG_WARN("Only on NetBSD 2.0 or later.")
139         AC_DEFINE([GC_NETBSD_THREADS], 1, [GC NetBSD threads])
140         AC_DEFINE([_REENTRANT], 1, [reentrant])
141         AC_DEFINE([_PTHREADS], 1, [pthreads])
142         THREADDLLIBS="-lpthread -lrt"
143         ;;
144      *-*-solaris*)
145         AC_DEFINE([GC_SOLARIS_THREADS], 1, [gc solaris threads])
146         AC_DEFINE([GC_SOLARIS_PTHREADS], 1, [gc solaris pthreads])
147         ;;
148      *-*-irix*)
149         AC_DEFINE([GC_IRIX_THREADS], 1, [gc irix threads])
150         ;;
151      *-*-cygwin*)
152         AC_DEFINE([GC_WIN32_THREADS], 1, [gc win32 threads])
153         ;;
154      *-*-darwin*)
155         AC_DEFINE([GC_DARWIN_THREADS], 1, [gc darwin threads])
156         AC_DEFINE([THREAD_LOCAL_ALLOC], 1, [thread local alloc])
157         if test "${enable_parallel_mark}" = yes; then
158           AC_DEFINE([PARALLEL_MARK], 1, [parallel mark])
159         fi
160         ;;
161      *-*-osf*)
162         AC_DEFINE([GC_OSF1_THREADS], 1, [gc osf1 threads])
163         if test "${enable_parallel_mark}" = yes; then
164           AC_DEFINE([PARALLEL_MARK], 1, [parallel mark])
165           AC_DEFINE([THREAD_LOCAL_ALLOC], 1, [thread local alloc])
166           # May want to enable it in other cases, too.
167           # Measurements havent yet been done.
168         fi
169         INCLUDES="$INCLUDES -pthread"
170         THREADDLLIBS="-lpthread -lrt"
171         ;;
172       *)
173         AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
174         ;;
175     esac
176     ;;
177  win32)
178     AC_DEFINE([GC_WIN32_THREADS], 1, [gc win32 threads])
179     dnl Wine getenv may not return NULL for missing entry
180     AC_DEFINE([NO_GETENV], 1, [no getenv])
181     ;;
182  dgux386)
183     THREADS=dgux386
184     AC_MSG_RESULT($THREADDLLIBS)
185     # Use pthread GCC  switch
186     THREADDLLIBS=-pthread
187     if test "${enable_parallel_mark}" = yes; then
188         AC_DEFINE([PARALLEL_MARK], 1, [parallel mark])
189     fi
190     AC_DEFINE([THREAD_LOCAL_ALLOC], 1, [thread local alloc])
191     AC_DEFINE([GC_DGUX386_THREADS], 1, [gc dgux386 threads])
192     AC_DEFINE([DGUX_THREADS], 1, [dgux threads])
193     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
194     INCLUDES="-pthread $INCLUDES"
195     ;;
196  aix)
197     THREADS=posix
198     THREADDLLIBS=-lpthread
199     AC_DEFINE([GC_AIX_THREADS], 1, [gc aix threads])
200     AC_DEFINE([_REENTRANT], 1, [reentrant])
201     ;;
202  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
203     AC_MSG_ERROR(thread package $THREADS not yet supported)
204     ;;
205  *)
206     AC_MSG_ERROR($THREADS is an unknown thread package)
207     ;;
208 esac
209 AC_SUBST(THREADDLLIBS)
210
211 case "$host" in 
212    powerpc-*-darwin*)
213       powerpc_darwin=true
214       dnl CACAO: disable this for now
215       AC_DEFINE([DARWIN_DONT_PARSE_STACK], 1, [don't use FindTopOfStack])
216       ;;
217 esac
218 AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
219
220 AC_MSG_CHECKING(for xlc)
221 AC_TRY_COMPILE([],[
222  #ifndef __xlC__
223  # error
224  #endif
225 ], [compiler_xlc=yes], [compiler_xlc=no])
226 AC_MSG_RESULT($compiler_xlc)
227 AM_CONDITIONAL(COMPILER_XLC,test $compiler_xlc = yes)
228 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
229   # the darwin stack-frame-walking code is completely broken on xlc
230   AC_DEFINE(DARWIN_DONT_PARSE_STACK)
231 fi
232
233 # We never want libdl on darwin. It is a fake libdl that just ends up making
234 # dyld calls anyway
235 case "$host" in
236   *-*-darwin*) ;;
237   *) 
238     AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
239     ;;
240 esac
241
242 AC_SUBST(EXTRA_TEST_LIBS)
243
244 target_all=libgc.la
245 AC_SUBST(target_all)
246
247 dnl If the target is an eCos system, use the appropriate eCos
248 dnl I/O routines.
249 dnl FIXME: this should not be a local option but a global target
250 dnl system; at present there is no eCos target.
251 TARGET_ECOS="no"
252 AC_ARG_WITH(ecos,
253 [  --with-ecos             enable runtime eCos target support],
254 TARGET_ECOS="$with_ecos"
255 )
256
257 addobjs=
258 addlibs=
259 addincludes=
260 addtests=
261 CXXINCLUDES=
262 case "$TARGET_ECOS" in
263    no)
264       ;;
265    *)
266       AC_DEFINE([ECOS], 1, [ecos])
267       CXXINCLUDES="-I${TARGET_ECOS}/include"
268       addobjs="$addobjs ecos.lo"
269       ;;
270 esac
271
272 if test "${enable_cplusplus}" = yes; then
273       addincludes="$addincludes include/gc_cpp.h include/gc_allocator.h"
274       addtests="$addtests test_cpp"
275 fi
276
277 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
278
279 AC_SUBST(CXX)
280
281 AC_SUBST(INCLUDES)
282 AC_SUBST(CXXINCLUDES)
283
284 # Configuration of shared libraries
285 #
286 AC_MSG_CHECKING(whether to build shared libraries)
287 AC_ENABLE_SHARED
288
289 case "$host" in
290  alpha-*-openbsd*)
291      enable_shared=no
292      AC_MSG_RESULT(no)
293      ;;
294  *)
295      AC_MSG_RESULT(yes)
296      ;;
297 esac
298
299 # Configuration of machine-dependent code
300 #
301 AC_MSG_CHECKING(which machine-dependent code should be used) 
302 machdep=
303 case "$host" in
304  alpha-*-openbsd*)
305     machdep="alpha_mach_dep.lo"
306     if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
307        AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
308     fi
309     ;;
310  alpha*-*-linux*)
311     machdep="alpha_mach_dep.lo"
312     ;;
313  i?86-*-solaris2.[[89]] | i?86-*-solaris2.1?)
314     AC_DEFINE([SOLARIS25_PROC_VDB_BUG_FIXED], 1, [solaris 2.5 proc vdb bug fixed])
315     ;;
316  mipstx39-*-elf*)
317     machdep="mips_ultrix_mach_dep.lo"
318     AC_DEFINE([STACKBASE], __stackbase, [stackbase])
319     AC_DEFINE([DATASTART_IS_ETEXT], 1, [datastart is etext])
320     ;;
321  mips-dec-ultrix*)
322     machdep="mips_ultrix_mach-dep.lo"
323     ;;
324  mips-nec-sysv*|mips-unknown-sysv*)
325     ;;
326  mips*-*-linux*) 
327     ;; 
328  mips-*-*)
329     machdep="mips_sgi_mach_dep.lo"
330     AC_DEFINE([NO_EXECUTE_PERMISSION], 1, [no execute permission])
331     ;;
332  sparc-*-netbsd*)
333     machdep="sparc_netbsd_mach_dep.lo"
334     ;;
335  sparc-sun-solaris2.3)
336     machdep="sparc_mach_dep.lo"
337     AC_DEFINE([SUNOS53_SHARED_LIB], 1, [sun os 5.3 shared lib])
338     ;;
339  sparc*-sun-solaris2.*)
340     machdep="sparc_mach_dep.lo"
341     ;;
342  ia64-*-*)
343     machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
344     ;;
345 esac
346 if test x"$machdep" = x; then
347 AC_MSG_RESULT($machdep)
348    machdep="mach_dep.lo"
349 fi
350 addobjs="$addobjs $machdep"
351 AC_SUBST(addobjs)
352 AC_SUBST(addincludes)
353 AC_SUBST(addlibs)
354 AC_SUBST(addtests)
355
356 AC_PROG_LIBTOOL
357
358 #
359 # Check for AViiON Machines running DGUX
360 #
361 ac_is_dgux=no
362 AC_CHECK_HEADER(sys/dg_sys_info.h,
363 [ac_is_dgux=yes;])
364
365     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
366 if test $ac_is_dgux = yes; then
367     if test "$enable_full_debug" = "yes"; then
368       CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
369       CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
370     else
371       CFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
372       CXXFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
373     fi
374     AC_SUBST(CFLAGS)
375     AC_SUBST(CXXFLAGS)
376 fi
377
378 dnl We use these options to decide which functions to include.
379 AC_ARG_WITH(target-subdir,
380 [  --with-target-subdir=SUBDIR
381                           configuring with a cross compiler])
382 AC_ARG_WITH(cross-host,
383 [  --with-cross-host=HOST  configuring with a cross compiler])
384
385 # automake wants to see AC_EXEEXT.  But we don't need it.  And having
386 # it is actually a problem, because the compiler we're passed can't
387 # necessarily do a full link.  So we fool automake here.
388 if false; then
389   # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
390   # to nothing, so nothing would remain between `then' and `fi' if it
391   # were not for the `:' below.
392   :
393   AC_EXEEXT
394 fi
395
396 dnl As of 4.13a2, the collector will not properly work on Solaris when
397 dnl built with gcc and -O.  So we remove -O in the appropriate case.
398 dnl Not needed anymore on Solaris.
399 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
400 case "$host" in
401  *aix*)
402     if test "$GCC" = yes; then
403        AC_MSG_RESULT(yes)
404        new_CFLAGS=
405        for i in $CFLAGS; do
406           case "$i" in
407            -O*)
408               ;;
409            *)
410               new_CFLAGS="$new_CFLAGS $i"
411               ;;
412           esac
413        done
414        CFLAGS="$new_CFLAGS"
415     else
416        AC_MSG_RESULT(no)
417     fi
418     ;;
419  *) AC_MSG_RESULT(no) ;;
420 esac
421
422 dnl We need to override the top-level CFLAGS.  This is how we do it.
423 dnl MY_CFLAGS="$CFLAGS"
424 dnl AC_SUBST(MY_CFLAGS)
425
426 dnl pass CFLAGS to Makefiles via AM_CFLAGS
427 CFLAGS=$OPT_CFLAGS
428 AM_CFLAGS=$ARCH_CFLAGS
429 AC_SUBST(AM_CFLAGS)
430
431 dnl Include defines that have become de facto standard.
432 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
433 AC_DEFINE([SILENT], 1, [silent])
434 AC_DEFINE([NO_SIGNALS], 1, [no signals])
435 AC_DEFINE([NO_EXECUTE_PERMISSION], 1, [no exceute permission])
436 AC_DEFINE([ALL_INTERIOR_POINTERS], 1, [all interior pointers])
437
438 dnl By default, make the library as general as possible.
439 AC_DEFINE([JAVA_FINALIZATION], 1, [java finalization])
440 AC_DEFINE([GC_GCJ_SUPPORT], 1, [gc gcj support])
441 AC_DEFINE([ATOMIC_UNCOLLECTABLE], 1, [atomic uncollectable])
442
443 dnl This is something of a hack.  When cross-compiling we turn off
444 dnl some functionality.  We also enable the "small" configuration.
445 dnl These is only correct when targetting an embedded system.  FIXME.
446 if test -n "${with_cross_host}"; then
447    AC_DEFINE([NO_SIGSET], 1, [no sigset])
448    AC_DEFINE([NO_CLOCK], 1, [no clock])
449    AC_DEFINE([SMALL_CONFIG], 1, [small config])
450    AC_DEFINE([NO_DEBUGGING], 1, [no debugging])
451 fi
452
453 UNWINDLIBS=
454 AC_ARG_ENABLE(full-debug,
455 [  --enable-full-debug  include full support for pointer backtracing etc.],
456 [ if test "$enable_full_debug" = "yes"; then
457     AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.")
458     AC_DEFINE([KEEP_BACK_PTRS], 1, [keep back ptrs])
459     AC_DEFINE([DBG_HDRS_ALL], 1, [dbg hdrs all])
460     case $host in
461       ia64-*-linux* )
462         AC_DEFINE([MAKE_BACK_GRAPH], 1, [make back graph])
463         AC_DEFINE([SAVE_CALL_COUNT], 8, [save call count])
464         AC_CHECK_LIB(unwind, backtrace, [
465           AC_DEFINE([GC_HAVE_BUILTIN_BACKTRACE], 1, [have builtin backtrace])
466           UNWINDLIBS=-lunwind
467           AC_MSG_WARN("Client code may need to link against libunwind.")
468         ])
469       ;;
470       x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
471         AC_DEFINE([MAKE_BACK_GRAPH], 1, [make back graph])
472         AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
473         AC_DEFINE([SAVE_CALL_COUNT], 8, [save call count])
474       ;;
475       i[3456]86-*-dgux*)
476         AC_DEFINE([MAKE_BACK_GRAPH], 1, [make back graph])
477       ;;
478     esac ]
479   fi)
480
481 AC_SUBST(UNWINDLIBS)
482
483 AC_ARG_ENABLE(redirect-malloc,
484 [  --enable-redirect-malloc  redirect malloc and friends to GC routines])
485
486 if test "${enable_redirect_malloc}" = yes; then
487     if test "${enable_full_debug}" = yes; then
488         AC_DEFINE([REDIRECT_MALLOC], GC_debug_malloc_replacement, [redirect malloc])
489         AC_DEFINE([REDIRECT_REALLOC], GC_debug_realloc_replacement, [redirect realloc])
490         AC_DEFINE([REDIRECT_FREE], GC_debug_free, [redirect free])
491     else
492         AC_DEFINE([REDIRECT_MALLOC], GC_malloc, [redirect malloc])
493     fi
494 fi
495
496 AC_ARG_ENABLE(gc-assertions,
497 [  --enable-gc-assertions  collector-internal assertion checking])
498 if test "${enable_gc_assertions}" = yes; then
499     AC_DEFINE([GC_ASSERTIONS], 1, [gc assertions])
500 fi
501
502 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
503
504 AC_OUTPUT([Makefile doc/Makefile include/Makefile],,
505 srcdir=${srcdir}
506 host=${host}
507 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
508 CC="${CC}"
509 DEFS="$DEFS"
510 )