July 23th Thursday (七月 二十三日 木曜日)

Multiple Targets in a Rule

  A rule with multiple targets is equivalent to writing many rules, each with one target, and all identical aside from that.  The same
commands apply to all the targets, but their effects may vary because you can substitute the actual target name into the command using
`$@'. The rule contributes the same dependencies to all the targets also.

  This is useful in two cases.

  You want just dependencies, no commands. For example:

kbd.o command.o files.o: command.h

gives an additional dependency to each of the three object files mentioned.

  Similar commands work for all the targets. The commands do not need to be absolutely identical, since the automatic variable `$@'
can be used to substitute the particular target to be remade into the commands.  For example:

bigoutput littleoutput : text.g
        generate text.g -$(subst output,,$@) > $@

is equivalent to

bigoutput : text.g
        generate text.g -big > bigoutput

littleoutput : text.g
        generate text.g -little > littleoutput

  Here we assume the hypothetical program generate makes two types of output, one if given `-big' and one if given `-little'.
Suppose you would like to vary the dependencies according to the target, much as the variable `$@' allows you to vary the commands.
You cannot do this with multiple targets in an ordinary rule, but you can do it with a static pattern rule.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值