diff options
author | Zack Weinberg <zackw@panix.com> | 2020-10-07 09:01:16 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2020-10-07 09:18:33 -0400 |
commit | 09346f1a776b1bba3634f2d3ccf30460fc372d44 (patch) | |
tree | 8c26f75ed05db434165f921fb9dabf1ad4931a1f | |
parent | 1b52a8609b9417a188fee773b8f296c180c4cc73 (diff) | |
download | autoconf-09346f1a776b1bba3634f2d3ccf30460fc372d44.tar.gz |
Don’t issue obsoletion warnings for AC_DIAGNOSE.
AC_DIAGNOSE is used in several extremely popular add-on macros,
notably AM_INIT_AUTOMAKE, AM_GNU_GETTEXT, and AC_LIBTOOL_DLOPEN.
Until newer versions of these macros are available, -Wobsolete
warnings for AC_DIAGNOSE will be unhelpful noise.
Therefore, make it so AC_DIAGNOSE(...) will still be replaced with
m4_warn(...) by autoupdate, but autoconf runs will not complain about
AC_DIAGNOSE. The bulk of the patch is augmenting AU_DEFUN so that it
can define a “silent” autoupdate replacement, and documenting the new
feature.
* lib/autoconf/autoupdate.m4 (AU_DEFUN): Add a fourth argument, SILENT,
which must be either empty or the word ‘silent’. If it is ‘silent’,
the macro being defined will *not* issue a -Wobsolete warning when
expanded by autoconf.
Tweak quotation to prevent emacs’ parenthesis matching from getting
confused.
(AU_ALIAS): Add the SILENT argument here as well.
* lib/autoconf/general.m4 (AC_DIAGNOSE): Define as a silent AU_DEFUN.
Add commentary explaining why this was done and when it can be
changed back.
* doc/autoconf.texi (AU_DEFUN, AU_ALIAS): Revise; document new SILENT
argument.
-rw-r--r-- | doc/autoconf.texi | 64 | ||||
-rw-r--r-- | lib/autoconf/autoupdate.m4 | 47 | ||||
-rw-r--r-- | lib/autoconf/general.m4 | 12 |
3 files changed, 82 insertions, 41 deletions
diff --git a/doc/autoconf.texi b/doc/autoconf.texi index dea85e4a..9f05cee8 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -14888,29 +14888,53 @@ with their modern implementation. Autoconf provides a simple means to obsolete a macro. @anchor{AU_DEFUN} -@defmac AU_DEFUN (@var{old-macro}, @var{implementation}, @ovar{message}) +@defmac AU_DEFUN (@var{old-macro}, @var{implementation}, @ovar{message}, @ovar{silent}) @auindex{DEFUN} -Define @var{old-macro} as @var{implementation}. The only difference -with @code{AC_DEFUN} is that the user is warned that -@var{old-macro} is now obsolete. - -If she then uses @command{autoupdate}, the call to @var{old-macro} is -replaced by the modern @var{implementation}. @var{message} should -include information on what to do after running @command{autoupdate}; -@command{autoupdate} prints it as a warning, and includes it -in the updated @file{configure.ac} file. +Define @var{old-macro} as @var{implementation}, just like +@code{AC_DEFUN}, but also declare @var{old-macro} to be obsolete. +When @command{autoupdate} is run, occurrences of @var{old-macro} will +be replaced by the text of @var{implementation} in the updated +@file{configure.ac} file. + +If a simple textual replacement is not enough to finish the job of +updating a @file{configure.ac} to modern style, provide instructions for +whatever additional manual work is required as @var{message}. These +instructions will be printed by @command{autoupdate}, and embedded in the +updated @file{configure.ac} file, next to the text of @var{implementation}. + +Normally, @command{autoconf} will also issue a warning (in the +``obsolete'' category) when it expands @var{old-macro}. This warning +does not include @var{message}; it only advises the maintainer to run +@command{autoupdate}. If it is inappropriate to issue this warning, set +the @var{silent} argument to the word @code{silent}. One might want to +use a silent @code{AU_DEFUN} when @var{old-macro} is used in a +widely-distributed third-party macro. If that macro's maintainers are +aware of the need to update their code, it's unnecessary to nag all +of the transitive users of @var{old-macro} as well. This capability +was added to @code{AU_DEFUN} in Autoconf 2.70; older versions of +autoconf will ignore the @var{silent} argument and issue the warning +anyway. + +@strong{Caution:} If @var{implementation} contains M4 or M4sugar macros, +they will be evaluated when @command{autoupdate} is run, not emitted +verbatim like the rest of @var{implementation}. This cannot be avoided +with extra quotation, because then @var{old-macro} will not work when +it is called normally. See the definition of @code{AC_FOREACH} in +@file{general.m4} for a workaround. +@end defmac + +@defmac AU_ALIAS (@var{old-name}, @var{new-name}, @ovar{silent}) +@auindex{ALIAS} +A shorthand version of @code{AU_DEFUN}, to be used when a macro has +simply been renamed. @command{autoupdate} will replace calls to +@var{old-name} with calls to @var{new-name}, keeping any arguments +intact. No instructions for additional manual work will be printed. -The details of this macro are hairy: if @command{autoconf} encounters an -@code{AU_DEFUN}ed macro, all macros inside its second argument are expanded -as usual. However, when @command{autoupdate} is run, only M4 and M4sugar -macros are expanded here, while all other macros are disabled and -appear literally in the updated @file{configure.ac}. -@end defmac +The @var{silent} argument works the same as the @var{silent} argument +to @code{AU_DEFUN}. It was added to @code{AU_ALIAS} in Autoconf 2.70. -@defmac AU_ALIAS (@var{old-name}, @var{new-name}) -@auindex{ALIAS} -Used if the @var{old-name} is to be replaced by a call to @var{new-macro} -with the same parameters. This happens for example if the macro was renamed. +@strong{Caution:} @code{AU_ALIAS} cannot be used when @var{new-name} is +an M4 or M4sugar macro. See above. @end defmac @node Coding Style diff --git a/lib/autoconf/autoupdate.m4 b/lib/autoconf/autoupdate.m4 index 109d8949..a3e13a69 100644 --- a/lib/autoconf/autoupdate.m4 +++ b/lib/autoconf/autoupdate.m4 @@ -36,20 +36,27 @@ # AU_DEFINE(NAME, CODE) # --------------------- -# Define the macro NAME so that it expand to CODE only when +# Define the macro NAME so that it expands to CODE only when # autoupdate is running. This is achieved with traces in # autoupdate itself, so this macro expands to nothing. # m4_define([AU_DEFINE], []) -# AU_DEFUN(NAME, NEW-CODE, [MESSAGE]) +# AU_DEFUN(NAME, NEW-CODE, [MESSAGE], [SILENT]) # ----------------------------------- -# Declare that the macro NAME is now obsoleted, and should be replaced -# by NEW-CODE. Tell the user she should run autoupdate, and when -# autoupdate is run, emit MESSAGE as a warning and include it in -# the updated configure.ac file. +# Define NAME as a macro whose expansion is NEW-CODE, just like +# AC_DEFUN, but also declare NAME as obsolete. When autoupdate +# is run, occurrences of NAME will be replaced with NEW-CODE in +# the updated configure.ac. # -# Also define NAME as a macro which code is NEW-CODE. +# If MESSAGE is not empty, it should be instructions for manual edits +# to configure.ac that are required to finish the job of replacing NAME. +# autoupdate will print MESSAGE, and [m4_warn([obsolete], [MESSAGE])] +# will be placed next to NEW-CODE in the updated configure.ac. +# +# SILENT must be either empty or the word "silent". If it is empty, +# *autoconf* will issue a generic obsolete-category warning when NAME +# is expanded, telling the maintainer to run autoupdate. # # This allows sharing the same code for both supporting obsoleted macros, # and to update a configure.ac. @@ -62,8 +69,8 @@ m4_define([AU_DEFUN], # unexpanded into the updated configure.ac. AU_DEFINE([$1], [m4_ifval([$3], [_au_warn_$1([$3])[m4_warn([obsolete], -[$3])dnl] -])dnl +[$3])dnl +]])dnl $2]) # This is an auxiliary macro that is also run when @@ -76,22 +83,28 @@ AU_DEFINE([_au_warn_$1], m4_define([_au_warn_$1], [])]) # Finally, this is the expansion that is picked up by -# autoconf. It tells the user to run autoupdate, and -# then outputs the replacement expansion. We do not care -# about autoupdate's warning because that contains -# information on what to do *after* running autoupdate. -AC_DEFUN([$1], +# autoconf, causing NAME to expand to NEW-CODE, plus +# (if SILENT is not "silent") a m4_warning telling the +# maintainer to run autoupdate. We don't issue MESSAGE +# from autoconf, because that's instructions for what +# to do *after* running autoupdate. +m4_case([$4], + [silent], [AC_DEFUN([$1], [$2])], + [], [AC_DEFUN([$1], [m4_warn([obsolete], [The macro `$1' is obsolete. You should run autoupdate.])dnl -$2])]) +$2])], + [m4_fatal([SILENT argument to `$0' must be either empty or `silent'])]dnl +)]) -# AU_ALIAS(OLD-NAME, NEW-NAME) +# AU_ALIAS(OLD-NAME, NEW-NAME, [SILENT]) # ---------------------------- # The OLD-NAME is no longer used, just use NEW-NAME instead. There is # little difference with using AU_DEFUN but the fact there is little # interest in running the test suite on both OLD-NAME and NEW-NAME. # This macro makes it possible to distinguish such cases. +# The SILENT argument works the same as for AU_DEFUN. # # Do not use `defn' since then autoupdate would replace an old macro # call with the new macro body instead of the new macro call. @@ -102,7 +115,7 @@ $2])]) # matters with poorly written macros which test for $# = 0. # m4_define([AU_ALIAS], -[AU_DEFUN([$1], _AU_ALIAS_BODY([$], [$2]))]) +[AU_DEFUN([$1], _AU_ALIAS_BODY([$], [$2]), [], [$4])]) # The body for the AU_DEFUN above should look like: # [m4_if($#, 0, [NEW-NAME], [NEW-NAME($@)])] diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index de5633d8..eaa1d91b 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -2324,10 +2324,14 @@ m4_append_uniq([_AC_SUBST_FILES], [$1], [ # The double definitions are necessary because autoupdate expands m4_ # macros, so we have to double-quote the replacements, but then they # won't work in a normal autoconf run. -AU_DEFUN([AC_DIAGNOSE], [[m4_warn($@)]]) -AC_DEFUN([AC_DIAGNOSE], [m4_warn($@)dnl -m4_warn([obsolete], [The macro `$0' is obsolete. -You should run autoupdate.])]) + +# 2020-10-06 / autoconf 2.70: Widely used third-party macros +# (among others, from automake, libtool, and gettext) use AC_DIAGNOSE, +# so we temporarily don't issue an obsoletion warning for it. +# Revisit after third parties have had a chance to update their macros +# and make releases. +AU_DEFUN([AC_DIAGNOSE], [[m4_warn($@)]], [], [silent]) +AC_DEFUN([AC_DIAGNOSE], [m4_warn($@)]) AU_DEFUN([AC_FATAL], [[m4_fatal($@)]]) AC_DEFUN([AC_FATAL], [m4_fatal($@)dnl |