Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / cond35.test
1 #!/bin/sh
2 # Copyright (C) 2004, 2011 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # Check rules output for parser defined conditionally.
18 # Report from Roman Fietze.
19
20 required='flex bison gcc'
21 . ./defs || Exit 1
22
23 set -e
24
25 cat >>configure.in <<'EOF'
26 AM_CONDITIONAL([CASE_A], test -z "$case_B")
27 AC_PROG_CC
28 AM_PROG_LEX
29 AC_PROG_YACC
30 AC_OUTPUT
31 EOF
32
33 cat >>Makefile.am <<'EOF'
34 AM_YFLAGS               =       -d
35
36 BUILT_SOURCES           =       tparse.h
37
38 if CASE_A
39 bin_PROGRAMS            =       ta
40 ta_SOURCES              =       ta.c tparse.h tscan.l tparse.y
41 ta_LDADD                =       $(LEXLIB)
42 else
43 bin_PROGRAMS            =       tb
44 tb_SOURCES              =       tb.c tparse.h tscan.l tparse.y
45 tb_LDADD                =       $(LEXLIB)
46 endif
47
48
49 test-ta:
50         test -f ta$(EXEEXT)
51 test-tb:
52         test -f tb$(EXEEXT)
53 EOF
54
55 $ACLOCAL
56 $AUTOCONF
57 $AUTOMAKE --add-missing
58
59 test `grep tparse.h: Makefile.in | wc -l` = 1
60
61 cat > tscan.l << 'END'
62 %%
63 "END"   return EOF;
64 %%
65 /* Avoid possible link errors. */
66 int yywrap (void)
67 {
68   return 1;
69 }
70 END
71
72 cat > tparse.y << 'END'
73 %{
74 void yyerror (char *s) {}
75 %}
76 %token EOF
77 %%
78 foobar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
79 END
80
81 cat >ta.c <<'END'
82 int main()
83 {
84   return 0;
85 }
86 END
87
88 cp ta.c tb.c
89
90 ./configure
91 $MAKE
92 $MAKE test-ta
93
94 ./configure case_B=yes
95 $MAKE
96 $MAKE test-tb