2 # Copyright (C) 2011-2024 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)
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 the user can force automake to use *_YFLAGS variables
18 # which have conditional content.
22 cat >> configure.ac
<<'END'
23 AC_SUBST([CC], [false])
25 AM_CONDITIONAL([COND], [test x"$cond" = x"yes"])
30 cat > bin
/fake-yacc
<<'END'
32 echo "/* $* */" > y.tab.c
33 echo 'extern int dummy;' >> y.tab.c
35 chmod a
+x bin
/fake-yacc
36 PATH
=$
(pwd)/bin
$PATH_SEPARATOR$PATH; export PATH
37 YACC
=fake-yacc
; export YACC
39 cat > Makefile.am
<<'END'
40 AUTOMAKE_OPTIONS = no-dependencies
41 AM_LFLAGS = --never-interactive
43 bin_PROGRAMS = foo bar
44 foo_SOURCES = foo.y main.c
45 bar_SOURCES = $(foo_SOURCES)
46 bar_YFLAGS = $(bar_yflags2)
48 AM_YFLAGS = __am_cond_yes__
49 bar_YFLAGS += __bar_cond_yes__
51 AM_YFLAGS = __am_cond_no__
52 bar_yflags2 = __bar_cond_no__
60 $AUTOMAKE -a -Wno-unsupported
62 $EGREP '(YFLAGS|yflags|am__append)' Makefile.
in # For debugging.
70 $FGREP ' __am_cond_yes__ ' foo.c
71 $FGREP ' __bar_cond_yes__ ' bar-foo.c
72 $FGREP 'cond_no' foo.c bar-foo.c
&& exit 1
74 $MAKE maintainer-clean
83 $FGREP ' __am_cond_no__ ' foo.c
84 $FGREP ' __bar_cond_no__ ' bar-foo.c
85 $FGREP 'cond_yes' foo.c bar-foo.c
&& exit 1