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