Merge branch 'minor'
[automake.git] / t / yflags.sh
blob3aaec0eb2b9681d14338f3ad7cef7793ca832c35
1 #! /bin/sh
2 # Copyright (C) 2010-2017 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 <https://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:
20 # - yflags-cxx.sh
21 # - lflags.sh
22 # - lflags-cxx.sh
24 . test-init.sh
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
33 cat >> configure.ac <<'END'
34 AC_SUBST([CC], [false])
35 # Simulate presence of Yacc using our fake-yacc script.
36 AC_SUBST([YACC], ['$(abs_top_srcdir)'/fake-yacc])
37 AC_OUTPUT
38 END
40 cat > Makefile.am <<'END'
41 AUTOMAKE_OPTIONS = no-dependencies
42 bin_PROGRAMS = foo bar
43 foo_SOURCES = main.c foo.y
44 bar_SOURCES = main.c bar.y
45 AM_YFLAGS = __am_flags__
46 bar_YFLAGS = __bar_flags__
47 END
49 $ACLOCAL
50 $AUTOMAKE -a
52 grep '\$(YFLAGS).*\$(bar_YFLAGS)' Makefile.in && exit 1
53 grep '\$(YFLAGS).*\$(AM_YFLAGS)' Makefile.in && exit 1
55 : > foo.y
56 : > bar.y
58 $AUTOCONF
59 ./configure
60 run_make YFLAGS=__user_flags__ foo.c bar-bar.c
62 cat foo.c
63 cat bar-bar.c
65 grep '__am_flags__.*__user_flags__' foo.c
66 grep '__bar_flags__.*__user_flags__' bar-bar.c