# This file is part of Autoconf. -*- Autoconf -*-
# Parameterizing and creating config.status.
# Copyright (C) 1992-1996, 1998-2017, 2020-2023 Free Software
# Foundation, Inc.
# This file is part of Autoconf. This program is free
# software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Under Section 7 of GPL version 3, you are granted additional
# permissions described in the Autoconf Configure Script Exception,
# version 3.0, as published by the Free Software Foundation.
#
# You should have received a copy of the GNU General Public License
# and a copy of the Autoconf Configure Script Exception along with
# this program; see the files COPYINGv3 and COPYING.EXCEPTION
# respectively. If not, see .
# Written by David MacKenzie, with help from
# François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
# Roland McGrath, Noah Friedman, david d zuhn, and many others.
# This file handles about all the preparation aspects for
# 'config.status': registering the configuration files, the headers,
# the links, and the commands 'config.status' will run. There is a
# little mixture though of things actually handled by 'configure',
# such as running the 'configure' in the sub directories. Minor
# detail.
#
# There are two kinds of commands:
#
# COMMANDS:
#
# They are output into 'config.status' via a quoted here doc. These
# commands are always associated to a tag which the user can use to
# tell 'config.status' what are the commands she wants to run.
#
# INIT-CMDS:
#
# They are output via an *unquoted* here-doc. As a consequence $var
# will be output as the value of VAR. This is typically used by
# 'configure' to give 'config.status' some variables it needs to run
# the COMMANDS. At the difference of COMMANDS, the INIT-CMDS are
# always run.
#
#
# Honorable members of this family are AC_CONFIG_FILES,
# AC_CONFIG_HEADERS, AC_CONFIG_LINKS and AC_CONFIG_COMMANDS. Bad boys
# are AC_LINK_FILES, AC_OUTPUT_COMMANDS and AC_OUTPUT when used with
# arguments. False members are AC_CONFIG_SRCDIR, AC_CONFIG_SUBDIRS
# and AC_CONFIG_AUX_DIR. Cousins are AC_CONFIG_COMMANDS_PRE and
# AC_CONFIG_COMMANDS_POST.
## ------------------ ##
## Auxiliary macros. ##
## ------------------ ##
# _AC_SRCDIRS(BUILD-DIR-NAME)
# ---------------------------
# Inputs:
# - BUILD-DIR-NAME is 'top-build -> build' and 'top-src -> src'
# - '$srcdir' is 'top-build -> top-src'
#
# Outputs:
# - 'ac_builddir' is '.', for symmetry only.
# - 'ac_top_builddir_sub' is 'build -> top_build'.
# This is used for @top_builddir@.
# - 'ac_top_build_prefix' is 'build -> top_build'.
# If not empty, has a trailing slash.
# - 'ac_srcdir' is 'build -> src'.
# - 'ac_top_srcdir' is 'build -> top-src'.
# and 'ac_abs_builddir' etc., the absolute directory names.
m4_define([_AC_SRCDIRS],
[ac_builddir=.
case $1 in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`AS_ECHO([$1]) | sed 's|^\.[[\\/]]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`AS_ECHO(["$ac_dir_suffix"]) | sed 's|/[[^\\/]]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[[\\/]]* | ?:[[\\/]]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
])# _AC_SRCDIRS
# _AC_HAVE_TOP_BUILD_PREFIX
# -------------------------
# Announce to the world (to Libtool) that we substitute @top_build_prefix@.
AC_DEFUN([_AC_HAVE_TOP_BUILD_PREFIX])
## ---------------------- ##
## Registering the tags. ##
## ---------------------- ##
# _AC_CONFIG_COMMANDS_INIT([INIT-COMMANDS])
# -----------------------------------------
#
# Register INIT-COMMANDS as command pasted *unquoted* in
# 'config.status'. This is typically used to pass variables from
# 'configure' to 'config.status'. Note that $[1] is not over quoted as
# was the case in AC_OUTPUT_COMMANDS.
m4_define([_AC_CONFIG_COMMANDS_INIT],
[m4_ifval([$1],
[m4_append([_AC_OUTPUT_COMMANDS_INIT],
[$1
])])])
# AC_FILE_DEPENDENCY_TRACE(DEST, SOURCE1, [SOURCE2...])
# -----------------------------------------------------
# This macro does nothing, it's a hook to be read with 'autoconf --trace'.
#
# It announces DEST depends upon the SOURCE1 etc.
m4_define([AC_FILE_DEPENDENCY_TRACE], [])
# _AC_FILE_DEPENDENCY_TRACE_COLON(DEST:SOURCE1[:SOURCE2...])
# ----------------------------------------------------------
# Declare that DEST depends upon SOURCE1 etc.
#
m4_define([_AC_FILE_DEPENDENCY_TRACE_COLON],
[AC_FILE_DEPENDENCY_TRACE(m4_translit([$1], [:], [,]))])
# _AC_CONFIG_DEPENDENCY(MODE, DEST[:SOURCE1...])
# ----------------------------------------------
# MODE is 'FILES', 'HEADERS', or 'LINKS'.
#
# Be sure that a missing dependency is expressed as a dependency upon
# 'DEST.in' (except with config links).
#
m4_define([_AC_CONFIG_DEPENDENCY],
[_AC_FILE_DEPENDENCY_TRACE_COLON([$2]_AC_CONFIG_DEPENDENCY_DEFAULT($@))dnl
])
# _AC_CONFIG_DEPENDENCY_DEFAULT(MODE, DEST[:SOURCE1...])
# ------------------------------------------------------
# Expand to ':DEST.in' if appropriate, or to empty string otherwise.
#
# More detailed description:
# If the tag contains ':', expand to nothing.
# Otherwise, for a config file or header, add ':DEST.in'.
# For a config link, DEST.in is not appropriate:
# - if the tag is literal, complain.
# - otherwise, just expand to nothing and proceed with fingers crossed.
# (We get to this case from the obsolete AC_LINK_FILES, for example.)
#
m4_define([_AC_CONFIG_DEPENDENCY_DEFAULT],
[m4_if(m4_index([$2], [:]), [-1],
[m4_if([$1], [LINKS],
[AS_LITERAL_IF([$2],
[m4_fatal([Invalid AC_CONFIG_LINKS tag: '$2'])])],
[:$2.in])])])
# _AC_CONFIG_UNIQUE(MODE, DEST)
# -----------------------------
# MODE is 'FILES', 'HEADERS', 'LINKS', 'COMMANDS', or 'SUBDIRS'.
#
# Verify that there is no double definition of an output file.
#
m4_define([_AC_CONFIG_UNIQUE],
[m4_ifdef([_AC_SEEN_TAG($2)],
[m4_fatal(['$2' is already registered with AC_CONFIG_]m4_defn(
[_AC_SEEN_TAG($2)]).)],
[m4_define([_AC_SEEN_TAG($2)], [$1])])dnl
])
# _AC_CONFIG_FOOS(MODE, TAGS..., [COMMANDS], [INIT-CMDS])
# -------------------------------------------------------
# MODE is 'FILES', 'HEADERS', 'LINKS', or 'COMMANDS'.
#
# Associate the COMMANDS to each TAG, i.e., when config.status creates TAG,
# run COMMANDS afterwards. (This is done in _AC_CONFIG_REGISTER_DEST.)
#
# For COMMANDS, do not m4_normalize TAGS before adding it to ac_config_commands.
# This historical difference allows macro calls in TAGS.
#
m4_define([_AC_CONFIG_FOOS],
[m4_map_args_w([$2], [_AC_CONFIG_REGISTER([$1],], [, [$3])])]dnl
[m4_define([_AC_SEEN_CONFIG(ANY)])]dnl
[m4_define([_AC_SEEN_CONFIG($1)])]dnl
[_AC_CONFIG_COMMANDS_INIT([$4])]dnl
[ac_config_[]m4_tolower([$1])="$ac_config_[]m4_tolower([$1]) ]dnl
[m4_if([$1], [COMMANDS], [$2], [m4_normalize([$2])])"
])
# _AC_CONFIG_COMPUTE_DEST(STRING)
# -------------------------------
# Compute the DEST from STRING by stripping any : and following
# characters. Guarantee a match in m4_index, so as to avoid a bug
# with precision -1 in m4_format in older m4.
m4_define([_AC_CONFIG_COMPUTE_DEST],
[m4_format([[%.*s]], m4_index([$1:], [:]), [$1])])
# _AC_CONFIG_REGISTER(MODE, TAG, [COMMANDS])
# ------------------------------------------
# MODE is 'FILES', 'HEADERS', 'LINKS', or 'COMMANDS'.
#
m4_define([_AC_CONFIG_REGISTER],
[m4_if([$1], [COMMANDS],
[],
[_AC_CONFIG_DEPENDENCY([$1], [$2])])]dnl
[_AC_CONFIG_REGISTER_DEST([$1], [$2],
_AC_CONFIG_COMPUTE_DEST([$2]), [$3])])
# _AC_CONFIG_REGISTER_DEST(MODE, TAG, DEST, [COMMANDS])
# -----------------------------------------------------
# MODE is 'FILES', 'HEADERS', 'LINKS', or 'COMMANDS'.
# TAG is in the form DEST[:SOURCE...].
# Thus parameter $3 is the first part of $2.
#
# With CONFIG_LINKS, reject DEST=., because it is makes it hard for ./config.status
# to guess the links to establish ('./config.status .').
#
# Save the name of the first config header to AH_HEADER.
#
m4_define([_AC_CONFIG_REGISTER_DEST],
[_AC_CONFIG_UNIQUE([$1], [$3])]dnl
[m4_if([$1 $3], [LINKS .],
[m4_fatal([invalid destination of a config link: '.'])],
[$1], [HEADERS],
[m4_define_default([AH_HEADER], [$3])])]dnl
dnl
dnl Recognize TAG as an argument to config.status:
dnl
[m4_append([_AC_LIST_TAGS],
[ "$3") CONFIG_$1="$CONFIG_$1 $2" ;;
])]dnl
dnl
dnl Register the associated commands, if any:
dnl
[m4_ifval([$4],
[m4_append([_AC_LIST_TAG_COMMANDS],
[ "$3":]m4_format([[%.1s]], [$1])[) $4 ;;
])])])# _AC_CONFIG_REGISTER_DEST
## --------------------- ##
## Configuration files. ##
## --------------------- ##
# AC_CONFIG_FILES(FILE..., [COMMANDS], [INIT-CMDS])
# -------------------------------------------------
# Specify output files, i.e., files that are configured with AC_SUBST.
#
AC_DEFUN([AC_CONFIG_FILES], [_AC_CONFIG_FOOS([FILES], $@)])
# _AC_SED_CMD_LIMIT
# -----------------
# Evaluate to an m4 number equal to the maximum number of commands to put
# in any single sed program, not counting ":" commands.
#
# Some seds have small command number limits, like on Digital OSF/1 and HP-UX.
m4_define([_AC_SED_CMD_LIMIT],
dnl One cannot portably go further than 99 commands because of HP-UX.
[99])
# _AC_AWK_LITERAL_LIMIT
# ---------------------
# Evaluate to the maximum number of characters to put in an awk
# string literal, not counting escape characters.
#
# Some awk's have small limits, such as Solaris and AIX awk.
m4_define([_AC_AWK_LITERAL_LIMIT],
[148])
# _AC_OUTPUT_FILES_PREPARE
# ------------------------
# Create the awk scripts needed for CONFIG_FILES.
# Support multiline substitutions and make sure that the substitutions are
# not evaluated recursively.
# The intention is to have readable config.status and configure, even
# though this m4 code might be scary.
#
# This code was written by Sarah Manthey and rewritten by Ralf Wildenhues.
#
# This macro is expanded inside a here document. If the here document is
# closed, it has to be reopened with
# "cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1".
#
m4_define([_AC_OUTPUT_FILES_PREPARE],
[# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
# This happens for instance with './config.status config.h'.
if test -n "$CONFIG_FILES"; then
dnl For AC_SUBST_FILE, check for usable getline support in awk,
dnl at config.status execution time.
dnl Otherwise, do the interpolation in sh, which is slower.
dnl Without any AC_SUBST_FILE, omit all related code.
dnl Note the expansion is double-quoted for readability.
m4_ifdef([_AC_SUBST_FILES],
[[if $AWK 'BEGIN { getline <"/dev/null" }' /dev/null; then
ac_cs_awk_getline=:
ac_cs_awk_pipe_init=
ac_cs_awk_read_file='
while ((getline aline < (F[key])) > 0)
print(aline)
close(F[key])'
ac_cs_awk_pipe_fini=
else
ac_cs_awk_getline=false
ac_cs_awk_pipe_init="print \"cat <<'|#_!!_#|' &&\""
ac_cs_awk_read_file='
print "|#_!!_#|"
print "cat " F[key] " &&"
'$ac_cs_awk_pipe_init
# The final ':' finishes the AND list.
ac_cs_awk_pipe_fini='END { print "|#_!!_#|"; print ":" }'
fi]])
ac_cr=`echo X | tr X '\015'`
# On cygwin, bash can eat \r inside `` if the user requested igncr.
# But we know of no other shell where ac_cr would be empty at this
# point, so we can use a bashism as a fallback.
if test "x$ac_cr" = x; then
eval ac_cr=\$\'\\r\'
fi
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
ac_cs_awk_cr='\\r'
else
ac_cs_awk_cr=$ac_cr
fi
dnl
dnl Define the pipe that does the substitution.
m4_ifdef([_AC_SUBST_FILES],
[m4_define([_AC_SUBST_CMDS], [|
if $ac_cs_awk_getline; then
$AWK -f "$ac_tmp/subs.awk"
else
$AWK -f "$ac_tmp/subs.awk" | $SHELL
fi])],
[m4_define([_AC_SUBST_CMDS],
[| $AWK -f "$ac_tmp/subs.awk"])])dnl
echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
_ACEOF
m4_ifdef([_AC_SUBST_FILES],
[# Create commands to substitute file output variables.
{
echo "cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1" &&
echo 'cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&' &&
echo "$ac_subst_files" | sed 's/.*/F@<:@"&"@:>@="$&"/' &&
echo "_ACAWK" &&
echo "_ACEOF"
} >conf$$files.sh &&
. ./conf$$files.sh ||
AC_MSG_ERROR([could not make $CONFIG_STATUS])
rm -f conf$$files.sh
])dnl
{
echo "cat >conf$$subs.awk <<_ACEOF" &&
echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
echo "_ACEOF"
} >conf$$subs.sh ||
AC_MSG_ERROR([could not make $CONFIG_STATUS])
ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
. ./conf$$subs.sh ||
AC_MSG_ERROR([could not make $CONFIG_STATUS])
dnl Do not use grep on conf$$subs.awk, since AIX grep has a line length limit.
ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
if test $ac_delim_n = $ac_delim_num; then
break
elif $ac_last_try; then
AC_MSG_ERROR([could not make $CONFIG_STATUS])
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
rm -f conf$$subs.sh
dnl Initialize an awk array of substitutions, keyed by variable name.
dnl
dnl The initial line contains the variable name VAR, then a '!'.
dnl Construct 'S["VAR"]=' from it.
dnl The rest of the line, and potentially further lines, contain the
dnl substituted value; the last of those ends with $ac_delim. We split
dnl the output both along those substituted newlines and at intervals of
dnl length _AC_AWK_LITERAL_LIMIT. The latter is done to comply with awk
dnl string literal limitations, the former for simplicity in doing so.
dnl
dnl We deal with one input line at a time to avoid sed pattern space
dnl limitations. We kill the delimiter $ac_delim before splitting the
dnl string (otherwise we risk splitting the delimiter). And we do the
dnl splitting before the quoting of awk special characters (otherwise we
dnl risk splitting an escape sequence).
dnl
dnl Output as separate string literals, joined with backslash-newline.
dnl Eliminate the newline after '=' in a second script, for readability.
dnl
dnl Notes to the main part of the awk script:
dnl - the unusual FS value helps prevent running into the limit of 99 fields,
dnl - we avoid sub/gsub because of the \& quoting issues, see
dnl https://www.gnu.org/software/gawk/manual/html_node/Gory-Details.html
dnl - Writing '$ 0' prevents expansion by both the shell and m4 here.
dnl
dnl m4-double-quote most of the scripting for readability.
[cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
_ACEOF
sed -n '
h
s/^/S["/; s/!.*/"]=/
p
g
s/^[^!]*!//
:repl
t repl
s/'"$ac_delim"'$//
t delim
:nl
h
s/\(.\{]_AC_AWK_LITERAL_LIMIT[\}\)..*/\1/
t more1
s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
p
n
b repl
:more1
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{]_AC_AWK_LITERAL_LIMIT[\}//
t nl
:delim
h
s/\(.\{]_AC_AWK_LITERAL_LIMIT[\}\)..*/\1/
t more2
s/["\\]/\\&/g; s/^/"/; s/$/"/
p
b
:more2
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{]_AC_AWK_LITERAL_LIMIT[\}//
t delim
' >$CONFIG_STATUS || ac_write_fail=1
rm -f conf$$subs.awk
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACAWK
cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
for (key in S) S_is_set[key] = 1
FS = "