+1999-10-31 Akim Demaille <akim@epita.fr>
+
+ Create AC_CONFIG_HEADERS which has the same interface as the other
+ AC_CONFIG_*S.
+
+ * acgeneral.m4 (AC_CONFIG_HEADERS): New macro, with the same
+ interface as AC_CONFIG_LINKS and AC_CONFIG_FILES.
+ (AC_LIST_HEADERS_COMMANDS): New growing string, initialize it.
+ (AC_CONFIG_HEADER): Rename as...
+ (AC_CONFIG_HEADERS): this, for consistency.
+ (AC_CONFIG_HEADER): New macro, which calls AC_OUTPUT_HEADERS.
+ (AC_OUTPUT_HEADERS): The square brackets for sed and grep were
+ not properly quoted: use @BKL@ and @BKR@.
+ (AC_OUTPUT_HEADERS): Run the AC_LIST_HEADERS_COMMANDS.
+
+ * acgeneral.m4 (AC_OUTPUT): Once config.status created, before
+ running it, trap to `exit 1' so that config.status is not removed
+ if configure is interrupted when config.status is complete.
+
+ * acgeneral.m4 (AC_OUTPUT_CONFIG_STATUS): When recognizing
+ arguments, accept only foo, and no longer foo:foo.in etc.
+
1999-10-31 Akim Demaille <akim@epita.fr>
* acgeneral.m4: Formating changes.
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_FATAL(`AC_File' [is already registered with AC_CONFIG_HEADER or AC_CONFIG_HEADERS.])])
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],
])
-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,
+dnl AC_CONFIG_HEADERS(HEADERS..., [COMMANDS])
+dnl -----------------------------------------
+dnl Specify that the HEADERS are to be created by instantiation of the
+dnl AC_DEFINEs. Associate the COMMANDS to the HEADERS. This macro
+dnl accumulates if called several times.
+dnl
+dnl The commands are stored in a growing string AC_LIST_HEADERS_COMMANDS
+dnl which should be used like this:
+dnl
+dnl case $ac_file in
+dnl AC_LIST_HEADERS_COMMANDS
+dnl esac
+AC_DEFUN([AC_CONFIG_HEADERS],
[AC_CONFIG_UNIQUE([$1])dnl
-define([AC_LIST_HEADERS], $1)])
+m4_append([AC_LIST_HEADERS], [$1])dnl
+dnl Register the commands
+ifelse([$2],,, [AC_FOREACH([AC_File], [$1],
+[m4_append([AC_LIST_HEADERS_COMMANDS],
+[ ]patsubst(AC_File, [:.*])[ ) $2 ;;
+])])])dnl
+])dnl
dnl Initialize to empty. It is much easier and uniform to have a config
dnl list expand to empty when undefined, instead of special casing when
dnl not defined (since in this case, AC_CONFIG_FOO expands to AC_CONFIG_FOO).
define([AC_LIST_HEADERS])
+define([AC_LIST_HEADERS_COMMANDS])
+
+
+dnl AC_CONFIG_HEADER(HEADER-TO-CREATE ...)
+dnl --------------------------------------
+dnl FIXME: Make it obsolete?
+AC_DEFUN(AC_CONFIG_HEADER,
+[AC_CONFIG_HEADERS([$1])])
+
dnl AC_CONFIG_LINKS(DEST:SOURCE...)
dnl -------------------------------
AC_OUTPUT_CONFIG_STATUS()dnl
rm -fr confdefs* $ac_clean_files
+trap 'exit 1' 1 2 15
test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1
dnl config.status should not do recursion.
ifset([AC_LIST_SUBDIRS], [AC_OUTPUT_SUBDIRS(AC_LIST_SUBDIRS)])dnl
dnl Issue this section only if there were actually config files.
dnl This checks if one of AC_LIST_HEADERS, AC_LIST_FILES, AC_CONFIG_COMMANDS,
dnl or AC_LIST_LINKS is set.
-ifval(AC_LIST_HEADERS AC_LIST_LINKS AC_LIST_FILES AC_LIST_COMMANDS,
+ifval(AC_LIST_HEADERS()AC_LIST_LINKS()AC_LIST_FILES()AC_LIST_COMMANDS(),
[Files to instantiate:
ifset([AC_LIST_FILES], [ Configuration files:
\$config_files
echo "[\$]ac_cs_usage"; exit 0 ;;
# Handling of arguments.
AC_FOREACH([AC_File], AC_LIST_FILES,
-[ 'patsubst(AC_File, [:.*])' | 'patsubst(AC_File, [:.*]):*' )dnl
+[ 'patsubst(AC_File, [:.*])' )dnl
CONFIG_FILES="[\$]CONFIG_FILES AC_File" ;;
])dnl
AC_FOREACH([AC_File], AC_LIST_LINKS,
-[ 'patsubst(AC_File, [:.*])' | 'patsubst(AC_File, [:.*]):*' )dnl
+[ 'patsubst(AC_File, [:.*])' )dnl
CONFIG_LINKS="[\$]CONFIG_LINKS AC_File" ;;
])dnl
AC_FOREACH([AC_File], AC_LIST_COMMANDS,
-[ 'patsubst(AC_File, [:.*])' | 'patsubst(AC_File, [:.*]):*' )dnl
+[ 'patsubst(AC_File, [:.*])' )dnl
CONFIG_COMMANDS="[\$]CONFIG_COMMANDS AC_File" ;;
])dnl
AC_FOREACH([AC_File], AC_LIST_HEADERS,
-[ 'patsubst(AC_File, [:.*])' | 'patsubst(AC_File, [:.*]):*' )dnl
+[ 'patsubst(AC_File, [:.*])' )dnl
CONFIG_HEADERS="[\$]CONFIG_HEADERS AC_File" ;;
])dnl
# This is an error.
dnl Issue this section only if there were actually config files.
dnl This checks if one of AC_LIST_HEADERS, AC_LIST_FILES, AC_CONFIG_COMMANDS,
dnl or AC_LIST_LINKS is set.
-ifval(AC_LIST_HEADERS AC_LIST_LINKS AC_LIST_FILES AC_LIST_COMMANDS,
+ifval(AC_LIST_HEADERS()AC_LIST_LINKS()AC_LIST_FILES()AC_LIST_COMMANDS(),
[cat >>$CONFIG_STATUS <<EOF
# If there were arguments and we reach this point, then the user
# has specified the files to intantiate. If there were no arguments,
AC_OUTPUT_FILES(AC_LIST_FILES)dnl
AC_DIVERT_POP()])dnl
ifset([AC_LIST_HEADERS],
- [AC_OUTPUT_HEADER(AC_LIST_HEADERS)])dnl
+ [AC_OUTPUT_HEADERS(AC_LIST_HEADERS)])dnl
ifset([AC_LIST_LINKS],
[AC_OUTPUT_LINKS(AC_LIST_LINKS)])dnl
ifset([AC_LIST_COMMANDS],
dnl Set the DEFS variable to the -D options determined earlier.
dnl This is a subroutine of AC_OUTPUT.
dnl It is called inside configure, outside of config.status.
-dnl FIXME: This has to be fixed the same way as in AC_OUTPUT_HEADER.
+dnl FIXME: This has to be fixed the same way as in AC_OUTPUT_HEADERS.
define(AC_OUTPUT_MAKE_DEFS,
[# Transform confdefs.h into DEFS.
dnl Using a here document instead of a string reduces the quoting nightmare.
])dnl AC_OUTPUT_FILES
-dnl AC_OUTPUT_HEADER(HEADER-FILE...)
-dnl --------------------------------
+dnl AC_OUTPUT_HEADERS(HEADER-FILE...)
+dnl ---------------------------------
dnl Create the config.h files from the config.h.in files.
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_HEADER,
+define(AC_OUTPUT_HEADERS,
[cat >>$CONFIG_STATUS <<\EOF
changequote(<<, >>)dnl
# Break up conftest.defines because some shells have a limit on the size
# of here documents, and old seds have small limits too (100 cmds).
echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo ' if egrep "^[ ]*#[ ]*define" $ac_cs_root.in >/dev/null; then' >>$CONFIG_STATUS
+echo ' if egrep "^@BKL@ @BKR@*#@BKL@ @BKR@*define" $ac_cs_root.in >/dev/null; then' >>$CONFIG_STATUS
rm -f conftest.tail
while :
do
echo ' cat >$ac_cs_root.frag <<CEOF' >>$CONFIG_STATUS
dnl Speed up: don't consider the non `#define' lines.
echo ': t' >>$CONFIG_STATUS
- echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
+ echo '/^@BKL@ @BKR@*#@BKL@ @BKR@*define/!b' >>$CONFIG_STATUS
sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
echo 'CEOF
sed -f $ac_cs_root.frag $ac_cs_root.in >$ac_cs_root.out
echo ' cat >$ac_cs_root.frag <<CEOF' >>$CONFIG_STATUS
dnl Speed up: don't consider the non `#undef'
echo ': t' >>$CONFIG_STATUS
- echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
+ echo '/^@BKL@ @BKR@*#@BKL@ @BKR@*undef/!b' >>$CONFIG_STATUS
sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
echo 'CEOF
sed -f $ac_cs_root.frag $ac_cs_root.in >$ac_cs_root.out
rm -f $ac_file
mv $ac_cs_root.h $ac_file
fi
+ifset([AC_LIST_HEADERS_COMMANDS],
+[ # Run the commands associated with the file.
+ case "$ac_file" in
+AC_LIST_HEADERS_COMMANDS()dnl
+ esac
+])dnl
fi; done
EOF
-])dnl AC_OUTPUT_HEADER
+])dnl AC_OUTPUT_HEADERS
dnl AC_OUTPUT_LINKS(DEST:SOURCE...)
dnl AC_OUTPUT_SUBDIRS(DIRECTORY...)
dnl -------------------------------
-dnl This is a subroutine of AC_OUTPUT.
-dnl It is called after running config.status.
+dnl This is a subroutine of AC_OUTPUT, but it does not go into
+dnl config.status, rather, it is called after running config.status.
define(AC_OUTPUT_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_FATAL(`AC_File' [is already registered with AC_CONFIG_HEADER or AC_CONFIG_HEADERS.])])
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],
])
-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,
+dnl AC_CONFIG_HEADERS(HEADERS..., [COMMANDS])
+dnl -----------------------------------------
+dnl Specify that the HEADERS are to be created by instantiation of the
+dnl AC_DEFINEs. Associate the COMMANDS to the HEADERS. This macro
+dnl accumulates if called several times.
+dnl
+dnl The commands are stored in a growing string AC_LIST_HEADERS_COMMANDS
+dnl which should be used like this:
+dnl
+dnl case $ac_file in
+dnl AC_LIST_HEADERS_COMMANDS
+dnl esac
+AC_DEFUN([AC_CONFIG_HEADERS],
[AC_CONFIG_UNIQUE([$1])dnl
-define([AC_LIST_HEADERS], $1)])
+m4_append([AC_LIST_HEADERS], [$1])dnl
+dnl Register the commands
+ifelse([$2],,, [AC_FOREACH([AC_File], [$1],
+[m4_append([AC_LIST_HEADERS_COMMANDS],
+[ ]patsubst(AC_File, [:.*])[ ) $2 ;;
+])])])dnl
+])dnl
dnl Initialize to empty. It is much easier and uniform to have a config
dnl list expand to empty when undefined, instead of special casing when
dnl not defined (since in this case, AC_CONFIG_FOO expands to AC_CONFIG_FOO).
define([AC_LIST_HEADERS])
+define([AC_LIST_HEADERS_COMMANDS])
+
+
+dnl AC_CONFIG_HEADER(HEADER-TO-CREATE ...)
+dnl --------------------------------------
+dnl FIXME: Make it obsolete?
+AC_DEFUN(AC_CONFIG_HEADER,
+[AC_CONFIG_HEADERS([$1])])
+
dnl AC_CONFIG_LINKS(DEST:SOURCE...)
dnl -------------------------------
AC_OUTPUT_CONFIG_STATUS()dnl
rm -fr confdefs* $ac_clean_files
+trap 'exit 1' 1 2 15
test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1
dnl config.status should not do recursion.
ifset([AC_LIST_SUBDIRS], [AC_OUTPUT_SUBDIRS(AC_LIST_SUBDIRS)])dnl
dnl Issue this section only if there were actually config files.
dnl This checks if one of AC_LIST_HEADERS, AC_LIST_FILES, AC_CONFIG_COMMANDS,
dnl or AC_LIST_LINKS is set.
-ifval(AC_LIST_HEADERS AC_LIST_LINKS AC_LIST_FILES AC_LIST_COMMANDS,
+ifval(AC_LIST_HEADERS()AC_LIST_LINKS()AC_LIST_FILES()AC_LIST_COMMANDS(),
[Files to instantiate:
ifset([AC_LIST_FILES], [ Configuration files:
\$config_files
echo "[\$]ac_cs_usage"; exit 0 ;;
# Handling of arguments.
AC_FOREACH([AC_File], AC_LIST_FILES,
-[ 'patsubst(AC_File, [:.*])' | 'patsubst(AC_File, [:.*]):*' )dnl
+[ 'patsubst(AC_File, [:.*])' )dnl
CONFIG_FILES="[\$]CONFIG_FILES AC_File" ;;
])dnl
AC_FOREACH([AC_File], AC_LIST_LINKS,
-[ 'patsubst(AC_File, [:.*])' | 'patsubst(AC_File, [:.*]):*' )dnl
+[ 'patsubst(AC_File, [:.*])' )dnl
CONFIG_LINKS="[\$]CONFIG_LINKS AC_File" ;;
])dnl
AC_FOREACH([AC_File], AC_LIST_COMMANDS,
-[ 'patsubst(AC_File, [:.*])' | 'patsubst(AC_File, [:.*]):*' )dnl
+[ 'patsubst(AC_File, [:.*])' )dnl
CONFIG_COMMANDS="[\$]CONFIG_COMMANDS AC_File" ;;
])dnl
AC_FOREACH([AC_File], AC_LIST_HEADERS,
-[ 'patsubst(AC_File, [:.*])' | 'patsubst(AC_File, [:.*]):*' )dnl
+[ 'patsubst(AC_File, [:.*])' )dnl
CONFIG_HEADERS="[\$]CONFIG_HEADERS AC_File" ;;
])dnl
# This is an error.
dnl Issue this section only if there were actually config files.
dnl This checks if one of AC_LIST_HEADERS, AC_LIST_FILES, AC_CONFIG_COMMANDS,
dnl or AC_LIST_LINKS is set.
-ifval(AC_LIST_HEADERS AC_LIST_LINKS AC_LIST_FILES AC_LIST_COMMANDS,
+ifval(AC_LIST_HEADERS()AC_LIST_LINKS()AC_LIST_FILES()AC_LIST_COMMANDS(),
[cat >>$CONFIG_STATUS <<EOF
# If there were arguments and we reach this point, then the user
# has specified the files to intantiate. If there were no arguments,
AC_OUTPUT_FILES(AC_LIST_FILES)dnl
AC_DIVERT_POP()])dnl
ifset([AC_LIST_HEADERS],
- [AC_OUTPUT_HEADER(AC_LIST_HEADERS)])dnl
+ [AC_OUTPUT_HEADERS(AC_LIST_HEADERS)])dnl
ifset([AC_LIST_LINKS],
[AC_OUTPUT_LINKS(AC_LIST_LINKS)])dnl
ifset([AC_LIST_COMMANDS],
dnl Set the DEFS variable to the -D options determined earlier.
dnl This is a subroutine of AC_OUTPUT.
dnl It is called inside configure, outside of config.status.
-dnl FIXME: This has to be fixed the same way as in AC_OUTPUT_HEADER.
+dnl FIXME: This has to be fixed the same way as in AC_OUTPUT_HEADERS.
define(AC_OUTPUT_MAKE_DEFS,
[# Transform confdefs.h into DEFS.
dnl Using a here document instead of a string reduces the quoting nightmare.
])dnl AC_OUTPUT_FILES
-dnl AC_OUTPUT_HEADER(HEADER-FILE...)
-dnl --------------------------------
+dnl AC_OUTPUT_HEADERS(HEADER-FILE...)
+dnl ---------------------------------
dnl Create the config.h files from the config.h.in files.
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_HEADER,
+define(AC_OUTPUT_HEADERS,
[cat >>$CONFIG_STATUS <<\EOF
changequote(<<, >>)dnl
# Break up conftest.defines because some shells have a limit on the size
# of here documents, and old seds have small limits too (100 cmds).
echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo ' if egrep "^[ ]*#[ ]*define" $ac_cs_root.in >/dev/null; then' >>$CONFIG_STATUS
+echo ' if egrep "^@BKL@ @BKR@*#@BKL@ @BKR@*define" $ac_cs_root.in >/dev/null; then' >>$CONFIG_STATUS
rm -f conftest.tail
while :
do
echo ' cat >$ac_cs_root.frag <<CEOF' >>$CONFIG_STATUS
dnl Speed up: don't consider the non `#define' lines.
echo ': t' >>$CONFIG_STATUS
- echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
+ echo '/^@BKL@ @BKR@*#@BKL@ @BKR@*define/!b' >>$CONFIG_STATUS
sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
echo 'CEOF
sed -f $ac_cs_root.frag $ac_cs_root.in >$ac_cs_root.out
echo ' cat >$ac_cs_root.frag <<CEOF' >>$CONFIG_STATUS
dnl Speed up: don't consider the non `#undef'
echo ': t' >>$CONFIG_STATUS
- echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
+ echo '/^@BKL@ @BKR@*#@BKL@ @BKR@*undef/!b' >>$CONFIG_STATUS
sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
echo 'CEOF
sed -f $ac_cs_root.frag $ac_cs_root.in >$ac_cs_root.out
rm -f $ac_file
mv $ac_cs_root.h $ac_file
fi
+ifset([AC_LIST_HEADERS_COMMANDS],
+[ # Run the commands associated with the file.
+ case "$ac_file" in
+AC_LIST_HEADERS_COMMANDS()dnl
+ esac
+])dnl
fi; done
EOF
-])dnl AC_OUTPUT_HEADER
+])dnl AC_OUTPUT_HEADERS
dnl AC_OUTPUT_LINKS(DEST:SOURCE...)
dnl AC_OUTPUT_SUBDIRS(DIRECTORY...)
dnl -------------------------------
-dnl This is a subroutine of AC_OUTPUT.
-dnl It is called after running config.status.
+dnl This is a subroutine of AC_OUTPUT, but it does not go into
+dnl config.status, rather, it is called after running config.status.
define(AC_OUTPUT_SUBDIRS,
[
#