bug-autoconf
[Top][All Lists]
Advanced

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

Re: "configure --help=recursive" only works in top_srcdir


From: Ralf Wildenhues
Subject: Re: "configure --help=recursive" only works in top_srcdir
Date: Fri, 12 Oct 2007 20:26:21 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

Hello Hans Ulrich, Stepan, all,

Sorry for the delay, I had to go back and think some more on
<http://thread.gmane.org/gmane.comp.sysutils.autoconf.bugs/5667>,
when Paul came to help and solved half of the problems in
<http://lists.gnu.org/archive/html/autoconf-patches/2007-10/msg00060.html>.

* Ralf Wildenhues wrote on Wed, Jul 18, 2007 at 11:01:23PM CEST:
> * Stepan Kasal wrote on Tue, Jul 17, 2007 at 02:45:46PM CEST:
> [...]
> > Near the top of m4sh initialization, we'd do:
> >     case $1 in
> >     --help | --help=* | --version ) as_skip_wr_tests=yes ;;
> >     esac
> > And then put the test which write to cwd inside an
> >     if test -z "$as_skip_wr_tests"
> 
[...]
> > Would it be too crazy to hardwire this into the AS_INIT code?
> > The --help and --version option are special: they are defined in the GCS.
> 
> Yes but also the GCS requires that these options work whereever they
> are passed, and there are several abbreviations that are accepted by
> the later configure code.  For example,
>   ./configure --bindir=/foo --help=... --datadir=...
> 
> should work as expected, and it would strike me as odd if
>   ./configure -V
> 
> (or --vers) would execute different code than
>   ./configure --version

...which is one reason why I don't like to have two different sections
that parse "$@".

Here's an analysis of what tests write files before argument parsing,
why, and their dependencies, and a new proposed patch, obsoleting the
other one fully.

0) Libtool's search-better-shell uses $0 instead of $as_myself.  That's
probably a separate bug, to be addressed there.  Can I rely on this
variable's presence?

1) If the LINENO test fails, it reads from $as_myself and creates
$as_me.lineno, chmods and sources that.
  - When it cannot write, it currently just fails loudly:
    "rerun with POSIX shell."  I think this is ok, as it guides users as
    to what to do.
  - Not using $$ in the name here prevents concurrency (a sub configure
    script using the same build directory as the toplevel one).  OTOH,
    using $$ in the name is very dangerous here: the script is
    long-lived, Automake et. al. have it hard-wired for cleaning.
    This means that for read-only pwd but writable srcdir, we have to
    descend to subpackages' source subdirectories with help=recursive.

2) The ln -s test writes conf$$.dir conf$$.file
  - We could just set as_ln_s to `cp -p' in this case, in the hope that
    --help was given anyway.
    But we should try to remove files anyway: may have been write error
    due to full disk.

3) The `mkdir -p' test may write ./-p
  - Well if not writable, then there is no problem at all except for a
    (desirable!) write error message.

4) Setting $srcdir requires readable `.' and `cd srcdir' to work.


[1] Anyway, `sh configure' with configure found in $PATH is broken at
the moment.  No wonder, as we don't test it.  Fixed, and test adjusted
in the patch below: _AC_INIT_SRCDIR was using $0 instead of $as_myself.


This change will have an impact on recursive packages where an inner
package's configure script was created with an older Autoconf release:
it will start complaining about write errors with
  mkdir build && cd build && ../path/to/cdrom/configure --help=recursive

OTOH, that usage just failed silently before, so it's not a regression.

OK to apply, regenerate configure, and put Hans Ulrich in THANKS?

This change puts one more subshell forks into the default execution
path for each configure invocation.  I guess one could also 
  test -w . && test -d .
but I think just trying to create a file is more idiomatic.

Cheers,
Ralf

2007-10-12  Ralf Wildenhues  <address@hidden>

        * 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/NEWS b/NEWS
index 2a59f84..e583dbf 100644
--- a/NEWS
+++ b/NEWS
@@ -59,6 +59,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.  However, as a side effect, any whitespace immediately
    following a single-quoted comma is lost.  If you previously used
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 1b7a355..350c89a 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 157b844..167b82f 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 ea639fc..0a835ba 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




reply via email to

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