Lines Matching refs:rule

1 /* Pattern and suffix rule internals for GNU Make.
25 #include "rule.h"
27 static void freerule PARAMS ((struct rule *rule, struct rule *lastrule));
32 struct rule *pattern_rules;
34 /* Pointer to last rule in the chain, so we can add onto the end. */
36 struct rule *last_pattern_rule;
42 /* Maximum number of target patterns of any pattern rule. */
46 /* Maximum number of dependencies of any pattern rule. */
50 /* Maximum length of the name of a dependencies of any pattern rule. */
66 flag for a rule when appropriate, possibly removing the rule
74 register struct rule *rule, *lastrule;
81 rule = pattern_rules;
83 while (rule != 0)
87 struct rule *next = rule->next;
93 while (rule->targets[ntargets] != 0)
99 for (dep = rule->deps; dep != 0; dep = dep->next)
134 /* In the deps of an implicit rule the `changed' flag
148 lastrule = rule;
149 rule = next;
157 /* Create a pattern rule from a suffix rule.
173 `.X.a' suffix rule; the target pattern is always `(%.o)'. */
240 /* Make a rule that is just the suffix, with no deps or commands.
241 This rule exists solely to disqualify match-anything rules. */
246 /* Record a pattern for this suffix's null-suffix rule. */
265 /* A suffix rule `.X.a:' generates the pattern rule `(%.o): %.X'.
266 It also generates a normal `%.a: %.X' rule below. */
271 /* The suffix rule `.X.Y:' is converted
272 to the pattern rule `%.Y: %.X'. */
279 /* Install the pattern rule RULE (whose fields have been filled in)
281 will take precedence). If this rule duplicates a previous one
284 When an old rule is replaced, the new one is put at the end of the
288 new_pattern_rule (struct rule *rule, int override)
290 register struct rule *r, *lastrule;
293 rule->in_use = 0;
294 rule->terminal = 0;
296 rule->next = 0;
298 /* Search for an identical rule. */
301 for (i = 0; rule->targets[i] != 0; ++i)
304 if (!streq (rule->targets[i], r->targets[j]))
310 for (d = rule->deps, d2 = r->deps;
319 /* Remove the old rule. */
323 pattern_rules = rule;
325 last_pattern_rule->next = rule;
326 last_pattern_rule = rule;
333 /* The old rule stays intact. Destroy the new one. */
334 freerule (rule, (struct rule *) 0);
345 /* There was no rule to replace. */
347 pattern_rules = rule;
349 last_pattern_rule->next = rule;
350 last_pattern_rule = rule;
357 /* Install an implicit pattern rule based on the three text strings
360 TERMINAL specifies what the `terminal' field of the rule should be. */
365 register struct rule *r;
368 r = (struct rule *) xmalloc (sizeof (struct rule));
409 pattern_rules chain. LASTRULE is the rule whose next pointer
413 freerule (struct rule *rule, struct rule *lastrule)
415 struct rule *next = rule->next;
419 for (i = 0; rule->targets[i] != 0; ++i)
420 free (rule->targets[i]);
422 dep = rule->deps;
435 free ((char *) rule->targets);
436 free ((char *) rule->suffixes);
437 free ((char *) rule->lens);
441 * If the commands came from a suffix rule, they could also be in
444 * If two suffixes that together make a two-suffix rule were each
448 pointer from the `struct file' for the suffix rule. */
450 free ((char *) rule);
452 if (pattern_rules == rule)
459 if (last_pattern_rule == rule)
464 /* Create a new pattern rule with the targets in the nil-terminated
467 The new rule has dependencies DEPS and commands from COMMANDS.
468 It is a terminal rule if TERMINAL is nonzero. This rule overrides
472 until the rule is destroyed. The storage for TARGET_PERCENTS is not used;
481 struct rule *r = (struct rule *) xmalloc (sizeof (struct rule));
523 print_rule (struct rule *r)
551 register struct rule *r;