doc: update Vala documentation
[automake.git] / t / subpkg-yacc.sh
blob8794d901ea0c6897f08e4bcacb4b5824ffb80851
1 #! /bin/sh
2 # Copyright (C) 2002-2024 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_PROG_CC
25 AC_CONFIG_SUBDIRS([lib])
26 AC_OUTPUT
27 END
29 cat >Makefile.am <<'EOF'
30 SUBDIRS = lib
31 bin_PROGRAMS = MU
32 MU_LDADD = lib/liblib.a
33 # It's ok to override distdir.
34 distdir = subpack-1
35 # Remove a file created by rules in subdir lib.
36 CLEANFILES = lib-dist-hook-has-run
37 EOF
39 cat >MU.c <<'EOF'
40 int lib (void);
41 int main (void)
43 return lib ();
45 EOF
47 mkdir lib
48 mkdir lib/src
50 cat >lib/configure.ac <<'EOF'
51 AC_INIT([lib], [2.3])
52 AM_INIT_AUTOMAKE([subdir-objects])
53 AC_PROG_RANLIB
54 AC_PROG_YACC
55 dnl This comes after YACC and RANLIB checks, deliberately.
56 AC_PROG_CC
57 AM_PROG_AR
58 AC_CONFIG_HEADERS([config.h:config.hin])
59 AC_CONFIG_FILES([Makefile])
60 AC_OUTPUT
61 EOF
63 cat >lib/Makefile.am <<'EOF'
64 AM_LFLAGS = --never-interactive
66 noinst_LIBRARIES = liblib.a
67 liblib_a_SOURCES = src/x.c foo.y
68 EXTRA_liblib_a_SOURCES = bar.y
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
90 cat > lib/foo.y << 'END'
92 int yylex (void) { return 0; }
93 void yyerror (const char *s) {}
96 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
97 END
99 cp lib/foo.y lib/bar.y
101 cat >lib/src/x.c <<'EOF'
102 #include <config.h>
103 int lib (void)
105 return 0;
109 $ACLOCAL
110 $AUTOCONF
111 $AUTOMAKE -Wno-override
113 cd lib
114 $ACLOCAL
115 $AUTOCONF
116 $AUTOHEADER
117 $AUTOMAKE -Wno-override --add-missing
118 cd ..
120 ./configure
122 $MAKE dist
123 test -f lib-dist-hook-has-run
124 test -f subpack-1.tar.gz
125 test ! -e subpack-1 # Make sure "dist" cleans up after itself.
127 rm -f lib-dist-hook-has-run subpack-1.tar.gz
129 yl_distcheck