autoconf: 1999-10-01 Akim Demaille <akim@epita.fr> (07035)

From 07035fdaa20709e44d979fb73241997fc9e23591 Mon Sep 17 00:00:00 2001
From: Akim Demaille <[EMAIL REDACTED]>
Date: Mon, 4 Oct 1999 08:19:57 +0000
Subject: [PATCH] 1999-10-01  Akim Demaille  <akim@epita.fr>

	Make the handling of the configuration links (AC_LINK_FILES)
	exactly the same as that of configurations files (AC_OUTPUT_FILES)
	and headers (AC_CONFIG_HEADERS).  As a result, it is sane to run
		./config.status src/libmy_lib
	or
		CONFIG_LINKS=src/lib_mylib:lib/lib_mylib ./config.status

	* acgeneral.m4 (AC_LINK_FILES): Use AC_FATAL to diagnose bad
	number of argument.
	Obsoleted (but implemented) in favor of AC_CONFIG_LINKS.

	* acgeneral.m4 (AC_CONFIG_LINKS): New macro.  Takes space
	separated list of DEST:SOURCES arguments.

	* acgeneral.m4: Rename each occurence of AC_LIST_HEADER as
 	AC_LIST_HEADERS for consistency.

	* acgeneral.m4 (AC_OUTPUT, config.status prologue): Move the
	definition of config_files and config_headers to the top.
	Add the definition of config_links.
	Change the help message to use the aforementioned variables.

	* acgeneral.m4 (AC_OUTPUT_LINKS): Adapted to the new scheme of
	AC_LIST_LINKS.

	* autoconf.texi (Output, AC_OUTPUT): Mention AC_CONFIG_LINKS.
	(Invoking config.status): Mention CONFIG_LINKS.

	* autoconf.texi (Using System Type): Document AC_CONFIG_LINKS.
	Explicit the obsoleteness of AC_LINK_FILES.
---
 ChangeLog               |  33 ++++++++++
 NEWS                    |   9 ++-
 TODO                    |  12 ++++
 acgeneral.m4            | 138 ++++++++++++++++++++++++++--------------
 autoconf.texi           |  45 ++++++++++---
 doc/autoconf.texi       |  45 ++++++++++---
 lib/autoconf/general.m4 | 138 ++++++++++++++++++++++++++--------------
 7 files changed, 302 insertions(+), 118 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 048a7f58..4c6113da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+1999-10-01  Akim Demaille  <akim@epita.fr>
+
+	Make the handling of the configuration links (AC_LINK_FILES)
+	exactly the same as that of configurations files (AC_OUTPUT_FILES)
+	and headers (AC_CONFIG_HEADERS).  As a result, it is sane to run
+		./config.status src/libmy_lib
+	or
+		CONFIG_LINKS=src/lib_mylib:lib/lib_mylib ./config.status
+
+	* acgeneral.m4 (AC_LINK_FILES): Use AC_FATAL to diagnose bad
+	number of argument.
+	Obsoleted (but implemented) in favor of AC_CONFIG_LINKS.
+
+	* acgeneral.m4 (AC_CONFIG_LINKS): New macro.  Takes space
+	separated list of DEST:SOURCES arguments.
+
+	* acgeneral.m4: Rename each occurence of AC_LIST_HEADER as
+ 	AC_LIST_HEADERS for consistency.
+
+	* acgeneral.m4 (AC_OUTPUT, config.status prologue): Move the
+	definition of config_files and config_headers to the top.
+	Add the definition of config_links.
+	Change the help message to use the aforementioned variables.
+
+	* acgeneral.m4 (AC_OUTPUT_LINKS): Adapted to the new scheme of
+	AC_LIST_LINKS.
+
+	* autoconf.texi (Output, AC_OUTPUT): Mention AC_CONFIG_LINKS.
+	(Invoking config.status): Mention CONFIG_LINKS.
+
+	* autoconf.texi (Using System Type): Document AC_CONFIG_LINKS.
+	Explicit the obsoleteness of AC_LINK_FILES.
+
 1999-10-01  Akim Demaille  <akim@epita.fr>
 
 	Moving most of the task of creating config.h.in from sh to m4.
diff --git a/NEWS b/NEWS
index 94002225..2a14dac9 100644
--- a/NEWS
+++ b/NEWS
@@ -4,12 +4,15 @@ Major changes in release 2.15:
   - much faster on most architectures
   - has a useful --help
   - concurrent executions
-    It is safe to use `make -j' with configure.
+    It is safe to use `make -j' with config.status.
+  - files to links (AC_LINK_FILES) can be specified via CONFIG_LINKS.
   - human interface improved
     It is possible to invoke
       ./config.status foobar
     instead of the former form (still valid)
-      CONFIG_HEADERS= CONFIG_FILES=foobar:foo.in:bar.in
+      CONFIG_HEADERS= CONFIG_LINKS= CONFIG_FILES=foobar:foo.in:bar.in \
+      ./config.status
+    The same holds for configuration headers and links.
 * New macros
   - AC_CHECK_DECL and AC_CHECK_DECLS
     To check whether a symbol is declared.
@@ -18,6 +21,8 @@ Major changes in release 2.15:
     when the user executes `configure --help'.
   - AC_ARG_VAR
     Document and ask for the registration of an envvar.
+  - AC_CONFIG_LINKS
+    Replaces the now obsolete AC_LINK_FILES.
 * Environment variables are kept when reconfiguring.
   The previous scheme to set envvar before running configure was
     ENV=VAL ./configure
diff --git a/TODO b/TODO
index fe1670dd..d2fd9989 100644
--- a/TODO
+++ b/TODO
@@ -16,6 +16,18 @@ easy), or remove (obsoleted since then).
 ** AC_CHECK_HEADER should not template config.h entries.
 Its entry in autoheader.m4 should be removed.
 
+
+** Document GNATS?
+
+** gettext (This is more for Automake, but I'm afraid to forget --akim)
+There a nsl_cv_ which is actually nls_cv_.
+It seems not valid to me to give twho empty strings to AC_LINK_FILES.
+The user should check herself if she wants not to link, it is not
+the job of Autoconf.
+
+Currently there are hacks to keep it legal, but it should be made
+illegal in the future.
+
 ** fnmatch
 From: Stanislav Brabec <utx@k332.feld.cvut.cz>
 
diff --git a/acgeneral.m4 b/acgeneral.m4
index 2140e9e0..2bcc3ffa 100644
--- a/acgeneral.m4
+++ b/acgeneral.m4
@@ -245,12 +245,12 @@ define(m4_foreach,
 [pushdef([$1], [])_m4_foreach($@)popdef([$1])])
 
 dnl Low level macros used to define m4_foreach
-define(_m4_car, [[$1]])
+define(m4_car, [[$1]])
 define(_m4_foreach,
 [ifelse($2, [()], ,
-        [define([$1], [_m4_car$2])$3[]_m4_foreach([$1],
-                                                  [(m4_shift$2)],
-                                                  [$3])])])
+        [define([$1], [m4_car$2])$3[]_m4_foreach([$1],
+                                                 [(m4_shift$2)],
+                                                 [$3])])])
 
 
 dnl m4_list_append(LIST, ELEMENT)
@@ -2300,7 +2300,7 @@ dnl because the test really is for library $1 defining function $2, not
 dnl just for library $1.  Separate tests with the same $1 and different $2s
 dnl may have different results.
 dnl
-dnl FIXME: This macro is extremely suspicious.  It DEFINE unconditionnally,
+dnl FIXME: This macro is extremely suspicious.  It DEFINEs unconditionnally,
 dnl whatever the FUNCTION, in addition to not being a *S macro.  Note
 dnl that the cache does depend upon the function with look for.
 AC_DEFUN(AC_CHECK_LIB,
@@ -2776,19 +2776,43 @@ dnl ### Creating output files
 
 dnl AC_CONFIG_HEADER(HEADER-TO-CREATE ...)
 AC_DEFUN(AC_CONFIG_HEADER,
-[define(AC_LIST_HEADER, $1)])
+[define(AC_LIST_HEADERS, $1)])
 
+
+dnl AC_CONFIG_LINKS(DEST:SOURCE...)
+dnl -------------------------------
+dnl Specify that config.status should establish a (symbolic if possible)
+dnl link from TOP_SRCDIR/SOURCE to TOP_SRCDIR/DEST.
+dnl Reject DEST=., because it is makes it hard for ./config.status
+dnl to guess the links to establish (`./config.status .').
+AC_DEFUN(AC_CONFIG_LINKS,
+[ifelse(regexp([$1], [^.:]), -1,,
+        [AC_FATAL([$0: invalid destination: `.'])])
+ifelse(regexp([$1], [ .:]), -1,,
+        [AC_FATAL([$0: invalid destination: `.'])])
+define([AC_LIST_LINKS],
+       ifdef([AC_LIST_LINKS], [AC_LIST_LINKS ],)[$1])])
+
+
+dnl AC_LINK_FILES(SOURCE..., DEST...)
+dnl ---------------------------------
 dnl Link each of the existing files SOURCE... to the corresponding
 dnl link name in DEST...
-dnl AC_LINK_FILES(SOURCE..., DEST...)
 AC_DEFUN(AC_LINK_FILES,
-[dnl
-ifelse($#, 2, , dnl
-  [errprint(__file__:__line__: incorrect number of arguments to [AC_LINK_FILES]
-)]
-  AC_MSG_ERROR([aborting due to error at __file__:__line__]))dnl
-define([AC_LIST_FILES], ifdef([AC_LIST_FILES], [AC_LIST_FILES ],)[$1])dnl
-define([AC_LIST_LINKS], ifdef([AC_LIST_LINKS], [AC_LIST_LINKS ],)[$2])])
+[AC_OBSOLETE([$0], [; instead use AC_CONFIG_FILES(DEST:SOURCE...)])dnl
+ifelse($#, 2, ,
+  [AC_FATAL([$0: incorrect number of arguments])])
+pushdef([AC_Sources], m4_split(m4_strip(m4_join([$1]))))
+pushdef([AC_Dests], m4_split(m4_strip(m4_join([$2]))))
+m4_foreach([AC_Dummy], (AC_Sources),
+  [AC_CONFIG_LINKS(m4_car(AC_Dests):m4_car(AC_Sources))
+   define([AC_Sources], m4_quote(m4_shift(AC_Sources)))
+   define([AC_Dests], m4_quote(m4_shift(AC_Dests)))])
+popdef([AC_Sources])
+popdef([AC_Dests])])
+
+define([AC_LIST_LINKS],
+       ifdef([AC_LIST_LINKS], [AC_LIST_LINKS ],)[$2:$1])])
 
 dnl AC_OUTPUT_COMMANDS(EXTRA-CMDS, INIT-CMDS)
 dnl -----------------------------------------
@@ -2815,7 +2839,7 @@ dnl AC_OUTPUT([CONFIG_FILES...] [, EXTRA-CMDS] [, INIT-CMDS])
 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.
+dnl The CONFIG_HEADERS are defined in the m4 variable AC_LIST_HEADERS.
 dnl Pay special attention not to have too long here docs: some old
 dnl shells die.  Unfortunately the limit is not known precisely...
 define(AC_OUTPUT,
@@ -2838,7 +2862,7 @@ fi
 
 trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
 
-ifdef([AC_LIST_HEADER], [DEFS=-DHAVE_CONFIG_H], [AC_OUTPUT_MAKE_DEFS()])
+ifdef([AC_LIST_HEADERS], [DEFS=-DHAVE_CONFIG_H], [AC_OUTPUT_MAKE_DEFS()])
 
 # Without the "./", some shells look in PATH for config.status.
 : ${CONFIG_STATUS=./config.status}
@@ -2859,6 +2883,17 @@ dnl so uname gets run too.
 # Compiler output produced by configure, useful for debugging
 # configure, is in ./config.log if it exists.
 
+# Files that config.status was made for.
+ifset([$1], [config_files="\\
+AC_WRAP($1, [    ])"
+])dnl
+ifdef([AC_LIST_HEADERS], [config_headers="\\
+AC_WRAP(AC_LIST_HEADERS, [    ])"
+])dnl
+ifdef([AC_LIST_LINKS], [config_links="\\
+AC_WRAP(AC_LIST_LINKS, [    ])"
+])dnl
+
 ac_cs_usage="\\
 \\\`$CONFIG_STATUS' instantiates files from templates according to the
 current configuration.
@@ -2870,19 +2905,22 @@ Usage: $CONFIG_STATUS @BKL@OPTIONS@BKR@ FILE...
   --help       Display this help and exit
 
 dnl Output this only if there are files to instantiate.
-ifset(ifdef([AC_LIST_HEADER], 1)$1,
+ifset(ifdef([AC_LIST_HEADERS], 1)$1,
 [Files to instantiate:
 ifset($1, [  Configuration files:
-AC_WRAP($1, [    ])
+\$config_files
 ])dnl
-ifdef([AC_LIST_HEADER], [  Configuration headers:
-AC_WRAP(AC_LIST_HEADER, [    ])
+ifdef([AC_LIST_HEADERS], [  Configuration headers:
+\$config_headers
+])dnl
+ifdef([AC_LIST_LINKS], [  Links to install:
+\$config_links
 ])dnl
 
 ])dnl
 Report bugs to <bug-autoconf@gnu.org>."
 
-ac_cs_version="\
+ac_cs_version="\\
 $CONFIG_STATUS generated by autoconf version AC_ACVERSION.
 Configured on host `(hostname || uname -n) 2>/dev/null | sed 1q` by running
   [$]0 [$]ac_configure_args"
@@ -2897,12 +2935,6 @@ ac_given_srcdir=$srcdir
 ifdef([AC_PROVIDE_AC_PROG_INSTALL], [ac_given_INSTALL="$INSTALL"
 ])dnl
 
-# Files that config.status was made for.
-ifset([$1], [AC_WRAP([config_files="]$1["])
-])dnl
-ifdef([AC_LIST_HEADER], [AC_WRAP([config_headers="]AC_LIST_HEADER["])
-])dnl
-
 for ac_option
 do
   case "[\$]ac_option" in
@@ -2913,7 +2945,7 @@ do
     echo "[\$]ac_cs_version"; exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "[\$]ac_cs_usage"; exit 0 ;;
-  *) # Find out the files to process
+  *) # Find out the files to process.
     for ac_file in [\$]config_files
     do
       case [\$]ac_file in
@@ -2934,6 +2966,16 @@ do
       esac
     done
     test -z "[\$]ac_option" && continue
+    for ac_file in [\$]config_links
+    do
+      case [\$]ac_file in
+        [\$]ac_option | [\$]ac_option:* )
+          CONFIG_LINKS="[\$]CONFIG_LINKS [\$]ac_file"
+          ac_option=
+          break ;;
+      esac
+    done
+    test -z "[\$]ac_option" && continue
     echo "$CONFIG_STATUS: invalid argument: [\$]ac_option"; exit 1
    ;;
   esac
@@ -2942,13 +2984,17 @@ done
 EOF
 
 dnl Issue this section only if there were actually config files.
-ifset(ifdef([AC_LIST_HEADER], 1)[$1],
+dnl The following test checks if one of AC_LIST_HEADERS, the CONFIG_FILES
+dnl which are given via $1, or AC_LIST_LINKS is set.
+ifset(ifdef([AC_LIST_HEADERS], 1)ifdef([AC_LIST_LINKS], 1)[$1],
 [cat >> $CONFIG_STATUS <<EOF
 # If there were arguments, don't assign a default value.
 if test \$[#] = 0; then
 ifset([$1], [  : \${CONFIG_FILES="\$config_files"}
 ])dnl
-ifdef([AC_LIST_HEADER], [  : \${CONFIG_HEADERS="\$config_headers"}
+ifdef([AC_LIST_HEADERS], [  : \${CONFIG_HEADERS="\$config_headers"}
+])dnl
+ifdef([AC_LIST_LINKS], [  : \${CONFIG_LINKS="\$config_links"}
 ])dnl
 fi
 
@@ -2972,8 +3018,8 @@ ifset([$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
+ifdef([AC_LIST_HEADERS], [AC_OUTPUT_HEADER(AC_LIST_HEADERS)])dnl
+ifdef([AC_LIST_LINKS], [AC_OUTPUT_LINKS(AC_LIST_LINKS)])dnl
 
 cat >> $CONFIG_STATUS <<EOF
 undivert(AC_DIVERSION_ICMDS)dnl
@@ -3328,27 +3374,23 @@ fi; done
 EOF
 ])dnl AC_OUTPUT_HEADER
 
-dnl AC_OUTPUT_LINKS(SOURCE..., DEST...)
-dnl -----------------------------------
+
+dnl AC_OUTPUT_LINKS(DEST:SOURCE...)
+dnl -------------------------------
 dnl This is a subroutine of AC_OUTPUT.
 dnl
 dnl It has to send itself into $CONFIG_STATUS (eg, via here documents).
 dnl Upon exit, no here document shall be opened.
 define(AC_OUTPUT_LINKS,
-[cat >> $CONFIG_STATUS <<EOF
-ac_sources="$1"
-ac_dests="$2"
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
+[cat >> $CONFIG_STATUS <<\EOF
 srcdir=$ac_given_srcdir
-# Remove spaces from $ac_sources if it is otherwise empty.
-set -- $ac_sources
-ac_sources=[$]*
 
-while test -n "$ac_sources"; do
-  set $ac_dests; ac_dest=[$]1; shift; ac_dests=[$]*
-  set $ac_sources; ac_source=[$]1; shift; ac_sources=[$]*
+dnl Here we use : instead of .. because if AC_LINK_FILES was used
+dnl with empty parameters (as in gettext.m4), then we obtain here
+dnl `:', which we want to skip.  So let's keep a single exception: `:'.
+for ac_file in : $CONFIG_LINKS; do if test "x$ac_file" != x:; then
+  ac_dest=`echo "$ac_file"|sed 's%:.*%%'`
+  ac_source=`echo "$ac_file"|sed 's%@BKL@^:@BKR@*:%%'`
 
   echo "linking $srcdir/$ac_source to $ac_dest"
 
@@ -3385,11 +3427,11 @@ changequote([, ])dnl
 
   # Make a symlink if possible; otherwise try a hard link.
   if ln -s $ac_rel_source $ac_dest 2>/dev/null ||
-    ln $srcdir/$ac_source $ac_dest; then :
+     ln $srcdir/$ac_source $ac_dest; then :
   else
     AC_MSG_ERROR(cannot link $ac_dest to $srcdir/$ac_source)
   fi
-done
+fi; done
 EOF
 ])dnl AC_OUTPUT_LINKS
 
diff --git a/autoconf.texi b/autoconf.texi
index a6d44be1..eb9d7bbd 100644
--- a/autoconf.texi
+++ b/autoconf.texi
@@ -6,8 +6,8 @@
 @c @setchapternewpage odd
 @c %**end of header
 
-@set EDITION 2.13.1
-@set VERSION 2.13.1
+@set EDITION 2.14.1
+@set VERSION 2.14.1
 @set UPDATED June 1999
 
 @iftex
@@ -868,7 +868,7 @@ not the parents of that directory).  Usually, @file{Makefile}s are
 created this way, but other files, such as @file{.gdbinit}, can be
 specified as well.
 
-If @code{AC_CONFIG_HEADER}, @code{AC_LINK_FILES}, or
+If @code{AC_CONFIG_HEADER}, @code{AC_CONFIG_LINKS}, or
 @code{AC_CONFIG_SUBDIRS} has been called, this macro also creates the
 files named as their arguments.
 
@@ -4629,24 +4629,42 @@ i960-*-bout) obj_format=bout ;;
 esac
 @end example
 
-@defmac AC_LINK_FILES (@var{source}@dots{}, @var{dest}@dots{})
-@maindex LINK_FILES
+@defmac AC_CONFIG_LINKS (@var{dest}:@var{source}@dots{})
+@maindex CONFIG_LINKS
 Make @code{AC_OUTPUT} link each of the existing files @var{source} to
 the corresponding link name @var{dest}.  Makes a symbolic link if
 possible, otherwise a hard link.  The @var{dest} and @var{source} names
-should be relative to the top level source or build directory.
-This macro may be called multiple times.
+should be relative to the top level source or build directory.  This
+macro may be called multiple times.
 
 For example, this call:
 
 @example
-AC_LINK_FILES(config/$@{machine@}.h config/$@{obj_format@}.h, host.h object.h)
+AC_LINK_FILES(host.h:config/$@{machine@}.h object.h:config/$@{obj_format@}.h)
 @end example
 
 @noindent
 creates in the current directory @file{host.h}, which is a link to
 @file{@var{srcdir}/config/$@{machine@}.h}, and @file{object.h}, which is a link
 to @file{@var{srcdir}/config/$@{obj_format@}.h}.
+
+The tempting value @samp{.} for @var{dest} is made illegal: it makes it
+impossible for @samp{config.status} to guess the links to establish.  It
+is there legal to run
+@example
+./config.status host.h object.h
+@end example
+to establish the links.
+@end defmac
+
+@defmac AC_LINK_FILES (@var{source}@dots{}, @var{dest}@dots{})
+@maindex LINK_FILES
+This is an obsolete version of the previous macro.  The previous example
+would have been written:
+
+@example
+AC_LINK_FILES(config/$@{machine@}.h config/$@{obj_format@}.h, host.h object.h)
+@end example
 @end defmac
 
 You can also use the host system type to find cross-compilation tools.
@@ -5205,6 +5223,13 @@ default is the arguments given to @code{AC_CONFIG_HEADER}; if that macro
 was not called, @file{config.status} ignores this variable.
 @end defvar
 
+@defvar CONFIG_LINKS
+@evindex CONFIG_LINKS
+The symbolic links to establish.  The default is the arguments given to
+@code{AC_CONFIG_LINKS}; if that macro was not called,
+@file{config.status} ignores this variable.
+@end defvar
+
 These variables also allow you to write @file{Makefile} rules that
 regenerate only some of the files.  For example, in the dependencies
 given above (@pxref{Automatic Remaking}), @file{config.status} is run
@@ -5215,11 +5240,11 @@ can make each run only regenerate the files for that rule:
 @group
 config.h: stamp-h
 stamp-h: config.h.in config.status
-        CONFIG_FILES= CONFIG_HEADERS=config.h ./config.status
+        CONFIG_LINKS= CONFIG_FILES= CONFIG_HEADERS=config.h ./config.status
         echo > stamp-h
 
 Makefile: Makefile.in config.status
-        CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status
+        CONFIG_LINKS CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status
 @end group
 @end example
 
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index a6d44be1..eb9d7bbd 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -6,8 +6,8 @@
 @c @setchapternewpage odd
 @c %**end of header
 
-@set EDITION 2.13.1
-@set VERSION 2.13.1
+@set EDITION 2.14.1
+@set VERSION 2.14.1
 @set UPDATED June 1999
 
 @iftex
@@ -868,7 +868,7 @@ not the parents of that directory).  Usually, @file{Makefile}s are
 created this way, but other files, such as @file{.gdbinit}, can be
 specified as well.
 
-If @code{AC_CONFIG_HEADER}, @code{AC_LINK_FILES}, or
+If @code{AC_CONFIG_HEADER}, @code{AC_CONFIG_LINKS}, or
 @code{AC_CONFIG_SUBDIRS} has been called, this macro also creates the
 files named as their arguments.
 
@@ -4629,24 +4629,42 @@ i960-*-bout) obj_format=bout ;;
 esac
 @end example
 
-@defmac AC_LINK_FILES (@var{source}@dots{}, @var{dest}@dots{})
-@maindex LINK_FILES
+@defmac AC_CONFIG_LINKS (@var{dest}:@var{source}@dots{})
+@maindex CONFIG_LINKS
 Make @code{AC_OUTPUT} link each of the existing files @var{source} to
 the corresponding link name @var{dest}.  Makes a symbolic link if
 possible, otherwise a hard link.  The @var{dest} and @var{source} names
-should be relative to the top level source or build directory.
-This macro may be called multiple times.
+should be relative to the top level source or build directory.  This
+macro may be called multiple times.
 
 For example, this call:
 
 @example
-AC_LINK_FILES(config/$@{machine@}.h config/$@{obj_format@}.h, host.h object.h)
+AC_LINK_FILES(host.h:config/$@{machine@}.h object.h:config/$@{obj_format@}.h)
 @end example
 
 @noindent
 creates in the current directory @file{host.h}, which is a link to
 @file{@var{srcdir}/config/$@{machine@}.h}, and @file{object.h}, which is a link
 to @file{@var{srcdir}/config/$@{obj_format@}.h}.
+
+The tempting value @samp{.} for @var{dest} is made illegal: it makes it
+impossible for @samp{config.status} to guess the links to establish.  It
+is there legal to run
+@example
+./config.status host.h object.h
+@end example
+to establish the links.
+@end defmac
+
+@defmac AC_LINK_FILES (@var{source}@dots{}, @var{dest}@dots{})
+@maindex LINK_FILES
+This is an obsolete version of the previous macro.  The previous example
+would have been written:
+
+@example
+AC_LINK_FILES(config/$@{machine@}.h config/$@{obj_format@}.h, host.h object.h)
+@end example
 @end defmac
 
 You can also use the host system type to find cross-compilation tools.
@@ -5205,6 +5223,13 @@ default is the arguments given to @code{AC_CONFIG_HEADER}; if that macro
 was not called, @file{config.status} ignores this variable.
 @end defvar
 
+@defvar CONFIG_LINKS
+@evindex CONFIG_LINKS
+The symbolic links to establish.  The default is the arguments given to
+@code{AC_CONFIG_LINKS}; if that macro was not called,
+@file{config.status} ignores this variable.
+@end defvar
+
 These variables also allow you to write @file{Makefile} rules that
 regenerate only some of the files.  For example, in the dependencies
 given above (@pxref{Automatic Remaking}), @file{config.status} is run
@@ -5215,11 +5240,11 @@ can make each run only regenerate the files for that rule:
 @group
 config.h: stamp-h
 stamp-h: config.h.in config.status
-        CONFIG_FILES= CONFIG_HEADERS=config.h ./config.status
+        CONFIG_LINKS= CONFIG_FILES= CONFIG_HEADERS=config.h ./config.status
         echo > stamp-h
 
 Makefile: Makefile.in config.status
-        CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status
+        CONFIG_LINKS CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status
 @end group
 @end example
 
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 2140e9e0..2bcc3ffa 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -245,12 +245,12 @@ define(m4_foreach,
 [pushdef([$1], [])_m4_foreach($@)popdef([$1])])
 
 dnl Low level macros used to define m4_foreach
-define(_m4_car, [[$1]])
+define(m4_car, [[$1]])
 define(_m4_foreach,
 [ifelse($2, [()], ,
-        [define([$1], [_m4_car$2])$3[]_m4_foreach([$1],
-                                                  [(m4_shift$2)],
-                                                  [$3])])])
+        [define([$1], [m4_car$2])$3[]_m4_foreach([$1],
+                                                 [(m4_shift$2)],
+                                                 [$3])])])
 
 
 dnl m4_list_append(LIST, ELEMENT)
@@ -2300,7 +2300,7 @@ dnl because the test really is for library $1 defining function $2, not
 dnl just for library $1.  Separate tests with the same $1 and different $2s
 dnl may have different results.
 dnl
-dnl FIXME: This macro is extremely suspicious.  It DEFINE unconditionnally,
+dnl FIXME: This macro is extremely suspicious.  It DEFINEs unconditionnally,
 dnl whatever the FUNCTION, in addition to not being a *S macro.  Note
 dnl that the cache does depend upon the function with look for.
 AC_DEFUN(AC_CHECK_LIB,
@@ -2776,19 +2776,43 @@ dnl ### Creating output files
 
 dnl AC_CONFIG_HEADER(HEADER-TO-CREATE ...)
 AC_DEFUN(AC_CONFIG_HEADER,
-[define(AC_LIST_HEADER, $1)])
+[define(AC_LIST_HEADERS, $1)])
 
+
+dnl AC_CONFIG_LINKS(DEST:SOURCE...)
+dnl -------------------------------
+dnl Specify that config.status should establish a (symbolic if possible)
+dnl link from TOP_SRCDIR/SOURCE to TOP_SRCDIR/DEST.
+dnl Reject DEST=., because it is makes it hard for ./config.status
+dnl to guess the links to establish (`./config.status .').
+AC_DEFUN(AC_CONFIG_LINKS,
+[ifelse(regexp([$1], [^.:]), -1,,
+        [AC_FATAL([$0: invalid destination: `.'])])
+ifelse(regexp([$1], [ .:]), -1,,
+        [AC_FATAL([$0: invalid destination: `.'])])
+define([AC_LIST_LINKS],
+       ifdef([AC_LIST_LINKS], [AC_LIST_LINKS ],)[$1])])
+
+
+dnl AC_LINK_FILES(SOURCE..., DEST...)
+dnl ---------------------------------
 dnl Link each of the existing files SOURCE... to the corresponding
 dnl link name in DEST...
-dnl AC_LINK_FILES(SOURCE..., DEST...)
 AC_DEFUN(AC_LINK_FILES,
-[dnl
-ifelse($#, 2, , dnl
-  [errprint(__file__:__line__: incorrect number of arguments to [AC_LINK_FILES]
-)]
-  AC_MSG_ERROR([aborting due to error at __file__:__line__]))dnl
-define([AC_LIST_FILES], ifdef([AC_LIST_FILES], [AC_LIST_FILES ],)[$1])dnl
-define([AC_LIST_LINKS], ifdef([AC_LIST_LINKS], [AC_LIST_LINKS ],)[$2])])
+[AC_OBSOLETE([$0], [; instead use AC_CONFIG_FILES(DEST:SOURCE...)])dnl
+ifelse($#, 2, ,
+  [AC_FATAL([$0: incorrect number of arguments])])
+pushdef([AC_Sources], m4_split(m4_strip(m4_join([$1]))))
+pushdef([AC_Dests], m4_split(m4_strip(m4_join([$2]))))
+m4_foreach([AC_Dummy], (AC_Sources),
+  [AC_CONFIG_LINKS(m4_car(AC_Dests):m4_car(AC_Sources))
+   define([AC_Sources], m4_quote(m4_shift(AC_Sources)))
+   define([AC_Dests], m4_quote(m4_shift(AC_Dests)))])
+popdef([AC_Sources])
+popdef([AC_Dests])])
+
+define([AC_LIST_LINKS],
+       ifdef([AC_LIST_LINKS], [AC_LIST_LINKS ],)[$2:$1])])
 
 dnl AC_OUTPUT_COMMANDS(EXTRA-CMDS, INIT-CMDS)
 dnl -----------------------------------------
@@ -2815,7 +2839,7 @@ dnl AC_OUTPUT([CONFIG_FILES...] [, EXTRA-CMDS] [, INIT-CMDS])
 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.
+dnl The CONFIG_HEADERS are defined in the m4 variable AC_LIST_HEADERS.
 dnl Pay special attention not to have too long here docs: some old
 dnl shells die.  Unfortunately the limit is not known precisely...
 define(AC_OUTPUT,
@@ -2838,7 +2862,7 @@ fi
 
 trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
 
-ifdef([AC_LIST_HEADER], [DEFS=-DHAVE_CONFIG_H], [AC_OUTPUT_MAKE_DEFS()])
+ifdef([AC_LIST_HEADERS], [DEFS=-DHAVE_CONFIG_H], [AC_OUTPUT_MAKE_DEFS()])
 
 # Without the "./", some shells look in PATH for config.status.
 : ${CONFIG_STATUS=./config.status}
@@ -2859,6 +2883,17 @@ dnl so uname gets run too.
 # Compiler output produced by configure, useful for debugging
 # configure, is in ./config.log if it exists.
 
+# Files that config.status was made for.
+ifset([$1], [config_files="\\
+AC_WRAP($1, [    ])"
+])dnl
+ifdef([AC_LIST_HEADERS], [config_headers="\\
+AC_WRAP(AC_LIST_HEADERS, [    ])"
+])dnl
+ifdef([AC_LIST_LINKS], [config_links="\\
+AC_WRAP(AC_LIST_LINKS, [    ])"
+])dnl
+
 ac_cs_usage="\\
 \\\`$CONFIG_STATUS' instantiates files from templates according to the
 current configuration.
@@ -2870,19 +2905,22 @@ Usage: $CONFIG_STATUS @BKL@OPTIONS@BKR@ FILE...
   --help       Display this help and exit
 
 dnl Output this only if there are files to instantiate.
-ifset(ifdef([AC_LIST_HEADER], 1)$1,
+ifset(ifdef([AC_LIST_HEADERS], 1)$1,
 [Files to instantiate:
 ifset($1, [  Configuration files:
-AC_WRAP($1, [    ])
+\$config_files
 ])dnl
-ifdef([AC_LIST_HEADER], [  Configuration headers:
-AC_WRAP(AC_LIST_HEADER, [    ])
+ifdef([AC_LIST_HEADERS], [  Configuration headers:
+\$config_headers
+])dnl
+ifdef([AC_LIST_LINKS], [  Links to install:
+\$config_links
 ])dnl
 
 ])dnl
 Report bugs to <bug-autoconf@gnu.org>."
 
-ac_cs_version="\
+ac_cs_version="\\
 $CONFIG_STATUS generated by autoconf version AC_ACVERSION.
 Configured on host `(hostname || uname -n) 2>/dev/null | sed 1q` by running
   [$]0 [$]ac_configure_args"
@@ -2897,12 +2935,6 @@ ac_given_srcdir=$srcdir
 ifdef([AC_PROVIDE_AC_PROG_INSTALL], [ac_given_INSTALL="$INSTALL"
 ])dnl
 
-# Files that config.status was made for.
-ifset([$1], [AC_WRAP([config_files="]$1["])
-])dnl
-ifdef([AC_LIST_HEADER], [AC_WRAP([config_headers="]AC_LIST_HEADER["])
-])dnl
-
 for ac_option
 do
   case "[\$]ac_option" in
@@ -2913,7 +2945,7 @@ do
     echo "[\$]ac_cs_version"; exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "[\$]ac_cs_usage"; exit 0 ;;
-  *) # Find out the files to process
+  *) # Find out the files to process.
     for ac_file in [\$]config_files
     do
       case [\$]ac_file in
@@ -2934,6 +2966,16 @@ do
       esac
     done
     test -z "[\$]ac_option" && continue
+    for ac_file in [\$]config_links
+    do
+      case [\$]ac_file in
+        [\$]ac_option | [\$]ac_option:* )
+          CONFIG_LINKS="[\$]CONFIG_LINKS [\$]ac_file"
+          ac_option=
+          break ;;
+      esac
+    done
+    test -z "[\$]ac_option" && continue
     echo "$CONFIG_STATUS: invalid argument: [\$]ac_option"; exit 1
    ;;
   esac
@@ -2942,13 +2984,17 @@ done
 EOF
 
 dnl Issue this section only if there were actually config files.
-ifset(ifdef([AC_LIST_HEADER], 1)[$1],
+dnl The following test checks if one of AC_LIST_HEADERS, the CONFIG_FILES
+dnl which are given via $1, or AC_LIST_LINKS is set.
+ifset(ifdef([AC_LIST_HEADERS], 1)ifdef([AC_LIST_LINKS], 1)[$1],
 [cat >> $CONFIG_STATUS <<EOF
 # If there were arguments, don't assign a default value.
 if test \$[#] = 0; then
 ifset([$1], [  : \${CONFIG_FILES="\$config_files"}
 ])dnl
-ifdef([AC_LIST_HEADER], [  : \${CONFIG_HEADERS="\$config_headers"}
+ifdef([AC_LIST_HEADERS], [  : \${CONFIG_HEADERS="\$config_headers"}
+])dnl
+ifdef([AC_LIST_LINKS], [  : \${CONFIG_LINKS="\$config_links"}
 ])dnl
 fi
 
@@ -2972,8 +3018,8 @@ ifset([$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
+ifdef([AC_LIST_HEADERS], [AC_OUTPUT_HEADER(AC_LIST_HEADERS)])dnl
+ifdef([AC_LIST_LINKS], [AC_OUTPUT_LINKS(AC_LIST_LINKS)])dnl
 
 cat >> $CONFIG_STATUS <<EOF
 undivert(AC_DIVERSION_ICMDS)dnl
@@ -3328,27 +3374,23 @@ fi; done
 EOF
 ])dnl AC_OUTPUT_HEADER
 
-dnl AC_OUTPUT_LINKS(SOURCE..., DEST...)
-dnl -----------------------------------
+
+dnl AC_OUTPUT_LINKS(DEST:SOURCE...)
+dnl -------------------------------
 dnl This is a subroutine of AC_OUTPUT.
 dnl
 dnl It has to send itself into $CONFIG_STATUS (eg, via here documents).
 dnl Upon exit, no here document shall be opened.
 define(AC_OUTPUT_LINKS,
-[cat >> $CONFIG_STATUS <<EOF
-ac_sources="$1"
-ac_dests="$2"
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
+[cat >> $CONFIG_STATUS <<\EOF
 srcdir=$ac_given_srcdir
-# Remove spaces from $ac_sources if it is otherwise empty.
-set -- $ac_sources
-ac_sources=[$]*
 
-while test -n "$ac_sources"; do
-  set $ac_dests; ac_dest=[$]1; shift; ac_dests=[$]*
-  set $ac_sources; ac_source=[$]1; shift; ac_sources=[$]*
+dnl Here we use : instead of .. because if AC_LINK_FILES was used
+dnl with empty parameters (as in gettext.m4), then we obtain here
+dnl `:', which we want to skip.  So let's keep a single exception: `:'.
+for ac_file in : $CONFIG_LINKS; do if test "x$ac_file" != x:; then
+  ac_dest=`echo "$ac_file"|sed 's%:.*%%'`
+  ac_source=`echo "$ac_file"|sed 's%@BKL@^:@BKR@*:%%'`
 
   echo "linking $srcdir/$ac_source to $ac_dest"
 
@@ -3385,11 +3427,11 @@ changequote([, ])dnl
 
   # Make a symlink if possible; otherwise try a hard link.
   if ln -s $ac_rel_source $ac_dest 2>/dev/null ||
-    ln $srcdir/$ac_source $ac_dest; then :
+     ln $srcdir/$ac_source $ac_dest; then :
   else
     AC_MSG_ERROR(cannot link $ac_dest to $srcdir/$ac_source)
   fi
-done
+fi; done
 EOF
 ])dnl AC_OUTPUT_LINKS
 

(Patch may be truncated, please check the link at the top of this post.)