Lines Matching defs:rule
1 /* Implicit rule searching for GNU Make.
21 #include "rule.h"
35 Returns 1 if a suitable implicit rule was found,
37 or returns 0 if no implicit rule was found. */
42 DBF (DB_IMPLICIT, _("Looking for an implicit rule for `%s'.\n"));
58 _("Looking for archive-member implicit rule for `%s'.\n"));
187 /* Search the pattern rules for a rule with an existing dependency to make
188 FILE. If a rule is found, the appropriate commands and deps are put in FILE
191 If ARCHIVE is nonzero, FILE->name is of the form "LIB(MEMBER)". A rule for
205 /* Filename we are searching for a rule for. */
220 found for a rule along with some other useful information
230 /* The start and length of the stem of FILENAME for the current rule. */
236 struct rule **tryrules
237 = (struct rule **) xmalloc (num_pattern_rules * max_pattern_targets
238 * sizeof (struct rule *));
243 /* The numbers of the rule targets of each rule
253 /* The index in TRYRULES of the rule we found. */
259 /* Nonzero if we have matched a pattern-rule target
264 struct rule *rule;
310 for (rule = pattern_rules; rule != 0; rule = rule->next)
312 /* If the pattern rule has deps but no commands, ignore it.
314 if (rule->deps != 0 && rule->cmds == 0)
317 /* If this rule is in use by a parent pattern_search,
319 if (rule->in_use)
321 DBS (DB_IMPLICIT, (_("Avoiding implicit rule recursion.\n")));
325 for (i = 0; rule->targets[i] != 0; ++i)
327 char *target = rule->targets[i];
328 char *suffix = rule->suffixes[i];
334 if (recursions > 0 && target[1] == '\0' && !rule->terminal)
337 if (rule->lens[i] > namelen)
344 stemlen = namelen - rule->lens[i] + 1;
377 /* Check that the rule pattern matches the text before the stem. */
388 /* Check that the rule pattern matches the text after the stem.
397 /* Record if we match a rule that not all filenames will match. */
401 /* A rule with no dependencies and no commands exists solely to set
403 if (rule->deps == 0 && rule->cmds == 0)
406 /* Record this rule in TRYRULES and the index of the matching
407 target in MATCHES. If several targets of the same rule match,
408 that rule will be in TRYRULES more than once. */
409 tryrules[nrules] = rule;
416 /* If we have found a matching rule that won't match all filenames,
431 for the rule. */
434 /* Try each rule once without intermediate files, then once with them. */
437 /* Try each pattern rule till we find one that applies.
448 rule = tryrules[i];
452 /* RULE is nil when we discover that a rule,
454 if (rule == 0)
459 if (intermed_ok && rule->terminal)
462 /* Mark this rule as in use so a recursive
464 rule->in_use = 1;
469 + (rule->suffixes[matches[i]] - rule->targets[matches[i]]) - 1;
470 stemlen = namelen - rule->lens[matches[i]] + 1;
478 DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"),
490 for (dep = rule->deps; dep != 0; dep = dep->next)
665 then the rule fails and don't bother trying it on the
670 : _("Rejecting impossible rule prerequisite `%s'.\n"),
681 : _("Trying rule prerequisite `%s'.\n"), name));
685 anyway, no matter which implicit rule we choose. */
732 (_("Looking for a rule with intermediate file `%s'.\n"),
759 /* A dependency of this rule does not exist. Therefore,
760 this rule fails. */
765 /* This rule is no longer `in use' for recursive searches. */
766 rule->in_use = 0;
770 /* This pattern rule does not apply. If some of its
777 /* This pattern rule does apply. Stop looking for one. */
781 /* If we found an applicable rule without
786 rule = 0;
789 /* RULE is nil if the loop went all the way
791 if (rule == 0)
801 file->name = rule->targets[matches[foundrule]];
803 /* FOUND_FILES lists the dependencies for the rule we found.
810 this implicit rule. */
898 and the rule that found it was a terminal one, then we want
899 to mark the found file so that it will not have implicit rule
934 file->cmds = rule->cmds;
939 struct file *f = lookup_file (rule->targets[matches[foundrule]]);
944 /* If this rule builds other targets, too, put the others into FILE's
947 if (rule->targets[1] != 0)
948 for (i = 0; rule->targets[i] != 0; ++i)
955 new->name = p = (char *) xmalloc (rule->lens[i] + fullstemlen + 1);
956 bcopy (rule->targets[i], p,
957 rule->suffixes[i] - rule->targets[i] - 1);
958 p += rule->suffixes[i] - rule->targets[i] - 1;
961 bcopy (rule->suffixes[i], p,
962 rule->lens[i] - (rule->suffixes[i] - rule->targets[i]) + 1);
967 f = lookup_file (rule->targets[i]);
972 as intermediate by the pattern rule search algorithm and
983 return rule != 0;