+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.
# 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
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.])