news: describe recently-fixed bug in vala support
[platform/upstream/automake.git] / tests / subpkg-yacc.test
1 #! /bin/sh
2 # Copyright (C) 2002, 2003, 2004, 2006, 2011 Free Software Foundation,
3 # Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # Check that ylwrap is installed properly, and $(YLWRAP) us defined
19 # properly, when a subpackage is involved.
20
21 required='cc yacc'
22 . ./defs || Exit 1
23
24 set -e
25
26 cat >>configure.in <<'END'
27 AC_PROG_CC
28 AC_CONFIG_SUBDIRS([lib])
29 AC_OUTPUT
30 END
31
32 cat >Makefile.am <<'EOF'
33 SUBDIRS = lib
34 bin_PROGRAMS = MU
35 MU_LDADD = lib/liblib.a
36 # It's ok to override distdir.
37 distdir = subpack-1
38 # Remove a file created by rules in subdir lib.
39 CLEANFILES = lib-dist-hook-has-run
40 EOF
41
42 cat >MU.c <<'EOF'
43 int lib (void);
44 int main (void)
45 {
46   return lib ();
47 }
48 EOF
49
50 mkdir lib
51 mkdir lib/src
52
53 cat >lib/configure.ac <<'EOF'
54 AC_INIT([lib], [2.3])
55 AM_INIT_AUTOMAKE
56 AC_PROG_RANLIB
57 AC_PROG_YACC
58 dnl This comes after YACC and RANLIB checks, deliberately.
59 AC_PROG_CC
60 AC_CONFIG_HEADERS([config.h:config.hin])
61 AC_CONFIG_FILES([Makefile])
62 AC_OUTPUT
63 EOF
64
65 cat >lib/Makefile.am <<'EOF'
66 noinst_LIBRARIES = liblib.a
67 liblib_a_SOURCES = src/x.c foo.y
68 EXTRA_liblib_a_SOURCES = bar.y
69
70 dist-hook:
71         test -d $(top_distdir)
72         test -d $(distdir)
73         find $(top_distdir) $(distdir) ;: For debugging.
74         test -f $(top_distdir)/MU.c
75         test ! -f $(distdir)/MU.c
76         for suf in y c; do \
77           for name in foo bar; do \
78             test -f $(distdir)/$$name.$$suf || exit 1; \
79             test ! -f $(top_distdir)/$$name.$$suf || exit 1; \
80           done; \
81         done
82         test -f $(distdir)/foo.y
83         test ! -f $(top_distdir)/foo.y
84         test -f $(distdir)/src/x.c
85         test ! -f $(top_distdir)/src/x.c
86         test -f $(YLWRAP)
87         : > $(top_builddir)/../lib-dist-hook-has-run
88 EOF
89
90 cat > lib/foo.y << 'END'
91 %{
92 int yylex (void) { return 0; }
93 void yyerror (char *s) {}
94 %}
95 %%
96 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
97 END
98
99 cp lib/foo.y lib/bar.y
100
101 cat >lib/src/x.c <<'EOF'
102 #include <config.h>
103 int lib (void)
104 {
105   return 0;
106 }
107 EOF
108
109 $ACLOCAL
110 $AUTOCONF
111 $AUTOMAKE -Wno-override
112
113 cd lib
114 $ACLOCAL
115 $AUTOCONF
116 $AUTOHEADER
117 $AUTOMAKE -Wno-override --add-missing
118 cd ..
119
120 # Some checks here are slightly more tricky than we'd like, but we cannot
121 # simply use "make distcheck", to avoid triggering a spurious failure due
122 # to issues with FreeBSD make and VPATH builds (see automake bug#7884).
123
124 ./configure
125 $MAKE
126 $MAKE dist
127 test -f lib-dist-hook-has-run
128 test -f subpack-1.tar.gz
129 test ! -d subpack-1 # Make sure "dist" cleans up after itself.
130
131 mkdir workdir
132 cd workdir
133 gzip -c -d ../subpack-1.tar.gz | tar xf -
134 test -d subpack-1
135 mkdir build
136 cd build
137 ../subpack-1/configure
138 $MAKE
139 $MAKE dist
140 test -f lib-dist-hook-has-run
141 test -f subpack-1.tar.gz
142 test ! -d subpack-1 # Make sure "dist" cleans up after itself.
143
144 # Don't trust non-GNU makes to do distcheck with a Yacc-using
145 # package (see bug referenced above).
146 if using_gmake; then
147   $MAKE distcheck || Exit 1
148 fi
149
150 :