tests: expose automake bug#14560
[platform/upstream/automake.git] / t / lex-pr204.sh
1 #! /bin/sh
2 # Copyright (C) 2011-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 # Related to PR 204.
18 # C sources derived from nodist_ lex sources should not be distributed.
19 # See also related test 'lex-nodist.sh'.
20 # The tests 'yacc-nodist.sh' and 'yacc-pr204.sh' does similar checks
21 # for yacc-generated .c and .h files.
22
23 required='cc lex'
24 . test-init.sh
25
26 cat >> configure.ac <<'EOF'
27 AM_MAINTAINER_MODE
28 AC_PROG_CC
29 dnl We use AC_PROG_LEX deliberately.
30 dnl Sister 'lex-nodist.sh' should use 'AM_PROG_LEX' instead.
31 AC_PROG_LEX
32 AC_OUTPUT
33 EOF
34
35 # The LEXER2 intermediate variable is there to make sure Automake
36 # matches 'nodist_' against the right variable name...
37 cat > Makefile.am << 'EOF'
38 EXTRA_PROGRAMS = foo
39 LEXER2 = lexer2.l
40 nodist_foo_SOURCES = lexer.l $(LEXER2)
41
42 distdirtest: distdir
43         test ! -f $(distdir)/lexer.c
44         test ! -f $(distdir)/lexer.l
45         test ! -f $(distdir)/lexer.h
46         test ! -f $(distdir)/lexer2.c
47         test ! -f $(distdir)/lexer2.l
48         test ! -f $(distdir)/lexer2.h
49 EOF
50
51 cat > lexer.l << 'END'
52 %{
53 #define YY_NO_UNISTD_H 1
54 %}
55 %%
56 "GOOD"   return EOF;
57 .
58 %%
59 int main (void)
60 {
61   return yylex ();
62 }
63 END
64
65 cp lexer.l lexer2.l
66
67 $ACLOCAL
68 $AUTOCONF
69 $AUTOMAKE -a
70
71 ./configure
72 $MAKE distdirtest
73
74 # Make sure lexer.c and lexer2.c are still targets.
75 $MAKE lexer.c lexer2.c
76 test -f lexer.c
77 test -f lexer2.c
78
79 # Ensure the rebuild rule works despite AM_MAINTAINER_MODE, because
80 # it's a nodist_ lexer.
81 $sleep
82 touch lexer.l lexer2.l
83 $sleep
84 $MAKE lexer.c lexer2.c
85 is_newest lexer.c lexer.l
86 is_newest lexer2.c lexer2.l
87
88 :