[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fix registration of factored rules, and hint about -local targets
From: |
Alexandre Duret-Lutz |
Subject: |
fix registration of factored rules, and hint about -local targets |
Date: |
Wed, 16 Apr 2003 00:10:56 +0200 |
User-agent: |
Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.2 (gnu/linux) |
Initally I wanted to change the -Woverride message to suggest
using -local variants of targets (when they are supported).
However while writing the test case I've discovered that
(horror!) factored targets such as 'installcheck', 'info',
'html', etc. weren't registered with rule_define (where the
-Woverride check is done). So I've fixed that. And since we
are now calling rule_define, it's easy to define these targets
only in conditions where they weren't already defined.
make check is running
2003-04-15 Alexandre Duret-Lutz <address@hidden>
* automake.in (rule_define): If the user tries to override
an Automake which has a -local variant, suggest using the
-local variant in the -Woverride diagnostic.
(handle_factored_dependencies): Register factored
rules with rule_define, and define them only in undefined
conditions.
* tests/Makefile.am (TESTS): Add override.test.
* tests/override.test: New file.
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1446
diff -u -r1.1446 automake.in
--- automake.in 14 Apr 2003 19:59:29 -0000 1.1446
+++ automake.in 15 Apr 2003 22:02:51 -0000
@@ -5004,11 +5004,18 @@
unless (@{$dependencies{$_}}
|| $actions{$_}
|| $required_targets{$_});
- &pretty_print_rule ("$_:", "\t",
- uniq (sort @{$dependencies{$_}}));
- $output_rules .= $actions{$_}
- if defined $actions{$_};
- $output_rules .= "\n";
+
+ # Define gathered targets in undefined conditions.
+ my @undefined_conds =
+ rule_define ($_, 'internal', TARGET_AUTOMAKE, TRUE, INTERNAL);
+ my @uniq_deps = uniq (sort @{$dependencies{$_}});
+ foreach my $cond (@undefined_conds)
+ {
+ my $condstr = $cond->subst_string;
+ &pretty_print_rule ("$condstr$_:", "$condstr\t", @uniq_deps);
+ $output_rules .= $actions{$_} if defined $actions{$_};
+ $output_rules .= "\n";
+ }
}
}
@@ -7196,11 +7203,27 @@
{
if ($oldowner == TARGET_USER)
{
+ # -am targets listed in %dependencies support a -local
+ # variant. If the user tries to override TARGET or
+ # TARGET-am for which there exists a -local variant,
+ # just tell the user to use it.
+ my $hint = 0;
+ my $noam = $target;
+ $noam =~ s/-am$//;
+ if (exists $dependencies{"$noam-am"})
+ {
+ $hint = "consider using $target-local instead of $target";
+ }
+
msg_cond_target ('override', $cond, $target,
"user target `$target' defined here"
. "$condmsg...", partial => 1);
msg ('override', $where,
- "... overrides Automake target `$target' defined here");
+ "... overrides Automake target `$target' defined here",
+ partial => $hint);
+ msg_cond_target ('override', $cond, $target, $hint)
+ if $hint;
+
# Don't overwrite the user definition of TARGET.
return ();
}
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.481
diff -u -r1.481 Makefile.am
--- tests/Makefile.am 14 Apr 2003 19:59:30 -0000 1.481
+++ tests/Makefile.am 15 Apr 2003 22:02:54 -0000
@@ -297,6 +297,7 @@
output3.test \
output4.test \
output5.test \
+override.test \
package.test \
parse.test \
percent.test \
Index: tests/override.test
===================================================================
RCS file: tests/override.test
diff -N tests/override.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/override.test 15 Apr 2003 22:02:55 -0000
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2003 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.
+
+# Make sure automake -Woverride suggests using TARGET-local instead
+# of TARGET when possible.
+
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AM_CONDITIONAL([COND])
+END
+
+cat > Makefile.am << 'END'
+install:
+ :
+installcheck:
+ :
+html:
+ :
+
+if COND
+ps: mine
+ :
+endif
+END
+
+$ACLOCAL
+$AUTOMAKE -Wno-override
+$AUTOMAKE 2>stderr && exit 1
+cat stderr
+grep install-local stderr && exit 1 # There is no such thing as install-local
+grep installcheck-local stderr
+grep html-local stderr
+
+# Conditional overrides ought to be diagnosed, but it can't be done yet.
+# See the FIXME in rule_define. Once this is fixed, the grep below
+# will fail. If you see the failure, it means you fixed Automake. Well done!
+# Just strip out the next '&& exit 1' and this comment.
+grep ps stderr && exit 1
+
+# Test for another issue. Overriding html: should cause only one
+# html: rule to be output.
+test `grep html: Makefile.in | wc -l` = 1
+
+# ps: should be output in two conditions
+test `grep ps: Makefile.in | wc -l` = 2
+grep '@address@hidden: mine' Makefile.in
+grep '@address@hidden: ps-am' Makefile.in
--
Alexandre Duret-Lutz
- fix registration of factored rules, and hint about -local targets,
Alexandre Duret-Lutz <=