[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: automake, conditionals, warnings about overriding commands using .yy
From: |
Alexandre Duret-Lutz |
Subject: |
Re: automake, conditionals, warnings about overriding commands using .yy-files |
Date: |
Sun, 29 Feb 2004 20:10:02 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) |
>>> "roman" == roman fietze <address@hidden> writes:
[...]
roman> if CASE_A
roman> bin_PROGRAMS = ta
roman> ta_SOURCES = ta.cc tparse.h tscan.ll tparse.yy
roman> else
roman> bin_PROGRAMS = tb
roman> tb_SOURCES = tb.cc tparse.h tscan.ll tparse.yy
roman> endif
[...]
roman> Makefile:250: warning: overriding commands for target `tparse.h'
roman> Makefile:242: warning: ignoring old commands for target `tparse.h'
roman> This is caused by the occurence of tparse.h or tparse.yy
roman> in two separate conditionals of Makefile.am, causing
roman> automake to create two rules "tparse.h: tparse.yy ...".
Thanks for the report. Trying this code with Automake 1.8.2
revealed another more serious bug: ta_SOURCES was not processed at all.
I'm installing the following "double-fix" on HEAD and branch-1-8.
2004-02-29 Alexandre Duret-Lutz <address@hidden>
* 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.
Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.256.2.29
diff -u -r1.256.2.29 NEWS
--- NEWS 29 Feb 2004 16:26:27 -0000 1.256.2.29
+++ NEWS 29 Feb 2004 19:02:51 -0000
@@ -33,6 +33,9 @@
- Secure temporary directory creation in `make distcheck'. (PR/413)
+ - Do not generate two build rules for `parser.h' when the
+ parser appears in two different conditionals.
+
* Bugs introduced by 1.8:
- In some situations (hand-written `m4_include's), aclocal would
@@ -42,6 +45,16 @@
It is likely that the next major Automake releases will require at
least Perl 5.6. Consider upgrading your development environment
if you are still using the five-year-old Perl 5.005.
+
+ - Automake would sometimes fail to define rules for targets listed
+ in variables defined in multiple conditions. For instance on
+ if C1
+ bin_PROGRAMS = a
+ else
+ bin_PROGRAMS = b
+ endif
+ it would define only the `a.$(OBJEXT): a.c' rule and omit the
+ `b.$(OBJEXT): b.c' rule.
* New sections in manual:
Index: THANKS
===================================================================
RCS file: /cvs/automake/automake/THANKS,v
retrieving revision 1.230.2.13
diff -u -r1.230.2.13 THANKS
--- THANKS 29 Feb 2004 16:26:27 -0000 1.230.2.13
+++ THANKS 29 Feb 2004 19:02:52 -0000
@@ -212,6 +212,7 @@
Robert Boehne address@hidden
Robert Collins address@hidden
Roberto Bagnara address@hidden
+Roman Fietze address@hidden
Ronald Landheer address@hidden
Rusty Ballinger address@hidden
Ryan T. Sammartino address@hidden
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1526.2.7
diff -u -r1.1526.2.7 automake.in
--- automake.in 1 Feb 2004 12:19:50 -0000 1.1526.2.7
+++ automake.in 29 Feb 2004 19:02:55 -0000
@@ -4961,13 +4961,20 @@
# 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
- . "address@hidden 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
+ . "address@hidden 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
Index: lib/Automake/Variable.pm
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/Variable.pm,v
retrieving revision 1.27.2.2
diff -u -r1.27.2.2 Variable.pm
--- lib/Automake/Variable.pm 1 Feb 2004 18:07:06 -0000 1.27.2.2
+++ lib/Automake/Variable.pm 29 Feb 2004 19:02:59 -0000
@@ -620,7 +620,7 @@
# Collect results.
sub {
my ($var, $parent_cond, @allresults) = @_;
- return map { my ($cond, @vals) = @$_; return @vals } @allresults;
+ return map { my ($cond, @vals) = @$_; @vals } @allresults;
},
%options);
}
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.539.2.9
diff -u -r1.539.2.9 Makefile.am
--- tests/Makefile.am 1 Feb 2004 18:14:17 -0000 1.539.2.9
+++ tests/Makefile.am 29 Feb 2004 19:02:59 -0000
@@ -121,6 +121,8 @@
cond32.test \
cond33.test \
cond34.test \
+cond35.test \
+cond36.test \
condd.test \
condinc.test \
condinc2.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.698.2.17
diff -u -r1.698.2.17 Makefile.in
--- tests/Makefile.in 1 Feb 2004 18:14:17 -0000 1.698.2.17
+++ tests/Makefile.in 29 Feb 2004 19:02:59 -0000
@@ -236,6 +236,8 @@
cond32.test \
cond33.test \
cond34.test \
+cond35.test \
+cond36.test \
condd.test \
condinc.test \
condinc2.test \
Index: tests/cond30.test
===================================================================
RCS file: /cvs/automake/automake/tests/cond30.test,v
retrieving revision 1.2
diff -u -r1.2 cond30.test
--- tests/cond30.test 2 Feb 2003 23:40:51 -0000 1.2
+++ tests/cond30.test 29 Feb 2004 19:02:59 -0000
@@ -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 @@
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
Index: tests/cond35.test
===================================================================
RCS file: tests/cond35.test
diff -N tests/cond35.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/cond35.test 29 Feb 2004 19:02:59 -0000
@@ -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
Index: tests/cond36.test
===================================================================
RCS file: tests/cond36.test
diff -N tests/cond36.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/cond36.test 29 Feb 2004 19:02:59 -0000
@@ -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 '@address@hidden:' Makefile.in
+grep '@address@hidden:' Makefile.in
--
Alexandre Duret-Lutz
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: automake, conditionals, warnings about overriding commands using .yy-files,
Alexandre Duret-Lutz <=