]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/autoconf/status.m4 (_AC_OUTPUT_LINK): Do not try to link a
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 18 Aug 2007 09:07:20 +0000 (09:07 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 18 Aug 2007 09:07:20 +0000 (09:07 +0000)
file to itself if source and build trees coincide.
* tests/torture.at (AC_CONFIG_LINKS and identical files): New
test.
Report by Sebastian Freundt <hroptatyr@gna.org>.

ChangeLog
lib/autoconf/status.m4
tests/torture.at

index 023e01c6989076d55cc79ffd75fe20933307307b..5470a4a8a30f928db5d25caa87a02db162d9c4d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-08-18  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       * 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 <hroptatyr@gna.org>.
+
 2007-07-20  Paul Eggert  <eggert@cs.ucla.edu>
 
        Reword the copyright notices to match what's suggested in GPLv3.
index a3fb561e36b930b28c53e1eaa2027438078692a7..5c00afd3471f6ad17ec73369476171de1514ee43 100644 (file)
@@ -871,24 +871,31 @@ m4_define([_AC_OUTPUT_LINK],
   # 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 1c30e9e763957bd06613723526df4691585276aa..d5e469dba3c26b2dd424cf485e527b2784cc6255 100644 (file)
@@ -880,6 +880,40 @@ AT_CHECK_CONFIGURE([], 1, ignore, ignore)
 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.])