Merge pull request #1056 from ranma42/vc-compat-C90
[mono.git] / libgc / configure.in
index 6fcf1ace4dcfcee1a310036651c7be44ce2b2350..837e2cb9f158c14f8cdbe47e0abc14091db14edf 100644 (file)
 
 dnl Process this file with autoconf to produce configure.
 
-AC_PREREQ(2.53)
-AC_INIT(libgc-mono, 6.6, Hans_Boehm@hp.com)
-
-AM_INIT_AUTOMAKE(libgc-mono, 6.6, 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,12 +41,21 @@ 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
@@ -66,7 +77,7 @@ AC_ARG_ENABLE(cplusplus,
 [  --enable-cplusplus          install C++ support],
 )
 
-INCLUDES=-I${srcdir}/include
+AM_CPPFLAGS=-I${srcdir}/include
 THREADDLLIBS=
 ## Libraries needed to support dynamic loading and/or threads.
 case "$THREADS" in
@@ -75,7 +86,7 @@ case "$THREADS" in
     ;;
  posix | pthreads)
     THREADS=posix
-    THREADDLLIBS=-lpthread
+    AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
     case "$host" in
      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)
@@ -85,7 +96,7 @@ case "$THREADS" in
        fi
        AC_DEFINE(THREAD_LOCAL_ALLOC)
        ;;
-     *-*-linux*)
+     *-*-linux* | *-*-nacl*)
        AC_DEFINE(GC_LINUX_THREADS)
        AC_DEFINE(_REENTRANT)
        ;;
@@ -103,36 +114,17 @@ case "$THREADS" in
        AC_DEFINE(THREAD_LOCAL_ALLOC)
        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
-               THREADDLLIBS=-pthread
-       else
-               THREADDLLIBS=$PTHREAD_LIBS
-       fi
-       ;;
-     *-*-freebsd5*)
-       AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
+      *-*-freebsd*)
        AC_DEFINE(GC_FREEBSD_THREADS)
-       INCLUDES="$INCLUDES -pthread"
-       THREADDLLIBS=-pthread
-       ;;
-        *-*-freebsd6*)
-        AC_DEFINE(GC_FREEBSD_THREADS)
-        if test "x$PTHREAD_CFLAGS" != "x"; then
-               INCLUDES="$INCLUDES $PTHREAD_CFLAGS"
+       if test "x$PTHREAD_CFLAGS" != "x"; then
+               AM_CPPFLAGS="$AM_CPPFLAGS $PTHREAD_CFLAGS"
        fi
        if test "x$PTHREAD_LIBS" = "x"; then
                THREADDLLIBS=-pthread
        else
                THREADDLLIBS="$PTHREAD_LIBS"
        fi
+       AC_DEFINE(THREAD_LOCAL_ALLOC)
        ;;
      *-*-solaris*)
        AC_DEFINE(GC_SOLARIS_THREADS)
@@ -158,6 +150,13 @@ case "$THREADS" in
        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
@@ -166,7 +165,7 @@ case "$THREADS" in
          # May want to enable it in other cases, too.
          # Measurements havent yet been done.
        fi
-       INCLUDES="$INCLUDES -pthread"
+       AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
        THREADDLLIBS="-lpthread -lrt"
        ;;
       *)
@@ -194,7 +193,7 @@ 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
@@ -218,6 +217,22 @@ 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__
@@ -259,7 +274,7 @@ addobjs=
 addlibs=
 addincludes=
 addtests=
-CXXINCLUDES=
+CXXAM_CPPFLAGS=
 case "$TARGET_ECOS" in
    no)
       ;;
@@ -279,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
@@ -341,7 +356,11 @@ case "$host" in
     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
@@ -349,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
@@ -500,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
@@ -509,6 +538,7 @@ else
 fi
 
 AC_OUTPUT(Makefile
+m4/Makefile
 include/Makefile
 include/private/Makefile
 doc/Makefile,,