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