Merge branch 'yacc-quote-fix'
[automake.git] / tests / cond35.test
blobf8d5e8670c18f2c6246603ad39d9ca4fc478bb8a
1 #!/bin/sh
2 # Copyright (C) 2004-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 # Check rules output for parser defined conditionally.
18 # Report from Roman Fietze.
20 required='cc lex yacc'
21 . ./defs || Exit 1
23 cat >>configure.in <<'EOF'
24 AM_CONDITIONAL([CASE_A], [test -z "$case_B"])
25 AC_PROG_CC
26 AM_PROG_LEX
27 AC_PROG_YACC
28 AC_OUTPUT
29 EOF
31 cat > Makefile.am <<'EOF'
32 AM_YFLAGS = -d
34 BUILT_SOURCES = tparse.h
36 if CASE_A
37 bin_PROGRAMS = ta
38 ta_SOURCES = ta.c tparse.h tscan.l tparse.y
39 ta_LDADD = $(LEXLIB)
40 else
41 bin_PROGRAMS = tb
42 tb_SOURCES = tb.c tparse.h tscan.l tparse.y
43 tb_LDADD = $(LEXLIB)
44 endif
47 test-ta:
48 test -f ta$(EXEEXT)
49 test-tb:
50 test -f tb$(EXEEXT)
51 EOF
53 $ACLOCAL
54 $AUTOCONF
55 $AUTOMAKE --add-missing
57 $FGREP 'tparse.h' Makefile.in # For debugging.
58 test `$FGREP -c 'tparse.h:' Makefile.in` = 1
60 cat > tscan.l << 'END'
62 "END" return EOF;
64 /* Avoid possible link errors. */
65 int yywrap (void)
67 return 1;
69 END
71 cat > tparse.y << 'END'
73 void yyerror (char *s) {}
75 %token EOF
77 foobar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
78 END
80 cat > ta.c << 'END'
81 int main (void)
83 return 0;
85 END
87 cp ta.c tb.c
89 ./configure
90 $MAKE
91 $MAKE test-ta
93 ./configure case_B=yes
94 $MAKE
95 $MAKE test-tb