doc: update Vala documentation
[automake.git] / t / yacc-subdir.sh
blob3249dcc22f934bcebb0212b31c9e30724abd00f9
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 # Test for subdir parsers.
19 required='cc yacc'
21 . test-init.sh
23 cat >> configure.ac << 'END'
24 AC_PROG_CC
25 AC_PROG_YACC
26 AC_OUTPUT
27 END
29 cat > Makefile.am << 'END'
30 AUTOMAKE_OPTIONS = subdir-objects
31 AM_LFLAGS = --never-interactive
33 bin_PROGRAMS = foo/foo
34 foo_foo_SOURCES = foo/parse.y
35 AM_YFLAGS = -d
37 .PHONY: obj
38 obj: foo/parse.$(OBJEXT)
40 .PHONY: test1 test2
41 test1: foo/parse.$(OBJEXT)
42 test -f foo/parse.c
43 test -f foo/parse.$(OBJEXT)
44 test2: foo/parse2.$(OBJEXT)
45 test -f foo/parse2.c
46 test -f foo/parse2.$(OBJEXT)
47 END
49 mkdir foo
51 cat > foo/parse.y << 'END'
53 int yylex () { return 0; }
54 void yyerror (const char *s) {}
57 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
58 END
60 $ACLOCAL
61 $AUTOCONF
62 $AUTOMAKE -a
64 mkdir sub
65 cd sub
67 ../configure
68 $MAKE test1
70 # Aside of the rest of this test, let's see if we can recover from
71 # parse.h removal.
72 test -f foo/parse.h
73 rm -f foo/parse.h
74 $MAKE foo/parse.h
75 test -f foo/parse.h
77 # Make sure foo/parse.h is not updated, unless when needed.
78 $sleep
79 touch ../foo/parse.y
80 $MAKE obj
81 is_newest ../foo/parse.y foo/parse.h
82 $sleep
83 sed 's/%%/%token TOKEN\n%%/g' ../foo/parse.y >../foo/parse.yt
84 mv -f ../foo/parse.yt ../foo/parse.y
85 $MAKE obj
86 is_newest foo/parse.h ../foo/parse.y
88 # Now, adds another parser to test ylwrap.
90 cd ..
92 # Sleep some to make sure timestamp of Makefile.am will change.
93 $sleep
95 cp foo/parse.y foo/parse2.y
96 cat >> Makefile.am << 'END'
97 EXTRA_foo_foo_SOURCES = foo/parse2.y
98 END
100 $AUTOMAKE -a
101 test -f ./ylwrap
103 cd sub
104 # Regenerate Makefile (automatic in GNU Make, but not in other Makes).
105 ./config.status
106 $MAKE test2