tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / t / lexvpath.sh
1 #! /bin/sh
2 # Copyright (C) 2010-2013 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 <http://www.gnu.org/licenses/>.
16
17 # This test checks that dependent files are updated before including
18 # in the distribution.  'lexer.c' depends on 'lexer.l'.  The latter is
19 # updated so that 'lexer.c' should be rebuild.  Then we are running
20 # 'make' and 'make distdir' and check whether the version of 'lexer.c'
21 # to be distributed is up to date.
22
23 # Please keep this in sync with sister test 'yaccvapth.sh'.
24
25 required='cc lex'
26 . test-init.sh
27
28 cat > lexoutroot.in << 'END'
29 LEX_OUTPUT_ROOT='@LEX_OUTPUT_ROOT@'
30 END
31
32 cat >> configure.ac << 'END'
33 AC_CONFIG_FILES([lexoutroot])
34 AC_PROG_CC
35 AC_PROG_LEX
36 AC_OUTPUT
37 END
38
39 cat > Makefile.am << 'END'
40 bin_PROGRAMS = foo
41 foo_SOURCES = lexer.l foo.c
42 LDADD = $(LEXLIB)
43 END
44
45 # Original lexer, with a "foobar" comment
46 cat > lexer.l << 'END'
47 %{
48 #define YY_NO_UNISTD_H 1
49 %}
50 %%
51 "END" return EOF;
52 .
53 %%
54 /*foobar*/
55 END
56
57 cat > foo.c << 'END'
58 int main (void)
59 {
60   return 0;
61 }
62 /* Avoid possible link errors. */
63 int yywrap (void)
64 {
65   return 1;
66 }
67 END
68
69 $ACLOCAL
70 $AUTOCONF
71 $AUTOMAKE -a
72
73 mkdir sub
74
75 # We must run configure early, to find out why $LEX_OUTPUT_ROOT is.
76 cd sub
77 ../configure
78 . ./lexoutroot
79 test -n "$LEX_OUTPUT_ROOT" # Sanity check.
80 cd ..
81
82 $LEX lexer.l
83 mv "$LEX_OUTPUT_ROOT".c lexer.c
84
85 cd sub
86
87 # Ensure that lexer.l will be newer than lexer.c.
88 $sleep
89
90 # New lexer, with 'fubar' comment.
91 cat > ../lexer.l << 'END'
92 %{
93 #define YY_NO_UNISTD_H 1
94 %}
95 %%
96 "END" return EOF;
97 .
98 %%
99 /*fubar*/
100 END
101
102 $MAKE
103 $MAKE distdir
104 $FGREP '/*fubar*/' $distdir/lexer.c
105
106 #
107 # Now check to make sure that 'make dist' will rebuilt the parser.
108 #
109
110 # Ensure that lexer.l will be newer than lexer.c.
111 $sleep
112
113 # New lexer, with 'maude' comment.
114 cat > ../lexer.l << 'END'
115 %{
116 #define YY_NO_UNISTD_H 1
117 %}
118 %%
119 "END" return EOF;
120 .
121 %%
122 /*maude*/
123 END
124
125 $MAKE distdir
126 $FGREP '/*maude*/' $distdir/lexer.c
127
128 :