[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_DIAGNOSE not obsolete, please

From: Zack Weinberg
Subject: Re: AC_DIAGNOSE not obsolete, please
Date: Tue, 6 Oct 2020 13:31:58 -0400

On Mon, Oct 5, 2020 at 5:40 PM Karl Berry <> wrote:
> Zack and all - Thien-Thi (cc'd) just reported two failures in automake
> make check with autoconf-2.69c ( The critical
> message appears to be:
>     ./lib/autoconf/general.m4:2328: AC_DIAGNOSE is expanded from...
>     /home/ttn/local/.b/automake-1.16.2/m4/init.m4:29: AM_INIT_AUTOMAKE is 
> expanded from...
> the top level
> warning: The macro `AC_DIAGNOSE' is obsolete.
> Since AM_INIT_AUTOMAKE calls AC_DIAGNOSE, can you please not make
> it obsolete? Otherwise upgrading will be a nightmare for everyone.

Seems reasonable.  What do you think of the patches below?  The first
set, applicable to autoconf, makes it so autoupdate will still replace
AC_DIAGNOSE with m4_warn, but autoconf *won't* complain about
AC_DIAGNOSE being obsolete.  This is handled with a new argument to
AU_DEFUN and AU_ALIAS, which can be either empty, for the historical
behavior of warning and updating, or the word "silent" for just update
with no warnings from autoconf.  Autoconf 2.69 and previous will
ignore the new argument, so this is safe to use in third-party macros
if desired.

The second set, applicable to automake, is additional tweaks I needed
to make to the automake testsuite to get it to pass 100%.  It seems
that both autoconf and automake have become pickier about incomplete
configure scripts.

(m4_warn was already available in Autoconf 2.50, by the way.)


--- autoconf patches ---
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index dea85e4a..07ab9763 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -14888,29 +14888,52 @@ Obsoleting Macros
 Autoconf provides a simple means to obsolete a macro.

-@defmac AU_DEFUN (@var{old-macro}, @var{implementation}, @ovar{message})
+@defmac AU_DEFUN (@var{old-macro}, @var{implementation},
@ovar{message}, @ovar{silent})
-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.
+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{} file.

-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{} file.
+If a simple textual replacement is not enough to finish the job of
+updating a @file{} 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{} file, next to the text of @var{implementation}.

-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{}.
+Normally, @command{autoconf} will also issue a warning (in the
+``obsolete'' category) when it expands @code{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 @code{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 @code{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
+@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}.  If this is wrong, you
+will need to work around it---see for instance the definition
+of @code{AC_FOREACH} in @file{general.m4}.
 @end defmac

-@defmac AU_ALIAS (@var{old-name}, @var{new-name})
+@defmac AU_ALIAS (@var{old-name}, @var{new-name}, @ovar{silent})
-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.
+A shorthand version of @code{AU_DEFUN}, to be used when a macro has
+simply been renamed.  @command{autoupdate} will replace @var{old-name}
+with a call to @var{new-macro}, with the same parameters.  No instructions
+for additional manual work will be printed.
+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.
+@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 @@

 # ---------------------
-# 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], [])

 # -----------------------------------
-# 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 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
-# Also define NAME as a macro which code is NEW-CODE.
+# If MESSAGE is not empty, it should be instructions for manual edits
+# to 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
+# 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
@@ -62,8 +69,8 @@ m4_define([AU_DEFUN],
 # unexpanded into the updated
 [m4_ifval([$3], [_au_warn_$1([$3])[m4_warn([obsolete],

 # 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.
+# 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.
+  [silent], [AC_DEFUN([$1], [$2])],
+  [],       [AC_DEFUN([$1],
      [m4_warn([obsolete], [The macro `$1' is obsolete.
 You should run autoupdate.])dnl
+  [m4_fatal([SILENT argument to `$0' must be either empty or `silent'])]dnl

 # ----------------------------
 # 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.
-[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..1f9df605 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2324,10 +2324,13 @@ 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 / automake 1.16: Key Automake macros use
+# AC_DIAGNOSE, so we temporarily don't issue an obsoletion warning for
+# that one.  Revisit after automake has had a chance to update its
+# macros and make a release.
+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

--- automake patches ---
diff --git a/t/ b/t/
index c3d49d502..ec9efe098 100644
--- a/t/
+++ b/t/
@@ -25,6 +25,7 @@ cat > <<'END'
 AM_INIT_AUTOMAKE([twoargs], [1.0])

diff --git a/t/ b/t/
index 337ae301f..a356bf1f1 100644
--- a/t/
+++ b/t/
@@ -19,12 +19,19 @@


-echo AM_PROG_MKDIR_P >>
+cat > <<'END'
+AC_INIT([test], [1.0])
 : >

 grep_err ()
-  loc='^'
+  loc='^'
   grep "$loc.*AM_PROG_MKDIR_P.*deprecated" stderr
   grep "$loc.* use .*AC_PROG_MKDIR_P" stderr
   grep "$loc.* use '\$(MKDIR_P)' instead of '\$(mkdir_p)'.*Makefile" stderr

reply via email to

[Prev in Thread] Current Thread [Next in Thread]