]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Publish m4_ifndef, m4_version_compare, m4_AUTOCONF_VERSION.
authorEric Blake <ebb9@byu.net>
Thu, 13 Sep 2007 03:21:18 +0000 (03:21 +0000)
committerEric Blake <ebb9@byu.net>
Thu, 13 Sep 2007 03:21:18 +0000 (03:21 +0000)
* 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
NEWS
doc/autoconf.texi
lib/m4sugar/Makefile.am
lib/m4sugar/Makefile.in
lib/m4sugar/m4sugar.m4
tests/m4sugar.at

index d54ecf43040e2396888602e286ca688437a193e9..bd41707beb156ee239da924e61ea34ec30c4452f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2007-09-12  Eric Blake  <ebb9@byu.net>
 
+       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 ad47847154b6224f6834e9463569b5bfba817113..1b8e24835cb568741d2716de5f51a98ae215b1b0 100644 (file)
--- 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
index e11d33d6816b75eda5c5a994601bb178b0d695e6..52faf505256a8496d7dba3ab459fca99e62642d8 100644 (file)
@@ -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
index 691113bda0c22bff4fcdc766cdd31081360fb06a..c983286003d11a5f6ec6ea9f4d1ff05874647c1e 100644 (file)
@@ -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 4864e20524ddc71c74a083ccc826a648f348fc54..e691e724dc25efa7aa7f827942765e75c67f2b3e 100644 (file)
@@ -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)])'; \
index 0e34d4474065c23247532ed100a629b9e55cfcab..4574a77a1d31b314777c463bcf22e24d022f04b8 100644 (file)
@@ -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.
index 395e1b1f46e17c802d15add14f0c0d140d08c5e0..6e3f1059f6a7fef0fd225b29e5ca124dff73d418 100644 (file)
@@ -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.  ##
 ## ------------------------------ ##