]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Add and document AS_INIT_GENERATED.
authorPaolo Bonzini <bonzini@gnu.org>
Fri, 10 Oct 2008 07:02:36 +0000 (09:02 +0200)
committerPaolo Bonzini <bonzini@gnu.org>
Mon, 13 Oct 2008 16:01:21 +0000 (18:01 +0200)
* lib/m4sugar/m4sh.m4 (AS_INIT_GENERATED): New.
* lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS): Use it.
* doc/autoconf.texi (Initialization macros): Document it.

ChangeLog
doc/autoconf.texi
lib/autoconf/status.m4
lib/m4sugar/m4sh.m4

index 418aff61e49dac4cd045ea33c9b321d2ea550af2..bd108add7527d8e62d8bcb6b3fdc1f44a2b4daf2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-10-13  Paolo Bonzini  <bonzini@gnu.org>
+
+       Add and document AS_INIT_GENERATED.
+       * lib/m4sugar/m4sh.m4 (AS_INIT_GENERATED): New.
+       * lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS): Use it.
+       * doc/autoconf.texi (Initialization macros): Document it.
+
 2008-10-13  Eric Blake  <ebb9@byu.net>
 
        Use consistent shell function style.
index d9d82aa7c353390fea7de012c1542aed0c286c11..ff81c2ecd2bcfb793fb5965797d05fdcb40a9bbd 100644 (file)
@@ -11943,6 +11943,41 @@ generated from, and code to sanitize the environment for the rest of the
 script.  Finally, it changes the current diversion to @code{BODY}.
 @end defmac
 
+@defmac AS_INIT_GENERATED
+@asindex{INIT_GENERATED}
+Initialize the M4sh environment.  This macro emits again all the
+code that is generated by @code{AS_INIT}, including the expansion of
+@code{AS_BOURNE_COMPATIBLE} and @code{AS_SHELL_SANITIZE}.  It is meant
+to be used in a quoted here document when generating other shell scripts.
+
+Note that @code{AS_INIT_GENERATED} does not emit the entire prolog.
+In particular, a line containing @code{#!$SHELL} must have already been
+emitted to the child script; you should not use @code{#!/bin/sh}, or the
+child script will not use the more modern shell that the parent script
+might have detected.  Currently, the suggested idiom for writing a M4sh
+shell script from within another script is:
+
+@example
+m4_rename([AS_MESSAGE_LOG_FD], [save_AS_MESSAGE_LOG_FD])dnl
+cat > "@var{file}" <<__EOF__
+#! $SHELL
+# Generated by $as_me.
+# ...
+
+SHELL=\$@{CONFIG_SHELL-$SHELL@}
+__EOF__
+
+cat >>"@var{file}" <<\__EOF__
+AS_INIT_GENERATED
+# ...
+__EOF__
+m4_rename([save_AS_MESSAGE_LOG_FD], [AS_MESSAGE_LOG_FD])dnl
+@end example
+
+This, however, may change in the future as the M4sh interface is
+stabilized further.
+@end defmac
+
 @defmac AS_LINENO_PREPARE
 @asindex{LINENO_PREPARE}
 @evindex LINENO
index ddc5f47fb3c54774116ad46fee67b805afb57a61..6d622b9e42487e058913f018619dac012b2fd8d2 100644 (file)
@@ -1332,11 +1332,7 @@ SHELL=\${CONFIG_SHELL-$SHELL}
 _ACEOF
 
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-AS_SHELL_SANITIZE
-dnl Watch out, this is directly the initializations, do not use
-dnl AS_PREPARE, otherwise you'd get it output in the initialization
-dnl of configure, not config.status.
-_AS_PREPARE
+AS_INIT_GENERATED
 exec AS_MESSAGE_FD>&1
 
 # Save the log message, to keep $[0] and so on meaningful, and to
index 2e6b2f2c21b3fd8c0bcc1713a7a0a6759e702283..9c09dc0147b7752ff5e9e5168b01ff98d4163586 100644 (file)
@@ -1695,6 +1695,17 @@ m4_define([AS_VAR_POPDEF],
 ## ----------------- ##
 
 
+# AS_INIT_GENERATED
+# -----------------
+# Emit m4sh initialization code in a suitable form for a quoted
+# here document.  Does not emit the `#!' sequence, which should be
+# generated with `#! $SHELL'; see the manual or autoconf/status.m4
+# for more detail.
+m4_defun([AS_INIT_GENERATED],
+[m4_require([AS_PREPARE])dnl
+AS_SHELL_SANITIZE
+_AS_PREPARE])
+
 # AS_INIT
 # -------
 # Initialize m4sh.