readme: fixlets to HACKING
[automake.git] / t / yflags.sh
blobb1ba9a3e28a1282dbfe25bee222f10dffd0b9248
1 #! /bin/sh
2 # Copyright (C) 2010-2012 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 # 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.
22 . ./defs || exit 1
24 cat >fake-yacc <<'END'
25 #!/bin/sh
26 echo '/*' "$*" '*/' >y.tab.c
27 echo 'extern int dummy;' >> y.tab.c
28 END
29 chmod a+x fake-yacc
31 # Remove Yacc from the environment, so that it won't interfere
32 # with 'make -e' below.
33 unset YACC || :
35 cat >> configure.ac <<'END'
36 AC_SUBST([CC], [false])
37 # Simulate presence of Yacc using our fake-yacc script.
38 AC_SUBST([YACC], ['$(abs_top_srcdir)'/fake-yacc])
39 AC_OUTPUT
40 END
42 cat > Makefile.am <<'END'
43 AUTOMAKE_OPTIONS = no-dependencies
44 bin_PROGRAMS = foo bar
45 foo_SOURCES = main.c foo.y
46 bar_SOURCES = main.c bar.y
47 AM_YFLAGS = __am_flags__
48 bar_YFLAGS = __bar_flags__
49 END
51 $ACLOCAL
52 $AUTOMAKE -a
54 grep '\$(YFLAGS).*\$(bar_YFLAGS)' Makefile.in && exit 1
55 grep '\$(YFLAGS).*\$(AM_YFLAGS)' Makefile.in && exit 1
57 : > foo.y
58 : > bar.y
60 $AUTOCONF
61 ./configure
62 env YFLAGS=__user_flags__ $MAKE -e foo.c bar-bar.c
64 cat foo.c
65 cat bar-bar.c
67 grep '__am_flags__.*__user_flags__' foo.c
68 grep '__bar_flags__.*__user_flags__' bar-bar.c