Merge pull request #1056 from ranma42/vc-compat-C90
[mono.git] / libgc / configure.in
index b8104a302f56b673b4fd6fa359c1323e7056570a..837e2cb9f158c14f8cdbe47e0abc14091db14edf 100644 (file)
 
 dnl Process this file with autoconf to produce configure.
 
-AC_PREREQ(2.53)
-AC_INIT(libgc-mono, 6.3alpha6, Hans_Boehm@hp.com)
-
-AM_INIT_AUTOMAKE(libgc-mono, 6.2, no-define)
+AC_PREREQ([2.53])
+AC_INIT([libgc-mono], [6.6], [Hans_Boehm@hp.com])
 
+AM_INIT_AUTOMAKE([1.9 no-define foreign])
 AC_CONFIG_SRCDIR(gcj_mlc.c)
+AC_CONFIG_MACRO_DIR([m4])
 AC_CANONICAL_HOST
 
 AC_SUBST(PACKAGE)
@@ -28,6 +28,8 @@ AC_SUBST(GC_VERSION)
 AC_PROG_CC
 AC_PROG_CXX
 
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
 dnl automake 1.6 and later need the AM_PROG_AS macro.
 ifdef([AM_PROG_AS],[AM_PROG_AS],[])
 AC_CHECK_TOOL(AR, ar)
@@ -39,16 +41,29 @@ AM_MAINTAINER_MODE
 
 . [$]{srcdir}/configure.host
 
+# We use a separate variable to pass down CPPFLAGS and CFLAGS from the main mono 
+# configure, because of autoconf brokeness
+if test "x$CPPFLAGS_FOR_LIBGC" != "x"; then
+   CPPFLAGS=$CPPFLAGS_FOR_LIBGC
+fi
+if test "x$CFLAGS_FOR_LIBGC" != "x"; then
+   CFLAGS=$CFLAGS_FOR_LIBGC
+fi
+
 GC_CFLAGS=${gc_cflags}
 AC_SUBST(GC_CFLAGS)
 
 case $enable_embed_check in
 no) ;;
-*) AC_MSG_ERROR([This module is now part of `mono' and can't be built as a stand-alone module any longer.]) ;;
+*) AC_MSG_ERROR([This module is now part of 'mono' and cannot be built as a stand-alone module any longer.]) ;;
 esac
 
 THREADS=$with_libgc_threads
 
+AC_ARG_ENABLE(win32-dllmain,
+[  --enable-win32-dllmain    Define the DllMain function in win32_threads.c even if the collector is not built as a dll],
+)
+
 AC_ARG_ENABLE(parallel-mark,
 [  --enable-parallel-mark      parallelize marking and free list construction],
    [case "$THREADS" in
@@ -62,17 +77,18 @@ AC_ARG_ENABLE(cplusplus,
 [  --enable-cplusplus          install C++ support],
 )
 
-INCLUDES=-I${srcdir}/include
-THREADLIBS=
+AM_CPPFLAGS=-I${srcdir}/include
+THREADDLLIBS=
+## Libraries needed to support dynamic loading and/or threads.
 case "$THREADS" in
  no | none | single)
     THREADS=none
     ;;
  posix | pthreads)
     THREADS=posix
-    THREADLIBS=-lpthread
+    AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
     case "$host" in
-     x86-*-linux* | ia64-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | alpha-*-linux* | s390*-*-linux* | powerpc-*-linux*)
+     x86-*-linux* | ia64-*-linux* | i386-*-linux* | i486-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | alpha*-*-linux* | s390*-*-linux* | sparc*-*-linux* | powerpc-*-linux*)
        AC_DEFINE(GC_LINUX_THREADS)
        AC_DEFINE(_REENTRANT)
         if test "${enable_parallel_mark}" = yes; then
@@ -80,7 +96,7 @@ case "$THREADS" in
        fi
        AC_DEFINE(THREAD_LOCAL_ALLOC)
        ;;
-     *-*-linux*)
+     *-*-linux* | *-*-nacl*)
        AC_DEFINE(GC_LINUX_THREADS)
        AC_DEFINE(_REENTRANT)
        ;;
@@ -96,44 +112,19 @@ case "$THREADS" in
          AC_DEFINE(PARALLEL_MARK)
        fi
        AC_DEFINE(THREAD_LOCAL_ALLOC)
-       THREADLIBS="-lpthread -lrt"
+       THREADDLLIBS="-lpthread -lrt"
        ;;
-     *-*-freebsd4*)
-       AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
-       AC_DEFINE(GC_FREEBSD_THREADS)
-       if test "x$PTHREAD_CFLAGS" = "x"; then
-               INCLUDES="$INCLUDES -pthread"
-       else
-               INCLUDES="$INCLUDES $PTHREAD_CFLAGS"
-       fi
-       if test "x$PTHREAD_LIBS" = "x"; then
-               THREADLIBS=-pthread
-       else
-               THREADLIBS=$PTHREAD_LIBS
-       fi
-       ;;
-     *-*-freebsd5*)
-       AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
+      *-*-freebsd*)
        AC_DEFINE(GC_FREEBSD_THREADS)
        if test "x$PTHREAD_CFLAGS" != "x"; then
-               INCLUDES="$INCLUDES $PTHREAD_CFLAGS"
+               AM_CPPFLAGS="$AM_CPPFLAGS $PTHREAD_CFLAGS"
        fi
        if test "x$PTHREAD_LIBS" = "x"; then
-               THREADLIBS=-pthread
+               THREADDLLIBS=-pthread
        else
-               THREADLIBS="$PTHREAD_LIBS"
-       fi
-       ;;
-        *-*-freebsd6*)
-        AC_DEFINE(GC_FREEBSD_THREADS)
-        if test "x$PTHREAD_CFLAGS" != "x"; then
-               INCLUDES="$INCLUDES $PTHREAD_CFLAGS"
-       fi
-       if test "x$PTHREAD_LIBS" = "x"; then
-               THREADLIBS=-pthread
-       else
-               THREADLIBS="$PTHREAD_LIBS"
+               THREADDLLIBS="$PTHREAD_LIBS"
        fi
+       AC_DEFINE(THREAD_LOCAL_ALLOC)
        ;;
      *-*-solaris*)
        AC_DEFINE(GC_SOLARIS_THREADS)
@@ -152,6 +143,20 @@ case "$THREADS" in
          AC_DEFINE(PARALLEL_MARK)
        fi
        ;;
+     *-*-netbsd*)
+       AC_DEFINE(GC_NETBSD_THREADS)
+       if test "${enable_parallel_mark}" = yes; then
+         AC_DEFINE(PARALLEL_MARK)
+       fi
+       AC_DEFINE(THREAD_LOCAL_ALLOC)
+       ;;
+     *-*-openbsd*)
+       AC_DEFINE(GC_OPENBSD_THREADS)
+       if test "${enable_parallel_mark}" = yes; then
+         AC_DEFINE(PARALLEL_MARK)
+       fi
+       AC_DEFINE(THREAD_LOCAL_ALLOC)
+       ;;
      *-*-osf*)
        AC_DEFINE(GC_OSF1_THREADS)
         if test "${enable_parallel_mark}" = yes; then
@@ -160,8 +165,11 @@ case "$THREADS" in
          # May want to enable it in other cases, too.
          # Measurements havent yet been done.
        fi
-       INCLUDES="$INCLUDES -pthread"
-       THREADLIBS="-lpthread -lrt"
+       AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
+       THREADDLLIBS="-lpthread -lrt"
+       ;;
+      *)
+       AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
        ;;
     esac
     ;;
@@ -169,12 +177,15 @@ case "$THREADS" in
     AC_DEFINE(GC_WIN32_THREADS)
     dnl Wine getenv may not return NULL for missing entry
     AC_DEFINE(NO_GETENV)
+       if test "${enable_win32_dllmain}" = yes; then
+          AC_DEFINE(GC_INSIDE_DLL)
+       fi
     ;;
  dgux386)
     THREADS=dgux386
-    AC_MSG_RESULT($THREADLIBS)
+    AC_MSG_RESULT($THREADDLLIBS)
     # Use pthread GCC  switch
-    THREADLIBS=-pthread
+    THREADDLLIBS=-pthread
     if test "${enable_parallel_mark}" = yes; then
         AC_DEFINE(PARALLEL_MARK)
     fi
@@ -182,11 +193,11 @@ case "$THREADS" in
     AC_DEFINE(GC_DGUX386_THREADS)
     AC_DEFINE(DGUX_THREADS)
     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
-    INCLUDES="-pthread $INCLUDES"
+    AM_CPPFLAGS="-pthread $AM_CPPFLAGS"
     ;;
  aix)
     THREADS=posix
-    THREADLIBS=-lpthread
+    THREADDLLIBS=-lpthread
     AC_DEFINE(GC_AIX_THREADS)
     AC_DEFINE(_REENTRANT)
     ;;
@@ -197,7 +208,7 @@ case "$THREADS" in
     AC_MSG_ERROR($THREADS is an unknown thread package)
     ;;
 esac
-AC_SUBST(THREADLIBS)
+AC_SUBST(THREADDLLIBS)
 
 case "$host" in 
    powerpc-*-darwin*)
@@ -206,12 +217,41 @@ case "$host" in
 esac
 AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
 
+# Check if the GCC builtin __sync_bool_compare_and_swap is available.
+# It is preferred in gc_locks.h for PPC as GCC 4.4 has a problem with the inline assembly there.
+AC_MSG_CHECKING(for __sync_bool_compare_and_swap)
+AC_TRY_COMPILE([],[
+volatile unsigned int foo = 0;
+int main(int argc, char** argv) {
+    unsigned int r1 = __sync_bool_compare_and_swap(&foo, 0, 1);
+    return 0;
+}
+], [
+AC_MSG_RESULT(yes)
+AC_DEFINE(HAS___SYNC_BOOL_COMPARE_AND_SWAP)
+], [
+AC_MSG_RESULT(no)
+])
+
+AC_MSG_CHECKING(for xlc)
+AC_TRY_COMPILE([],[
+ #ifndef __xlC__
+ # error
+ #endif
+], [compiler_xlc=yes], [compiler_xlc=no])
+AC_MSG_RESULT($compiler_xlc)
+AM_CONDITIONAL(COMPILER_XLC,test $compiler_xlc = yes)
+if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
+  # the darwin stack-frame-walking code is completely broken on xlc
+  AC_DEFINE(DARWIN_DONT_PARSE_STACK)
+fi
+
 # We never want libdl on darwin. It is a fake libdl that just ends up making
 # dyld calls anyway
 case "$host" in
   *-*-darwin*) ;;
   *) 
-    AC_CHECK_LIB(dl, dlopen, EXTRA_TEST_LIBS="$EXTRA_TEST_LIBS -ldl")
+    AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
     ;;
 esac
 
@@ -234,7 +274,7 @@ addobjs=
 addlibs=
 addincludes=
 addtests=
-CXXINCLUDES=
+CXXAM_CPPFLAGS=
 case "$TARGET_ECOS" in
    no)
       ;;
@@ -254,7 +294,7 @@ AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
 
 AC_SUBST(CXX)
 
-AC_SUBST(INCLUDES)
+AC_SUBST(AM_CPPFLAGS)
 AC_SUBST(CXXINCLUDES)
 
 # Configuration of shared libraries
@@ -312,11 +352,15 @@ case "$host" in
     machdep="sparc_mach_dep.lo"
     AC_DEFINE(SUNOS53_SHARED_LIB)
     ;;
- sparc-sun-solaris2.*)
+ sparc*-sun-solaris2.*)
     machdep="sparc_mach_dep.lo"
     ;;
  ia64-*-*)
-    machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
+     machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
+       target_ia64=true
+    ;;
+ *-*-nacl*)
+    AC_DEFINE(NO_EXECUTE_PERMISSION)
     ;;
 esac
 if test x"$machdep" = x; then
@@ -324,12 +368,21 @@ AC_MSG_RESULT($machdep)
    machdep="mach_dep.lo"
 fi
 addobjs="$addobjs $machdep"
-AC_SUBST(addobjs)
+#
+# Adding object files directly to _LIBADD breaks -j builds, so we need to add the sources
+# instead, but _SOURCES can't contain autoconf substitutions, so add them using automake
+# conditionals.
+#
+#AC_SUBST(addobjs)
 AC_SUBST(addincludes)
 AC_SUBST(addlibs)
 AC_SUBST(addtests)
 
+AM_CONDITIONAL(TARGET_IA64,test x$target_ia64 = xtrue)
+
 AC_PROG_LIBTOOL
+# Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
+DOLT
 
 #
 # Check for AViiON Machines running DGUX
@@ -374,10 +427,10 @@ AC_MSG_RESULT($THREADS)
 
 dnl As of 4.13a2, the collector will not properly work on Solaris when
 dnl built with gcc and -O.  So we remove -O in the appropriate case.
-dnl
+dnl Not needed anymore on Solaris.
 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
 case "$host" in
sparc-sun-solaris2*|*aix*)
+ *aix*)
     if test "$GCC" = yes; then
        AC_MSG_RESULT(yes)
        new_CFLAGS=
@@ -475,6 +528,7 @@ if test "${enable_gc_assertions}" = yes; then
     AC_DEFINE(GC_ASSERTIONS)
 fi
 
+AC_ARG_ENABLE(quiet-build, [  --enable-quiet-build  Enable quiet libgc build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
 
 if test "${multilib}" = "yes"; then
@@ -484,6 +538,7 @@ else
 fi
 
 AC_OUTPUT(Makefile
+m4/Makefile
 include/Makefile
 include/private/Makefile
 doc/Makefile,,