From: Alexandre Duret-Lutz Date: Sun, 31 Aug 2003 21:15:57 +0000 (+0000) Subject: * aclocal.in (scan_file): Warn about underquoted AC_DEFUN. X-Git-Tag: Release-1-7b~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d39793a3d35375fb9c15be17741d6b6d31d01a06;p=thirdparty%2Fautomake.git * aclocal.in (scan_file): Warn about underquoted AC_DEFUN. ($underquoted_manual_once): New variable. * automake.texi (Extending aclocal): Document this. --- diff --git a/ChangeLog b/ChangeLog index a025756fa..981f73c7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-08-31 Alexandre Duret-Lutz + + * aclocal.in (scan_file): Warn about underquoted AC_DEFUN. + ($underquoted_manual_once): New variable. + * automake.texi (Extending aclocal): Document this. + 2003-08-29 Alexandre Duret-Lutz * aclocal.in (@file_order): New variable, to make sure diff --git a/aclocal.in b/aclocal.in index b134cab25..3454e0178 100644 --- a/aclocal.in +++ b/aclocal.in @@ -426,6 +426,9 @@ sub add_file ($) } } +# Point to the documentation for underquoted AC_DEFUN only once. +my $underquoted_manual_once = 0; + # Scan a single M4 file. Return contents. sub scan_file ($) { @@ -444,6 +447,15 @@ sub scan_file ($) if (/$ac_defun_rx/) { + if (! defined $1) + { + print STDERR "$file:$.: underquoted definition of $2\n"; + print STDERR "$file:$.: run info '(automake)Extending aclocal'\n" + . "or see http://sources.redhat.com/automake/" + . "automake.html#Extending%20aclocal\n" + unless $underquoted_manual_once; + $underquoted_manual_once = 1; + } if (! defined $map{$1 || $2}) { print STDERR "aclocal: found macro $1 in $file: $.\n" diff --git a/automake.texi b/automake.texi index 627e626d0..ec06601bc 100644 --- a/automake.texi +++ b/automake.texi @@ -1778,12 +1778,6 @@ library supplies a macro @code{AM_GNU_GETTEXT} which should be used by any package using @command{gettext}. When the library is installed, it installs this macro so that @command{aclocal} will find it. -A file of macros should be a series of @code{AC_DEFUN}'s. The -@code{aclocal} programs also understands @code{AC_REQUIRE}, so it is -safe to put each macro in a separate file. @xref{Prerequisite Macros, , -, autoconf, The Autoconf Manual}, and @ref{Macro Definitions, , , -autoconf, The Autoconf Manual}. - A macro file's name should end in @file{.m4}. Such files should be installed in @file{$(datadir)/aclocal}. This is as simple as writing: @@ -1792,6 +1786,64 @@ aclocaldir = $(datadir)/aclocal aclocal_DATA = mymacro.m4 myothermacro.m4 @end example +A file of macros should be a series of properly quoted +@code{AC_DEFUN}'s (@pxref{Macro Definitions, , , autoconf, The +Autoconf Manual}). The @command{aclocal} programs also understands +@code{AC_REQUIRE} (@pxref{Prerequisite Macros, , , autoconf, The +Autoconf Manual}), so it is safe to put each macro in a separate file. +Each file should have no side effects but macro definitions. +Especially, any call to @code{AC_PREREQ} should be done inside the +defined macro, not at the beginning of the file. + +@cindex underquoted AC_DEFUN +@cvindex AC_DEFUN +@cvindex AC_PREREQ + +Starting with Automake 1.8, @command{aclocal} will warn about all +underquoted calls to @code{AC_DEFUN}. We realize this will annoy a +lot of people, because @command{aclocal} was not so strict in the past +and many third party macros are underquoted; and we have to apologize +for this temporary inconvenience. The reason we have to be stricter +is that a future implementation of @command{aclocal} (@pxref{Future of +aclocal}) will have to temporary include all these third party +@file{.m4} files, maybe several times, even those which are not +actually needed. Doing so should alleviate many problem of the +current implementation, however it requires a stricter style from the +macro authors. Hopefully it is easy to revise the existing macros. +For instance +@example +# bad style +AC_PREREQ(2.57) +AC_DEFUN(AX_FOOBAR, +[AC_REQUIRE([AX_SOMETHING])dnl +AX_FOO +AX_BAR +]) +@end example +@noindent +should be rewritten as +@example +AC_DEFUN([AX_FOOBAR], +[AC_PREREQ(2.57)dnl +AC_REQUIRE([AX_SOMETHING])dnl +AX_FOO +AX_BAR +]) +@end example + +Wrapping the @code{AC_PREREQ} call inside the macro ensures that +Autoconf 2.57 will not be required if @code{AX_FOOBAR} is not actually +used. Most importantly, quoting the first argument of @code{AC_DEFUN} +allows the macro to be redefined or included twice (otherwise this +first argument would be expansed during the second definition). + +If you have been directed here by the @command{aclocal} diagnostic but +are not the maintainer of the implicated macro, you will want to +contact the maintainer of that macro. Please make sure you have the +last version of the macro and that the problem already hasn't been +reported before doing so: people tend to work faster when they aren't +flooded by mails. + Another situation where @command{aclocal} is commonly used is to manage macros which are used locally by the package, @ref{Local Macros}. @@ -6582,4 +6634,4 @@ Note that the renaming of objects is also affected by the @c LocalWords: DSOMEFLAG DVERSION automake Lutz insertcopying versioning FAQ @c LocalWords: LTLIBOBJ Libtool's libtool's libltdl dlopening itutions libbar @c LocalWords: WANTEDLIBS libhello sublibraries libtop libsub dlopened Ratfor -@c LocalWords: mymodule timestamps timestamp +@c LocalWords: mymodule timestamps timestamp underquoted diff --git a/stamp-vti b/stamp-vti index d49c9a2d8..3ab03a68b 100644 --- a/stamp-vti +++ b/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 24 August 2003 +@set UPDATED 31 August 2003 @set UPDATED-MONTH August 2003 @set EDITION 1.7a @set VERSION 1.7a diff --git a/version.texi b/version.texi index d49c9a2d8..3ab03a68b 100644 --- a/version.texi +++ b/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 24 August 2003 +@set UPDATED 31 August 2003 @set UPDATED-MONTH August 2003 @set EDITION 1.7a @set VERSION 1.7a