Merge branch 'python-fix-pr10227' into maint
[automake.git] / t / yacc-basic.sh
blobb1883385b1353011051c4bfa1f3dbff2a33f869e
1 #! /bin/sh
2 # Copyright (C) 2010-2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Basic semantic checks on Yacc support (without yacc-generated headers).
18 # Keep in sync with sister test 'yacc-cxx.sh'.
20 required='cc yacc'
21 . ./defs || exit 1
23 cat >> configure.ac << 'END'
24 AC_PROG_CC
25 AC_PROG_YACC
26 AC_OUTPUT
27 END
29 cat > Makefile.am << 'END'
30 bin_PROGRAMS = foo bar
31 foo_SOURCES = parse.y foo.c
32 bar_SOURCES = $(foo_SOURCES)
33 bar_YFLAGS = -v
35 .PHONY: echo-distcom
36 echo-distcom:
37 @echo ' ' $(DIST_COMMON) ' '
38 END
40 cat > parse.y << 'END'
42 #include <stdio.h>
43 #include <stdlib.h>
44 int yylex () { return getchar (); }
45 void yyerror (char *s) {}
48 a : 'a' { exit(0); };
49 END
51 cat > foo.c << 'END'
52 int main () { yyparse (); return 1; }
53 END
55 $ACLOCAL
56 $AUTOCONF
57 $AUTOMAKE -a
59 ./configure
60 $MAKE
61 ls -l
62 # The Yacc-derived C sources must be created, and not removed once
63 # compiled (i.e., not treated like "intermediate files" in the GNU
64 # make sense).
65 test -f parse.c
66 test -f bar-parse.c
67 # Check that per-object flags are honored.
68 test -f bar-parse.output
70 if ! cross_compiling; then
71 echo a | ./foo
72 echo b | ./foo && exit 1
73 echo a | ./bar
74 echo b | ./bar && exit 1
75 : For shells with busted 'set -e'.
78 # The Yacc-derived C sources must be shipped.
79 $MAKE echo-distcom
80 $MAKE -s echo-distcom | grep '[ /]parse\.c '
81 $MAKE -s echo-distcom | grep '[ /]bar-parse\.c '
82 $MAKE distdir
83 ls -l $distdir
84 test -f $distdir/parse.c
85 test -f $distdir/bar-parse.c
87 # Sanity check on distribution.
88 # Note that, for this to succeed, bar-parse.output must either not
89 # be distributed, or properly cleaned by automake-generated rules.
90 # We don't want to set the exact semantics yet, but want to ensure
91 # they are are consistent.
92 yl_distcheck
94 # Make sure that the Yacc-derived C sources are erased by
95 # maintainer-clean, and not by distclean.
96 test -f parse.c
97 test -f bar-parse.c
98 $MAKE distclean
99 ls -l
100 test -f parse.c
101 test -f bar-parse.c
102 ./configure # We must re-create 'Makefile'.
103 $MAKE maintainer-clean
104 ls -l
105 test ! -e parse.c
106 test ! -e bar-parse.c