]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
init: warn against obsolete usage of AM_INIT_AUTOMAKE
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 31 Mar 2012 14:39:32 +0000 (16:39 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 6 May 2012 09:30:16 +0000 (11:30 +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 <stefano.lattarini@gmail.com>
17 files changed:
NEWS
automake.in
doc/automake.texi
m4/init.m4
t/ac-output-old.tap
t/aminit-moreargs-deprecation.sh [new file with mode: 0755]
t/backcompat.sh
t/backcompat3.sh
t/backcompat5.sh
t/backcompat6.sh
t/confsub.sh
t/install2.sh
t/list-of-tests.mk
t/pr2.sh
t/pr87.sh
t/version.sh
t/version2.sh

diff --git a/NEWS b/NEWS
index dcfd8c1c4c3d57f9f2a14b2314e14ec81719f854..57af90117bd8c49f03af9972453b800605b9f510 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -56,6 +56,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.
+
   - Support for the "Cygnus-style" trees (enabled by the 'cygnus' option) is
     now deprecated (its use triggers a warning in the 'obsolete' category).
     It will be removed in the next major Automake release (1.13).
index 16f44b705d9f012a33084bfa5e6818f97d7d2082..5cf5a2c1692a34fda970c945ba7903f70d0ee292 100644 (file)
@@ -5409,6 +5409,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;
            }
index 5e2b9c22bccb10b40f3132c94d3741a61211df1c..2f2ebb087be879e2b2f82ac96bcdd9a38a9c0ba1 100644 (file)
@@ -3946,13 +3946,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).
 
+@anchor{Modernize AM_INIT_AUTOMAKE invocation}
 If your @file{configure.ac} has:
 
 @example
index 206034c549da709a438dab15f1d09eaa28288e1d..85228ba8c94c28f2cb94f8107b14b95f007d1d22 100644 (file)
@@ -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
index 5c906a2f081497c768332356e765958dd5c1da43..5ba3d3e3a901ac4cfe5af98453282ef7253245e9 100755 (executable)
@@ -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 (executable)
index 0000000..ac91d1d
--- /dev/null
@@ -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
+
+:
index ec8292c121801f5f7f67333711714e198671bf6f..8a93141a9887c4d7e41fb0b458c7f81b998022a2 100755 (executable)
@@ -55,7 +55,7 @@ END
     cat configure.in # For debugging.
     $ACLOCAL
     $AUTOCONF
-    $AUTOMAKE
+    $AUTOMAKE -Wno-obsolete
     ./configure
     $MAKE test
   done
index 2377e8876b44a90c678946db198a2dbd4720def7..5dc78f672244a60290bc299cd5e567c9ff0e9599 100755 (executable)
@@ -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
index 3aa90679e8effed3e4cd1385475bc2c807093638..6bfb1c21e82205018573e284a84c170549f93518 100755 (executable)
@@ -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
index fde118b1ce915106847155b7efeb2ca87c3bb52e..4523a656791f683e840eb1d48d12f682a23fe25f 100755 (executable)
@@ -78,7 +78,7 @@ int main (void)
 END
 
 $ACLOCAL
-$AUTOMAKE --add-missing
+$AUTOMAKE -Wno-obsolete --add-missing
 $AUTOCONF
 
 ./configure
index 188704678ab2b961690ddf0e8b122dda9a6f5046..b13f26a3bae6e4e977e53ac13acaf75ee778f348 100755 (executable)
 
 . ./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'
index f1992e8b15991b0fa6ba29da370da5cc17f51be3..bd400f42735992dd12bef166d89f9243b9e0191a 100755 (executable)
 # 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'
index 708e9722ad297eaadff0135abb979bc441bd83c4..e9f8d238f7e340ffc85b1fe4f0bd496b95d026ac 100644 (file)
@@ -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 \
index ffe4a81d79a0616f86f7bc13a16171c1f0ea26a6..9aa7bc536ac110c67664fa274dbc3ae9762cf2d9 100755 (executable)
--- a/t/pr2.sh
+++ b/t/pr2.sh
 
 . ./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
 
 :
index d98b66152da398fb71d4bb6c170e81575d794967..121328d6332460ef4d4b673ac4c1134975ff94a1 100755 (executable)
--- 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
index 98664e28ca3057403d2bae3d7281dcee7532f9f7..431eb0dae2216fac833949d307270c07dec01e0e 100755 (executable)
@@ -38,4 +38,4 @@ END
 : > THANKS
 
 $ACLOCAL
-$AUTOMAKE --gnits
+$AUTOMAKE --gnits -Wno-obsolete
index 71749f64b4fb265ace6fc4ef3249d016fc48a61e..273bd36702599d958c33e970a866b1b7eac15ea9 100755 (executable)
@@ -38,4 +38,4 @@ END
 : > THANKS
 
 $ACLOCAL
-$AUTOMAKE --gnits
+$AUTOMAKE --gnits -Wno-obsolete