autoconf-patches
[Top][All Lists]
Advanced

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

Re: Be done with AU_DEFUN's third argument


From: Bonzini
Subject: Re: Be done with AU_DEFUN's third argument
Date: Mon, 2 Feb 2004 07:11:50 -0500
User-agent: Mutt/1.3.28i

This one seems quite obvious, so I'll install this tomorrow
if I get no reaction (for example with respect to my English).

Fixing autoupdate's warnings is actually very easy.  The bug
is in macros whose AU_DEFUN third argument includes $0, it
is fixed by expanding the warning in the AU_DEFUN'd macro
instead of expanding it in _au_warn_XXX.  I hope this is
clearer with the new documentation.

Paolo

2004-02-02  Paolo Bonzini  <address@hidden>

        * bin/autoupdate.in: Define __file__ so that warnings
        refer to the correct file.
        * doc/autoconf.texi (AU_DEFUN): Describe more correctly
        the behavior of the third argument.
        * lib/autoconf/autoupdate.m4 (AU_DEFUN): Describe more
        correctly the behavior of the third argument.  Document
        what the three macros that AU_DEFUN defines do.  Fix
        warning message when the third argument includes $0
        (reported by Alexandre Duret-Lutz).

Index: bin/autoupdate.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/autoupdate.in,v
retrieving revision 1.50
diff -u -r1.50 autoupdate.in
--- bin/autoupdate.in   30 Jan 2004 14:21:35 -0000      1.50
+++ bin/autoupdate.in   2 Feb 2004 11:39:49 -0000
@@ -282,6 +282,9 @@
       divert(-1)                                            -*- Autoconf -*-
       changequote([, ])
 
+      # Redefine __file__ to make warnings nicer; $file is replaced below.
+      define([__file__], [$file])
+
       # Move all the builtins into the `_au_' pseudo namespace
       include([m4save.m4])
 
@@ -379,6 +382,7 @@
 EOF
 
     $input_m4 =~ s/^      //mg;
+    $input_m4 =~ s/\$file/$file/g;
 
     # prepared input -- input, but reenables the quote before each AU macro.
     open INPUT_M4, ">$tmp/input.m4"
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.798
diff -u -r1.798 autoconf.texi
--- doc/autoconf.texi   30 Jan 2004 14:21:35 -0000      1.798
+++ doc/autoconf.texi   2 Feb 2004 11:39:53 -0000
@@ -8940,8 +8940,10 @@
 @var{old-macro} is now obsolete.
 
 If she then uses @command{autoupdate}, the call to @var{old-macro} will be
-replaced by the modern @var{implementation}.  @command{autoupdate} will
-then print the additional @var{message}.
+replaced by the modern @var{implementation}.  @var{message} should
+include information on what to do after running @command{autoupdate},
+and @command{autoupdate} will print it as a warning, @emph{and} include
+it in the updated @file{configure.ac} file.
 @end defmac
 
 @node Coding Style
Index: lib/autoconf/autoupdate.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/autoupdate.m4,v
retrieving revision 1.7
diff -u -r1.7 autoupdate.m4
--- lib/autoconf/autoupdate.m4  30 Jan 2004 14:21:36 -0000      1.7
+++ lib/autoconf/autoupdate.m4  2 Feb 2004 11:39:53 -0000
@@ -67,8 +67,9 @@
 # AU_DEFUN(NAME, NEW-CODE, [MESSAGE])
 # -----------------------------------
 # Declare that the macro NAME is now obsoleted, and should be replaced
-# by NEW-CODE.  Tell the user she should run autoupdate, and include
-# the additional MESSAGE.
+# 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.
 #
 # Also define NAME as a macro which code is NEW-CODE.
 #
@@ -76,15 +77,31 @@
 # and to update a configure.ac.
 # See `acobsolete.m4' for a longer description.
 m4_define([AU_DEFUN],
-[AU_DEFINE([$1],
-[m4_ifval([$3], [_au_warn_$1[]AC_DIAGNOSE([obsolete], [$3])d[]nl
+[# This is what autoupdate's m4 run will expand.  It fires
+# the warning (with _au_warn_XXX), outputs it into the
+# updated configure.ac (with AC_DIAGNOSE), and then outputs
+# the replacement expansion.
+AU_DEFINE([$1],
+[m4_ifval([$3], [_au_warn_$1([$3])AC_DIAGNOSE([obsolete], [$3])d[]nl
 ])dnl
 $2])
+
+# This is an auxiliary macro that is also run when
+# autoupdate runs m4.  It simply calls m4_warning, but
+# we need a wrapper so that each warning is emitted only
+# once.  We break the quoting in m4_warning's argument in
+# order to expand this macro's arguments, not AU_DEFUN's.
 AU_DEFINE([_au_warn_$1],
-[m4_warning([$3])dnl
+[m4_warning($][@)dnl
 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],
-          [AC_DIAGNOSE([obsolete], [The macro `$1' is obsolete.
+        [AC_DIAGNOSE([obsolete], [The macro `$1' is obsolete.
 You should run autoupdate.])dnl
 $2])])
 





reply via email to

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