f78
Implicit Rule Search Algorithm
Suffix rules are not mentioned in this algorithm because suffix rules are
converted to equivalent pattern rules once the makefiles have been read in. For an
archive member target of the form, ‘
Once a rule that applies has been found, for each target pattern of the rule
other than the one that matched
When the commands of a pattern rule are executed for
Split t into a directory part, called d, and the rest, called n. For example, if t is ‘src/foo.o’, then d is ‘src/’ and n is ‘foo.o’.
Make a list of all the pattern rules one of whose targets matches t or n. If the target pattern contains a slash, it is matched against t; otherwise, against n.
If any rule in that list is not a match-anything rule, then remove all
non-terminal match-anything rules from the list.
Remove from the list all rules with no commands.
For each pattern rule in the list:
Find the stem s, which is the non-empty part of t or n matched by the ‘%’ in the target pattern.
Compute the dependency names by substituting s for ‘%’; if the target pattern does not contain a slash, append d to the front of each dependency name.
Test whether all the dependencies exist or ought to exist. (If a file name is
mentioned in the makefile as a target or as an explicit dependency, then we say
it ought to exist.)
If all dependencies exist or ought to exist, or there are no dependencies,
then this rule applies.
If no pattern rule has been found so far, try harder. For each pattern rule in
the list:
If the rule is terminal, ignore it and go on to the next rule.
Compute the dependency names as before.
Test whether all the dependencies exist or ought to exist.
For each dependency that does not exist, follow this algorithm recursively to
see if the dependency can be made by an implicit rule.
If all dependencies exist, ought to exist, or can be made by implicit rules,
then this rule applies.
If no implicit rule applies, the rule for .DEFAULT, if any, applies. In that case, give t the same commands that .DEFAULT has. Otherwise, there are no commands for t.