From: Akim Demaille Date: Sun, 25 Nov 2007 10:15:23 +0000 (+0100) Subject: Define and use register_action. X-Git-Tag: v1.10b~207 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a3cfc9bd5da9d38c34b10eac420eeed33637ca1;p=thirdparty%2Fautomake.git Define and use register_action. * lib/Automake/Rule.pm: Fix a few typos in the doc. (&rule): Use || to simplify the code. (®ister_action): New. Export it. * automake.in (&handle_factored_dependencies, &file_contents_internal): Use it. Signed-off-by: Akim Demaille --- diff --git a/ChangeLog b/ChangeLog index 2070bbbd5..ea797ae77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-11-25 Akim Demaille + + Define and use register_action. + * lib/Automake/Rule.pm: Fix a few typos in the doc. + (&rule): Use || to simplify the code. + (®ister_action): New. + Export it. + * automake.in (&handle_factored_dependencies, &file_contents_internal): + Use it. + 2007-11-25 Akim Demaille * bootstrap: Fix typos on redirections. diff --git a/automake.in b/automake.in index efad09769..b5f5f12ce 100755 --- a/automake.in +++ b/automake.in @@ -4530,10 +4530,10 @@ sub handle_factored_dependencies { if (user_phony_rule "$_-hook") { - $actions{"$_-am"} .= - ("\t\@\$(NORMAL_INSTALL)\n" - . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n"); depend ('.MAKE', "$_-am"); + register_action("$_-am", + ("\t\@\$(NORMAL_INSTALL)\n" + . "\t\$(MAKE) \$(AM_MAKEFLAGS) $_-hook")); } } @@ -6686,14 +6686,7 @@ sub file_contents_internal ($$$%) if (defined $dependencies{$_} && $cond != FALSE) { &depend ($_, @deps); - if ($actions{$_}) - { - $actions{$_} .= "\n$actions" if $actions; - } - else - { - $actions{$_} = $actions; - } + register_action ($_, $actions); } else { diff --git a/lib/Automake/Rule.pm b/lib/Automake/Rule.pm index 21890f0b0..cebf4fd07 100644 --- a/lib/Automake/Rule.pm +++ b/lib/Automake/Rule.pm @@ -31,7 +31,8 @@ use vars '@ISA', '@EXPORT', '@EXPORT_OK'; @ISA = qw/Automake::Item Exporter/; @EXPORT = qw (reset register_suffix_rule suffix_rules_count suffixes rules $suffix_rules $KNOWN_EXTENSIONS_PATTERN - depend %dependencies %actions accept_extensions + depend %dependencies %actions register_action + accept_extensions reject_rule msg_rule msg_cond_rule err_rule err_cond_rule rule rrule ruledef rruledef); @@ -62,9 +63,9 @@ and one to look up the conditional definition: { my $def = $rule->def ($cond); if ($def) - { - return $def->location; - } + { + return $def->location; + } ... } ... @@ -76,7 +77,7 @@ being looked up exist, the above can be simplified to but is better written - return rrule ($name)->rrule ($cond)->location; + return rrule ($name)->rdef ($cond)->location; or even @@ -109,7 +110,7 @@ use vars '$_suffix_rules_default'; Holds the dependencies of targets which dependencies are factored. Typically, C<.PHONY> will appear in plenty of F<*.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 +this factoring, but it is not unpleasant to have paragraphs in Makefile: keeping related stuff altogether. =cut @@ -272,7 +273,7 @@ sub accept_extensions (@) =item C -Returns the list of all L instances. (I.e., all +Return the list of all L instances. (I.e., all rules defined so far.) =cut @@ -284,6 +285,27 @@ sub rules () } +=item C + +Append the C<$action> to C<$actions{$target}> taking care of special +cases. + +=cut + +sub register_action ($$) +{ + my ($target, $action) = @_; + if ($actions{$target}) + { + $actions{$target} .= "\n$action" if $action; + } + else + { + $actions{$target} = $action; + } +} + + =item C The I function. Clears all know rules and reset some @@ -478,8 +500,7 @@ sub rule ($) # Strip $(EXEEXT) from $name, so we can diagnose # a clash if `ctags$(EXEEXT):' is redefined after `ctags:'. $name =~ s,\$\(EXEEXT\)$,,; - return $_rule_dict{$name} if exists $_rule_dict{$name}; - return 0; + return $_rule_dict{$name} || 0; } =item C @@ -640,7 +661,7 @@ sub define ($$$$$) # msg ('syntax', $where, # "redefinition of `$target'$condmsg...", partial => 1); # msg_cond_rule ('syntax', $cond, $target, - # "... `$target' previously defined here"); + # "... `$target' previously defined here"); } # Return so we don't redefine the rule in our tables, # don't check for ambiguous condition, etc. The rule