[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: expose m4_PACKAGE_VERSION,m4_version_compare
From: |
Eric Blake |
Subject: |
Re: expose m4_PACKAGE_VERSION,m4_version_compare |
Date: |
Thu, 13 Sep 2007 03:15:51 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Eric Blake <ebb9 <at> byu.net> writes:
>
> Benoit SIGOURE <tsuna <at> lrde.epita.fr> writes:
>
> >
> > It looks great. The name m4_PACKAGE_VERSION is somewhat misleading
> > however (as I understand it, it contains the current version of
> > autoconf right? So why not name it like m4_AUTOCONF_VERSION or
> > whatever?).
>
> Good point. There are other m4_PACKAGE_* macros that I did not document;
> basically, they all perform a hard-wired mapping to the contents of the
> PACKAGE_* macros from autoconf's configure script. I like your idea of
making
> the public macro have a more obvious name. I'll rework my patch accordingly
> (as in, add m4_AUTOCONF_VERSION as the new documented alias, and leave
> m4_PACKAGE_VERSION available, but undocumented).
It turns out that even Automake 1.10 uses m4_PACKAGE_VERSION, so I don't feel
good obsoleting it just yet (at least, not until after one release of autoconf
with both names, and a release of automake that prefers the newer name when
available). That, and obsoleting an m4sugar macro is not as simple as
obsoleting a normal autoconf macro, since there is no AU_DEFUN in the m4sugar
level. It would involve something like the trick that lib/autoconf/autoconf.m4
uses for discouraging the name m4_patsubst (users should either use patsubst or
m4_bpatsubst).
So for now, I'm checking in this:
2007-09-12 Eric Blake <address@hidden>
Publish m4_ifndef, m4_version_compare, m4_AUTOCONF_VERSION.
* doc/autoconf.texi (Text processing Macros): Document
m4_version_compare, m4_AUTOCONF_VERSION, m4_PACKAGE_VERSION.
(Redefined M4 Macros): Document m4_ifndef.
* lib/m4sugar/m4sugar.m4 (m4_AUTOCONF_VERSION): New macro; we
can't obsolete m4_PACKAGE_VERSION at this time since Autoconf 1.10
used it while it was undocumented.
* NEWS: Document this change.
* lib/m4sugar/Makefile.am (version.m4): Update copyright dates.
* lib/m4sugar/Makefile.in: Regenerate.
* tests/m4sugar.at (m4@&address@hidden): New test.
Reported by Bruno Haible.
Index: NEWS
===================================================================
RCS file: /sources/autoconf/autoconf/NEWS,v
retrieving revision 1.437
diff -u -p -r1.437 NEWS
--- NEWS 11 Sep 2007 17:13:13 -0000 1.437
+++ NEWS 13 Sep 2007 03:09:27 -0000
@@ -8,7 +8,7 @@ GNU Autoconf NEWS - User visible changes
generated by autoconf under the license of your own program.
FIXME - revisit this line once exception clause is finalized.
-** New macros AC_OPENMP, AC_PATH_PROGS_FEATURE_CHECK.
+** New Autoconf macros AC_OPENMP, AC_PATH_PROGS_FEATURE_CHECK.
** AC_C_BIGENDIAN now supports universal binaries a la Mac OS X.
@@ -47,6 +47,13 @@ GNU Autoconf NEWS - User visible changes
Autoconf and Automake. GNU M4 1.4.8 or later is recommended. The
configure search for a working M4 is improved.
+** New m4sugar macro m4_AUTOCONF_VERSION. Also, document the m4sugar macros
+ m4_ifndef, m4_version_compare, and m4_PACKAGE_VERSION (available
+ without documentation since at least autoconf 2.53), in part so
+ that packages can make decisions based on the current version of
+ autoconf used to evaluate a given configure.ac. The name
+ m4_PACKAGE_VERSION may be marked obsolescent in a future release.
+
** Warnings are now generated by default when an installer invokes
'configure' with an unknown --enable-* or --with-* option.
These warnings can be disabled with the new AC_DISABLE_OPTION_CHECKING
Index: lib/m4sugar/m4sugar.m4
===================================================================
RCS file: /sources/autoconf/autoconf/lib/m4sugar/m4sugar.m4,v
retrieving revision 2.102
diff -u -p -r2.102 m4sugar.m4
--- lib/m4sugar/m4sugar.m4 20 Jul 2007 23:11:54 -0000 2.102
+++ lib/m4sugar/m4sugar.m4 13 Sep 2007 03:09:27 -0000
@@ -3,8 +3,8 @@ divert(-1)#
# Base M4 layer.
# Requires GNU M4.
#
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
-# Foundation, Inc.
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free
+# Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1725,6 +1725,15 @@ m4_define([m4_version_compare],
m4_include([m4sugar/version.m4])
+# m4_AUTOCONF_VERSION
+# -------------------
+# A nicer synonym for the name m4_PACKAGE_VERSION. However, since
+# automake 1.10 decided to use m4_PACKAGE_VERSION while it was still
+# undocumented, it will be a while before we can try to obsolete the
+# confusing name.
+m4_copy([m4_PACKAGE_VERSION], [m4_AUTOCONF_VERSION])
+
+
# m4_version_prereq(VERSION, [IF-OK], [IF-NOT = FAIL])
# ----------------------------------------------------
# Check this Autoconf version against VERSION.
Index: lib/m4sugar/Makefile.am
===================================================================
RCS file: /sources/autoconf/autoconf/lib/m4sugar/Makefile.am,v
retrieving revision 1.16
diff -u -p -r1.16 Makefile.am
--- lib/m4sugar/Makefile.am 20 Jul 2007 23:11:53 -0000 1.16
+++ lib/m4sugar/Makefile.am 13 Sep 2007 03:09:27 -0000
@@ -1,6 +1,6 @@
# Make Autoconf library for M4sugar.
-# Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2006, 2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@ version.m4: $(top_srcdir)/configure.ac
{ \
echo '# This file is part of -*- Autoconf -*-.'; \
echo '# Version of Autoconf.'; \
- echo '# Copyright (C) 1999, 2000, 2001, 2002'; \
+ echo '# Copyright (C) 1999, 2000, 2001, 2002, 2006, 2007'; \
echo '# Free Software Foundation, Inc.'; \
echo ;\
echo 'm4_define([m4_PACKAGE_NAME], [$(PACKAGE_NAME)])'; \
Index: doc/autoconf.texi
===================================================================
RCS file: /sources/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1173
diff -u -p -r1.1173 autoconf.texi
--- doc/autoconf.texi 13 Sep 2007 02:35:41 -0000 1.1173
+++ doc/autoconf.texi 13 Sep 2007 03:09:27 -0000
@@ -10050,6 +10050,14 @@ This macro corresponds to @code{m4exit}.
This macro corresponds to @code{ifelse}.
@end defmac
address@hidden m4_ifndef (@var{macro}, @var{if-not-defined}, @ovar{if-defined})
address@hidden
+This is shorthand for:
address@hidden
+m4_ifdef(address@hidden, address@hidden, address@hidden)
address@hidden example
address@hidden defmac
+
@defmac m4_include (@var{file})
@defmacx m4_sinclude (@var{file})
@msindex{include}
@@ -10270,6 +10278,59 @@ added. @code{m4_append} can be used to
@code{m4_append_uniq} to grow strings without duplicating substrings.
@end defmac
address@hidden m4_version_compare (@var{version-1}, @var{version-2})
address@hidden
+Introduced in autoconf 2.53. Compare the version strings
address@hidden and @var{version-2}, and expand to @samp{-1} if
address@hidden is smaller, @samp{0} if they are the same, or @samp{1}
address@hidden is smaller. Version strings must be a list of elements
+separated by @samp{.}, where each element is a number along with an
+optional letter. The comparison stops at the leftmost element that
+contains a difference, although a 0 element compares equal to a missing
+element.
+
address@hidden
+m4_version_compare([1.1], [2.0])
address@hidden
+m4_version_compare([2.0b], [2.0a])
address@hidden
+m4_version_compare([1.1.1], [1.1.1a])
address@hidden
+m4_version_compare([1.2], [1.1.1a])
address@hidden
+m4_version_compare([1.0], [1])
address@hidden
address@hidden example
address@hidden defmac
+
address@hidden m4_AUTOCONF_VERSION
address@hidden m4_PACKAGE_VERSION
address@hidden
address@hidden
+These macros identify the version of Autoconf that is currently parsing
+the input file, in a format suitable for @code{m4_version_compare}. The
+name @code{m4_AUTOCONF_VERSION} was introduced in Autoconf 2.62. The
+synonym @code{m4_PACKAGE_VERSION} existed since Autoconf 2.53, but was
+undocumented for many years because it is not named very well, and it
+may be withdrawn in a future release. One use of these macros is for
+writing conditional fallbacks based on when a feature was added to
+Autoconf, rather than using @code{AC_PREREQ} to require the newer
+version of Autoconf.
+
+For an example, @code{AC_USE_SYSTEM_EXTENSIONS} was only added in
+Autoconf 2.60 (@pxref{AC_USE_SYSTEM_EXTENSIONS}). A @file{configure.ac}
+designed to work even with Autoconf 2.59 can do the following in a
+compatibility section, then use the newer macros elsewhere without
+worrying about Autoconf versions:
+
address@hidden
+m4_ifndef([m4_AUTOCONF_VERSION],
+ [m4_define([m4_AUTOCONF_VERSION],
+ m4_defn([m4_PACKAGE_VERSION]))])
+m4_if(m4_version_compare(m4_AUTOCONF_VERSION, [2.60]), [-1],
+ [AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], [AC_GNU_SOURCE])])
address@hidden example
address@hidden defmac
@node Forbidden Patterns
Index: tests/m4sugar.at
===================================================================
RCS file: /sources/autoconf/autoconf/tests/m4sugar.at,v
retrieving revision 1.34
diff -u -p -r1.34 m4sugar.at
--- tests/m4sugar.at 20 Jul 2007 23:11:54 -0000 1.34
+++ tests/m4sugar.at 13 Sep 2007 03:09:27 -0000
@@ -2,7 +2,7 @@
AT_BANNER([M4sugar.])
-# Copyright (C) 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002, 2005, 2006, 2007 Free Software Foundation,
Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -117,10 +117,6 @@ AT_CLEANUP
AT_SETUP([m4@&address@hidden: circular dependencies])
-# m4_text_wrap is used to display the help strings. Also, check that
-# commas are not swallowed. This can easily happen because of
-# m4-listification.
-
AT_DATA_M4SUGAR([script.4s],
[[m4_defun([foo], [m4_require([bar])])
@@ -191,6 +187,41 @@ AT_CHECK_M4SUGAR([-o-], 0, [expout])
AT_CLEANUP
+## -------------------- ##
+## m4_version_compare. ##
+## -------------------- ##
+
+AT_SETUP([m4@&address@hidden)
+
+# In addition to version checks, also check m4_AUTOCONF_VERSION, added
+# for autoconf 2.62.
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_version_compare([1.1], [2.0])
+m4_version_compare([2.0b], [2.0a])
+m4_version_compare([2.0z], [2.0y])
+m4_version_compare([1.1.1], [1.1.1a])
+m4_version_compare([1.2], [1.1.1a])
+m4_version_compare([1.0], [1])
+m4_version_compare([1.0a], [1.0a])
+m4_version_compare([1.1a], [1.1a.1])
+m4_version_compare(m4_AUTOCONF_VERSION, [2.61])
+m4_version_compare(m4_defn([m4_AUTOCONF_VERSION]), [2.61])
+]],
+[[-1
+1
+1
+-1
+1
+0
+0
+-1
+1
+1
+]])
+
+AT_CLEANUP
+
## ------------------------------ ##
## Standard regular expressions. ##
## ------------------------------ ##
- expose m4_PACKAGE_VERSION,m4_version_compare, Eric Blake, 2007/09/12
- Re: expose m4_PACKAGE_VERSION,m4_version_compare, Benoit SIGOURE, 2007/09/12
- Re: expose m4_PACKAGE_VERSION,m4_version_compare, Eric Blake, 2007/09/12
- Re: expose m4_PACKAGE_VERSION,m4_version_compare, Benoit SIGOURE, 2007/09/12
- Re: expose m4_PACKAGE_VERSION,m4_version_compare,
Eric Blake <=
- Re: expose m4_PACKAGE_VERSION,m4_version_compare, Paolo Bonzini, 2007/09/13
- Re: expose m4_PACKAGE_VERSION,m4_version_compare, Eric Blake, 2007/09/13
- Re: expose m4_PACKAGE_VERSION,m4_version_compare, Eric Blake, 2007/09/15
- Re: expose m4_PACKAGE_VERSION,m4_version_compare, Benoit SIGOURE, 2007/09/13