Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / yflags.test
1 #! /bin/sh
2 # Copyright (C) 2010, 2011 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 $(YFLAGS) takes precedence over both $(AM_YFLAGS) and
18 # $(foo_YFLAGS).
19 # Please keep this in sync with the sister tests yflags2.test, lflags.test
20 # and lflags2.test
21
22 . ./defs || Exit 1
23
24 set -e
25
26 cat >fake-yacc <<'END'
27 #!/bin/sh
28 echo '/*' "$*" '*/' >y.tab.c
29 echo 'extern int dummy;' >> y.tab.c
30 END
31 chmod a+x fake-yacc
32
33 # Remove Yacc from the environment, so that it won't interfere
34 # with `make -e' below.
35 unset YACC || :
36
37 cat >> configure.in <<'END'
38 AC_PROG_CC
39 # Simulate presence of Yacc using our fake-yacc script.
40 AC_SUBST([YACC], ['$(abs_top_srcdir)'/fake-yacc])
41 AC_OUTPUT
42 END
43
44 cat > Makefile.am <<'END'
45 bin_PROGRAMS = foo bar
46 foo_SOURCES = main.c foo.y
47 bar_SOURCES = main.c bar.y
48 AM_YFLAGS = __am_flags__
49 bar_YFLAGS = __bar_flags__
50 END
51
52 $ACLOCAL
53 $AUTOMAKE -a
54
55 grep '\$(YFLAGS).*\$(bar_YFLAGS)' Makefile.in && Exit 1
56 grep '\$(YFLAGS).*\$(AM_YFLAGS)' Makefile.in && Exit 1
57
58 echo 'int main(void){ return 0; }' > main.c
59 : > foo.y
60 : > bar.y
61
62 $AUTOCONF
63 ./configure
64 env YFLAGS=__user_flags__ $MAKE -e
65
66 ls -l
67
68 cat foo.c
69 grep '__am_flags__.*__user_flags__' foo.c
70 cat bar-bar.c
71 grep '__bar_flags__.*__user_flags__' bar-bar.c
72
73 :