Avoid leaking TEST_LOG_COMPILER in environment of test scripts.
[automake.git] / tests / mmodely.test
blob0f9bb3bd6bbc85e3c632360725400c5d13ff5665
1 #! /bin/sh
2 # Copyright (C) 2004, 2006, 2007, 2009 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 # Verify that intermediate files are only built from Yacc and Lex
18 # sources in maintainer mode.
19 # From Derek R. Price.
21 required=gcc
22 . ./defs || Exit 1
24 set -e
26 cat >> configure.in << 'END'
27 AM_MAINTAINER_MODE
28 AC_PROG_CC
29 AM_PROG_LEX
30 AC_PROG_YACC
31 AC_OUTPUT
32 END
34 cat > Makefile.am <<'END'
35 YACC = false
36 LEX = false
37 bin_PROGRAMS = zardoz
38 zardoz_SOURCES = zardoz.y joe.l
39 LDADD = @LEXLIB@
40 END
42 # The point of this test is that it is not dependent on a working lex or yacc.
43 cat > joe.c <<EOF
44 int joe (int arg)
46 return arg * 2;
48 EOF
49 # On systems which link in libraries non-lazily and whose linkers
50 # complain about unresolved symbols by default, such as Solaris, an
51 # yylex function needs to be defined to avoid an error due to an
52 # unresolved symbol.
53 cat > zardoz.c <<EOF
54 int joe (int arg);
55 int yylex (void)
57 return 0;
59 int main (int argc, char **argv)
61 return joe (argc);
63 EOF
65 # Ensure a later timestamp for our Lex & Yacc sources.
66 $sleep
67 : > joe.l
68 : > zardoz.y
70 $ACLOCAL
71 $AUTOCONF
72 $AUTOMAKE -a
74 ./configure
75 $MAKE
77 cat >myyacc.sh <<'END'
78 #! /bin/sh
79 echo "$@" >y.tab.c
80 END
81 cat >mylex.sh <<'END'
82 echo "$@" >lex.yy.c
83 END
84 chmod +x myyacc.sh mylex.sh
85 PATH="`pwd`:$PATH"
87 # make maintainer-clean; ./configure; make should always work,
88 # per GNU Standard.
89 $MAKE maintainer-clean
90 ./configure
91 YACC="myyacc.sh" LEX="mylex.sh" \
92 LEX_OUTPUT_ROOT='lex.yy' $MAKE -e zardoz.c joe.c
93 grep zardoz.y zardoz.c
94 grep joe.l joe.c