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.
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.
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
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}
@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
# 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
{ \
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)])'; \
# 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
{ \
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)])'; \
# 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
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.
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
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])])
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. ##
## ------------------------------ ##