1 # Copyright (c) 1999-2001 by Red Hat, Inc. All rights reserved.
3 # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
4 # OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
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.
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])
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],[])
36 AC_CHECK_TOOL(RANLIB, ranlib, :) # :)
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}
56 case $enable_embed_check in
58 *) AC_MSG_ERROR([This module is now part of 'mono' and cannot be built as a stand-alone module any longer.]) ;;
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],
71 AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec])
76 AC_ARG_ENABLE(cplusplus,
77 [ --enable-cplusplus install C++ support],
80 AM_CPPFLAGS=-I${srcdir}/include
82 ## Libraries needed to support dynamic loading and/or threads.
89 AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
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)
94 if test "${enable_parallel_mark}" = yes; then
95 AC_DEFINE(PARALLEL_MARK)
97 AC_DEFINE(THREAD_LOCAL_ALLOC)
99 *-*-linux* | *-*-nacl*)
100 AC_DEFINE(GC_LINUX_THREADS)
101 AC_DEFINE(_REENTRANT)
104 AC_DEFINE(GC_AIX_THREADS)
105 AC_DEFINE(_REENTRANT)
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)
114 AC_DEFINE(THREAD_LOCAL_ALLOC)
115 THREADDLLIBS="-lpthread -lrt"
118 AC_DEFINE(GC_FREEBSD_THREADS)
119 INCLUDES="$INCLUDES -pthread"
120 THREADDLLIBS=-pthread
121 AC_DEFINE(_REENTRANT)
122 if test "${enable_parallel_mark}" = yes; then
123 AC_DEFINE(PARALLEL_MARK)
125 AC_DEFINE(THREAD_LOCAL_ALLOC)
126 AC_DEFINE(USE_COMPILER_TLS)
129 AC_DEFINE(GC_FREEBSD_THREADS)
130 if test "x$PTHREAD_CFLAGS" != "x"; then
131 AM_CPPFLAGS="$AM_CPPFLAGS $PTHREAD_CFLAGS"
133 if test "x$PTHREAD_LIBS" = "x"; then
134 THREADDLLIBS=-pthread
136 THREADDLLIBS="$PTHREAD_LIBS"
138 AC_DEFINE(THREAD_LOCAL_ALLOC)
141 AC_DEFINE(GC_SOLARIS_THREADS)
142 AC_DEFINE(GC_SOLARIS_PTHREADS)
145 AC_DEFINE(GC_IRIX_THREADS)
148 AC_DEFINE(GC_WIN32_THREADS)
151 AC_DEFINE(GC_DARWIN_THREADS)
152 AC_DEFINE(THREAD_LOCAL_ALLOC)
153 if test "${enable_parallel_mark}" = yes; then
154 AC_DEFINE(PARALLEL_MARK)
158 AC_DEFINE(GC_NETBSD_THREADS)
159 if test "${enable_parallel_mark}" = yes; then
160 AC_DEFINE(PARALLEL_MARK)
162 AC_DEFINE(THREAD_LOCAL_ALLOC)
165 AC_DEFINE(GC_OPENBSD_THREADS)
166 if test "${enable_parallel_mark}" = yes; then
167 AC_DEFINE(PARALLEL_MARK)
169 AC_DEFINE(THREAD_LOCAL_ALLOC)
172 AC_DEFINE(GC_OSF1_THREADS)
173 if test "${enable_parallel_mark}" = yes; then
174 AC_DEFINE(PARALLEL_MARK)
175 AC_DEFINE(THREAD_LOCAL_ALLOC)
176 # May want to enable it in other cases, too.
177 # Measurements havent yet been done.
179 AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
180 THREADDLLIBS="-lpthread -lrt"
183 AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
188 AC_DEFINE(GC_WIN32_THREADS)
189 dnl Wine getenv may not return NULL for missing entry
191 if test "${enable_win32_dllmain}" = yes; then
192 AC_DEFINE(GC_INSIDE_DLL)
197 AC_MSG_RESULT($THREADDLLIBS)
198 # Use pthread GCC switch
199 THREADDLLIBS=-pthread
200 if test "${enable_parallel_mark}" = yes; then
201 AC_DEFINE(PARALLEL_MARK)
203 AC_DEFINE(THREAD_LOCAL_ALLOC)
204 AC_DEFINE(GC_DGUX386_THREADS)
205 AC_DEFINE(DGUX_THREADS)
206 # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
207 AM_CPPFLAGS="-pthread $AM_CPPFLAGS"
211 THREADDLLIBS=-lpthread
212 AC_DEFINE(GC_AIX_THREADS)
213 AC_DEFINE(_REENTRANT)
215 decosf1 | irix | mach | os2 | solaris | dce | vxworks)
216 AC_MSG_ERROR(thread package $THREADS not yet supported)
219 AC_MSG_ERROR($THREADS is an unknown thread package)
222 AC_SUBST(THREADDLLIBS)
229 AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
231 # Check if the GCC builtin __sync_bool_compare_and_swap is available.
232 # It is preferred in gc_locks.h for PPC as GCC 4.4 has a problem with the inline assembly there.
233 AC_MSG_CHECKING(for __sync_bool_compare_and_swap)
235 volatile unsigned int foo = 0;
236 int main(int argc, char** argv) {
237 unsigned int r1 = __sync_bool_compare_and_swap(&foo, 0, 1);
242 AC_DEFINE(HAS___SYNC_BOOL_COMPARE_AND_SWAP)
247 AC_MSG_CHECKING(for xlc)
252 ], [compiler_xlc=yes], [compiler_xlc=no])
253 AC_MSG_RESULT($compiler_xlc)
254 AM_CONDITIONAL(COMPILER_XLC,test $compiler_xlc = yes)
255 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
256 # the darwin stack-frame-walking code is completely broken on xlc
257 AC_DEFINE(DARWIN_DONT_PARSE_STACK)
260 # We never want libdl on darwin. It is a fake libdl that just ends up making
265 AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
269 AC_SUBST(EXTRA_TEST_LIBS)
274 dnl If the target is an eCos system, use the appropriate eCos
276 dnl FIXME: this should not be a local option but a global target
277 dnl system; at present there is no eCos target.
280 [ --with-ecos enable runtime eCos target support],
281 TARGET_ECOS="$with_ecos"
289 case "$TARGET_ECOS" in
294 CXXINCLUDES="-I${TARGET_ECOS}/include"
295 addobjs="$addobjs ecos.lo"
299 if test "${enable_cplusplus}" = yes; then
300 addincludes="$addincludes include/gc_cpp.h include/gc_allocator.h"
301 addtests="$addtests test_cpp"
304 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
308 AC_SUBST(AM_CPPFLAGS)
309 AC_SUBST(CXXINCLUDES)
311 # Configuration of shared libraries
313 AC_MSG_CHECKING(whether to build shared libraries)
326 # Configuration of machine-dependent code
328 AC_MSG_CHECKING(which machine-dependent code should be used)
332 machdep="alpha_mach_dep.lo"
333 if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
334 AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
338 machdep="alpha_mach_dep.lo"
340 i?86-*-solaris2.[[89]] | i?86-*-solaris2.1?)
341 AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED)
344 machdep="mips_ultrix_mach_dep.lo"
345 AC_DEFINE(STACKBASE, __stackbase)
346 AC_DEFINE(DATASTART_IS_ETEXT)
349 machdep="mips_ultrix_mach-dep.lo"
351 mips-nec-sysv*|mips-unknown-sysv*)
356 machdep="mips_sgi_mach_dep.lo"
357 AC_DEFINE(NO_EXECUTE_PERMISSION)
360 machdep="sparc_netbsd_mach_dep.lo"
362 sparc-sun-solaris2.3)
363 machdep="sparc_mach_dep.lo"
364 AC_DEFINE(SUNOS53_SHARED_LIB)
366 sparc*-sun-solaris2.*)
367 machdep="sparc_mach_dep.lo"
370 machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
374 AC_DEFINE(NO_EXECUTE_PERMISSION)
377 if test x"$machdep" = x; then
378 AC_MSG_RESULT($machdep)
379 machdep="mach_dep.lo"
381 addobjs="$addobjs $machdep"
383 # Adding object files directly to _LIBADD breaks -j builds, so we need to add the sources
384 # instead, but _SOURCES can't contain autoconf substitutions, so add them using automake
388 AC_SUBST(addincludes)
392 AM_CONDITIONAL(TARGET_IA64,test x$target_ia64 = xtrue)
395 # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
399 # Check for AViiON Machines running DGUX
402 AC_CHECK_HEADER(sys/dg_sys_info.h,
405 ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
406 if test $ac_is_dgux = yes; then
407 if test "$enable_full_debug" = "yes"; then
408 CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
409 CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
411 CFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
412 CXXFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
418 dnl We use these options to decide which functions to include.
419 AC_ARG_WITH(target-subdir,
420 [ --with-target-subdir=SUBDIR
421 configuring with a cross compiler])
422 AC_ARG_WITH(cross-host,
423 [ --with-cross-host=HOST configuring with a cross compiler])
425 # automake wants to see AC_EXEEXT. But we don't need it. And having
426 # it is actually a problem, because the compiler we're passed can't
427 # necessarily do a full link. So we fool automake here.
429 # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
430 # to nothing, so nothing would remain between `then' and `fi' if it
431 # were not for the `:' below.
436 AC_MSG_CHECKING([for threads package to use])
437 AC_MSG_RESULT($THREADS)
439 dnl As of 4.13a2, the collector will not properly work on Solaris when
440 dnl built with gcc and -O. So we remove -O in the appropriate case.
441 dnl Not needed anymore on Solaris.
442 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
445 if test "$GCC" = yes; then
453 new_CFLAGS="$new_CFLAGS $i"
462 *) AC_MSG_RESULT(no) ;;
465 dnl We need to override the top-level CFLAGS. This is how we do it.
469 dnl Include defines that have become de facto standard.
470 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
472 AC_DEFINE(NO_SIGNALS)
473 AC_DEFINE(NO_EXECUTE_PERMISSION)
474 dnl AC_DEFINE(ALL_INTERIOR_POINTERS)
476 dnl By default, make the library as general as possible.
477 AC_DEFINE(JAVA_FINALIZATION)
478 AC_DEFINE(GC_GCJ_SUPPORT)
479 AC_DEFINE(ATOMIC_UNCOLLECTABLE)
481 dnl This is something of a hack. When cross-compiling we turn off
482 dnl some functionality. We also enable the "small" configuration.
483 dnl These is only correct when targetting an embedded system. FIXME.
484 if test -n "${with_cross_host}"; then
487 AC_DEFINE(SMALL_CONFIG)
488 AC_DEFINE(NO_DEBUGGING)
492 AC_ARG_ENABLE(full-debug,
493 [ --enable-full-debug include full support for pointer backtracing etc.],
494 [ if test "$enable_full_debug" = "yes"; then
495 AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.")
496 AC_DEFINE(KEEP_BACK_PTRS)
497 AC_DEFINE(DBG_HDRS_ALL)
500 AC_DEFINE(MAKE_BACK_GRAPH)
501 AC_DEFINE(SAVE_CALL_COUNT, 8)
502 AC_CHECK_LIB(unwind, backtrace, [
503 AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
505 AC_MSG_WARN("Client code may need to link against libunwind.")
508 x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
509 AC_DEFINE(MAKE_BACK_GRAPH)
510 AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
511 AC_DEFINE(SAVE_CALL_COUNT, 8)
514 AC_DEFINE(MAKE_BACK_GRAPH)
521 AC_ARG_ENABLE(redirect-malloc,
522 [ --enable-redirect-malloc redirect malloc and friends to GC routines])
524 if test "${enable_redirect_malloc}" = yes; then
525 if test "${enable_full_debug}" = yes; then
526 AC_DEFINE(REDIRECT_MALLOC, GC_debug_malloc_replacement)
527 AC_DEFINE(REDIRECT_REALLOC, GC_debug_realloc_replacement)
528 AC_DEFINE(REDIRECT_FREE, GC_debug_free)
530 AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
536 AC_ARG_ENABLE(gc-assertions,
537 [ --enable-gc-assertions collector-internal assertion checking])
538 if test "${enable_gc_assertions}" = yes; then
539 AC_DEFINE(GC_ASSERTIONS)
542 AC_ARG_ENABLE(quiet-build, [ --enable-quiet-build Enable quiet libgc build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
543 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
545 AC_ARG_ENABLE(werror, [ --enable-werror Pass -Werror to the C compiler], werror_flag=$enableval, werror_flag=no)
546 if test x$werror_flag = xyes; then
547 WERROR_CFLAGS="-Werror"
549 AC_SUBST([WERROR_CFLAGS])
551 if test "${multilib}" = "yes"; then
552 multilib_arg="--enable-multilib"
560 include/private/Makefile
564 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}