Hi Jim,
* Jim Meyering wrote on Thu, Aug 13, 2009 at 08:29:21AM CEST:
[...]
systems with automake older than 1.11.
On those systems, it's fine to ignore or disable these
two unsupported options.
Yes. Often, automake's rejection of unsupported options is stricter
than it would need to be. Unfortunately, I don't know of a general way
to solve that, as just ignoring (and warning about) them is definitely
not strict enough: some options cause incompatible behavior that may be
desired.
I proposed a configure.ac-modifying solution,
https://www.redhat.com/archives/libguestfs/2009-August/msg00160.html
but it's too ugly.
Can you think of another way?
I think Automake should provide an API to allow users to say if the
Automake version is = X, then expand this configure.ac code. I think
that would be general enough (it could use Automake conditionals to
adjust Makefile.am files, it could check for = X and not = X+1 to
enforce exact versions (or we could just provide a general version
compare function) and it could then call AM_INIT_AUTOMAKE with the
appropriate options). Also, it would be explicit enough for the
developer to be conscious about not using this by accident.
However, it would likely allow fool any tools that directly grepped the
configure.ac files for AM_INIT_AUTOMAKE invocations, instead of using
autom4te --language=Autoconf-without-aclocal-m4 --trace=AM_INIT_AUTOMAKE
and even that would probably not give the right answer then (as
aclocal.m4 contents will be needed in order to provide it).
The initial patch below ought to improve the situation for future
Automake versions (but unfortunately not for past ones). With it,
you will be able to write code like
AM_VERSION_PREREQ([1.12],
[# this code assumes Automake 1.12
AM_INIT_AUTOMAKE([foreign fancy-new-option])],
[# this code does not assume 1.12
AM_INIT_AUTOMAKE([foreign])])
Does that look like a viable approach to people?
Of course, just like m4_version_prereq, it violates the Autoconf
principle that you should test the actual feature you would like to use,
rather than some version number. I don't know how to solve that without
another layer of indirection, which would amount to something you
outline in the URL above. (The other rationale why it may not be so bad
here is that luckily, distros seem to provide pretty much plain upstream
Automake these days, without many patches tacked on and features added,
so that a version number actually retains some meaning.)
What you can do in the meantime to have things work well for you with
git Automake (once that provides AM_VERSION_PREREQ) is something like
m4_ifdef([AM_VERSION_PREREQ],
[ use AM_VERSION_PREREQ like above ... ],
[ backward compat code ... ])
and you could even extend the idea to work back to 1.11 by testing for
some macro that was new in 1.11, such as AM_SILENT_RULES or AM_COND_IF.
However, there is a glitch: in case these macros are defined, i.e., the
version is = 1.11, you have to also actually use them in your
configure.ac, so that not only aclocal (who searches in the
.../share/aclocal-X.Y directory by default) finds them as defined, but
also actually includes their definition into the aclocal.m4 file, so
that a subsequent autoconf (who doesn't search .../share/aclocal-X.Y)
finds them defined, too. Clear?
As an unrelated side note, we don't use @defmac to define our macros,
which can cause bugs when used with @dvar on a @-continued definition
line, in the manual. This should be fixed.
Cheers,
Ralf
New macro AM_VERSION_PREREQ.
* m4/amversion.in (_AM_AUTOMAKE_VERSION): New define.
* m4/prereq.m4 (AM_VERSION_PREREQ): New file, new macro,
with code taken from Autoconf's m4_version_prereq.
* tests/prereq.test: New test.
* tests/Makefile.am: Adjust.
* doc/automake.texi (@dvar): New texinfo macro, taken from
Autoconf.
(Public Macros): Document AM_VERSION_PREREQ.
* NEWS: Update.
Based on suggestion from Jim Meyering.
diff --git a/NEWS b/NEWS
index 7e14ed8..fe11327 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
New in 1.11a:
+* Miscellaneous changes:
+
+ - New macro AM_VERSION_PREREQ to allow expanding different code at M4 run
+time based upon the Automake version used.
+
Bugs fixed in 1.11a:
* Bugs introduced by 1.11:
diff --git a/doc/automake.texi b/doc/automake.texi
index b3f4a76..9a489ef 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -15,6 +15,14 @@
@r...@var{\varname\}@r{]}
@end macro
+...@c @dvar(ARG, DEFAULT)
+...@c ---
+...@c The ARG is an optional argument, defaulting to DEFAULT. To be used
+...@c for macro arguments in their documentation (@defmac).
+...@macro dvar{varname, default}
+...@r{[}@var{\varname\} = @samp{\defaul...@r{]}@c
+...@end macro
+
@copying
This manual is for @acronym{GNU} Automake (version @value{VERSION},
@@ -3896,6 +3904,15 @@