+1999-11-01 Akim Demaille <akim@epita.fr>
+
+ Be kind to Automake: list the arguments of selected macros
+ (for instance AC_SUBST will list each variable which may be
+ substitued).
+
+ * autoconf.sh (--trace, --output): New options.
+ Implement tracing of macros.
+ trap also on 0, so that there is no need to rm here and there.
+ * autoconf.texi (Output): Document --trace and --output.
+
1999-11-01 Akim Demaille <akim@epita.fr>
Clean up the macros for testing members of aggregates.
ridiculously small, so that people see a framework in which they may
provide their additional tests.
+** AC_INCLUDE
+I think shell globbing is a bad thing. In particular, this is bad for
+automake. I think we should make it static, i.e., very much like
+AC_CONFIG_ things. So there would no problems of localization, some
+macros may AC_INCLUDE files etc.
+
** testsuite/config/unix.exp
Fix the regex snippet so that it properly parses the current version
of Autoconf.
** Allow --recursive to config.status
So that --recheck does not pass --no-recursive to configure.
-** Allow --header, --command, --file to config.status.
-./config.status --file foo, would work on foo as if it were a config
-file. It would be great that we could use stdin and stdout also.
-
** Move AM_PROG_CC_STDC into Autoconf.
Autoconf should provide the means to determine the ANSIsm of the
compiler, not Automake.
\`configure.in' by default. Output is sent to the standard output if
TEMPLATE-FILE is given, else into \`configure'.
- -m, --macrodir=DIR directory storing macro files
- -l, --localdir=DIR directory storing the \`aclocal.m4' file
- -h, --help print this help, then exit
- --version print version number, then exit
+If the option \`--trace' is used, no configuration script is created.
+
+ -h, --help print this help, then exit
+ --version print version number, then exit
+ -m, --macrodir=DIR directory storing macro files
+ -l, --localdir=DIR directory storing the \`aclocal.m4' file
+ -t, --trace=MACRO report the list of calls to MACRO
+ -o, --output=FILE save output in FILE (stdout is the default)
Report bugs to <bug-autoconf@gnu.org>."
if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+# ac_LF_and_DOT
+# We use echo to avoid assuming a particular line-breaking character.
+# The extra dot is to prevent the shell from consuming trailing
+# line-breaks from the sub-command output. A line-break within
+# single-quotes doesn't work because, if this script is created in a
+# platform that uses two characters for line-breaks (e.g., DOS), tr
+# would break.
+ac_LF_and_DOT="`echo; echo .`"
+
: ${AC_MACRODIR=@datadir@}
: ${M4=@M4@}
: ${AWK=@AWK@}
-case "${M4}" in
+case "$M4" in
/*) # Handle the case that m4 has moved since we were configured.
# It may have been found originally in a build directory.
- test -f "${M4}" || M4=m4 ;;
+ test -f "$M4" || M4=m4 ;;
esac
: ${TMPDIR=/tmp}
-tmpout=${TMPDIR}/acout.$$
+tmpin=$TMPDIR/acin.$$
+tmpout=$TMPDIR/acout.$$
localdir=
+outfile=
+# Tasks:
+# - trace
+# Trace the first arguments of some macros
+# - script
+# Produce the configure script (default)
+task=script
while test $# -gt 0 ; do
- case "${1}" in
- -h | --help | --h* )
- echo "${usage}"; exit 0 ;;
- --localdir=* | --l*=* )
- localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
- shift ;;
- -l | --localdir | --l*)
- shift
- test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
- localdir="${1}"
- shift ;;
- --macrodir=* | --m*=* )
- AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
- shift ;;
- -m | --macrodir | --m* )
- shift
- test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
- AC_MACRODIR="${1}"
- shift ;;
- --version | --v* )
- echo "$version" ; exit 0 ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "${usage}" 1>&2; exit 1 ;;
- * )
- break ;;
- esac
+ case "$1" in
+ -h | --help | --h* )
+ echo "$usage"; exit 0 ;;
+ --localdir=* | --l*=* )
+ localdir="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -l | --localdir | --l*)
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ localdir="$1"
+ shift ;;
+ --macrodir=* | --m*=* )
+ AC_MACRODIR="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -m | --macrodir | --m* )
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ AC_MACRODIR="$1"
+ shift ;;
+ --trace | -t )
+ task=trace
+ shift
+ traces="$traces -t $1"
+ shift ;;
+ --trace=* )
+ task=trace
+ traces="$traces -t `echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -t* )
+ task=trace
+ traces="$traces -t `echo \"$1\" | sed -e 's/^-t//'`"
+ shift ;;
+ --output | -o )
+ shift
+ outfile="$1"
+ shift ;;
+ --output=* )
+ outfile="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -o* )
+ outfile="`echo \"$1\" | sed -e 's/^-o//'`"
+ shift ;;
+ --version | --v* )
+ echo "$version" ; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$usage" 1>&2; exit 1 ;;
+ * )
+ break ;;
+ esac
done
case $# in
- 0) infile=configure.in ;;
+ 0) infile=configure.in
+ test $task = script && test "x$outfile" = x && outfile=configure;;
1) infile="$1" ;;
*) echo "$usage" >&2; exit 1 ;;
esac
-trap 'rm -f $tmpin $tmpout; exit 1' 1 2 15
-
-tmpin=${TMPDIR}/acin.$$ # Always set this, to avoid bogus errors from some rm's.
+trap 'rm -f $tmpin $tmpout' 0 1 2 15
if test z$infile = z-; then
infile=$tmpin
- cat > $infile
+ cat >$infile
elif test ! -r "$infile"; then
- echo "autoconf: ${infile}: No such file or directory" >&2
+ echo "autoconf: $infile: No such file or directory" >&2
exit 1
fi
case `$M4 --help < /dev/null 2>&1` in
*reload-state*) test -r $AC_MACRODIR/autoconf.m4f && { r=--reload f=f; } ;;
*traditional*) ;;
-*) echo Autoconf requires GNU m4 1.1 or later >&2; rm -f $tmpin; exit 1 ;;
+*) echo Autoconf requires GNU m4 1.1 or later >&2; exit 1 ;;
esac
+run_m4="$M4 -I$AC_MACRODIR $use_localdir $r autoconf.m4$f"
-$M4 -I$AC_MACRODIR $use_localdir $r autoconf.m4$f $infile > $tmpout ||
- { rm -f $tmpin $tmpout; exit 2; }
-
-# You could add your own prefixes to pattern if you wanted to check for
-# them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
-# alternation.
-pattern="A[CHM]_"
-
-status=0
-if grep "^[^#]*${pattern}" $tmpout > /dev/null 2>&1; then
- echo "autoconf: Undefined macros:" >&2
- sed -n "s/^[^#]*\\(${pattern}[_A-Za-z0-9]*\\).*/\\1/p" $tmpout |
- while read macro; do
- grep -n "^[^#]*$macro" $infile /dev/null
- test $? -eq 1 && echo "***BUG in Autoconf--please report*** $macro"
- done | sort -u >&2
- status=1
-fi
+# Output is produced into FD 4. Prepare it.
+case "x$outfile" in
+ x- | x ) # Output to stdout
+ exec 4>&1 ;;
+ * )
+ exec 4>$outfile;;
+esac
-if test $# -eq 0; then
- exec 4> configure; chmod +x configure
-else
- exec 4>&1
-fi
+# Initializations are performed. Perform the task.
+case $task in
+ #
+ # Generate the script
+ #
+ script)
+ $run_m4 $infile > $tmpout || exit 2
-# Put the real line numbers into configure to make config.log more helpful.
-# Because quoting can sometimes get really painful in m4, there are special
-# tokens to substitute.
-$AWK '
-/__oline__/ { printf "%d:", NR + 1 }
- { print }
-' $tmpout | sed '
-/__oline__/s/^\([0-9][0-9]*\):\(.*\)__oline__/\2\1/
-s/@BKL@/[/g
-s/@BKR@/]/g
-s/@DLR@/$/g
-s/@PND@/#/g
-' >&4
-
-rm -f $tmpout
+ # You could add your own prefixes to pattern if you wanted to check for
+ # them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
+ # alternation.
+ pattern="A[CHM]_"
+
+ status=0
+ if grep "^[^#]*$pattern" $tmpout > /dev/null 2>&1; then
+ echo "autoconf: Undefined macros:" >&2
+ sed -n "s/^[^#]*\\($pattern[_A-Za-z0-9]*\\).*/\\1/p" $tmpout |
+ while read macro; do
+ grep -n "^[^#]*$macro" $infile /dev/null
+ test $? -eq 1 && echo "***BUG in Autoconf--please report*** $macro"
+ done | sort -u >&2
+ status=1
+ fi
+
+ if test -n "$outfile"; then
+ chmod +x $outfile
+ fi
+
+ # Put the real line numbers into configure to make config.log more helpful.
+ # Because quoting can sometimes get really painful in m4, there are special
+ # @tokens@ to substitute.
+ $AWK '
+ /__oline__/ { printf "%d:", NR + 1 }
+ { print }
+ ' $tmpout | sed '
+ /__oline__/s/^\([0-9][0-9]*\):\(.*\)__oline__/\2\1/
+ s/@BKL@/[/g
+ s/@BKR@/]/g
+ s/@DLR@/$/g
+ s/@PND@/#/g
+ ' >&4
+ ;; # End of the task script.
+
+ #
+ # Trace macros.
+ #
+ trace)
+ $run_m4 $traces -dafl $infile -o $tmpout>/dev/null || exit 2
+ # The output looks like this:
+ # | m4trace:configure.in:2: -1- AC_CHECK_FUNCS(foo bar
+ # | baz, fubar)
+ # and should be like this:
+ # configure.in:2:AC_CHECK_FUNCS:foo bar baz, fubar
+ cat $tmpout |
+ # No need to be too verbose
+ uniq |
+ sed -e 's/m4trace:/@&/' |
+ # Join arguments spread on several lines
+ tr "$ac_LF_and_DOT" ' .' |
+ tr @. "$ac_LF_and_DOT" |
+ # Remove m4trace and -1-
+ sed -n -e 's/^[^:]*:\([^:]*:[^:]*:\)[^a-zA-Z_]*\([a-zA-Z_]*.*\) $/\1\2/p' |
+ # Replace the first `(' by a colon, remove the last `)'.
+ sed -e 's/(/:/; s/)$//' >&4
+ # The last eof was eaten.
+ echo >&4
+ ;;
+
+ *)echo "$0: internal error: unknown task: $task" >&2
+ exit 1
+esac
exit $status
\`configure.in' by default. Output is sent to the standard output if
TEMPLATE-FILE is given, else into \`configure'.
- -m, --macrodir=DIR directory storing macro files
- -l, --localdir=DIR directory storing the \`aclocal.m4' file
- -h, --help print this help, then exit
- --version print version number, then exit
+If the option \`--trace' is used, no configuration script is created.
+
+ -h, --help print this help, then exit
+ --version print version number, then exit
+ -m, --macrodir=DIR directory storing macro files
+ -l, --localdir=DIR directory storing the \`aclocal.m4' file
+ -t, --trace=MACRO report the list of calls to MACRO
+ -o, --output=FILE save output in FILE (stdout is the default)
Report bugs to <bug-autoconf@gnu.org>."
if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+# ac_LF_and_DOT
+# We use echo to avoid assuming a particular line-breaking character.
+# The extra dot is to prevent the shell from consuming trailing
+# line-breaks from the sub-command output. A line-break within
+# single-quotes doesn't work because, if this script is created in a
+# platform that uses two characters for line-breaks (e.g., DOS), tr
+# would break.
+ac_LF_and_DOT="`echo; echo .`"
+
: ${AC_MACRODIR=@datadir@}
: ${M4=@M4@}
: ${AWK=@AWK@}
-case "${M4}" in
+case "$M4" in
/*) # Handle the case that m4 has moved since we were configured.
# It may have been found originally in a build directory.
- test -f "${M4}" || M4=m4 ;;
+ test -f "$M4" || M4=m4 ;;
esac
: ${TMPDIR=/tmp}
-tmpout=${TMPDIR}/acout.$$
+tmpin=$TMPDIR/acin.$$
+tmpout=$TMPDIR/acout.$$
localdir=
+outfile=
+# Tasks:
+# - trace
+# Trace the first arguments of some macros
+# - script
+# Produce the configure script (default)
+task=script
while test $# -gt 0 ; do
- case "${1}" in
- -h | --help | --h* )
- echo "${usage}"; exit 0 ;;
- --localdir=* | --l*=* )
- localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
- shift ;;
- -l | --localdir | --l*)
- shift
- test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
- localdir="${1}"
- shift ;;
- --macrodir=* | --m*=* )
- AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
- shift ;;
- -m | --macrodir | --m* )
- shift
- test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
- AC_MACRODIR="${1}"
- shift ;;
- --version | --v* )
- echo "$version" ; exit 0 ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "${usage}" 1>&2; exit 1 ;;
- * )
- break ;;
- esac
+ case "$1" in
+ -h | --help | --h* )
+ echo "$usage"; exit 0 ;;
+ --localdir=* | --l*=* )
+ localdir="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -l | --localdir | --l*)
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ localdir="$1"
+ shift ;;
+ --macrodir=* | --m*=* )
+ AC_MACRODIR="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -m | --macrodir | --m* )
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ AC_MACRODIR="$1"
+ shift ;;
+ --trace | -t )
+ task=trace
+ shift
+ traces="$traces -t $1"
+ shift ;;
+ --trace=* )
+ task=trace
+ traces="$traces -t `echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -t* )
+ task=trace
+ traces="$traces -t `echo \"$1\" | sed -e 's/^-t//'`"
+ shift ;;
+ --output | -o )
+ shift
+ outfile="$1"
+ shift ;;
+ --output=* )
+ outfile="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -o* )
+ outfile="`echo \"$1\" | sed -e 's/^-o//'`"
+ shift ;;
+ --version | --v* )
+ echo "$version" ; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$usage" 1>&2; exit 1 ;;
+ * )
+ break ;;
+ esac
done
case $# in
- 0) infile=configure.in ;;
+ 0) infile=configure.in
+ test $task = script && test "x$outfile" = x && outfile=configure;;
1) infile="$1" ;;
*) echo "$usage" >&2; exit 1 ;;
esac
-trap 'rm -f $tmpin $tmpout; exit 1' 1 2 15
-
-tmpin=${TMPDIR}/acin.$$ # Always set this, to avoid bogus errors from some rm's.
+trap 'rm -f $tmpin $tmpout' 0 1 2 15
if test z$infile = z-; then
infile=$tmpin
- cat > $infile
+ cat >$infile
elif test ! -r "$infile"; then
- echo "autoconf: ${infile}: No such file or directory" >&2
+ echo "autoconf: $infile: No such file or directory" >&2
exit 1
fi
case `$M4 --help < /dev/null 2>&1` in
*reload-state*) test -r $AC_MACRODIR/autoconf.m4f && { r=--reload f=f; } ;;
*traditional*) ;;
-*) echo Autoconf requires GNU m4 1.1 or later >&2; rm -f $tmpin; exit 1 ;;
+*) echo Autoconf requires GNU m4 1.1 or later >&2; exit 1 ;;
esac
+run_m4="$M4 -I$AC_MACRODIR $use_localdir $r autoconf.m4$f"
-$M4 -I$AC_MACRODIR $use_localdir $r autoconf.m4$f $infile > $tmpout ||
- { rm -f $tmpin $tmpout; exit 2; }
-
-# You could add your own prefixes to pattern if you wanted to check for
-# them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
-# alternation.
-pattern="A[CHM]_"
-
-status=0
-if grep "^[^#]*${pattern}" $tmpout > /dev/null 2>&1; then
- echo "autoconf: Undefined macros:" >&2
- sed -n "s/^[^#]*\\(${pattern}[_A-Za-z0-9]*\\).*/\\1/p" $tmpout |
- while read macro; do
- grep -n "^[^#]*$macro" $infile /dev/null
- test $? -eq 1 && echo "***BUG in Autoconf--please report*** $macro"
- done | sort -u >&2
- status=1
-fi
+# Output is produced into FD 4. Prepare it.
+case "x$outfile" in
+ x- | x ) # Output to stdout
+ exec 4>&1 ;;
+ * )
+ exec 4>$outfile;;
+esac
-if test $# -eq 0; then
- exec 4> configure; chmod +x configure
-else
- exec 4>&1
-fi
+# Initializations are performed. Perform the task.
+case $task in
+ #
+ # Generate the script
+ #
+ script)
+ $run_m4 $infile > $tmpout || exit 2
-# Put the real line numbers into configure to make config.log more helpful.
-# Because quoting can sometimes get really painful in m4, there are special
-# tokens to substitute.
-$AWK '
-/__oline__/ { printf "%d:", NR + 1 }
- { print }
-' $tmpout | sed '
-/__oline__/s/^\([0-9][0-9]*\):\(.*\)__oline__/\2\1/
-s/@BKL@/[/g
-s/@BKR@/]/g
-s/@DLR@/$/g
-s/@PND@/#/g
-' >&4
-
-rm -f $tmpout
+ # You could add your own prefixes to pattern if you wanted to check for
+ # them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
+ # alternation.
+ pattern="A[CHM]_"
+
+ status=0
+ if grep "^[^#]*$pattern" $tmpout > /dev/null 2>&1; then
+ echo "autoconf: Undefined macros:" >&2
+ sed -n "s/^[^#]*\\($pattern[_A-Za-z0-9]*\\).*/\\1/p" $tmpout |
+ while read macro; do
+ grep -n "^[^#]*$macro" $infile /dev/null
+ test $? -eq 1 && echo "***BUG in Autoconf--please report*** $macro"
+ done | sort -u >&2
+ status=1
+ fi
+
+ if test -n "$outfile"; then
+ chmod +x $outfile
+ fi
+
+ # Put the real line numbers into configure to make config.log more helpful.
+ # Because quoting can sometimes get really painful in m4, there are special
+ # @tokens@ to substitute.
+ $AWK '
+ /__oline__/ { printf "%d:", NR + 1 }
+ { print }
+ ' $tmpout | sed '
+ /__oline__/s/^\([0-9][0-9]*\):\(.*\)__oline__/\2\1/
+ s/@BKL@/[/g
+ s/@BKR@/]/g
+ s/@DLR@/$/g
+ s/@PND@/#/g
+ ' >&4
+ ;; # End of the task script.
+
+ #
+ # Trace macros.
+ #
+ trace)
+ $run_m4 $traces -dafl $infile -o $tmpout>/dev/null || exit 2
+ # The output looks like this:
+ # | m4trace:configure.in:2: -1- AC_CHECK_FUNCS(foo bar
+ # | baz, fubar)
+ # and should be like this:
+ # configure.in:2:AC_CHECK_FUNCS:foo bar baz, fubar
+ cat $tmpout |
+ # No need to be too verbose
+ uniq |
+ sed -e 's/m4trace:/@&/' |
+ # Join arguments spread on several lines
+ tr "$ac_LF_and_DOT" ' .' |
+ tr @. "$ac_LF_and_DOT" |
+ # Remove m4trace and -1-
+ sed -n -e 's/^[^:]*:\([^:]*:[^:]*:\)[^a-zA-Z_]*\([a-zA-Z_]*.*\) $/\1\2/p' |
+ # Replace the first `(' by a colon, remove the last `)'.
+ sed -e 's/(/:/; s/)$//' >&4
+ # The last eof was eaten.
+ echo >&4
+ ;;
+
+ *)echo "$0: internal error: unknown task: $task" >&2
+ exit 1
+esac
exit $status
@item --version
Print the version number of Autoconf and exit.
+
+@item --trace=@var{macro}
+@itemx -t @var{macro}
+List the calls to @var{macro}. Multiple calls to @samp{--trace} list
+several macros. It is adviced to use this feature instead of parsing
+@file{configure.in}.
+
+The output is composed of separated lines for each macro call. Each
+line follows this model:
+@example
+% ./autoconf -t AC_INIT -t AM_INIT_AUTOMAKE
+configure.in:2:AC_INIT:acgeneral.m4
+configure.in:3:AM_INIT_AUTOMAKE:autoconf, 2.14a
+@end example
+
+@item --output=@var{file}
+@itemx -o @var{file}
+Save output (script or traces) to @var{file}. The file @samp{-} stands
+for the standard output.
@end table
@node Invoking autoreconf, , Invoking autoconf, Making configure Scripts
told which files to load, and in which order.
@defmac AC_INCLUDE (@var{file}...)
-@maindex AC_INCLUDE
+@maindex INCLUDE
Read the macro definitions that appear in the listed files. A list of
space-separated filenames or shell globbing patterns is expected. The
files will be read in the order they're listed.
\`configure.in' by default. Output is sent to the standard output if
TEMPLATE-FILE is given, else into \`configure'.
- -m, --macrodir=DIR directory storing macro files
- -l, --localdir=DIR directory storing the \`aclocal.m4' file
- -h, --help print this help, then exit
- --version print version number, then exit
+If the option \`--trace' is used, no configuration script is created.
+
+ -h, --help print this help, then exit
+ --version print version number, then exit
+ -m, --macrodir=DIR directory storing macro files
+ -l, --localdir=DIR directory storing the \`aclocal.m4' file
+ -t, --trace=MACRO report the list of calls to MACRO
+ -o, --output=FILE save output in FILE (stdout is the default)
Report bugs to <bug-autoconf@gnu.org>."
if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+# ac_LF_and_DOT
+# We use echo to avoid assuming a particular line-breaking character.
+# The extra dot is to prevent the shell from consuming trailing
+# line-breaks from the sub-command output. A line-break within
+# single-quotes doesn't work because, if this script is created in a
+# platform that uses two characters for line-breaks (e.g., DOS), tr
+# would break.
+ac_LF_and_DOT="`echo; echo .`"
+
: ${AC_MACRODIR=@datadir@}
: ${M4=@M4@}
: ${AWK=@AWK@}
-case "${M4}" in
+case "$M4" in
/*) # Handle the case that m4 has moved since we were configured.
# It may have been found originally in a build directory.
- test -f "${M4}" || M4=m4 ;;
+ test -f "$M4" || M4=m4 ;;
esac
: ${TMPDIR=/tmp}
-tmpout=${TMPDIR}/acout.$$
+tmpin=$TMPDIR/acin.$$
+tmpout=$TMPDIR/acout.$$
localdir=
+outfile=
+# Tasks:
+# - trace
+# Trace the first arguments of some macros
+# - script
+# Produce the configure script (default)
+task=script
while test $# -gt 0 ; do
- case "${1}" in
- -h | --help | --h* )
- echo "${usage}"; exit 0 ;;
- --localdir=* | --l*=* )
- localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
- shift ;;
- -l | --localdir | --l*)
- shift
- test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
- localdir="${1}"
- shift ;;
- --macrodir=* | --m*=* )
- AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
- shift ;;
- -m | --macrodir | --m* )
- shift
- test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
- AC_MACRODIR="${1}"
- shift ;;
- --version | --v* )
- echo "$version" ; exit 0 ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "${usage}" 1>&2; exit 1 ;;
- * )
- break ;;
- esac
+ case "$1" in
+ -h | --help | --h* )
+ echo "$usage"; exit 0 ;;
+ --localdir=* | --l*=* )
+ localdir="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -l | --localdir | --l*)
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ localdir="$1"
+ shift ;;
+ --macrodir=* | --m*=* )
+ AC_MACRODIR="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -m | --macrodir | --m* )
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ AC_MACRODIR="$1"
+ shift ;;
+ --trace | -t )
+ task=trace
+ shift
+ traces="$traces -t $1"
+ shift ;;
+ --trace=* )
+ task=trace
+ traces="$traces -t `echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -t* )
+ task=trace
+ traces="$traces -t `echo \"$1\" | sed -e 's/^-t//'`"
+ shift ;;
+ --output | -o )
+ shift
+ outfile="$1"
+ shift ;;
+ --output=* )
+ outfile="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
+ shift ;;
+ -o* )
+ outfile="`echo \"$1\" | sed -e 's/^-o//'`"
+ shift ;;
+ --version | --v* )
+ echo "$version" ; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$usage" 1>&2; exit 1 ;;
+ * )
+ break ;;
+ esac
done
case $# in
- 0) infile=configure.in ;;
+ 0) infile=configure.in
+ test $task = script && test "x$outfile" = x && outfile=configure;;
1) infile="$1" ;;
*) echo "$usage" >&2; exit 1 ;;
esac
-trap 'rm -f $tmpin $tmpout; exit 1' 1 2 15
-
-tmpin=${TMPDIR}/acin.$$ # Always set this, to avoid bogus errors from some rm's.
+trap 'rm -f $tmpin $tmpout' 0 1 2 15
if test z$infile = z-; then
infile=$tmpin
- cat > $infile
+ cat >$infile
elif test ! -r "$infile"; then
- echo "autoconf: ${infile}: No such file or directory" >&2
+ echo "autoconf: $infile: No such file or directory" >&2
exit 1
fi
case `$M4 --help < /dev/null 2>&1` in
*reload-state*) test -r $AC_MACRODIR/autoconf.m4f && { r=--reload f=f; } ;;
*traditional*) ;;
-*) echo Autoconf requires GNU m4 1.1 or later >&2; rm -f $tmpin; exit 1 ;;
+*) echo Autoconf requires GNU m4 1.1 or later >&2; exit 1 ;;
esac
+run_m4="$M4 -I$AC_MACRODIR $use_localdir $r autoconf.m4$f"
-$M4 -I$AC_MACRODIR $use_localdir $r autoconf.m4$f $infile > $tmpout ||
- { rm -f $tmpin $tmpout; exit 2; }
-
-# You could add your own prefixes to pattern if you wanted to check for
-# them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
-# alternation.
-pattern="A[CHM]_"
-
-status=0
-if grep "^[^#]*${pattern}" $tmpout > /dev/null 2>&1; then
- echo "autoconf: Undefined macros:" >&2
- sed -n "s/^[^#]*\\(${pattern}[_A-Za-z0-9]*\\).*/\\1/p" $tmpout |
- while read macro; do
- grep -n "^[^#]*$macro" $infile /dev/null
- test $? -eq 1 && echo "***BUG in Autoconf--please report*** $macro"
- done | sort -u >&2
- status=1
-fi
+# Output is produced into FD 4. Prepare it.
+case "x$outfile" in
+ x- | x ) # Output to stdout
+ exec 4>&1 ;;
+ * )
+ exec 4>$outfile;;
+esac
-if test $# -eq 0; then
- exec 4> configure; chmod +x configure
-else
- exec 4>&1
-fi
+# Initializations are performed. Perform the task.
+case $task in
+ #
+ # Generate the script
+ #
+ script)
+ $run_m4 $infile > $tmpout || exit 2
-# Put the real line numbers into configure to make config.log more helpful.
-# Because quoting can sometimes get really painful in m4, there are special
-# tokens to substitute.
-$AWK '
-/__oline__/ { printf "%d:", NR + 1 }
- { print }
-' $tmpout | sed '
-/__oline__/s/^\([0-9][0-9]*\):\(.*\)__oline__/\2\1/
-s/@BKL@/[/g
-s/@BKR@/]/g
-s/@DLR@/$/g
-s/@PND@/#/g
-' >&4
-
-rm -f $tmpout
+ # You could add your own prefixes to pattern if you wanted to check for
+ # them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
+ # alternation.
+ pattern="A[CHM]_"
+
+ status=0
+ if grep "^[^#]*$pattern" $tmpout > /dev/null 2>&1; then
+ echo "autoconf: Undefined macros:" >&2
+ sed -n "s/^[^#]*\\($pattern[_A-Za-z0-9]*\\).*/\\1/p" $tmpout |
+ while read macro; do
+ grep -n "^[^#]*$macro" $infile /dev/null
+ test $? -eq 1 && echo "***BUG in Autoconf--please report*** $macro"
+ done | sort -u >&2
+ status=1
+ fi
+
+ if test -n "$outfile"; then
+ chmod +x $outfile
+ fi
+
+ # Put the real line numbers into configure to make config.log more helpful.
+ # Because quoting can sometimes get really painful in m4, there are special
+ # @tokens@ to substitute.
+ $AWK '
+ /__oline__/ { printf "%d:", NR + 1 }
+ { print }
+ ' $tmpout | sed '
+ /__oline__/s/^\([0-9][0-9]*\):\(.*\)__oline__/\2\1/
+ s/@BKL@/[/g
+ s/@BKR@/]/g
+ s/@DLR@/$/g
+ s/@PND@/#/g
+ ' >&4
+ ;; # End of the task script.
+
+ #
+ # Trace macros.
+ #
+ trace)
+ $run_m4 $traces -dafl $infile -o $tmpout>/dev/null || exit 2
+ # The output looks like this:
+ # | m4trace:configure.in:2: -1- AC_CHECK_FUNCS(foo bar
+ # | baz, fubar)
+ # and should be like this:
+ # configure.in:2:AC_CHECK_FUNCS:foo bar baz, fubar
+ cat $tmpout |
+ # No need to be too verbose
+ uniq |
+ sed -e 's/m4trace:/@&/' |
+ # Join arguments spread on several lines
+ tr "$ac_LF_and_DOT" ' .' |
+ tr @. "$ac_LF_and_DOT" |
+ # Remove m4trace and -1-
+ sed -n -e 's/^[^:]*:\([^:]*:[^:]*:\)[^a-zA-Z_]*\([a-zA-Z_]*.*\) $/\1\2/p' |
+ # Replace the first `(' by a colon, remove the last `)'.
+ sed -e 's/(/:/; s/)$//' >&4
+ # The last eof was eaten.
+ echo >&4
+ ;;
+
+ *)echo "$0: internal error: unknown task: $task" >&2
+ exit 1
+esac
exit $status
@item --version
Print the version number of Autoconf and exit.
+
+@item --trace=@var{macro}
+@itemx -t @var{macro}
+List the calls to @var{macro}. Multiple calls to @samp{--trace} list
+several macros. It is adviced to use this feature instead of parsing
+@file{configure.in}.
+
+The output is composed of separated lines for each macro call. Each
+line follows this model:
+@example
+% ./autoconf -t AC_INIT -t AM_INIT_AUTOMAKE
+configure.in:2:AC_INIT:acgeneral.m4
+configure.in:3:AM_INIT_AUTOMAKE:autoconf, 2.14a
+@end example
+
+@item --output=@var{file}
+@itemx -o @var{file}
+Save output (script or traces) to @var{file}. The file @samp{-} stands
+for the standard output.
@end table
@node Invoking autoreconf, , Invoking autoconf, Making configure Scripts
told which files to load, and in which order.
@defmac AC_INCLUDE (@var{file}...)
-@maindex AC_INCLUDE
+@maindex INCLUDE
Read the macro definitions that appear in the listed files. A list of
space-separated filenames or shell globbing patterns is expected. The
files will be read in the order they're listed.
Generate a configuration script from a TEMPLATE-FILE if given, or
`configure.in' by default. Output is sent to the standard output if
TEMPLATE-FILE is given, else into `configure'.
+.PP
+If the option `--trace' is used, no configuration script is created.
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+print this help, then exit
+.TP
+\fB\-\-version\fR
+print version number, then exit
.TP
\fB\-m\fR, \fB\-\-macrodir\fR=\fIDIR\fR
directory storing macro files
\fB\-l\fR, \fB\-\-localdir\fR=\fIDIR\fR
directory storing the `aclocal.m4' file
.TP
-\fB\-h\fR, \fB\-\-help\fR
-print this help, then exit
+\fB\-t\fR, \fB\-\-trace\fR=\fIMACRO\fR
+report the list of calls to MACRO
.TP
-\fB\-\-version\fR
-print version number, then exit
+\fB\-o\fR, \fB\-\-output\fR=\fIFILE\fR
+save output in FILE (stdout is the default)
.SH AUTHOR
Written by David J. MacKenzie.
.SH "REPORTING BUGS"