source: trunk/essentials/sys-devel/automake-1.10/lib/Automake/Rule.pm

Last change on this file was 3147, checked in by bird, 18 years ago

automake 1.10

File size: 22.5 KB
Line 
1# Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2, or (at your option)
6# any later version.
7
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16# 02110-1301, USA.
17
18package Automake::Rule;
19use strict;
20use Carp;
21
22use Automake::Item;
23use Automake::RuleDef;
24use Automake::ChannelDefs;
25use Automake::Channels;
26use Automake::Options;
27use Automake::Condition qw (TRUE FALSE);
28use Automake::DisjConditions;
29require Exporter;
30use vars '@ISA', '@EXPORT', '@EXPORT_OK';
31@ISA = qw/Automake::Item Exporter/;
32@EXPORT = qw (reset register_suffix_rule suffix_rules_count
33 suffixes rules $suffix_rules $KNOWN_EXTENSIONS_PATTERN
34 depend %dependencies %actions accept_extensions
35 reject_rule msg_rule msg_cond_rule err_rule err_cond_rule
36 rule rrule ruledef rruledef);
37
38=head1 NAME
39
40Automake::Rule - support for rules definitions
41
42=head1 SYNOPSIS
43
44 use Automake::Rule;
45 use Automake::RuleDef;
46
47
48=head1 DESCRIPTION
49
50This package provides support for Makefile rule definitions.
51
52An C<Automake::Rule> is a rule name associated to possibly
53many conditional definitions. These definitions are instances
54of C<Automake::RuleDef>.
55
56Therefore obtaining the value of a rule under a given
57condition involves two lookups. One to look up the rule,
58and one to look up the conditional definition:
59
60 my $rule = rule $name;
61 if ($rule)
62 {
63 my $def = $rule->def ($cond);
64 if ($def)
65 {
66 return $def->location;
67 }
68 ...
69 }
70 ...
71
72when it is known that the rule and the definition
73being looked up exist, the above can be simplified to
74
75 return rule ($name)->def ($cond)->location; # do not write this.
76
77but is better written
78
79 return rrule ($name)->rrule ($cond)->location;
80
81or even
82
83 return rruledef ($name, $cond)->location;
84
85The I<r> variants of the C<rule>, C<def>, and C<ruledef> methods add
86an extra test to ensure that the lookup succeeded, and will diagnose
87failures as internal errors (with a message which is much more
88informative than Perl's warning about calling a method on a
89non-object).
90
91=head2 Global variables
92
93=over 4
94
95=cut
96
97my $_SUFFIX_RULE_PATTERN =
98 '^(\.[a-zA-Z0-9_(){}$+@\-]+)(\.[a-zA-Z0-9_(){}$+@\-]+)' . "\$";
99
100# Suffixes found during a run.
101use vars '@_suffixes';
102
103# Same as $suffix_rules (declared below), but records only the
104# default rules supplied by the languages Automake supports.
105use vars '$_suffix_rules_default';
106
107=item C<%dependencies>
108
109Holds the dependencies of targets which dependencies are factored.
110Typically, C<.PHONY> will appear in plenty of F<*.am> files, but must
111be output once. Arguably all pure dependencies could be subject to
112this factorization, but it is not unpleasant to have paragraphs in
113Makefile: keeping related stuff altogether.
114
115=cut
116
117use vars '%dependencies';
118
119=item <%actions>
120
121Holds the factored actions. Tied to C<%dependencies>, i.e., filled
122only when keys exists in C<%dependencies>.
123
124=cut
125
126use vars '%actions';
127
128=item <$suffix_rules>
129
130This maps the source extension for all suffix rule seen to
131a C<hash> whose keys are the possible output extensions.
132
133Note that this is transitively closed by construction:
134if we have
135 exists $suffix_rules{$ext1}{$ext2}
136 && exists $suffix_rules{$ext2}{$ext3}
137then we also have
138 exists $suffix_rules{$ext1}{$ext3}
139
140So it's easy to check whether C<.foo> can be transformed to
141C<.$(OBJEXT)> by checking whether
142C<$suffix_rules{'.foo'}{'.$(OBJEXT)'}> exists. This will work even if
143transforming C<.foo> to C<.$(OBJEXT)> involves a chain of several
144suffix rules.
145
146The value of C<$suffix_rules{$ext1}{$ext2}> is the a pair
147C<[ $next_sfx, $dist ]> where C<$next_sfx> is target suffix
148for the next rule to use to reach C<$ext2>, and C<$dist> the
149distance to C<$ext2'>.
150
151The content of this variable should be updated via the
152C<register_suffix_rule> function.
153
154=cut
155
156use vars '$suffix_rules';
157
158=item C<$KNOWN_EXTENSIONS_PATTERN>
159
160Pattern that matches all know input extensions (i.e. extensions used
161by the languages supported by Automake). Using this pattern (instead
162of `\..*$') to match extensions allows Automake to support dot-less
163extensions.
164
165New extensions should be registered with C<accept_extensions>.
166
167=cut
168
169use vars qw ($KNOWN_EXTENSIONS_PATTERN @_known_extensions_list);
170$KNOWN_EXTENSIONS_PATTERN = "";
171@_known_extensions_list = ();
172
173=back
174
175=head2 Error reporting functions
176
177In these functions, C<$rule> can be either a rule name, or
178an instance of C<Automake::Rule>.
179
180=over 4
181
182=item C<err_rule ($rule, $message, [%options])>
183
184Uncategorized errors about rules.
185
186=cut
187
188sub err_rule ($$;%)
189{
190 msg_rule ('error', @_);
191}
192
193=item C<err_cond_rule ($cond, $rule, $message, [%options])>
194
195Uncategorized errors about conditional rules.
196
197=cut
198
199sub err_cond_rule ($$$;%)
200{
201 msg_cond_rule ('error', @_);
202}
203
204=item C<msg_cond_rule ($channel, $cond, $rule, $message, [%options])>
205
206Messages about conditional rules.
207
208=cut
209
210sub msg_cond_rule ($$$$;%)
211{
212 my ($channel, $cond, $rule, $msg, %opts) = @_;
213 my $r = ref ($rule) ? $rule : rrule ($rule);
214 msg $channel, $r->rdef ($cond)->location, $msg, %opts;
215}
216
217=item C<msg_rule ($channel, $targetname, $message, [%options])>
218
219Messages about rules.
220
221=cut
222
223sub msg_rule ($$$;%)
224{
225 my ($channel, $rule, $msg, %opts) = @_;
226 my $r = ref ($rule) ? $rule : rrule ($rule);
227 # Don't know which condition is concerned. Pick any.
228 my $cond = $r->conditions->one_cond;
229 msg_cond_rule ($channel, $cond, $r, $msg, %opts);
230}
231
232
233=item C<$bool = reject_rule ($rule, $error_msg)>
234
235Bail out with C<$error_msg> if a rule with name C<$rule> has been
236defined.
237
238Return true iff C<$rule> is defined.
239
240=cut
241
242sub reject_rule ($$)
243{
244 my ($rule, $msg) = @_;
245 if (rule ($rule))
246 {
247 err_rule $rule, $msg;
248 return 1;
249 }
250 return 0;
251}
252
253=back
254
255=head2 Administrative functions
256
257=over 4
258
259=item C<accept_extensions (@exts)>
260
261Update C<$KNOWN_EXTENSIONS_PATTERN> to recognize the extensions
262listed C<@exts>. Extensions should contain a dot if needed.
263
264=cut
265
266sub accept_extensions (@)
267{
268 push @_known_extensions_list, @_;
269 $KNOWN_EXTENSIONS_PATTERN =
270 '(?:' . join ('|', map (quotemeta, @_known_extensions_list)) . ')';
271}
272
273=item C<rules>
274
275Returns the list of all L<Automake::Rule> instances. (I.e., all
276rules defined so far.)
277
278=cut
279
280use vars '%_rule_dict';
281sub rules ()
282{
283 return values %_rule_dict;
284}
285
286
287=item C<Automake::Rule::reset>
288
289The I<forget all> function. Clears all know rules and reset some
290other internal data.
291
292=cut
293
294sub reset()
295{
296 %_rule_dict = ();
297 @_suffixes = ();
298 # The first time we initialize the variables,
299 # we save the value of $suffix_rules.
300 if (defined $_suffix_rules_default)
301 {
302 $suffix_rules = $_suffix_rules_default;
303 }
304 else
305 {
306 $_suffix_rules_default = $suffix_rules;
307 }
308
309 %dependencies =
310 (
311 # Texinfoing.
312 'dvi' => [],
313 'dvi-am' => [],
314 'pdf' => [],
315 'pdf-am' => [],
316 'ps' => [],
317 'ps-am' => [],
318 'info' => [],
319 'info-am' => [],
320 'html' => [],
321 'html-am' => [],
322
323 # Installing/uninstalling.
324 'install-data-am' => [],
325 'install-exec-am' => [],
326 'uninstall-am' => [],
327
328 'install-man' => [],
329 'uninstall-man' => [],
330
331 'install-dvi' => [],
332 'install-dvi-am' => [],
333 'install-html' => [],
334 'install-html-am' => [],
335 'install-info' => [],
336 'install-info-am' => [],
337 'install-pdf' => [],
338 'install-pdf-am' => [],
339 'install-ps' => [],
340 'install-ps-am' => [],
341
342 'installcheck-am' => [],
343
344 # Cleaning.
345 'clean-am' => [],
346 'mostlyclean-am' => [],
347 'maintainer-clean-am' => [],
348 'distclean-am' => [],
349 'clean' => [],
350 'mostlyclean' => [],
351 'maintainer-clean' => [],
352 'distclean' => [],
353
354 # Tarballing.
355 'dist-all' => [],
356
357 # Phoning.
358 '.PHONY' => [],
359 # Recursive install targets (so `make -n install' works for BSD Make).
360 '.MAKE' => [],
361 );
362 %actions = ();
363}
364
365=item C<register_suffix_rule ($where, $src, $dest)>
366
367Register a suffix rules defined on C<$where> that transform
368files ending in C<$src> into files ending in C<$dest>.
369
370This upgrades the C<$suffix_rules> variables.
371
372=cut
373
374sub register_suffix_rule ($$$)
375{
376 my ($where, $src, $dest) = @_;
377
378 verb "Sources ending in $src become $dest";
379 push @_suffixes, $src, $dest;
380
381 # When transforming sources to objects, Automake uses the
382 # %suffix_rules to move from each source extension to
383 # `.$(OBJEXT)', not to `.o' or `.obj'. However some people
384 # define suffix rules for `.o' or `.obj', so internally we will
385 # consider these extensions equivalent to `.$(OBJEXT)'. We
386 # CANNOT rewrite the target (i.e., automagically replace `.o'
387 # and `.obj' by `.$(OBJEXT)' in the output), or warn the user
388 # that (s)he'd better use `.$(OBJEXT)', because Automake itself
389 # output suffix rules for `.o' or `.obj'...
390 $dest = '.$(OBJEXT)' if ($dest eq '.o' || $dest eq '.obj');
391
392 # Reading the comments near the declaration of $suffix_rules might
393 # help to understand the update of $suffix_rules that follows...
394
395 # Register $dest as a possible destination from $src.
396 # We might have the create the \hash.
397 if (exists $suffix_rules->{$src})
398 {
399 $suffix_rules->{$src}{$dest} = [ $dest, 1 ];
400 }
401 else
402 {
403 $suffix_rules->{$src} = { $dest => [ $dest, 1 ] };
404 }
405
406 # If we know how to transform $dest in something else, then
407 # we know how to transform $src in that "something else".
408 if (exists $suffix_rules->{$dest})
409 {
410 for my $dest2 (keys %{$suffix_rules->{$dest}})
411 {
412 my $dist = $suffix_rules->{$dest}{$dest2}[1] + 1;
413 # Overwrite an existing $src->$dest2 path only if
414 # the path via $dest which is shorter.
415 if (! exists $suffix_rules->{$src}{$dest2}
416 || $suffix_rules->{$src}{$dest2}[1] > $dist)
417 {
418 $suffix_rules->{$src}{$dest2} = [ $dest, $dist ];
419 }
420 }
421 }
422
423 # Similarly, any extension that can be derived into $src
424 # can be derived into the same extensions as $src can.
425 my @dest2 = keys %{$suffix_rules->{$src}};
426 for my $src2 (keys %$suffix_rules)
427 {
428 if (exists $suffix_rules->{$src2}{$src})
429 {
430 for my $dest2 (@dest2)
431 {
432 my $dist = $suffix_rules->{$src}{$dest2} + 1;
433 # Overwrite an existing $src2->$dest2 path only if
434 # the path via $src is shorter.
435 if (! exists $suffix_rules->{$src2}{$dest2}
436 || $suffix_rules->{$src2}{$dest2}[1] > $dist)
437 {
438 $suffix_rules->{$src2}{$dest2} = [ $src, $dist ];
439 }
440 }
441 }
442 }
443}
444
445=item C<$count = suffix_rules_count>
446
447Return the number of suffix rules added while processing the current
448F<Makefile> (excluding predefined suffix rules).
449
450=cut
451
452sub suffix_rules_count ()
453{
454 return (scalar keys %$suffix_rules) - (scalar keys %$_suffix_rules_default);
455}
456
457=item C<@list = suffixes>
458
459Return the list of known suffixes.
460
461=cut
462
463sub suffixes ()
464{
465 return @_suffixes;
466}
467
468=item C<rule ($rulename)>
469
470Return the C<Automake::Rule> object for the rule
471named C<$rulename> if defined. Return 0 otherwise.
472
473=cut
474
475sub rule ($)
476{
477 my ($name) = @_;
478 # Strip $(EXEEXT) from $name, so we can diagnose
479 # a clash if `ctags$(EXEEXT):' is redefined after `ctags:'.
480 $name =~ s,\$\(EXEEXT\)$,,;
481 return $_rule_dict{$name} if exists $_rule_dict{$name};
482 return 0;
483}
484
485=item C<rule ($rulename, $cond>
486
487Return the C<Automake::RuleDef> object for the rule named
488C<$rulename> if defined in condition C<$cond>. Return false
489if the condition or the rule does not exist.
490
491=cut
492
493sub ruledef ($$)
494{
495 my ($name, $cond) = @_;
496 my $rule = rule $name;
497 return $rule && $rule->def ($cond);
498}
499
500=item C<rrule ($rulename)
501
502Return the C<Automake::Rule> object for the variable named
503C<$rulename>. Abort with an internal error if the variable was not
504defined.
505
506The I<r> in front of C<var> stands for I<required>. One
507should call C<rvar> to assert the rule's existence.
508
509=cut
510
511sub rrule ($)
512{
513 my ($name) = @_;
514 my $r = rule $name;
515 prog_error ("undefined rule $name\n" . &rules_dump)
516 unless $r;
517 return $r;
518}
519
520=item C<rruledef ($varname, $cond)>
521
522Return the C<Automake::RuleDef> object for the rule named
523C<$rulename> if defined in condition C<$cond>. Abort with an internal
524error if the condition or the rule does not exist.
525
526=cut
527
528sub rruledef ($$)
529{
530 my ($name, $cond) = @_;
531 return rrule ($name)->rdef ($cond);
532}
533
534# Create the variable if it does not exist.
535# This is used only by other functions in this package.
536sub _crule ($)
537{
538 my ($name) = @_;
539 my $r = rule $name;
540 return $r if $r;
541 return _new Automake::Rule $name;
542}
543
544sub _new ($$)
545{
546 my ($class, $name) = @_;
547
548 # Strip $(EXEEXT) from $name, so we can diagnose
549 # a clash if `ctags$(EXEEXT):' is redefined after `ctags:'.
550 (my $keyname = $name) =~ s,\$\(EXEEXT\)$,,;
551
552 my $self = Automake::Item::new ($class, $name);
553 $_rule_dict{$keyname} = $self;
554 return $self;
555}
556
557
558=itcem C<@conds = define ($rulename, $source, $owner, $cond, $where)>
559
560Define a new rule. C<$rulename> is the list of targets. C<$source>
561is the filename the rule comes from. C<$owner> is the owner of the
562rule (C<RULE_AUTOMAKE> or C<RULE_USER>). C<$cond> is the
563C<Automake::Condition> under which the rule is defined. C<$where> is
564the C<Automake::Location> where the rule is defined.
565
566Returns a (possibly empty) list of C<Automake::Condition>s where the
567rule's definition should be output.
568
569=cut
570
571sub define ($$$$$)
572{
573 my ($target, $source, $owner, $cond, $where) = @_;
574
575 prog_error "$where is not a reference"
576 unless ref $where;
577 prog_error "$cond is not a reference"
578 unless ref $cond;
579
580 # Don't even think about defining a rule in condition FALSE.
581 return () if $cond == FALSE;
582
583 # For now `foo:' will override `foo$(EXEEXT):'. This is temporary,
584 # though, so we emit a warning.
585 (my $noexe = $target) =~ s,\$\(EXEEXT\)$,,;
586 my $noexerule = rule $noexe;
587 my $tdef = $noexerule ? $noexerule->def ($cond) : undef;
588
589 if ($noexe ne $target
590 && $tdef
591 && $noexerule->name ne $target)
592 {
593 # The no-exeext option enables this feature.
594 if (! option 'no-exeext')
595 {
596 msg ('obsolete', $tdef->location,
597 "deprecated feature: target `$noexe' overrides "
598 . "`$noexe\$(EXEEXT)'\n"
599 . "change your target to read `$noexe\$(EXEEXT)'");
600 msg ('obsolete', $where, "target `$target' was defined here");
601 }
602 # Don't `return ()' now, as this might hide target clashes
603 # detected below.
604 }
605
606
607 # A GNU make-style pattern rule has a single "%" in the target name.
608 msg ('portability', $where,
609 "`%'-style pattern rules are a GNU make extension")
610 if $target =~ /^[^%]*%[^%]*$/;
611
612 # Diagnose target redefinitions.
613 if ($tdef)
614 {
615 my $oldowner = $tdef->owner;
616 # Ok, it's the name target, but the name maybe different because
617 # `foo$(EXEEXT)' and `foo' have the same key in our table.
618 my $oldname = $tdef->name;
619
620 # Don't mention true conditions in diagnostics.
621 my $condmsg =
622 $cond == TRUE ? '' : " in condition `" . $cond->human . "'";
623
624 if ($owner == RULE_USER)
625 {
626 if ($oldowner == RULE_USER)
627 {
628 # Ignore `%'-style pattern rules. We'd need the
629 # dependencies to detect duplicates, and they are
630 # already diagnosed as unportable by -Wportability.
631 if ($target !~ /^[^%]*%[^%]*$/)
632 {
633 ## FIXME: Presently we can't diagnose duplicate user rules
634 ## because we don't distinguish rules with commands
635 ## from rules that only add dependencies. E.g.,
636 ## .PHONY: foo
637 ## .PHONY: bar
638 ## is legitimate. (This is phony.test.)
639
640 # msg ('syntax', $where,
641 # "redefinition of `$target'$condmsg...", partial => 1);
642 # msg_cond_rule ('syntax', $cond, $target,
643 # "... `$target' previously defined here");
644 }
645 # Return so we don't redefine the rule in our tables,
646 # don't check for ambiguous condition, etc. The rule
647 # will be output anyway beauce &read_am_file ignore the
648 # return code.
649 return ();
650 }
651 else
652 {
653 # Since we parse the user Makefile.am before reading
654 # the Automake fragments, this condition should never happen.
655 prog_error ("user target `$target'$condmsg seen after Automake's"
656 . " definition\nfrom " . $tdef->source);
657 }
658 }
659 else # $owner == RULE_AUTOMAKE
660 {
661 if ($oldowner == RULE_USER)
662 {
663 # -am targets listed in %dependencies support a -local
664 # variant. If the user tries to override TARGET or
665 # TARGET-am for which there exists a -local variant,
666 # just tell the user to use it.
667 my $hint = 0;
668 my $noam = $target;
669 $noam =~ s/-am$//;
670 if (exists $dependencies{"$noam-am"})
671 {
672 $hint = "consider using $noam-local instead of $target";
673 }
674
675 msg_cond_rule ('override', $cond, $target,
676 "user target `$target' defined here"
677 . "$condmsg...", partial => 1);
678 msg ('override', $where,
679 "... overrides Automake target `$oldname' defined here",
680 partial => $hint);
681 msg_cond_rule ('override', $cond, $target, $hint)
682 if $hint;
683
684 # Don't overwrite the user definition of TARGET.
685 return ();
686 }
687 else # $oldowner == RULE_AUTOMAKE
688 {
689 # Automake should ignore redefinitions of its own
690 # rules if they came from the same file. This makes
691 # it easier to process a Makefile fragment several times.
692 # Hower it's an error if the target is defined in many
693 # files. E.g., the user might be using bin_PROGRAMS = ctags
694 # which clashes with our `ctags' rule.
695 # (It would be more accurate if we had a way to compare
696 # the *content* of both rules. Then $targets_source would
697 # be useless.)
698 my $oldsource = $tdef->source;
699 return () if $source eq $oldsource && $target eq $oldname;
700
701 msg ('syntax', $where, "redefinition of `$target'$condmsg...",
702 partial => 1);
703 msg_cond_rule ('syntax', $cond, $target,
704 "... `$oldname' previously defined here");
705 return ();
706 }
707 }
708 # Never reached.
709 prog_error ("Unreachable place reached.");
710 }
711
712 # Conditions for which the rule should be defined.
713 my @conds = $cond;
714
715 # Check ambiguous conditional definitions.
716 my $rule = _crule $target;
717 my ($message, $ambig_cond) = $rule->conditions->ambiguous_p ($target, $cond);
718 if ($message) # We have an ambiguity.
719 {
720 if ($owner == RULE_USER)
721 {
722 # For user rules, just diagnose the ambiguity.
723 msg 'syntax', $where, "$message ...", partial => 1;
724 msg_cond_rule ('syntax', $ambig_cond, $target,
725 "... `$target' previously defined here");
726 return ();
727 }
728 else
729 {
730 # FIXME: for Automake rules, we can't diagnose ambiguities yet.
731 # The point is that Automake doesn't propagate conditions
732 # everywhere. For instance &handle_PROGRAMS doesn't care if
733 # bin_PROGRAMS was defined conditionally or not.
734 # On the following input
735 # if COND1
736 # foo:
737 # ...
738 # else
739 # bin_PROGRAMS = foo
740 # endif
741 # &handle_PROGRAMS will attempt to define a `foo:' rule
742 # in condition TRUE (which conflicts with COND1). Fixing
743 # this in &handle_PROGRAMS and siblings seems hard: you'd
744 # have to explain &file_contents what to do with a
745 # condition. So for now we do our best *here*. If `foo:'
746 # was already defined in condition COND1 and we want to define
747 # it in condition TRUE, then define it only in condition !COND1.
748 # (See cond14.test and cond15.test for some test cases.)
749 @conds = $rule->not_always_defined_in_cond ($cond)->conds;
750
751 # No conditions left to define the rule.
752 # Warn, because our workaround is meaningless in this case.
753 if (scalar @conds == 0)
754 {
755 msg 'syntax', $where, "$message ...", partial => 1;
756 msg_cond_rule ('syntax', $ambig_cond, $target,
757 "... `$target' previously defined here");
758 return ();
759 }
760 }
761 }
762
763 # Finally define this rule.
764 for my $c (@conds)
765 {
766 my $def = new Automake::RuleDef ($target, '', $where->clone,
767 $owner, $source);
768 $rule->set ($c, $def);
769 }
770
771 # We honor inference rules with multiple targets because many
772 # make support this and people use it. However this is disallowed
773 # by POSIX. We'll print a warning later.
774 my $target_count = 0;
775 my $inference_rule_count = 0;
776
777 for my $t (split (' ', $target))
778 {
779 ++$target_count;
780 # Check if the rule is a suffix rule: either it's a rule for
781 # two known extensions...
782 if ($t =~ /^($KNOWN_EXTENSIONS_PATTERN)($KNOWN_EXTENSIONS_PATTERN)$/
783 # ...or it's a rule with unknown extensions (.i.e, the rule
784 # looks like `.foo.bar:' but `.foo' or `.bar' are not
785 # declared in SUFFIXES and are not known language
786 # extensions). Automake will complete SUFFIXES from
787 # @suffixes automatically (see handle_footer).
788
789
790 || ($t =~ /$_SUFFIX_RULE_PATTERN/o && accept_extensions($1)))
791 {
792 ++$inference_rule_count;
793 register_suffix_rule ($where, $1, $2);
794 }
795 }
796
797 # POSIX allows multiple targets before the colon, but disallows
798 # definitions of multiple inference rules. It's also
799 # disallowed to mix plain targets with inference rules.
800 msg ('portability', $where,
801 "Inference rules can have only one target before the colon (POSIX).")
802 if $inference_rule_count > 0 && $target_count > 1;
803
804 return @conds;
805}
806
807=item C<depend ($target, @deps)>
808
809Adds C<@deps> to the dependencies of target C<$target>. This should
810be used only with factored targets (those appearing in
811C<%dependees>).
812
813=cut
814
815sub depend ($@)
816{
817 my ($category, @dependees) = @_;
818 push (@{$dependencies{$category}}, @dependees);
819}
820
821=back
822
823=head1 SEE ALSO
824
825L<Automake::RuleDef>, L<Automake::Condition>,
826L<Automake::DisjConditions>, L<Automake::Location>.
827
828=cut
829
8301;
831
832### Setup "GNU" style for perl-mode and cperl-mode.
833## Local Variables:
834## perl-indent-level: 2
835## perl-continued-statement-offset: 2
836## perl-continued-brace-offset: 0
837## perl-brace-offset: 0
838## perl-brace-imaginary-offset: 0
839## perl-label-offset: -2
840## cperl-indent-level: 2
841## cperl-brace-offset: 0
842## cperl-continued-brace-offset: 0
843## cperl-label-offset: -2
844## cperl-extra-newline-before-brace: t
845## cperl-merge-trailing-else: nil
846## cperl-continued-statement-offset: 2
847## End:
Note: See TracBrowser for help on using the repository browser.