autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_CONFIG_LINKS breaks every second time


From: Ralf Wildenhues
Subject: Re: AC_CONFIG_LINKS breaks every second time
Date: Sat, 18 Aug 2007 11:07:04 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

[ http://lists.gnu.org/archive/html/autoconf-patches/2007-07/msg00008.html ]

* Sebastian Freundt wrote on Wed, Jul 25, 2007 at 12:06:01AM CEST:
> Ralf Wildenhues <address@hidden> writes:
> > * Sebastian Freundt wrote on Mon, Jul 23, 2007 at 11:31:07PM CEST:
> > [...]
> >> my build directory (distinct from $srcdir):
> >> /home/src/=build/
> >> 
> >> There's an AC_CONFIG_LINKS([src/s:src/s]) in my configure.ac.
> >> configure or config.status, respectively, now do the following:
> >> 
> >> 1. in a clean build directory: create the src subdirectory, create the
> >>    symlink from $srcdir/src/s to $builddir/src/s
> >> 2. in a configured build directory: delete $builddir/src/s and create a
> >>    link from $builddir/src/s(!) to $builddir/src/s
> >> 3. in such a screwed build directory, another invocation of config.status
> >>    yields the correct link again ($builddir/src/s -> $srcdir/src/s)
[...]
> > OK to apply?
> 
> Fine by me :)  Works like a charm!

No developer commented, so I installed the patch (copied below again for
autoconf-patches records).

Cheers,
Ralf

2007-08-18  Ralf Wildenhues  <address@hidden>

        * lib/autoconf/status.m4 (_AC_OUTPUT_LINK): Do not try to link a
        file to itself if source and build trees coincide.
        * tests/torture.at (AC_CONFIG_LINKS and identical files): New
        test.
        Report by Sebastian Freundt <address@hidden>.

Index: lib/autoconf/status.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/status.m4,v
retrieving revision 1.136
diff -u -r1.136 status.m4
--- lib/autoconf/status.m4      20 Jul 2007 23:11:53 -0000      1.136
+++ lib/autoconf/status.m4      18 Aug 2007 09:06:19 -0000
@@ -871,24 +871,31 @@
   # CONFIG_LINK
   #
 
-  test -r "$ac_source" || ac_source=$srcdir/$ac_source
+  if test "$ac_source" = "$ac_file" && test "$srcdir" = '.'; then
+    AC_MSG_WARN([not linking $ac_source to itself])
+  else
+    # Prefer the file from the source tree if names are identical.
+    if test "$ac_source" = "$ac_file" || test ! -r "$ac_source"; then
+      ac_source=$srcdir/$ac_source
+    fi
 
-  AC_MSG_NOTICE([linking $ac_source to $ac_file])
+    AC_MSG_NOTICE([linking $ac_source to $ac_file])
 
-  if test ! -r "$ac_source"; then
-    AC_MSG_ERROR([$ac_source: file not found])
-  fi
-  rm -f "$ac_file"
+    if test ! -r "$ac_source"; then
+      AC_MSG_ERROR([$ac_source: file not found])
+    fi
+    rm -f "$ac_file"
 
-  # Try a relative symlink, then a hard link, then a copy.
-  case $srcdir in
-  [[\\/$]]* | ?:[[\\/]]* ) ac_rel_source=$ac_source ;;
-      *) ac_rel_source=$ac_top_build_prefix$ac_source ;;
-  esac
-  ln -s "$ac_rel_source" "$ac_file" 2>/dev/null ||
-    ln "$ac_source" "$ac_file" 2>/dev/null ||
-    cp -p "$ac_source" "$ac_file" ||
-    AC_MSG_ERROR([cannot link or copy $ac_source to $ac_file])
+    # Try a relative symlink, then a hard link, then a copy.
+    case $srcdir in
+    [[\\/$]]* | ?:[[\\/]]* ) ac_rel_source=$ac_source ;;
+       *) ac_rel_source=$ac_top_build_prefix$ac_source ;;
+    esac
+    ln -s "$ac_rel_source" "$ac_file" 2>/dev/null ||
+      ln "$ac_source" "$ac_file" 2>/dev/null ||
+      cp -p "$ac_source" "$ac_file" ||
+      AC_MSG_ERROR([cannot link or copy $ac_source to $ac_file])
+  fi
 ])# _AC_OUTPUT_LINK
 
 
Index: tests/torture.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/torture.at,v
retrieving revision 1.84
diff -u -r1.84 torture.at
--- tests/torture.at    20 Jul 2007 23:11:55 -0000      1.84
+++ tests/torture.at    18 Aug 2007 09:06:19 -0000
@@ -880,6 +880,40 @@
 AT_CLEANUP
 
 
+## ------------------------------------- ##
+## AC_CONFIG_LINKS and identical files.  ##
+## ------------------------------------- ##
+AT_SETUP([AC_CONFIG_LINKS and identical files])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_LINKS([src/s:src/s])
+test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
+AC_OUTPUT
+]])
+
+mkdir src build
+echo file1 > src/s
+echo file2 > src/t
+AT_CHECK_AUTOCONF
+cd build
+AT_CHECK([../configure && ../configure], 0, [ignore])
+AT_CHECK([cat src/s src/t], 0, [file1
+file2
+])
+cd ..
+AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
+AT_CHECK([grep src/t stderr], 1)
+AT_CHECK([cat src/s src/t], 0, [file1
+file2
+])
+AT_CHECK(["`pwd`"/configure && "`pwd`"/configure], 0, [ignore], [ignore])
+AT_CHECK([cat src/s src/t], 0, [file1
+file2
+])
+
+AT_CLEANUP
+
 
 AT_BANNER([autoreconf.])
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]