From: Alexandre Duret-Lutz Date: Sun, 29 Feb 2004 19:10:21 +0000 (+0000) Subject: * automake.in (lang_yacc_target_hook): Use Automake::Rule::define X-Git-Tag: Release-1-8b~56 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=83e68bdce97a72b2122050bfef446b4584b60f91;p=automake.git * automake.in (lang_yacc_target_hook): Use Automake::Rule::define so that rules for the same headers are not output twice. * lib/Automake/Variable.pm (value_as_list_recursive): Do not call `return' inside `map'. * tests/cond30.test: Make sure `a.c' and `b.c' both appear in the Makefile.in. * tests/cond35.test, tests/cond36.test: New files. * tests/Makefile.am (TESTS): Add cond35.test and cond36.test. Report from Roman Fietze. --- diff --git a/ChangeLog b/ChangeLog index a9071376..8386e5a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2004-02-29 Alexandre Duret-Lutz + * automake.in (lang_yacc_target_hook): Use Automake::Rule::define + so that rules for the same headers are not output twice. + * lib/Automake/Variable.pm (value_as_list_recursive): Do not + call `return' inside `map'. + * tests/cond30.test: Make sure `a.c' and `b.c' both appear + in the Makefile.in. + * tests/cond35.test, tests/cond36.test: New files. + * tests/Makefile.am (TESTS): Add cond35.test and cond36.test. + Report from Roman Fietze. + Fix for PR/413: * lib/am/distdir.am (distcheck): Create $dc_destdir with `umask 077 && mkdir' instead of `$(mkdir_p)'. This prevents possible diff --git a/THANKS b/THANKS index cbdf7dd6..ebfa490f 100644 --- a/THANKS +++ b/THANKS @@ -212,6 +212,7 @@ Robert Bihlmeyer robbe@orcus.priv.at Robert Boehne rboehne@ricardo-us.com Robert Collins robert.collins@itdomain.com.au Roberto Bagnara bagnara@cs.unipr.it +Roman Fietze roman.fietze@telemotive.de Ronald Landheer ronald@landheer.com Rusty Ballinger rusty@rlyeh.engr.sgi.com Ryan T. Sammartino ryants@shaw.ca diff --git a/automake.in b/automake.in index f22cffc8..af5a86fa 100755 --- a/automake.in +++ b/automake.in @@ -5064,13 +5064,20 @@ sub lang_yacc_target_hook # Add a dependency for the generated header file, and arrange # for that file to be included in the distribution. # FIXME: this fails for `nodist_*_SOURCES'. - $output_rules .= ("${header}: $output\n" - # Recover from removal of $header - . "\t\@if test ! -f \$@; then \\\n" - . "\t rm -f $output; \\\n" - . "\t \$(MAKE) $output; \\\n" - . "\telse :; fi\n"); + foreach my $cond (Automake::Rule::define (${header}, 'internal', + RULE_AUTOMAKE, TRUE, + INTERNAL)) + { + my $condstr = $cond->subst_string; + $output_rules .= ("$condstr${header}: $output\n" + # Recover from removal of $header + . "$condstr\t\@if test ! -f \$@; then \\\n" + . "$condstr\t rm -f $output; \\\n" + . "$condstr\t \$(MAKE) $output; \\\n" + . "$condstr\telse :; fi\n"); + } &push_dist_common ($header); + # If the files are built in the build directory, then we want # to remove them with `make clean'. If they are in srcdir # they shouldn't be touched. However, we can't determine this diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index e743011c..797d2ca9 100644 --- a/lib/Automake/Variable.pm +++ b/lib/Automake/Variable.pm @@ -620,7 +620,7 @@ sub value_as_list_recursive ($;%) # Collect results. sub { my ($var, $parent_cond, @allresults) = @_; - return map { my ($cond, @vals) = @$_; return @vals } @allresults; + return map { my ($cond, @vals) = @$_; @vals } @allresults; }, %options); } diff --git a/tests/Makefile.am b/tests/Makefile.am index f9c812f0..a1333479 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -121,6 +121,8 @@ cond31.test \ cond32.test \ cond33.test \ cond34.test \ +cond35.test \ +cond36.test \ condd.test \ condinc.test \ condinc2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index e6f60dd6..8b808575 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -236,6 +236,8 @@ cond31.test \ cond32.test \ cond33.test \ cond34.test \ +cond35.test \ +cond36.test \ condd.test \ condinc.test \ condinc2.test \ diff --git a/tests/cond30.test b/tests/cond30.test index c9fb80b2..10ff041c 100755 --- a/tests/cond30.test +++ b/tests/cond30.test @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -56,3 +56,6 @@ grep 'BEG: a.foo :END' stdout EXEEXT=.foo $MAKE -e print > stdout cat stdout grep 'BEG: b.foo :END' stdout + +grep 'a_SOURCES = a.c' Makefile.in +grep 'b_SOURCES = b.c' Makefile.in diff --git a/tests/cond35.test b/tests/cond35.test new file mode 100755 index 00000000..3e9bae6d --- /dev/null +++ b/tests/cond35.test @@ -0,0 +1,94 @@ +#!/bin/sh +# Copyright (C) 2004 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Automake is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Check rules output for parser defined conditionally. +# Report from Roman Fietze. + +required='flex bison gcc' +. ./defs + +set -e + +cat >>configure.in <<'EOF' +AM_CONDITIONAL([CASE_A], test -z "$case_B") +AC_PROG_CC +AM_PROG_LEX +AC_PROG_YACC +AC_OUTPUT +EOF + +cat >>Makefile.am <<'EOF' +AM_YFLAGS = -d + +BUILT_SOURCES = tparse.h + +if CASE_A +bin_PROGRAMS = ta +ta_SOURCES = ta.c tparse.h tscan.l tparse.y +ta_LDADD = $(LEXLIB) +else +bin_PROGRAMS = tb +tb_SOURCES = tb.c tparse.h tscan.l tparse.y +tb_LDADD = $(LEXLIB) +endif + + +test-ta: + test -f ta$(EXEEXT) +test-tb: + test -f tb$(EXEEXT) +EOF + +$ACLOCAL +$AUTOCONF +$AUTOMAKE --add-missing + +test `grep tparse.h: Makefile.in | wc -l` = 1 + +cat > tscan.l << 'END' +%% +"END" return EOF; +END + +cat > tparse.y << 'END' +%{ +void yyerror (char *s) {} +%} +%token EOF +%% +foobar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {}; +END + +cat >ta.c <<'END' +int main() +{ + return 0; +} +END + +cp ta.c tb.c + +./configure +$MAKE +$MAKE test-ta + +./configure case_B=yes +$MAKE +$MAKE test-tb diff --git a/tests/cond36.test b/tests/cond36.test new file mode 100755 index 00000000..e87c460d --- /dev/null +++ b/tests/cond36.test @@ -0,0 +1,64 @@ +#!/bin/sh +# Copyright (C) 2004 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Automake is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Check rules output for parser defined conditionally. + +required='flex bison gcc' +. ./defs + +set -e + +cat >>configure.in <<'EOF' +AM_CONDITIONAL([CASE_A], test -z "$case_B") +AC_PROG_CC +AM_PROG_LEX +AC_PROG_YACC +AC_OUTPUT +EOF + +cat >>Makefile.am <<'EOF' +AM_YFLAGS = -d + +BUILT_SOURCES = tparse.h + +if CASE_A +bin_PROGRAMS = ta +ta_SOURCES = ta.c tparse.h tscan.l tparse.y +ta_LDADD = $(LEXLIB) +else +bin_PROGRAMS = tb +tb_SOURCES = tb.c tparse.h tscan.l tparse.y +tb_LDADD = $(LEXLIB) +tparse.h: tparce.c + echo whatever +endif +EOF + +$ACLOCAL + +# Presently Automake doesn't fully support partially overriden rules +# and should complain. +AUTOMAKE_fails --add-missing +grep 'tparse.h.*already defined' stderr + +# Still and all, it should generate two rules. +test `grep tparse.h: Makefile.in | wc -l` = 2 +grep '@CASE_A_TRUE@tparse.h:' Makefile.in +grep '@CASE_A_FALSE@tparse.h:' Makefile.in