[Gc]: Dependency tracking for configuration macros

Petter Urkedal urkedal at nbi.dk
Tue Sep 29 12:02:22 PDT 2009


On 2009-09-29, Ivan Maidanski wrote:
> Could you re-post the patch in this ML (if you think it should be applied to bdwgc)?

Attached is the patch, excluding generated files.  Log:

	* configure.ac: Rewrite the tests for external or internal
	libatomic_ops.
	* configure.ac: In particular, drop the symbolic links. Add option
	--with-libatomic-ops for forced selection.
	* Makefile.am: Adjust the path of source files from libatomic_ops to
	not use the links.
	* Makefile.am (libgc_la_LIBADD): Add $(ATOMIC_OPS_LIBS). This will be
	empty if we use the bundled AO sources.

> Nonetheless, I've committed the rename. I don't think having such an artifact is good - the hard-coded version, e.g., may make someone think bdwgc can work only with a particular libatomic_ops version. The cvs version numbers start from 1.1 but the old numbers and log history is in the old place - the only inconvenience is diff across rename (same as for libatomic_ops-1.1 to libatomic_ops-1.2 rename).

Good.  I agree it wouldn't have been nice.  (BTW, Git, which I use,
preserves the history across the rename.  The reason is that it does not
rely on metadata to detect moves but deduce it from the content of the
files.)
-------------- next part --------------
diff --git a/Makefile.am b/Makefile.am
index 46fa7a8..a473cdb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,6 +33,10 @@
 SUBDIRS =
 
 AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
+if USE_INTERNAL_LIBATOMIC_OPS
+AM_CPPFLAGS += -I$(top_builddir)/libatomic_ops/src \
+	       -I$(top_srcdir)/libatomic_ops/src
+endif
 
 # Initialize variables so that we can declare files locally.
 EXTRA_DIST = 
@@ -74,16 +78,16 @@ libgc_la_SOURCES += win32_threads.c
 endif
 
 if USE_INTERNAL_LIBATOMIC_OPS 	 
-nodist_libgc_la_SOURCES = ./atomic_ops.c 	 
+nodist_libgc_la_SOURCES = libatomic_ops/src/atomic_ops.c
 endif 	 
   	 
 if NEED_ATOMIC_OPS_ASM 	 
-nodist_libgc_la_SOURCES = ./atomic_ops_sysdeps.S 	 
+nodist_libgc_la_SOURCES = libatomic_ops/src/atomic_ops_sysdeps.S
 endif
 
 # Include THREADDLLIBS here to ensure that the correct versions of
 # linuxthread semaphore functions get linked:
-libgc_la_LIBADD = @addobjs@ $(THREADDLLIBS) $(UNWINDLIBS)
+libgc_la_LIBADD = @addobjs@ $(THREADDLLIBS) $(UNWINDLIBS) $(ATOMIC_OPS_LIBS)
 libgc_la_DEPENDENCIES = @addobjs@
 libgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:3:0 -no-undefined
 
diff --git a/configure.ac b/configure.ac
index ff1e07b..828f681 100644
--- a/configure.ac
+++ b/configure.ac
@@ -687,57 +687,37 @@ fi
 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
 
 
-dnl Atomic Ops
-dnl ----------
-
-atomic_ops_libs=-latomic_ops
-AC_CHECK_HEADER(atomic_ops.h,
-  [ AC_MSG_NOTICE([Using pre-installed libatomic_ops]) ],
-  [ ao_dir=
-    for candidate in ${srcdir}/libatomic_ops*; do
-	case $candidate in
-	    *.tar.gz)
-		;;
-	    *install)
-	    	dnl generated by alternate Makefile.
-		;;
-	    *)
-		if test -e "$candidate"; then
-		    ao_dir="$candidate"
-		fi
-		;;
-	esac
-    done
-    if test -z "$ao_dir"; then
-	AC_MSG_ERROR([Missig libatomic_ops.])
-    fi
-    ao_version="${ao_dir#*libatomic_ops-}"
-    AC_MSG_NOTICE([Using internal version of libatomic_ops])
-
-    dnl Automake does not accept shell variables in AC_CONFIG_SUBDIRS
-    test -e libatomic_ops \
-	|| ln -s ${ao_dir} libatomic_ops
-    AC_CONFIG_SUBDIRS(libatomic_ops)
-
-    dnl Also copy the source files to be linked in.
-    test -e atomic_ops.c \
-    	|| ln -s libatomic_ops/src/atomic_ops.c \
-		 atomic_ops.c
-
-    test -e atomic_ops_sysdeps.S \
-    	|| ln -s libatomic_ops/src/atomic_ops_sysdeps.S \
-		 atomic_ops_sysdeps.S
-
-    dnl This gets the source include files, which is often close enough.
-    dnl It also makes atomic_ops_sysdeps.S assemble.
-    GC_CFLAGS="${GC_CFLAGS} -I libatomic_ops/src"
-    maybe_libatomic_ops="libatomic_ops"
+# Atomic Ops
+# ----------
+
+# Do we want to use an external libatomic_ops?  By default use it if it's
+# found.
+AC_ARG_WITH([libatomic-ops],
+    [AS_HELP_STRING([--with-libatomic-ops[=yes|no|check]],
+		    [Use a pre-installed libatomic_ops? (default: check)])],
+    [], [with_libatomic_ops=check])
+
+# Check for an external libatomic_ops if the answer was yes or check.  If not
+# found, fail on yes, and convert check to no.
+AS_IF([test x"$with_libatomic_ops" != xno],
+  [ AC_CHECK_HEADER([atomic_ops.h], [],
+      [ AS_IF([test x"$with_libatomic_ops" != xcheck],
+	      [AC_MSG_ERROR([A pre-installed libatomic_ops was not found.])])
+	with_libatomic_ops=no ]) ])
+
+# Finally, emit the definitions for bundled or pre-installed AO.
+AC_MSG_CHECKING([which libatomic_ops to use])
+AS_IF([test x"$with_libatomic_ops" != xno],
+  [ AC_MSG_RESULT([pre-installed])
+    ATOMIC_OPS_LIBS="-latomic_ops"
+    AC_SUBST([ATOMIC_OPS_LIBS]) ],
+  [ AC_MSG_RESULT([bundled])
+    AC_CONFIG_SUBDIRS([libatomic_ops])
   ])
-
-AM_CONDITIONAL(USE_INTERNAL_LIBATOMIC_OPS,
-		test -n "$maybe_libatomic_ops" -a "$THREADS" != "none")
-AM_CONDITIONAL(NEED_ATOMIC_OPS_ASM, test -n "$maybe_libatomic_ops" -a x$need_atomic_ops_asm = xtrue)
-AC_SUBST(atomic_ops_libs)
+AM_CONDITIONAL([USE_INTERNAL_LIBATOMIC_OPS],
+    [test x$with_libatomic_ops = xno -a x"$THREADS" != xnone])
+AM_CONDITIONAL([NEED_ATOMIC_OPS_ASM],
+    [test x$with_libatomic_ops = xno -a x$need_atomic_ops_asm = xtrue])
 
 dnl Produce the Files
 dnl -----------------


More information about the Gc mailing list