1#! /bin/sh 2# Copyright (C) 2001-2021 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 <https://www.gnu.org/licenses/>. 16 17# This test checks that dependent files are updated before including 18# in the distribution. 'parse.c' depends on 'parse.y'. The later is 19# updated so that 'parse.c' should be rebuild. Then we are running 20# 'make' and 'make distdir' and check whether the version of 'parse.c' 21# to be distributed is up to date. 22 23# Please keep this in sync with sister test 'yacc-d-vpath.sh'. 24 25required='cc yacc' 26. test-init.sh 27 28cat >> configure.ac << 'END' 29AC_PROG_CC 30AC_PROG_YACC 31AC_OUTPUT 32END 33 34cat > Makefile.am << 'END' 35bin_PROGRAMS = foo 36foo_SOURCES = parse.y foo.c 37END 38 39# Original parser, with 'foobar'. 40cat > parse.y << 'END' 41%{ 42int yylex () { return 0; } 43void yyerror (const char *s) {} 44%} 45%% 46foobar : 'f' 'o' 'o' 'b' 'a' 'r' {}; 47END 48 49cat > foo.c << 'END' 50int main () { return 0; } 51END 52 53$ACLOCAL 54$AUTOCONF 55$AUTOMAKE -a 56 57$YACC parse.y 58mv y.tab.c parse.c 59 60mkdir sub 61cd sub 62../configure 63 64$sleep 65 66# New parser, with 'fubar'. 67cat > ../parse.y << 'END' 68%{ 69int yylex () { return 0; } 70void yyerror (const char *s) {} 71%} 72%% 73fubar : 'f' 'o' 'o' 'b' 'a' 'r' {}; 74END 75 76$MAKE 77$MAKE distdir 78$FGREP fubar $distdir/parse.c 79 80# Now check to make sure that 'make dist' will rebuild the parser. 81 82$sleep 83 84# New parser, with 'maude'. 85cat > ../parse.y << 'END' 86%{ 87int yylex () { return 0; } 88void yyerror (const char *s) {} 89%} 90%% 91maude : 'm' 'a' 'u' 'd' 'e' {}; 92END 93 94$MAKE distdir 95$FGREP maude $distdir/parse.c 96 97: 98