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?
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.
The general syntax is
targets: pattern: prerequisites
So this -- grossly oversimplified -- example of yours says, basically, when we build foo, bar depends on baz. However, the second argument needs to be a pattern rule, so your example is in fact a syntax error.
A more useful and correct example would be along the lines of
$(OBJS): %.o: ick.h
which says that if you are building one of OBJS, their .o file depends on ick.h.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With