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