From: Ralf Wildenhues Date: Sat, 18 Aug 2007 09:07:20 +0000 (+0000) Subject: * lib/autoconf/status.m4 (_AC_OUTPUT_LINK): Do not try to link a X-Git-Tag: v2.62~290 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acb069f9d25ff6ad857f6b8de097506c1c1da0a6;p=thirdparty%2Fautoconf.git * 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 . --- diff --git a/ChangeLog b/ChangeLog index 023e01c6..5470a4a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-08-18 Ralf Wildenhues + + * 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 . + 2007-07-20 Paul Eggert Reword the copyright notices to match what's suggested in GPLv3. diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4 index a3fb561e..5c00afd3 100644 --- a/lib/autoconf/status.m4 +++ b/lib/autoconf/status.m4 @@ -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 diff --git a/tests/torture.at b/tests/torture.at index 1c30e9e7..d5e469db 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -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.])