[interp] Reduce computation under calc_section mutex
[mono-project.git] / libgc / configure.ac
blob628144d3a16ddafa98b217d9e02e46cd7cc388e0
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.
12 # Original author: Tom Tromey
13 # Modified by: Grzegorz Jakacki <jakacki at acm dot org>
15 dnl Process this file with autoconf to produce configure.
17 AC_PREREQ([2.53])
18 AC_INIT([libgc-mono], [6.6], [Hans_Boehm@hp.com])
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
25 AC_SUBST(PACKAGE)
26 AC_SUBST(GC_VERSION)
28 AC_PROG_CC
29 AC_PROG_CXX
31 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
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, :)  # :)
38 AC_PROG_INSTALL
40 AM_MAINTAINER_MODE
42 . [$]{srcdir}/configure.host
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
49 if test "x$CFLAGS_FOR_LIBGC" != "x"; then
50    CFLAGS=$CFLAGS_FOR_LIBGC
53 GC_CFLAGS=${gc_cflags}
54 AC_SUBST(GC_CFLAGS)
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
61 THREADS=$with_libgc_threads
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],
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]
76 AC_ARG_ENABLE(cplusplus,
77 [  --enable-cplusplus           install C++ support],
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      *-*-haiku*)
108         AC_DEFINE(GC_HAIKU_THREADS)
109         AC_DEFINE(_REENTRANT)
110         ;;
111      *-*-hpux*)
112         AC_MSG_WARN("Only HP/UX 11 threads are supported.")
113         AC_DEFINE(GC_HPUX_THREADS)
114         AC_DEFINE(_POSIX_C_SOURCE,199506L)
115         if test "${enable_parallel_mark}" = yes; then
116           AC_DEFINE(PARALLEL_MARK)
117         fi
118         AC_DEFINE(THREAD_LOCAL_ALLOC)
119         THREADDLLIBS="-lpthread -lrt"
120         ;;
121      *-*-kfreebsd*-gnu)
122         AC_DEFINE(GC_FREEBSD_THREADS)
123         INCLUDES="$INCLUDES -pthread"
124         THREADDLLIBS=-pthread
125         AC_DEFINE(_REENTRANT)
126         if test "${enable_parallel_mark}" = yes; then
127                 AC_DEFINE(PARALLEL_MARK)
128         fi
129         AC_DEFINE(THREAD_LOCAL_ALLOC)
130         AC_DEFINE(USE_COMPILER_TLS)
131         ;;
132       *-*-freebsd*)
133         AC_DEFINE(GC_FREEBSD_THREADS)
134         if test "x$PTHREAD_CFLAGS" != "x"; then
135                 AM_CPPFLAGS="$AM_CPPFLAGS $PTHREAD_CFLAGS"
136         fi
137         if test "x$PTHREAD_LIBS" = "x"; then
138                 THREADDLLIBS=-pthread
139         else
140                 THREADDLLIBS="$PTHREAD_LIBS"
141         fi
142         AC_DEFINE(THREAD_LOCAL_ALLOC)
143         ;;
144      *-*-solaris*)
145         AC_DEFINE(GC_SOLARIS_THREADS)
146         AC_DEFINE(GC_SOLARIS_PTHREADS)
147         ;;
148      *-*-irix*)
149         AC_DEFINE(GC_IRIX_THREADS)
150         ;;
151      *-*-cygwin*)
152         AC_DEFINE(GC_WIN32_THREADS)
153         ;;
154      *-*-darwin*)
155         AC_DEFINE(GC_DARWIN_THREADS)
156         AC_DEFINE(THREAD_LOCAL_ALLOC)
157         if test "${enable_parallel_mark}" = yes; then
158           AC_DEFINE(PARALLEL_MARK)
159         fi
160         ;;
161      *-*-netbsd*)
162         AC_DEFINE(GC_NETBSD_THREADS)
163         if test "${enable_parallel_mark}" = yes; then
164           AC_DEFINE(PARALLEL_MARK)
165         fi
166         AC_DEFINE(THREAD_LOCAL_ALLOC)
167         ;;
168      *-*-openbsd*)
169         AC_DEFINE(GC_OPENBSD_THREADS)
170         if test "${enable_parallel_mark}" = yes; then
171           AC_DEFINE(PARALLEL_MARK)
172         fi
173         AC_DEFINE(THREAD_LOCAL_ALLOC)
174         ;;
175      *-*-osf*)
176         AC_DEFINE(GC_OSF1_THREADS)
177         if test "${enable_parallel_mark}" = yes; then
178           AC_DEFINE(PARALLEL_MARK)
179           AC_DEFINE(THREAD_LOCAL_ALLOC)
180           # May want to enable it in other cases, too.
181           # Measurements havent yet been done.
182         fi
183         AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
184         THREADDLLIBS="-lpthread -lrt"
185         ;;
186       *)
187         AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
188         ;;
189     esac
190     ;;
191  win32)
192     AC_DEFINE(GC_WIN32_THREADS)
193     dnl Wine getenv may not return NULL for missing entry
194     AC_DEFINE(NO_GETENV)
195         if test "${enable_win32_dllmain}" = yes; then
196            AC_DEFINE(GC_INSIDE_DLL)
197         fi
198     ;;
199  dgux386)
200     THREADS=dgux386
201     AC_MSG_RESULT($THREADDLLIBS)
202     # Use pthread GCC  switch
203     THREADDLLIBS=-pthread
204     if test "${enable_parallel_mark}" = yes; then
205         AC_DEFINE(PARALLEL_MARK)
206     fi
207     AC_DEFINE(THREAD_LOCAL_ALLOC)
208     AC_DEFINE(GC_DGUX386_THREADS)
209     AC_DEFINE(DGUX_THREADS)
210     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
211     AM_CPPFLAGS="-pthread $AM_CPPFLAGS"
212     ;;
213  aix)
214     THREADS=posix
215     THREADDLLIBS=-lpthread
216     AC_DEFINE(GC_AIX_THREADS)
217     AC_DEFINE(_REENTRANT)
218     ;;
219  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
220     AC_MSG_ERROR(thread package $THREADS not yet supported)
221     ;;
222  *)
223     AC_MSG_ERROR($THREADS is an unknown thread package)
224     ;;
225 esac
226 AC_SUBST(THREADDLLIBS)
228 case "$host" in 
229    powerpc-*-darwin*)
230       powerpc_darwin=true
231       ;;
232 esac
233 AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
235 # Check if the GCC builtin __sync_bool_compare_and_swap is available.
236 # It is preferred in gc_locks.h for PPC as GCC 4.4 has a problem with the inline assembly there.
237 AC_MSG_CHECKING(for __sync_bool_compare_and_swap)
238 AC_TRY_COMPILE([],[
239 volatile unsigned int foo = 0;
240 unsigned int r1 = __sync_bool_compare_and_swap(&foo, 0, 1);
241 return 0;
242 ], [
243 AC_MSG_RESULT(yes)
244 AC_DEFINE(HAS___SYNC_BOOL_COMPARE_AND_SWAP)
245 ], [
246 AC_MSG_RESULT(no)
249 AC_MSG_CHECKING(for xlc)
250 AC_TRY_COMPILE([],[
251  #ifndef __xlC__
252  # error
253  #endif
254 ], [compiler_xlc=yes], [compiler_xlc=no])
255 AC_MSG_RESULT($compiler_xlc)
256 AM_CONDITIONAL(COMPILER_XLC,test $compiler_xlc = yes)
257 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
258   # the darwin stack-frame-walking code is completely broken on xlc
259   AC_DEFINE(DARWIN_DONT_PARSE_STACK)
262 # We never want libdl on darwin. It is a fake libdl that just ends up making
263 # dyld calls anyway
264 case "$host" in
265   *-*-darwin*) ;;
266   *) 
267     AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
268     ;;
269 esac
271 AC_SUBST(EXTRA_TEST_LIBS)
273 target_all=libgc.la
274 AC_SUBST(target_all)
276 dnl If the target is an eCos system, use the appropriate eCos
277 dnl I/O routines.
278 dnl FIXME: this should not be a local option but a global target
279 dnl system; at present there is no eCos target.
280 TARGET_ECOS="no"
281 AC_ARG_WITH(ecos,
282 [  --with-ecos             enable runtime eCos target support],
283 TARGET_ECOS="$with_ecos"
286 addobjs=
287 addlibs=
288 addincludes=
289 addtests=
290 CXXAM_CPPFLAGS=
291 case "$TARGET_ECOS" in
292    no)
293       ;;
294    *)
295       AC_DEFINE(ECOS)
296       CXXINCLUDES="-I${TARGET_ECOS}/include"
297       addobjs="$addobjs ecos.lo"
298       ;;
299 esac
301 if test "${enable_cplusplus}" = yes; then
302       addincludes="$addincludes include/gc_cpp.h include/gc_allocator.h"
303       addtests="$addtests test_cpp"
306 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
308 AC_SUBST(CXX)
310 AC_SUBST(AM_CPPFLAGS)
311 AC_SUBST(CXXINCLUDES)
313 # Configuration of shared libraries
315 AC_MSG_CHECKING(whether to build shared libraries)
316 AC_ENABLE_SHARED
318 case "$host" in
319  alpha-*-openbsd*)
320      enable_shared=no
321      AC_MSG_RESULT(no)
322      ;;
323  *)
324      AC_MSG_RESULT(yes)
325      ;;
326 esac
328 # Configuration of machine-dependent code
330 AC_MSG_CHECKING(which machine-dependent code should be used) 
331 machdep=
332 case "$host" in
333  alpha-*-openbsd*)
334     machdep="alpha_mach_dep.lo"
335     if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
336        AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
337     fi
338     ;;
339  alpha*-*-linux*)
340     machdep="alpha_mach_dep.lo"
341     ;;
342  i?86-*-solaris2.[[89]] | i?86-*-solaris2.1?)
343     AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED)
344     ;;
345  mipstx39-*-elf*)
346     machdep="mips_ultrix_mach_dep.lo"
347     AC_DEFINE(STACKBASE, __stackbase)
348     AC_DEFINE(DATASTART_IS_ETEXT)
349     ;;
350  mips-dec-ultrix*)
351     machdep="mips_ultrix_mach-dep.lo"
352     ;;
353  mips-nec-sysv*|mips-unknown-sysv*)
354     ;;
355  mips*-*-linux*) 
356     ;; 
357  mips-*-*)
358     machdep="mips_sgi_mach_dep.lo"
359     AC_DEFINE(NO_EXECUTE_PERMISSION)
360     ;;
361  sparc-*-netbsd*)
362     machdep="sparc_netbsd_mach_dep.lo"
363     ;;
364  sparc-sun-solaris2.3)
365     machdep="sparc_mach_dep.lo"
366     AC_DEFINE(SUNOS53_SHARED_LIB)
367     ;;
368  sparc*-sun-solaris2.*)
369     machdep="sparc_mach_dep.lo"
370     ;;
371  ia64-*-*)
372      machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
373         target_ia64=true
374     ;;
375  *-*-nacl*)
376     AC_DEFINE(NO_EXECUTE_PERMISSION)
377     ;;
378 esac
379 if test x"$machdep" = x; then
380 AC_MSG_RESULT($machdep)
381    machdep="mach_dep.lo"
383 addobjs="$addobjs $machdep"
385 # Adding object files directly to _LIBADD breaks -j builds, so we need to add the sources
386 # instead, but _SOURCES can't contain autoconf substitutions, so add them using automake
387 # conditionals.
389 #AC_SUBST(addobjs)
390 AC_SUBST(addincludes)
391 AC_SUBST(addlibs)
392 AC_SUBST(addtests)
394 AM_CONDITIONAL(TARGET_IA64,test x$target_ia64 = xtrue)
396 AC_PROG_LIBTOOL
397 # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
398 DOLT
401 # Check for AViiON Machines running DGUX
403 ac_is_dgux=no
404 AC_CHECK_HEADER(sys/dg_sys_info.h,
405 [ac_is_dgux=yes;])
407     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
408 if test $ac_is_dgux = yes; then
409     if test "$enable_full_debug" = "yes"; then
410       CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
411       CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
412     else
413       CFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
414       CXXFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
415     fi
416     AC_SUBST(CFLAGS)
417     AC_SUBST(CXXFLAGS)
420 dnl We use these options to decide which functions to include.
421 AC_ARG_WITH(target-subdir,
422 [  --with-target-subdir=SUBDIR
423                           configuring with a cross compiler])
424 AC_ARG_WITH(cross-host,
425 [  --with-cross-host=HOST  configuring with a cross compiler])
427 # automake wants to see AC_EXEEXT.  But we don't need it.  And having
428 # it is actually a problem, because the compiler we're passed can't
429 # necessarily do a full link.  So we fool automake here.
430 if false; then
431   # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
432   # to nothing, so nothing would remain between `then' and `fi' if it
433   # were not for the `:' below.
434   :
435   AC_EXEEXT
438 AC_MSG_CHECKING([for threads package to use])
439 AC_MSG_RESULT($THREADS)
441 dnl As of 4.13a2, the collector will not properly work on Solaris when
442 dnl built with gcc and -O.  So we remove -O in the appropriate case.
443 dnl Not needed anymore on Solaris.
444 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
445 case "$host" in
446  *aix*)
447     if test "$GCC" = yes; then
448        AC_MSG_RESULT(yes)
449        new_CFLAGS=
450        for i in $CFLAGS; do
451           case "$i" in
452            -O*)
453               ;;
454            *)
455               new_CFLAGS="$new_CFLAGS $i"
456               ;;
457           esac
458        done
459        CFLAGS="$new_CFLAGS"
460     else
461        AC_MSG_RESULT(no)
462     fi
463     ;;
464  *) AC_MSG_RESULT(no) ;;
465 esac
467 dnl We need to override the top-level CFLAGS.  This is how we do it.
468 MY_CFLAGS="$CFLAGS"
469 AC_SUBST(MY_CFLAGS)
471 dnl Include defines that have become de facto standard.
472 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
473 AC_DEFINE(SILENT)
474 AC_DEFINE(NO_SIGNALS)
475 AC_DEFINE(NO_EXECUTE_PERMISSION)
476 dnl AC_DEFINE(ALL_INTERIOR_POINTERS)
478 dnl By default, make the library as general as possible.
479 AC_DEFINE(JAVA_FINALIZATION)
480 AC_DEFINE(GC_GCJ_SUPPORT)
481 AC_DEFINE(ATOMIC_UNCOLLECTABLE)
483 dnl This is something of a hack.  When cross-compiling we turn off
484 dnl some functionality.  We also enable the "small" configuration.
485 dnl These is only correct when targetting an embedded system.  FIXME.
486 if test -n "${with_cross_host}"; then
487    AC_DEFINE(NO_SIGSET)
488    AC_DEFINE(NO_CLOCK)
489    AC_DEFINE(SMALL_CONFIG)
490    AC_DEFINE(NO_DEBUGGING)
493 UNWINDLIBS=
494 AC_ARG_ENABLE(full-debug,
495 [  --enable-full-debug  include full support for pointer backtracing etc.],
496 [ if test "$enable_full_debug" = "yes"; then
497     AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.")
498     AC_DEFINE(KEEP_BACK_PTRS)
499     AC_DEFINE(DBG_HDRS_ALL)
500     case $host in
501       ia64-*-linux* )
502         AC_DEFINE(MAKE_BACK_GRAPH)
503         AC_DEFINE(SAVE_CALL_COUNT, 8)
504         AC_CHECK_LIB(unwind, backtrace, [
505           AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
506           UNWINDLIBS=-lunwind
507           AC_MSG_WARN("Client code may need to link against libunwind.")
508         ])
509       ;;
510       x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
511         AC_DEFINE(MAKE_BACK_GRAPH)
512         AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
513         AC_DEFINE(SAVE_CALL_COUNT, 8)
514       ;;
515       i[3456]86-*-dgux*)
516         AC_DEFINE(MAKE_BACK_GRAPH)
517       ;;
518     esac ]
519   fi)
521 AC_SUBST(UNWINDLIBS)
523 AC_ARG_ENABLE(redirect-malloc,
524 [  --enable-redirect-malloc  redirect malloc and friends to GC routines])
526 if test "${enable_redirect_malloc}" = yes; then
527     if test "${enable_full_debug}" = yes; then
528         AC_DEFINE(REDIRECT_MALLOC, GC_debug_malloc_replacement)
529         AC_DEFINE(REDIRECT_REALLOC, GC_debug_realloc_replacement)
530         AC_DEFINE(REDIRECT_FREE, GC_debug_free)
531     else
532         AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
533     fi
536 AC_DEFINE(_IN_LIBGC)
538 AC_ARG_ENABLE(gc-assertions,
539 [  --enable-gc-assertions  collector-internal assertion checking])
540 if test "${enable_gc_assertions}" = yes; then
541     AC_DEFINE(GC_ASSERTIONS)
544 AC_ARG_ENABLE(quiet-build, [  --enable-quiet-build  Enable quiet libgc build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
545 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
547 AC_ARG_ENABLE(werror, [  --enable-werror Pass -Werror to the C compiler], werror_flag=$enableval, werror_flag=no)
548 if test x$werror_flag = xyes; then
549         WERROR_CFLAGS="-Werror"
551 AC_SUBST([WERROR_CFLAGS])
553 if test "${multilib}" = "yes"; then
554   multilib_arg="--enable-multilib"
555 else
556   multilib_arg=
559 AC_OUTPUT(Makefile
560 m4/Makefile
561 include/Makefile
562 include/private/Makefile
563 doc/Makefile,,
564 srcdir=${srcdir}
565 host=${host}
566 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
567 CC="${CC}"
568 DEFS="$DEFS"