Inference Rules

Defining Rules   Rule Matching   Inference Rules and Target Groups

Defining Inference Rules [Top]

The general form for an inference rule is:

Tp%Ts [attribute ...] : Sp%Ss 
	[shell line]

Where Tp is the target prefix, Ts is the target suffix, Sp is the source prefix and Ss is the source suffix. All prefixes and suffixes are optional.

The attribute are target attributes for this rule. These attributes will be given to the target that matches this rule.

The shell lines are the commands that update the target.


The Rule-Matching Process [Top]

When Make tries to match a target to an inference rule, each Tp%Ts pattern is matched against the target name, with "%" used to match zero or more characters. Every possible rule is tried and scored, with the best-scoring rule the one that uses "%" to match the smallest number of characters. Make then goes through this ranked list of rules, forming Sp%Ss and seeing if this name corresponds to a source file or source target name. If it does, the rule is matched.


Inference Rules and Target Groups [Top]

Multiple targets can be updated with a single rule of the form:

Tp1%Ts1 + Tp2%Ts2 [ + Tp3%Ts3]... [attribute ...] : Sp%Ss 
	[shell line]

If a target matches any of TpN%TsN patterns and Sp%Ss is found, Make knows that this rule builds all targets on the left side of the colon.