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