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