automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] init: warn against obsolete usage of AM_INIT_AUTOMAKE


From: Stefano Lattarini
Subject: [PATCH] init: warn against obsolete usage of AM_INIT_AUTOMAKE
Date: Tue, 1 May 2012 18:11:14 +0200

Support for the two- and three-arguments invocation forms of the
AM_INIT_AUTOMAKE macro, as in:

  AM_INIT_AUTOMAKE($PACKAGE, $VERSION)

or:

  AM_INIT_AUTOMAKE($PACKAGE, $VERSION, NODEFINE)

will be removed in the next major Automake release (1.13).

Such usages have already been deprecated in the documentation
starting from commit v1.11-2015-ge99690a of 23-02-2012 "docs,
news: document planned removal of obsolete macros and features".

We now start giving runtime warnings as well (in the 'obsolete'
category).

* NEWS: Update.
* m4/init.m4 (AM_INIT_AUTOMAKE): Report the two- and three-arguments
form invocation.
* automake.in (scan_autoconf_traces): Likewise.
* doc/automake.texi: Minor adjustments.  Add an @anchor to the
location where it's described how to modernize outdated invocation
of AM_INIT_AUTOMAKE, so that it can be referenced from automake
warning/error messages.
* t/aminit-moreargs-deprecation.sh: New test.
* tests/list-of-tests.mk: Add it.
* tests/ac-output-old.tap: Adjust by calling automake with the
warnings in the 'obsolete' category disabled.
* t/backcompat.test: Likewise.
* t/backcompat3.test: Likewise.
* t/backcompat5.test: Likewise.
* t/backcompat6.test: Likewise.
* t/version.test: Likewise.
* t/version2.test: Likewise.
* t/pr2.test: Modernize style of AC_INIT and AM_INIT_AUTOMAKE
invocations, and use proper m4 quoting.
* t/pr87.test: Likewise.
* t/confsub.test: Likewise.
* t/install2.test: Likewise.

Signed-off-by: Stefano Lattarini <address@hidden>
---

 I will push this in 72 hours.

 Regards,
   Stefano

 NEWS                             |    5 ++++
 automake.in                      |    4 +++
 doc/automake.texi                |    3 ++-
 m4/init.m4                       |    5 +++-
 t/ac-output-old.tap              |    2 ++
 t/aminit-moreargs-deprecation.sh |   51 ++++++++++++++++++++++++++++++++++++++
 t/backcompat.sh                  |    2 +-
 t/backcompat3.sh                 |    2 ++
 t/backcompat5.sh                 |    4 +--
 t/backcompat6.sh                 |    2 +-
 t/confsub.sh                     |    9 +++----
 t/install2.sh                    |   12 +++++----
 t/list-of-tests.mk               |    1 +
 t/pr2.sh                         |    9 +++----
 t/pr87.sh                        |   14 +++++++----
 t/version.sh                     |    2 +-
 t/version2.sh                    |    2 +-
 17 files changed, 100 insertions(+), 29 deletions(-)
 create mode 100755 t/aminit-moreargs-deprecation.sh

diff --git a/NEWS b/NEWS
index b415be6..420d2a4 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ New in 1.12.1:
 
 * Deprecated obsolescent features:
 
+  - Use of the long-deprecated two- and three-arguments invocation forms
+    of the AM_INIT_AUTOMAKE macro now elicits a warning in the 'obsolete'
+    category.  Starting from the next major Automake release (1.13), such
+    usages won't be allowed anymore.
+
   - The long-obsolete (since 1.10) automake-provided $(mkdir_p) make
     variable, @mkdir_p@ configure-time substitution and AM_PROG_MKDIR
     m4 macro are deprecated, eliciting a warning in the 'obsolete'
diff --git a/automake.in b/automake.in
index a993451..9c9561d 100644
--- a/automake.in
+++ b/automake.in
@@ -5391,6 +5391,10 @@ EOF
          $seen_init_automake = $where;
          if (defined $args[2])
            {
+              msg 'obsolete', $where, <<'EOF';
+AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated.  For more 
info, see:
+http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation
+EOF
              $package_version = $args[2];
              $package_version_location = $where;
            }
diff --git a/doc/automake.texi b/doc/automake.texi
index c21a5b7..e3d1c28 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -3941,13 +3941,14 @@ each option were listed in @code{AUTOMAKE_OPTIONS} 
(@pxref{Options}).
 
 @acindex AC_INIT
 This macro can also be called in @emph{another, deprecated form} (support
-for which will be @emph{removed in the next major Automake release}):
+for which will be @emph{removed in the next major Automake release (1.13)}):
 @code{AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])}.  In this form,
 there are two required arguments: the package and the version number.
 This form is obsolete because the @var{package} and @var{version} can
 be obtained from Autoconf's @code{AC_INIT} macro (which itself has an
 old and a new form).
 
address@hidden AM_INIT_AUTOMAKE invocation}
 If your @file{configure.ac} has:
 
 @example
diff --git a/m4/init.m4 b/m4/init.m4
index 3520dcb..7664665 100644
--- a/m4/init.m4
+++ b/m4/init.m4
@@ -52,7 +52,10 @@ AC_SUBST([CYGPATH_W])
 # Define the identity of the package.
 dnl Distinguish between old-style and new-style calls.
 m4_ifval([$2],
-[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+[AC_DIAGNOSE([obsolete],
+[$0: two- and three-arguments forms are deprecated.  For more info, see:
+http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation])
+m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
  AC_SUBST([PACKAGE], [$1])dnl
  AC_SUBST([VERSION], [$2])],
 [_AM_SET_OPTIONS([$1])dnl
diff --git a/t/ac-output-old.tap b/t/ac-output-old.tap
index 5c906a2..5ba3d3e 100755
--- a/t/ac-output-old.tap
+++ b/t/ac-output-old.tap
@@ -24,6 +24,8 @@ plan_ 22
 
 rm -f configure.ac depcomp # Not required.
 
+AUTOMAKE="$AUTOMAKE -Wno-obsolete"
+
 # -----------------------------------------------------------------------
 
 # Test for bug reported by François Pinard.
diff --git a/t/aminit-moreargs-deprecation.sh b/t/aminit-moreargs-deprecation.sh
new file mode 100755
index 0000000..ac91d1d
--- /dev/null
+++ b/t/aminit-moreargs-deprecation.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2012 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that automake warns against old-style usages of AM_INIT_AUTOMAKE
+# (i.e., calls with two or three arguments).
+
+. ./defs || Exit 1
+
+warn_rx='AM_INIT_AUTOMAKE.* two-.* three-arguments form.*deprecated'
+
+cat > configure.ac <<'END'
+AC_INIT([Makefile.am])
+AM_INIT_AUTOMAKE([twoargs], [1.0])
+AC_CONFIG_FILES([Makefile])
+END
+
+$ACLOCAL
+
+do_check()
+{
+  rm -rf autom4te*.cache
+  for cmd in "$AUTOCONF" "$AUTOMAKE"; do
+    $cmd -Werror -Wnone -Wobsolete 2>stderr && { cat stderr; Exit 1; }
+    cat stderr >&2
+    grep "^configure\.ac:2:.*$warn_rx" stderr
+    $cmd -Werror -Wall -Wno-obsolete || Exit 1
+  done
+}
+
+: > Makefile.am
+do_check
+
+sed "/^AM_INIT_AUTOMAKE/s|)$|, [NODEFINE])|" configure.ac > t
+diff configure.ac t && fatal_ "failed to edit configure.ac"
+mv -f t configure.ac
+do_check
+
+:
diff --git a/t/backcompat.sh b/t/backcompat.sh
index ec8292c..8a93141 100755
--- a/t/backcompat.sh
+++ b/t/backcompat.sh
@@ -55,7 +55,7 @@ END
     cat configure.in # For debugging.
     $ACLOCAL
     $AUTOCONF
-    $AUTOMAKE
+    $AUTOMAKE -Wno-obsolete
     ./configure
     $MAKE test
   done
diff --git a/t/backcompat3.sh b/t/backcompat3.sh
index 2377e88..5dc78f6 100755
--- a/t/backcompat3.sh
+++ b/t/backcompat3.sh
@@ -22,6 +22,8 @@ am_create_testdir=empty
 
 empty=''
 
+AUTOMAKE="$AUTOMAKE -Wno-obsolete"
+
 cat > Makefile.am <<'END'
 ## Leading ':;' here required to work around bugs of (at least) bash 3.2
 got: Makefile
diff --git a/t/backcompat5.sh b/t/backcompat5.sh
index 3aa9067..6bfb1c2 100755
--- a/t/backcompat5.sh
+++ b/t/backcompat5.sh
@@ -94,10 +94,10 @@ END
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE -a
+$AUTOMAKE -a -Wno-obsolete
 test -f install-sh
 for f in $makefiles; do mv -f $f.in $f.sav; done
-$AUTOMAKE
+$AUTOMAKE -Wno-obsolete
 for f in $makefiles; do diff $f.sav $f.in; done
 
 ./configure
diff --git a/t/backcompat6.sh b/t/backcompat6.sh
index fde118b..4523a65 100755
--- a/t/backcompat6.sh
+++ b/t/backcompat6.sh
@@ -78,7 +78,7 @@ int main (void)
 END
 
 $ACLOCAL
-$AUTOMAKE --add-missing
+$AUTOMAKE -Wno-obsolete --add-missing
 $AUTOCONF
 
 ./configure
diff --git a/t/confsub.sh b/t/confsub.sh
index 1887046..b13f26a 100755
--- a/t/confsub.sh
+++ b/t/confsub.sh
@@ -19,11 +19,10 @@
 
 . ./defs || Exit 1
 
-cat > configure.ac << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AM_CONFIG_HEADER(subdir/config.h:subdir/config.hin)
-AC_OUTPUT(Makefile subdir/Makefile)
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([subdir/Makefile])
+AM_CONFIG_HEADER([subdir/config.h:subdir/config.hin])
+AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
diff --git a/t/install2.sh b/t/install2.sh
index f1992e8..bd400f4 100755
--- a/t/install2.sh
+++ b/t/install2.sh
@@ -17,14 +17,16 @@
 # Test for bug in 'make dist'
 # From Pavel Roskin.
 
+am_create_testdir=empty
 . ./defs || Exit 1
 
-cat > configure.ac << 'END'
-AC_INIT
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
 dnl Prevent automake from looking in .. and ../..
-AC_CONFIG_AUX_DIR(.)
-AM_INIT_AUTOMAKE(foo, 0.1)
-AC_OUTPUT(Makefile)
+AC_CONFIG_AUX_DIR([.])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index d692561..e9b6642 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -117,6 +117,7 @@ t/alpha2.sh \
 t/amhello-cflags.sh \
 t/amhello-cross-compile.sh \
 t/amhello-binpkg.sh \
+t/aminit-moreargs-deprecation.sh \
 t/amassign.sh \
 t/ammissing.sh \
 t/amopt.sh \
diff --git a/t/pr2.sh b/t/pr2.sh
index ffe4a81..9aa7bc5 100755
--- a/t/pr2.sh
+++ b/t/pr2.sh
@@ -29,11 +29,8 @@
 
 . ./defs || Exit 1
 
-# Please keep this underquoted and old-style.
-cat > configure.ac << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT(README.foo:templ/README.foo.in Makefile)
+cat >> configure.ac << 'END'
+AC_OUTPUT([README.foo:templ/README.foo.in])
 END
 
 : > Makefile.am
@@ -46,6 +43,6 @@ $AUTOCONF
 $AUTOMAKE
 ./configure
 $MAKE distdir
-test -f nonesuch-nonesuch/templ/README.foo.in
+test -f $distdir/templ/README.foo.in
 
 :
diff --git a/t/pr87.sh b/t/pr87.sh
index d98b661..121328d 100755
--- a/t/pr87.sh
+++ b/t/pr87.sh
@@ -37,12 +37,16 @@ EOF
 done
 
 echo "SUBDIRS = $subdirs" > Makefile.am
-cat >configure.ac <<EOF
-AC_INIT(`echo $subdirs | sed 's|\([a-z][a-z]*\).*|\1/\1.c|'`)
-AC_CONFIG_AUX_DIR(.)
-AM_INIT_AUTOMAKE($me, 1.0)
+
+cat > configure.ac <<EOF
+AC_INIT([$me], [1.0])
+AC_CONFIG_SRCDIR([foo/foo.c])
+AC_CONFIG_AUX_DIR([.])
+AM_INIT_AUTOMAKE
 AC_PROG_CC
-AC_OUTPUT(Makefile `echo $subdirs | sed 's|\([a-z][a-z]*\)|\1/Makefile|g'`)
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([`echo $subdirs | sed 's|\([a-z][a-z]*\)|\1/Makefile|g'`])
+AC_OUTPUT
 EOF
 
 mkdir build
diff --git a/t/version.sh b/t/version.sh
index 98664e2..431eb0d 100755
--- a/t/version.sh
+++ b/t/version.sh
@@ -38,4 +38,4 @@ END
 : > THANKS
 
 $ACLOCAL
-$AUTOMAKE --gnits
+$AUTOMAKE --gnits -Wno-obsolete
diff --git a/t/version2.sh b/t/version2.sh
index 71749f6..273bd36 100755
--- a/t/version2.sh
+++ b/t/version2.sh
@@ -38,4 +38,4 @@ END
 : > THANKS
 
 $ACLOCAL
-$AUTOMAKE --gnits
+$AUTOMAKE --gnits -Wno-obsolete
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]