From b6ef3cc579256779b23f8b707d906cc7d3fb941d Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 13 Sep 2007 03:21:18 +0000 Subject: [PATCH] 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@&t@_version_compare): New test. Reported by Bruno Haible. --- ChangeLog | 13 +++++++++ NEWS | 9 +++++- doc/autoconf.texi | 61 +++++++++++++++++++++++++++++++++++++++++ lib/m4sugar/Makefile.am | 4 +-- lib/m4sugar/Makefile.in | 4 +-- lib/m4sugar/m4sugar.m4 | 13 +++++++-- tests/m4sugar.at | 41 +++++++++++++++++++++++---- 7 files changed, 133 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index d54ecf43..bd41707b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2007-09-12 Eric Blake + 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@&t@_version_compare): New test. + Reported by Bruno Haible. + * doc/autoconf.texi (Generic Compiler Characteristics): Add missing index entries. diff --git a/NEWS b/NEWS index ad478471..1b8e2483 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/doc/autoconf.texi b/doc/autoconf.texi index e11d33d6..52faf505 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -10050,6 +10050,14 @@ This macro corresponds to @code{m4exit}. This macro corresponds to @code{ifelse}. @end defmac +@defmac m4_ifndef (@var{macro}, @var{if-not-defined}, @ovar{if-defined}) +@msindex{ifndef} +This is shorthand for: +@example +m4_ifdef([@var{macro}], [@var{if-defined}], [@var{if-not-defined}]) +@end example +@end 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 grow strings, and @code{m4_append_uniq} to grow strings without duplicating substrings. @end defmac +@defmac m4_version_compare (@var{version-1}, @var{version-2}) +@msindex{version_compare} +Introduced in autoconf 2.53. Compare the version strings +@var{version-1} and @var{version-2}, and expand to @samp{-1} if +@var{version-1} is smaller, @samp{0} if they are the same, or @samp{1} +@var{version-2} 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. + +@example +m4_version_compare([1.1], [2.0]) +@result{}-1 +m4_version_compare([2.0b], [2.0a]) +@result{}1 +m4_version_compare([1.1.1], [1.1.1a]) +@result{}-1 +m4_version_compare([1.2], [1.1.1a]) +@result{}1 +m4_version_compare([1.0], [1]) +@result{}0 +@end example +@end defmac + +@defmac m4_AUTOCONF_VERSION +@defmacx m4_PACKAGE_VERSION +@msindex{AUTOCONF_VERSION} +@msindex{PACKAGE_VERSION} +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: + +@example +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])]) +@end example +@end defmac @node Forbidden Patterns diff --git a/lib/m4sugar/Makefile.am b/lib/m4sugar/Makefile.am index 691113bd..c9832860 100644 --- a/lib/m4sugar/Makefile.am +++ b/lib/m4sugar/Makefile.am @@ -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)])'; \ diff --git a/lib/m4sugar/Makefile.in b/lib/m4sugar/Makefile.in index 4864e205..e691e724 100644 --- a/lib/m4sugar/Makefile.in +++ b/lib/m4sugar/Makefile.in @@ -16,7 +16,7 @@ # 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 @@ -500,7 +500,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)])'; \ diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4 index 0e34d447..4574a77a 100644 --- a/lib/m4sugar/m4sugar.m4 +++ b/lib/m4sugar/m4sugar.m4 @@ -3,8 +3,8 @@ divert(-1)# -*- Autoconf -*- # 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. diff --git a/tests/m4sugar.at b/tests/m4sugar.at index 395e1b1f..6e3f1059 100644 --- a/tests/m4sugar.at +++ b/tests/m4sugar.at @@ -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@&t@_require: 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@&t@_version_compare]) + +# 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. ## ## ------------------------------ ## -- 2.47.2