Merge branch 'minor'
[automake.git] / t / subpkg-yacc.sh
blob3997175abfa381cfda40991b023498fa79e145cd
1 #! /bin/sh
2 # Copyright (C) 2002-2017 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 <https://www.gnu.org/licenses/>.
17 # Check that ylwrap is installed properly, and $(YLWRAP) us defined
18 # properly, when a subpackage is involved.
20 required='cc yacc'
21 . test-init.sh
23 cat > configure.ac <<'END'
24 AC_INIT([suya], [0.5a], [automake-bug@gnu.org])
25 AM_INIT_AUTOMAKE([foreign -Wall])
26 AC_PROG_CC
27 AC_CONFIG_FILES([Makefile])
28 AC_CONFIG_SUBDIRS([lib])
29 AC_OUTPUT
30 END
32 cat >Makefile.am <<'EOF'
33 AUTOMAKE_OPTIONS = -Wno-override
34 SUBDIRS = lib
35 bin_PROGRAMS = MU
36 MU_LDADD = lib/liblib.a
37 # It's ok to override distdir.
38 distdir = subpack-1
39 # Remove a file created by rules in subdir lib.
40 CLEANFILES = lib-dist-hook-has-run
41 EOF
43 cat >MU.c <<'EOF'
44 int lib (void);
45 int main (void)
47 return lib ();
49 EOF
51 mkdir lib
52 mkdir lib/src
54 cat >lib/configure.ac <<'EOF'
55 AC_INIT([lib], [2.3])
56 AM_INIT_AUTOMAKE([subdir-objects])
57 AC_PROG_RANLIB
58 AC_PROG_YACC
59 dnl This comes after YACC and RANLIB checks, deliberately.
60 AC_PROG_CC
61 AM_PROG_AR
62 AC_CONFIG_HEADERS([config.h:config.hin])
63 AC_CONFIG_FILES([Makefile])
64 AC_OUTPUT
65 EOF
67 cat >lib/Makefile.am <<'EOF'
68 noinst_LIBRARIES = liblib.a
69 liblib_a_SOURCES = src/x.c foo.y
70 EXTRA_liblib_a_SOURCES = bar.y
72 dist-hook:
73 test -d $(top_distdir)
74 test -d $(distdir)
75 find $(top_distdir) $(distdir) ;: For debugging.
76 test -f $(top_distdir)/MU.c
77 test ! -f $(distdir)/MU.c
78 for suf in y c; do \
79 for name in foo bar; do \
80 test -f $(distdir)/$$name.$$suf || exit 1; \
81 test ! -f $(top_distdir)/$$name.$$suf || exit 1; \
82 done; \
83 done
84 test -f $(distdir)/foo.y
85 test ! -f $(top_distdir)/foo.y
86 test -f $(distdir)/src/x.c
87 test ! -f $(top_distdir)/src/x.c
88 test -f $(YLWRAP)
89 : > $(top_builddir)/../lib-dist-hook-has-run
90 EOF
92 cat > lib/foo.y << 'END'
94 int yylex (void) { return 0; }
95 void yyerror (char *s) {}
98 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
99 END
101 cp lib/foo.y lib/bar.y
103 cat >lib/src/x.c <<'EOF'
104 #include <config.h>
105 int lib (void)
107 return 0;
111 $ACLOCAL
112 $AUTOCONF
113 $AUTOMAKE
115 test ! -e ylwrap
116 test ! -e ar-lib
117 cd lib
118 $ACLOCAL
119 $AUTOCONF
120 $AUTOHEADER
121 $AUTOMAKE --add-missing
122 cd ..
123 test -f ylwrap
124 test -f ar-lib
126 ./configure
128 $MAKE dist
129 test -f lib-dist-hook-has-run
130 test -f subpack-1.tar.gz
131 test ! -e subpack-1 # Make sure "dist" cleans up after itself.
133 rm -f lib-dist-hook-has-run subpack-1.tar.gz
135 yl_distcheck