+2011-12-26 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ configure: will re-execute with $CONFIG_SHELL, if it's set
+ * lib/m4sugar/general.m4 (_AS_DETECT_BETTER_SHELL): Define the macro
+ `_AS_FORCE_REEXEC_WITH_CONFIG_SHELL' to `yes', so that the code in
+ `_AS_DETECT_BETTER_SHELL' will cause autoconf-generated configure
+ scripts to always re-execute themselves with $CONFIG_SHELL, if it's
+ set in the environment.
+ * doc/autoconf.texi (config.status Invocation): Update.
+ * doc/install.texi (Defining Variables): Likewise.
+ * NEWS: Likewise.
+ * tests/m4sh.at: Add tests for the new semantics in ...
+ (Configure re-execs self with CONFIG_SHELL): ... this new
+ test group.
+
2011-12-26 Stefano Lattarini <stefano.lattarini@gmail.com>
m4sh: allow forced re-execution with $CONFIG_SHELL, if it's set
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Autoconf-generated configure scripts now unconditionally re-execute
+ themselves with $CONFIG_SHELL, if that's set in the environment.
+
** The texinfo documentation no longer specifies "front-cover" or
"back-cover" texts, so that it may now be included in Debian's
"main" section.
@anchor{CONFIG_SHELL}
@defvar CONFIG_SHELL
@evindex CONFIG_SHELL
-The shell with which to run @command{configure} for the @option{--recheck}
-option. It must be Bourne-compatible. The default is a shell that
-supports @code{LINENO} if available, and @file{/bin/sh} otherwise.
-Invoking @command{configure} by hand bypasses this setting, so you may
-need to use a command like @samp{CONFIG_SHELL=/bin/bash /bin/bash ./configure}
-to insure that the same shell is used everywhere. The absolute name of the
-shell should be passed.
+The shell with which to run @command{configure}. It must be
+Bourne-compatible, and the absolute name of the shell should be passed.
+The default is a shell that supports @code{LINENO} if available, and
+@file{/bin/sh} otherwise.
@end defvar
@defvar CONFIG_STATUS
@noindent
Unfortunately, this technique does not work for @env{CONFIG_SHELL} due
-to an Autoconf bug. Until the bug is fixed you can use this
-workaround:
+to an Autoconf limitation. Until the limitation is lifted, you can use
+this workaround:
@example
-CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
@end example
@node configure Invocation
[do not use LIBOBJS directly, use AC_LIBOBJ (see section `AC_LIBOBJ vs LIBOBJS'])
# Actually reserved by M4sh.
m4_pattern_allow([^AS_FLAGS$])
+# So that the autoconf-generated scripts will always re-execute
+# themselves with $CONFIG_SHELL, if that's set in the environment.
+m4_define([_AS_FORCE_REEXEC_WITH_CONFIG_SHELL], [yes])
AS_INIT[]dnl
AS_PREPARE[]dnl
m4_divert_push([KILL])
AT_CLEANUP
+AT_SETUP([Configure re-execs self with CONFIG_SHELL])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+echo foobar >> quux
+]])
+
+AT_CHECK_AUTOCONF
+
+AT_DATA([cfg-sh],
+[[#!/bin/sh
+: > cfg-sh-has-run
+exec sh "@S|@@"
+]])
+chmod a+x cfg-sh
+
+AT_CAPTURE_FILE([config.log])
+AT_CHECK([env CONFIG_SHELL=./cfg-sh ./configure], [0], [], [])
+# ./configure re-executed itself.
+AT_CHECK([test -f cfg-sh-has-run], [0])
+# And did that not to cause extra execution of later commands.
+AT_CHECK([cat quux], [0], [foobar
+], [])
+
+rm -f quux cfg-sh*
+AT_CLEANUP
+
## ------------------- ##
## AS_WARN, AS_ERROR. ##