autoconf: 1999-09-27 Akim Demaille <akim@epita.fr> (a9964)

From a9964aef03efe9bbc10aaa0bb9f618f342a7dea3 Mon Sep 17 00:00:00 2001
From: Akim Demaille <[EMAIL REDACTED]>
Date: Mon, 27 Sep 1999 14:06:13 +0000
Subject: [PATCH] 1999-09-27  Akim Demaille  <akim@epita.fr>

	* acgeneral.m4 (AC_OUTPUT): Divert AC_OUTPUT_FILE to
	AC_DIVERSION_KILL if there are no CONFIG_FILES.
	(AC_OUTPUT, ac_cs_usage): Output the list of files to instanciate
	only if there are.
---
 ChangeLog               |  7 +++++++
 acgeneral.m4            | 42 +++++++++++++++++++++++++++--------------
 configure               | 10 ++++------
 lib/autoconf/general.m4 | 42 +++++++++++++++++++++++++++--------------
 4 files changed, 67 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9038ebd8..f1e0ff69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+1999-09-27  Akim Demaille  <akim@epita.fr>
+
+	* acgeneral.m4 (AC_OUTPUT): Divert AC_OUTPUT_FILE to
+	AC_DIVERSION_KILL if there are no CONFIG_FILES.
+	(AC_OUTPUT, ac_cs_usage): Output the list of files to instanciate
+	only if there are.
+
 1999-09-27  Akim Demaille  <akim@epita.fr>
 
 	* acgeneral.m4 (AC_CHECK_DECL): Renamed as...
diff --git a/acgeneral.m4 b/acgeneral.m4
index 79866c7d..d019024f 100644
--- a/acgeneral.m4
+++ b/acgeneral.m4
@@ -2703,7 +2703,7 @@ AC_SUBST(subdirs)dnl
 ])
 
 dnl AC_OUTPUT([CONFIG_FILES...] [, EXTRA-CMDS] [, INIT-CMDS])
-dnl -------------------------------------------------
+dnl ---------------------------------------------------------
 dnl The big finish.
 dnl Produce config.status, config.h, and links; and configure subdirs.
 dnl The CONFIG_HEADERS are defined in the m4 variable AC_LIST_HEADER.
@@ -2751,8 +2751,8 @@ dnl so uname gets run too.
 # configure, is in ./config.log if it exists.
 
 ac_cs_usage="\\
-\\\`$CONFIG_STATUS' configures files from templates according to the current
-configuration.
+\\\`$CONFIG_STATUS' instanciates files from templates according to the
+current configuration.
 
 Usage: $CONFIG_STATUS @BKL@OPTIONS@BKR@ FILE...
 
@@ -2760,14 +2760,17 @@ Usage: $CONFIG_STATUS @BKL@OPTIONS@BKR@ FILE...
   --version    Print the version of Autoconf and exit
   --help       Display this help and exit
 
-By default the following files will updated.
+dnl Output this only if there are files to instanciate.
+ifset(ifdef([AC_LIST_HEADER], 1)$1,
+[Files to instanciate:
 ifset($1, [  Configuration files:
 AC_WRAP($1, [    ])
 ])dnl
 ifdef([AC_LIST_HEADER], [  Configuration headers:
-AC_WRAP(AC_LIST_HEADER, [    ])]
-)dnl
+AC_WRAP(AC_LIST_HEADER, [    ])
+])dnl
 
+])dnl
 Report bugs to <bug-autoconf@gnu.org>."
 
 ac_cs_version="\
@@ -2781,16 +2784,15 @@ dnl files used by configure, and `ac_cs_root' which is the root of the
 dnl files of config.status.
 # Root of the tmp file names.  Use pid to allow concurrent executions.
 ac_cs_root=cs\$\$
-
 ac_given_srcdir=$srcdir
 ifdef([AC_PROVIDE_AC_PROG_INSTALL], [ac_given_INSTALL="$INSTALL"
 ])dnl
 
 # Files that config.status was made for.
-AC_WRAP([config_files="]$1["]
-)
-ifdef([AC_LIST_HEADER], [AC_WRAP([config_headers="]AC_LIST_HEADER["])]
-)dnl
+ifset([$1], [AC_WRAP([config_files="]$1["])
+])dnl
+ifdef([AC_LIST_HEADER], [AC_WRAP([config_headers="]AC_LIST_HEADER["])
+])dnl
 
 for ac_option
 do
@@ -2830,10 +2832,13 @@ done
 
 EOF
 
-cat >> $CONFIG_STATUS <<EOF
+dnl Issue this section only if there were actually config files.
+ifset(ifdef([AC_LIST_HEADER], 1)[$1],
+[cat >> $CONFIG_STATUS <<EOF
 # If there were arguments, don't assign a default value.
 if test \$[#] = 0; then
-  : \${CONFIG_FILES="\$config_files"}
+ifset([$1], [  : \${CONFIG_FILES="\$config_files"}
+])dnl
 ifdef([AC_LIST_HEADER], [  : \${CONFIG_HEADERS="\$config_headers"}
 ])dnl
 fi
@@ -2845,10 +2850,19 @@ rm -fr \`echo "\$CONFIG_FILES" | sed "s/:@BKL@^ @BKR@*//g"\`
 trap 'rm -fr \$ac_cs_root*; exit 1' 1 2 15
 
 EOF
+])[]dnl
 
 dnl The following three sections are in charge of their own here
 dnl documenting into $CONFIG_STATUS.
-AC_OUTPUT_FILES($1)
+
+dnl Because AC_OUTPUT_FILES is in charge of undiverting the AC_SUBST
+dnl section, it is better to divert it to void and *call it*, rather
+dnl than not calling it at all
+ifset([$1],
+      [AC_OUTPUT_FILES([$1])],
+      [AC_DIVERT_PUSH(AC_DIVERSION_KILL)dnl
+AC_OUTPUT_FILES([$1])dnl
+AC_DIVERT_POP()])dnl
 ifdef([AC_LIST_HEADER], [AC_OUTPUT_HEADER(AC_LIST_HEADER)])dnl
 ifdef([AC_LIST_LINKS], [AC_OUTPUT_LINKS(AC_LIST_FILES, AC_LIST_LINKS)])dnl
 
diff --git a/configure b/configure
index f184f461..26bc53ab 100755
--- a/configure
+++ b/configure
@@ -901,8 +901,8 @@ cat > $CONFIG_STATUS <<EOF
 # configure, is in ./config.log if it exists.
 
 ac_cs_usage="\\
-\\\`$CONFIG_STATUS' configures files from templates according to the current
-configuration.
+\\\`$CONFIG_STATUS' instanciates files from templates according to the
+current configuration.
 
 Usage: $CONFIG_STATUS [OPTIONS] FILE...
 
@@ -910,10 +910,9 @@ Usage: $CONFIG_STATUS [OPTIONS] FILE...
   --version    Print the version of Autoconf and exit
   --help       Display this help and exit
 
-By default the following files will updated.
+Files to instanciate:
   Configuration files:
     Makefile testsuite/Makefile 
-
 Report bugs to <bug-autoconf@gnu.org>."
 
 ac_cs_version="\
@@ -923,7 +922,6 @@ Configured on host `(hostname || uname -n) 2>/dev/null | sed 1q` by running
 
 # Root of the tmp file names.  Use pid to allow concurrent executions.
 ac_cs_root=cs\$\$
-
 ac_given_srcdir=$srcdir
 ac_given_INSTALL="$INSTALL"
 
@@ -980,6 +978,7 @@ trap 'rm -fr \$ac_cs_root*; exit 1' 1 2 15
 
 EOF
 
+
 cat >>$CONFIG_STATUS <<EOF
 # Protect against being on the right side of a sed subst in config.status.
 sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
@@ -1130,7 +1129,6 @@ fi; done
 rm -f $ac_cs_root.s*
 EOF
 
-
 cat >> $CONFIG_STATUS <<EOF
 
 EOF
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 79866c7d..d019024f 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2703,7 +2703,7 @@ AC_SUBST(subdirs)dnl
 ])
 
 dnl AC_OUTPUT([CONFIG_FILES...] [, EXTRA-CMDS] [, INIT-CMDS])
-dnl -------------------------------------------------
+dnl ---------------------------------------------------------
 dnl The big finish.
 dnl Produce config.status, config.h, and links; and configure subdirs.
 dnl The CONFIG_HEADERS are defined in the m4 variable AC_LIST_HEADER.
@@ -2751,8 +2751,8 @@ dnl so uname gets run too.
 # configure, is in ./config.log if it exists.
 
 ac_cs_usage="\\
-\\\`$CONFIG_STATUS' configures files from templates according to the current
-configuration.
+\\\`$CONFIG_STATUS' instanciates files from templates according to the
+current configuration.
 
 Usage: $CONFIG_STATUS @BKL@OPTIONS@BKR@ FILE...
 
@@ -2760,14 +2760,17 @@ Usage: $CONFIG_STATUS @BKL@OPTIONS@BKR@ FILE...
   --version    Print the version of Autoconf and exit
   --help       Display this help and exit
 
-By default the following files will updated.
+dnl Output this only if there are files to instanciate.
+ifset(ifdef([AC_LIST_HEADER], 1)$1,
+[Files to instanciate:
 ifset($1, [  Configuration files:
 AC_WRAP($1, [    ])
 ])dnl
 ifdef([AC_LIST_HEADER], [  Configuration headers:
-AC_WRAP(AC_LIST_HEADER, [    ])]
-)dnl
+AC_WRAP(AC_LIST_HEADER, [    ])
+])dnl
 
+])dnl
 Report bugs to <bug-autoconf@gnu.org>."
 
 ac_cs_version="\
@@ -2781,16 +2784,15 @@ dnl files used by configure, and `ac_cs_root' which is the root of the
 dnl files of config.status.
 # Root of the tmp file names.  Use pid to allow concurrent executions.
 ac_cs_root=cs\$\$
-
 ac_given_srcdir=$srcdir
 ifdef([AC_PROVIDE_AC_PROG_INSTALL], [ac_given_INSTALL="$INSTALL"
 ])dnl
 
 # Files that config.status was made for.
-AC_WRAP([config_files="]$1["]
-)
-ifdef([AC_LIST_HEADER], [AC_WRAP([config_headers="]AC_LIST_HEADER["])]
-)dnl
+ifset([$1], [AC_WRAP([config_files="]$1["])
+])dnl
+ifdef([AC_LIST_HEADER], [AC_WRAP([config_headers="]AC_LIST_HEADER["])
+])dnl
 
 for ac_option
 do
@@ -2830,10 +2832,13 @@ done
 
 EOF
 
-cat >> $CONFIG_STATUS <<EOF
+dnl Issue this section only if there were actually config files.
+ifset(ifdef([AC_LIST_HEADER], 1)[$1],
+[cat >> $CONFIG_STATUS <<EOF
 # If there were arguments, don't assign a default value.
 if test \$[#] = 0; then
-  : \${CONFIG_FILES="\$config_files"}
+ifset([$1], [  : \${CONFIG_FILES="\$config_files"}
+])dnl
 ifdef([AC_LIST_HEADER], [  : \${CONFIG_HEADERS="\$config_headers"}
 ])dnl
 fi
@@ -2845,10 +2850,19 @@ rm -fr \`echo "\$CONFIG_FILES" | sed "s/:@BKL@^ @BKR@*//g"\`
 trap 'rm -fr \$ac_cs_root*; exit 1' 1 2 15
 
 EOF
+])[]dnl
 
 dnl The following three sections are in charge of their own here
 dnl documenting into $CONFIG_STATUS.
-AC_OUTPUT_FILES($1)
+
+dnl Because AC_OUTPUT_FILES is in charge of undiverting the AC_SUBST
+dnl section, it is better to divert it to void and *call it*, rather
+dnl than not calling it at all
+ifset([$1],
+      [AC_OUTPUT_FILES([$1])],
+      [AC_DIVERT_PUSH(AC_DIVERSION_KILL)dnl
+AC_OUTPUT_FILES([$1])dnl
+AC_DIVERT_POP()])dnl
 ifdef([AC_LIST_HEADER], [AC_OUTPUT_HEADER(AC_LIST_HEADER)])dnl
 ifdef([AC_LIST_LINKS], [AC_OUTPUT_LINKS(AC_LIST_FILES, AC_LIST_LINKS)])dnl