From 5aa38da39b8b626c4f6232a224ca63e48874b8be Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 20 Dec 1999 12:14:28 +0000 Subject: [PATCH] 1999-10-31 Akim Demaille New macro: AC_CONFIG_FILES which is very much like AC_OUTPUT but that one associates commands to run when a config file is created. For instance for a shell script `foo', one uses AC_CONFIG_FILES(foo, chmod +x foo). In addition, check that the same name is never used twice in config files, headers, subdirs and links. * acgeneral.m4 (m4_append): Don't insert new line between elements. (m4_list_append): New macro. (AC_CONFIG_IF_MEMBER): New macro which tests if a file is member of a config list. (AC_CONFIG_UNIQUE): New macro which ensures that a config file name is not yet used. (AC_CONFIG_HEADER, AC_CONFIG_LINKS, AC_CONFIG_SUBDIRS): Use AC_CONFIG_UNIQUE. * acgeneral.m4 (AC_CONFIG_FILES): New macro. (AC_LIST_FILES): New list, which stores arguments of AC_CONFIG_LISTS the same as AC_LIST_LINKS stores AC_CONFIG_LINKS etc. (AC_OUTPUT): No longer rely on $1 to designate the config files: register them via AC_CONFIG_FILES. All uses of $1 replaced by uses of AC_LIST_FILES. (AC_OUTPUT_FILES): Run the commands associated to the CONFIG_FILES. --- ChangeLog | 30 +++++++ TODO | 35 ++++++++ acgeneral.m4 | 181 ++++++++++++++++++++++++++++++---------- autoconf.texi | 14 ++-- doc/autoconf.texi | 14 ++-- lib/autoconf/general.m4 | 181 ++++++++++++++++++++++++++++++---------- 6 files changed, 355 insertions(+), 100 deletions(-) diff --git a/ChangeLog b/ChangeLog index 014f35b8..51e3e9b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +1999-10-31 Akim Demaille + + New macro: AC_CONFIG_FILES which is very much like AC_OUTPUT but + that one associates commands to run when a config file is + created. For instance for a shell script `foo', one uses + AC_CONFIG_FILES(foo, chmod +x foo). + + In addition, check that the same name is never used twice in + config files, headers, subdirs and links. + + * acgeneral.m4 (m4_append): Don't insert new line between + elements. + (m4_list_append): New macro. + (AC_CONFIG_IF_MEMBER): New macro which tests if a file is member + of a config list. + (AC_CONFIG_UNIQUE): New macro which ensures that a config file + name is not yet used. + (AC_CONFIG_HEADER, AC_CONFIG_LINKS, AC_CONFIG_SUBDIRS): Use + AC_CONFIG_UNIQUE. + + * acgeneral.m4 (AC_CONFIG_FILES): New macro. + (AC_LIST_FILES): New list, which stores arguments of + AC_CONFIG_LISTS the same as AC_LIST_LINKS stores AC_CONFIG_LINKS + etc. + (AC_OUTPUT): No longer rely on $1 to designate the config files: + register them via AC_CONFIG_FILES. All uses of $1 replaced by + uses of AC_LIST_FILES. + (AC_OUTPUT_FILES): Run the commands associated to the + CONFIG_FILES. + 1999-10-31 Akim Demaille * autoconf.sh (Looking for bugs): In addition to AC_, match AH_ diff --git a/TODO b/TODO index e6a87b0e..c7270803 100644 --- a/TODO +++ b/TODO @@ -13,8 +13,25 @@ These are things mandatory to fulfill before releasing 2.15. There are also suggestions we should either satisfy right now (they're easy), or remove (obsoleted since then). +** autoconf.texi: config.status in node names. +The info mode of Emacs seems to have problems with this. If the info +reader catches that properly, we should not care. If no info reader +can handle this, we should change the affected node names. Bug +triggered by looking for `CONFIG_FILES' in the index. + +** autoconf.texi: Document AC_CONFIG_FILES. +I didn't do it, because I don't know where to do that. I would like +to have all the AC_CONFIG_ together, but it is not currently the +case. An architecture for the docs needs to be decided. + +** autoconf.texi, near fubar=27. +This example is *wrong*. fubar is set in configure, not +config.status, therefore the extra commands will not know $fubar, as +the example let us believe. + ** AC_C_STRUCT_MEMBER needs a full rewrite. And once done, the former specialized macros should be adapted. +AC_CHECK_MEMBER/AC_CHECK_MEMBERS is a proposal, see the code. ** AC_CHECK_HEADER should not template config.h entries. Its entry in autoheader.m4 should be removed. @@ -22,9 +39,27 @@ Its entry in autoheader.m4 should be removed. ** Allow tags for AC_OUTPUT_COMMANDS so that we can run ./config.status name-of-the command. +** Generalize the association of a commands to an output file. +See AC_CONFIG_FILES: it is possible to associate a command which is +run when the file is creating. This should be extended to all the +other AC_CONFIG entities. But then there is a question: should the +commands associated to a HEADER be in config.status's HEADER section, +ran right after the file is created, or we should just plug the +commands in the section of tagged AC_OUTPUT_COMMANDS. There are two +issues here: if we want to display the commands ran, then we want them +to appear after `creating ...', not at the end. It is also better wrt +trapping (since files are finalized sooner, there are less files to +remove when C-c is caught). On the other hand, it is a bit less +pleasant to program in Autoconf. + +** Rename AC_CONFIG_HEADER as AC_CONFIG_HEADERS? +See the FIXME note in the code. + ** Allow --recursive to config.status +So that --recheck does not pass --no-recursive to configure. ** Allow --header, --command, --file to config.status. +I don't remember the purpose, ask Alexandre. ** Move AM_PROG_CC_STDC into Autoconf. Autoconf should provide the means to determine the ANSIsm of the diff --git a/acgeneral.m4 b/acgeneral.m4 index d5cea62c..6d74cd3f 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -174,7 +174,7 @@ dnl Redefine MACRO-NAME to hold its former content plus STRING at the dnl end. It is valid to use this macro with MACRO-NAME undefined. dnl dnl This macro is robust to active symbols. It can be used to grow -dnl strings or lists. +dnl strings. dnl dnl | define(active, ACTIVE) dnl | m4_append([sentence], [This is an]) @@ -200,8 +200,15 @@ dnl => dnl => active define(m4_append, [define([$1], -ifdef([$1], [defn([$1])]) -[$2])]) +ifdef([$1], [defn([$1])])[$2])]) + + +dnl m4_list_append(MACRO-NAME, STRING) +dnl ---------------------------------- +dnl Same as `m4_append', but each element is separated by `, '. +define(m4_list_append, +[define([$1], +ifdef([$1], [defn([$1]), ])[$2])]) dnl ------------------------------------------------------------ @@ -2872,10 +2879,50 @@ AC_VAR_POPDEF([ac_Type])dnl dnl ### Creating output files +dnl AC_CONFIG_IF_MEMBER(DEST[:SOURCE], LIST, ACTION-IF-TRUE, ACTION-IF-FALSE) +dnl ------------------------------------------------------------------------- +dnl If DEST is member of LIST, expand to ACTION-IF-TRUE, else ACTION-IF-FALSE. +dnl +dnl LIST is an AC_CONFIG list, i.e., a list of DEST[:SOURCE], separated +dnl with spaces. +dnl +dnl FIXME: This macro is badly designed, but I'm not guilty: m4 is. There +dnl is just no way to simply compare two strings in m4, but to use pattern +dnl matching. The big problem is then that the active characters should +dnl be quoted. So an additional macro should be used here. Nevertheless, +dnl in the case of file names, there is not much to worry. +define(AC_CONFIG_IF_MEMBER, +[pushdef([AC_Dest], patsubst([$1], [:.*]))dnl +ifelse(regexp($2, [\(^\| \)]AC_Dest[\(:\| \|$\)]), -1, [$4], [$3])dnl +popdef([AC_Dest])dnl +]) + + +dnl AC_CONFIG_UNIQUE(DEST[:SOURCE]...) +dnl ---------------------------------- +dnl Verify that there is no double definition of an output file +dnl (precisely, guarantees there is no common elements between +dnl CONFIG_HEADERS, CONFIG_FILES, CONFIG_LINKS, and CONFIG_SUBDIRS). +define(AC_CONFIG_UNIQUE, +[AC_FOREACH([AC_File], [$1], + [AC_CONFIG_IF_MEMBER(AC_File, [AC_LIST_HEADERS], + [AC_FATAL(`AC_File' [is already registered with AC_CONFIG_HEADER.])]) + AC_CONFIG_IF_MEMBER(AC_File, [AC_LIST_LINKS], + [AC_FATAL(`AC_File' [is already registered with AC_CONFIG_LINKS.])]) + AC_CONFIG_IF_MEMBER(AC_File, [AC_LIST_SUBDIRS], + [AC_FATAL(`AC_File' [is already registered with AC_CONFIG_SUBDIRS.])]) + AC_CONFIG_IF_MEMBER(AC_File, [AC_LIST_FILES], + [AC_FATAL(`AC_File' [is already registered with AC_CONFIG_FILES or AC_OUTPUT.])])])dnl +]) + dnl AC_CONFIG_HEADER(HEADER-TO-CREATE ...) +dnl -------------------------------------- +dnl FIXME: For sake of uniformity, it should be AC_CONFIG_HEADERS, and +dnl it should be possible to accumulate several calls. AC_DEFUN(AC_CONFIG_HEADER, -[define(AC_LIST_HEADERS, $1)]) +[AC_CONFIG_UNIQUE([$1])dnl +define(AC_LIST_HEADERS, $1)]) dnl AC_CONFIG_LINKS(DEST:SOURCE...) @@ -2884,13 +2931,12 @@ 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 .'). +dnl This macro may be called multiple times. 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]) +[AC_CONFIG_UNIQUE([$1])dnl +ifelse(regexp([$1], [^\.:\| \.:]), -1,, + [AC_FATAL([$0: invalid destination: `.'])])dnl +m4_append([AC_LIST_LINKS], [$1])dnl ]) @@ -2898,27 +2944,49 @@ dnl AC_LINK_FILES(SOURCE..., DEST...) dnl --------------------------------- dnl Link each of the existing files SOURCE... to the corresponding dnl link name in DEST... -dnl This macro, as AC_CONFIG_FILES, produces no sh code, so we don't -dnl dnl. AC_DEFUN(AC_LINK_FILES, -[AC_OBSOLETE([$0], [; instead use AC_CONFIG_FILES(DEST:SOURCE...)]) +[AC_OBSOLETE([$0], [; instead use AC_CONFIG_LINKS(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])))) - + [AC_FATAL([$0: incorrect number of arguments])])dnl +dnl +pushdef([AC_Sources], m4_split(m4_strip(m4_join([$1]))))dnl +pushdef([AC_Dests], m4_split(m4_strip(m4_join([$2]))))dnl +dnl 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)))]) +[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)))])dnl +dnl +popdef([AC_Sources])dnl +popdef([AC_Dests])dnl +])dnl AC_LINK_FILES + + +dnl AC_CONFIG_FILES(FILE...[, COMMANDS]) +dnl ------------------------------------ +dnl Specify output files, as with AC_OUTPUT, i.e., files that are +dnl configured with AC_SUBST. Associate the COMMANDS to each FILE, +dnl i.e., when config.status creates FILE, run COMMANDS afterwards. +dnl +dnl The commands are stored in a growing string AC_LIST_FILES_COMMANDS +dnl which should be used like this: +dnl +dnl case $ac_file in +dnl AC_LIST_FILES_COMMANDS +dnl esac +AC_DEFUN([AC_CONFIG_FILES], +[AC_CONFIG_UNIQUE([$1])dnl +m4_append([AC_LIST_FILES], [ $1])dnl +dnl +pushdef([AC_Prefix], [ ])dnl +dnl +ifelse([$2],,, [AC_FOREACH([AC_File], [$1], +[m4_append([AC_LIST_FILES_COMMANDS], +[ ]patsubst(AC_File, [:.*])[ ) $2 ;; +])])])dnl +])dnl -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 ----------------------------------------- @@ -2934,9 +3002,11 @@ AC_DIVERT_PUSH(AC_DIVERSION_ICMDS)dnl AC_DIVERT_POP()]) dnl AC_CONFIG_SUBDIRS(DIR ...) +dnl -------------------------- AC_DEFUN(AC_CONFIG_SUBDIRS, -[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl -define([AC_LIST_SUBDIRS], ifdef([AC_LIST_SUBDIRS], [AC_LIST_SUBDIRS ],)[$1])dnl +[AC_CONFIG_UNIQUE([$1])dnl +AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +m4_append([AC_LIST_SUBDIRS], [$1])dnl subdirs="AC_LIST_SUBDIRS" AC_SUBST(subdirs)dnl ]) @@ -2949,7 +3019,9 @@ 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, -[trap '' 1 2 15 +[dnl Store the CONFIG_FILES +AC_CONFIG_FILES([$1])dnl +trap '' 1 2 15 AC_CACHE_SAVE trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 @@ -2990,8 +3062,8 @@ dnl so uname gets run too. # configure, is in ./config.log if it exists. # Files that config.status was made for. -ifset([$1], [config_files="\\ -AC_WRAP($1, [ ])" +ifdef([AC_LIST_FILES], [config_files="\\ +AC_WRAP(AC_LIST_FILES, [ ])" ])dnl ifdef([AC_LIST_HEADERS], [config_headers="\\ AC_WRAP(AC_LIST_HEADERS, [ ])" @@ -3013,9 +3085,9 @@ Usage: $CONFIG_STATUS @BKL@OPTIONS@BKR@ FILE... dnl Issue this section only if there were actually config files. 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], +ifset(ifdef([AC_LIST_HEADERS], 1)ifdef([AC_LIST_LINKS], 1)ifdef([AC_LIST_FILES], 1), [Files to instantiate: -ifset($1, [ Configuration files: +ifdef([AC_LIST_FILES], [ Configuration files: \$config_files ])dnl ifdef([AC_LIST_HEADERS], [ Configuration headers: @@ -3094,15 +3166,15 @@ EOF dnl Issue this section only if there were actually config files. 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], +ifset(ifdef([AC_LIST_HEADERS], 1)ifdef([AC_LIST_LINKS], 1)ifdef([AC_LIST_FILES], 1), [cat >> $CONFIG_STATUS <>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF changequote(<<, >>)dnl + +# +# CONFIG_HEADER section. +# + # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # @@ -3511,6 +3602,10 @@ 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 + +# +# CONFIG_LINKS section. +# srcdir=$ac_given_srcdir dnl Here we use : instead of .. because if AC_LINK_FILES was used @@ -3550,7 +3645,7 @@ changequote([, ])dnl changequote(, )dnl [/$]*) ac_rel_source="$srcdir/$ac_source" ;; changequote([, ])dnl - *) ac_rel_source="$ac_dots$srcdir/$ac_source" ;; + *) ac_rel_source="$ac_dots$srcdir/$ac_source" ;; esac # Make a symlink if possible; otherwise try a hard link. diff --git a/autoconf.texi b/autoconf.texi index 75fd6185..905be436 100644 --- a/autoconf.texi +++ b/autoconf.texi @@ -866,9 +866,9 @@ 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_CONFIG_LINKS}, or -@code{AC_CONFIG_SUBDIRS} has been called, this macro also creates the -files named as their arguments. +If @code{AC_CONFIG_HEADER}, @code{AC_CONFIG_LINKS}, +@code{AC_CONFIG_FILES}, or @code{AC_CONFIG_SUBDIRS} has been called, +this macro also creates the files named as their arguments. A typical call to @code{AC_OUTPUT} looks like this: @example @@ -5212,8 +5212,8 @@ one of them, perhaps a common library, does. These variables allow a @defvar CONFIG_FILES @evindex CONFIG_FILES The files in which to perform @samp{@@@var{variable}@@} substitutions. -The default is the arguments given to @code{AC_OUTPUT} in -@file{configure.in}. +The default is the arguments given to @code{AC_OUTPUT} and +@code{AC_CONFIG_FILES} in @file{configure.in}. @end defvar @defvar CONFIG_HEADERS @@ -5244,7 +5244,7 @@ stamp-h: config.h.in config.status echo > stamp-h Makefile: Makefile.in config.status - CONFIG_LINKS CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status + CONFIG_LINKS= CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status @end group @end example @@ -5252,7 +5252,7 @@ Makefile: Makefile.in config.status (If @file{configure.in} does not call @code{AC_CONFIG_HEADER}, there is no need to set @code{CONFIG_HEADERS} in the @code{make} rules.) -Note that this example could also have been written +Note that this example could also have been written: @example @group diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 75fd6185..905be436 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -866,9 +866,9 @@ 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_CONFIG_LINKS}, or -@code{AC_CONFIG_SUBDIRS} has been called, this macro also creates the -files named as their arguments. +If @code{AC_CONFIG_HEADER}, @code{AC_CONFIG_LINKS}, +@code{AC_CONFIG_FILES}, or @code{AC_CONFIG_SUBDIRS} has been called, +this macro also creates the files named as their arguments. A typical call to @code{AC_OUTPUT} looks like this: @example @@ -5212,8 +5212,8 @@ one of them, perhaps a common library, does. These variables allow a @defvar CONFIG_FILES @evindex CONFIG_FILES The files in which to perform @samp{@@@var{variable}@@} substitutions. -The default is the arguments given to @code{AC_OUTPUT} in -@file{configure.in}. +The default is the arguments given to @code{AC_OUTPUT} and +@code{AC_CONFIG_FILES} in @file{configure.in}. @end defvar @defvar CONFIG_HEADERS @@ -5244,7 +5244,7 @@ stamp-h: config.h.in config.status echo > stamp-h Makefile: Makefile.in config.status - CONFIG_LINKS CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status + CONFIG_LINKS= CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status @end group @end example @@ -5252,7 +5252,7 @@ Makefile: Makefile.in config.status (If @file{configure.in} does not call @code{AC_CONFIG_HEADER}, there is no need to set @code{CONFIG_HEADERS} in the @code{make} rules.) -Note that this example could also have been written +Note that this example could also have been written: @example @group diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index d5cea62c..6d74cd3f 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -174,7 +174,7 @@ dnl Redefine MACRO-NAME to hold its former content plus STRING at the dnl end. It is valid to use this macro with MACRO-NAME undefined. dnl dnl This macro is robust to active symbols. It can be used to grow -dnl strings or lists. +dnl strings. dnl dnl | define(active, ACTIVE) dnl | m4_append([sentence], [This is an]) @@ -200,8 +200,15 @@ dnl => dnl => active define(m4_append, [define([$1], -ifdef([$1], [defn([$1])]) -[$2])]) +ifdef([$1], [defn([$1])])[$2])]) + + +dnl m4_list_append(MACRO-NAME, STRING) +dnl ---------------------------------- +dnl Same as `m4_append', but each element is separated by `, '. +define(m4_list_append, +[define([$1], +ifdef([$1], [defn([$1]), ])[$2])]) dnl ------------------------------------------------------------ @@ -2872,10 +2879,50 @@ AC_VAR_POPDEF([ac_Type])dnl dnl ### Creating output files +dnl AC_CONFIG_IF_MEMBER(DEST[:SOURCE], LIST, ACTION-IF-TRUE, ACTION-IF-FALSE) +dnl ------------------------------------------------------------------------- +dnl If DEST is member of LIST, expand to ACTION-IF-TRUE, else ACTION-IF-FALSE. +dnl +dnl LIST is an AC_CONFIG list, i.e., a list of DEST[:SOURCE], separated +dnl with spaces. +dnl +dnl FIXME: This macro is badly designed, but I'm not guilty: m4 is. There +dnl is just no way to simply compare two strings in m4, but to use pattern +dnl matching. The big problem is then that the active characters should +dnl be quoted. So an additional macro should be used here. Nevertheless, +dnl in the case of file names, there is not much to worry. +define(AC_CONFIG_IF_MEMBER, +[pushdef([AC_Dest], patsubst([$1], [:.*]))dnl +ifelse(regexp($2, [\(^\| \)]AC_Dest[\(:\| \|$\)]), -1, [$4], [$3])dnl +popdef([AC_Dest])dnl +]) + + +dnl AC_CONFIG_UNIQUE(DEST[:SOURCE]...) +dnl ---------------------------------- +dnl Verify that there is no double definition of an output file +dnl (precisely, guarantees there is no common elements between +dnl CONFIG_HEADERS, CONFIG_FILES, CONFIG_LINKS, and CONFIG_SUBDIRS). +define(AC_CONFIG_UNIQUE, +[AC_FOREACH([AC_File], [$1], + [AC_CONFIG_IF_MEMBER(AC_File, [AC_LIST_HEADERS], + [AC_FATAL(`AC_File' [is already registered with AC_CONFIG_HEADER.])]) + AC_CONFIG_IF_MEMBER(AC_File, [AC_LIST_LINKS], + [AC_FATAL(`AC_File' [is already registered with AC_CONFIG_LINKS.])]) + AC_CONFIG_IF_MEMBER(AC_File, [AC_LIST_SUBDIRS], + [AC_FATAL(`AC_File' [is already registered with AC_CONFIG_SUBDIRS.])]) + AC_CONFIG_IF_MEMBER(AC_File, [AC_LIST_FILES], + [AC_FATAL(`AC_File' [is already registered with AC_CONFIG_FILES or AC_OUTPUT.])])])dnl +]) + dnl AC_CONFIG_HEADER(HEADER-TO-CREATE ...) +dnl -------------------------------------- +dnl FIXME: For sake of uniformity, it should be AC_CONFIG_HEADERS, and +dnl it should be possible to accumulate several calls. AC_DEFUN(AC_CONFIG_HEADER, -[define(AC_LIST_HEADERS, $1)]) +[AC_CONFIG_UNIQUE([$1])dnl +define(AC_LIST_HEADERS, $1)]) dnl AC_CONFIG_LINKS(DEST:SOURCE...) @@ -2884,13 +2931,12 @@ 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 .'). +dnl This macro may be called multiple times. 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]) +[AC_CONFIG_UNIQUE([$1])dnl +ifelse(regexp([$1], [^\.:\| \.:]), -1,, + [AC_FATAL([$0: invalid destination: `.'])])dnl +m4_append([AC_LIST_LINKS], [$1])dnl ]) @@ -2898,27 +2944,49 @@ dnl AC_LINK_FILES(SOURCE..., DEST...) dnl --------------------------------- dnl Link each of the existing files SOURCE... to the corresponding dnl link name in DEST... -dnl This macro, as AC_CONFIG_FILES, produces no sh code, so we don't -dnl dnl. AC_DEFUN(AC_LINK_FILES, -[AC_OBSOLETE([$0], [; instead use AC_CONFIG_FILES(DEST:SOURCE...)]) +[AC_OBSOLETE([$0], [; instead use AC_CONFIG_LINKS(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])))) - + [AC_FATAL([$0: incorrect number of arguments])])dnl +dnl +pushdef([AC_Sources], m4_split(m4_strip(m4_join([$1]))))dnl +pushdef([AC_Dests], m4_split(m4_strip(m4_join([$2]))))dnl +dnl 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)))]) +[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)))])dnl +dnl +popdef([AC_Sources])dnl +popdef([AC_Dests])dnl +])dnl AC_LINK_FILES + + +dnl AC_CONFIG_FILES(FILE...[, COMMANDS]) +dnl ------------------------------------ +dnl Specify output files, as with AC_OUTPUT, i.e., files that are +dnl configured with AC_SUBST. Associate the COMMANDS to each FILE, +dnl i.e., when config.status creates FILE, run COMMANDS afterwards. +dnl +dnl The commands are stored in a growing string AC_LIST_FILES_COMMANDS +dnl which should be used like this: +dnl +dnl case $ac_file in +dnl AC_LIST_FILES_COMMANDS +dnl esac +AC_DEFUN([AC_CONFIG_FILES], +[AC_CONFIG_UNIQUE([$1])dnl +m4_append([AC_LIST_FILES], [ $1])dnl +dnl +pushdef([AC_Prefix], [ ])dnl +dnl +ifelse([$2],,, [AC_FOREACH([AC_File], [$1], +[m4_append([AC_LIST_FILES_COMMANDS], +[ ]patsubst(AC_File, [:.*])[ ) $2 ;; +])])])dnl +])dnl -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 ----------------------------------------- @@ -2934,9 +3002,11 @@ AC_DIVERT_PUSH(AC_DIVERSION_ICMDS)dnl AC_DIVERT_POP()]) dnl AC_CONFIG_SUBDIRS(DIR ...) +dnl -------------------------- AC_DEFUN(AC_CONFIG_SUBDIRS, -[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl -define([AC_LIST_SUBDIRS], ifdef([AC_LIST_SUBDIRS], [AC_LIST_SUBDIRS ],)[$1])dnl +[AC_CONFIG_UNIQUE([$1])dnl +AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +m4_append([AC_LIST_SUBDIRS], [$1])dnl subdirs="AC_LIST_SUBDIRS" AC_SUBST(subdirs)dnl ]) @@ -2949,7 +3019,9 @@ 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, -[trap '' 1 2 15 +[dnl Store the CONFIG_FILES +AC_CONFIG_FILES([$1])dnl +trap '' 1 2 15 AC_CACHE_SAVE trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 @@ -2990,8 +3062,8 @@ dnl so uname gets run too. # configure, is in ./config.log if it exists. # Files that config.status was made for. -ifset([$1], [config_files="\\ -AC_WRAP($1, [ ])" +ifdef([AC_LIST_FILES], [config_files="\\ +AC_WRAP(AC_LIST_FILES, [ ])" ])dnl ifdef([AC_LIST_HEADERS], [config_headers="\\ AC_WRAP(AC_LIST_HEADERS, [ ])" @@ -3013,9 +3085,9 @@ Usage: $CONFIG_STATUS @BKL@OPTIONS@BKR@ FILE... dnl Issue this section only if there were actually config files. 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], +ifset(ifdef([AC_LIST_HEADERS], 1)ifdef([AC_LIST_LINKS], 1)ifdef([AC_LIST_FILES], 1), [Files to instantiate: -ifset($1, [ Configuration files: +ifdef([AC_LIST_FILES], [ Configuration files: \$config_files ])dnl ifdef([AC_LIST_HEADERS], [ Configuration headers: @@ -3094,15 +3166,15 @@ EOF dnl Issue this section only if there were actually config files. 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], +ifset(ifdef([AC_LIST_HEADERS], 1)ifdef([AC_LIST_LINKS], 1)ifdef([AC_LIST_FILES], 1), [cat >> $CONFIG_STATUS <>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF changequote(<<, >>)dnl + +# +# CONFIG_HEADER section. +# + # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # @@ -3511,6 +3602,10 @@ 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 + +# +# CONFIG_LINKS section. +# srcdir=$ac_given_srcdir dnl Here we use : instead of .. because if AC_LINK_FILES was used @@ -3550,7 +3645,7 @@ changequote([, ])dnl changequote(, )dnl [/$]*) ac_rel_source="$srcdir/$ac_source" ;; changequote([, ])dnl - *) ac_rel_source="$ac_dots$srcdir/$ac_source" ;; + *) ac_rel_source="$ac_dots$srcdir/$ac_source" ;; esac # Make a symlink if possible; otherwise try a hard link.