Search code examples
makefileprerequisites

Makefile rule "foo : bar : baz"


What does it mean to have a rule specified as follows?

foo: bar : baz

I understand that foo is a target, bar and baz are prerequisites but why there is another colon between bar and baz - what's the meaning of that colon?


Solution

  • The feature you are thinking of is a static pattern rule, and the syntax you give: foo : bar : baz is illegal; the bar part must be a pattern (that is, it must contain a % character).

    Tripleee gives a reasonable explanation, except the statement when we build foo, bar depends on baz is somewhat confusing. What a static pattern rule means is that for each word in targets, create a new explicit rule where the target is the result of applying the pattern pattern to that word with the prerequisites prerequisites.