tests: Let 'ltorder.sh' run successfully with Guix dynamic loader
[automake.git] / t / lexvpath.sh
blobd42d5c4632eb652903bbb7848a71500cf05b5555
1 #! /bin/sh
2 # Copyright (C) 2010-2018 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 # 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.
23 # Please keep this in sync with sister test 'yaccvapth.sh'.
25 required='cc lex'
26 . test-init.sh
28 cat > lexoutroot.in << 'END'
29 LEX_OUTPUT_ROOT='@LEX_OUTPUT_ROOT@'
30 END
32 cat >> configure.ac << 'END'
33 AC_CONFIG_FILES([lexoutroot])
34 AC_PROG_CC
35 AC_PROG_LEX
36 AC_OUTPUT
37 END
39 cat > Makefile.am << 'END'
40 bin_PROGRAMS = foo
41 foo_SOURCES = lexer.l foo.c
42 LDADD = $(LEXLIB)
43 END
45 # Original lexer, with a "foobar" comment
46 cat > lexer.l << 'END'
48 #define YY_NO_UNISTD_H 1
51 "END" return EOF;
54 /*foobar*/
55 END
57 cat > foo.c << 'END'
58 int main (void)
60 return 0;
62 /* Avoid possible link errors. */
63 int yywrap (void)
65 return 1;
67 END
69 $ACLOCAL
70 $AUTOCONF
71 $AUTOMAKE -a
73 mkdir sub
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 ..
82 $LEX lexer.l
83 mv "$LEX_OUTPUT_ROOT".c lexer.c
85 cd sub
87 # Ensure that lexer.l will be newer than lexer.c.
88 $sleep
90 # New lexer, with 'fubar' comment.
91 cat > ../lexer.l << 'END'
93 #define YY_NO_UNISTD_H 1
96 "END" return EOF;
99 /*fubar*/
102 $MAKE
103 $MAKE distdir
104 $FGREP '/*fubar*/' $distdir/lexer.c
107 # Now check to make sure that 'make dist' will rebuilt the parser.
110 # Ensure that lexer.l will be newer than lexer.c.
111 $sleep
113 # New lexer, with 'maude' comment.
114 cat > ../lexer.l << 'END'
116 #define YY_NO_UNISTD_H 1
119 "END" return EOF;
122 /*maude*/
125 $MAKE distdir
126 $FGREP '/*maude*/' $distdir/lexer.c