automake-commit
[Top][All Lists]
Advanced

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

[Automake-commit] [SCM] GNU Automake branch, yacc-work, updated. v1.11-2


From: Stefano Lattarini
Subject: [Automake-commit] [SCM] GNU Automake branch, yacc-work, updated. v1.11-285-g06efe9c
Date: Mon, 21 Mar 2011 20:24:33 +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=06efe9c467768a25c374b5d47dc8f1412874352d

The branch, yacc-work has been updated
       via  06efe9c467768a25c374b5d47dc8f1412874352d (commit)
       via  34ca92b99405c5d0361a64a2eb9a70d0f6f0c3cd (commit)
      from  076f8a295193344e77e1f9e37a908978688c3600 (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 06efe9c467768a25c374b5d47dc8f1412874352d
Author: Stefano Lattarini <address@hidden>
Date:   Fri Jan 21 17:47:42 2011 +0100

    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.

commit 34ca92b99405c5d0361a64a2eb9a70d0f6f0c3cd
Author: Stefano Lattarini <address@hidden>
Date:   Sat Jan 29 19:47:46 2011 +0100

    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.

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

Summary of changes:
 ChangeLog                                   |   38 +++++
 Makefile.in                                 |    2 -
 automake.in                                 |   20 ++-
 configure                                   |    5 +
 configure.ac                                |    5 +
 doc/Makefile.in                             |    2 -
 lib/Automake/Makefile.in                    |    2 -
 lib/Automake/tests/Makefile.in              |    2 -
 lib/Makefile.in                             |    2 -
 lib/am/Makefile.in                          |    2 -
 lib/am/yacc.am                              |   11 +-
 m4/Makefile.in                              |    2 -
 tests/Makefile.am                           |    3 +
 tests/Makefile.in                           |    5 +-
 tests/yacc-basic.test                       |    3 +-
 tests/yacc-cxx.test                         |  138 ++++++++++++++++
 tests/yacc-d-basic.test                     |    7 +-
 tests/yacc-d-cxx.test                       |  229 +++++++++++++++++++++++++++
 tests/{yaccpp.test => yacc-weirdnames.test} |   37 +++--
 tests/yaccpp.test                           |   41 +++++-
 20 files changed, 513 insertions(+), 43 deletions(-)
 create mode 100755 tests/yacc-cxx.test
 create mode 100755 tests/yacc-d-cxx.test
 copy tests/{yaccpp.test => yacc-weirdnames.test} (55%)

diff --git a/ChangeLog b/ChangeLog
index d2c2768..f81eeaf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,41 @@
+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
diff --git a/Makefile.in b/Makefile.in
index 23ffa29..25d580d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -166,7 +166,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LEX = @LEX@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LN = @LN@
@@ -189,7 +188,6 @@ SHELL = @SHELL@
 STRIP = @STRIP@
 TEX = @TEX@
 VERSION = @VERSION@
-YACC = @YACC@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/automake.in b/automake.in
index fa458d6..e2e67b9 100755
--- a/automake.in
+++ b/automake.in
@@ -6084,12 +6084,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))
diff --git a/configure b/configure
index ffb4514..e0456ff 100755
--- a/configure
+++ b/configure
@@ -2503,6 +2503,11 @@ fi
 done
 test -n "$LEX" || LEX="false"
 
+# 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.
+
+
 
 # Generate man pages.
 
diff --git a/configure.ac b/configure.ac
index ddd0af6..70b35f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,6 +107,11 @@ AC_CHECK_PROG([TEX], [tex], [tex])
 #     configure help screen.
 AC_CHECK_PROGS([YACC], [yacc byacc 'bison -y'], [false])
 AC_CHECK_PROGS([LEX], [lex flex], [false])
+# 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.
+AM_SUBST_NOTMAKE([YACC])
+AM_SUBST_NOTMAKE([LEX])
 
 # Generate man pages.
 AM_MISSING_PROG([HELP2MAN], [help2man])
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 8eda666..c1739e5 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -133,7 +133,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LEX = @LEX@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LN = @LN@
@@ -156,7 +155,6 @@ SHELL = @SHELL@
 STRIP = @STRIP@
 TEX = @TEX@
 VERSION = @VERSION@
-YACC = @YACC@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/lib/Automake/Makefile.in b/lib/Automake/Makefile.in
index a86e899..5f051ed 100644
--- a/lib/Automake/Makefile.in
+++ b/lib/Automake/Makefile.in
@@ -153,7 +153,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LEX = @LEX@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LN = @LN@
@@ -176,7 +175,6 @@ SHELL = @SHELL@
 STRIP = @STRIP@
 TEX = @TEX@
 VERSION = @VERSION@
-YACC = @YACC@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/lib/Automake/tests/Makefile.in b/lib/Automake/tests/Makefile.in
index 9b2b38c..4b2c57f 100644
--- a/lib/Automake/tests/Makefile.in
+++ b/lib/Automake/tests/Makefile.in
@@ -198,7 +198,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LEX = @LEX@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LN = @LN@
@@ -221,7 +220,6 @@ SHELL = @SHELL@
 STRIP = @STRIP@
 TEX = @TEX@
 VERSION = @VERSION@
-YACC = @YACC@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 4d5f77e..d9e41e2 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -155,7 +155,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LEX = @LEX@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LN = @LN@
@@ -178,7 +177,6 @@ SHELL = @SHELL@
 STRIP = @STRIP@
 TEX = @TEX@
 VERSION = @VERSION@
-YACC = @YACC@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/lib/am/Makefile.in b/lib/am/Makefile.in
index 225977f..352c64f 100644
--- a/lib/am/Makefile.in
+++ b/lib/am/Makefile.in
@@ -113,7 +113,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LEX = @LEX@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LN = @LN@
@@ -136,7 +135,6 @@ SHELL = @SHELL@
 STRIP = @STRIP@
 TEX = @TEX@
 VERSION = @VERSION@
-YACC = @YACC@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
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/m4/Makefile.in b/m4/Makefile.in
index caf019c..cd80415 100644
--- a/m4/Makefile.in
+++ b/m4/Makefile.in
@@ -113,7 +113,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LEX = @LEX@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LN = @LN@
@@ -136,7 +135,6 @@ SHELL = @SHELL@
 STRIP = @STRIP@
 TEX = @TEX@
 VERSION = @VERSION@
-YACC = @YACC@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8422455..0de0211 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -796,6 +796,8 @@ xsource.test \
 xz.test \
 yacc-basic.test \
 yacc-d-basic.test \
+yacc-cxx.test \
+yacc-d-cxx.test \
 yacc-clean.test \
 yacc.test \
 yacc2.test \
@@ -811,6 +813,7 @@ yacc-nodist.test \
 yaccpp.test \
 yaccvpath.test \
 yacc-d-vpath.test \
+yacc-weirdnames.test \
 yflags.test \
 yflags2.test \
 yflags-cmdline-override.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index a1cd3e2..f9949c3 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -203,7 +203,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LEX = @LEX@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LN = @LN@
@@ -226,7 +225,6 @@ SHELL = @SHELL@
 STRIP = @STRIP@
 TEX = @TEX@
 VERSION = @VERSION@
-YACC = @YACC@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -1065,6 +1063,8 @@ xsource.test \
 xz.test \
 yacc-basic.test \
 yacc-d-basic.test \
+yacc-cxx.test \
+yacc-d-cxx.test \
 yacc-clean.test \
 yacc.test \
 yacc2.test \
@@ -1080,6 +1080,7 @@ yacc-nodist.test \
 yaccpp.test \
 yaccvpath.test \
 yacc-d-vpath.test \
+yacc-weirdnames.test \
 yflags.test \
 yflags2.test \
 yflags-cmdline-override.test \
diff --git a/tests/yacc-basic.test b/tests/yacc-basic.test
index cc28401..845a861 100755
--- a/tests/yacc-basic.test
+++ b/tests/yacc-basic.test
@@ -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=yacc
 . ./defs || Exit 1
diff --git a/tests/yacc-cxx.test b/tests/yacc-cxx.test
new file mode 100755
index 0000000..86693d6
--- /dev/null
+++ b/tests/yacc-cxx.test
@@ -0,0 +1,138 @@
+#! /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
+
+distdir=$me-1.0
+
+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 bar.cxx
+foo3_YFLAGS = -v
+foo4_YFLAGS = $(foo3_YFLAGS)
+
+.PHONY: echo-distcom
+echo-distcom:
+       @echo ' ' $(DIST_COMMON) ' '
+END
+
+cat > parse1.yy << 'END'
+%{
+// Valid as C++, but deliberatly invalid as 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 as C++, but deliberatly invalid as 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 bar.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
+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.
+$MAKE 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 11e5ba3..6cb5e99 100755
--- a/tests/yacc-d-basic.test
+++ b/tests/yacc-d-basic.test
@@ -14,8 +14,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/>.
 
-# 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=yacc
 . ./defs || Exit 1
@@ -111,7 +112,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
diff --git a/tests/yacc-d-cxx.test b/tests/yacc-d-cxx.test
new file mode 100755
index 0000000..b94b14d
--- /dev/null
+++ b/tests/yacc-d-cxx.test
@@ -0,0 +1,229 @@
+#! /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
+
+tab='  '
+distdir=$me-1.0
+
+write_parse ()
+{
+  header=$1
+  sed 's/^ *//' <<END
+    %{
+    // Valid as C++, but deliberatly invalid as 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 as C++, but deliberatly invalid as 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
+
+cat > Makefile.am <<'END'
+SUBDIRS = foo bar baz qux
+END
+
+mkdir foo bar baz qux baz/sub
+
+# These makefiles will be extended later.
+cat > foo/Makefile.am <<'END'
+.PHONY: echo-distcom
+echo-distcom:
+       @echo ' ' $(DIST_COMMON) ' '
+END
+cp foo/Makefile.am bar/Makefile.am
+cp foo/Makefile.am baz/Makefile.am
+cp foo/Makefile.am qux/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE Makefile
+
+cp $testsrcdir/../lib/ylwrap .
+
+# 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 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/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).
+$MAKE 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/yaccpp.test b/tests/yacc-weirdnames.test
similarity index 55%
copy from tests/yaccpp.test
copy to tests/yacc-weirdnames.test
index 9c4ae24..8f0424e 100755
--- a/tests/yaccpp.test
+++ b/tests/yacc-weirdnames.test
@@ -1,6 +1,5 @@
 #! /bin/sh
-# Copyright (C) 1997, 2001, 2002, 2006, 2010 Free Software Foundation,
-# Inc.
+# 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
@@ -15,33 +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 to make sure Yacc + C++ is supported.
-# Please keep this is sync with sister test lexcpp.test.
+# Check that yacc sources with many dots in their name are handled
+# correctly.
 
 . ./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 = foo bar baz qux
-foo_SOURCES = foo.y++
-bar_SOURCES = bar.ypp
-baz_SOURCES = baz.yy
-qux_SOURCES = qux.yxx
+bin_PROGRAMS = foo bar foo2 bar2
+
+foo_SOURCES = parse.y.y
+bar_SOURCES = parse.s.f..y
+bar_YFLAGS = -d
+
+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 -a
 
-sed -e 's/^/ /' -e 's/$/ /' Makefile.in >mk
-$FGREP ' foo.c++ ' mk
-$FGREP ' bar.cpp ' mk
-$FGREP ' baz.cc '  mk
-$FGREP ' qux.cxx ' mk
+$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/yaccpp.test b/tests/yaccpp.test
index 9c4ae24..e5c9e31 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
 
@@ -38,10 +40,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
+
 :


hooks/post-receive
-- 
GNU Automake



reply via email to

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