Something that the following does not show, and it should have, is the
fact that Automake's Makefile.in have _not_ changed. They have been
regenerated using this very automake.
I'm quite happy: it's going to be possible to get rid of all the adhoc
code which registers various global dependencies in automake.in
itself, i.e., which violates `code-proximity' with *.am files.
Index: ChangeLog
from Akim Demaille <[EMAIL PROTECTED]>
* automake.in (%factored_dependencies): New.
(file_contents): Use it.
(handle_phony): Rename as...
(handle_factored_dependencies): this.
* subdirs.am: No need for convolved syntax to declare .PHONY.
Index: automake.in
--- automake.in Wed, 31 Jan 2001 01:46:13 +0100 akim (am/f/39_automake.i 1.22 755)
+++ automake.in Wed, 31 Jan 2001 02:41:57 +0100 akim (am/f/39_automake.i 1.22 755)
@@ -325,6 +325,15 @@
# in the top-level Makefile.in.
%configure_dist_common = ();
+# Holds the dependencies of target which dependencies are factored.
+# Typically, `.PHONY' will appear in plenty of *.am files, but must
+# be output once. Arguably all pure dependencies could be subject
+# to this factorization, but it is not unpleasant to have paragraphs
+# in Makefile: keeping related stuff altogether.
+%dependencies =
+(
+ ".PHONY" => []
+);
# Initialize global constants and our list of languages that are
@@ -680,7 +689,7 @@ sub generate_makefile
&handle_merge_targets ($output);
&handle_installdirs;
&handle_clean;
- &handle_phony;
+ &handle_factored_dependencies;
&check_typos;
@@ -4028,10 +4037,18 @@ sub do_one_clean_target
}
# Handle .PHONY target.
-sub handle_phony
+sub handle_factored_dependencies
{
- &pretty_print_rule ('.PHONY:', "", sort @phony);
- $output_rules .= "\n";
+ # FIXME: @PHONY must die!
+ push (@{${dependencies{".PHONY"}}}, @phony);
+
+ my ($category);
+ foreach $category (sort keys %dependencies)
+ {
+ &pretty_print_rule ("$category:", "",
+ sort @{${dependencies{$category}}});
+ $output_rules .= "\n";
+ }
}
@@ -7056,11 +7073,27 @@ sub file_contents
# Stick comments before the incoming macro or rule.
$comment = $_;
}
- elsif (/^\.PHONY: (.*)$/mso)
+ elsif (/$RULE_PATTERN/mso && !/\t/ && /^([^:]+): ([^:]+)$/som)
{
- # Having a special case for PHONY upstream seems much easier than
- # trying to have it fit in RULE_PATTERN and extract it later.
- push (@phony, split (/\s/, $1));
+ # Pure dependencies: take some Dude, it's good stuff!
+ my ($dependers, $dependees) = ($1, $2);
+ $dependers =~ s/\\\n//somg;
+ $dependees =~ s/\\\n//somg;
+ foreach (split (/\s/ , $dependers))
+ {
+ if (defined $dependencies{$_})
+ {
+ print STDERR "Pushing $dependees into $_\n";
+ push (@{$dependencies{$_}}, split (/\s/, $dependees));
+ }
+ else
+ {
+ # Free lance dependency.
+ $result_rules .= "$comment$separator$1: $2\n"
+ unless defined $contents{$1};
+ $comment = $separator = '';
+ }
+ }
}
elsif (/$RULE_PATTERN/mso)
{
Index: subdirs.am
--- subdirs.am Sun, 28 Jan 2001 15:51:12 +0100 akim (am/g/14_subdirs.am 1.2 644)
+++ subdirs.am Wed, 31 Jan 2001 01:49:25 +0100 akim (am/g/14_subdirs.am 1.2 644)
@@ -24,10 +24,9 @@
# (2) otherwise, pass the desired values on the `make' command line.
-.PHONY: all-recursive install-data-recursive install-exec-recursive
-.PHONY: installdirs-recursive install-recursive uninstall-recursive
-.PHONY: @INSTALLINFO@ check-recursive installcheck-recursive info-recursive
-.PHONY: dvi-recursive
+.PHONY: all-recursive install-data-recursive install-exec-recursive \
+installdirs-recursive install-recursive uninstall-recursive @INSTALLINFO@ \
+check-recursive installcheck-recursive info-recursive dvi-recursive
all-recursive install-data-recursive install-exec-recursive \
installdirs-recursive install-recursive uninstall-recursive @INSTALLINFO@ \