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