+2000-04-12 Akim Demaille <akim@epita.fr>
+
+ Provide a fine grained control over autoconf's warnings.
+
+ * acgeneral.m4 (AC_WARNING_IFELSE, _AC_DIAGNOSE, AC_DIAGNOSE):
+ New macros.
+ (AC_DEFUN_ONCE, AC_OBSOLETE, AC_BEFORE, AU_DEFUN, AC_PREREQ,
+ AC_WARNING, AC_FATAL, AC_TRY_RUN): Use AC_DIAGNOSE.
+ * autoconf.sh: Provide support for `--warnings', `-W'.
+ * doc/autoconf.texi (Invoking autoconf): Adjust.
+ (Reporting Messages): New section.
+
2000-04-12 Akim Demaille <akim@epita.fr>
* acgeneral.m4 (_AC_INIT_HELP): Move --srcdir in the first
define([AC_DEFUN_ONCE],
[define([$1],
[AC_PROVIDE_IFELSE([$1],
- [AC_WARNING([$1 invoked multiple times])],
+ [AC_DIAGNOSE([syntax], [$1 invoked multiple times])],
[AC_PRO([$1])$2[]AC_EPI()])])])
# AC_OBSOLETE(THIS-MACRO-NAME, [SUGGESTION])
# ------------------------------------------
define(AC_OBSOLETE,
-[AC_WARNING([$1 is obsolete$2])])
+[AC_DIAGNOSE([obsolete], [$1 is obsolete$2])])
# AC_SPECIALIZE(MACRO, ARG1 [, ARGS...])
# AC_BEFORE(THIS-MACRO-NAME, CALLED-MACRO-NAME)
# ---------------------------------------------
define(AC_BEFORE,
-[AC_PROVIDE_IFELSE([$2], [AC_WARNING([$2 was called before $1])])])
+[AC_PROVIDE_IFELSE([$2], [AC_DIAGNOSE([syntax], [$2 was called before $1])])])
# AC_REQUIRE(MACRO-NAME)
# See `acobsolete.m4' for a longer description.
define(AU_DEFUN,
[define([$1],
-[m4_warn([The macro `$1' is obsolete.
+[AC_DIAGNOSE([obsolete], [The macro `$1' is obsolete.
You should run autoupdate.])dnl
$2])dnl
AU_DEFINE([$1], [$2], [$3])dnl
# --------------------------------
#
-# The idea behind these macros is that we may sometimes have to handle
-# manifest values (e.g. `stdlib.h'), while at other moments, the same
-# code may have to get the value from a variable (e.g., `ac_header').
-# To have a uniform handling of both case, when a new value is about to
-# be processed, declare a local variable, e.g.:
+# Sometimes we may have to handle literals (e.g. `stdlib.h'), while at
+# other moments, the same code may have to get the value from a
+# variable (e.g., `ac_header'). To have a uniform handling of both
+# cases, when a new value is about to be processed, declare a local
+# variable, e.g.:
#
# AC_VAR_PUSHDEF([header], [ac_cv_header_$1])
#
-# and then in the body of the macro, use `header' as is. It is of first
-# importance to use `AC_VAR_*' to access this variable. Don't quote its
-# name: it must be used right away by m4.
+# and then in the body of the macro, use `header' as is. It is of
+# first importance to use `AC_VAR_*' to access this variable. Don't
+# quote its name: it must be used right away by m4.
#
-# If the value `$1' was manifest (e.g. `stdlib.h'), then `header' is in
-# fact the value `ac_cv_header_stdlib_h'. If `$1' was indirect, then
-# `header's value in m4 is in fact `$ac_header', the shell variable that
-# holds all of the magic to get the expansion right.
+# If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is
+# in fact the value `ac_cv_header_stdlib_h'. If `$1' was indirect,
+# then `header's value in m4 is in fact `$ac_header', the shell
+# variable that holds all of the magic to get the expansion right.
#
# At the end of the block, free the variable with
#
# The point of this section is to provide high level functions
# comparable to m4's `translit' primitive, but m4:sh polymorphic.
-# Transliteration of manifest strings should be handled by m4, while
+# Transliteration of literal strings should be handled by m4, while
# shell variables' content will be translated at runtime (tr or sed).
# AC_TR_CPP(EXPRESSION)
# Complain and exit if the Autoconf version is less than VERSION.
define(AC_PREREQ,
[ifelse(_AC_VERSION_COMPARE([AC_ACVERSION], [$1]), -1,
- [AC_FATAL(Autoconf version $1 or higher is required for this script)])])
+ [AC_FATAL([Autoconf version $1 or higher is required for this script])])])
# directly. This will also avoid to some people to get it wrong
# between AC_FATAL and AC_MSG_ERROR.
+
+# AC_WARNING_IFELSE(CATEGORY, IF-TRUE, IF-FALSE)
+# ----------------------------------------------
+# If the CATEGORY of warnings is enabled, expand IF_TRUE otherwise
+# IF-FALSE. CATEGORY is enabled iff `AC_WARNING_ENABLE(CATEGORY)' or
+# `AC_WARNING_ENABLE(all)' is defined.
+define([AC_WARNING_IFELSE],
+[ifdef([AC_WARNING_ENABLE($1)], [$2],
+ [ifdef([AC_WARNING_ENABLE(all)], [$2], [$3])])])
+
+
+# _AC_DIAGNOSE(MESSAGE)
+# ---------------------
+# Report MESSAGE as a warning, unless the user requested -W error,
+# in which case report a fatal error.
+define([_AC_DIAGNOSE],
+[ifdef([AC_WARNING_ENABLE(error)],
+ [m4_fatal([$1])],
+ [m4_warn([$1])])])
+
+
+# AC_DIAGNOSE(CATEGORY, MESSAGE)
+# ------------------------------
+# Report a MESSAGE to the autoconf user if the CATEGORY of warnings
+# is requested (in fact, not disabled).
+define([AC_DIAGNOSE],
+[AC_WARNING_IFELSE([$1], [_AC_DIAGNOSE([$2])])])
+
+
# AC_WARNING(MESSAGE)
-define(AC_WARNING, [m4_warn([$1])])
+# -------------------
+# Report a MESSAGE to the user of autoconf if `-W' or `-W all' was
+# specified.
+define([AC_WARNING], [AC_DIAGNOSE([], [$1])])
+
# AC_FATAL(MESSAGE, [EXIT-STATUS])
-define(AC_FATAL, [m4_fatal([$1], [$2])])
+# --------------------------------
+define([AC_FATAL], [m4_fatal([$1], [$2])])
define([_AC_SH_QUOTE],
[ifelse(regexp([[$1]], [\\`]),
-1, [patsubst([[$1]], [`], [\\`])],
- [AC_WARNING([backquotes should not be backslashed in: $1])dnl
+ [AC_DIAGNOSE([syntax],
+ [backquotes should not be backslashed in: $1])dnl
[$1]])])
# AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
# variables are not a valid argument.
AC_DEFUN(AC_CHECK_MEMBER,
-[AC_REQUIRE([AC_HEADER_STDC])dnl
-AC_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl
-dnl Extract the aggregate name, and the member name
-AC_VAR_IF_INDIR([$1],
-[AC_FATAL([$0: requires manifest arguments])])
+[AC_VAR_IF_INDIR([$1], [AC_FATAL([$0: requires literal arguments])])dnl
ifelse(regexp([$1], [\.]), -1,
[AC_FATAL([$0: Did not see any dot in `$1'])])dnl
+AC_REQUIRE([AC_HEADER_STDC])dnl
+AC_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl
+dnl Extract the aggregate name, and the member name
AC_CACHE_CHECK([for $1], ac_Member,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
[dnl AGGREGATE foo;
# --------------------------------------------------------
AC_DEFUN([AC_TRY_RUN],
[if test "$cross_compiling" = yes; then
- ifelse([$4], ,
- [AC_WARNING([AC_TRY_RUN called without default to allow cross compiling])dnl
- AC_MSG_ERROR(cannot run test program while cross compiling)],
- [$4])
+ m4_default([$4],
+ [AC_DIAGNOSE([cross],
+ [AC_TRY_RUN called without default to allow cross compiling])dnl
+AC_MSG_ERROR(cannot run test program while cross compiling)])
else
AC_RUN_IFELSE([AC_LANG_SOURCE([[$1]])], [$2], [$3])
fi
#
# Check for the existence of FILE.
AC_DEFUN(AC_CHECK_FILE,
-[AC_VAR_PUSHDEF([ac_File], [ac_cv_file_$1])dnl
+[AC_DIAGNOSE([cross],
+ [Cannot check for file existence when cross compiling])dnl
+AC_VAR_PUSHDEF([ac_File], [ac_cv_file_$1])dnl
dnl FIXME: why was there this line? AC_REQUIRE([AC_PROG_CC])dnl
AC_CACHE_CHECK([for $1], ac_File,
-[if test "$cross_compiling" = yes; then
- AC_WARNING([Cannot check for file existence when cross compiling])dnl
+[test "$cross_compiling" = yes &&
AC_MSG_ERROR([Cannot check for file existence when cross compiling])
-fi
if test -r "[$1]"; then
AC_VAR_SET(ac_File, yes)
else
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
-Usage: autoconf [OPTION] ... [TEMPLATE-FILE]
+Usage: $0 [OPTION] ... [TEMPLATE-FILE]
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'.
-If the option \`--trace' is used, no configuration script is created.
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -v, --verbose verbosely report processing
- -d, --debug don't remove temporary files
- -m, --macrodir=DIR directory storing Autoconf's macro files
- -l, --localdir=DIR directory storing the \`aclocal.m4' file
+Operation modes:
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -v, --verbose verbosely report processing
+ -d, --debug don't remove temporary files
+ -m, --macrodir=DIR directory storing Autoconf's macro files
+ -l, --localdir=DIR directory storing the \`aclocal.m4' file
+ -o, --output=FILE save output in FILE (stdout is the default)
+ -W, --warnings=CATEGORY report the warnings falling in CATEGORY
+
+Warning categories include:
+ \`cross' cross compilation issues
+ \`obsolete' use of obsolete macros
+ \`syntax' dubious syntactic constructs
+ \`all' all the warnings
+ \`error' warnings are error
+
+Tracing:
-t, --trace=MACRO report the list of calls to MACRO
-i, --initialization also trace Autoconf's initialization process
- -o, --output=FILE save output in FILE (stdout is the default)
+
+In tracing mode, no configuration script is created.
Report bugs to <bug-autoconf@gnu.org>."
outfile=`echo "$1" | sed -e 's/^[^=]*=//'`
shift ;;
+ --warnings | -W )
+ shift
+ test $# = 0 && { echo "$help" >&2; exit 1; }
+ warnings="$warnings "`echo $1 | sed -e 's/,/ /g'`
+ shift ;;
+ --warnings=* )
+ warnings="$warnings "`echo "$1" | sed -e 's/^[^=]*=//;s/,/ /g'`
+ shift ;;
+ -W* ) # People are used to -Wall, -Werror etc.
+ warnings="$warnings "`echo "$1" | sed -e 's/^.//;s/,/ /g'`
+ shift ;;
+
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
esac
done
+# Support $WARNINGS.
+: ${warnings=`echo $WARNINGS | sed -e 's/,/ /g'`}
+
# Trap on 0 to stop playing with `rm'.
$debug ||
{
# Initializations are performed. Proceed to the main task.
case $task in
- ## --------------------- ##
- ## Generate the script. ##
- ## --------------------- ##
+ ## --------------------------------- ##
+ ## Generate the `configure' script. ##
+ ## --------------------------------- ##
script)
- $run_m4f $infile >$tmp/configure || exit 2
+ # Enable the requested warnings.
+ warnings_opt=`echo "$warnings" |
+ sed -e 's/\([^ ][^ ]*\)/-DAC_WARNING_ENABLE(\1) /g'`
+ $run_m4f $warnings_opt $infile >$tmp/configure || 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
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
-Usage: autoconf [OPTION] ... [TEMPLATE-FILE]
+Usage: $0 [OPTION] ... [TEMPLATE-FILE]
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'.
-If the option \`--trace' is used, no configuration script is created.
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -v, --verbose verbosely report processing
- -d, --debug don't remove temporary files
- -m, --macrodir=DIR directory storing Autoconf's macro files
- -l, --localdir=DIR directory storing the \`aclocal.m4' file
+Operation modes:
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -v, --verbose verbosely report processing
+ -d, --debug don't remove temporary files
+ -m, --macrodir=DIR directory storing Autoconf's macro files
+ -l, --localdir=DIR directory storing the \`aclocal.m4' file
+ -o, --output=FILE save output in FILE (stdout is the default)
+ -W, --warnings=CATEGORY report the warnings falling in CATEGORY
+
+Warning categories include:
+ \`cross' cross compilation issues
+ \`obsolete' use of obsolete macros
+ \`syntax' dubious syntactic constructs
+ \`all' all the warnings
+ \`error' warnings are error
+
+Tracing:
-t, --trace=MACRO report the list of calls to MACRO
-i, --initialization also trace Autoconf's initialization process
- -o, --output=FILE save output in FILE (stdout is the default)
+
+In tracing mode, no configuration script is created.
Report bugs to <bug-autoconf@gnu.org>."
outfile=`echo "$1" | sed -e 's/^[^=]*=//'`
shift ;;
+ --warnings | -W )
+ shift
+ test $# = 0 && { echo "$help" >&2; exit 1; }
+ warnings="$warnings "`echo $1 | sed -e 's/,/ /g'`
+ shift ;;
+ --warnings=* )
+ warnings="$warnings "`echo "$1" | sed -e 's/^[^=]*=//;s/,/ /g'`
+ shift ;;
+ -W* ) # People are used to -Wall, -Werror etc.
+ warnings="$warnings "`echo "$1" | sed -e 's/^.//;s/,/ /g'`
+ shift ;;
+
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
esac
done
+# Support $WARNINGS.
+: ${warnings=`echo $WARNINGS | sed -e 's/,/ /g'`}
+
# Trap on 0 to stop playing with `rm'.
$debug ||
{
# Initializations are performed. Proceed to the main task.
case $task in
- ## --------------------- ##
- ## Generate the script. ##
- ## --------------------- ##
+ ## --------------------------------- ##
+ ## Generate the `configure' script. ##
+ ## --------------------------------- ##
script)
- $run_m4f $infile >$tmp/configure || exit 2
+ # Enable the requested warnings.
+ warnings_opt=`echo "$warnings" |
+ sed -e 's/\([^ ][^ ]*\)/-DAC_WARNING_ENABLE(\1) /g'`
+ $run_m4f $warnings_opt $infile >$tmp/configure || 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
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
-Usage: autoconf [OPTION] ... [TEMPLATE-FILE]
+Usage: $0 [OPTION] ... [TEMPLATE-FILE]
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'.
-If the option \`--trace' is used, no configuration script is created.
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -v, --verbose verbosely report processing
- -d, --debug don't remove temporary files
- -m, --macrodir=DIR directory storing Autoconf's macro files
- -l, --localdir=DIR directory storing the \`aclocal.m4' file
+Operation modes:
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -v, --verbose verbosely report processing
+ -d, --debug don't remove temporary files
+ -m, --macrodir=DIR directory storing Autoconf's macro files
+ -l, --localdir=DIR directory storing the \`aclocal.m4' file
+ -o, --output=FILE save output in FILE (stdout is the default)
+ -W, --warnings=CATEGORY report the warnings falling in CATEGORY
+
+Warning categories include:
+ \`cross' cross compilation issues
+ \`obsolete' use of obsolete macros
+ \`syntax' dubious syntactic constructs
+ \`all' all the warnings
+ \`error' warnings are error
+
+Tracing:
-t, --trace=MACRO report the list of calls to MACRO
-i, --initialization also trace Autoconf's initialization process
- -o, --output=FILE save output in FILE (stdout is the default)
+
+In tracing mode, no configuration script is created.
Report bugs to <bug-autoconf@gnu.org>."
outfile=`echo "$1" | sed -e 's/^[^=]*=//'`
shift ;;
+ --warnings | -W )
+ shift
+ test $# = 0 && { echo "$help" >&2; exit 1; }
+ warnings="$warnings "`echo $1 | sed -e 's/,/ /g'`
+ shift ;;
+ --warnings=* )
+ warnings="$warnings "`echo "$1" | sed -e 's/^[^=]*=//;s/,/ /g'`
+ shift ;;
+ -W* ) # People are used to -Wall, -Werror etc.
+ warnings="$warnings "`echo "$1" | sed -e 's/^.//;s/,/ /g'`
+ shift ;;
+
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
esac
done
+# Support $WARNINGS.
+: ${warnings=`echo $WARNINGS | sed -e 's/,/ /g'`}
+
# Trap on 0 to stop playing with `rm'.
$debug ||
{
# Initializations are performed. Proceed to the main task.
case $task in
- ## --------------------- ##
- ## Generate the script. ##
- ## --------------------- ##
+ ## --------------------------------- ##
+ ## Generate the `configure' script. ##
+ ## --------------------------------- ##
script)
- $run_m4f $infile >$tmp/configure || exit 2
+ # Enable the requested warnings.
+ warnings_opt=`echo "$warnings" |
+ sed -e 's/\([^ ][^ ]*\)/-DAC_WARNING_ENABLE(\1) /g'`
+ $run_m4f $warnings_opt $infile >$tmp/configure || 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
* Defining Symbols:: Defining C preprocessor symbols
* Setting Output Variables:: Replacing variables in output files
* Caching Results:: Speeding up subsequent @code{configure} runs
-* Printing Messages:: Notifying users of progress or problems
+* Printing Messages:: Notifying @code{configure} users
Caching Results
* Macro Definitions:: Basic format of an Autoconf macro
* Macro Names:: What to call your new macros
* Quoting:: Protecting macros from unwanted expansion
+* Reporting Messages:: Notifying @code{autoconf} users
* Dependencies Between Macros:: What to do when macros depend on other macros
Quoting
@itemx -h
Print a summary of the command line options and exit.
-@item --localdir=@var{dir}
-@itemx -l @var{dir}
-Look for the package file @file{aclocal.m4} in directory @var{dir}
-instead of in the current directory.
+@item --version
+@itemx -V
+Print the version number of Autoconf and exit.
+
+@item --verbose
+@itemx -v
+Report processing steps.
+
+@item --debug
+@itemx -d
+Don't remove the temporary files.
@item --macrodir=@var{dir}
@itemx -m @var{dir}
set the @code{AC_MACRODIR} environment variable to a directory; this
option overrides the environment variable.
-@item --version
-@itemx -V
-Print the version number of Autoconf and exit.
-
-@item --trace=@var{macro}[:@var{format}]
-@itemx -t @var{macro}[:@var{format}]
-List the calls to @var{macro} according to the @var{format}. Multiple
-@samp{--trace} list several macros. Multiple @samp{--trace} for a
-single macro do not accumulate, nevertheless, @var{format} can be
-arbitrarily long.
-
-It is often needed to check the content of a @file{configure.in} file,
-but it is extremely fragile and error prone to try to parse it. It is
-suggested to rely upon @samp{--trace} to scan @file{configure.in}.
-
-The @var{format} is a regular string, with new lines if wanted. It
-defaults to @samp{$f:$l:$n:$@@}.
+@item --localdir=@var{dir}
+@itemx -l @var{dir}
+Look for the package file @file{aclocal.m4} in directory @var{dir}
+instead of in the current directory.
@item --output=@var{file}
@itemx -o @var{file}
Save output (script or trace) to @var{file}. The file @samp{-} stands
for the standard output.
+
+@item --warnings=@var{category}
+@itemx -W @var{category}
+@evindex WARNINGS
+Report the warnings related to @var{category} (which can actually be a
+comma separated list). @xref{Reporting Messages}, macro
+@code{AC_DIAGNOSE}, for a comprehensive list of categories. The special
+category @samp{all} will report all the warnings, and @samp{error}
+treats warnings as errors.
+
+The soon-do-be-standard environment variable @code{WARNINGS} is
+supported: it consists in a comma separated list of categories. It is
+honored iff @samp{--warnings} was not used.
+
+@item --trace=@var{macro}[:@var{format}]
+@itemx -t @var{macro}[:@var{format}]
+Do not create the @code{configure} script, but list the calls to
+@var{macro} according to the @var{format}. Multiple @samp{--trace} list
+several macros. Multiple @samp{--trace} for a single macro do not
+accumulate, nevertheless, @var{format} can be arbitrarily long.
+
+The @var{format} is a regular string, with new lines if wanted. It
+defaults to @samp{$f:$l:$n:$@@}, see below for details on the
+@var{format}.
+
+@item --initialization
+@itemx -i
+By default @samp{--trace} does not trace the initialization of the
+Autoconf macros (typically the @code{AC_DEFUN} definitions). This
+results in a noticeable speedup, but can be disabled by this option.
@end table
+It is often needed to check the content of a @file{configure.in} file,
+but it is extremely fragile and error prone to try to parse it. It is
+suggested to rely upon @samp{--trace} to scan @file{configure.in}.
+
The @var{format} of @samp{--trace} can use the following special
escapes:
* Defining Symbols:: Defining C preprocessor symbols
* Setting Output Variables:: Replacing variables in output files
* Caching Results:: Speeding up subsequent @code{configure} runs
-* Printing Messages:: Notifying users of progress or problems
+* Printing Messages:: Notifying @code{configure} users
@end menu
@node Defining Symbols, Setting Output Variables, Results, Results
@node Printing Messages, , Caching Results, Results
@section Printing Messages
+@cindex Messages, from @code{configure}
@code{configure} scripts need to give users running them several kinds
of information. The following macros print messages in ways appropriate
for each kind. The arguments to all of them get enclosed in shell
-double quotes, so the shell performs variable and back quote substitution
-on them. You can print a message containing a comma by quoting the
-message with the @code{m4} quote characters:
-
-@example
-AC_MSG_RESULT([never mind, I found the BASIC compiler])
-@end example
+double quotes, so the shell performs variable and back quote
+substitution on them.
These macros are all wrappers around the @code{echo} shell command.
@code{configure} scripts should rarely need to run @code{echo} directly
only be made to the macro definitions, and all of the callers change
automatically.
+To diagnose static issues, i.e., when @code{autoconf} is run, see
+@ref{Reporting Messages}.
+
@defmac AC_MSG_CHECKING (@var{feature-description})
@maindex MSG_CHECKING
Notify the user that @code{configure} is checking for a particular
* Macro Definitions:: Basic format of an Autoconf macro
* Macro Names:: What to call your new macros
* Quoting:: Protecting macros from unwanted expansion
+* Reporting Messages:: Notifying @code{autoconf} users
* Dependencies Between Macros:: What to do when macros depend on other macros
@end menu
macro does. For example, @code{AC_PATH_X} has internal macros
@code{_AC_PATH_X_XMKMF} and @code{_AC_PATH_X_DIRECT}.
-@node Quoting, Dependencies Between Macros, Macro Names, Writing Macros
+@node Quoting, Reporting Messages, Macro Names, Writing Macros
@section Quoting
@cindex quotation
unexpanded macros. The @code{autoconf} program checks for this problem
by doing @samp{grep AC_ configure}.
-@node Dependencies Between Macros, , Quoting, Writing Macros
+
+@node Reporting Messages, Dependencies Between Macros, Quoting, Writing Macros
+@section Reporting Messages
+@cindex Messages, from @code{autoconf}
+
+When macros statically diagnose abnormal situations, benign or fatal,
+they should report them using these macros. For dynamic issues, i.e.,
+when @code{configure} is run, see @ref{Printing Messages}.
+
+@defmac AC_DIAGNOSE (@var{category}, @var{message})
+@maindex DIAGNOSE
+Report @var{message} as a warning (or as an error if requested by the
+user) if it falls into the @var{category}. You are encouraged to use
+standard categories, which currently include:
+
+@table @samp
+@item all
+messages that don't fall into one of the following category. Use of an
+empty @var{category} is equivalent.
+
+@item cross
+related to cross compilation issues.
+
+@item obsolete
+use of an obsolete construct.
+
+@item syntax
+dubious syntactic constructs, incorrectly ordered macro calls.
+@end table
+@end defmac
+
+@defmac AC_WARNING (@var{message})
+@maindex WARNING
+Equivalent to @samp{AC_DIAGNOSE([], @var{message})}, but you are
+strongly encouraged to use a finer grained category.
+@end defmac
+
+@defmac AC_FATAL (@var{message})
+@maindex FATAL
+Report a severe error @var{message}, and have @code{autoconf} die.
+@end defmac
+
+When the user runs @samp{autoconf -W error}, warnings from
+@code{AC_DIAGNOSE} and @code{AC_WARNING} are reported as error, see
+@ref{Invoking autoconf}.
+
+@node Dependencies Between Macros, , Reporting Messages, Writing Macros
@section Dependencies Between Macros
Some Autoconf macros depend on other macros having been called first in
define([AC_DEFUN_ONCE],
[define([$1],
[AC_PROVIDE_IFELSE([$1],
- [AC_WARNING([$1 invoked multiple times])],
+ [AC_DIAGNOSE([syntax], [$1 invoked multiple times])],
[AC_PRO([$1])$2[]AC_EPI()])])])
# AC_OBSOLETE(THIS-MACRO-NAME, [SUGGESTION])
# ------------------------------------------
define(AC_OBSOLETE,
-[AC_WARNING([$1 is obsolete$2])])
+[AC_DIAGNOSE([obsolete], [$1 is obsolete$2])])
# AC_SPECIALIZE(MACRO, ARG1 [, ARGS...])
# AC_BEFORE(THIS-MACRO-NAME, CALLED-MACRO-NAME)
# ---------------------------------------------
define(AC_BEFORE,
-[AC_PROVIDE_IFELSE([$2], [AC_WARNING([$2 was called before $1])])])
+[AC_PROVIDE_IFELSE([$2], [AC_DIAGNOSE([syntax], [$2 was called before $1])])])
# AC_REQUIRE(MACRO-NAME)
# See `acobsolete.m4' for a longer description.
define(AU_DEFUN,
[define([$1],
-[m4_warn([The macro `$1' is obsolete.
+[AC_DIAGNOSE([obsolete], [The macro `$1' is obsolete.
You should run autoupdate.])dnl
$2])dnl
AU_DEFINE([$1], [$2], [$3])dnl
# --------------------------------
#
-# The idea behind these macros is that we may sometimes have to handle
-# manifest values (e.g. `stdlib.h'), while at other moments, the same
-# code may have to get the value from a variable (e.g., `ac_header').
-# To have a uniform handling of both case, when a new value is about to
-# be processed, declare a local variable, e.g.:
+# Sometimes we may have to handle literals (e.g. `stdlib.h'), while at
+# other moments, the same code may have to get the value from a
+# variable (e.g., `ac_header'). To have a uniform handling of both
+# cases, when a new value is about to be processed, declare a local
+# variable, e.g.:
#
# AC_VAR_PUSHDEF([header], [ac_cv_header_$1])
#
-# and then in the body of the macro, use `header' as is. It is of first
-# importance to use `AC_VAR_*' to access this variable. Don't quote its
-# name: it must be used right away by m4.
+# and then in the body of the macro, use `header' as is. It is of
+# first importance to use `AC_VAR_*' to access this variable. Don't
+# quote its name: it must be used right away by m4.
#
-# If the value `$1' was manifest (e.g. `stdlib.h'), then `header' is in
-# fact the value `ac_cv_header_stdlib_h'. If `$1' was indirect, then
-# `header's value in m4 is in fact `$ac_header', the shell variable that
-# holds all of the magic to get the expansion right.
+# If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is
+# in fact the value `ac_cv_header_stdlib_h'. If `$1' was indirect,
+# then `header's value in m4 is in fact `$ac_header', the shell
+# variable that holds all of the magic to get the expansion right.
#
# At the end of the block, free the variable with
#
# The point of this section is to provide high level functions
# comparable to m4's `translit' primitive, but m4:sh polymorphic.
-# Transliteration of manifest strings should be handled by m4, while
+# Transliteration of literal strings should be handled by m4, while
# shell variables' content will be translated at runtime (tr or sed).
# AC_TR_CPP(EXPRESSION)
# Complain and exit if the Autoconf version is less than VERSION.
define(AC_PREREQ,
[ifelse(_AC_VERSION_COMPARE([AC_ACVERSION], [$1]), -1,
- [AC_FATAL(Autoconf version $1 or higher is required for this script)])])
+ [AC_FATAL([Autoconf version $1 or higher is required for this script])])])
# directly. This will also avoid to some people to get it wrong
# between AC_FATAL and AC_MSG_ERROR.
+
+# AC_WARNING_IFELSE(CATEGORY, IF-TRUE, IF-FALSE)
+# ----------------------------------------------
+# If the CATEGORY of warnings is enabled, expand IF_TRUE otherwise
+# IF-FALSE. CATEGORY is enabled iff `AC_WARNING_ENABLE(CATEGORY)' or
+# `AC_WARNING_ENABLE(all)' is defined.
+define([AC_WARNING_IFELSE],
+[ifdef([AC_WARNING_ENABLE($1)], [$2],
+ [ifdef([AC_WARNING_ENABLE(all)], [$2], [$3])])])
+
+
+# _AC_DIAGNOSE(MESSAGE)
+# ---------------------
+# Report MESSAGE as a warning, unless the user requested -W error,
+# in which case report a fatal error.
+define([_AC_DIAGNOSE],
+[ifdef([AC_WARNING_ENABLE(error)],
+ [m4_fatal([$1])],
+ [m4_warn([$1])])])
+
+
+# AC_DIAGNOSE(CATEGORY, MESSAGE)
+# ------------------------------
+# Report a MESSAGE to the autoconf user if the CATEGORY of warnings
+# is requested (in fact, not disabled).
+define([AC_DIAGNOSE],
+[AC_WARNING_IFELSE([$1], [_AC_DIAGNOSE([$2])])])
+
+
# AC_WARNING(MESSAGE)
-define(AC_WARNING, [m4_warn([$1])])
+# -------------------
+# Report a MESSAGE to the user of autoconf if `-W' or `-W all' was
+# specified.
+define([AC_WARNING], [AC_DIAGNOSE([], [$1])])
+
# AC_FATAL(MESSAGE, [EXIT-STATUS])
-define(AC_FATAL, [m4_fatal([$1], [$2])])
+# --------------------------------
+define([AC_FATAL], [m4_fatal([$1], [$2])])
define([_AC_SH_QUOTE],
[ifelse(regexp([[$1]], [\\`]),
-1, [patsubst([[$1]], [`], [\\`])],
- [AC_WARNING([backquotes should not be backslashed in: $1])dnl
+ [AC_DIAGNOSE([syntax],
+ [backquotes should not be backslashed in: $1])dnl
[$1]])])
# AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
# variables are not a valid argument.
AC_DEFUN(AC_CHECK_MEMBER,
-[AC_REQUIRE([AC_HEADER_STDC])dnl
-AC_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl
-dnl Extract the aggregate name, and the member name
-AC_VAR_IF_INDIR([$1],
-[AC_FATAL([$0: requires manifest arguments])])
+[AC_VAR_IF_INDIR([$1], [AC_FATAL([$0: requires literal arguments])])dnl
ifelse(regexp([$1], [\.]), -1,
[AC_FATAL([$0: Did not see any dot in `$1'])])dnl
+AC_REQUIRE([AC_HEADER_STDC])dnl
+AC_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl
+dnl Extract the aggregate name, and the member name
AC_CACHE_CHECK([for $1], ac_Member,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
[dnl AGGREGATE foo;
# --------------------------------------------------------
AC_DEFUN([AC_TRY_RUN],
[if test "$cross_compiling" = yes; then
- ifelse([$4], ,
- [AC_WARNING([AC_TRY_RUN called without default to allow cross compiling])dnl
- AC_MSG_ERROR(cannot run test program while cross compiling)],
- [$4])
+ m4_default([$4],
+ [AC_DIAGNOSE([cross],
+ [AC_TRY_RUN called without default to allow cross compiling])dnl
+AC_MSG_ERROR(cannot run test program while cross compiling)])
else
AC_RUN_IFELSE([AC_LANG_SOURCE([[$1]])], [$2], [$3])
fi
#
# Check for the existence of FILE.
AC_DEFUN(AC_CHECK_FILE,
-[AC_VAR_PUSHDEF([ac_File], [ac_cv_file_$1])dnl
+[AC_DIAGNOSE([cross],
+ [Cannot check for file existence when cross compiling])dnl
+AC_VAR_PUSHDEF([ac_File], [ac_cv_file_$1])dnl
dnl FIXME: why was there this line? AC_REQUIRE([AC_PROG_CC])dnl
AC_CACHE_CHECK([for $1], ac_File,
-[if test "$cross_compiling" = yes; then
- AC_WARNING([Cannot check for file existence when cross compiling])dnl
+[test "$cross_compiling" = yes &&
AC_MSG_ERROR([Cannot check for file existence when cross compiling])
-fi
if test -r "[$1]"; then
AC_VAR_SET(ac_File, yes)
else
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.020.
-.TH AUTOCONF "1" "March 2000" "GNU autoconf 2.14a" FSF
+.TH AUTOCONF "1" "April 2000" "GNU autoconf 2.14a" FSF
.SH NAME
autoconf \- Generate configuration scripts
.SH SYNOPSIS
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.
+.SS "Operation modes:"
.TP
\fB\-h\fR, \fB\-\-help\fR
print this help, then exit
\fB\-l\fR, \fB\-\-localdir\fR=\fIDIR\fR
directory storing the `aclocal.m4' file
.TP
+\fB\-o\fR, \fB\-\-output\fR=\fIFILE\fR
+save output in FILE (stdout is the default)
+.TP
+\fB\-W\fR, \fB\-\-warnings\fR=\fICATEGORY\fR
+report the warnings falling in CATEGORY
+.SS "Warning categories include:"
+.TP
+`cross'
+cross compilation issues
+.TP
+`obsolete'
+use of obsolete macros
+.TP
+`syntax'
+dubious syntactic constructs
+.TP
+`all'
+all the warnings
+.TP
+`error'
+warnings are error
+.SS "Tracing:"
+.TP
\fB\-t\fR, \fB\-\-trace\fR=\fIMACRO\fR
report the list of calls to MACRO
.TP
\fB\-i\fR, \fB\-\-initialization\fR
also trace Autoconf's initialization process
-.TP
-\fB\-o\fR, \fB\-\-output\fR=\fIFILE\fR
-save output in FILE (stdout is the default)
+.PP
+In tracing mode, no configuration script is created.
.SH AUTHOR
Written by David J. MacKenzie.
.SH "REPORTING BUGS"
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.020.
-.TH AUTOHEADER "1" "March 2000" "GNU autoconf 2.14a" FSF
+.TH AUTOHEADER "1" "April 2000" "GNU autoconf 2.14a" FSF
.SH NAME
autoheader \- Create a template header for configure
.SH SYNOPSIS