automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCHES] yacc: support variable expansions in *YFLAGS definition


From: Ralf Wildenhues
Subject: Re: [PATCHES] yacc: support variable expansions in *YFLAGS definition
Date: Sat, 8 Jan 2011 19:09:27 +0100
User-agent: Mutt/1.5.20 (2010-08-04)

[ dropping the PR Cc: ]

* Stefano Lattarini wrote on Fri, Jan 07, 2011 at 11:50:51PM CET:
> On Friday 07 January 2011, Ralf Wildenhues wrote:
> > * Stefano Lattarini wrote on Fri, Jan 07, 2011 at 03:36:43PM CET:
> > > Currently, automake is not smart enough to resolve variable expansions
> > > in AM_YFLAGS (or foo_YFLAGS) when scanning them for the `-d' flag.

> The attached two-patch series should fix the bug (the first patch
> is a testsuite enhancement, the second one really fixes the bug).
> 
> OK to apply to the temporary branch 'yacc-clean' (recently merged into
> master with commit v1.11-575-ga297a16) and merge to master again?

The first one is OK with nits addressed.  I'll reply to the second
separately (as my mailer somehow only quoted the first patch).

I note that some of the tests ({cmdline,force}-override) in these
patches require either yacc or bison to be present, but don't have
'required' lines.  If you want to make a distinction (feel free to
decide), then you could add a 'yacc' entry in tests/defs.in that doesn't
check --version (as non-GNU yaccs won't understand that); preapproved.

Thanks!
Ralf

> Subject: [PATCH 1/2] tests: more on *YFLAGS support
> 
> * tests/yflags-var-expand.test: New test, still xfailing.  It
> exposes automake bug#7800 -- "automake fails to honor `-d' in
> AM_YFLAGS when variable expansions are involved".
> * tests/yflags-d-false-positive.test: New test, checking that
> automake do not spuriously see `-d' in *YFLAGS when that isn't
> really there.
> * tests/yflags-force-override.test: New test, checking that
> automake can cope with definition of the YFLAGS variable in
> Makefile.am (even if that is an extremely bad practice, as that
> variable is user-reserved).
> * tests/yflags-cmdline-override.test: New test, checking that
> automake can cope with user-redefinition of YFLAGS at configure
> time and/or at make time.
> * tests/yflags-conditional.test: New test, checks that automake
> warns on conditionally-defined *YFLAGS variables.
> * tests/Makefile.am (TESTS, XFAIL_TESTS): Update.

> --- /dev/null
> +++ b/tests/yflags-cmdline-override.test
> @@ -0,0 +1,88 @@
> +#! /bin/sh
> +# Copyright (C) 2011 Free Software Foundation, Inc.

> +# Check that automake can cope with user-redefinition of $(YFLAGS)
> +# at configure time and/or at make time.
> +
> +. ./defs || Exit 1
> +
> +set -e
> +
> +unset YFLAGS || :
> +
> +cat >> configure.in <<'END'
> +AC_PROG_CC
> +AC_PROG_YACC
> +AC_OUTPUT
> +END
> +
> +cat > Makefile.am <<'END'
> +bin_PROGRAMS = foo
> +foo_SOURCES = foo.y
> +# A minor automake wart: automake doesn't generate the code to clean

s/the //

> +# `*.output' files generated by yacc (it's not even clear if that would
> +# be useful in general, so it's probably better to be conservative).
> +CLEANFILES = foo.output
> +# Another automake wart: `-d' flag won't be given at automake time, so
> +# automake won't be able to generate the code to clean `foo.h' :-(
> +MAINTAINERCLEANFILES = foo.h
> +END
> +
> +cat > foo.y << 'END'
> +%{
> +int yylex () { return 0; }
> +void yyerror (char *s) { return; }
> +int main () { return 0; }
> +%}
> +%%
> +foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
> +END
> +
> +$ACLOCAL
> +$AUTOMAKE -a
> +$AUTOCONF
> +
> +./configure YFLAGS='-d -v'
> +$MAKE
> +ls -l
> +test -f foo.c
> +test -f foo.h
> +test -f foo.output
> +
> +$MAKE maintainer-clean
> +ls -l
> +
> +./configure YFLAGS='-v'
> +$MAKE
> +ls -l
> +test -f foo.c
> +test ! -r foo.h
> +test -f foo.output
> +
> +$MAKE maintainer-clean
> +ls -l
> +
> +./configure YFLAGS='-v'
> +YFLAGS=-d $MAKE -e
> +ls -l
> +test -f foo.c
> +test -f foo.h
> +test ! -r foo.output
> +
> +$MAKE maintainer-clean
> +ls -l
> +
> +:

> --- /dev/null
> +++ b/tests/yflags-conditional.test
> @@ -0,0 +1,46 @@

> +# Check that automake complains about conditionally-defined *_YFLAGS.
> +
> +. ./defs || Exit 1
> +
> +set -e
> +
> +cat >> configure.in <<'END'
> +AC_PROG_CC
> +AC_PROG_YACC
> +AM_CONDITIONAL([COND], [:])
> +END
> +
> +cat > Makefile.am <<'END'
> +bin_PROGRAMS = foo bar
> +foo_SOURCES = foo.y
> +bar_SOURCES = bar.y
> +if COND
> +AM_YFLAGS = $(YFLAGS)
> +bar_YFLAGS = -v
> +endif COND
> +END
> +
> +: > ylwrap
> +
> +$ACLOCAL
> +AUTOMAKE_fails
> +grep "Makefile\.am:5:.*AM_YFLAGS.* defined conditionally" stderr
> +grep "Makefile\.am:6:.*bar_YFLAGS.* defined conditionally" stderr

> --- /dev/null
> +++ b/tests/yflags-d-false-positives.test

> +# Check for false positives in automake recognition of `-d' in YFLAGS.
> +
> +. ./defs || Exit 1
> +
> +set -e
> +
> +cat >> configure.in <<'END'
> +AC_PROG_CC
> +AC_PROG_YACC
> +END
> +
> +$ACLOCAL
> +
> +cat > Makefile.am <<'END'
> +bin_PROGRAMS = zardoz foobar
> +zardoz_SOURCES = zardoz.y
> +foobar_SOURCES = foobar.y
> +AM_YFLAGS = -xd --d - d --output=d
> +foobar_YFLAGS = - d $(foovar)-d -dd

Is that '- d' a typo?

> +END
> +
> +$AUTOMAKE -a
> +$EGREP '(foobar|zardoz)\.h.*:' Makefile.in && Exit 1
> +$EGREP '(foobar|zardoz)\.h' Makefile.in | $FGREP -v '$(YLWRAP) ' && Exit 1

> --- /dev/null
> +++ b/tests/yflags-force-override.test

> +# Check that automake can cope with definition of the $(YFLAGS) variable

a definition

> +# in Makefile.am (even if that is an extremely bad practice, because that

s/an //

> +# variable is user-reserved).
> +
> +. ./defs || Exit 1
> +
> +set -e
> +
> +cat >> configure.in <<'END'
> +AC_PROG_CC
> +AC_PROG_YACC
> +AC_OUTPUT
> +END
> +
> +cat > Makefile.am <<'END'
> +bin_PROGRAMS = foo
> +foo_SOURCES = foo.y
> +YFLAGS = -d -v
> +END
> +
> +cat > foo.y << 'END'
> +%{
> +int yylex () { return 0; }
> +void yyerror (char *s) { return; }
> +int main () { return 0; }
> +%}
> +%%
> +foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
> +END
> +
> +$ACLOCAL
> +$AUTOMAKE -a -Wno-gnu
> +
> +$EGREP '(foo|YFLAGS)' Makefile.in # for debugging
> +grep '^foo.h *:' Makefile.in
> +
> +$AUTOCONF
> +./configure
> +
> +$MAKE
> +
> +test -f foo.c
> +test -f foo.h
> +test -f foo.output
> +
> +$MAKE distcheck

> --- /dev/null
> +++ b/tests/yflags-var-expand.test

> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# Check that automake expand variables when looking for `-d' in YFLAGS;
> +# for example, the following is supposed to work:
> +#  foo_flags = -d
> +#  AM_YFLAGS = $(foo_flags)
> +
> +. ./defs || Exit 1
> +
> +set -e
> +
> +cat >> configure.in <<'END'
> +AC_PROG_CC
> +AC_PROG_YACC
> +END
> +
> +$ACLOCAL
> +
> +cat > Makefile.am <<'END'
> +bin_PROGRAMS = foo bar
> +foo_SOURCES = foo.y
> +bar_SOURCES = bar.y
> +my_YFLAGS = -x
> +AM_YFLAGS = $(my_YFLAGS:x=d)
> +bar_YFLAGS = $(AM_YFLAGS)
> +END
> +
> +$AUTOMAKE -a
> +
> +$EGREP '(foo|bar|YFLAGS)' Makefile.in # for debugging
> +grep '^foo.h *:' Makefile.in
> +grep '^bar-bar.h *:' Makefile.in
> +
> +cat > Makefile.am <<'END'
> +AUTOMAKE_OPTIONS = -Wno-gnu
> +bin_PROGRAMS = zardoz
> +zardoz_SOURCES = parser.y
> +my_YFLAGS = $(my_YFLAGS_1)
> +my_YFLAGS += $(my_YFLAGS_2)
> +my_YFLAGS_2 = -d
> +YFLAGS = $(my_YFLAGS)
> +END
> +
> +$AUTOMAKE
> +
> +$EGREP 'parser|YFLAGS' Makefile.in # for debugging
> +grep '^parser.h *:' Makefile.in



reply via email to

[Prev in Thread] Current Thread [Next in Thread]