am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / yflags-cmdline-override.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 # Check that automake can cope with user-redefinition of $(YFLAGS)
18 # at configure time and/or at make time.
19
20 required='cc yacc'
21 . test-init.sh
22
23 cat >> configure.ac <<'END'
24 AC_PROG_CC
25 AC_PROG_YACC
26 AC_OUTPUT
27 END
28
29 cat > Makefile.am <<'END'
30 bin_PROGRAMS = foo
31 foo_SOURCES = foo.y
32 # A minor automake wart: automake doesn't generate code to clean
33 # '*.output' files generated by yacc (it's not even clear if that
34 # would be useful in general, so it's probably better to be
35 # conservative).
36 CLEANFILES = foo.output
37 # As the '-d' flag won't be given at automake time, automake won't
38 # be able to generate code to clean 'foo.h'.  We can't really blame
39 # automake for that.
40 MAINTAINERCLEANFILES = foo.h
41 END
42
43 cat > foo.y << 'END'
44 %{
45 int yylex () { return 0; }
46 void yyerror (char *s) { return; }
47 int main () { return 0; }
48 %}
49 %%
50 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
51 END
52
53 $ACLOCAL
54 $AUTOMAKE -a
55 $AUTOCONF
56
57 ./configure YFLAGS='-d -v'
58 $MAKE
59 ls -l
60 test -f foo.c
61 test -f foo.h
62 test -f foo.output
63
64 $MAKE maintainer-clean
65 ls -l
66
67 ./configure YFLAGS='-v'
68 $MAKE
69 ls -l
70 test -f foo.c
71 test ! -e foo.h
72 test -f foo.output
73
74 $MAKE maintainer-clean
75 ls -l
76
77 ./configure YFLAGS='-v'
78 run_make YFLAGS=-d
79 ls -l
80 test -f foo.c
81 test -f foo.h
82 test ! -e foo.output
83
84 $MAKE maintainer-clean
85 ls -l
86
87 :