make: Multiple Targets

1 
1 4.10 Multiple Targets in a Rule
1 ===============================
1 
1 A rule with multiple targets is equivalent to writing many rules, each
1 with one target, and all identical aside from that.  The same recipe
1 applies to all the targets, but its effect may vary because you can
1 substitute the actual target name into the recipe using '$@'.  The rule
1 contributes the same prerequisites to all the targets also.
1 
1    This is useful in two cases.
1 
1    * You want just prerequisites, no recipe.  For example:
1 
1           kbd.o command.o files.o: command.h
1 
1      gives an additional prerequisite to each of the three object files
1      mentioned.
1 
1    * Similar recipes work for all the targets.  The recipes do not need
1      to be absolutely identical, since the automatic variable '$@' can
1      be used to substitute the particular target to be remade into the
1      commands (⇒Automatic Variables).  For example:
1 
1           bigoutput littleoutput : text.g
1                   generate text.g -$(subst output,,$@) > $@
1 
1      is equivalent to
1 
1           bigoutput : text.g
1                   generate text.g -big > bigoutput
1           littleoutput : text.g
1                   generate text.g -little > littleoutput
1 
1      Here we assume the hypothetical program 'generate' makes two types
11      of output, one if given '-big' and one if given '-little'.  ⇒
      Functions for String Substitution and Analysis Text Functions, for
1      an explanation of the 'subst' function.
1 
1    Suppose you would like to vary the prerequisites according to the
1 target, much as the variable '$@' allows you to vary the recipe.  You
1 cannot do this with multiple targets in an ordinary rule, but you can do
11 it with a "static pattern rule".  ⇒Static Pattern Rules Static
 Pattern.
1