automake-commit
[Top][All Lists]
Advanced

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

[Automake-commit] [SCM] GNU Automake branch, master, updated. v1.11-1937


From: Stefano Lattarini
Subject: [Automake-commit] [SCM] GNU Automake branch, master, updated. v1.11-1937-g8f41580
Date: Wed, 15 Feb 2012 17:35:45 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Automake".

http://git.sv.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=8f41580e5d039d9549f7e73f51c2e82de4075015

The branch, master has been updated
       via  8f41580e5d039d9549f7e73f51c2e82de4075015 (commit)
       via  f4d2f3b76702ee43025c809d3588662859146943 (commit)
       via  de839e5b0f4a95242f03f731110ac07e72cf146c (commit)
       via  02ce5d5a0ce42563e8aa8ea03a977d35f3a30f72 (commit)
       via  b42514b48a5104785737cb4459e177b98d023ed7 (commit)
       via  ee29b576923c240a951b7f0d93b7cb5d6a33face (commit)
       via  a2437fee3612a2186005d361c84d62a9859278d7 (commit)
       via  568a1a5e0bfc5bbe1e6d683fe38871a906c2f2a8 (commit)
       via  682d5ce5382ab50d63eaf9fe373a1370bb435b6f (commit)
       via  e0906b7e17bc34b1183d273ca0571c10d5619c08 (commit)
       via  0b34421dc2d78a163ce9eaca41348dd672c302ed (commit)
       via  e6c40d4bba3155a8dd2406806a7be51d3ac73ed0 (commit)
       via  abe0587b12ac59561d011640d998e7dd74b1820f (commit)
       via  818bc406278a138da6480412d3c289f91e6dbfda (commit)
       via  df6841b7d543abc9731b4b42a2392089a41fb838 (commit)
       via  9f2642d4f91d5d6191b21ae1df5842b261c0b854 (commit)
       via  65a1bf9980d62187708f78b53a4e92907677aa99 (commit)
       via  f0645e2ddf6327fafdd072d1c30d15f48510e605 (commit)
       via  1560265e1ca8d5c542d27a4143e1879379831e12 (commit)
       via  0a8cfb4c59d2523ecd7a8f253afce8f8e436594f (commit)
       via  a9edac6c6e0c33d6571d6ef5ce0bbf682459c3bc (commit)
       via  91ea62abccb87e2a1ae989bae95640d8913d2970 (commit)
       via  0f3b3e840715c4a287e1f467ce552820d07253fd (commit)
       via  d3612a83d0db6f570450da176c828fed0501e8df (commit)
       via  6399e59a930314ef6b4945fbcae4d76dfa74af87 (commit)
       via  5f2ec6ccb226272ab94077ab0898af188b5999cf (commit)
       via  c2ee522f4555e2ac326e5b07c03a2f5b56b556d3 (commit)
       via  ebb212043205b4ce9d1ec025e0bd99b4de9cbdb2 (commit)
       via  94f3f898ff4bac2c67c254b7bf933a2698f0115c (commit)
       via  3efb29e48c0721a6d270c3c2a3e91c71792f1e2c (commit)
       via  f2ed2817e85bb9e174889171cbc8d2bcb2694f59 (commit)
       via  1d76d3f56efbaf6152ce5a6795fd0b2a3d0d92dd (commit)
       via  73c31733ff88493f751938451600d6950f9fb0b7 (commit)
       via  e79aed067f344f7431346ef6d97859abd30e18f4 (commit)
       via  9474426b7637f2d6dcfa454f0e77bb0ebe1fd741 (commit)
       via  9ef5f5ffede710fe01cab5e4a62773a763c2eafd (commit)
       via  b50458a6f8766aa2369995f8f664334f97f94a23 (commit)
       via  fea854ed044c3bdb3f7d85fafa35e1d17a9e63fc (commit)
       via  b67712acad6d2b0be448687c76e69a43b71e27b4 (commit)
       via  68da6ae8ce04258668e63aee320011c8bf130d18 (commit)
       via  1e6914a488ba23c9a098510d100de7cbe6edb79d (commit)
       via  4a187a50b89839f823f174256afa0903e0040a97 (commit)
       via  f88a6ca185c106aecf11953b044acc7ae40599b4 (commit)
       via  83974491df282581b9d5c4ded42153043ee53a8a (commit)
       via  34d2d2f08ed9891e50fd99d35645afdd038c5402 (commit)
       via  80cafde38274058f6194632d2719e64e9446f488 (commit)
       via  916b5702472d1282c6ef8895503cfb72a71b8113 (commit)
       via  978b6989d59e31c516421f82fbca64b99d48f741 (commit)
       via  d986a8006ff7ce7fbe6f50b3242167cefa94448b (commit)
       via  92efa457efce86a1b9c4dfa928d6c9e37c0736ea (commit)
       via  a0e045d60639b630b06214a3f05f9f353ed73a63 (commit)
       via  d6186ffa1f4b9889f2b30fd52fca1b26d2cbf3af (commit)
       via  87918bb4fd5b4a9d93e710454525300f372c9057 (commit)
       via  21e109d87e24c23dc88f39294a8fb0f83151f192 (commit)
       via  69513875e7847a5b6b89ffb58721daee9a49f06b (commit)
       via  2f16c2e9bb84027e6b42d74f7906db5ccdcd086d (commit)
       via  395e5abd368bba4ecd6a1934ad5ceeebc73ba4b3 (commit)
       via  7ad822a39190682bc159c2f9c21c25a4273d037c (commit)
       via  f02ce8d9f9c1c287915a8acef067cc2e30875b05 (commit)
       via  7c0d9cbbffbbe11bf1d863b7fe2c63cd6e86b584 (commit)
       via  2b1609fc05d829fa8bf10dda48de81396515ddc1 (commit)
       via  4ed586c011158cb60ba310fb20604184c5b25ebc (commit)
       via  0f4005f0838abb58e77a5a352225efebdb28464c (commit)
       via  da7f6125bd8dffa08c10a0fc7baeb812f8c6aada (commit)
       via  06efe9c467768a25c374b5d47dc8f1412874352d (commit)
       via  34ca92b99405c5d0361a64a2eb9a70d0f6f0c3cd (commit)
       via  076f8a295193344e77e1f9e37a908978688c3600 (commit)
       via  05aa7398db64e97090b0ba5fbccd4a31ebaf9c8c (commit)
       via  d47433523cced767f8c48fa39aa0556d552d323d (commit)
       via  478d8f99b33b22809f7e04245869a60507e8207b (commit)
       via  aa9a269b397af1c29de1f1fa40bd36b8d2759699 (commit)
       via  d86a273998952c09a569121c252512556b00d985 (commit)
       via  0283a956cd5f0a4522e2c3f1fa7155944464348e (commit)
       via  0532535cad4197145cef54918b641e373629b264 (commit)
       via  a33290b3dd6726e3d8c09975053e841338ec2b67 (commit)
      from  7604b2eede07b84b2f22c81a11db2078f8ffe3da (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8f41580e5d039d9549f7e73f51c2e82de4075015
Merge: f4d2f3b 02ce5d5
Author: Stefano Lattarini <address@hidden>
Date:   Wed Feb 15 18:31:33 2012 +0100

    Merge branch 'extra-dist-tests-ksh-bug'
    
    * extra-dist-tests-ksh-bug:
      tests: avoid ksh bug for wildcards in EXTRA_DIST

commit f4d2f3b76702ee43025c809d3588662859146943
Merge: de839e5 b42514b
Author: Stefano Lattarini <address@hidden>
Date:   Wed Feb 15 18:29:57 2012 +0100

    Merge branch 'yl-work-for-master'
    
    * yl-work-for-master: (44 commits)
      tests: truly use Lex and Yacc selected by configure
      news: fix grammaros related to Yacc
      yacc/lex tests: avoid spurious skips with non-GNU make
      fixup: remove double news entry
      tests: workaround for shells with broken 'set -e'
      tests: avoid spurious failure with non-bison yacc
      tests: fix spurious failures due to missing 'yywrap()' function
      fixup: list of yacc/lex tests was botched
      tests: work around bug#7884 in many yacc/lex tests
      yacc/lex tests: remove an unneeded workaround for bug#8485
      yacc/lex tests: avoid too much failures with FreeBSD make
      yacc-dist-nobuild.test: add reference to bug#7884
      yacc tests: fix bug in 'yacc-cxx.test'
      lex tests: fix spurious link errors on Solaris
      lex: "make clean" removes .c files from non-distributed .l
      lex tests: make test on Lex dependency tracking more "semantic"
      lex tests: remove erroneous check about ylwrap distribution
      yacc tests: "make clean" removes C++ files from non-distributed .y
      tests: add a workaround for automake bug#8485
      tests: add a couple of inter-tests reference
      ...

commit de839e5b0f4a95242f03f731110ac07e72cf146c
Author: Stefano Lattarini <address@hidden>
Date:   Wed Feb 15 10:16:36 2012 +0100

    cscope: is only expected to work with GNU make in VPATH setup
    
    The 'cscope' functionality does not properly handle VPATH rewrites;
    so we explicitly document that, for now, it is only ensured to work
    with GNU make when doing a VPATH build, and we adjust testsuite
    requirements accordingly.
    
    Issue revealed by a failure of 'cscope.test' with Solaris 10 CCS
    make.
    
    * doc/automake.texi (Tags): Document the limitations of the cscope
    support.  Couple of fixlets to formatting since we are at it.
    * tests/cscope.test: Converted to TAP, and thus moved ...
    * tests/cscope.tap: ... here.  Only run tests with VPATH builds when
    using GNU make.  Adjust so that no C, C++, Fortran or Java compiler,
    nor any Emacs program, will be required to run this test.
    * tests/list-of-tests.mk: Adjust.

commit 02ce5d5a0ce42563e8aa8ea03a977d35f3a30f72
Author: Stefano Lattarini <address@hidden>
Date:   Tue Feb 14 19:26:29 2012 +0100

    tests: avoid ksh bug for wildcards in EXTRA_DIST
    
    Some shells, like NetBSD 5.1 /bin/ksh, have a bug that causes
    wildcards resulting from an unquoted parameter expansion not to
    be expanded as expected in some cases:
    
        $ touch a b c d
        $ /bin/sh -c 'var="[ab]" && echo $var' # As expected.
        a b
        $ /bin/ksh -c 'var="[ab]" && echo $var' # Oops.
        [ab]
        $ /bin/ksh -c 'var="?" && echo $var' # But this as expected.
        a b c d
    
    This was causing a failure in our testsuite.  Work around that.
    
    See also:
    <http://lists.gnu.org/archive/html/automake-patches/2012-02/msg00149.html>
    
    * tests/extra11.test: Work around the described issue by using the
    $(wildcard) builtin in the EXTRA_DIST definition.  This is not a
    problem, since this test was assuming GNU make anyway.  Since we are
    at it, enhance coverage a little by also running "make distcheck".
    * tests/extra10.test: Similarly, enhance coverage by also running
    "make distcheck", and fix a minor bug in the process.  But continue
    using a "bare" wildcard expression in EXTRA_DIST, without involving
    the $(wildcard) builtin, to ensure coverage of similar usages "in
    the wild".

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog.11                                       |  590 +++++++++++++++++++-
 NEWS                                               |   17 +-
 automake.in                                        |   33 +-
 configure.ac                                       |   14 +
 doc/automake.texi                                  |   24 +-
 lib/am/yacc.am                                     |   11 +-
 tests/Makefile.am                                  |    4 +
 tests/check12.test                                 |    5 +-
 tests/cond35.test                                  |    2 +-
 tests/cscope.tap                                   |  168 ++++++
 tests/cscope.test                                  |  107 ----
 tests/defs                                         |   85 ++-
 tests/defs-static.in                               |    2 +
 tests/extra10.test                                 |   14 +-
 tests/extra11.test                                 |   26 +-
 tests/lex-clean-cxx.test                           |  125 +++++
 tests/lex-clean.test                               |  113 ++++
 tests/lex-depend-cxx.test                          |   94 ++++
 tests/{lex4.test => lex-depend-grep.test}          |   16 +-
 tests/lex-depend.test                              |   88 +++
 tests/lex-line.test                                |  122 ++++
 tests/{yacc-nodist.test => lex-nodist.test}        |   76 ++--
 tests/lex-pr204.test                               |   88 +++
 tests/lex-subobj-nodep.test                        |    4 +-
 tests/lex3.test                                    |    4 +-
 tests/lex5.test                                    |   11 +-
 tests/lexvpath.test                                |    4 +-
 tests/list-of-tests.mk                             |   45 +-
 tests/silent-lex-gcc.test                          |  144 -----
 tests/silent-lex-generic.test                      |  148 -----
 tests/silent-lex.test                              |  138 +++++
 tests/silent-many-gcc.test                         |   16 +-
 tests/silent-many-generic.test                     |   17 +-
 tests/silent-yacc-gcc.test                         |  143 -----
 tests/silent-yacc-generic.test                     |  143 -----
 tests/silent-yacc-headers.test                     |  175 ++++++
 tests/silent-yacc.test                             |  138 +++++
 tests/subpkg-yacc.test                             |   25 +-
 tests/subpkg.test                                  |    4 +-
 tests/suffix10.tap                                 |    2 +-
 tests/{yacc6.test => yacc-auxdir.test}             |   77 +---
 tests/yacc-basic.test                              |   44 ++-
 tests/yacc-bison-skeleton-cxx.test                 |  100 ++++
 ...-dist-nobuild.test => yacc-bison-skeleton.test} |   65 +--
 tests/yacc-clean-cxx.test                          |  165 ++++++
 tests/yacc-clean.test                              |   10 +-
 tests/yacc-cxx.test                                |  139 +++++
 tests/yacc-d-basic.test                            |   13 +-
 tests/yacc-d-cxx.test                              |  233 ++++++++
 tests/yacc-d-vpath.test                            |    8 +-
 tests/yacc-deleted-headers.test                    |  165 ++++++
 tests/yacc-depend.test                             |   85 +++
 tests/yacc-depend2.test                            |   89 +++
 tests/yacc-dist-nobuild-subdir.test                |    6 +-
 tests/yacc-dist-nobuild.test                       |    3 +-
 tests/yacc-line.test                               |  116 ++++
 tests/yacc-mix-c-cxx.test                          |  208 +++++++
 tests/yacc-nodist.test                             |   17 +-
 tests/{pr204.test => yacc-pr204.test}              |   14 +-
 tests/{ar-lib4.test => yacc-weirdnames.test}       |   45 +-
 tests/yacc4.test                                   |    5 +-
 tests/yacc8.test                                   |    4 +-
 tests/yaccdry.test                                 |    2 +-
 tests/yaccpp.test                                  |   41 ++-
 tests/yaccvpath.test                               |   12 +-
 tests/yflags-force-override.test                   |    2 -
 66 files changed, 3620 insertions(+), 1033 deletions(-)
 create mode 100755 tests/cscope.tap
 delete mode 100755 tests/cscope.test
 create mode 100755 tests/lex-clean-cxx.test
 create mode 100755 tests/lex-clean.test
 create mode 100755 tests/lex-depend-cxx.test
 rename tests/{lex4.test => lex-depend-grep.test} (66%)
 create mode 100755 tests/lex-depend.test
 create mode 100755 tests/lex-line.test
 copy tests/{yacc-nodist.test => lex-nodist.test} (52%)
 create mode 100755 tests/lex-pr204.test
 delete mode 100755 tests/silent-lex-gcc.test
 delete mode 100755 tests/silent-lex-generic.test
 create mode 100755 tests/silent-lex.test
 delete mode 100755 tests/silent-yacc-gcc.test
 delete mode 100755 tests/silent-yacc-generic.test
 create mode 100755 tests/silent-yacc-headers.test
 create mode 100755 tests/silent-yacc.test
 rename tests/{yacc6.test => yacc-auxdir.test} (51%)
 create mode 100755 tests/yacc-bison-skeleton-cxx.test
 copy tests/{yacc-dist-nobuild.test => yacc-bison-skeleton.test} (54%)
 create mode 100755 tests/yacc-clean-cxx.test
 create mode 100755 tests/yacc-cxx.test
 create mode 100755 tests/yacc-d-cxx.test
 create mode 100755 tests/yacc-deleted-headers.test
 create mode 100755 tests/yacc-depend.test
 create mode 100755 tests/yacc-depend2.test
 create mode 100755 tests/yacc-line.test
 create mode 100755 tests/yacc-mix-c-cxx.test
 rename tests/{pr204.test => yacc-pr204.test} (77%)
 copy tests/{ar-lib4.test => yacc-weirdnames.test} (57%)

diff --git a/ChangeLog.11 b/ChangeLog.11
index 9c2af31..c9efbcf 100644
--- a/ChangeLog.11
+++ b/ChangeLog.11
@@ -784,6 +784,45 @@
        * tests/remake-am-pr10111.test: Make executable.
        * tests/remake-m4-pr10111.test: Likewise.
 
+2011-12-27  Stefano Lattarini  <address@hidden>
+
+       yacc/lex tests: remove an unneeded workaround for bug#8485
+
+       * tests/yacc-d-cxx.test: Remove the workaround previously required
+       to avoid spurious failures due to automake bug#8485: that bug has
+       been solved with commit `v1.11-512-g40c3432'.
+
+2011-12-27  Stefano Lattarini  <address@hidden>
+
+       yacc/lex tests: avoid too much failures with FreeBSD make
+
+       In various Yacc/Lex tests, we used to run "make distcheck" commands
+       whose value was mostly dubious, and, even when it was there, was
+       very, very little.  The presence of these extra distchecks had two
+       disadvantages: it slowed down our already-too-slow testsuite even
+       more, and, much worse, caused a lot of extra failures with FreeBSD,
+       all due to automake bug#7884, which is already exposed by the test
+       case `yacc-dist-nobuild.test'.
+
+       We can improve this situation by simply removing "make distcheck"
+       calls from a few testcases, or making them conditional to the use
+       of GNU make.
+
+       * tests/lex-clean-cxx.test: Do not call "make distcheck".
+       * tests/lex-clean.test: Likewise.
+       * tests/yacc-clean-cxx.test: Likewise.
+       * tests/yacc-clean.test: Likewise.
+       * tests/yflags-force-override.test: Likewise.
+       * tests/yacc-nodist.test: Only run "make distcheck" if make
+       is GNU make.
+
+2011-12-15  Stefano Lattarini  <address@hidden>
+
+       Merge branch 'maint' into 'yacc-work'
+       * tests/silent-lex.test: Provide a dummy `yywrap()' function, to
+       avoid link errors on systems that doesn't provide a "lex library".
+       See also commit `v1.11-546-gca0ba5d'.
+
 2011-12-14  Stefano Lattarini  <address@hidden>
 
        readme: reference webpages for automake mailing lists
@@ -1983,6 +2022,10 @@
        complaints from the `sc_no_brace_variable_expansions' maintainer
        check.
 
+2011-10-18  Stefano Lattarini  <address@hidden>
+
+       * tests/yacc-dist-nobuild.test: Add reference to relevant bug#7884.
+
 2011-10-06  Stefano Lattarini  <address@hidden>
 
        tests: fix spurious error in 'test-extensions.test'
@@ -5699,6 +5742,34 @@
        example, simpler this time, but still inspired to real-world
        usage (the GNU coreutils testsuite).
 
+2011-06-28   Stefano Lattarini  <address@hidden>
+
+       yacc tests: fix bug in 'yacc-cxx.test'
+       * tests/yacc-cxx.test: Enable `errexit' shell flag (the lack of
+       which was masking the bug).
+       (bar.cxx): Rename to ...
+       (bar2.cxx): ... this, otherwise automake will (correctly) complain
+       that object `bar.o' is created by both `bar.cxx' and `bar.c++'.
+       (Makefile.am): Adjust.
+
+2011-06-28   Stefano Lattarini  <address@hidden>
+
+       lex tests: fix spurious link errors on Solaris
+       On Solaris 10, linking of lex-generated programs was failing in a
+       couple of lex tests with errors like this:
+         g++ -g -O2 -o joe joe.o -ll
+         Undefined symbol     first referenced in file
+         yywrap()             joe.o
+         ld: fatal: Symbol referencing errors. No output written to joe
+         collect2: ld returned 1 exit status
+       This change fixes it, also fixing at once potential problems for
+       systems that don't have a "lex library" (this happens for example
+       when cross-compiling from GNU/Linux to MinGW).
+       * tests/lex-depend-cxx.test (joe.ll, moe.l++): Define a dummy
+       `yywrap()' function.
+       * tests/lex-clean-cxx.test (mainfoo.cc, mainbar.cpp, mainbaz.c++,
+       mainqux.cxx): Likewise.
+
 2011-06-23  Stefano Lattarini  <address@hidden>
 
        docs: avoid a footnote, some related rewordings and improvements
@@ -7435,6 +7506,99 @@
        * tests/dejagnu4.test: Likewise.
        * tests/installdir.test: Likewise.
 
+2011-05-13   Stefano Lattarini  <address@hidden>
+
+       lex: "make clean" removes .c files from non-distributed .l
+       Previously, while automake did *not* distribute C source and header
+       files derived from non-distributed Lex sources, it still caused
+       them to be removed only by "make maintainer-clean" only, and not by
+       simply "make clean" or "make distclean".
+       This caused "make distcheck" to fail, unless the developer put
+       those generated .c files in CLEANFILES or in DISTCLEANFILES by
+       hand.
+       This change fixes this issue, by making non-distributed `.c' files
+       generated by non-distributed Lex sources cleaned by "make clean".
+       A similar problem for Yacc support had been fixed with the commit
+       v1.11-263-ged2c8bc.
+       * tests/automake.in (lang_lex_target_hook): Make C source files
+       derived from non-distributed Lex files cleaned by "make clean",
+       not only by "make maintainer-clean".
+       * tests/lex-clean.test: New test.
+       * tests/lex-clean-cxx.test: Likewise.
+       * tests/lex-nodist.test: Likewise.
+       * tests/lex-pr204.test: Likewise.
+       * tests/pr204.test: For consistency, renamed ...
+       * tests/yacc-pr204.test: ... to this, and updated to keep it
+       more in sync with 'lex-pr204.test'.
+       * tests/yacc-nodist.test: Updated to keep it more in sync with
+       'lex-nodist.test'.
+       * tests/Makefile.am (TESTS): Update.
+       * NEWS: Update.
+
+2011-05-13  Stefano Lattarini  <address@hidden>
+
+       lex tests: make test on Lex dependency tracking more "semantic"
+       * tests/lex4.test: Renamed ...
+       * tests/lex-depend-grep.test: ... to this, and extended.
+       * tests/lex-depend.test, tests/lex-depend-cxx.test: ... these
+       new tests.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-05-13  Stefano Lattarini  <address@hidden>
+
+       lex tests: remove erroneous check about ylwrap distribution
+       * tests/lex5.test: Do not check that the ylwrap script is *not*
+       distributed when there is only one lexer, as ylwrap is in fact
+       expected to distributed unconditionally (at least starting from
+       commit `Release-1-9-323-gc5881cc' of 19-08-2006).  Note that this
+       bogus check wasn't triggering any failure because it was done at
+       the wrong time (i.e. from the VPATH build directory), so that it
+       could never fail anyway.
+       Instead, check that ylwrap is distributed even when there is only
+       one lexer.
+       Since we are at it, add a couple of `ls -l' calls, to get better
+       debugging info.
+
+2011-05-13  Stefano Lattarini  <address@hidden>
+
+       yacc tests: "make clean" removes C++ files from non-distributed .y
+       * tests/yacc-clean-cxx.test: New test, sister of `yacc-clean.test'.
+       * tests/yacc-clean.test: Update heading comment to reference the
+       new sister test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-05-06  Stefano Lattarini  <address@hidden>
+
+       tests: add a workaround for automake bug#8485
+       * tests/yacc-d-cxx.test (Makefile.am): Add temporary workaround
+       for automake bug#8485.  The bug is still exposed by the testcase
+       'yacc-dist-nobuild-subdir.test'.
+
+2011-05-04  Stefano Lattarini  <address@hidden>
+
+       tests: add a couple of inter-tests reference
+       * tests/yacc-nodist.test, tests/pr204.test: These tests are
+       related, so add references to each other in heading comments.
+
+2011-05-04  Stefano Lattarini  <address@hidden>
+
+       lex tests: require just `lex' instead of `flex'
+       * tests/lex-subobj-nodep.test ($required): Require `lex',
+       not `flex', as this test is expected to work with any lex
+       implementation.
+       * tests/silent-lex.test: Likewise.
+
+2011-05-04  Stefano Lattarini  <address@hidden>
+
+       tests defs: use `skip_' for skipping yacc/lex related tests
+       * tests/defs.in (lex, bison): Use `skip_' to signal test skipping.
+
+2011-05-04  Stefano Lattarini  <address@hidden>
+
+       tests defs: merge cleanup
+       * tests/defs.in (flex, bison): Requirements removed, we have real
+       `lex' and `yacc' requirements now.
+
 2011-05-04  Stefano Lattarini  <address@hidden>
 
        tests defs: allow requirements for compilers (mostly dummy)
@@ -8079,9 +8243,19 @@
 
 2011-04-12  Stefano Lattarini  <address@hidden>
 
-       coverage: test for automake bug#8485 (known regression)
-       * tests/yacc-dist-nobuild-subdir.test: New test.
-       * tests/Makefile.am (TESTS, XFAIL_TESTS): Update.
+       lex/yacc tests: remove redundant $distdir definition
+       * tests/lex3.test ($distdir): Remove definition, that's already
+       done in `tests/defs'.
+       * tests/lexvpath.test: Likewise.
+       * tests/yacc-basic.test: Likewise.
+       * tests/yacc-cxx.test: Likewise.
+       * tests/yacc-d-basic.test: Likewise.
+       * tests/yacc-d-cxx.test: Likewise.
+       * tests/yacc-d-vpath.test: Likewise.
+       * tests/yacc-dist-nobuild-subdir.test: Likewise.
+       * tests/yacc-dist-nobuild.test: Likewise.
+       * tests/yacc-mix-c-cxx.test: Likewise.
+       * tests/yaccvpath.test: Likewise.
 
 2011-04-14  Stefano Lattarini  <address@hidden>
 
@@ -8134,6 +8308,416 @@
        * tests/vtexi3.test: Add comment explaining why we redefine
        $distdir in this test.
 
+2011-04-14  Stefano Lattarini  <address@hidden>
+
+       coverage: test lex-generated "#line" directives postprocessing
+       * tests/yacc-line.test: In heading comments, add reference to new
+       sister test `lex-line.test'.
+       * tests/lex-line.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-04-14  Stefano Lattarini  <address@hidden>
+
+       tests: minor improvements to a couple of yacc tests
+       * tests/yacc-auxdir.test: Avoid running autoconf, it's not
+       needed.
+       * tests/yacc-line.test: Also check that the yacc-generated C
+       and header files do not contain "#line" directives referencing
+       `y.tab.c' or `y.tab.h'.  Add a couple of explicative comments.
+
+2011-04-11  Stefano Lattarini  <address@hidden>
+
+       tests: split yacc6.test, for better separation and coverage
+       * tests/yacc6.test: Test removed, its content extended and split
+       into ...
+       * tests/yacc-auxdir.test, tests/yacc-depend.test,
+       tests/yacc-line.test: ... these new tests.
+       * tests/yacc-depend2.test: New test, exposes the failure that
+       FreeBSD used to encounter in yacc6.test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-04-11  Stefano Lattarini  <address@hidden>
+
+       tests: do not uselessly require GNU make or gcc in a few tests
+       * tests/lex3.test: Remove gcc from requirements, as any working C
+       compiler should be ok.  Consequently, do not clobber user CFLAGS.
+       Also, remove GNUmake from requirements; it was added (see commit
+       `Release-1-8-103-g0d2f592') because this test fails with FreeBSD
+       make due to VPATH issues -- but so do many other yacc-related and
+       lex-related tests currently, and requiring GNU make in all of
+       them would unacceptably reduce coverage.
+       * tests/lexvpath.test: Remove gcc from requirements, as any
+       working C compiler should be ok.
+       * tests/yacc4.test: Likewise.
+       * tests/yacc8.test: Likewise.
+       * tests/lex5.test: Likewise.  Also, do not require anymore GNU
+       make; to compensate, explicitly call "$MAKE Makefile" to update
+       the out-of-date Makefile if $MAKE is not GNU make.
+
+2011-04-12  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failure in test 'yacc-d-cxx.test'
+       * tests/yacc-d-cxx.test: Create ylwrap script before calling
+       automake for the first time, so that the script gets correctly
+       distributed.  Add checks verifying it indeed is.
+
+2011-04-12  Stefano Lattarini  <address@hidden>
+
+       tests cosmetics: remove redundant definitions of variable $tab
+       * tests/yacc-d-basic.test ($tab): Remove definition: it's already
+       defined in `tests/defs'.
+       * tests/yacc-d-cxx.test: Likewise.
+
+2011-04-12  Stefano Lattarini  <address@hidden>
+
+       yacc: add some tests on bison support (still xfailing)
+       Related to automake bug#7648 and PR automake/491.
+       * tests/bison-skeleton-cxx.test: New test.
+       * tests/bison-skeleton.test: New test.
+       * tests/Makefile.am (TESTS, XFAIL_TESTS): Updated.
+
+2011-04-12  Stefano Lattarini  <address@hidden>
+
+       coverage: test for automake bug#8485 (known regression)
+       * tests/yacc-dist-nobuild-subdir.test: New test.
+       * tests/Makefile.am (TESTS, XFAIL_TESTS): Update.
+
+2011-04-10  Stefano Lattarini  <address@hidden>
+
+       coverage: test mixed C/C++ yacc-generated parsers in the same dir
+       * tests/yacc-mix-c-cxx.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-04-10  Stefano Lattarini  <address@hidden>
+
+       cosmetics: fix typos and wording in some yacc tests
+       * tests/yacc-cxx.test (foo.cc): Clarify comment about the content
+       of this file being valid C++ but invalid C.
+       (parse1.yy): Likewise.  Also, remove redundant parentheses in a
+       `return' statement.
+       * tests/yacc-d-cxx.test (write_parse): Clarify comment about the
+       content of the generated files being valid C++ but invalid C.
+       (write_main): Likewise.
+       * tests/yacc-basic.test: Remove redundant parentheses in a
+       `return' statement.
+       * tests/yacc-d-vpath.test: Adjust spacing around curly brackets.
+       * tests/yaccvpath.test: Likewise.
+       * tests/yaccdry.test: Likewise.
+       * tests/yacc8.test: Likewise.
+       * tests/yacc4.test: Likewise.
+       Suggested by Ralf Wildenhues.
+
+2011-04-10  Stefano Lattarini  <address@hidden>
+
+       yacc: update NEWS and docs about yacc-generated headers extensions
+       * doc/automake.texi (Yacc and Lex): Document explicitly that
+       extensions of yacc-generated headers are modelled after the
+       extension of the corresponding sources.
+       * NEWS: Update.
+
+2011-01-28   Stefano Lattarini  <address@hidden>
+
+       yacc: extension of headers modelled after extension of sources
+       With this change, if '-d' is in *YFLAGS, a yacc input file named
+       foo.y++ will cause a foo.h++ header to be generated, instead of a
+       foo.h header.  Similarly for foo.ypp, foo.yxx and foo.yy.
+       This way, the name of the files generated by an automake-created
+       `ylwrap' invocation should be consistent with those generated by
+       a `bison -o' call.
+       Related to automake bug#7648 and PR automake/491.
+       * lib/am/yacc.am (am__yacc_c2h): New internal variable.
+       (?GENERIC?%EXT%%DERIVED-EXT%, ?!GENERIC?%OBJ%): Get the name of
+       the header dynamically at make runtime, so that its extension is
+       modelled after the extension of the source.
+       * automake.in (lang_yacc_target_hook): Adjust the calculation of
+       `$header' accordingly.
+       * tests/yacc-cxx.test: New test.
+       * tests/yacc-d-cxx.test: Likewise.
+       * tests/yacc-weirdnames.test: Likewise.
+       * tests/yacc-basic.test: Update comments.
+       * tests/yacc-d-basic.test: Likewise.
+       * tests/yaccpp.test: Updated and extended.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-01-29  Stefano Lattarini  <address@hidden>
+
+       tests: don't define YACC and LEX in the Makefiles
+       We don't want YACC and LEX defined as make variables, otherwise
+       the values determined at configure time will override those from
+       the environment, even in the make-spawned testcases.  For example,
+       before this change, with the following usage:
+         $ ./configure YACC=yacc
+         $ export YACC='bison -y'
+         $ make check
+       the testsuite would have ended up, very counterintuitively, with
+       YACC defined to 'yacc' in the testcases' environment.
+       * configure.ac: Call `AM_SUBST_NOTMAKE' on YACC and LEX.
+
+2011-01-29  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failures in lflags*.test
+       * tests/lflags.test: Remove 'LEX' from the environment, so
+       that it won't be erroneously picked up by `make -e'.
+       * tests/lflags2.test: Likewise.
+
+2011-01-29   Stefano Lattarini  <address@hidden>
+
+       coverage: more on 'yacc -d' and recovery from deleted headers
+       * tests/yacc-deleted-headers.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-01-29   Stefano Lattarini  <address@hidden>
+
+       tests: remove redundancy from silent lex/yacc tests
+       * tests/silent-yacc-gcc.test, tests/silent-yacc-generic.test: Merge
+       these two testcases into ...
+       * tests/silent-yacc.test: ... this new one, which doesn't fiddle
+       which dependency tracking, as that shouldn't impact on generation
+       of yacc-derived C source and header files (and, for what concerns
+       compilation of C files, is already tested in other testcases).
+       * tests/silent-lex-gcc.test, tests/silent-lex-generic.test: Merge
+       these two testcases into ...
+       * tests/silent-lex.test: ... this new test, for similar reasons.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-01-29  Stefano Lattarini  <address@hidden>
+           Ralf Wildenhues  <address@hidden>
+
+       tests init: better messages for 'yacc' and 'lex' requirements
+       * tests/defs.in: Give better diagnostic messages when a test must
+       be skipped to the unavailability of yacc or lex program.  Also,
+       improve syncing between code for requiring yacc and lex.
+
+2011-01-28  Stefano Lattarini  <address@hidden>
+
+       configure: look for a lex program to be used by the testsuite
+       This will allow the testcases requiring a 'lex' program to run also
+       with vendor/legacy lex implementations, not only with 'flex'.
+       * configure.ac: Look for a lex program, using AC_CHECK_PROGS.
+       * tests/defs.in: New required entry 'lex'.
+       ($LEX): Let the user override the lex program to be used by the
+       testsuite.
+       * tests/cond35.test ($required): Require 'lex', not 'flex'.
+       * tests/cond36.test: Likewise.
+       * tests/lexv3.test: Likewise.
+       * tests/lexv3.test: Likewise.
+       * tests/silent-lex-gcc.test: Likewise.
+       * tests/silent-lex-generic.test: Likewise.
+       * tests/silent-many-gcc.test: Likewise.
+       * tests/silent-many-generic.test:likewise.
+       * tests/lexvpath.test: Likewise, and fix typo in comments.
+
+2011-01-22   Stefano Lattarini  <address@hidden>
+
+       configure: look for a yacc program to be used by the testsuite
+       Instead of forcing the user to manually export 'YACC' in the
+       testsuite to use a non-bison yacc, we now look for a yacc program
+       at configure time, and use that as the default in the testsuite.
+       * configure.ac: Look for a yacc program, using AC_CHECK_PROGS.
+       * tests/defs.in: Updated to use the value of $YACC precomputed by
+       configure, unless the user overrides that in the environment.
+
+2011-01-22   Stefano Lattarini  <address@hidden>
+
+       tests: more coverage on yacc/lex silent-rules, plus minor cleanups
+       * tests/silent-yacc-gcc.test: Add sanity checks verifying that the
+       generated Makefile.in files really contains the non-generic rules
+       we expect.  Do not redundantly manually remove files we know to be
+       already removed "make maintainer-clean".
+       (Makefile.am): Ensure we cover also non-generic yacc rules, by
+       setting target-specific YFLAGS.
+       (sub/Makefile.am): Likewise.
+       * tests/silent-yacc-generic.test: Likewise.
+       * tests/silent-lex-gcc.test: Likewise, but with LFLAGS instead of
+       YFLAGS.
+       * tests/silent-lex-generic.test: Likewise.
+       * tests/silent-many-gcc.test: Likewise, but with both LFLAGS and
+       YFLAGS.  Also ...
+       (do_and_check_verbose_build): Remove redundant blank line.
+       * tests/silent-many-generic.test: Likewise.
+       * tests/silent-yacc-headers.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-01-22  Stefano Lattarini  <address@hidden>
+
+       tests: fix spurious failures in yflags*.test
+       * tests/yflags.test: Remove 'YACC' from the environment, so
+       that it won't be erroneously picked up by `make -e'.
+       * tests/yflags2.test: Likewise.
+
+2011-01-22   Stefano Lattarini  <address@hidden>
+
+       tests: cover yacc target-specific flags, and `-v' flag handling
+       * tests/yacc-basic.test: Also try to build a parser having `-v'
+       as target-specific flags.  Add a couple of `ls -l' commands, for
+       debugging.  Update and extend comments.  Escape literal dots in
+       grep regular expressions.
+
+2011-01-12   Stefano Lattarini  <address@hidden>
+
+       docs: clustered '-d' not recognized in YFLAGS
+       This change fixes automake bug#7828.
+       * doc/automake.texi (Yacc and Lex): Document that automake
+       recognizes '-d' in AM_YFLAGS only if it's not clustered with
+       other options.
+       From a report by Юрий Пухальский.
+
+2011-01-11  Stefano Lattarini  <address@hidden>
+
+       tests: do not force yacc-requiring tests to use bison
+       * tests/defs.in: New required entry 'yacc'.  Remove old
+       required entry 'bison'.
+       * tests/cond35.test ($required): Require yacc, not bison.
+       * tests/cond36.test: Likewise.
+       * tests/pr204.test: Likewise.
+       * tests/silent-many-gcc.test: Likewise.
+       * tests/silent-many-generic.test: Likewise.
+       * tests/silent-yacc-gcc.test: Likewise.
+       * tests/silent-yacc-generic.test: Likewise.
+       * tests/subpkg.test: Likewise.
+       * tests/suffix10.test: Likewise.
+       * tests/yacc-basic.test: Likewise.
+       * tests/yacc-clean.test: Likewise.
+       * tests/yacc-d-basic.test: Likewise.
+       * tests/yacc-d-vpath.test: Likewise.
+       * tests/yacc-dist-nobuild.test: Likewise.
+       * tests/yacc-nodist.test: Likewise.
+       * tests/yacc4.test: Likewise.
+       * tests/yacc6.test: Likewise.
+       * tests/yacc7.test: Likewise.
+       * tests/yacc8.test: Likewise.
+       * tests/yaccdry.test: Likewise.
+       * tests/yaccvpath.test: Likewise.
+
+2011-01-10   Stefano Lattarini  <address@hidden>
+
+       yacc: warn about conditional content in *YFLAGS variables
+       This change fixes automake bug#7804.
+       * automake.in (lang_yacc_target_hook): Warn if any of the relevant
+       *YFLAGS variables has conditional contents (not only a conditional
+       definition).  Related refactoring.
+       * NEWS: Updated.
+       * tests/yflags-conditional.test: Updated and extended.
+       * tests/yflags-conditional-force.test: New test.
+       * tests/Makefile.am (TESTS): Updated.
+
+2011-01-08   Stefano Lattarini  <address@hidden>
+
+       yacc: support variable expansions in *YFLAGS definition.
+       This change fixes automake bug#7800.
+       * automake.in (lang_yacc_target_hook): Use 'value_as_list_recursive'
+       instead of 'variable_value' to get the value of *YFLAGS variables.
+       Related changes.
+       ($DASH_D_PATTERN): Removed.
+       * tests/Makefile.am (XFAIL_TESTS): Remove yflags-var-expand.test.
+       * tests/yacc-clean.test: Remove workaround for now-fixed bug.
+       * NEWS: Update.
+
+2011-01-08   Stefano Lattarini  <address@hidden>
+
+       yacc: more tests on *YFLAGS support
+       * tests/yflags-var-expand.test: New test, still xfailing.  It
+       exposes automake bug#7800 -- "automake fails to honor `-d' in
+       AM_YFLAGS when variable expansions are involved".
+       * tests/yflags-d-false-positive.test: New test, checking that
+       automake do not spuriously see `-d' in *YFLAGS when that isn't
+       really there.
+       * tests/yflags-force-override.test: New test, checking that
+       automake can cope with definition of the YFLAGS variable in
+       Makefile.am (even if that is an extremely bad practice, as that
+       variable is user-reserved).
+       * tests/yflags-cmdline-override.test: New test, checking that
+       automake can cope with user-redefinition of YFLAGS at configure
+       time and/or at make time.
+       * tests/yflags-conditional.test: New test, checks that automake
+       warns on conditionally-defined *YFLAGS variables.
+       * tests/Makefile.am (TESTS, XFAIL_TESTS): Update.
+
+2011-01-08   Stefano Lattarini  <address@hidden>
+
+       yacc: extend and improve tests
+       * tests/yacc-basic.test: Also check that the intermediate C file
+       is mentioned in the generated Makefile.in, and that it is created
+       by the first make invocation.
+       * tests/yacc3.test: Test removed, superseded by ...
+       * tests/yacc-d-basic.test: ... this new test.
+       * tests/yacc2.test: Add reference to that new test in the heading
+       comments.
+       * tests/yacc-d-vpath.test: New test.
+       * tests/yaccvpath.test: Updated heading comments.  Do not require
+       gcc anymore, as any working C compiler should be enough.  Remove
+       redundant comments.
+       * tests/yacc-nodist.test: New test.
+       * tests/yacc-dist-nobuild.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
+2010-12-13  Stefano Lattarini  <address@hidden>
+
+       Extend, fix and improve tests on Lex and Yacc support.
+       * tests/lexcpp.test: New test script, on support for Lex + C++.
+       * tests/lexvpath.test: New test script, test build and rebuild
+       rules for lexers in VPATH setup.
+       * tests/yacc-basic.test: New test script, run simple "semantic"
+       checks on basic Yacc support (similarly to what lex3.test does
+       for Lex support).
+       * tests/lex.test: Don't create useless dummy source file joe.l.
+       Remove extra blank lines.
+       * tests/lex4.test: Add trailing `:' command.  Do not create dummy
+       useless lex source file.
+       * tests/lex2.test: Likewise.  Call automake with the `-a' option,
+       so that it doesn't fail for the absence of `ylwrap' script.  Make
+       grepping of automake stderr stricter.
+       * tests/yacc7.test: Add trailing `:' command.  Enable `errexit'
+       shell flag earlier (just after having sourced ./defs).
+       * tests/yacc4.test: Likewise.  Also ...
+       (configure.in): Use pre-populated skeleton set up by ./defs,
+       instead of writing one from scratch.
+       Other minor cosmetic changes.
+       * tests/yacc5.test: Likewise.
+       * tests/yaccvpath.test: Likewise. Also ...
+       ($distdir): New variable.
+       Use it throughout.
+       * tests/lex5.test: Likewise.
+       * tests/lex3.test: Likewise.  Check the distdir, rather than
+       grepping the distribution tarball.  Extend the test on the
+       created binary, and be sure to avoid hangs.  Add some comments.
+       * tests/yacc.test: Use stricter grepping.  Add trailing `:'.
+       * tests/yacc6.test: Likewise.
+       * tests/yacc3.test: Likewise.  Do not create the unused file
+       `Makefile.sed'.  Remove useless rules from Makefile.am.  Other
+       minor cosmetic changes.
+       * tests/yacc2.test: Make grepping of generated `Makefile.in' and
+       of automake error messages stricter.  Do not redirect output of
+       grep to /dev/null.  Move call to aclocal earlier.  Reduce the
+       number of empty blank lines.  Fix a typo in comments.
+       * tests/yacc8.test: Fixed bugs that reduced the completeness of
+       the tests.  Added trailing `:' command.
+       (configure.in): Use pre-populated skeleton set up by ./defs,
+       instead of writing one from scratch.
+       * tests/yaccpp.test: Test also extensions `.y++', `.ypp', and
+       `.yxx', rather than only `.yy'.
+       * tests/Makefile.am (TESTS): Update.
+
+2011-01-07   Stefano Lattarini  <address@hidden>
+
+       yacc: "make clean" removes .c and .h files from non-distributed .y
+       Previously, while automake did *not* distribute C source and header
+       files derived from non-distributed Yacc sources, it still caused
+       them to be removed only by "make maintainer-clean" only, and not by
+       simply "make clean" or "make distclean".
+       This caused "make distcheck" to fail, unless the developer put
+       those generated .c and .h files in CLEANFILES or in DISTCLEANFILES
+       by hand.
+       This change fixes this issue, by making non-distributed `.c' and
+       `.h' files generated by non-distributed Yacc sources cleaned by
+       "make clean".
+       * tests/automake.in (lang_yacc_target_hook): Make C source and
+       header files derived from non-distributed Yacc files cleaned by
+       "make clean", not only by "make maintainer-clean".
+       * tests/yacc-clean.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+       * NEWS: Update.
+
 2011-04-11  Stefano Lattarini  <address@hidden>
 
        depcomp: fix bugs in tests and in the depcomp script
diff --git a/NEWS b/NEWS
index 54d9ca5..856e965 100644
--- a/NEWS
+++ b/NEWS
@@ -100,6 +100,20 @@ New in 1.11a:
   - Initial and still experimental support for the TAP test protocol is
     now provided.
 
+* Changes to Yacc and Lex support:
+
+  - C source and header files derived from non-distributed Yacc and/or
+    Lex sources are now removed by a simple "make clean" (while they were
+    previously removed only by "make maintainer-clean").
+
+  - Slightly backward-incompatible change, relevant only for use of Yacc
+    with C++: the extensions of the header files produced by the Yacc
+    rules are now modelled after the extension of the corresponding
+    sources.  For example, yacc files named "foo.y++" and "bar.yy" will
+    produce header files named "foo.h++" and "bar.hh" respectively, where
+    they would have previously produced header files named simply "foo.h"
+    and "bar.h".  This change offers better compatibility with `bison -o'.
+
 * Miscellaneous changes:
 
   - The `dist' and `dist-all' targets now can run compressors in parallel.
@@ -127,9 +141,6 @@ New in 1.11a:
     overwriting the foo_DEPENDENCIES variable, which is normally computed
     by automake.
 
-  - C source and header files derived from non-distributed Yacc sources
-    are now removed by "make clean", not only by "make maintainer-clean".
-
   - The warnings in the category `extra-portability' are now enabled by
     `-Wall'.  In previous versions, one has to use `-Wextra-portability'
     to enable them.
diff --git a/automake.in b/automake.in
index 940e770..98ec2bb 100644
--- a/automake.in
+++ b/automake.in
@@ -5956,12 +5956,26 @@ sub lang_yacc_target_hook
 
     if ($yflags_contains_minus_d)
       {
-       (my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//;
-       my $header = $output_base . '.h';
-
        # Found a `-d' that applies to the compilation of this file.
        # Add a dependency for the generated header file, and arrange
        # for that file to be included in the distribution.
+
+       # The extension of the output file (e.g., `.c' or `.cxx').
+       # We'll need it to compute the name of the generated header file.
+       (my $output_ext = basename ($output)) =~ s/.*(\.[^.]+)$/$1/;
+
+       # We know that a yacc input should be turned into either a C or
+       # C++ output file.  We depend on this fact (here and in yacc.am),
+       # so check that it really holds.
+       my $lang = $languages{$extension_map{$output_ext}};
+       prog_error "invalid output name `$output' for yacc file `$input'"
+         if (!$lang || ($lang->name ne 'c' && $lang->name ne 'cxx'));
+
+       (my $header_ext = $output_ext) =~ s/c/h/g;
+        # Quote $output_ext in the regexp, so that dots in it are taken
+        # as literal dots, not as metacharacters.
+       (my $header = $output) =~ s/\Q$output_ext\E$/$header_ext/;
+
        foreach my $cond (Automake::Rule::define (${header}, 'internal',
                                                  RULE_AUTOMAKE, TRUE,
                                                  INTERNAL))
@@ -5993,13 +6007,12 @@ sub lang_yacc_target_hook
 # compile a lex file.
 sub lang_lex_target_hook
 {
-    my ($self, $aggregate, $output, $input) = @_;
-    # If the files are built in the build directory, then we want to
-    # remove them with `make clean'.  If they are in srcdir they
-    # shouldn't be touched.  However, we can't determine this
-    # statically, and the GNU rules say that yacc/lex output files
-    # should be removed by maintainer-clean.  So that's what we do.
-    $clean_files{$output} = MAINTAINER_CLEAN;
+    my ($self, $aggregate, $output, $input, %transform) = @_;
+    # The GNU rules say that yacc/lex output files should be removed
+    # by maintainer-clean.  However, if the files are not distributed,
+    # then we want to remove them with "make clean"; otherwise,
+    # "make distcheck" will fail.
+    $clean_files{$output} = $transform{'DIST_SOURCE'} ? MAINTAINER_CLEAN : 
CLEAN;
 }
 
 # This is a helper for both lex and yacc.
diff --git a/configure.ac b/configure.ac
index e461e17..badf9bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,6 +112,20 @@ AC_CHECK_PROG([TEX], [tex], [tex])
 # for input from the terminal.
 AM_RUN_LOG([$TEX --version </dev/null])
 
+# The test suite will skip some tests if no lex or yacc program is
+# available.
+# We don't use AC_PROG_LEX nor AC_PROG_YACC here because:
+#  1. we don't want flex (resp. bison) to be preferred to system lex
+#     (resp. system yacc);
+#  2. we don't want $LEX (resp. $YACC) to be defined to ':' (resp. 'yacc')
+#     by default;
+#  3. we prefer not to have the variables YFLAGS, LEX_OUTPUT_ROOT and
+#     LEXLIB to be calculated and/or AC_SUBST'd;
+#  4. we prefer that the YACC and LEX variables are not reported in the
+#     configure help screen.
+AC_CHECK_PROGS([YACC], [yacc byacc 'bison -y'], [false])
+AC_CHECK_PROGS([LEX], [lex flex], [false])
+
 # Generate man pages.
 AM_MISSING_PROG([HELP2MAN], [help2man])
 
diff --git a/doc/automake.texi b/doc/automake.texi
index 9c148f9..0679ee2 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -6173,12 +6173,16 @@ cause the intermediate file to be named @file{foo.c} 
(as opposed to
 @file{y.tab.c}, which is more traditional).
 
 The extension of a yacc source file is used to determine the extension
-of the resulting C or C++ file.  Files with the extension @file{.y}
-will be turned into @file{.c} files; likewise, @file{.yy} will become
address@hidden; @file{.y++}, @file{c++}; @file{.yxx}, @file{.cxx}; and
address@hidden, @file{.cpp}.
-
-Likewise, lex source files can be used to generate C or C++; the
+of the resulting C or C++ source and header files.  Note that header
+files are generated only when the @option{-d} Yacc option is used; see
+below for more information about this flag, and how to specify it.
+Files with the extension @file{.y} will thus be turned into @file{.c}
+sources and @file{.h} headers; likewise, @file{.yy} will become
address@hidden and @file{.hh}, @file{.y++} will become @file{c++} and
address@hidden, @file{.yxx} will become @file{.cxx} and @file{.hxx},
+and @file{.ypp} will become @file{.cpp} and @file{.hpp}.
+
+Similarly, lex source files can be used to generate C or C++; the
 extensions @file{.l}, @file{.ll}, @file{.l++}, @file{.lxx}, and
 @file{.lpp} are recognized.
 
@@ -10350,10 +10354,10 @@ is the name of the program to invoke (by default 
@command{ctags});
 @code{CTAGSFLAGS} can be used by the user to pass additional flags,
 and @code{AM_CTAGSFLAGS} can be used by the @file{Makefile.am}.
 
address@hidden id
 Automake will also generate an @code{ID} rule that will run
 @command{mkid} on the source.  This is only supported on a
 directory-by-directory basis.
address@hidden id
 
 Similarly, the @code{cscope} rule will create a list of all the source
 files in the tree and run @command{cscope} to build an inverted index
@@ -10361,7 +10365,11 @@ database.  The variable @code{CSCOPE} is the name of 
the program to invoke
 (by default @command{cscope}); @code{CSCOPEFLAGS} and
 @code{CSCOPE_ARGS} can be used by the user to pass additional flags and
 file names respectively, while @code{AM_CSCOPEFLAGS} can be used by the
address@hidden
address@hidden  Note that, currently, the Automake-provided
address@hidden support, when used in a VPATH build, might not work well
+with non-GNU make implementations (especially with make implementations
+performing @ref{Automatic Rule Rewriting, , VPATH rewrites, autoconf,
+The Autoconf Manual}).
 
 Finally, Automake also emits rules to support the
 @uref{http://www.gnu.org/software/global/, GNU Global Tags program}.
diff --git a/lib/am/yacc.am b/lib/am/yacc.am
index 6d35cd4..8ad4074 100644
--- a/lib/am/yacc.am
+++ b/lib/am/yacc.am
@@ -33,16 +33,19 @@
 ## distributed or not.  We cannot have a generic rule that works in
 ## both cases, so we ensure in automake that nodist_ parsers always
 ## use non-generic rules.
-if %?MAINTAINER-MODE%
 if %?FIRST%
+if %?MAINTAINER-MODE%
 @address@hidden = test -f $@ ||
-endif %?FIRST%
 endif %?MAINTAINER-MODE%
+## The 's/c$/h/' substitution *must* be the last one.
+am__yacc_c2h = sed -e s/cc$$/hh/ -e s/cpp$$/hpp/ -e s/cxx$$/hxx/ \
+                  -e s/c++$$/h++/ -e s/c$$/h/
+endif %?FIRST%
 
 ?GENERIC?%EXT%%DERIVED-EXT%:
 ?!GENERIC?%OBJ%: %SOURCE%
-?GENERIC?      %VERBOSE%$(am__skipyacc) $(SHELL) $(YLWRAP) %SOURCE% y.tab.c 
%OBJ% y.tab.h %BASE%.h y.output %BASE%.output -- %COMPILE%
+?GENERIC?      %VERBOSE%$(am__skipyacc) $(SHELL) $(YLWRAP) %SOURCE% y.tab.c 
%OBJ% y.tab.h `echo %OBJ% | $(am__yacc_c2h)` y.output %BASE%.output -- %COMPILE%
 ?!GENERIC?     %VERBOSE% \
 ?!GENERIC??DIST_SOURCE?        $(am__skipyacc) \
 ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
-?!GENERIC?     $(SHELL) $(YLWRAP) `test -f '%SOURCE%' || echo 
'$(srcdir)/'`%SOURCE% y.tab.c %OBJ% y.tab.h %BASE%.h y.output %BASE%.output -- 
%COMPILE%
+?!GENERIC?     $(SHELL) $(YLWRAP) `test -f '%SOURCE%' || echo 
'$(srcdir)/'`%SOURCE% y.tab.c %OBJ% y.tab.h `echo %OBJ% | $(am__yacc_c2h)` 
y.output %BASE%.output -- %COMPILE%
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 873c08e..e8da6ce 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -36,6 +36,8 @@ TESTS = ## Will be updated later.
 
 XFAIL_TESTS = \
 all.test \
+yacc-bison-skeleton-cxx.test \
+yacc-bison-skeleton.test \
 cond17.test \
 gcj6.test \
 override-conditional-2.test \
@@ -151,6 +153,8 @@ do_subst = sed \
   -e 's|@address@hidden|$(GNU_CXXFLAGS)|g' \
   -e 's|@address@hidden|$(GNU_FFLAGS)|g' \
   -e 's|@address@hidden|$(GNU_FCFLAGS)|g' \
+  -e 's|@address@hidden|$(YACC)|g' \
+  -e 's|@address@hidden|$(LEX)|g' \
   -e 's|@address@hidden|$(TEX)|g' \
   -e 's|@address@hidden|$(MODIFICATION_DELAY)|g' \
   -e 's|@address@hidden|$(am_AUTOCONF)|g' \
diff --git a/tests/check12.test b/tests/check12.test
index 88235f8..92e4a69 100755
--- a/tests/check12.test
+++ b/tests/check12.test
@@ -140,9 +140,7 @@ for vpath in : false; do
     test -f test-suite.log
     test -f a.log
     test -f b.log
-  else
-    :
-  fi
+  else :; fi
   grep 'check-local succeeded :-)' local.log
 
   cp -f config.status config-status.sav
@@ -179,6 +177,7 @@ for vpath in : false; do
     grep '^FAIL: b$' test-suite.log
     grep '^b\.test: exit status: 1$' test-suite.log
     grep '^a\.test' test-suite.log && Exit 1
+    : For shells with busted 'set -e'.
   else :; fi
 
   CHECKLOCAL_EXIT_STATUS=1 $MAKE check && Exit 1
diff --git a/tests/cond35.test b/tests/cond35.test
index f2b0ded..074d110 100755
--- a/tests/cond35.test
+++ b/tests/cond35.test
@@ -17,7 +17,7 @@
 # Check rules output for parser defined conditionally.
 # Report from Roman Fietze.
 
-required='cc flex yacc'
+required='cc lex yacc'
 . ./defs || Exit 1
 
 cat >>configure.in <<'EOF'
diff --git a/tests/cscope.tap b/tests/cscope.tap
new file mode 100755
index 0000000..0269dff
--- /dev/null
+++ b/tests/cscope.tap
@@ -0,0 +1,168 @@
+#! /bin/sh
+# Copyright (C) 2009, 2010, 2011, 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/>.
+
+# Test cscope functionality.
+
+. ./defs || Exit 1
+
+plan_ 18
+
+ocwd=`pwd` || fatal_ "getting top-level directory"
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_SUBST([CC],  [who-cares])
+AC_SUBST([CXX], [who-cares])
+AC_SUBST([FC],  [who-cares])
+AC_SUBST([GCJ], [who-cares])
+AM_PATH_LISPDIR
+AC_OUTPUT
+END
+
+mkdir sub sub/subsub
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c bar.cpp baz.f90
+lisp_LISP = foo.el
+EXTRA_DIST = foo.el
+END
+
+cat > sub/Makefile.am <<'END'
+bin_PROGRAMS = bar
+bar_SOURCES = subsub/dist.c
+nodist_bar_SOURCES = subsub/gen.c
+subsub/gen.c:
+       $(MKDIR_P) subsub
+       echo 'int generated_subsub () { return 0; }' > $@
+CLEANFILES = subsub/gen.c
+END
+
+echo 'int foo_func () { return 0; }' > foo.c
+echo 'int main () { return 0; }' > bar.cpp
+cat > baz.f90 <<'END'
+      subroutine baz
+      end
+END
+: > foo.el
+echo 'int main () { return 0; }' > sub/subsub/dist.c
+
+$ACLOCAL || fatal_ "aclocal failed"
+$AUTOCONF || fatal_ "autoconf failed"
+$AUTOMAKE -i -a || fatal_ "automake -i -a failed"
+
+# Sun cscope is interactive without redirection.
+if cscope --version </dev/null; then
+  have_cscope=yes
+else
+  have_cscope=no
+fi
+
+test_cleanup ()
+{
+  r=ok
+  if test -f configure; then
+    # In-tree build.
+    $MAKE distclean
+  else
+    # VPATH build.
+    $MAKE distcleancheck
+  fi \
+    && test ! -f cscope.files \
+    && test ! -f cscope.out \
+    && test ! -f cscope.in.out \
+    && test ! -f cscope.po.out \
+    || r='not ok'
+  result_ "$r" "[$pfx] make distcheck"
+}
+
+test_cscope ()
+{
+  r=ok
+  $MAKE -n cscope || r='not ok'
+  result_ "$r" "[$pfx] make -n cscope"
+
+  if test $have_cscope = no; then
+    # For later tests.
+    touch cscope.files cscope.out cscope.in.out cscope.po.out
+    skip_row_ 3 -r "no cscope program avaiable"
+    return 0
+  fi
+
+  r=ok
+  $MAKE cscope 2>stderr || r='not ok'
+  cat stderr >&2
+  grep 'cannot find file' stderr && r='not ok'
+  rm -f stderr
+  result_ "$r" "[$pfx] make cscope"
+
+  r=ok
+  test -f cscope.files \
+    && $FGREP foo.c cscope.files \
+    && $FGREP bar.cpp cscope.files \
+    && $FGREP sub/subsub/dist.c cscope.files \
+    && $FGREP sub/subsub/gen.c cscope.files \
+    || r='not ok'
+  result_ "$r" "[$pfx] cscope.files looks correct"
+
+  r=ok
+  # cscope.files might not exist of the earlier "make cscope" failed.
+  cp cscope.files cscope.files1 \
+    && $MAKE cscope \
+    && diff cscope.files cscope.files1 \
+    || r='not ok'
+  rm -f cscope.files1
+  result_ "$r" "[$pfx] second \"make cscope\" is consistent"
+}
+
+my_configure ()
+{
+  command_ok_ "[$pfx] configure" \
+              "$1"/configure EMACS=no --with-lispdir=/who/cares
+}
+
+if using_gmake; then
+
+  cd "$ocwd"
+  pfx="relative VPATH"
+  mkdir build
+  cd build
+  my_configure ..
+  test_cscope
+  test_cleanup
+
+  cd "$ocwd"
+  pfx="absolute VPATH"
+  mkdir build2
+  cd build2
+  my_configure "$ocwd"
+  test_cscope
+  test_cleanup
+
+else
+
+  skip_row_ 12 -r "cscope in VPATH required GNU make"
+
+fi
+
+cd "$ocwd"
+pfx="in-tree build"
+my_configure .
+test_cscope
+test_cleanup
+
+:
diff --git a/tests/cscope.test b/tests/cscope.test
deleted file mode 100755
index 859653b..0000000
--- a/tests/cscope.test
+++ /dev/null
@@ -1,107 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2009, 2010, 2011 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/>.
-
-# Test cscope functionality.
-
-required=
-. ./defs || Exit 1
-
-cat >> configure.in << 'END'
-AC_CONFIG_FILES([sub/Makefile])
-AC_PROG_CC
-AC_PROG_CXX
-AC_PROG_FC
-AM_PROG_GCJ
-AM_PATH_LISPDIR
-AC_OUTPUT
-END
-
-mkdir sub sub/subsub
-
-cat >Makefile.am <<'END'
-SUBDIRS = sub
-bin_PROGRAMS = foo
-foo_SOURCES = foo.c bar.cpp baz.f90
-lisp_LISP = foo.el
-EXTRA_DIST = foo.el
-END
-
-cat >sub/Makefile.am <<'END'
-bin_PROGRAMS = bar
-bar_SOURCES = subsub/dist.c
-nodist_bar_SOURCES = subsub/gen.c
-subsub/gen.c:
-       $(MKDIR_P) subsub
-       echo 'int generated_subsub () { return 0; }' > $@
-CLEANFILES = subsub/gen.c
-END
-
-echo 'int foo_func () { return 0; }' > foo.c
-echo 'int main () { return 0; }' > bar.cpp
-cat > baz.f90 <<'END'
-      subroutine baz
-      end
-END
-: >foo.el
-echo 'int main () { return 0; }' > sub/subsub/dist.c
-
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE --add-missing
-
-mkdir build
-cd build
-../configure || Exit 77
-
-$MAKE -n cscope
-
-: ${CSCOPE=cscope}
-( $CSCOPE --version ) >/dev/null 2>&1 || Exit 77
-
-$MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; }
-cat stderr >&2
-grep 'cannot find file' stderr && Exit 1
-
-test -f cscope.files
-$FGREP foo.c cscope.files
-$FGREP bar.cpp cscope.files
-$FGREP sub/subsub/dist.c cscope.files
-$FGREP sub/subsub/gen.c cscope.files
-
-cp cscope.files cscope.files1
-$MAKE cscope
-diff cscope.files cscope.files1
-
-$MAKE distclean
-test ! -f cscope.files
-test ! -f cscope.out
-test ! -f cscope.in.out
-test ! -f cscope.po.out
-
-
-`pwd`/../configure || Exit 77
-
-$MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; }
-cat stderr >&2
-grep 'cannot find file' stderr && Exit 1
-$MAKE || Exit 77
-$MAKE distclean
-
-cd ..
-./configure
-$MAKE distcheck
-
-:
diff --git a/tests/defs b/tests/defs
index 03766ea..819a96a 100644
--- a/tests/defs
+++ b/tests/defs
@@ -444,6 +444,52 @@ END
 }
 am__can_chain_suffix_rules="" # Avoid interferences from the environment.
 
+# useless_vpath_rebuild
+# ---------------------
+# Tell whether $MAKE suffers of the bug triggering automake bug#7884.
+# For example, this happens with FreeBSD make, since in a VPATH build
+# it tends to rebuilt files for which there is an explicit or even just
+# a suffix rule, even if said files are already available in the VPATH
+# directory.
+useless_vpath_rebuild ()
+{
+  if test -z "$am__useless_vpath_rebuild"; then
+    if using_gmake; then
+      am__useless_vpath_rebuild=no
+      return 1
+    fi
+    mkdir am__vpath.dir$$
+    cd am__vpath.dir$$
+    touch foo.a foo.b bar baz
+    mkdir build
+    cd build
+    unindent > Makefile << 'END'
+        .SUFFIXES: .a .b
+        VPATH = ..
+        all: foo.b baz
+        .PHONY: all
+        .a.b: ; cp $< $@
+        baz: bar ; cp ../baz bar
+END
+    if $MAKE all && test ! -f foo.b && test ! -f bar; then
+      am__useless_vpath_rebuild=no
+    else
+      am__useless_vpath_rebuild=yes
+    fi
+    cd ../..
+    rm -rf am__vpath.dir$$
+  fi
+  case $am__useless_vpath_rebuild in
+    yes) return 0;;
+     no) return 1;;
+     "") ;;
+      *) fatal_ "no_useless_builddir_remake: internal error";;
+  esac
+}
+am__useless_vpath_rebuild=""
+
+yl_distcheck () { useless_vpath_rebuild || $MAKE distcheck ${1+"$@"}; }
+
 # seq_ - print a sequence of numbers
 # ----------------------------------
 # This function simulates GNU seq(1) portably.  Valid usages:
@@ -935,36 +981,23 @@ do
       texi2dvi -o /dev/null --version \
         || skip_all_ "required program \`texi2dvi' not available"
       ;;
-    flex)
-      # Since flex is required, we pick LEX for ./configure.
-      LEX=flex
+    lex)
+      test x"$LEX" = x"false" && skip_all_ "lex not found or disabled"
       export LEX
+      ;;
+    yacc)
+      test x"$YACC" = x"false" && skip_all_ "yacc not found or disabled"
+      export YACC
+      ;;
+    flex)
+      LEX=flex; export LEX
       echo "$me: running flex --version"
       flex --version || skip_all_ "required program \`flex' not available"
       ;;
-    lex)
-      test "$LEX" = false && skip_all_ "no Lex program available"
-      if test -z "$LEX"; then
-        # The user hasn't explicitly specified any lex program in the
-        # environment, so we try to use flex, skipping the test if it's
-        # not found.
-        LEX=flex
-        export LEX
-        echo "$me: running flex --version"
-        flex --version || skip_all_ "required program \`flex' not available"
-      fi
-      ;;
-    yacc)
-      test "$YACC" = false && skip_all_ "no Yacc program available"
-      if test -z "$YACC"; then
-        # The user hasn't explicitly specified any yacc program in the
-        # environment, so we try to use bison, skipping the test if it's
-        # not found.
-        YACC='bison -y'
-        export YACC
-        echo "$me: running bison --version"
-        bison --version || skip_all_ "required program \`bison' not available"
-      fi
+    bison)
+      YACC='bison -y'; export YACC
+      echo "$me: running bison --version"
+      bison --version || skip_all_ "required program \`bison' not available"
       ;;
     *)
       # Generic case: the tool must support --version.
diff --git a/tests/defs-static.in b/tests/defs-static.in
index 79484a9..826c08a 100644
--- a/tests/defs-static.in
+++ b/tests/defs-static.in
@@ -146,6 +146,8 @@ SHELL=${AM_TESTSUITE_SHELL-'@SHELL@'}; export SHELL
 # that automake testsuite, if they are available.
 PERL=${AM_TESTSUITE_PERL-${PERL-'@PERL@'}}
 MAKE=${AM_TESTSUITE_MAKE-${MAKE-'make'}}
+YACC=${AM_TESTSUITE_YACC-${YACC-'@YACC@'}}
+LEX=${AM_TESTSUITE_LEX-${LEX-'@LEX@'}}
 AUTOCONF=${AM_TESTSUITE_AUTOCONF-${AUTOCONF-'@am_AUTOCONF@'}}
 AUTOM4TE=${AM_TESTSUITE_AUTOM4TE-${AUTOM4TE-'@am_AUTOM4TE@'}}
 AUTORECONF=${AM_TESTSUITE_AUTORECONF-${AUTORECONF-'@am_AUTORECONF@'}}
diff --git a/tests/extra10.test b/tests/extra10.test
index f44b1e2..a635f9c 100755
--- a/tests/extra10.test
+++ b/tests/extra10.test
@@ -16,6 +16,8 @@
 
 # Check that wildcards in EXTRA_DIST are honoured.
 # Suggested by observations from Braden McDaniel.
+# See also sister test 'extra11.test', that check a similar usage
+# with the involvement of the $(wildcard) GNU make builtin.
 
 required=GNUmake
 . ./defs || Exit 1
@@ -23,12 +25,16 @@ required=GNUmake
 echo AC_OUTPUT >> configure.in
 
 cat > Makefile.am <<'END'
-EXTRA_DIST=*.foo
+EXTRA_DIST = *.foo
 .PHONY: test
 test: distdir
        diff a.foo $(distdir)/a.foo
        diff b.foo $(distdir)/b.foo
        test ! -r $(distdir)/c.bar
+check-local:
+       test -f $(srcdir)/a.foo
+       test -f $(srcdir)/b.foo
+       test ! -r $(srcdir)/c.bar
 END
 
 $ACLOCAL
@@ -37,6 +43,10 @@ $AUTOCONF
 
 echo aaa > a.foo
 echo bbb > b.foo
-echo ccc > c.foo
+echo ccc > c.bar
 ./configure
 $MAKE test
+
+$MAKE distcheck
+
+:
diff --git a/tests/extra11.test b/tests/extra11.test
index fb7c559..38b1654 100755
--- a/tests/extra11.test
+++ b/tests/extra11.test
@@ -23,7 +23,9 @@ required=GNUmake
 echo AC_OUTPUT >> configure.in
 
 cat > Makefile.am <<'END'
-EXTRA_DIST = [!c-z].t d.t [ab].dir foo.* *zardoz*
+AUTOMAKE_OPTIONS = -Wno-portability
+
+EXTRA_DIST = $(wildcard [!c-z].t d.t [ab].dir foo.* *zardoz*)
 
 .PHONY: prereq
 prereq:
@@ -45,6 +47,7 @@ prereq:
 
 .PHONY: test
 test: distdir
+       ls -l $(distdir) $(distdir)/*.dir ;: For debugging.
        diff a.t $(distdir)/a.t
        diff b.t $(distdir)/b.t
        test ! -r $(distdir)/c.t
@@ -59,6 +62,22 @@ test: distdir
        diff foo.bar $(distdir)/foo.bar
        test ! -r $(distdir)/foo
        diff _zardoz_ $(distdir)/_zardoz_
+check-local:
+       ls -l . *.dir ;: For debugging.
+       test -f $(srcdir)/a.t
+       test -f $(srcdir)/b.t
+       test ! -r $(srcdir)/c.t
+       test -f $(srcdir)/d.t
+       test ! -r $(srcdir)/m.t
+       test ! -r $(srcdir)/z.t
+       test -f $(srcdir)/a.dir/f1
+       test -f $(srcdir)/a.dir/f2
+       test -f $(srcdir)/b.dir/f
+       test ! -r $(srcdir)/c.dir
+       test -f $(srcdir)/foo.x
+       test -f $(srcdir)/foo.bar
+       test ! -r $(srcdir)/foo
+       test -f $(srcdir)/_zardoz_
 END
 
 $ACLOCAL
@@ -67,5 +86,8 @@ $AUTOCONF
 
 ./configure
 $MAKE prereq
-ls -l . *.dir
+ls -l . *.dir # For debugging.
 $MAKE test
+$MAKE distcheck
+
+:
diff --git a/tests/lex-clean-cxx.test b/tests/lex-clean-cxx.test
new file mode 100755
index 0000000..6ca8071
--- /dev/null
+++ b/tests/lex-clean-cxx.test
@@ -0,0 +1,125 @@
+#! /bin/sh
+# Copyright (C) 2011 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 C++ source and header files derived from non-distributed
+# Yacc sources are cleaned by "make clean", while C++ source and
+# header files derived from distributed Yacc sources are cleaned by
+# "make maintainer-clean".
+# See also sister test `lex-clean.test'.
+
+required=lex
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CXX
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz qux
+
+foo_SOURCES = mainfoo.cc parsefoo.lxx
+
+bar_SOURCES = mainbar.cpp parsebar.ll
+bar_LFLAGS = $(AM_LFLAGS)
+
+baz_SOURCES = mainbaz.c++
+nodist_baz_SOURCES = parsebaz.l++
+
+qux_SOURCES = mainqux.cxx
+nodist_qux_SOURCES = parsequx.lpp
+qux_LFLAGS = $(AM_LFLAGS)
+
+parsebaz.l++ parsequx.lpp:
+       cp $(srcdir)/parsefoo.lxx $@
+
+CLEANFILES = parsebaz.l++ parsequx.lpp
+
+LDADD = $(LEXLIB)
+END
+
+cat > parsefoo.lxx << 'END'
+%%
+"GOOD"   return EOF;
+.
+%%
+int yywrap (void)
+{
+  return 1;
+}
+END
+cp parsefoo.lxx parsebar.ll
+
+cat > mainfoo.cc << 'END'
+// This file should contain valid C++ but invalid C.
+using namespace std;
+int main (int argc, char **argv)
+{
+  extern int yylex (void);
+  return yylex ();
+}
+END
+cp mainfoo.cc mainbar.cpp
+cp mainfoo.cc mainbaz.c++
+cp mainfoo.cc mainqux.cxx
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+cp config.status config.sav
+
+$MAKE
+ls -l
+# Sanity checks.
+test -f parsefoo.cxx
+test -f bar-parsebar.cc
+test -f parsebaz.l++
+test -f parsebaz.c++
+test -f parsequx.lpp
+test -f qux-parsequx.cpp
+
+for target in clean distclean; do
+  $MAKE $target
+  ls -l
+  test -f parsefoo.cxx
+  test -f bar-parsebar.cc
+  test ! -r parsebaz.l++
+  test ! -r parsebaz.c++
+  test ! -r parsequx.lpp
+  test ! -r qux-parsequx.cpp
+done
+
+cp config.sav config.status
+./config.status # re-create Makefile
+
+$MAKE maintainer-clean
+ls -l
+test -f parsefoo.lxx
+test -f parsebar.ll
+test ! -r parsefoo.cxx
+test ! -r bar-parsebar.cc
+test -f parsefoo.lxx
+test -f parsebar.ll
+test ! -r parsefoo.cxx
+test ! -r bar-parsebar.cc
+
+:
diff --git a/tests/lex-clean.test b/tests/lex-clean.test
new file mode 100755
index 0000000..6f03887
--- /dev/null
+++ b/tests/lex-clean.test
@@ -0,0 +1,113 @@
+#! /bin/sh
+# Copyright (C) 2011 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 .c files derived from non-distributed .l sources
+# are cleaned by "make clean", while .c files derived from
+# distributed .l sources are cleaned by "make maintainer-clean".
+# See also sister test `lex-clean-cxx.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz qux
+
+foo_SOURCES = main.c lexer.l
+
+bar_SOURCES = main.c lexer.l
+bar_LFLAGS = $(AM_LFLAGS)
+
+baz_SOURCES = main.c
+nodist_baz_SOURCES = baz.l
+
+qux_SOURCES = main.c
+nodist_qux_SOURCES = baz.l
+qux_LFLAGS = $(AM_LFLAGS)
+
+baz.l:
+       cp $(srcdir)/lexer.l $@
+
+CLEANFILES = baz.l
+
+LDADD = $(LEXLIB)
+END
+
+cat > lexer.l << 'END'
+%%
+"GOOD"   return EOF;
+.
+END
+
+cat > main.c << 'END'
+int main (void)
+{
+  return yylex ();
+}
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+cp config.status config.sav
+
+$MAKE
+ls -l
+# Sanity checks.
+test -f lexer.l
+test -f lexer.c
+test -f bar-lexer.c
+test -f baz.l
+test -f baz.c
+test -f qux-baz.c
+
+for target in clean distclean; do
+  $MAKE $target
+  ls -l
+  test -f lexer.l
+  test -f lexer.c
+  test -f bar-lexer.c
+  test ! -r baz.l
+  test ! -r baz.c
+  test ! -r qux-baz.c
+done
+
+cp config.sav config.status
+./config.status # re-create Makefile
+
+$MAKE maintainer-clean
+ls -l
+test -f lexer.l
+test ! -r lexer.c
+test ! -r bar-lexer.c
+
+:
diff --git a/tests/lex-depend-cxx.test b/tests/lex-depend-cxx.test
new file mode 100755
index 0000000..9b5416d
--- /dev/null
+++ b/tests/lex-depend-cxx.test
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Test to make sure dependencies work with Lex/C++.
+# Test synthesized from PR automake/6.
+
+required=lex
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CXX
+AM_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = joe moe
+joe_SOURCES = joe.ll
+moe_SOURCES = moe.l++
+LDADD = $(LEXLIB)
+
+.PHONY: test-deps-exist
+test-deps-exist:
+       ls -l $(DEPDIR) ;: For debugging.
+       test -f $(DEPDIR)/joe.Po
+       test -f $(DEPDIR)/moe.Po
+
+.PHONY: test-obj-updated
+test-obj-updated: joe.$(OBJEXT) moe.$(OBJEXT)
+       stat older my-hdr.hxx joe.$(OBJEXT) moe.$(OBJEXT) || :
+       test `ls -t older joe.$(OBJEXT) | sed 1q` = joe.$(OBJEXT)
+       test `ls -t older moe.$(OBJEXT) | sed 1q` = moe.$(OBJEXT)
+END
+
+cat > joe.ll << 'END'
+%%
+"foo" return EOF;
+.
+%%
+#include "my-hdr.hxx"
+int yywrap (void)
+{
+  return 1;
+}
+int main (int argc, char **argv)
+{
+  printf("Hello, World!\n");
+  return 0;
+}
+END
+
+cp joe.ll moe.l++
+
+cat > my-hdr.hxx <<'END'
+// This header contains deliberetly invalid C (but valid C++)
+#include <cstdio>
+using namespace std;
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+$FGREP joe.Po Makefile.in
+$FGREP moe.Po Makefile.in
+
+$AUTOCONF
+# Try to enable dependency tracking if possible, even if that means
+# using slow dependency extractors.
+./configure --enable-dependency-tracking
+
+$MAKE test-deps-exist
+$MAKE
+
+: > older
+$sleep
+touch my-hdr.hxx
+$MAKE test-obj-updated
+
+:
diff --git a/tests/lex4.test b/tests/lex-depend-grep.test
similarity index 66%
rename from tests/lex4.test
rename to tests/lex-depend-grep.test
index f2bf574..2f1af8c 100755
--- a/tests/lex4.test
+++ b/tests/lex-depend-grep.test
@@ -15,8 +15,9 @@
 # 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 to make sure dependencies work with .ll files.
-# Test synthesized from PR automake/6.
+# Test to make sure dependencies for Lex and C/C++ does not break
+# in obvious ways.  See PR automake/6, and related semantic tests
+# `lex-depend.test' and `lex-depend-cxx.test'.
 
 . ./defs || Exit 1
 
@@ -27,13 +28,20 @@ AM_PROG_LEX
 END
 
 cat > Makefile.am << 'END'
-bin_PROGRAMS = zoo
+bin_PROGRAMS = zoo foo
 zoo_SOURCES = joe.ll
+foo_SOURCES = moe.l
+noinst_PROGRAMS = zardoz
+zardoz_SOURCES = _0.l _1.ll _2.lxx _3.l++ _4.lpp
 END
 
 $ACLOCAL
 $AUTOMAKE -a
 
-$FGREP joe.Po Makefile.in
+$EGREP '([mj]oe|_[01234]|include|\.P)' Makefile.in # For debugging.
+
+for x in joe moe _0 _1 _2 _3 _4; do
+  grep "include.*$x\.Po" Makefile.in
+done
 
 :
diff --git a/tests/lex-depend.test b/tests/lex-depend.test
new file mode 100755
index 0000000..2ef27da
--- /dev/null
+++ b/tests/lex-depend.test
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Test to make sure automatic dependency tracking work with Lex/C.
+# Test suggested by PR automake/6.
+
+required=lex
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zoo
+zoo_SOURCES = joe.l
+LDADD = $(LEXLIB)
+
+.PHONY: test-deps-exist
+test-deps-exist:
+       ls -l $(DEPDIR) ;: For debugging.
+       test -f $(DEPDIR)/joe.Po
+
+.PHONY: test-obj-updated
+test-obj-updated: joe.$(OBJEXT)
+       stat older my-hdr.h joe.$(OBJEXT) || : For debugging.
+       test `ls -t older joe.$(OBJEXT) | sed 1q` = joe.$(OBJEXT)
+END
+
+cat > joe.l << 'END'
+%%
+"foo" return EOF;
+.
+%%
+#include "my-hdr.h"
+int main (void)
+{
+  printf("%s\n", MESSAGE);
+  return 0;
+}
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
+END
+
+cat > my-hdr.h <<'END'
+#include <stdio.h>
+#define MESSAGE "Hello, World!"
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+$FGREP joe.Po Makefile.in
+
+$AUTOCONF
+# Try to enable dependency tracking if possible, even if that means
+# using slow dependency extractors.
+./configure --enable-dependency-tracking
+
+$MAKE test-deps-exist
+$MAKE
+
+: > older
+$sleep
+touch my-hdr.h
+$MAKE test-obj-updated
+
+:
diff --git a/tests/lex-line.test b/tests/lex-line.test
new file mode 100755
index 0000000..a7e1640
--- /dev/null
+++ b/tests/lex-line.test
@@ -0,0 +1,122 @@
+#! /bin/sh
+# Copyright (C) 2011 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 lex support ensures that lex-generated C
+# files use correct "#line" directives.  Try also with the
+# `subdir-object' option enabled.
+# See also sister test `yacc-line.test'.
+
+required=lex
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+mkdir dir sub sub/dir
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo bar
+LDADD = $(LEXLIB)
+bar_LFLAGS = -v
+foo_SOURCES = zardoz.l
+bar_SOURCES = dir/quux.l
+## Avoid spurious failures with Solaris make.
address@hidden@: zardoz.c
address@hidden@: bar-quux.c
+END
+
+cat > sub/Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_PROGRAMS = foo bar
+## We already used $(LEXLIB) above, so try @LEXLIB@ now.
+LDADD = @LEXLIB@
+foo_LFLAGS = -v
+foo_SOURCES = zardoz.l
+bar_SOURCES = dir/quux.l
+## Avoid spurious failures with Solaris make.
address@hidden@: foo-zardoz.c
+dir/address@hidden@: dir/quux.c
+END
+
+cat > zardoz.l << 'END'
+%%
+"END"  return EOF;
+.
+%%
+int main ()
+{
+  while (yylex () != EOF)
+    ;
+  return 0;
+}
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
+}
+END
+
+cp zardoz.l dir/quux.l
+cp zardoz.l sub/zardoz.l
+cp zardoz.l sub/dir/quux.l
+
+c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+for vpath in : false; do
+
+  if $vpath; then
+    srcdir=..
+    mkdir build
+    cd build
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+  $MAKE
+
+  # For debugging,
+  ls -l . sub sub/dir
+  $FGREP '.l' $c_outputs
+
+  # Adjusted "#line" should not contain reference to the builddir.
+  $EGREP '#.*line.*(build|\.\.).*\.l' $c_outputs && Exit 1
+  # Adjusted "#line" should not contain reference to the default
+  # output file names, e.g., `lex.yy.c'.
+  $EGREP '#.*line.*lex\.yy' $c_outputs && Exit 1
+  # Don't be excessively strict in grepping, to avoid spurious failures.
+  grep '#.*line.*zardoz\.l' zardoz.c
+  grep '#.*line.*quux\.l' bar-quux.c
+  grep '#.*line.*zardoz\.l' sub/foo-zardoz.c
+  grep '#.*line.*quux\.l' sub/dir/quux.c
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/yacc-nodist.test b/tests/lex-nodist.test
similarity index 52%
copy from tests/yacc-nodist.test
copy to tests/lex-nodist.test
index 83f63dd..092e089 100755
--- a/tests/yacc-nodist.test
+++ b/tests/lex-nodist.test
@@ -14,73 +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/>.
 
-# Checks for .c and .h files derived from non-distributed .y sources.
+# Checks for .c files derived from non-distributed .l sources.
+# The test `lex-pr204.test' does similar check with AM_MAINTAINER_MODE
+# enabled.
+# The tests 'yacc-nodist.test' and 'yacc-pr204.test' does similar checks
+# for yacc-generated .c and .h files.
 
-required='cc yacc'
+required=lex
 . ./defs || Exit 1
 
+set -e
+
 cat >> configure.in << 'END'
 AC_PROG_CC
-AC_PROG_YACC
-AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+dnl Sister test 'lex-pr204.test' should use 'AC_PROG_LEX' instead.
+AM_PROG_LEX
 AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
-SUBDIRS = sub1 sub2
-.PHONY: test
+.PHONY: test-build test-dist
 test-build: all
-       ls -l . sub1 sub2
-       test -f sub1/parse.y
-       test -f sub1/parse.c
-       test -f sub2/parse.y
-       test -f sub2/parse.c
-       test -f sub2/parse.h
+       ls -l
+       test -f lexer.l
+       test -f lexer.c
 test-dist: distdir
-       ls -l $(distdir) $(distdir)/sub1 $(distdir)/sub2
-       test ! -r $(distdir)/sub1/parse.y
-       test ! -r $(distdir)/sub1/parse.c
-       test ! -r $(distdir)/sub1/parse.h
-       test ! -r $(distdir)/sub2/parse.y
-       test ! -r $(distdir)/sub2/parse.c
-       test ! -r $(distdir)/sub2/parse.h
+       ls -l $(distdir)
+       test ! -r $(distdir)/lexer.l
+       test ! -r $(distdir)/lexer.c
 check-local: test-build test-dist
-END
-
-mkdir sub1 sub2
 
-cat > sub1/Makefile.am << 'END'
-parse.y:
+lexer.l:
        rm -f $@ address@hidden
        :; { : \
-         && echo "%{" \
-         && echo "int yylex () { return 0; }" \
-         && echo "void yyerror (char *s) {}" \
-         && echo "%}" \
-         && echo "%%" \
-         && echo "maude : 'm' 'a' 'u' 'd' 'e' {}"; \
+         && echo '%%' \
+         && echo '"GOOD" return EOF;' \
+         && echo '.'; \
        } > address@hidden
-       chmod a-w address@hidden
-       mv -f address@hidden $@
+       chmod a-w address@hidden && mv -f address@hidden $@
+
 bin_PROGRAMS = prog
 prog_SOURCES = main.c
-nodist_prog_SOURCES = parse.y
+nodist_prog_SOURCES = lexer.l
+prog_LDADD = $(LEXLIB)
 CLEANFILES = $(nodist_prog_SOURCES)
 END
 
-cat sub1/Makefile.am - > sub2/Makefile.am << 'END'
-AM_YFLAGS = -d
-BUILT_SOURCES = parse.h
-END
-
-cat > sub1/main.c << 'END'
+cat > main.c << 'END'
 int main ()
 {
-  return yyparse ();
+  return yylex ();
+}
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+  return 1;
 }
-END
-cat - sub1/main.c > sub2/main.c << 'END'
-#include "parse.h"
 END
 
 $ACLOCAL
diff --git a/tests/lex-pr204.test b/tests/lex-pr204.test
new file mode 100755
index 0000000..095d611
--- /dev/null
+++ b/tests/lex-pr204.test
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Related to PR 204.
+# C sources derived from nodist_ lex sources should not be distributed.
+# See also related test `lex-nodist.test'.
+# The tests 'yacc-nodist.test' and 'yacc-pr204.test' does similar checks
+# for yacc-generated .c and .h files.
+
+required=lex
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'EOF'
+AM_MAINTAINER_MODE
+AC_PROG_CC
+dnl We use AC_PROG_LEX deliberately.
+dnl Sister 'lex-nodist.test' should use 'AM_PROG_LEX' instead.
+AC_PROG_LEX
+AC_OUTPUT
+EOF
+
+# The LEXER2 intermediate variable is there to make sure Automake
+# matches 'nodist_' against the right variable name...
+cat > Makefile.am << 'EOF'
+EXTRA_PROGRAMS = foo
+LEXER2 = lexer2.l
+nodist_foo_SOURCES = lexer.l $(LEXER2)
+
+distdirtest: distdir
+       test ! -f $(distdir)/lexer.c
+       test ! -f $(distdir)/lexer.l
+       test ! -f $(distdir)/lexer.h
+       test ! -f $(distdir)/lexer2.c
+       test ! -f $(distdir)/lexer2.l
+       test ! -f $(distdir)/lexer2.h
+EOF
+
+cat > lexer.l << 'END'
+%%
+"GOOD"   return EOF;
+.
+%%
+int main (void)
+{
+  return yylex ();
+}
+END
+
+cp lexer.l lexer2.l
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE distdirtest
+
+# Make sure lexer.c and lexer2.c are still targets.
+$MAKE lexer.c lexer2.c
+test -f lexer.c
+test -f lexer2.c
+
+# Ensure the rebuild rule works despite AM_MAINTAINER_MODE, because
+# it's a nodist_ lexer.
+$sleep
+touch lexer.l lexer2.l
+$sleep
+$MAKE lexer.c lexer2.c
+stat lexer.c lexer.l lexer2.c lexer2.l || : # For debugging.
+test `ls -t lexer.c lexer.l | sed 1q` = lexer.c
+test `ls -t lexer2.c lexer2.l | sed 1q` = lexer2.c
+
+:
diff --git a/tests/lex-subobj-nodep.test b/tests/lex-subobj-nodep.test
index 5db7168..bca664d 100755
--- a/tests/lex-subobj-nodep.test
+++ b/tests/lex-subobj-nodep.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
+# Copyright (C) 2011, 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
@@ -17,7 +17,7 @@
 # Ensure subdirs for subdir scanners are generated when subdir-objects
 # are used, even when dependency tracking is disabled.
 
-required='cc flex'
+required='cc lex'
 . ./defs || Exit 1
 
 cat >>configure.in <<\END
diff --git a/tests/lex3.test b/tests/lex3.test
index 01d9651..474490b 100755
--- a/tests/lex3.test
+++ b/tests/lex3.test
@@ -19,7 +19,7 @@
 # Test associated with PR 19.
 # From Matthew D. Langston.
 
-required='cc flex'
+required='cc lex'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -75,7 +75,7 @@ $MAKE distdir
 test -f $distdir/foo.c
 
 # Sanity check on distribution.
-$MAKE distcheck
+yl_distcheck
 
 # While we are at it, make sure that foo.c is erased by
 # maintainer-clean, and not by distclean.
diff --git a/tests/lex5.test b/tests/lex5.test
index 932a374..2ba2ad6 100755
--- a/tests/lex5.test
+++ b/tests/lex5.test
@@ -17,7 +17,7 @@
 
 # Test for subdir lexers.
 
-required='cc flex'
+required='cc lex'
 . ./defs || Exit 1
 
 cat >> configure.in << 'END'
@@ -56,15 +56,18 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
+# We expect ylwrap to be used and distributed even if there is
+# only one lexer.
+test -f ylwrap
+
 mkdir sub
 cd sub
 ../configure
 $MAKE foo/foo.o
+ls -l # For debugging.
 
 test -f foo/foo.c
 test -f foo/foo.o
-# ylwrap is not needed
-test ! -f ./ylwrap
 
 # Now, adds another lexer to test ylwrap.
 
@@ -82,11 +85,11 @@ END
 $sleep
 
 $AUTOMAKE -a --no-force
-test -f ./ylwrap
 
 cd sub
 using_gmake || $MAKE Makefile
 $MAKE foo/foo2.o
+ls -l # For debugging.
 test -f foo/foo2.c
 test -f foo/foo2.o
 
diff --git a/tests/lexvpath.test b/tests/lexvpath.test
index 106093e..d86ef2f 100755
--- a/tests/lexvpath.test
+++ b/tests/lexvpath.test
@@ -22,7 +22,7 @@
 
 # Please keep this in sync with sister test `yaccvapth.test'.
 
-required='cc flex'
+required='cc lex'
 . ./defs || Exit 1
 
 cat > lexoutroot.in << 'END'
@@ -76,7 +76,7 @@ cd sub
 test -n "$LEX_OUTPUT_ROOT" # Sanity check.
 cd ..
 
-flex lexer.l
+$LEX lexer.l
 mv "$LEX_OUTPUT_ROOT".c lexer.c
 
 cd sub
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk
index c726bde..3bcc4b6 100644
--- a/tests/list-of-tests.mk
+++ b/tests/list-of-tests.mk
@@ -287,7 +287,7 @@ confsub.test \
 confvar.test \
 confvar2.test \
 copy.test \
-cscope.test \
+cscope.tap \
 cscope2.test \
 cscope3.test \
 cxx.test \
@@ -516,7 +516,6 @@ ldflags.test \
 lex.test \
 lex2.test \
 lex3.test \
-lex4.test \
 lex5.test \
 lexcpp.test \
 lexvpath.test \
@@ -525,6 +524,14 @@ lex-lib.test \
 lex-lib-external.test \
 lex-libobj.test \
 lex-noyywrap.test \
+lex-clean-cxx.test \
+lex-clean.test \
+lex-depend-cxx.test \
+lex-depend-grep.test \
+lex-depend.test \
+lex-line.test \
+lex-nodist.test \
+lex-pr204.test \
 lflags.test \
 lflags2.test \
 libexec.test \
@@ -782,7 +789,6 @@ pr2.test \
 pr9.test \
 pr72.test \
 pr87.test \
-pr204.test \
 pr211.test \
 pr220.test \
 pr224.test \
@@ -914,13 +920,12 @@ silentf77.test \
 silentf90.test \
 silent-many-gcc.test \
 silent-many-generic.test \
-silent-lex-gcc.test \
-silent-lex-generic.test \
-silent-yacc-gcc.test \
-silent-yacc-generic.test \
 silent-nowarn.test \
 silent-configsite.test \
 silent-nested-vars.test \
+silent-lex.test \
+silent-yacc.test \
+silent-yacc-headers.test \
 srcsub.test \
 srcsub2.test \
 space.test \
@@ -1176,30 +1181,42 @@ werror3.test \
 werror4.test \
 whoami.test \
 xsource.test \
-yacc-basic.test \
-yacc-d-basic.test \
-yacc-clean.test \
 yacc.test \
 yacc2.test \
 yacc4.test \
 yacc5.test \
-yacc6.test \
 yacc7.test \
 yacc8.test \
 yaccdry.test \
-yacc-dist-nobuild.test \
-yacc-nodist.test \
 yaccpp.test \
 yaccvpath.test \
+yacc-auxdir.test \
+yacc-basic.test \
+yacc-cxx.test \
+yacc-bison-skeleton-cxx.test \
+yacc-bison-skeleton.test \
+yacc-clean.test \
+yacc-clean-cxx.test \
+yacc-d-basic.test \
+yacc-d-cxx.test \
 yacc-d-vpath.test \
+yacc-deleted-headers.test \
+yacc-depend.test \
+yacc-depend2.test \
 yacc-dist-nobuild-subdir.test \
+yacc-dist-nobuild.test \
+yacc-line.test \
+yacc-mix-c-cxx.test \
+yacc-nodist.test \
+yacc-pr204.test \
+yacc-weirdnames.test \
 yflags.test \
 yflags2.test \
 yflags-cmdline-override.test \
 yflags-conditional.test \
 yflags-d-false-positives.test \
-yflags-force-override.test \
 yflags-force-conditional.test \
+yflags-force-override.test \
 yflags-var-expand.test \
 libtool-macros.test \
 gettext-macros.test
diff --git a/tests/silent-lex-gcc.test b/tests/silent-lex-gcc.test
deleted file mode 100755
index 5ab5ecd..0000000
--- a/tests/silent-lex-gcc.test
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2010, 2011 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 silent-rules mode for Lex, forcing gcc depmode.
-# Keep this in sync with sister test `silent-lex-generic.test'.
-
-required='flex gcc'
-. ./defs || Exit 1
-
-mkdir sub
-
-cat >>configure.in <<'EOF'
-AM_SILENT_RULES
-AM_PROG_CC_C_O
-AC_PROG_LEX
-AC_CONFIG_FILES([sub/Makefile])
-AC_OUTPUT
-EOF
-
-cat > Makefile.am <<'EOF'
-# Need generic and non-generic rules.
-bin_PROGRAMS = foo1 foo2
-foo1_SOURCES = foo.l
-foo2_SOURCES = $(foo1_SOURCES)
-foo2_CFLAGS = $(AM_CFLAGS)
-SUBDIRS = sub
-LDADD = $(LEXLIB)
-EOF
-
-cat > sub/Makefile.am <<'EOF'
-AUTOMAKE_OPTIONS = subdir-objects
-# Need generic and non-generic rules.
-bin_PROGRAMS = bar1 bar2
-bar1_SOURCES = bar.l
-bar2_SOURCES = $(bar1_SOURCES)
-bar2_CFLAGS = $(AM_CFLAGS)
-LDADD = $(LEXLIB)
-EOF
-
-cat > foo.l <<'EOF'
-%%
-"END"   return EOF;
-.
-%%
-/* Avoid possible link errors. */
-int yywrap (void) { return 1; }
-int   main (void) { return 0; }
-EOF
-cp foo.l sub/bar.l
-
-$ACLOCAL
-$AUTOMAKE --add-missing
-$AUTOCONF
-
-# Force gcc ("fast") depmode.
-# This apparently useless "for" loop is here to simplify the syncing
-# with sister test `silent-lex-gcc.test'.
-for config_args in \
-  am_cv_CC_dependencies_compiler_type=gcc
-do
-  ./configure $config_args --enable-silent-rules
-
-  $MAKE >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  $EGREP ' (-c|-o)' stdout && Exit 1
-  $EGREP '(mv|ylwrap) ' stdout && Exit 1
-
-  grep 'LEX .*foo\.' stdout
-  grep 'LEX .*bar\.' stdout
-  grep ' CC .*foo\.' stdout
-  grep ' CC .*bar\.' stdout
-  grep 'CCLD .*foo1' stdout
-  grep 'CCLD .*bar1' stdout
-  grep 'CCLD .*foo2' stdout
-  grep 'CCLD .*bar2' stdout
-
-  # Cleaning and then rebuilding with the same V flag (and without
-  # removing the generated sources in between) shouldn't trigger a
-  # different set of rules.
-  $MAKE clean
-
-  $MAKE >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  $EGREP ' (-c|-o)' stdout && Exit 1
-  $EGREP '(mv|ylwrap) ' stdout && Exit 1
-
-  # Don't look for LEX, as probably lex hasn't been re-run.
-  grep ' CC .*foo\.' stdout
-  grep ' CC .*bar\.' stdout
-  grep 'CCLD .*foo1' stdout
-  grep 'CCLD .*bar1' stdout
-  grep 'CCLD .*foo2' stdout
-  grep 'CCLD .*bar2' stdout
-
-  # Ensure a truly clean rebuild.
-  $MAKE clean
-  rm -f foo.c sub/bar.c
-
-  $MAKE V=1 >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  grep ' -c ' stdout
-  grep ' -o ' stdout
-  grep 'ylwrap ' stdout
-
-  $EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
-
-  # Cleaning and then rebuilding with the same V flag (and without
-  # removing the generated sources in between) shouldn't trigger a
-  # different set of rules.
-  $MAKE clean
-
-  $MAKE V=1 >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  # Don't look for ylwrap, as probably lex hasn't been re-run.
-  grep ' -c ' stdout
-  grep ' -o ' stdout
-
-  $EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
-
-  # Ensure a truly clean reconfiguration/rebuild.
-  $MAKE clean
-  $MAKE maintainer-clean
-  rm -f foo.c sub/bar.c
-
-done
-
-:
diff --git a/tests/silent-lex-generic.test b/tests/silent-lex-generic.test
deleted file mode 100755
index a4767c2..0000000
--- a/tests/silent-lex-generic.test
+++ /dev/null
@@ -1,148 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2010, 2011 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 silent-rules mode for Lex.
-# Keep this in sync with sister test `silent-lex-gcc.test'.
-
-required='cc flex'
-. ./defs || Exit 1
-
-mkdir sub
-
-cat >>configure.in <<'EOF'
-AM_SILENT_RULES
-AM_PROG_CC_C_O
-AC_PROG_LEX
-AC_CONFIG_FILES([sub/Makefile])
-AC_OUTPUT
-EOF
-
-cat > Makefile.am <<'EOF'
-# Need generic and non-generic rules.
-bin_PROGRAMS = foo1 foo2
-foo1_SOURCES = foo.l
-foo2_SOURCES = $(foo1_SOURCES)
-foo2_CFLAGS = $(AM_CFLAGS)
-SUBDIRS = sub
-LDADD = $(LEXLIB)
-EOF
-
-cat > sub/Makefile.am <<'EOF'
-AUTOMAKE_OPTIONS = subdir-objects
-# Need generic and non-generic rules.
-bin_PROGRAMS = bar1 bar2
-bar1_SOURCES = bar.l
-bar2_SOURCES = $(bar1_SOURCES)
-bar2_CFLAGS = $(AM_CFLAGS)
-LDADD = $(LEXLIB)
-EOF
-
-cat > foo.l <<'EOF'
-%{
-/* avoid non-ANSI #include of unistd.h */
-#define YY_NO_UNISTD_H 1
-%}
-%%
-"END"   return EOF;
-.
-%%
-/* Avoid possible link errors. */
-int yywrap (void) { return 1; }
-int   main (void) { return 0; }
-EOF
-cp foo.l sub/bar.l
-
-$ACLOCAL
-$AUTOMAKE --add-missing
-$AUTOCONF
-
-# Force dependency tracking explicitly, so that slow dependency
-# extractors are not rejected.  Try also with dependency tracking
-# explicitly disabled.
-for config_args in \
-  --enable-dependency-tracking --disable-dependency-tracking
-do
-  ./configure $config_args --enable-silent-rules
-
-  $MAKE >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  $EGREP ' (-c|-o)' stdout && Exit 1
-  $EGREP '(mv|ylwrap) ' stdout && Exit 1
-
-  grep 'LEX .*foo\.' stdout
-  grep 'LEX .*bar\.' stdout
-  grep ' CC .*foo\.' stdout
-  grep ' CC .*bar\.' stdout
-  grep 'CCLD .*foo1' stdout
-  grep 'CCLD .*bar1' stdout
-  grep 'CCLD .*foo2' stdout
-  grep 'CCLD .*bar2' stdout
-
-  # Cleaning and then rebuilding with the same V flag (and without
-  # removing the generated sources in between) shouldn't trigger a
-  # different set of rules.
-  $MAKE clean
-
-  $MAKE >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  $EGREP ' (-c|-o)' stdout && Exit 1
-  $EGREP '(mv|ylwrap) ' stdout && Exit 1
-
-  # Don't look for LEX, as probably lex hasn't been re-run.
-  grep ' CC .*foo\.' stdout
-  grep ' CC .*bar\.' stdout
-  grep 'CCLD .*foo1' stdout
-  grep 'CCLD .*bar1' stdout
-  grep 'CCLD .*foo2' stdout
-  grep 'CCLD .*bar2' stdout
-
-  # Ensure a truly clean rebuild.
-  $MAKE clean
-  rm -f foo.c sub/bar.c
-
-  $MAKE V=1 >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  grep ' -c ' stdout
-  grep ' -o ' stdout
-  grep 'ylwrap ' stdout
-
-  $EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
-
-  # Cleaning and then rebuilding with the same V flag (and without
-  # removing the generated sources in between) shouldn't trigger a
-  # different set of rules.
-  $MAKE clean
-
-  $MAKE V=1 >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  # Don't look for ylwrap, as probably lex hasn't been re-run.
-  grep ' -c ' stdout
-  grep ' -o ' stdout
-
-  $EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
-
-  # Ensure a truly clean reconfiguration/rebuild.
-  $MAKE clean
-  $MAKE maintainer-clean
-  rm -f foo.c sub/bar.c
-
-done
-
-:
diff --git a/tests/silent-lex.test b/tests/silent-lex.test
new file mode 100755
index 0000000..ce1dc5b
--- /dev/null
+++ b/tests/silent-lex.test
@@ -0,0 +1,138 @@
+#!/bin/sh
+# Copyright (C) 2010, 2011 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 silent-rules mode for Lex.
+
+required=lex
+. ./defs || Exit 1
+
+set -e
+
+mkdir sub
+
+cat >>configure.in <<'EOF'
+AM_SILENT_RULES
+AM_PROG_CC_C_O
+AC_PROG_LEX
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo1 foo2
+foo1_SOURCES = foo.l
+foo2_SOURCES = $(foo1_SOURCES)
+foo2_LFLAGS = -n
+foo2_CFLAGS = $(AM_CFLAGS)
+SUBDIRS = sub
+LDADD = $(LEXLIB)
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = bar1 bar2
+bar1_SOURCES = bar.l
+bar2_SOURCES = $(bar1_SOURCES)
+bar2_LFLAGS = -n
+bar2_CFLAGS = $(AM_CFLAGS)
+LDADD = $(LEXLIB)
+EOF
+
+cat > foo.l <<'EOF'
+%%
+"END"   return EOF;
+.
+%%
+/* Avoid possible link errors. */
+int yywrap (void) { return 1; }
+int   main (void) { return 0; }
+EOF
+cp foo.l sub/bar.l
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Ensure per-target rules are used, to ensure their coverage below.
+$FGREP 'foo2-foo.c' Makefile.in || Exit 99
+$FGREP 'bar2-bar.c' sub/Makefile.in || Exit 99
+
+./configure --enable-silent-rules
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'LEX .*foo\.' stdout
+grep 'LEX .*bar\.' stdout
+grep ' CC .*foo\.' stdout
+grep ' CC .*bar\.' stdout
+grep 'CCLD .*foo1' stdout
+grep 'CCLD .*bar1' stdout
+grep 'CCLD .*foo2' stdout
+grep 'CCLD .*bar2' stdout
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+# Don't look for LEX, as probably lex hasn't been re-run.
+grep ' CC .*foo\.' stdout
+grep ' CC .*bar\.' stdout
+grep 'CCLD .*foo1' stdout
+grep 'CCLD .*bar1' stdout
+grep 'CCLD .*foo2' stdout
+grep 'CCLD .*bar2' stdout
+
+# Ensure a truly clean rebuild.
+$MAKE clean
+rm -f *foo.c sub/*bar.c
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -c ' stdout
+grep ' -o ' stdout
+grep 'ylwrap ' stdout
+
+$EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+# Don't look for ylwrap, as probably lex hasn't been re-run.
+grep ' -c ' stdout
+grep ' -o ' stdout
+
+$EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
+
+:
diff --git a/tests/silent-many-gcc.test b/tests/silent-many-gcc.test
index b2d4174..3598969 100755
--- a/tests/silent-many-gcc.test
+++ b/tests/silent-many-gcc.test
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2009, 2010, 2011, 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
@@ -21,7 +21,7 @@
 # This test requires the GNU compilers; keep it in sync with sister test
 # `silent-many-generic.test', which should work with generic compilers.
 
-required='gcc g++ gfortran flex yacc'
+required='gcc g++ gfortran lex yacc'
 . ./defs || Exit 1
 
 # Avoids too much code duplication.
@@ -71,7 +71,6 @@ do_and_check_silent_build ()
 # Avoids too much code duplication.
 do_and_check_verbose_build ()
 {
-
   case $1 in
     --rebuild) rebuild=true;;
             *) rebuild=false;;
@@ -116,6 +115,8 @@ fo2_SOURCES = $(foo_SOURCES)
 fo2_CPPFLAGS = $(AM_CPPFLAGS)
 fo2_FFLAGS = $(AM_FFLAGS)
 fo2_FCFLAGS = $(AM_FCFLAGS)
+fo2_YFLAGS = -v
+fo2_LFLAGS = -n
 SUBDIRS = sub
 AM_YFLAGS = -d
 LDADD = $(LEXLIB)
@@ -132,6 +133,8 @@ ba2_SOURCES = $(baz_SOURCES)
 ba2_CPPFLAGS = $(AM_CPPFLAGS)
 ba2_FFLAGS = $(AM_FFLAGS)
 ba2_FCFLAGS = $(AM_FCFLAGS)
+ba2_YFLAGS = -v
+ba2_LFLAGS = -n
 AM_YFLAGS = -d
 LDADD = $(LEXLIB)
 BUILT_SOURCES = baz6.h
@@ -189,6 +192,11 @@ $AUTOCONF
 # used by configure.
 $FGREP am_cv_CC_dependencies_compiler_type configure
 $FGREP am_cv_CXX_dependencies_compiler_type configure
+# Ensure per-target rules are used, to ensure their coverage below.
+# (We do not do an exhaustive check, that wouldn't be practical).
+$FGREP 'bar-bar.o' Makefile.in
+$FGREP 'fo2-foo5.c' Makefile.in
+$FGREP 'fo2-foo6.c' Makefile.in
 
 # Force gcc ("fast") depmode.
 depmodes="am_cv_CC_dependencies_compiler_type=gcc \
@@ -212,7 +220,7 @@ do
   $MAKE clean
   # This is required, since these files are not removed by `make clean'
   # (as dictated by the GNU Coding Standards).
-  rm -f foo5.c foo6.[ch] sub/baz5.c sub/baz6.[ch]
+  rm -f *foo5.c *foo6.[ch] sub/*baz5.c sub/*baz6.[ch]
 
   do_and_check_verbose_build
   # Cleaning and then rebuilding with the same V flag (and without
diff --git a/tests/silent-many-generic.test b/tests/silent-many-generic.test
index 4ae52de..ebbacda 100755
--- a/tests/silent-many-generic.test
+++ b/tests/silent-many-generic.test
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2009, 2010, 2011, 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
@@ -22,7 +22,7 @@
 # sister test `silent-many-gcc.test', which requires the GNU compilers
 # and forces the use of gcc depmode.
 
-required='cc c++ fortran fortran77 flex yacc'
+required='cc c++ fortran fortran77 lex yacc'
 . ./defs || Exit 1
 
 # Avoids too much code duplication.
@@ -72,7 +72,6 @@ do_and_check_silent_build ()
 # Avoids too much code duplication.
 do_and_check_verbose_build ()
 {
-
   case $1 in
     --rebuild) rebuild=true;;
             *) rebuild=false;;
@@ -139,6 +138,8 @@ fo2_SOURCES = $(foo_SOURCES)
 fo2_CPPFLAGS = $(AM_CPPFLAGS)
 fo2_FFLAGS = $(AM_FFLAGS)
 fo2_FCFLAGS = $(AM_FCFLAGS)
+fo2_YFLAGS = -v
+fo2_LFLAGS = -n
 SUBDIRS = sub
 AM_YFLAGS = -d
 LDADD = $(LEXLIB)
@@ -155,6 +156,8 @@ ba2_SOURCES = $(baz_SOURCES)
 ba2_CPPFLAGS = $(AM_CPPFLAGS)
 ba2_FFLAGS = $(AM_FFLAGS)
 ba2_FCFLAGS = $(AM_FCFLAGS)
+ba2_YFLAGS = -v
+ba2_LFLAGS = -n
 AM_YFLAGS = -d
 LDADD = $(LEXLIB)
 BUILT_SOURCES = baz6.h
@@ -212,6 +215,12 @@ $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
 
+# Ensure per-target rules are used, to ensure their coverage below.
+# (We do not do an exhaustive check, that wouldn't be practical).
+$FGREP 'bar-bar.o' Makefile.in
+$FGREP 'fo2-foo5.c' Makefile.in
+$FGREP 'fo2-foo6.c' Makefile.in
+
 # Force dependency tracking explicitly, so that slow dependency
 # extractors are not rejected.  Try also with dependency tracking
 # explicitly disabled.
@@ -232,7 +241,7 @@ do
   $MAKE clean
   # This is required, since these files are not removed by `make clean'
   # (as dictated by the GNU Coding Standards).
-  rm -f foo5.c foo6.[ch] sub/baz5.c sub/baz6.[ch]
+  rm -f *foo5.c *foo6.[ch] sub/*baz5.c sub/*baz6.[ch]
 
   do_and_check_verbose_build
   # Cleaning and then rebuilding with the same V flag (and without
diff --git a/tests/silent-yacc-gcc.test b/tests/silent-yacc-gcc.test
deleted file mode 100755
index 624b2cd..0000000
--- a/tests/silent-yacc-gcc.test
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2010, 2011 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 silent-rules mode for Yacc, forcing gcc depmode.
-# Keep this in sync with sister test `silent-yacc-generic.test'.
-
-required='gcc yacc'
-. ./defs || Exit 1
-
-mkdir sub
-
-cat >>configure.in <<'EOF'
-AM_SILENT_RULES
-AM_PROG_CC_C_O
-AC_PROG_YACC
-AC_CONFIG_FILES([sub/Makefile])
-AC_OUTPUT
-EOF
-
-cat > Makefile.am <<'EOF'
-# Need generic and non-generic rules.
-bin_PROGRAMS = foo1 foo2
-foo1_SOURCES = foo.y
-foo2_SOURCES = $(foo1_SOURCES)
-foo2_CFLAGS = $(AM_CPPFLAGS)
-SUBDIRS = sub
-EOF
-
-cat > sub/Makefile.am <<'EOF'
-AUTOMAKE_OPTIONS = subdir-objects
-# Need generic and non-generic rules.
-bin_PROGRAMS = bar1 bar2
-bar1_SOURCES = bar.y
-bar2_SOURCES = $(bar1_SOURCES)
-bar2_CFLAGS = $(AM_CPPFLAGS)
-EOF
-
-cat > foo.y <<'EOF'
-%{
-void yyerror (char *s) {}
-int yylex (void) {return 0;}
-int main(void) {return 0;}
-%}
-%token EOF
-%%
-fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
-EOF
-cp foo.y sub/bar.y
-
-$ACLOCAL
-$AUTOMAKE --add-missing
-$AUTOCONF
-
-# Force gcc ("fast") depmode.
-# This apparently useless "for" loop is here to simplify the syncing
-# with sister test `silent-yacc-gcc.test'.
-for config_args in \
-  am_cv_CC_dependencies_compiler_type=gcc
-do
-  ./configure $config_args --enable-silent-rules
-
-  $MAKE >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  $EGREP ' (-c|-o)' stdout && Exit 1
-  $EGREP '(mv|ylwrap) ' stdout && Exit 1
-
-  grep 'YACC .*foo\.' stdout
-  grep 'YACC .*bar\.' stdout
-  grep ' CC .*foo\.' stdout
-  grep ' CC .*bar\.' stdout
-  grep 'CCLD .*foo1' stdout
-  grep 'CCLD .*bar1' stdout
-  grep 'CCLD .*foo2' stdout
-  grep 'CCLD .*bar2' stdout
-
-  # Cleaning and then rebuilding with the same V flag (and without
-  # removing the generated sources in between) shouldn't trigger a
-  # different set of rules.
-  $MAKE clean
-
-  $MAKE >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  $EGREP ' (-c|-o)' stdout && Exit 1
-  $EGREP '(mv|ylwrap) ' stdout && Exit 1
-
-  # Don't look for YACC, as probably yacc hasn't been re-run.
-  grep ' CC .*foo\.' stdout
-  grep ' CC .*bar\.' stdout
-  grep 'CCLD .*foo1' stdout
-  grep 'CCLD .*bar1' stdout
-  grep 'CCLD .*foo2' stdout
-  grep 'CCLD .*bar2' stdout
-
-  # Ensure a truly clean rebuild.
-  $MAKE clean
-  rm -f foo.[ch] sub/bar.[ch]
-
-  $MAKE V=1 >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  grep ' -c ' stdout
-  grep ' -o ' stdout
-  grep 'ylwrap ' stdout
-
-  $EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
-
-  # Cleaning and then rebuilding with the same V flag (and without
-  # removing the generated sources in between) shouldn't trigger a
-  # different set of rules.
-  $MAKE clean
-
-  $MAKE V=1 >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  # Don't look for ylwrap, as probably lex hasn't been re-run.
-  grep ' -c ' stdout
-  grep ' -o ' stdout
-
-  $EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
-
-  # Ensure a truly clean reconfiguration/rebuild.
-  $MAKE clean
-  $MAKE maintainer-clean
-  rm -f foo.[ch] sub/bar.[ch]
-
-done
-
-:
diff --git a/tests/silent-yacc-generic.test b/tests/silent-yacc-generic.test
deleted file mode 100755
index 6579911..0000000
--- a/tests/silent-yacc-generic.test
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2010, 2011 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 silent-rules mode for Yacc.
-# Keep this in sync with sister test `silent-yacc-gcc.test'.
-
-required='cc yacc'
-. ./defs || Exit 1
-
-mkdir sub
-
-cat >>configure.in <<'EOF'
-AM_SILENT_RULES
-AM_PROG_CC_C_O
-AC_PROG_YACC
-AC_CONFIG_FILES([sub/Makefile])
-AC_OUTPUT
-EOF
-
-cat > Makefile.am <<'EOF'
-# Need generic and non-generic rules.
-bin_PROGRAMS = foo1 foo2
-foo1_SOURCES = foo.y
-foo2_SOURCES = $(foo1_SOURCES)
-foo2_CFLAGS = $(AM_CPPFLAGS)
-SUBDIRS = sub
-EOF
-
-cat > sub/Makefile.am <<'EOF'
-AUTOMAKE_OPTIONS = subdir-objects
-# Need generic and non-generic rules.
-bin_PROGRAMS = bar1 bar2
-bar1_SOURCES = bar.y
-bar2_SOURCES = $(bar1_SOURCES)
-bar2_CFLAGS = $(AM_CPPFLAGS)
-EOF
-
-cat > foo.y <<'EOF'
-%{
-void yyerror (char *s) {}
-int yylex (void) {return 0;}
-int main(void) {return 0;}
-%}
-%token EOF
-%%
-fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
-EOF
-cp foo.y sub/bar.y
-
-$ACLOCAL
-$AUTOMAKE --add-missing
-$AUTOCONF
-
-# Force dependency tracking explicitly, so that slow dependency
-# extractors are not rejected.  Try also with dependency tracking
-# explicitly disabled.
-for config_args in \
-  --enable-dependency-tracking --disable-dependency-tracking
-do
-  ./configure $config_args --enable-silent-rules
-
-  $MAKE >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  $EGREP ' (-c|-o)' stdout && Exit 1
-  $EGREP '(mv|ylwrap) ' stdout && Exit 1
-
-  grep 'YACC .*foo\.' stdout
-  grep 'YACC .*bar\.' stdout
-  grep ' CC .*foo\.' stdout
-  grep ' CC .*bar\.' stdout
-  grep 'CCLD .*foo1' stdout
-  grep 'CCLD .*bar1' stdout
-  grep 'CCLD .*foo2' stdout
-  grep 'CCLD .*bar2' stdout
-
-  # Cleaning and then rebuilding with the same V flag (and without
-  # removing the generated sources in between) shouldn't trigger a
-  # different set of rules.
-  $MAKE clean
-
-  $MAKE >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  $EGREP ' (-c|-o)' stdout && Exit 1
-  $EGREP '(mv|ylwrap) ' stdout && Exit 1
-
-  # Don't look for YACC, as probably yacc hasn't been re-run.
-  grep ' CC .*foo\.' stdout
-  grep ' CC .*bar\.' stdout
-  grep 'CCLD .*foo1' stdout
-  grep 'CCLD .*bar1' stdout
-  grep 'CCLD .*foo2' stdout
-  grep 'CCLD .*bar2' stdout
-
-  # Ensure a truly clean rebuild.
-  $MAKE clean
-  rm -f foo.[ch] sub/bar.[ch]
-
-  $MAKE V=1 >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  grep ' -c ' stdout
-  grep ' -o ' stdout
-  grep 'ylwrap ' stdout
-
-  $EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
-
-  # Cleaning and then rebuilding with the same V flag (and without
-  # removing the generated sources in between) shouldn't trigger a
-  # different set of rules.
-  $MAKE clean
-
-  $MAKE V=1 >stdout || { cat stdout; Exit 1; }
-  cat stdout
-
-  # Don't look for ylwrap, as probably lex hasn't been re-run.
-  grep ' -c ' stdout
-  grep ' -o ' stdout
-
-  $EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
-
-  # Ensure a truly clean reconfiguration/rebuild.
-  $MAKE clean
-  $MAKE maintainer-clean
-  rm -f foo.[ch] sub/bar.[ch]
-
-done
-
-:
diff --git a/tests/silent-yacc-headers.test b/tests/silent-yacc-headers.test
new file mode 100755
index 0000000..f8dd99e
--- /dev/null
+++ b/tests/silent-yacc-headers.test
@@ -0,0 +1,175 @@
+#!/bin/sh
+# Copyright (C) 2011 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 silent-rules mode for Yacc, when yacc-generated headers are
+# involved (i.e., the `-d' option is in *YFLAGS).
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+mkdir sub
+
+cat >>configure.in <<'EOF'
+AM_SILENT_RULES
+AC_PROG_YACC
+AC_PROG_CC
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+AM_YFLAGS = -d
+bin_PROGRAMS = foo bar
+foo_SOURCES = parse.y
+bar_SOURCES = $(foo_SOURCES)
+bar_YFLAGS = $(AM_YFLAGS)
+EOF
+
+cat > parse.y <<'EOF'
+%{
+void yyerror (char *s) { return; }
+int yylex (void) { return 0; }
+int main (void) { return 0; }
+%}
+%token EOF
+%%
+fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
+EOF
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Check that the expected non-generic rules has been truly generated.
+# Otherwise, the coverage offered by this test will be weaker then
+# expected and planned.
+$FGREP 'bar-parse.c' Makefile.in
+$FGREP '$(bar_YFLAGS)' Makefile.in
+
+./configure --enable-silent-rules
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'YACC  *parse\.c' stdout
+grep 'updating  *parse\.h' stdout
+grep 'YACC  *bar-parse\.c' stdout
+grep 'updating  *bar-parse\.h' stdout
+
+grep ' CC  *parse\.' stdout
+grep ' CC  *bar-parse\.' stdout
+grep 'CCLD  *foo' stdout
+grep 'CCLD  *bar' stdout
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'YACC  *parse\.c' stdout
+grep 'updating  *parse\.h' stdout
+grep 'YACC  *bar-parse\.c' stdout
+grep 'updating  *bar-parse\.h' stdout
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+# Don't look for "YACC *.c" and "updating *.h", as yacc shouldn't
+# have been re-run.
+grep ' CC  *parse\.' stdout
+grep ' CC  *bar-parse\.' stdout
+grep 'CCLD  *foo' stdout
+grep 'CCLD  *bar' stdout
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'YACC  *parse\.c' stdout
+grep 'updating  *parse\.h' stdout
+grep 'YACC  *bar-parse\.c' stdout
+grep 'updating  *bar-parse\.h' stdout
+
+# Ensure a truly clean rebuild.
+$MAKE maintainer-clean
+
+./configure --enable-silent-rules
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -c ' stdout
+grep ' -o ' stdout
+grep ' -d ' stdout
+grep 'ylwrap ' stdout
+
+$EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE V=1 parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -d ' stdout
+grep 'ylwrap ' stdout
+
+grep 'YACC' stdout && Exit 1
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+# Don't look for ylwrap, as probably lex hasn't been re-run.
+grep ' -c ' stdout
+grep ' -o ' stdout
+
+$EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE V=1 parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -d ' stdout
+grep 'ylwrap ' stdout
+
+grep 'YACC' stdout && Exit 1
+
+:
diff --git a/tests/silent-yacc.test b/tests/silent-yacc.test
new file mode 100755
index 0000000..4a5e46a
--- /dev/null
+++ b/tests/silent-yacc.test
@@ -0,0 +1,138 @@
+#!/bin/sh
+# Copyright (C) 2010, 2011 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 silent-rules mode for Yacc.
+# Keep this in sync with sister test `silent-yacc-gcc.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+mkdir sub
+
+cat >>configure.in <<'EOF'
+AM_SILENT_RULES
+AM_PROG_CC_C_O
+AC_PROG_YACC
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo1 foo2
+foo1_SOURCES = foo.y
+foo2_SOURCES = $(foo1_SOURCES)
+foo2_YFLAGS = -v
+foo2_CFLAGS = $(AM_CPPFLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = bar1 bar2
+bar1_SOURCES = bar.y
+bar2_SOURCES = $(bar1_SOURCES)
+bar2_YFLAGS = -v
+bar2_CFLAGS = $(AM_CPPFLAGS)
+EOF
+
+cat > foo.y <<'EOF'
+%{
+void yyerror (char *s) { return; }
+int yylex (void) { return 0; }
+int main (void) { return 0; }
+%}
+%token EOF
+%%
+fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
+EOF
+cp foo.y sub/bar.y
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Ensure per-target rules are used, to ensure their coverage below.
+$FGREP 'foo2-foo.c' Makefile.in || Exit 99
+$FGREP 'bar2-bar.c' sub/Makefile.in || Exit 99
+
+./configure --enable-silent-rules
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'YACC .*foo\.' stdout
+grep 'YACC .*bar\.' stdout
+grep ' CC .*foo\.' stdout
+grep ' CC .*bar\.' stdout
+grep 'CCLD .*foo1' stdout
+grep 'CCLD .*bar1' stdout
+grep 'CCLD .*foo2' stdout
+grep 'CCLD .*bar2' stdout
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+# Don't look for YACC, as probably yacc hasn't been re-run.
+grep ' CC .*foo\.' stdout
+grep ' CC .*bar\.' stdout
+grep 'CCLD .*foo1' stdout
+grep 'CCLD .*bar1' stdout
+grep 'CCLD .*foo2' stdout
+grep 'CCLD .*bar2' stdout
+
+# Ensure a truly clean rebuild.
+$MAKE clean
+rm -f *foo.[ch] sub/*bar.[ch]
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -c ' stdout
+grep ' -o ' stdout
+grep 'ylwrap ' stdout
+
+$EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+# Don't look for ylwrap, as probably lex hasn't been re-run.
+grep ' -c ' stdout
+grep ' -o ' stdout
+
+$EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
+
+:
diff --git a/tests/subpkg-yacc.test b/tests/subpkg-yacc.test
index 76cbf42..757e042 100755
--- a/tests/subpkg-yacc.test
+++ b/tests/subpkg-yacc.test
@@ -116,34 +116,15 @@ $AUTOHEADER
 $AUTOMAKE -Wno-override --add-missing
 cd ..
 
-# Some checks here are slightly more tricky than we'd like, but we cannot
-# simply use "make distcheck", to avoid triggering a spurious failure due
-# to issues with FreeBSD make and VPATH builds (see automake bug#7884).
-
 ./configure
-$MAKE
-$MAKE dist
-test -f lib-dist-hook-has-run
-test -f subpack-1.tar.gz
-test ! -d subpack-1 # Make sure "dist" cleans up after itself.
 
-mkdir workdir
-cd workdir
-gzip -c -d ../subpack-1.tar.gz | tar xf -
-test -d subpack-1
-mkdir build
-cd build
-../subpack-1/configure
-$MAKE
 $MAKE dist
 test -f lib-dist-hook-has-run
 test -f subpack-1.tar.gz
 test ! -d subpack-1 # Make sure "dist" cleans up after itself.
 
-# Don't trust non-GNU makes to do distcheck with a Yacc-using
-# package (see bug referenced above).
-if using_gmake; then
-  $MAKE distcheck || Exit 1
-fi
+rm -f lib-dist-hook-has-run subpack-1.tar.gz
+
+yl_distcheck
 
 :
diff --git a/tests/subpkg.test b/tests/subpkg.test
index 658a8e5..d51e67e 100755
--- a/tests/subpkg.test
+++ b/tests/subpkg.test
@@ -1,6 +1,6 @@
 #! /bin/sh
-# Copyright (C) 2002, 2003, 2004, 2006, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2002, 2003, 2004, 2006, 2011, 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
diff --git a/tests/suffix10.tap b/tests/suffix10.tap
index 2d66f3b..1b812cb 100755
--- a/tests/suffix10.tap
+++ b/tests/suffix10.tap
@@ -42,7 +42,7 @@ libfoo_la_SOURCES = foo.x_
          && echo 'void yyerror (char *s) {}' \
          && echo '%}' \
          && echo '%%' \
-         && echo 'WORD: "foo";' \
+         && echo 'foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};' \
          && echo '%%' \
 ## Account for VPATH issues on weaker make implementations.
          && cat `test -f '$<' || echo $(srcdir)/`$<; \
diff --git a/tests/yacc6.test b/tests/yacc-auxdir.test
similarity index 51%
rename from tests/yacc6.test
rename to tests/yacc-auxdir.test
index 8992e95..700fcd8 100755
--- a/tests/yacc6.test
+++ b/tests/yacc-auxdir.test
@@ -15,94 +15,45 @@
 # 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 to make sure ylwrap put in right location.
+# Test to make sure ylwrap is put in right location.
 # Report from Tim Van Holder.
-# Also make sure depcomp does not needlessly update headers.
-# Report from Paolo Bonzini.
 
-required='gcc yacc GNUmake'
 . ./defs || Exit 1
 
-cat > configure.in << 'END'
-AC_INIT([yacc6], [1.0])
-# `aux' is not an acceptable file/directory name on Windows systems.
+set -e
+
+mkdir aux1 sub
+
+cat > configure.in << END
+AC_INIT([$me], [1.0])
+# 'aux' is not an acceptable file/directory name on Windows systems
 AC_CONFIG_AUX_DIR([aux1])
 AM_INIT_AUTOMAKE
 AC_CONFIG_FILES([Makefile sub/Makefile])
 AC_PROG_CC
-AM_PROG_CC_C_O
 AC_PROG_YACC
-AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
 SUBDIRS = sub
-
-test-time-unchanged:
-       test `ls -1t sub/main.$(OBJEXT) z | sed 1q` = z
-test-time-changed:
-       test `ls -1t sub/main.$(OBJEXT) z | sed 1q` = sub/main.$(OBJEXT)
+bin_PROGRAMS = foo
+AM_YFLAGS = -d
+foo_SOURCES = foo.y
 END
 
-mkdir aux1 sub
-
 cat > sub/Makefile.am << 'END'
-bin_PROGRAMS = foo bar
+bin_PROGRAMS = bar
 AM_YFLAGS = -d
-foo_SOURCES = foo.y main.c
-foo_CPPFLAGS = -DFOO
 bar_SOURCES = bar.y main.c
-BUILT_SOURCES = foo.h bar.h
 END
 
-cat > sub/foo.y << 'END'
-%{
-int yylex () {return 0;}
-void yyerror (char *s) {}
-%}
-%token TOKEN
-%%
-foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
-END
-
-cp sub/foo.y sub/bar.y
-
-cat >sub/main.c <<'EOF'
-#ifdef FOO
-#  include "foo.h"
-#else
-#  include "bar.h"
-#endif
-
-int
-main()
-{
-  return 0;
-}
-EOF
-
 $ACLOCAL
-$AUTOCONF
 $AUTOMAKE -a
 test -f aux1/ylwrap
 test ! -f ylwrap
 test ! -f sub/ylwrap
+grep -i 'ylwrap' Makefile.in sub/Makefile.in # For debugging.
+$FGREP '$(top_srcdir)/aux1/ylwrap' Makefile.in
 $FGREP '$(top_srcdir)/aux1/ylwrap' sub/Makefile.in
-./configure
-$MAKE
-grep '#.*line.*foo\.y' sub/foo.c
-grep '#.*line.*bar\.y' sub/bar.c
-
-$sleep
-: > z
-$sleep
-touch sub/bar.y
-$MAKE
-$MAKE test-time-unchanged
-$sleep
-sed s/TOKEN/TEKON/g sub/bar.y >sub/bar.yt
-mv -f sub/bar.yt sub/bar.y
-$MAKE
-$MAKE test-time-changed
 
 :
diff --git a/tests/yacc-basic.test b/tests/yacc-basic.test
index ee153f4..48f76c9 100755
--- a/tests/yacc-basic.test
+++ b/tests/yacc-basic.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2010, 2011, 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
@@ -14,7 +14,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Basic semantic checks on Yacc support.
+# Basic semantic checks on Yacc support (without yacc-generated headers).
+# Keep in sync with sister test `yacc-cxx.test'.
 
 required='cc yacc'
 . ./defs || Exit 1
@@ -26,8 +27,10 @@ AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
-bin_PROGRAMS = foo
+bin_PROGRAMS = foo bar
 foo_SOURCES = parse.y foo.c
+bar_SOURCES = $(foo_SOURCES)
+bar_YFLAGS = -v
 
 .PHONY: echo-distcom
 echo-distcom:
@@ -38,7 +41,7 @@ cat > parse.y << 'END'
 %{
 #include <stdio.h>
 #include <stdlib.h>
-int yylex () { return (getchar ()); }
+int yylex () { return getchar (); }
 void yyerror (char *s) {}
 %}
 %%
@@ -55,9 +58,14 @@ $AUTOMAKE -a
 
 ./configure
 $MAKE
-# The `parse.c' file must be created and not removed (i.e., not treated
-# like an "intermediate file" in the GNU make sense).
+ls -l
+# The Yacc-derived C sources must be created, and not removed once
+# compiled (i.e., not treated like "intermediate files" in the GNU
+# make sense).
 test -f parse.c
+test -f bar-parse.c
+# Check that per-object flags are honored.
+test -f bar-parse.output
 
 if cross_compiling; then :; else
   echo a | ./foo
@@ -65,23 +73,37 @@ if cross_compiling; then :; else
   : For shells with busted 'set -e'.
 fi
 
-# The generated file `parse.c' must be shipped.
+echo a | ./bar
+echo b | ./bar && Exit 1
+
+# The Yacc-derived C sources must be shipped.
 $MAKE echo-distcom
-$MAKE -s echo-distcom | grep '[ /]parse.c '
+$MAKE -s echo-distcom | grep '[ /]parse\.c '
+$MAKE -s echo-distcom | grep '[ /]bar-parse\.c '
 $MAKE distdir
 ls -l $distdir
 test -f $distdir/parse.c
+test -f $distdir/bar-parse.c
 
 # Sanity check on distribution.
-$MAKE distcheck
+# Note that, for this to succeed, bar-parse.output must either not
+# be distributed, or properly cleaned by automake-generated rules.
+# We don't want to set the exact semantics yet, but want to ensure
+# they are are consistent.
+yl_distcheck
 
-# While we are at it, make sure that parse.c is erased by
+# Make sure that the Yacc-derived C sources are erased by
 # maintainer-clean, and not by distclean.
 test -f parse.c
+test -f bar-parse.c
 $MAKE distclean
+ls -l
 test -f parse.c
-./configure # Re-create `Makefile'.
+test -f bar-parse.c
+./configure # We must re-create 'Makefile'.
 $MAKE maintainer-clean
+ls -l
 test ! -f parse.c
+test ! -f bar-parse.c
 
 :
diff --git a/tests/yacc-bison-skeleton-cxx.test 
b/tests/yacc-bison-skeleton-cxx.test
new file mode 100755
index 0000000..b080441
--- /dev/null
+++ b/tests/yacc-bison-skeleton-cxx.test
@@ -0,0 +1,100 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Test to make sure bison + bison's C++ skeleton + C++ works.
+# For Automake bug#7648 and PR automake/491.
+
+required=bison
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CXX
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.yy foo.cc
+
+# This is required even with %defines in zardoz.yy.
+AM_YFLAGS = -d
+
+BUILT_SOURCES = zardoz.hh
+EXTRA_DIST = stack.hh location.hh position.hh
+END
+
+cat > zardoz.yy << 'END'
+%skeleton "lalr1.cc"
+%defines
+
+%{
+#define YYSTYPE int
+int yylex(YYSTYPE* yylval_param);
+%}
+
+%%
+start :        /* empty */
+%%
+
+int
+yylex(YYSTYPE*)
+{
+    return 0;
+}
+
+void
+yy::parser::error(const yy::parser::location_type&, const std::string& m)
+{
+    return;
+}
+END
+
+cat > foo.cc << 'END'
+#include "zardoz.hh"
+
+using namespace std;
+
+int
+main(int argc, char** argv)
+{
+  yy::parser my_parser;
+  return my_parser.parse ();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try a VPATH build first.
+mkdir build
+cd build
+../configure YACC='bison -y'
+$MAKE
+cd ..
+
+# Now try an in-tree build.
+./configure YACC='bison -y'
+$MAKE
+
+# Check that distribution is self-contained, and do not require
+# bison to be built.
+env YACC=false DISTCHECK_CONFIGURE_FLAGS='YACC=false' $MAKE -e distcheck
+
+:
diff --git a/tests/yacc-dist-nobuild.test b/tests/yacc-bison-skeleton.test
similarity index 54%
copy from tests/yacc-dist-nobuild.test
copy to tests/yacc-bison-skeleton.test
index acdba6a..cc89a3d 100755
--- a/tests/yacc-dist-nobuild.test
+++ b/tests/yacc-bison-skeleton.test
@@ -14,12 +14,14 @@
 # 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 distributed Yacc-generated parsers are not uselessly
-# remade from an unpacked distributed tarball.
+# Test to make sure bison + bison's skeleton works.
+# For Automake bug#7648 and PR automake/491.
 
-required='cc yacc'
+required=bison
 . ./defs || Exit 1
 
+set -e
+
 cat >> configure.in << 'END'
 AC_PROG_CC
 AC_PROG_YACC
@@ -27,59 +29,46 @@ AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
-bin_PROGRAMS = foobar zardoz
-foobar_SOURCES = parse.y main.c
-zardoz_SOURCES = $(foobar_SOURCES)
-zardoz_YFLAGS = -d
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.y foo.c
+AM_YFLAGS = -d --skeleton glr.c
 END
 
-cat > parse.y << 'END'
+# Parser.
+cat > zardoz.y << 'END'
 %{
 int yylex () { return 0; }
-void yyerror (char *s) {}
+void yyerror (const char *s) { return; }
 %}
 %%
 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
 END
 
-cat > main.c << 'END'
-int main () { return 0; }
+cat > foo.c << 'END'
+#include "zardoz.h"
+int main (void)
+{
+  return yyparse ();
+}
 END
 
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-./configure
-$MAKE
-
-$MAKE distdir
-chmod -R a-w $distdir
-
-mkdir bin
-cat > bin/yacc <<'END'
-#!/bin/sh
-echo "$0 invoked, shouldn't happen!" >&2
-exit 1
-END
-cp bin/yacc bin/bison
-chmod a+x bin/yacc bin/bison
-PATH=`pwd`/bin$PATH_SEPARATOR$PATH
-
-YACC=yacc BISON=bison
-export YACC BISON
-
+# Try a VPATH build first.
 mkdir build
 cd build
-../$distdir/configure
+../configure YACC='bison -y'
+$MAKE
+cd ..
+
+# Now try an in-tree build.
+./configure YACC='bison -y'
 $MAKE
 
-# Sanity check.
-chmod u+w ../$distdir
-rm -f ../$distdir/parse.c
-chmod a-w ../$distdir
-$MAKE >out 2>&1 && { cat out; Exit 1; }
-cat out
-$FGREP parse.c out
+# Check that distribution is self-contained, and do not require
+# bison to be built.
+env YACC=false DISTCHECK_CONFIGURE_FLAGS='YACC=false' $MAKE -e distcheck
 
 :
diff --git a/tests/yacc-clean-cxx.test b/tests/yacc-clean-cxx.test
new file mode 100755
index 0000000..81d43e7
--- /dev/null
+++ b/tests/yacc-clean-cxx.test
@@ -0,0 +1,165 @@
+#! /bin/sh
+# Copyright (C) 2011 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 C++ source and header files derived from non-distributed
+# Yacc sources are cleaned by "make clean", while C++ source and
+# header files derived from distributed Yacc sources are cleaned by
+# "make maintainer-clean".
+# See also sister test `yacc-clean.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CXX
+AC_PROG_YACC
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# Use two subdirectories, one to test with `-d' in YFLAGS, the
+# other one to test with empty YFLAGS.
+SUBDIRS = sub1 sub2
+END
+
+mkdir sub1 sub2
+
+cat > sub1/Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz qux
+
+foo_SOURCES = mainfoo.cc parsefoo.yxx
+
+bar_SOURCES = mainbar.cpp parsebar.yy
+bar_YFLAGS = $(AM_YFLAGS)
+
+baz_SOURCES = mainbaz.c++
+nodist_baz_SOURCES = parsebaz.y++
+
+qux_SOURCES = mainqux.cxx
+nodist_qux_SOURCES = parsequx.ypp
+qux_YFLAGS = $(AM_YFLAGS)
+
+parsebaz.y++ parsequx.ypp:
+       cp $(srcdir)/parsefoo.yxx $@
+
+CLEANFILES = parsebaz.y++ parsequx.ypp
+END
+
+cat > sub2/Makefile.am << 'END'
+include $(top_srcdir)/sub1/Makefile.am
+AM_YFLAGS = -d
+END
+
+cat > sub1/parsefoo.yxx << 'END'
+%{
+// This file should contain valid C++ but invalid C.
+#include <cstdio>
+int yylex (void) { return (getchar ()); }
+void yyerror (const char *s) { return; }
+%}
+%%
+x : 'x' { };
+END
+cp sub1/parsefoo.yxx sub1/parsebar.yy
+cp sub1/parsefoo.yxx sub2/parsefoo.yxx
+cp sub1/parsefoo.yxx sub2/parsebar.yy
+
+cat > sub1/mainfoo.cc << 'END'
+// This file should contain valid C++ but invalid C.
+using namespace std;
+int main (int argc, char **argv)
+{
+  extern int yyparse (void);
+  return yyparse ();
+}
+END
+cp sub1/mainfoo.cc sub1/mainbar.cpp
+cp sub1/mainfoo.cc sub1/mainbaz.c++
+cp sub1/mainfoo.cc sub1/mainqux.cxx
+cp sub1/main???.c* sub2
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+cp config.status config.sav
+
+$MAKE
+ls -l . sub1 sub2
+# Sanity checks.
+test -f sub1/parsefoo.cxx
+test -f sub1/bar-parsebar.cc
+test -f sub1/parsebaz.y++
+test -f sub1/parsebaz.c++
+test -f sub1/parsequx.ypp
+test -f sub1/qux-parsequx.cpp
+test -f sub2/parsefoo.cxx
+test -f sub2/parsefoo.hxx
+test -f sub2/bar-parsebar.cc
+test -f sub2/bar-parsebar.hh
+test -f sub2/parsebaz.y++
+test -f sub2/parsebaz.c++
+test -f sub2/parsebaz.h++
+test -f sub2/parsequx.ypp
+test -f sub2/qux-parsequx.cpp
+test -f sub2/qux-parsequx.hpp
+
+for target in clean distclean; do
+  $MAKE $target
+  ls -l . sub1 sub2
+  test -f sub1/parsefoo.cxx
+  test -f sub1/bar-parsebar.cc
+  test ! -r sub1/parsebaz.y++
+  test ! -r sub1/parsebaz.c++
+  test ! -r sub1/parsequx.ypp
+  test ! -r sub1/qux-parsequx.cpp
+  test -f sub2/parsefoo.cxx
+  test -f sub2/parsefoo.hxx
+  test -f sub2/bar-parsebar.cc
+  test -f sub2/bar-parsebar.hh
+  test ! -r sub2/parsebaz.y++
+  test ! -r sub2/parsebaz.c++
+  test ! -r sub2/parsebaz.h++
+  test ! -r sub2/parsequx.ypp
+  test ! -r sub2/qux-parsequx.cpp
+  test ! -r sub2/qux-parsequx.hpp
+done
+
+cp config.sav config.status
+./config.status # re-create Makefile
+
+$MAKE maintainer-clean
+ls -l . sub1 sub2
+test -f sub1/parsefoo.yxx
+test -f sub1/parsebar.yy
+test ! -r sub1/parsefoo.cxx
+test ! -r sub1/bar-parsebar.cc
+test -f sub2/parsefoo.yxx
+test -f sub2/parsebar.yy
+test ! -r sub2/parsefoo.cxx
+test ! -r sub2/parsefoo.hxx
+test ! -r sub2/bar-parsebar.cc
+test ! -r sub2/bar-parsebar.hh
+
+cp config.sav config.status
+./config.status # re-create Makefile
+
+:
diff --git a/tests/yacc-clean.test b/tests/yacc-clean.test
index ca03466..9671b8c 100755
--- a/tests/yacc-clean.test
+++ b/tests/yacc-clean.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
+# Copyright (C) 2011, 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
@@ -17,6 +17,7 @@
 # Check that .c and .h files derived from non-distributed .y sources
 # are cleaned by "make clean", while .c and .h files derived from
 # distributed .y sources are cleaned by "make maintainer-clean".
+# See also sister test `yacc-cxx-clean.test'.
 
 required='cc yacc'
 . ./defs || Exit 1
@@ -143,11 +144,4 @@ test ! -r sub2/parse.h
 test ! -r sub2/bar-parse.c
 test ! -r sub2/bar-parse.h
 
-cp config.sav config.status
-./config.status # Re-create `Makefile'.
-
-# The distribution must work correctly, assuming the user has
-# the proper tools to process yacc files.
-$MAKE distcheck
-
 :
diff --git a/tests/yacc-cxx.test b/tests/yacc-cxx.test
new file mode 100755
index 0000000..430fe06
--- /dev/null
+++ b/tests/yacc-cxx.test
@@ -0,0 +1,139 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Basic semantic checks on Yacc + C++ support (when yacc-generated
+# headers are not involved).
+# Keep in sync with sister test `yacc-basic.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CXX
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo1 foo2 foo3 foo4
+foo1_SOURCES = parse1.yy  foo.cc
+foo2_SOURCES = parse2.y++ bar.c++
+foo3_SOURCES = parse3.yxx foo.cc
+foo4_SOURCES = parse4.ypp bar2.cxx
+foo3_YFLAGS = -v
+foo4_YFLAGS = $(foo3_YFLAGS)
+
+.PHONY: echo-distcom
+echo-distcom:
+       @echo ' ' $(DIST_COMMON) ' '
+END
+
+cat > parse1.yy << 'END'
+%{
+// Valid C++, but deliberately invalid C.
+#include <cstdio>
+#include <cstdlib>
+int yylex (void) { return getchar (); }
+void yyerror (const char *s) { return; }
+%}
+%%
+a : 'a' { exit(0); };
+END
+cp parse1.yy parse2.y++
+cp parse1.yy parse3.yxx
+cp parse1.yy parse4.ypp
+
+cat > foo.cc << 'END'
+// Valid C++, but deliberately invalid C.
+using namespace std;
+int main (int argc, char **argv)
+{
+  int yyparse (void);
+  yyparse ();
+  return 1;
+}
+END
+cp foo.cc bar.c++
+cp foo.cc bar2.cxx
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE
+
+# The Yacc-derived C++ sources must be created, and not removed once
+# compiled (i.e., not treated like "intermediate files" in the GNU
+# make sense).
+test -f parse1.cc
+test -f parse2.c++
+test -f foo3-parse3.cxx
+test -f foo4-parse4.cpp
+# Check that per-object flags are honored.
+test -f foo3-parse3.output
+test -f foo4-parse4.output
+
+for i in 1 2 3 4; do
+  echo a | ./foo$i
+  echo b | ./foo$i && Exit 1
+  : For shells with busted 'set -e'.
+done
+
+# The Yacc-derived C++ sources must be shipped.
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]parse1\.cc '
+$MAKE -s echo-distcom | grep '[ /]parse2\.c++ '
+$MAKE -s echo-distcom | grep '[ /]foo3-parse3\.cxx '
+$MAKE -s echo-distcom | grep '[ /]foo4-parse4\.cpp '
+$MAKE distdir
+ls -l $distdir
+test -f $distdir/parse1.cc
+test -f $distdir/parse2.c++
+test -f $distdir/foo3-parse3.cxx
+test -f $distdir/foo4-parse4.cpp
+
+# Sanity check on distribution.
+# Note that, for this to succeed, foo3-parse3.output and foo4-parse4.output
+# must either not be distributed, or properly cleaned by automake-generated
+# rules.  We don't want to set the exact semantics yet, but want to ensure
+# they are are consistent.
+yl_distcheck
+
+# Make sure that the Yacc-derived C++ sources are erased by
+# maintainer-clean, and not by distclean.
+test -f parse1.cc
+test -f parse2.c++
+test -f foo3-parse3.cxx
+test -f foo4-parse4.cpp
+$MAKE distclean
+ls -l
+test -f parse1.cc
+test -f parse2.c++
+test -f foo3-parse3.cxx
+test -f foo4-parse4.cpp
+./configure # we must re-create `Makefile'
+$MAKE maintainer-clean
+ls -l
+test ! -f parse1.cc
+test ! -f parse2.c++
+test ! -f foo3-parse3.cxx
+test ! -f foo4-parse4.cpp
+
+:
diff --git a/tests/yacc-d-basic.test b/tests/yacc-d-basic.test
index e705f06..f499bf0 100755
--- a/tests/yacc-d-basic.test
+++ b/tests/yacc-d-basic.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
+# Copyright (C) 2011, 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
@@ -14,14 +14,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Tests on basic Yacc support for when we have -d in YFLAGS, AM_YFLAGS
-# or maude_YFLAGS.
+# Tests Yacc support with yacc-generated headers
+# (i.e., '-d' in *YFLAGS).
+# Keep in sync with sister test `yacc-d-cxx.test'.
 
 required='cc yacc'
 . ./defs || Exit 1
 
-tab='  '
-
 cat >> configure.in << 'END'
 AC_PROG_CC
 AC_PROG_YACC
@@ -108,7 +107,7 @@ test -f bar/parse.h
 test -f baz/zardoz-parse.c
 test -f baz/zardoz-parse.h
 
-# The generated C and header files must be shipped.
+# The generated C source and header files must be shipped.
 for dir in foo bar; do
   cd $dir
   $MAKE echo-distcom
@@ -132,7 +131,7 @@ test -f $distdir/baz/zardoz-parse.c
 test -f $distdir/baz/zardoz-parse.h
 
 # Sanity check the distribution.
-$MAKE distcheck
+yl_distcheck
 
 # While we are at it, make sure that `parse.c' and `parse.h' are erased
 # by maintainer-clean, and not by distclean.
diff --git a/tests/yacc-d-cxx.test b/tests/yacc-d-cxx.test
new file mode 100755
index 0000000..13bb094
--- /dev/null
+++ b/tests/yacc-d-cxx.test
@@ -0,0 +1,233 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Various tests on Yacc/C++ support with yacc-generated headers
+# (i.e., '-d' in *YFLAGS).
+# Keep in sync with sister test `yacc-d-basic.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+write_parse ()
+{
+  header=$1
+  sed 's/^ *//' <<END
+    %{
+    // Valid C++, but deliberately invalid C.
+    #include <cstdlib>
+    #include "$header"
+    int yylex (void) { return 0; }
+    void yyerror (const char *s) {}
+    %}
+    %%
+    x : 'x' {};
+    %%
+END
+}
+
+write_main ()
+{
+  header=$1
+  sed 's/^ *//' <<END
+    // Valid C++, but deliberately invalid C.
+    #include <cstdio>
+    #include "$header"
+    int main (int argc, char **argv)
+    {
+      int yyparse (void);
+      return yyparse ();
+    }
+END
+}
+
+cat >> configure.in << 'END'
+AC_PROG_CXX
+AC_PROG_YACC
+AC_CONFIG_FILES([foo/Makefile bar/Makefile baz/Makefile qux/Makefile])
+AC_OUTPUT
+END
+
+mkdir foo bar baz qux baz/sub
+
+# These makefiles will be extended later.
+cat > Makefile.am <<'END'
+.PHONY: echo-distcom
+echo-distcom:
+       @echo ' ' $(DIST_COMMON) ' '
+END
+cp Makefile.am foo/Makefile.am
+cp Makefile.am bar/Makefile.am
+cp Makefile.am baz/Makefile.am
+cp Makefile.am qux/Makefile.am
+
+cat >> Makefile.am <<'END'
+SUBDIRS = foo bar baz qux
+END
+
+$ACLOCAL
+$AUTOCONF
+
+cp $testsrcdir/../lib/ylwrap .
+
+$AUTOMAKE Makefile
+
+# Try with -d in $(YFLAGS) (don't do this in real life!).
+cat >> foo/Makefile.am <<END
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = parse.yy main.cc
+BUILT_SOURCES = parse.hh
+YFLAGS=\
+-d
+END
+
+$AUTOMAKE -Wno-gnu foo/Makefile
+
+write_parse parse.hh > foo/parse.yy
+write_main parse.hh > foo/main.cc
+
+# Try with -d in $(AM_YFLAGS).
+cat >> bar/Makefile.am <<END
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = parse.ypp main.cpp
+BUILT_SOURCES = parse.hpp
+AM_YFLAGS${tab}=  -d ${tab}
+END
+
+$AUTOMAKE bar/Makefile
+
+write_parse parse.hpp > bar/parse.ypp
+write_main parse.hpp > bar/main.cpp
+
+# Try with -d in $(AM_YFLAGS), and a subdir parser.
+cat >> baz/Makefile.am <<END
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = joe
+joe_SOURCES = sub/parse.y++ sub/main.c++
+BUILT_SOURCES = sub/parse.h++
+AM_YFLAGS = \
+${tab}-d
+END
+
+$AUTOMAKE baz/Makefile
+
+write_parse sub/parse.h++ > baz/sub/parse.y++
+write_main sub/parse.h++ > baz/sub/main.c++
+
+# Try with -d in $(xxx_YFLAGS) (per-object flag).
+cat >> qux/Makefile.am <<END
+bin_PROGRAMS = maude
+maude_SOURCES = parse.yxx main.cxx
+maude_YFLAGS=${tab}  -d${tab}
+BUILT_SOURCES = maude-parse.hxx
+END
+
+$AUTOMAKE qux/Makefile
+
+write_parse maude-parse.hxx > qux/parse.yxx
+write_main maude-parse.hxx > qux/main.cxx
+
+./configure
+
+$MAKE
+ls -l . foo bar baz baz/sub qux # For debugging.
+
+test -f foo/parse.cc
+test -f foo/parse.hh
+test -f bar/parse.cpp
+test -f bar/parse.hpp
+test -f baz/sub/parse.c++
+test -f baz/sub/parse.h++
+test -f qux/maude-parse.cxx
+test -f qux/maude-parse.hxx
+
+# The ylwrap script must be shipped.
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]ylwrap '
+
+# The generated C++ source and header files must be shipped.
+cd foo
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]parse\.cc '
+$MAKE -s echo-distcom | grep '[ /]parse\.hh '
+cd ..
+cd bar
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]parse\.cpp '
+$MAKE -s echo-distcom | grep '[ /]parse\.hpp '
+cd ..
+cd baz
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]sub/parse\.c++ '
+$MAKE -s echo-distcom | grep '[ /]sub/parse\.h++ '
+cd ..
+cd qux
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]maude-parse\.cxx '
+$MAKE -s echo-distcom | grep '[ /]maude-parse\.hxx '
+cd ..
+
+$MAKE distdir
+find $distdir # For debugging.
+
+test -f $distdir/ylwrap
+test -f $distdir/foo/parse.cc
+test -f $distdir/foo/parse.hh
+test -f $distdir/bar/parse.cpp
+test -f $distdir/bar/parse.hpp
+test -f $distdir/baz/sub/parse.c++
+test -f $distdir/baz/sub/parse.h++
+test -f $distdir/qux/maude-parse.cxx
+test -f $distdir/qux/maude-parse.hxx
+
+# The Yacc-derived C++ sources must be created, and not removed once
+# compiled (i.e., not treated like "intermediate files" in the GNU
+# make sense).
+yl_distcheck
+
+# Check that we can recover from deleted headers.
+$MAKE clean
+rm -f foo/parse.hh bar/parse.hpp baz/sub/parse.h++ qux/maude-parse.hxx
+$MAKE
+test -f foo/parse.hh
+test -f bar/parse.hpp
+test -f baz/sub/parse.h++
+test -f qux/maude-parse.hxx
+
+# Make sure that the Yacc-derived C++ sources are erased by
+# maintainer-clean, and not by distclean.
+$MAKE distclean
+test -f foo/parse.cc
+test -f foo/parse.hh
+test -f bar/parse.cpp
+test -f bar/parse.hpp
+test -f baz/sub/parse.c++
+test -f baz/sub/parse.h++
+test -f qux/maude-parse.cxx
+test -f qux/maude-parse.hxx
+./configure # We must re-create `Makefile'.
+$MAKE maintainer-clean
+test ! -f foo/parse.cc
+test ! -f foo/parse.hh
+test ! -f bar/parse.cpp
+test ! -f bar/parse.hpp
+test ! -f baz/sub/parse.c++
+test ! -f baz/sub/parse.h++
+test ! -f qux/maude-parse.cxx
+test ! -f qux/maude-parse.hxx
+
+:
diff --git a/tests/yacc-d-vpath.test b/tests/yacc-d-vpath.test
index 87e6946..9c437aa 100755
--- a/tests/yacc-d-vpath.test
+++ b/tests/yacc-d-vpath.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
+# Copyright (C) 2011, 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
@@ -40,7 +40,7 @@ END
 # Original parser, with `foobar'.
 cat > parse.y << 'END'
 %{
-int yylex () {return 0;}
+int yylex () { return 0; }
 void yyerror (char *s) {}
 %}
 %token FOOBAR
@@ -73,7 +73,7 @@ $sleep
 # New parser, with `fubar'.
 cat > ../parse.y << 'END'
 %{
-int yylex () {return 0;}
+int yylex () { return 0; }
 void yyerror (char *s) {}
 %}
 %token FUBAR
@@ -93,7 +93,7 @@ $sleep
 # New parser, with `maude'.
 cat > ../parse.y << 'END'
 %{
-int yylex () {return 0;}
+int yylex () { return 0; }
 void yyerror (char *s) {}
 %}
 %token MAUDE
diff --git a/tests/yacc-deleted-headers.test b/tests/yacc-deleted-headers.test
new file mode 100755
index 0000000..6d6a0a1
--- /dev/null
+++ b/tests/yacc-deleted-headers.test
@@ -0,0 +1,165 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Tests that we can recover from deleted headers generated by `yacc -d'.
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = p1 p2 p3 p4
+# The order in which files are listed in the p*_SOURCES variables
+# below is significant, since it causes make failures whenever
+# the proper definition of BUILT_SOURCES or the declaration of
+# extra dependencies for `main3.o' are removed.
+p1_SOURCES = main1.c parse1.y
+p2_SOURCES = main2.c parse2.y
+p3_SOURCES = main3.c parse3.y parse3.h
+p4_SOURCES = parse4.y
+AM_YFLAGS = -d
+p2_YFLAGS = -d
+
+BUILT_SOURCES = parse1.h p2-parse2.h
+
+# When we know which files include a yacc-generated header, we
+# should be able to just declare dependencies directly instead
+# of relying on the BUILT_SOURCES hack, and things should still
+# work correctly.
address@hidden@: parse3.h
+
+.PHONY: clean-p3 build-p3
+build-p3: p3$(EXEEXT)
+clean-p3:
+       rm -f p3$(EXEEXT)
+END
+
+cat > parse1.y << 'END'
+%{
+#include "parse1.h"
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%token ZARDOZ
+%%
+x : 'x' {};
+%%
+END
+
+cat > main1.c << 'END'
+#include "parse1.h"
+int main (void)
+{
+  return ZARDOZ + yyparse ();
+}
+END
+
+sed 's/"parse1\.h"/"p2-parse2.h"/' parse1.y > parse2.y
+sed 's/"parse1\.h"/"p2-parse2.h"/' main1.c > main2.c
+
+sed 's/"parse1\.h"/"parse3.h"/' parse1.y > parse3.y
+sed 's/"parse1\.h"/"parse3.h"/' main1.c > main3.c
+
+cat > parse4.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%%
+x : 'x' {};
+%%
+int main (void)
+{
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+
+headers='parse1.h p2-parse2.h parse3.h parse4.h'
+
+# Check that we remake only the necessary headers.
+
+rm -f $headers
+$MAKE parse1.h
+test -f parse1.h
+test ! -r p2-parse2.h
+test ! -r parse3.h
+test ! -r parse4.h
+
+rm -f $headers
+$MAKE p2-parse2.h
+test ! -r parse1.h
+test -f p2-parse2.h
+test ! -r parse3.h
+test ! -r parse4.h
+
+rm -f $headers
+$MAKE parse3.h
+test ! -r parse1.h
+test ! -r p2-parse2.h
+test -f parse3.h
+test ! -r parse4.h
+# Since we declared parse3.h into $(p3_SOURCES), make should be
+# able to rebuild it automatically before remaking `p3'.
+rm -f $headers
+$MAKE clean-p3
+test ! -f parse3.h # Sanity check.
+$MAKE build-p3
+test -f parse3.h
+
+$MAKE
+
+rm -f $headers
+$MAKE parse4.h
+test ! -r parse1.h
+test ! -r p2-parse2.h
+test ! -r parse3.h
+test -f parse4.h
+
+# Now remake all the headers together.
+
+rm -f $headers
+$MAKE $headers
+test -f parse1.h
+test -f p2-parse2.h
+test -f parse3.h
+test -f parse4.h
+
+# Most headers should be remade by "make all".
+
+rm -f $headers
+$MAKE all
+test -f parse1.h
+test -f p2-parse2.h
+test -f parse3.h
+# parse4.h is not declared in any *_SOURCES variable, nor #included
+# by any C source file, so it shouldn't be rebuilt by "make all".
+test ! -r parse4.h
+
+:
diff --git a/tests/yacc-depend.test b/tests/yacc-depend.test
new file mode 100755
index 0000000..2f708ec
--- /dev/null
+++ b/tests/yacc-depend.test
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 2010, 2011 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/>.
+
+# Make sure depcomp does not needlessly update headers for yacc rules.
+# Report from Paolo Bonzini.
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+AM_YFLAGS = -d
+foo_SOURCES = foo.y main.c
+BUILT_SOURCES = foo.h
+END
+
+cat > foo.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%token TOKEN
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+
+cat > main.c << 'END'
+#include "foo.h"
+int main(void)
+{
+  return yyparse ();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try to enable dependency tracking if possible, even if that means
+# using slow dependency extractors.
+./configure --enable-dependency-tracking
+$MAKE
+ls -l # For debugging.
+
+# Make sure foo.h is not updated if not really needed.
+$sleep
+: > my-timestamp
+$sleep
+touch foo.y
+$MAKE
+stat my-timestamp foo.* || : # For debugging.
+is_newest my-timestamp foo.h
+
+# Make sure foo.h is updated if needed.
+$sleep
+sed 's/TOKEN/TEKON/g' foo.y > t
+mv -f t foo.y
+$MAKE
+stat my-timestamp foo.* || : # For debugging.
+is_newest foo.h my-timestamp
+
+:
diff --git a/tests/yacc-depend2.test b/tests/yacc-depend2.test
new file mode 100755
index 0000000..51c1fe1
--- /dev/null
+++ b/tests/yacc-depend2.test
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 2010, 2011 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/>.
+
+# Make sure depcomp does not needlessly update headers and objects
+# for yacc rules.  This test still fails with FreeBSD make (but passes
+# with NetBSD make).
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+AM_YFLAGS = -d
+foo_SOURCES = foo.y main.c
+BUILT_SOURCES = foo.h
+.PHONY: debug-info test-time-unchanged test-time-changed
+debug-info:
+       ls -l
+       stat *.[ch] *.$(OBJEXT) my-timestamp || :
+test-time-unchanged: debug-info
+       test `ls -1t main.$(OBJEXT) my-timestamp | sed 1q` = my-timestamp
+test-time-changed: debug-info
+       test `ls -1t main.$(OBJEXT) my-timestamp | sed 1q` = main.$(OBJEXT)
+END
+
+cat > foo.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%token TOKEN
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+
+cat > main.c << 'END'
+#include "foo.h"
+int main(void)
+{
+  return yyparse ();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try to enable dependency tracking if possible, even if that means
+# using slow dependency extractors.
+./configure --enable-dependency-tracking
+$MAKE
+ls -l # For debugging.
+
+$sleep
+: > my-timestamp
+$sleep
+touch foo.y
+$MAKE
+$MAKE test-time-unchanged
+$sleep
+sed 's/TOKEN/TEKON/g' foo.y > t
+mv -f t foo.y
+$MAKE
+$MAKE test-time-changed
+
+:
diff --git a/tests/yacc-dist-nobuild-subdir.test 
b/tests/yacc-dist-nobuild-subdir.test
index 7ae38b2..de12d77 100755
--- a/tests/yacc-dist-nobuild-subdir.test
+++ b/tests/yacc-dist-nobuild-subdir.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
+# Copyright (C) 2011, 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
@@ -21,7 +21,9 @@
 required=yacc
 . ./defs || Exit 1
 
-distdir=$me-1.0
+# This test is bounded to fail for any implementation that
+# triggers automake bug#7884.
+useless_vpath_rebuild && skip_ "would trip on automake bug#7884"
 
 cat >> configure.in << 'END'
 AC_PROG_CC
diff --git a/tests/yacc-dist-nobuild.test b/tests/yacc-dist-nobuild.test
index acdba6a..942bec5 100755
--- a/tests/yacc-dist-nobuild.test
+++ b/tests/yacc-dist-nobuild.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
+# Copyright (C) 2011, 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
@@ -16,6 +16,7 @@
 
 # Check that distributed Yacc-generated parsers are not uselessly
 # remade from an unpacked distributed tarball.
+# See automake bug#7884.
 
 required='cc yacc'
 . ./defs || Exit 1
diff --git a/tests/yacc-line.test b/tests/yacc-line.test
new file mode 100755
index 0000000..f760b72
--- /dev/null
+++ b/tests/yacc-line.test
@@ -0,0 +1,116 @@
+#! /bin/sh
+# Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 2010, 2011 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 yacc support ensures that yacc-generated C
+# files use correct "#line" directives.  Try also with the
+# `subdir-object' option enabled.
+# See also sister test `lex-line.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+mkdir dir sub sub/dir
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo bar
+AM_YFLAGS = -d
+bar_YFLAGS =
+foo_SOURCES = zardoz.y
+bar_SOURCES = dir/quux.y
+## Avoid spurious failures with Solaris make.
address@hidden@: zardoz.c
address@hidden@: bar-quux.c
+END
+
+cat > sub/Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_PROGRAMS = foo bar
+foo_YFLAGS = -d
+foo_SOURCES = zardoz.y
+bar_SOURCES = dir/quux.y
+## Avoid spurious failures with Solaris make.
address@hidden@: foo-zardoz.c
+dir/address@hidden@: dir/quux.c
+END
+
+cat > zardoz.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%%
+x : 'x' {};
+%%
+int main(void)
+{
+  return yyparse ();
+}
+END
+
+cp zardoz.y dir/quux.y
+cp zardoz.y sub/zardoz.y
+cp zardoz.y sub/dir/quux.y
+
+c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+for vpath in : false; do
+
+  if $vpath; then
+    srcdir=..
+    mkdir build
+    cd build
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+  $MAKE
+
+  # For debugging,
+  ls -l . sub sub/dir
+  $FGREP '.y' $c_outputs
+
+  # Adjusted "#line" should not contain reference to the builddir.
+  $EGREP '#.*line.*(build|\.\.).*\.y' $c_outputs && Exit 1
+  # Adjusted "#line" should not contain reference to the default
+  # output file names, e.g., `y.tab.c' and `y.tab.h'.
+  $EGREP '#.*line.*y\.tab\.' $c_outputs && Exit 1
+  # Don't be excessively strict in grepping, to avoid spurious failures.
+  grep '#.*line.*zardoz\.y' zardoz.c
+  grep '#.*line.*quux\.y' bar-quux.c
+  grep '#.*line.*zardoz\.y' sub/foo-zardoz.c
+  grep '#.*line.*quux\.y' sub/dir/quux.c
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/yacc-mix-c-cxx.test b/tests/yacc-mix-c-cxx.test
new file mode 100755
index 0000000..4765b5c
--- /dev/null
+++ b/tests/yacc-mix-c-cxx.test
@@ -0,0 +1,208 @@
+#! /bin/sh
+# Copyright (C) 2011 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 many different Yacc parsers (both C and C++) can co-exists
+# in the same directory.
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = c1 c2 cxx1 cxx2 cxx3
+AM_YFLAGS = -d
+
+c1_SOURCES = p.y p.h 1.c
+c2_SOURCES = p.y 2.c
+c2_YFLAGS =
+
+cxx1_SOURCES = parse.yy main1.cc parse.hh
+
+cxx2_SOURCES = parse2.y++ main2.c++
+cxx2_YFLAGS =
+
+cxx3_SOURCES = parse3.yxx main3.cxx
+
+BUILT_SOURCES = p.h parse.hh parse3.hxx
+END
+
+# The content of all the .c and .y files created below is valid C but
+# deliberately invalid C++.
+# Vice versa, the content of all the .c++, .cxx, .cc, .y++, .yxx and
+# .yy files created below is valid C++ but deliberately invalid C.
+
+cat > p.y <<'END'
+%{
+int yylex (void) { int new = 0; return new; }
+void yyerror (char *s) { return; }
+%}
+%token ZARDOZ
+%%
+x : 'x' {};
+%%
+END
+
+cat > 1.c <<'END'
+#include "p.h"
+int main ()
+{
+    int new = ZARDOZ;
+    return yyparse () + new;
+}
+
+END
+
+cat > 2.c <<'END'
+int main ()
+{
+    int yyparse ();
+    int new = 0;
+    return yyparse () + new;
+}
+END
+
+cat > parse.yy <<'END'
+%{
+#include <cstdlib>
+#include "parse.hh"
+int yylex (void) { return 0; }
+void yyerror (const char *s) { return; }
+%}
+%token FOOBAR
+%%
+x : 'x' {};
+%%
+END
+
+cat > parse2.y++ <<'END'
+%{
+#include <cstdlib>
+int yylex (void) { return 0; }
+void yyerror (const char *s) { return; }
+%}
+%%
+x : 'x' {};
+%%
+END
+
+cat > main1.cc <<'END'
+using namespace std;
+#include "parse.hh"
+int main (int argc, char **argv)
+{
+    int yyparse (void);
+    return yyparse () + FOOBAR;
+}
+END
+
+cat > main2.c++ <<'END'
+using namespace std;
+int main (int argc, char **argv)
+{
+    int yyparse (void);
+    return yyparse ();
+}
+END
+
+edit () { sed -e 's/FOOBAR/BAZQUUX/' -e 's/"parse\.hh"/"parse3.hxx"/'; }
+edit <parse.yy >parse3.yxx
+edit <main1.cc >main3.cxx
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try a VPATH and by default serial build first, and then an in-tree
+# and by default parallel build.
+
+for try in 0 1; do
+
+  if test $try -eq 0; then
+    # VPATH serial build.
+    mkdir build
+    cd build
+    srcdir=..
+    debug_info="ls -l . $srcdir"
+    run_make=$MAKE
+  elif test $try -eq 1; then
+    # In-tree parallel build.
+    srcdir=.
+    debug_info="ls -l"
+    case $MAKE in
+      *\ -j*)
+        # Degree of parallelism already specified by the user: do
+        # not override it.
+        run_make=$MAKE;;
+      *)
+        # Some make implementations (e.g., HP-UX) don't grok `-j',
+        # some require no space between `-j' and the number of jobs
+        # (e.g., older GNU make versions), and some *do* require a
+        # space between `-j' and the number of jobs (e.g., Solaris
+        # dmake).  We need a runtime test to see what works.
+        echo 'all:' > Makefile
+        for run_make in "$MAKE -j3" "$MAKE -j 3" "$MAKE"; do
+          $run_make && break
+        done
+        rm -f Makefile
+    esac
+  else
+    echo "$me: invalid value of \$try '$try'" >&2
+    Exit 99
+  fi
+
+  $srcdir/configure
+
+  $run_make
+  $debug_info
+
+  test -f p.c
+  test -f p.h
+  test -f c2-p.c
+  test ! -r c2-p.h
+
+  test -f parse.cc
+  test -f parse.hh
+  test -f parse3.cxx
+  test -f parse3.hxx
+
+  test -f cxx2-parse2.c++
+  test ! -r parse2.h++
+  test ! -r cxx2-parse2.h++
+
+  # Minimal checks about recovering from header removal.
+  rm -f p.h parse.hh parse3.hxx
+  $run_make p.h parse.hh
+  $debug_info
+  test -f p.h
+  test -f parse.hh
+  test ! -r parse3.hxx
+  $run_make
+  $debug_info
+  test -f parse3.hxx
+
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/yacc-nodist.test b/tests/yacc-nodist.test
index 83f63dd..4b92c1e 100755
--- a/tests/yacc-nodist.test
+++ b/tests/yacc-nodist.test
@@ -14,7 +14,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Checks for .c and .h files derived from non-distributed .y sources.
+# Checks for .c and .h files derived from non-distributed yacc sources.
+# The test 'yacc-pr204.test' does similar check with AM_MAINTAINER_MODE
+# enabled.
+# The tests 'lex-nodist.test' and 'lex-pr204.test' does similar checks
+# for lex-generated .c files.
 
 required='cc yacc'
 . ./defs || Exit 1
@@ -28,7 +32,7 @@ END
 
 cat > Makefile.am << 'END'
 SUBDIRS = sub1 sub2
-.PHONY: test
+.PHONY: test-build test-dist
 test-build: all
        ls -l . sub1 sub2
        test -f sub1/parse.y
@@ -60,8 +64,8 @@ parse.y:
          && echo "%%" \
          && echo "maude : 'm' 'a' 'u' 'd' 'e' {}"; \
        } > address@hidden
-       chmod a-w address@hidden
-       mv -f address@hidden $@
+       chmod a-w address@hidden && mv -f address@hidden $@
+
 bin_PROGRAMS = prog
 prog_SOURCES = main.c
 nodist_prog_SOURCES = parse.y
@@ -93,7 +97,8 @@ $MAKE test-build
 $MAKE test-dist
 
 # But the distribution must work correctly, assuming the user has
-# the proper tools to process yacc files.
-$MAKE distcheck
+# the proper tools to process yacc files.  Do this check only with
+# GNU make, to avoid tripping on automake bug#7884.
+if using_gmake; then $MAKE distcheck; fi
 
 :
diff --git a/tests/pr204.test b/tests/yacc-pr204.test
similarity index 77%
rename from tests/pr204.test
rename to tests/yacc-pr204.test
index 1c4b0fa..bab841a 100755
--- a/tests/pr204.test
+++ b/tests/yacc-pr204.test
@@ -1,5 +1,6 @@
 #! /bin/sh
-# Copyright (C) 2002, 2004, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2004, 2010, 2011, 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
@@ -15,7 +16,10 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # For PR 204.
-# Sources derived from nodist_ sources should not be distributed.
+# C sources derived from nodist_ yacc sources should not be distributed.
+# See also related test `yacc-nodist.test'.
+# The tests 'lex-nodist.test' and 'lex-pr204.test' does similar checks
+# for lex-generated C files.
 
 required='cc yacc'
 . ./defs || Exit 1
@@ -71,9 +75,11 @@ test -f parse2.c
 # Ensure the rebuild rule works despite AM_MAINTAINER_MODE, because
 # it's a nodist_ parser.
 $sleep
-touch parse.y
+touch parse.y parse2.y
 $sleep
 $MAKE parse.c parse2.c
-test `ls -1t parse.c parse.y | sed 1q` = parse.c
+stat parse.c parse.y parse2.c parse2.y || : # For debugging.
+test `ls -t parse.c parse.y | sed 1q` = parse.c
+test `ls -t parse2.c parse2.y | sed 1q` = parse2.c
 
 :
diff --git a/tests/ar-lib4.test b/tests/yacc-weirdnames.test
similarity index 57%
copy from tests/ar-lib4.test
copy to tests/yacc-weirdnames.test
index fb0ca5f..8f0424e 100755
--- a/tests/ar-lib4.test
+++ b/tests/yacc-weirdnames.test
@@ -14,42 +14,43 @@
 # 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 if lib_LTLIBRARIES requests AM_PROG_AR.
+# Check that yacc sources with many dots in their name are handled
+# correctly.
 
-required=libtoolize
 . ./defs || Exit 1
 
-cp configure.in X
+set -e
 
 cat >> configure.in << 'END'
 AC_PROG_CC
-AC_PROG_RANLIB
-AC_PROG_LIBTOOL
+AC_PROG_CXX
+AC_PROG_YACC
 AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
-lib_LTLIBRARIES = libfoo.la
-libfoo_la_SOURCES = foo.c
-END
-
-libtoolize
-$ACLOCAL
-AUTOMAKE_fails
+bin_PROGRAMS = foo bar foo2 bar2
 
-grep 'requires.*AM_PROG_AR' stderr
+foo_SOURCES = parse.y.y
+bar_SOURCES = parse.s.f..y
+bar_YFLAGS = -d
 
-cp X configure.in
-
-cat >> configure.in << 'END'
-AC_PROG_CC
-AM_PROG_AR
-AC_PROG_RANLIB
-AC_PROG_LIBTOOL
-AC_OUTPUT
+foo2_SOURCES = parse..5.y++
+bar2_SOURCES = parse.yxx.yy
+bar2_YFLAGS = -d
 END
 
+outputs=' parse.y.c      bar-parse.s.f..c   bar-parse.s.f..h
+          parse..5.c++   bar2-parse.yxx.cc  bar2-parse.yxx.hh '
+
 $ACLOCAL
-$AUTOMAKE --add-missing
+$AUTOMAKE -a
+
+$EGREP '(\.[ch]|parse)' Makefile.in # For debugging.
+
+# All expected files should be mentioned in the generated Makefile.in.
+for s in $outputs; do
+  $FGREP $s Makefile.in
+done
 
 :
diff --git a/tests/yacc4.test b/tests/yacc4.test
index eee210e..f50bebd 100755
--- a/tests/yacc4.test
+++ b/tests/yacc4.test
@@ -1,5 +1,6 @@
 #! /bin/sh
-# Copyright (C) 2001, 2002, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2010, 2011, 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
@@ -34,7 +35,7 @@ END
 # First parser.
 cat > parse.y << 'END'
 %{
-int yylex () {return 0;}
+int yylex () { return 0; }
 void yyerror (char *s) {}
 %}
 %%
diff --git a/tests/yacc8.test b/tests/yacc8.test
index ec04a75..b33b6fd 100755
--- a/tests/yacc8.test
+++ b/tests/yacc8.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2002, 2003, 2004, 2006, 2010, 2011 Free Software
+# Copyright (C) 2002, 2003, 2004, 2006, 2010, 2011, 2012 Free Software
 # Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -50,7 +50,7 @@ mkdir foo
 
 cat > foo/parse.y << 'END'
 %{
-int yylex () {return 0;}
+int yylex () { return 0; }
 void yyerror (char *s) {}
 %}
 %%
diff --git a/tests/yaccdry.test b/tests/yaccdry.test
index fed10d3..9e87f72 100755
--- a/tests/yaccdry.test
+++ b/tests/yaccdry.test
@@ -37,7 +37,7 @@ END
 
 cat > parse.y << 'END'
 %{
-int yylex () {return 0;}
+int yylex () { return 0; }
 void yyerror (char *s) {}
 %}
 %%
diff --git a/tests/yaccpp.test b/tests/yaccpp.test
index 0d0591d..d9ea112 100755
--- a/tests/yaccpp.test
+++ b/tests/yaccpp.test
@@ -15,8 +15,10 @@
 # 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 to make sure Yacc + C++ is supported.
-# Please keep this is sync with sister test lexcpp.test.
+# Test to make sure Yacc + C++ is not obviously broken.
+# See also related tests `yacc-cxx.test' and `yacc-d-cxx.test',
+# which does much more in-depth checks (but requires an actual
+# Yacc program and a working C++ compiler).
 
 . ./defs || Exit 1
 
@@ -36,10 +38,45 @@ END
 $ACLOCAL
 $AUTOMAKE -a
 
+$EGREP '(\.[ch]|foo|bar|baz|qux)' Makefile.in # For debugging.
+
+$EGREP '(foo|bar|baz|qux)\.h' Makefile.in && Exit 1
+
 sed -e 's/^/ /' -e 's/$/ /' Makefile.in >mk
+
 $FGREP ' foo.c++ ' mk
 $FGREP ' bar.cpp ' mk
 $FGREP ' baz.cc '  mk
 $FGREP ' qux.cxx ' mk
 
+cat >> Makefile.am <<END
+AM_YFLAGS = -d
+qux_YFLAGS = foo
+END
+
+$AUTOMAKE
+
+$EGREP '(\.[ch]|foo|bar|baz|qux)' Makefile.in # For debugging.
+
+sed -e 's/^/ /' -e 's/$/ /' Makefile.in >mk
+
+$FGREP ' foo.c++ ' mk
+$FGREP ' foo.h++ ' mk
+$FGREP ' bar.cpp ' mk
+$FGREP ' bar.hpp ' mk
+$FGREP ' baz.cc '  mk
+$FGREP ' baz.hh '  mk
+
+$EGREP '(^| )foo\.h\+\+(:| .*:)' Makefile.in
+$EGREP '(^| )bar\.hpp(:| .*:)'   Makefile.in
+$EGREP '(^| )baz\.hh(:| .*:)'    Makefile.in
+
+grep ' foo\.h[ :]' mk && Exit 1
+grep ' bar\.h[ :]' mk && Exit 1
+grep ' baz\.h[ :]' mk && Exit 1
+
+$FGREP ' qux-qux.cxx ' mk
+$EGREP '(^| )qux-qux\.cxx(:| .*:)' Makefile.in
+grep 'qux\.h.*:' Makefile.in && Exit 1
+
 :
diff --git a/tests/yaccvpath.test b/tests/yaccvpath.test
index c98fb46..922c53e 100755
--- a/tests/yaccvpath.test
+++ b/tests/yaccvpath.test
@@ -1,6 +1,6 @@
 #! /bin/sh
-# Copyright (C) 2001, 2002, 2003, 2010, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2001, 2002, 2003, 2010, 2011, 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
@@ -26,8 +26,6 @@
 required='cc yacc'
 . ./defs || Exit 1
 
-distdir=$me-1.0
-
 cat >> configure.in << 'END'
 AC_PROG_CC
 AC_PROG_YACC
@@ -42,7 +40,7 @@ END
 # Original parser, with `foobar'.
 cat > parse.y << 'END'
 %{
-int yylex () {return 0;}
+int yylex () { return 0; }
 void yyerror (char *s) {}
 %}
 %%
@@ -69,7 +67,7 @@ $sleep
 # New parser, with `fubar'.
 cat > ../parse.y << 'END'
 %{
-int yylex () {return 0;}
+int yylex () { return 0; }
 void yyerror (char *s) {}
 %}
 %%
@@ -87,7 +85,7 @@ $sleep
 # New parser, with `maude'.
 cat > ../parse.y << 'END'
 %{
-int yylex () {return 0;}
+int yylex () { return 0; }
 void yyerror (char *s) {}
 %}
 %%
diff --git a/tests/yflags-force-override.test b/tests/yflags-force-override.test
index 3ed1b38..de2a363 100755
--- a/tests/yflags-force-override.test
+++ b/tests/yflags-force-override.test
@@ -59,6 +59,4 @@ test -f foo.c
 test -f foo.h
 test -f foo.output
 
-$MAKE distcheck
-
 :


hooks/post-receive
-- 
GNU Automake



reply via email to

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