Skip to content

Commit

Permalink
configure: will re-execute with $CONFIG_SHELL, if it's set
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
slattarini committed Dec 26, 2011
1 parent eee6c22 commit b583202
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 10 deletions.
15 changes: 15 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
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
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ GNU Autoconf NEWS - User visible changes.

* 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.
Expand Down
11 changes: 4 additions & 7 deletions doc/autoconf.texi
Original file line number Diff line number Diff line change
Expand Up @@ -22646,13 +22646,10 @@ can alter its behavior:
@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
Expand Down
6 changes: 3 additions & 3 deletions doc/install.texi
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ overridden in the site shell script).

@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
Expand Down
3 changes: 3 additions & 0 deletions lib/autoconf/general.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,9 @@ m4_pattern_forbid([^LIBOBJS$],
[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])
Expand Down
27 changes: 27 additions & 0 deletions tests/m4sh.at
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,33 @@ test ! -f sentinel || rm -f sentinel # Cleanup for next test.

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. ##
Expand Down

0 comments on commit b583202

Please sign in to comment.