automake-patches
[Top][All Lists]
Advanced

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

[PATCH 3/6] Add new tests on Lex and Yacc.


From: Stefano Lattarini
Subject: [PATCH 3/6] Add new tests on Lex and Yacc.
Date: Thu, 20 May 2010 12:19:34 +0200
User-agent: KMail/1.12.1 (Linux/2.6.30-2-686; KDE/4.3.4; i686; ; )

Add some more new test scripts on Lex/Yacc support.   Some of these
expose bugs in the Yacc/Lex support w.r.t. Heirloom make.

---
* tests/lex7.test: New test.
* tests/lex8.test: Likewise.
* tests/lex9.test: Likewise.
* tests/yacc10.test: Likewise.
* tests/yacc11.test: Likewise.
* tests/Makefile.am (TESTS): Updated.
---
 ChangeLog         |    8 +++
 tests/Makefile.am |    5 ++
 tests/Makefile.in |    5 ++
 tests/lex7.test   |  152 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/lex8.test   |  134 +++++++++++++++++++++++++++++++++++++++++++
 tests/lex9.test   |  102 +++++++++++++++++++++++++++++++++
 tests/yacc10.test |  164 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/yacc11.test |  145 ++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 715 insertions(+), 0 deletions(-)
 create mode 100755 tests/lex7.test
 create mode 100755 tests/lex8.test
 create mode 100755 tests/lex9.test
 create mode 100755 tests/yacc10.test
 create mode 100755 tests/yacc11.test
From e14cdb67a91afeadfc77b8cb860a42cdf55ad467 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Tue, 27 Apr 2010 19:26:17 +0200
Subject: [PATCH 3/6] Add new tests on Lex and Yacc.

* tests/lex7.test: New test.
* tests/lex8.test: Likewise.
* tests/lex9.test: Likewise.
* tests/yacc10.test: Likewise.
* tests/yacc11.test: Likewise.
* tests/Makefile.am (TESTS): Updated.
---
 ChangeLog         |    8 +++
 tests/Makefile.am |    5 ++
 tests/Makefile.in |    5 ++
 tests/lex7.test   |  152 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/lex8.test   |  134 +++++++++++++++++++++++++++++++++++++++++++
 tests/lex9.test   |  102 +++++++++++++++++++++++++++++++++
 tests/yacc10.test |  164 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/yacc11.test |  145 ++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 715 insertions(+), 0 deletions(-)
 create mode 100755 tests/lex7.test
 create mode 100755 tests/lex8.test
 create mode 100755 tests/lex9.test
 create mode 100755 tests/yacc10.test
 create mode 100755 tests/yacc11.test

diff --git a/ChangeLog b/ChangeLog
index daaa3bc..515c153 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-05-20  Stefano Lattarini  <address@hidden>
 
+       Add new tests on Lex and Yacc.
+       * tests/lex7.test: New test.
+       * tests/lex8.test: Likewise.
+       * tests/lex9.test: Likewise.
+       * tests/yacc10.test: Likewise.
+       * tests/yacc11.test: Likewise.
+       * tests/Makefile.am (TESTS): Updated.
+
        New tests: incompatibility of Heirloom make w.r.t. Lex/Yacc rules.
        * tests/lex6.test: New test (fails if $MAKE is Heirloom make).
        * tests/yacc9.test: Likewise.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f97752b..3df93a4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -404,6 +404,9 @@ lex3.test \
 lex4.test \
 lex5.test \
 lex6.test \
+lex7.test \
+lex8.test \
+lex9.test \
 lexcpp.test \
 lexvpath.test \
 libexec.test \
@@ -781,6 +784,8 @@ yacc6.test \
 yacc7.test \
 yacc8.test \
 yacc9.test \
+yacc10.test \
+yacc11.test \
 yaccpp.test \
 yaccvpath.test \
 $(parallel_tests)
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 4fbbbca..6ec61a4 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -645,6 +645,9 @@ lex3.test \
 lex4.test \
 lex5.test \
 lex6.test \
+lex7.test \
+lex8.test \
+lex9.test \
 lexcpp.test \
 lexvpath.test \
 libexec.test \
@@ -1022,6 +1025,8 @@ yacc6.test \
 yacc7.test \
 yacc8.test \
 yacc9.test \
+yacc10.test \
+yacc11.test \
 yaccpp.test \
 yaccvpath.test \
 $(parallel_tests)
diff --git a/tests/lex7.test b/tests/lex7.test
new file mode 100755
index 0000000..6b58313
--- /dev/null
+++ b/tests/lex7.test
@@ -0,0 +1,152 @@
+#! /bin/sh
+# Copyright (C) 2010 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/>.
+
+# Stress test on Automake Lex support.  In particular, this script checks
+# Automake rename rules w.r.t. Lex + C, and verify that make uses our
+# ".l => .c => .o" rule chain rather than a built-in ".l => .o" rule,
+# even when automake conditionals and per-program Lex flags are involved.
+# Please keep this in sync with the suster test yacc10.test.
+
+. ./defs || Exit 1
+
+set -e
+
+# Useful to reduce code duplication.
+expected_files() {
+  ls -l # useful for debugging
+  ls *foo*.[ch] *ba[rz]*.[ch] *quux*.[ch] | LC_ALL=C sort | uniq > got.lst
+  for x in ${1+"$@"}; do
+    echo "$x"
+  done | LC_ALL=C sort > exp.lst
+  cat exp.lst; cat got.lst; # useful for debugging
+  diff exp.lst got.lst
+}
+
+cat >fake-lex <<'END'
+#!/bin/sh
+outfile=lex.yy.c
+string=dummy
+while test $# -gt 0; do
+  case $1 in
+    --string)
+      if test $# -gt 1; then
+        string=$2
+        shift # --string
+        shift # argument of '--string'
+      else
+        echo "fake-lex: missing argument to option '$1'" >&2
+        exit 2
+      fi;;
+    -*)
+      echo "fake-lex: invalid option '$1'" >&2; exit 2;;
+    *)
+      break;;
+  esac
+done
+test $# -eq 0 && { echo "fake-lex: missing argument" >&2; exit 2; }
+test $# -gt 2 && { echo "fake-lex: too many arguments" >&2; exit 2; }
+name=`echo "$1" | sed -e 's|^.*/||' -e 's|\.l$||'`
+echo "main() { /* $name : $string */ }" >"$outfile"
+END
+chmod a+x fake-lex
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+
+AM_CONDITIONAL([DUMMYCOND], [test x"$DUMMYCOND" != x"no"])
+
+# Simulate presence of Lex using our fake-lex script.
+AC_SUBST([LEX], ['$(abs_top_srcdir)/fake-lex'])
+AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
+AC_SUBST([LEXLIB], [''])
+
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo quux quux2
+AM_LFLAGS = --string fnord
+
+quux_SOURCES = quux.l
+quux2_SOURCES = $(quux_SOURCES)
+quux2_LFLAGS = --string tux
+quux2_CFLAGS = $(AM_CFLAGS)
+
+if DUMMYCOND
+  foo_SOURCES = bar.l
+  foo_CFLAGS = $(AM_CFLAGS)
+else
+  foo_SOURCES = baz.l
+endif
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+: > bar.l
+: > baz.l
+: > quux.l
+
+mkdir one
+cd one
+pwd
+DUMMYCOND=yes ../configure
+$MAKE
+
+expected_files bar.c quux.c quux2-quux.c
+
+cat bar.c
+$FGREP '/* bar : fnord */' bar.c
+cat quux.c
+$FGREP '/* quux : fnord */' quux.c
+cat quux2-quux.c
+$FGREP '/* quux : tux */' quux2-quux.c
+
+cd ..
+
+mkdir two
+cd two
+pwd
+DUMMYCOND=no ../configure
+quux2_LFLAGS='--string zardoz' AM_LFLAGS='' $MAKE -e
+
+expected_files baz.c quux.c quux2-quux.c
+
+cat baz.c
+$FGREP '/* baz : dummy */' baz.c
+cat quux.c
+$FGREP '/* quux : dummy */' quux.c
+cat quux2-quux.c
+$FGREP '/* quux : zardoz */' quux2-quux.c
+
+cd ..
+
+pwd
+./configure
+AM_LFLAGS='--string user' quux2_CFLAGS='-DQUUX=1' $MAKE -e
+
+expected_files bar.c quux.c quux2-quux.c
+
+cat bar.c
+$FGREP '/* bar : user */' bar.c
+cat quux.c
+$FGREP '/* quux : user */' quux.c
+cat quux2-quux.c
+$FGREP '/* quux : tux */' quux2-quux.c
+
+:
diff --git a/tests/lex8.test b/tests/lex8.test
new file mode 100755
index 0000000..c1c24cf
--- /dev/null
+++ b/tests/lex8.test
@@ -0,0 +1,134 @@
+#! /bin/sh
+# Copyright (C) 2010 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/>.
+
+# Stress test on Automake Lex support.  In particular, this script checks
+# Automake rename rules w.r.t. Lex + C, and verify that make uses our
+# ".l => .c => .o" rule chain rather than a built-in ".l => .o" rule,
+# even when libtool and per-library Lex flags are involved.
+# Please keep this in sync with the sister test yacc11.test.
+
+required='libtoolize'
+. ./defs || Exit 1
+
+set -e
+
+# Useful to reduce code duplication.
+expected_files() {
+  ls -l # useful for debugging
+  ls *foo*.[ch] *ba[rz]*.[ch] | LC_ALL=C sort | uniq > got.lst
+  for x in ${1+"$@"}; do
+    echo "$x"
+  done | LC_ALL=C sort > exp.lst
+  cat exp.lst; cat got.lst; # useful for debugging
+  diff exp.lst got.lst
+}
+
+cat >fake-lex <<'END'
+#!/bin/sh
+outfile=lex.yy.c
+string=dummy
+while test $# -gt 0; do
+  case $1 in
+    --string)
+      if test $# -gt 1; then
+        string=$2
+        shift # --string
+        shift # argument of '--string'
+      else
+        echo "fake-lex: missing argument to option '$1'" >&2
+        exit 2
+      fi;;
+    -*)
+      echo "fake-lex: invalid option '$1'" >&2; exit 2;;
+    *)
+      break;;
+  esac
+done
+test $# -eq 0 && { echo "fake-lex: missing argument" >&2; exit 2; }
+test $# -gt 2 && { echo "fake-lex: too many arguments" >&2; exit 2; }
+name=`echo "$1" | sed -e 's|^.*/||' -e 's|\.l$||'`
+echo "/* $name : $string */ int $string = 0;" >"$outfile"
+END
+chmod a+x fake-lex
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+# Simulate presence of Lex using our fake-lex script.
+AC_SUBST([LEX], ['$(abs_top_srcdir)/fake-lex'])
+AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
+AC_SUBST([LEXLIB], [''])
+
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+lib_LTLIBRARIES = libfoo.la libbar.la libbaz.la
+
+AM_LFLAGS = --string fnord
+
+libfoo_la_SOURCES = foo.l
+
+libbar_la_SOURCES = bar.l
+libbar_la_LFLAGS = --string bar
+
+libbaz_la_SOURCES = $(libbar_la_SOURCES)
+libbaz_la_LFLAGS = $(AM_LFLAGS) --string baz
+libbaz_la_CFLAGS = $(AM_CFLAGS)
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+: > foo.l
+: > bar.l
+
+mkdir sub
+cd sub
+
+../configure
+libbaz_la_LFLAGS='--string bazbaz' $MAKE -e
+
+expected_files foo.c libbar_la-bar.c libbaz_la-bar.c
+
+cat foo.c
+$FGREP '/* foo : fnord */' foo.c
+cat libbar_la-bar.c
+$FGREP '/* bar : bar */' libbar_la-bar.c
+cat libbaz_la-bar.c
+$FGREP '/* bar : bazbaz */' libbaz_la-bar.c
+
+cd ..
+
+./configure
+AM_LFLAGS='--string user' \
+  libbar_la_LFLAGS='' \
+  libbaz_la_CFLAGS='-DBAZ=1' \
+  $MAKE -e
+
+expected_files foo.c libbar_la-bar.c libbaz_la-bar.c
+
+cat foo.c
+$FGREP '/* foo : user */' foo.c
+cat libbar_la-bar.c
+$FGREP '/* bar : dummy */' libbar_la-bar.c
+cat libbaz_la-bar.c
+$FGREP '/* bar : baz */' libbaz_la-bar.c
+
+:
diff --git a/tests/lex9.test b/tests/lex9.test
new file mode 100755
index 0000000..69a97ae
--- /dev/null
+++ b/tests/lex9.test
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2010 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 for subdir lexers.
+
+required="gcc flex"
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = foo/foo
+foo_foo_SOURCES = foo/lexer.l
+
+.PHONY: test test2
+test: foo/lexer.$(OBJEXT)
+       test -f foo/lexer.c
+       test -f foo/lexer.$(OBJEXT)
+test2: foo/lexer2.$(OBJEXT)
+       test -f foo/lexer2.c
+       test -f foo/lexer2.$(OBJEXT)
+END
+
+mkdir foo
+
+cat > foo/lexer.l << 'END'
+%%
+"END"   return EOF;
+.
+%%
+int
+main ()
+{
+  while (yylex () != EOF)
+    ;
+
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir sub
+cd sub
+
+../configure
+$MAKE test
+rm -f foo/lexer.c
+$MAKE test
+rm -f foo/lexer.[!c]*
+$MAKE test
+
+
+# Now, adds another lexer to test ylwrap.
+
+cd ..
+
+# Sleep some to make sure timestamp of Makefile.am will change.
+$sleep
+
+cp foo/lexer.l foo/lexer2.l
+cat >> Makefile.am << 'END'
+EXTRA_foo_foo_SOURCES = foo/lexer2.l
+END
+
+$AUTOMAKE -a
+test -f ./ylwrap
+
+cd sub
+# Regenerate Makefile (automatic in GNU Make, but not in other Makes)
+./config.status
+$MAKE test2
+rm -f foo/lexer2.c
+$MAKE test2
+rm -f foo/lexer2.[!c]*
+$MAKE test2
+
+:
diff --git a/tests/yacc10.test b/tests/yacc10.test
new file mode 100755
index 0000000..fe1af45
--- /dev/null
+++ b/tests/yacc10.test
@@ -0,0 +1,164 @@
+#! /bin/sh
+# Copyright (C) 2010 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/>.
+
+# Stress test on Automake Lex support.  In particular, this script checks
+# Automake rename rules w.r.t. Yacc + C, and verify that make uses our
+# ".y => .c => .o" rule chain rather than a built-in ".y => .o" rule,
+# even when automake conditionals and per-program Yacc flags are involved.
+# Please keep this in sync with the suster test lex7.test.
+
+. ./defs || Exit 1
+
+set -e
+
+# Useful to reduce code duplication.
+expected_files() {
+  ls -l # useful for debugging
+  ls *foo*.[ch] *ba[rz]*.[ch] *quux*.[ch] | LC_ALL=C sort | uniq > got.lst
+  for x in ${1+"$@"}; do
+    echo "$x"
+  done | LC_ALL=C sort > exp.lst
+  cat exp.lst; cat got.lst; # useful for debugging
+  diff exp.lst got.lst
+}
+
+cat >fake-yacc <<'END'
+#!/bin/sh
+cfile=y.tab.c
+hfile=y.tab.h
+
+string=dummy
+write_hfile=false
+while test $# -gt 0; do
+  case $1 in
+    -d)
+      write_hfile=:; shift;; # -d
+    --string)
+      if test $# -gt 1; then
+        string=$2
+        shift # --string
+        shift # argument of '--string'
+      else
+        echo "fake-yacc: missing argument to option '$1'" >&2
+        exit 2
+      fi;;
+    -*)
+      echo "fake-yacc: invalid option '$1'" >&2; exit 2;;
+    *)
+      break;;
+  esac
+done
+test $# -eq 0 && { echo "fake-yacc: missing argument" >&2; exit 2; }
+test $# -gt 2 && { echo "fake-yacc: too many arguments" >&2; exit 2; }
+name=`echo "$1" | sed -e 's|^.*/||' -e 's|\.y$||'`
+echo "main() { /* $name.c : $string */ }" >"$cfile" || exit 1
+if $write_hfile; then
+  echo "/* $name.h : $string */" >"$hfile" || exit 1
+fi
+END
+chmod a+x fake-yacc
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+
+AM_CONDITIONAL([DUMMYCOND], [test x"$DUMMYCOND" != x"no"])
+
+# Simulate presence of Yacc using our fake-yacc script.
+AC_SUBST([YACC], ['$(abs_top_srcdir)/fake-yacc'])
+
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo quux quux2
+AM_YFLAGS = --string fnord
+
+quux_SOURCES = quux.y
+quux2_SOURCES = $(quux_SOURCES)
+quux2_YFLAGS = -d --string tux
+quux2_CFLAGS = $(AM_CFLAGS)
+
+if DUMMYCOND
+  foo_SOURCES = bar.y
+  foo_CFLAGS = $(AM_CFLAGS)
+else
+  foo_SOURCES = baz.y
+endif
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+: > bar.y
+: > baz.y
+: > quux.y
+
+mkdir one
+cd one
+pwd
+DUMMYCOND=yes ../configure
+$MAKE
+
+expected_files bar.c quux.c quux2-quux.c quux2-quux.h
+
+cat bar.c
+$FGREP '/* bar.c : fnord */' bar.c
+cat quux.c
+$FGREP '/* quux.c : fnord */' quux.c
+cat quux2-quux.c
+$FGREP '/* quux.c : tux */' quux2-quux.c
+cat quux2-quux.h
+$FGREP '/* quux.h : tux */' quux2-quux.h
+
+cd ..
+
+mkdir two
+cd two
+pwd
+DUMMYCOND=no ../configure
+quux2_YFLAGS='--string zardoz' AM_YFLAGS='-d' $MAKE -e
+
+expected_files baz.c baz.h quux.c quux.h quux2-quux.c
+
+cat baz.c
+$FGREP '/* baz.c : dummy */' baz.c
+cat baz.h
+$FGREP '/* baz.h : dummy */' baz.h
+cat quux.c
+$FGREP '/* quux.c : dummy */' quux.c
+cat quux.h
+$FGREP '/* quux.h : dummy */' quux.h
+cat quux2-quux.c
+$FGREP '/* quux.c : zardoz */' quux2-quux.c
+
+cd ..
+
+pwd
+./configure
+AM_YFLAGS='--string user -d' $MAKE -e
+
+expected_files bar.c bar.h quux.c quux.h quux2-quux.c quux2-quux.h
+
+cat bar.c
+$FGREP '/* bar.c : user */' bar.c
+cat quux.c
+$FGREP '/* quux.c : user */' quux.c
+cat quux2-quux.c
+$FGREP '/* quux.c : tux */' quux2-quux.c
+
+:
diff --git a/tests/yacc11.test b/tests/yacc11.test
new file mode 100755
index 0000000..9385f5e
--- /dev/null
+++ b/tests/yacc11.test
@@ -0,0 +1,145 @@
+#! /bin/sh
+# Copyright (C) 2010 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/>.
+
+# Stress test on Automake Lex support.  In particular, this script checks
+# Automake rename rules w.r.t. Yacc + C, and verify that make uses our
+# ".y => .c => .o" rule chain rather than a built-in ".y => .o" rule,
+# even when automake conditionals and per-program Yacc flags are involved.
+# Please keep this in sync with the sister test lex8.test.
+
+required='libtoolize'
+. ./defs || Exit 1
+
+set -e
+
+# Useful to reduce code duplication.
+expected_files() {
+  ls -l # useful for debugging
+  ls *foo*.[ch] *ba[rz]*.[ch] | LC_ALL=C sort | uniq > got.lst
+  for x in ${1+"$@"}; do
+    echo "$x"
+  done | LC_ALL=C sort > exp.lst
+  cat exp.lst; cat got.lst; # useful for debugging
+  diff exp.lst got.lst
+}
+
+cat >fake-yacc <<'END'
+#!/bin/sh
+cfile=y.tab.c
+hfile=y.tab.h
+
+string=dummy
+write_hfile=false
+while test $# -gt 0; do
+  case $1 in
+    -d)
+      write_hfile=:; shift;; # -d
+    --string)
+      if test $# -gt 1; then
+        string=$2
+        shift # --string
+        shift # argument of '--string'
+      else
+        echo "fake-yacc: missing argument to option '$1'" >&2
+        exit 2
+      fi;;
+    -*)
+      echo "fake-yacc: invalid option '$1'" >&2; exit 2;;
+    *)
+      break;;
+  esac
+done
+test $# -eq 0 && { echo "fake-yacc: missing argument" >&2; exit 2; }
+test $# -gt 2 && { echo "fake-yacc: too many arguments" >&2; exit 2; }
+name=`echo "$1" | sed -e 's|^.*/||' -e 's|\.y$||'`
+echo "/* $name.c : $string */ int $string = 0;" >"$cfile"
+if $write_hfile; then
+  echo "/* $name.h : $string */" >"$hfile" || exit 1
+fi
+END
+chmod a+x fake-yacc
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+# Simulate presence of Yacc using our fake-yacc script.
+AC_SUBST([YACC], ['$(abs_top_srcdir)/fake-yacc'])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+lib_LTLIBRARIES = libfoo.la libbar.la libbaz.la
+
+AM_YFLAGS = --string fnord
+
+libfoo_la_SOURCES = foo.y
+
+libbar_la_SOURCES = bar.y
+libbar_la_YFLAGS = --string bar -d
+
+libbaz_la_SOURCES = $(libbar_la_SOURCES)
+libbaz_la_YFLAGS = $(AM_YFLAGS) --string baz
+libbaz_la_CFLAGS = $(AM_CFLAGS)
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+: > foo.y
+: > bar.y
+
+mkdir sub
+cd sub
+
+../configure
+libbaz_la_YFLAGS='--string bazbaz' $MAKE -e
+
+expected_files foo.c libbar_la-bar.c libbar_la-bar.h libbaz_la-bar.c
+
+cat foo.c
+$FGREP '/* foo.c : fnord */' foo.c
+cat libbar_la-bar.c
+$FGREP '/* bar.c : bar */' libbar_la-bar.c
+cat libbar_la-bar.h
+$FGREP '/* bar.h : bar */' libbar_la-bar.h
+cat libbaz_la-bar.c
+$FGREP '/* bar.c : bazbaz */' libbaz_la-bar.c
+
+cd ..
+
+./configure
+AM_YFLAGS='--string user -d' \
+  libbar_la_YFLAGS='' \
+  libbaz_la_CFLAGS='-DBAZ=1' \
+  $MAKE -e
+
+expected_files foo.c foo.h libbar_la-bar.c libbaz_la-bar.c libbaz_la-bar.h
+
+cat foo.c
+$FGREP '/* foo.c : user */' foo.c
+cat foo.h
+$FGREP '/* foo.h : user */' foo.h
+cat libbar_la-bar.c
+$FGREP '/* bar.c : dummy */' libbar_la-bar.c
+cat libbaz_la-bar.c
+$FGREP '/* bar.c : baz */' libbaz_la-bar.c
+cat libbaz_la-bar.h
+$FGREP '/* bar.h : baz */' libbaz_la-bar.h
+
+:
-- 
1.6.5


reply via email to

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