automake-patches
[Top][All Lists]
Advanced

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

Re: fix registration of factored rules, and hint about -local targets


From: Alexandre Duret-Lutz
Subject: Re: fix registration of factored rules, and hint about -local targets
Date: Wed, 16 Apr 2003 21:57:14 +0200
User-agent: Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.2 (gnu/linux)

>>> "Rich" == Richard Dawe <address@hidden> writes:

[...]

 Rich> Perhaps the test should be overrid.test or overide.test,

Yep, why not.

I'm installing the patch as follows.  I've added a special
exception to ignore .PHONY redefinitions (their are output but
not diagnosed).

2003-04-16  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/overrid.test: New file.
        * tests/phony.test: Count the number of .PHONY targets.

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 16 Apr 2003 19:55:35 -0000
@@ -5004,11 +5004,28 @@
        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";
+       }
     }
 }
 
@@ -7196,11 +7213,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   16 Apr 2003 19:55:41 -0000
@@ -297,6 +297,7 @@
 output3.test \
 output4.test \
 output5.test \
+overrid.test \
 package.test \
 parse.test \
 percent.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.620
diff -u -r1.620 Makefile.in
--- tests/Makefile.in   14 Apr 2003 19:59:30 -0000      1.620
+++ tests/Makefile.in   16 Apr 2003 19:55:41 -0000
@@ -400,6 +400,7 @@
 output3.test \
 output4.test \
 output5.test \
+overrid.test \
 package.test \
 parse.test \
 percent.test \
Index: tests/overrid.test
===================================================================
RCS file: tests/overrid.test
diff -N tests/overrid.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/overrid.test  16 Apr 2003 19:55:41 -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
Index: tests/phony.test
===================================================================
RCS file: /cvs/automake/automake/tests/phony.test,v
retrieving revision 1.1
diff -u -r1.1 phony.test
--- tests/phony.test    19 Sep 2002 08:59:49 -0000      1.1
+++ tests/phony.test    16 Apr 2003 19:55:41 -0000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (C) 2002  Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003  Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -32,3 +32,4 @@
 
 $ACLOCAL
 $AUTOMAKE
+test `$FGREP .PHONY: Makefile.in | wc -l` = 3

-- 
Alexandre Duret-Lutz





reply via email to

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