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