tests: work around strangeness in MSYS
[automake.git] / tests / yacc-nodist.test
blob83f63dd03ffb71d273cc36845ac8f2cbc0b25747
1 #! /bin/sh
2 # Copyright (C) 2011 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 <http://www.gnu.org/licenses/>.
17 # Checks for .c and .h files derived from non-distributed .y sources.
19 required='cc yacc'
20 . ./defs || Exit 1
22 cat >> configure.in << 'END'
23 AC_PROG_CC
24 AC_PROG_YACC
25 AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
26 AC_OUTPUT
27 END
29 cat > Makefile.am << 'END'
30 SUBDIRS = sub1 sub2
31 .PHONY: test
32 test-build: all
33 ls -l . sub1 sub2
34 test -f sub1/parse.y
35 test -f sub1/parse.c
36 test -f sub2/parse.y
37 test -f sub2/parse.c
38 test -f sub2/parse.h
39 test-dist: distdir
40 ls -l $(distdir) $(distdir)/sub1 $(distdir)/sub2
41 test ! -r $(distdir)/sub1/parse.y
42 test ! -r $(distdir)/sub1/parse.c
43 test ! -r $(distdir)/sub1/parse.h
44 test ! -r $(distdir)/sub2/parse.y
45 test ! -r $(distdir)/sub2/parse.c
46 test ! -r $(distdir)/sub2/parse.h
47 check-local: test-build test-dist
48 END
50 mkdir sub1 sub2
52 cat > sub1/Makefile.am << 'END'
53 parse.y:
54 rm -f $@ $@-t
55 :; { : \
56 && echo "%{" \
57 && echo "int yylex () { return 0; }" \
58 && echo "void yyerror (char *s) {}" \
59 && echo "%}" \
60 && echo "%%" \
61 && echo "maude : 'm' 'a' 'u' 'd' 'e' {}"; \
62 } > $@-t
63 chmod a-w $@-t
64 mv -f $@-t $@
65 bin_PROGRAMS = prog
66 prog_SOURCES = main.c
67 nodist_prog_SOURCES = parse.y
68 CLEANFILES = $(nodist_prog_SOURCES)
69 END
71 cat sub1/Makefile.am - > sub2/Makefile.am << 'END'
72 AM_YFLAGS = -d
73 BUILT_SOURCES = parse.h
74 END
76 cat > sub1/main.c << 'END'
77 int main ()
79 return yyparse ();
81 END
82 cat - sub1/main.c > sub2/main.c << 'END'
83 #include "parse.h"
84 END
86 $ACLOCAL
87 $AUTOCONF
88 $AUTOMAKE -a
90 ./configure
91 $MAKE
92 $MAKE test-build
93 $MAKE test-dist
95 # But the distribution must work correctly, assuming the user has
96 # the proper tools to process yacc files.
97 $MAKE distcheck