Subject: [PATCH] subdir-objects: complain if it isn't enabled (was: Re: bug#13378: [IMPORTANT] Make the 'subdir-objects' setup the default, and only available one)

From: Stefano Lattarini <[email-masked]>
Date: Sun, 13 Jan 2013 20:51:33 +0100

Reference:
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13378>

On 01/07/2013 09:08 PM, Stefano Lattarini wrote:
> Severity: wishlist
> 
> Inspired from Automake-NG commit 'v1.12.1-313-g14fe163' of 2012-06-07,
> "[ng] subdir-objects: enable unconditionally".
> 
> The fact that Automake-generated Makefiles place compiled object files in
> he current directory by default, also when the corresponding source file
> is in a subdirectory, is basically an historical accident, due to the fact
> that the 'subdir-objects' option had only been introduced in April 1999,
> starting with commit 'user-dep-gen-branchpoint-56-g88b5959', and never
> made the default (likely to avoid backwards-compatibility issues).
> 
> Since I believe the behaviour enabled by the 'subdir-objects' is the most
> useful one, and in fact the *only* natural one, I'd like to make it the
> the only one available, simplifying the Automake implementation and APIs
> a little in the process.
> 
> Alas, since this also means changing the default behaviour of Automake
> ('subdir-objects' is not enabled by default, sadly), this means the
> transition path will be less smooth than I'd like.  Here it is a sketch
> for it:
> 
>   Automake 1.13.2
>   ---------------
> 
>   Give a warning in the category 'unsupported' if the 'subdir-objects'
>   option is not specified.  This should give the users enough forewarning
>   about the planned change, and give them time to update their packages
>   to the new semantic.
> 
Here is a patch doing that.  I will push it in a couple of days if there
are no objections.

Regards,
  Stefano

---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ----

>From 4864af66bfd189a501061d775bb9743a1285d88e Mon Sep 17 00:00:00 2001
Message-Id: <4864af66b[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Sun, 13 Jan 2013 17:50:30 +0100
Subject: [PATCH] subdir-objects: complain if it isn't enabled

Since the next major automake version will make the behaviour so far
only activated with the 'subdir-object' option mandatory, it's better
if we start warning users not using that option.

As suggested by Peter Johansson, we strive to avoid the warning when
it would be irrelevant, i.e., if all source files sit in "current"
directory.

See automake bug#13378.

* automake.in (handle_single_transform): Print the warning when
necessary.
* t/subobj.sh: Enhance.
* t/ax/depcomp.sh: Adjust.
* t/cscope.tap: Likewise.
* t/depcomp8a.sh: Likewise.
* t/depcomp8b.sh: Likewise.
* t/ext2.sh: Likewise.
* t/extra-portability.sh: Likewise.
* t/fort2.sh: Likewise.
* t/fort4.sh: Likewise.
* t/fort5.sh: Likewise.
* t/lex-line.sh: Likewise.
* t/libtool3.sh: Likewise.
* t/ltinstloc.sh: Likewise.
* t/ltlibsrc.sh: Likewise.
* t/ltorder.sh: Likewise.
* t/parallel-tests-suffix-prog.sh: Likewise.
* t/sourcefile-in-subdir.sh: Likewise.
* t/specflg9.sh: Likewise.
* t/subobj4.sh: Likewise.
* t/subobj7.sh: Likewise.
* t/subpkg-yacc.sh: Likewise.
* t/subpkg.sh: Likewise.
* t/suffix-custom-subobj-and-specflg.sh: Likewise.
* t/vala-libs.sh: Likewise.
* t/vala-non-recursive-setup.sh: Likewise.
* t/yacc-grepping2.sh: Likewise.
* t/yacc-line.sh: Likewise.
---
 automake.in                           | 31 ++++++++++++++++--
 t/ax/depcomp.sh                       |  9 +++---
 t/cscope.tap                          |  6 ++--
 t/depcomp8a.sh                        |  4 ++-
 t/depcomp8b.sh                        |  9 ++++--
 t/ext2.sh                             |  1 +
 t/extra-portability.sh                |  2 +-
 t/fort2.sh                            | 58 +++++++++++++++++++++++++--------
 t/fort4.sh                            |  2 +-
 t/fort5.sh                            |  4 ++-
 t/lex-line.sh                         |  4 ++-
 t/libtool3.sh                         |  4 +++
 t/ltinstloc.sh                        |  1 +
 t/ltlibsrc.sh                         |  2 ++
 t/ltorder.sh                          |  1 +
 t/parallel-tests-suffix-prog.sh       |  1 +
 t/sourcefile-in-subdir.sh             |  2 +-
 t/specflg9.sh                         |  1 +
 t/subobj.sh                           | 61 +++++++++++++++++++++++++++++++----
 t/subobj4.sh                          |  2 +-
 t/subobj7.sh                          |  1 +
 t/subpkg-yacc.sh                      |  2 +-
 t/subpkg.sh                           |  2 +-
 t/suffix-custom-subobj-and-specflg.sh | 11 +------
 t/vala-libs.sh                        |  3 +-
 t/vala-non-recursive-setup.sh         |  1 +
 t/yacc-grepping2.sh                   | 10 +++---
 t/yacc-line.sh                        |  4 ++-
 28 files changed, 183 insertions(+), 56 deletions(-)

diff --git a/automake.in b/automake.in
index 990b60d..0e3b882 100644
--- a/automake.in
+++ b/automake.in
@@ -1793,9 +1793,36 @@ sub handle_single_transform ($$$$$%)

 	    # If rewrite said it was ok, put the object into a
 	    # subdir.
-	    if ($r == LANG_SUBDIR && $directory ne '')
+	    if ($directory ne '')
 	    {
-		$object = $directory . '/' . $object;
+              if ($r == LANG_SUBDIR)
+                {
+                  $object = $directory . '/' . $object;
+                }
+              else
+                {
+                  # Since the next major version of automake (1.14) will
+                  # make the behaviour so far only activated with the
+                  # 'subdir-object' option mandatory, it's better if we
+                  # start warning users not using that option.
+                  # As suggested by Peter Johansson, we strive to avoid
+                  # the warning when it would be irrelevant, i.e., if
+                  # all source files sit in "current" directory.
+                  msg_var 'unsupported', $var,
+                          "source file '$full' is in a subdirectory,"
+                          . "\nbut option 'subdir-objects' is disabled";
+                  msg 'unsupported', INTERNAL, <<'EOF', uniq_scope => US_GLOBAL;
+possible forward-incompatibility.
+At least a source file is in a subdirectory, but the 'subdir-objects'
+automake option hasn't been enabled.  For now, the corresponding output
+object file(s) will be placed in the top-level directory.  However,
+this behaviour will change in future Automake versions: they will
+unconditionally cause object files to be placed in the same subdirectory
+of the corresponding sources.
+You are advised to start using 'subdir-objects' option throughout your
+project, to avoid future incompatibilities.
+EOF
+                }
 	    }

 	    # If the object file has been renamed (because per-target
diff --git a/t/ax/depcomp.sh b/t/ax/depcomp.sh
index 0e5b6a5..1534d5f 100644
--- a/t/ax/depcomp.sh
+++ b/t/ax/depcomp.sh
@@ -130,7 +130,7 @@ check_distclean ()
 cat > configure.ac <<END
 AC_INIT([$me], [1.0])
 AC_CONFIG_AUX_DIR([build-aux])
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([subdir-objects])
 AC_PROG_CC
 AM_PROG_AR
 $(if test $depcomp_with_libtool = yes; then
@@ -199,18 +199,17 @@ ${normalized_target}_${LINKADD} = src/libbaz.$a
 grep-test:
 ## For debugging.
 	cat \$(DEPDIR)/foo.$po || :
-	cat \$(DEPDIR)/subfoo.$po || :
+	cat sub/\$(DEPDIR)/subfoo.$po || :
 	cat src/\$(DEPDIR)/baz.$po || :
 	cat src/sub2/\$(DEPDIR)/sub2foo.$po || :
-## Checks done here.
+## Checks are done here.
 	grep '^foo.$objext.*:' \$(DEPDIR)/foo.$po
-	grep '^subfoo\.$objext.*:' \$(DEPDIR)/subfoo.$po
+	grep '^sub/subfoo\.$objext.*:' sub/\$(DEPDIR)/subfoo.$po
 	grep '^baz\.$objext.*:' src/\$(DEPDIR)/baz.$po
 	grep '^sub2/sub2foo\.$objext.*:' src/sub2/\$(DEPDIR)/sub2foo.$po
 END

 cat > src/Makefile.am <<END
-AUTOMAKE_OPTIONS = subdir-objects
 noinst_${LIBPRIMARY} = libbaz.$a
 # We include sub2foo only to be sure that the munging in depcomp
 # doesn't remove too much from the object file name.
diff --git a/t/cscope.tap b/t/cscope.tap
index 29feec2..9dbe01b 100755
--- a/t/cscope.tap
+++ b/t/cscope.tap
@@ -22,8 +22,10 @@ plan_ 18

 ocwd=$(pwd) || fatal_ "getting top-level directory"

-cat >> configure.ac << 'END'
-AC_CONFIG_FILES([sub/Makefile])
+cat > configure.ac << 'END'
+AC_INIT([cscope-test], [1.0])
+AM_INIT_AUTOMAKE([subdir-objects])
+AC_CONFIG_FILES([Makefile sub/Makefile])
 AC_SUBST([CC],  [who-cares])
 AC_SUBST([CXX], [who-cares])
 AC_SUBST([FC],  [who-cares])
diff --git a/t/depcomp8a.sh b/t/depcomp8a.sh
index 76aa376..d6c73ed 100755
--- a/t/depcomp8a.sh
+++ b/t/depcomp8a.sh
@@ -48,7 +48,9 @@ int bar (void)
 END

 $ACLOCAL
-$AUTOMAKE -a
+# FIXME: stop disabling the warnings in the 'unsupported' category
+# FIXME: once the 'subdir-objects' option has been mandatory.
+$AUTOMAKE -a -Wno-unsupported
 grep include Makefile.in # For debugging.
 grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
 grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in
diff --git a/t/depcomp8b.sh b/t/depcomp8b.sh
index 52382f1..879ee1c 100755
--- a/t/depcomp8b.sh
+++ b/t/depcomp8b.sh
@@ -31,6 +31,9 @@ AC_OUTPUT
 END

 cat > Makefile.am << 'END'
+## FIXME: stop disabling the warnings in the 'unsupported' category
+## FIXME: once the 'subdir-objects' option has been mandatory.
+AUTOMAKE_OPTIONS = -Wno-unsupported
 lib_LTLIBRARIES = libzardoz.la
 libzardoz_la_SOURCES = foo.c sub/bar.c
 END
@@ -42,7 +45,9 @@ echo 'int bar (void) { return 0; }' > sub/bar.c
 libtoolize

 $ACLOCAL
-$AUTOMAKE -a
+# FIXME: stop disabling the warnings in the 'unsupported' category
+# FIXME: once the 'subdir-objects' option has been mandatory.
+$AUTOMAKE -a -Wno-unsupported
 grep include Makefile.in # For debugging.
 grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
 grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in
@@ -56,7 +61,7 @@ DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck

 # Try again with subdir-objects option.

-echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am
+echo AUTOMAKE_OPTIONS += subdir-objects >> Makefile.am

 $AUTOMAKE
 grep include Makefile.in # For debugging.
diff --git a/t/ext2.sh b/t/ext2.sh
index 1089080..4858aec 100755
--- a/t/ext2.sh
+++ b/t/ext2.sh
@@ -25,6 +25,7 @@ AC_PROG_CXX
 EOF

 cat >Makefile.am <<EOF
+AUTOMAKE_OPTIONS = subdir-objects
 bin_PROGRAMS = p q r
 p_SOURCES = a.cc b.cpp c.cxx
 q_SOURCES = sub/d.cc sub/e.cpp sub/f.cxx
diff --git a/t/extra-portability.sh b/t/extra-portability.sh
index 1ea23ad..63849c7 100755
--- a/t/extra-portability.sh
+++ b/t/extra-portability.sh
@@ -40,7 +40,7 @@ $ACLOCAL

 cat >Makefile.am <<END
 EXTRA_LIBRARIES = libfoo.a
-libfoo_a_SOURCES = sub/foo.c
+libfoo_a_SOURCES = foo.c
 END

 # Sanity check: extra-portability warnings causes the expected error.
diff --git a/t/fort2.sh b/t/fort2.sh
index c99e8b7..d614452 100755
--- a/t/fort2.sh
+++ b/t/fort2.sh
@@ -19,6 +19,7 @@

 # Cf. 'fort1.sh' and 'link_f90_only.sh'.

+required=gfortran # Required only in order to run ./configure.
 . test-init.sh

 mkdir sub
@@ -30,33 +31,64 @@ AC_FC_SRCEXT([f95])
 AC_FC_SRCEXT([f03])
 AC_FC_SRCEXT([f08])
 AC_FC_SRCEXT([blabla])
+AC_OUTPUT
 END

 cat >Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+FC = fake-fc
 bin_PROGRAMS = hello goodbye
-hello_SOURCES = hello.f90 foo.f95 sub/bar.f95 hi.f03 sub/howdy.f03 greets.f08 sub/bonjour.f08
+hello_SOURCES = hello.f90 foo.f95 sub/bar.f95 hi.f03 sub/howdy.f03 \
+                greets.f08 sub/bonjour.f08
 goodbye_SOURCES = bye.f95 sub/baz.f90
-goodbye_FCFLAGS =
+goodbye_FCFLAGS = --gby
 END

 $ACLOCAL
 $AUTOMAKE
-# The following tests aren't fool-proof, but they don't
-# need a Fortran compiler.
 grep '.\$(LINK)'       Makefile.in && exit 1
 grep '.\$(FCLINK)'     Makefile.in
 grep '.\$(FCCOMPILE)'  Makefile.in > stdout
 cat stdout
 grep -v '\$(FCFLAGS_f' stdout && exit 1
 grep '.\$(FC.*\$(FCFLAGS_blabla' Makefile.in && exit 1
-# Notice the TAB:
-grep '^[	].*\$(FC.*\$(FCFLAGS_f90).*\.f90' Makefile.in
-grep '^[	].*\$(FC.*\$(FCFLAGS_f95).*\.f95' Makefile.in
-grep '^[	].*\$(FC.*\$(FCFLAGS_f03).*\.f03' Makefile.in
-grep '^[	].*\$(FC.*\$(FCFLAGS_f08).*\.f08' Makefile.in
-grep '^[	].*\$(FC.*\$(FCFLAGS_f90).*\.f95' Makefile.in && exit 1
-grep '^[	].*\$(FC.*\$(FCFLAGS_f95).*\.f90' Makefile.in && exit 1
-grep '^[	].*\$(FC.*\$(FCFLAGS_f90).*\.f03' Makefile.in && exit 1
-grep '^[	].*\$(FC.*\$(FCFLAGS_f08).*\.f90' Makefile.in && exit 1
+
+sed '/^AC_FC_SRCEXT.*blabla/d' configure.ac >t
+mv -f t configure.ac
+
+rm -rf autom4te*.cache
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+
+touch hello.f90 foo.f95 sub/bar.f95 hi.f03 sub/howdy.f03 greets.f08 \
+      sub/bonjour.f08 bye.f95 sub/baz.f90
+
+$MAKE -n \
+  FCFLAGS_f90=--@90 FCFLAGS_f95=--@95 FCFLAGS_f03=--@03 FCFLAGS_f08=--@08 \
+  > stdout || { cat stdout; exit 1; }
+cat stdout
+# To make it easier to have  stricter grepping below.
+sed -e 's/[ 	][ 	]*/  /g' -e 's/^/ /' -e 's/$/ /' stdout > out
+cat out
+
+grep ' fake-fc .* --@90 .* hello\.f90 ' out
+grep ' fake-fc .* --@95 .* foo\.f95 ' out
+grep ' fake-fc .* --@95 .* sub/bar\.f95 ' out
+grep ' fake-fc .* --@03 .* hi\.f03 ' out
+grep ' fake-fc .* --@03 .* sub/howdy\.f03 ' out
+grep ' fake-fc .* --@08 .* greets\.f08 ' out
+grep ' fake-fc .* --@08 .* sub/bonjour\.f08 ' out
+grep ' fake-fc .* --gby .* --@95 .*[` ]bye\.f95 ' out
+grep ' fake-fc .* --gby .* --@90 .*[` ]sub/baz\.f90 ' out
+
+test $(grep -c '.*--gby.*\.f' out) -eq 2
+
+$EGREP 'fake-fc.*--@(95|03|08).*\.f90' out && exit 1
+$EGREP 'fake-fc.*--@(90|03|08).*\.f95' out && exit 1
+$EGREP 'fake-fc.*--@(90|95|08).*\.f03' out && exit 1
+$EGREP 'fake-fc.*--@(95|95|03).*\.f08' out && exit 1

 :
diff --git a/t/fort4.sh b/t/fort4.sh
index 822edb8..2ef27ab 100755
--- a/t/fort4.sh
+++ b/t/fort4.sh
@@ -65,7 +65,7 @@ LDADD = $(FCLIBS)
 END

 $ACLOCAL
-$AUTOMAKE -a
+$AUTOMAKE -a -Wno-unsupported
 # The Fortran 77 linker should be preferred:
 grep '.\$(FCLINK)' Makefile.in && exit 1

diff --git a/t/fort5.sh b/t/fort5.sh
index 0272706..7b9991b 100755
--- a/t/fort5.sh
+++ b/t/fort5.sh
@@ -75,7 +75,9 @@ END

 libtoolize --force
 $ACLOCAL
-$AUTOMAKE -a
+# FIXME: stop disabling the warnings in the 'unsupported' category
+# FIXME: once the 'subdir-objects' option has been mandatory.
+$AUTOMAKE -a -Wno-unsupported
 $AUTOCONF

 # This test requires Libtool >= 2.0.  Earlier Libtool does not
diff --git a/t/lex-line.sh b/t/lex-line.sh
index 9b27c0b..258f6af 100755
--- a/t/lex-line.sh
+++ b/t/lex-line.sh
@@ -86,7 +86,9 @@ c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'

 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE -a
+# FIXME: stop disabling the warnings in the 'unsupported' category
+# FIXME: once the 'subdir-objects' option has been mandatory.
+$AUTOMAKE -a -Wno-unsupported

 for vpath in : false; do

diff --git a/t/libtool3.sh b/t/libtool3.sh
index fb8c194..5653280 100755
--- a/t/libtool3.sh
+++ b/t/libtool3.sh
@@ -28,6 +28,10 @@ AC_OUTPUT
 END

 cat > Makefile.am << 'END'
+# FIXME: stop disabling the warnings in the 'unsupported' category
+# FIXME: once the 'subdir-objects' option has been mandatory.
+AUTOMAKE_OPTIONS = -Wno-unsupported
+
 lib_LTLIBRARIES = lib0.la liba/liba.la
 lib0_la_SOURCES = 0.c
 liba_liba_la_SOURCES = liba/a.c
diff --git a/t/ltinstloc.sh b/t/ltinstloc.sh
index b9670cb..bae3d49 100755
--- a/t/ltinstloc.sh
+++ b/t/ltinstloc.sh
@@ -35,6 +35,7 @@ lib_LTLIBRARIES = liba1.la sub/liba2.la
 pkglib_LTLIBRARIES = liba1.la
 nobase_lib_LTLIBRARIES = sub/liba2.la
 endif
+AUTOMAKE_OPTIONS = subdir-objects
 END

 libtoolize
diff --git a/t/ltlibsrc.sh b/t/ltlibsrc.sh
index e58bba7..8c8098b 100755
--- a/t/ltlibsrc.sh
+++ b/t/ltlibsrc.sh
@@ -35,6 +35,8 @@ noinst_LTLIBRARIES = foo.la zoo.d/old2.la

 $(srcdir)/zoo_d_old2_la.c: $(srcdir)/old_la.c
 	cp $(srcdir)/old_la.c $@
+
+AUTOMAKE_OPTIONS = -Wno-unsupported
 END

 cat > foo.c << 'END'
diff --git a/t/ltorder.sh b/t/ltorder.sh
index fe9d7bd..c243ac7 100755
--- a/t/ltorder.sh
+++ b/t/ltorder.sh
@@ -27,6 +27,7 @@ AC_OUTPUT
 END

 cat >Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
 nobase_lib_LTLIBRARIES = liba1.la sub/liba2.la sub/liba3.la liba4.la liba5.la
 sub_liba2_la_LIBADD = liba1.la
 sub_liba3_la_LIBADD = sub/liba2.la
diff --git a/t/parallel-tests-suffix-prog.sh b/t/parallel-tests-suffix-prog.sh
index 64f103c..7b924a3 100755
--- a/t/parallel-tests-suffix-prog.sh
+++ b/t/parallel-tests-suffix-prog.sh
@@ -27,6 +27,7 @@ AC_OUTPUT
 END

 cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
 ## Note that automake should not match the '/test' part of 'sub/test' as
 ## '.test' suffix, nor the '/chk' part of 'sub/chk' as '.chk' suffix.
 TESTS = $(dist_TESTS) $(check_PROGRAMS)
diff --git a/t/sourcefile-in-subdir.sh b/t/sourcefile-in-subdir.sh
index a010776..1054f18 100755
--- a/t/sourcefile-in-subdir.sh
+++ b/t/sourcefile-in-subdir.sh
@@ -29,7 +29,7 @@ AC_PROG_CC
 END

 $ACLOCAL
-$AUTOMAKE
+$AUTOMAKE -Wno-unsupported

 grep '^z\.o: x/z\.c$' Makefile.in

diff --git a/t/specflg9.sh b/t/specflg9.sh
index 3e0c694..4f3d3b0 100755
--- a/t/specflg9.sh
+++ b/t/specflg9.sh
@@ -24,6 +24,7 @@ AC_OUTPUT
 END

 cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
 bin_PROGRAMS = zzfoo zzbar
 zzfoo_SOURCES = sub/foo.c
 zzbar_SOURCES = bar.c
diff --git a/t/subobj.sh b/t/subobj.sh
index d16512a..22ab2d3 100755
--- a/t/subobj.sh
+++ b/t/subobj.sh
@@ -14,19 +14,63 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

-# Test of subdir objects with C.
+# Test of subdir objects with C and C++.

 . test-init.sh

-echo AC_PROG_CC >> configure.ac
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_YACC
+AC_CONFIG_FILES([sub/Makefile])
+END
+
+$ACLOCAL
+: > ylwrap

 cat > Makefile.am << 'END'
-AUTOMAKE_OPTIONS = subdir-objects
+SUBDIRS = sub
 bin_PROGRAMS = wish
-wish_SOURCES = generic/a.c generic/b.c
+wish_SOURCES = generic/a.c
+wish_SOURCES += another/z.cxx
 END

-$ACLOCAL
+mkdir sub
+cat > sub/Makefile.am << 'END'
+dream_SOURCES = generic/b.c more/r.y
+bin_PROGRAMS = dream
+END
+
+AUTOMAKE_fails
+grep "^Makefile\.am:3:.*'generic/a\.c'.* in a subdirectory" stderr
+grep "^Makefile\.am:[34]:.*'another/z\.cxx'.* in a subdirectory" stderr
+grep "^sub/Makefile\.am:1:.*'generic/b\.c'.* in a subdirectory" stderr
+grep "option 'subdir-objects' is disabled" stderr
+# Verbose tips should be given, but not too many times.
+for msg in \
+  "possible forward-incompatibility" \
+  "advi[sc]e.* 'subdir-objects' option throughout" \
+  "unconditionally.* object file.* same subdirectory" \
+; do
+  test $(grep -c "$msg" stderr) -eq 1
+done
+
+# Guard against stupid typos.
+grep 'subdir-object([^s]|$)' stderr && exit 1
+
+$AUTOMAKE -Wno-unsupported
+
+echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am
+AUTOMAKE_fails
+grep "^Makefile\.am" stderr && exit 1
+grep "^sub/Makefile\.am:.*'generic/b\.c'.* in a subdirectory" stderr
+grep "option 'subdir-objects' is disabled" stderr
+
+sed 's/^AM_INIT_AUTOMAKE/&([subdir-objects])/' configure.ac > configure.tmp
+mv -f configure.tmp configure.ac
+$ACLOCAL --force
+$AUTOMAKE
+
 rm -f compile
 $AUTOMAKE --add-missing 2>stderr || { cat stderr >&2; exit 1; }
 cat stderr >&2
@@ -35,9 +79,12 @@ grep '^configure\.ac:4:.*install.*compile' stderr
 test -f compile

 grep '^generic/a\.\$(OBJEXT):' Makefile.in
-grep '[^/]a\.\$(OBJEXT)' Makefile.in && exit 1
+grep '^generic/b\.\$(OBJEXT):' sub/Makefile.in
+grep '^another/z\.\$(OBJEXT):' Makefile.in
+$EGREP '(^|[^/])[abz]\.\$(OBJEXT)' Makefile.in sub/Makefile.in && exit 1

 # Opportunistically test for a different bug.
-grep '^generic/b\.\$(OBJEXT):.*dirstamp' Makefile.in
+grep '^another/z\.\$(OBJEXT):.*dirstamp' Makefile.in
+grep '^generic/b\.\$(OBJEXT):.*dirstamp' sub/Makefile.in

 :
diff --git a/t/subobj4.sh b/t/subobj4.sh
index 816f506..dbbed30 100755
--- a/t/subobj4.sh
+++ b/t/subobj4.sh
@@ -43,7 +43,7 @@ END
 : > d2/z.c

 $ACLOCAL
-$AUTOMAKE
+$AUTOMAKE -Wno-unsupported

 grep '\$(CC) .*\.\./d2/z\.c' d1/Makefile.in

diff --git a/t/subobj7.sh b/t/subobj7.sh
index 5dc9ea8..de73cc2 100755
--- a/t/subobj7.sh
+++ b/t/subobj7.sh
@@ -25,6 +25,7 @@ AC_OUTPUT
 END

 cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
 bin_PROGRAMS = wish
 wish_SOURCES = foo.c generic/a.c
 END
diff --git a/t/subpkg-yacc.sh b/t/subpkg-yacc.sh
index 639e415..9fc6761 100755
--- a/t/subpkg-yacc.sh
+++ b/t/subpkg-yacc.sh
@@ -49,7 +49,7 @@ mkdir lib/src

 cat >lib/configure.ac <<'EOF'
 AC_INIT([lib], [2.3])
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([subdir-objects])
 AC_PROG_RANLIB
 AC_PROG_YACC
 dnl This comes after YACC and RANLIB checks, deliberately.
diff --git a/t/subpkg.sh b/t/subpkg.sh
index 6f59ac5..f9cdc74 100755
--- a/t/subpkg.sh
+++ b/t/subpkg.sh
@@ -62,7 +62,7 @@ mkdir lib/src

 cat >lib/configure.ac <<'EOF'
 AC_INIT([lib], [2.3])
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([subdir-objects])
 AC_CONFIG_MACRO_DIR([../m4])
 AM_PROG_AR
 AC_PROG_RANLIB
diff --git a/t/suffix-custom-subobj-and-specflg.sh b/t/suffix-custom-subobj-and-specflg.sh
index 32356d7..b862d88 100755
--- a/t/suffix-custom-subobj-and-specflg.sh
+++ b/t/suffix-custom-subobj-and-specflg.sh
@@ -53,18 +53,9 @@ END
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
-./configure
-$MAKE
-
-$MAKE distcheck
-$MAKE distclean
-
-# Should also work without subdir-objects.

-sed '/subdir-objects/d' < Makefile.am > t
-mv -f t Makefile.am
-$AUTOMAKE
 ./configure
+
 $MAKE
 $MAKE distcheck

diff --git a/t/vala-libs.sh b/t/vala-libs.sh
index 66fd243..f1ed99a 100755
--- a/t/vala-libs.sh
+++ b/t/vala-libs.sh
@@ -31,6 +31,7 @@ AC_OUTPUT
 END

 cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
 lib_LIBRARIES = libmu.a
 lib_LTLIBRARIES = src/libzardoz.la
 libmu_a_SOURCES = mu.vala mu2.c mu.vapi mu2.h
@@ -75,7 +76,7 @@ int main ()
 }
 END

-mkdir src
+mkdir -p src
 cat > src/zardoz-foo.vala << 'END'
 using GLib;
 public class Foo {
diff --git a/t/vala-non-recursive-setup.sh b/t/vala-non-recursive-setup.sh
index 88d9d33..88f67a8 100755
--- a/t/vala-non-recursive-setup.sh
+++ b/t/vala-non-recursive-setup.sh
@@ -39,6 +39,7 @@ public class Zardoz {
 END

 cat > 'Makefile.am' <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
 bin_PROGRAMS = src/zardoz
 src_zardoz_CFLAGS = $(GOBJECT_CFLAGS)
 src_zardoz_LDADD = $(GOBJECT_LIBS)
diff --git a/t/yacc-grepping2.sh b/t/yacc-grepping2.sh
index 58a963c..3c5da22 100755
--- a/t/yacc-grepping2.sh
+++ b/t/yacc-grepping2.sh
@@ -34,7 +34,9 @@ mkdir sub
 : > sub/maude.y

 $ACLOCAL
-$AUTOMAKE -a
+# FIXME: stop disabling the warnings in the 'unsupported' category
+# FIXME: once the 'subdir-objects' option has been mandatory.
+$AUTOMAKE -a -Wno-unsupported

 grep '^maude\.c:.*maude\.y' Makefile.in

@@ -47,7 +49,6 @@ bin_PROGRAMS = maude
 maude_SOURCES = sub/maude.y
 END

-$ACLOCAL
 $AUTOMAKE -a

 # No rule needed, the default .y.c: inference rule is enough
@@ -64,8 +65,9 @@ maude_SOURCES = sub/maude.y
 maude_YFLAGS = -d
 END

-$ACLOCAL
-$AUTOMAKE -a
+# FIXME: stop disabling the warnings in the 'unsupported' category
+# FIXME: once the 'subdir-objects' option has been mandatory.
+$AUTOMAKE -a -Wno-unsupported

 # Rule should use maude_YFLAGS.
 grep 'AM_YFLAGS.*maude' Makefile.in && exit 1
diff --git a/t/yacc-line.sh b/t/yacc-line.sh
index 9067a2d..b034af3 100755
--- a/t/yacc-line.sh
+++ b/t/yacc-line.sh
@@ -76,7 +76,9 @@ c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'

 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE -a
+# FIXME: stop disabling the warnings in the 'unsupported' category
+# FIXME: once the 'subdir-objects' option has been mandatory.
+$AUTOMAKE -a -Wno-unsupported

 for vpath in : false; do

-- 
1.8.1.rc3.192.g2d0029e