From: Ralf Wildenhues Date: Tue, 16 Oct 2007 21:50:03 +0000 (+0200) Subject: Fix `configure --help=recursive' in unconfigured/read-only trees. X-Git-Tag: v2.62~210 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbb9c9628d6700fdf5129c6e1e3e2d4628184dc8;p=thirdparty%2Fautoconf.git Fix `configure --help=recursive' in unconfigured/read-only trees. * lib/m4sugar/m4sh.m4 (_AS_LN_S_PREPARE): Avoid errors when `.' is not writable, use 'cp -p' in this case, in the hope that it will not actually be needed. Still try removing files, in case of other write errors. * lib/autoconf/general.m4 (_AC_INIT_SRCDIR): For ac_confdir, use $as_myself, not $0. (_AC_INIT_HELP): For --help=recursive, if the subdir does not exist, try again in the the source tree. This change assumes that the subpackage configure script is capable of running --help=recursive in the source tree. * tests/torture.at (Configuring subdirectories, Deep Package): Adjust tests to expose both issues, also try invocation as `sh configure ...' and plain `configure ...' with PATH adjusted. * NEWS, THANKS: Update. Report by Hans Ulrich Niedermann. --- diff --git a/ChangeLog b/ChangeLog index 101ba00d..60a1558a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2007-10-16 Ralf Wildenhues + + Fix `configure --help=recursive' in unconfigured/read-only trees. + * lib/m4sugar/m4sh.m4 (_AS_LN_S_PREPARE): Avoid errors when `.' + is not writable, use 'cp -p' in this case, in the hope that it + will not actually be needed. Still try removing files, in case + of other write errors. + * lib/autoconf/general.m4 (_AC_INIT_SRCDIR): For ac_confdir, + use $as_myself, not $0. + (_AC_INIT_HELP): For --help=recursive, if the subdir does not + exist, try again in the the source tree. This change assumes + that the subpackage configure script is capable of running + --help=recursive in the source tree. + * tests/torture.at (Configuring subdirectories, Deep Package): + Adjust tests to expose both issues, also try invocation as + `sh configure ...' and plain `configure ...' with PATH adjusted. + * NEWS, THANKS: Update. + Report by Hans Ulrich Niedermann. + 2007-10-16 Paul Eggert Check for 64-bit int errors in HP-UX 10.20 preprocessor. diff --git a/NEWS b/NEWS index 25095f20..9d31144a 100644 --- a/NEWS +++ b/NEWS @@ -66,6 +66,9 @@ GNU Autoconf NEWS - User visible changes. command './configure --prefix=/usr/' will still result in an expanded libdir value of /usr/lib, not /usr//lib. +** `configure --help=recursive' now works in read-only trees and from + unconfigured build trees. + ** AT_SETUP now handles macro expansions properly when calculating line length. diff --git a/THANKS b/THANKS index c30e3417..4faae015 100644 --- a/THANKS +++ b/THANKS @@ -131,6 +131,7 @@ H. Peter Anvin ? H.J. Lu hjl@gnu.org Hans Aberg haberg@math.su.se Hans Olsson Hans.Olsson@dna.lth.se +Hans Ulrich Niedermann hun@n-dimensional.de Harlan Stenn stenn@whimsy.udel.edu Henk Krus h.krus@cyclone.nl Howard Chu hyc@highlandsun.com diff --git a/configure b/configure index bccfc0a4..ceddf50e 100755 --- a/configure +++ b/configure @@ -513,19 +513,22 @@ if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir - mkdir conf$$.dir -fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln + fi else as_ln_s='cp -p' fi @@ -1172,12 +1175,12 @@ test "X$ac_ls_di" = "X$ac_pwd_ls_di" || if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$0" || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$0" | + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -1329,7 +1332,9 @@ fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || continue + test -d "$ac_dir" || + { cd "$srcdir" && srcdir=. && test -d "$ac_dir"; } || + continue ac_builddir=. case "$ac_dir" in @@ -3261,19 +3266,22 @@ if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir - mkdir conf$$.dir -fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln + fi else as_ln_s='cp -p' fi diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index b57d8872..2834e25c 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -498,7 +498,7 @@ m4_divert_push([PARSE_ARGS])dnl if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. - ac_confdir=`AS_DIRNAME(["$[0]"])` + ac_confdir=`AS_DIRNAME(["$as_myself"])` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. @@ -1102,7 +1102,9 @@ fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || continue + test -d "$ac_dir" || + { cd "$srcdir" && srcdir=. && test -d "$ac_dir"; } || + continue _AC_SRCDIRS(["$ac_dir"]) cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index debf2084..7036c004 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -949,26 +949,30 @@ _AS_LINENO_WORKS || { # Don't use conftest.sym to avoid file name issues on DJGPP, where this # would yield conftest.sym.exe for DJGPP < 2.04. And don't use `conftest' # as base name to avoid prohibiting concurrency (e.g., concurrent -# config.statuses). +# config.statuses). On read-only media, assume 'cp -p' and hope we +# are just running --help anyway. m4_defun([_AS_LN_S_PREPARE], [rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir - mkdir conf$$.dir + mkdir conf$$.dir 2>/dev/null fi -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else as_ln_s='cp -p' -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln + fi else as_ln_s='cp -p' fi diff --git a/tests/torture.at b/tests/torture.at index ea639fc5..0a835ba2 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -1052,7 +1052,9 @@ AT_CHECK([test -f inner/configure]) # Running the outer configure recursively should provide the innermost # help strings. +chmod a-w inner/innermost inner . AT_CHECK([./configure --help=recursive | grep INNER], 0, [ignore]) +chmod u+w . inner inner/innermost # Running the outer configure should trigger the inner. AT_CHECK_CONFIGURE @@ -1154,8 +1156,13 @@ AT_CHECK([test -f inner/innermost/config.hin]) # Running the outer configure recursively should provide the innermost # help strings. +chmod a-w inner/innermost inner AT_CHECK([./configure --help=recursive | grep " INNER "], 0, [ignore]) AT_CHECK([./configure --help=recursive | grep " INNERMOST "], 0, [ignore]) +AT_CHECK([/bin/sh ./configure --help=recursive | grep " INNERMOST "], 0, [ignore]) +AT_CHECK([PATH=.$PATH_SEPARATOR$PATH /bin/sh configure --help=recursive | grep " INNERMOST "], 0, [ignore]) +AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; configure --help=recursive | grep " INNERMOST "], 0, [ignore]) +chmod u+w inner inner/innermost # Running the outer configure should trigger the inner. AT_CHECK_CONFIGURE([INNERMOST=tsomrenni]) @@ -1165,6 +1172,13 @@ AT_CHECK([grep INNERMOST inner/innermost/config.h], 0, # The same, but from a builddir. AS_MKDIR_P([builddir]) +chmod a-w builddir inner/innermost inner +AT_CHECK([cd builddir && ../configure --help=recursive | grep " INNER "], 0, [ignore]) +AT_CHECK([cd builddir && ../configure --help=recursive | grep " INNERMOST "], 0, [ignore]) +AT_CHECK([cd builddir && /bin/sh ../configure --help=recursive | grep " INNERMOST "], 0, [ignore]) +AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help=recursive | grep " INNERMOST "], 0, [ignore]) +AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && configure --help=recursive | grep " INNERMOST "], 0, [ignore]) +chmod u+w builddir inner inner/innermost AT_CHECK([cd builddir && ../configure INNERMOST=build/tsomrenni], 0, [ignore]) AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0, [[#define INNERMOST build/tsomrenni