Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / mmodely.test
1 #! /bin/sh
2 # Copyright (C) 2004, 2006, 2007, 2009, 2010 Free Software Foundation,
3 # Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # Verify that intermediate files are only built from Yacc and Lex
19 # sources in maintainer mode.
20 # From Derek R. Price.
21
22 required=gcc
23 . ./defs || Exit 1
24
25 set -e
26
27 cat >> configure.in << 'END'
28 AM_MAINTAINER_MODE
29 AC_PROG_CC
30 AM_PROG_LEX
31 AC_PROG_YACC
32 AC_OUTPUT
33 END
34
35 cat > Makefile.am <<'END'
36 YACC = false
37 LEX = false
38 bin_PROGRAMS = zardoz
39 zardoz_SOURCES = zardoz.y joe.l
40 LDADD = @LEXLIB@
41 END
42
43 # The point of this test is that it is not dependent on a working lex or yacc.
44 cat > joe.c <<EOF
45 int joe (int arg)
46 {
47     return arg * 2;
48 }
49 EOF
50 # On systems which link in libraries non-lazily and whose linkers
51 # complain about unresolved symbols by default, such as Solaris, an
52 # yylex function needs to be defined to avoid an error due to an
53 # unresolved symbol.
54 cat > zardoz.c <<EOF
55 int joe (int arg);
56 int yylex (void)
57 {
58     return 0;
59 }
60 int main (int argc, char **argv)
61 {
62     return joe (argc);
63 }
64 EOF
65
66 # Ensure a later timestamp for our Lex & Yacc sources.
67 $sleep
68 : > joe.l
69 : > zardoz.y
70
71 $ACLOCAL
72 $AUTOCONF
73 $AUTOMAKE -a
74
75 ./configure
76 $MAKE
77
78 cat >myyacc.sh <<'END'
79 #! /bin/sh
80 echo "$@" >y.tab.c
81 END
82 cat >mylex.sh <<'END'
83 echo "$@" >lex.yy.c
84 END
85 chmod +x myyacc.sh mylex.sh
86 PATH="`pwd`$PATH_SEPARATOR$PATH"
87
88 # make maintainer-clean; ./configure; make should always work,
89 # per GNU Standard.
90 $MAKE maintainer-clean
91 ./configure
92 YACC="myyacc.sh" LEX="mylex.sh" \
93    LEX_OUTPUT_ROOT='lex.yy' $MAKE -e zardoz.c joe.c
94 grep zardoz.y zardoz.c
95 grep joe.l joe.c