+2003-04-16 Alexandre Duret-Lutz <adl@gnu.org>
+
+ * 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/overrid.test: New file.
+ * tests/phony.test: Count the number of .PHONY targets.
+
2003-04-15 Alexandre Duret-Lutz <adl@gnu.org>
* lib/am/distdir.am (distuninstallcheck, distcleancheck): Silent
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.
+ # FIXME: Right now we must handle .PHONY as an exception,
+ # because people write things like
+ # .PHONY: myphonytarget
+ # to append dependencies. This would not work if Automake
+ # refrained from defining its own .PHONY target as it does
+ # with other overridden targets.
+ my @undefined_conds = (TRUE,);
+ if ($_ ne '.PHONY')
+ {
+ @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";
+ }
}
}
{
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 ();
}
output3.test \
output4.test \
output5.test \
+overrid.test \
package.test \
parse.test \
percent.test \
output3.test \
output4.test \
output5.test \
+overrid.test \
package.test \
parse.test \
percent.test \
--- /dev/null
+#! /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 '@COND_TRUE@ps: mine' Makefile.in
+grep '@COND_FALSE@ps: ps-am' Makefile.in
#!/bin/sh
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
$ACLOCAL
$AUTOMAKE
+test `$FGREP .PHONY: Makefile.in | wc -l` = 3