我正在寻找一种方法来说服 gnumake 将规则的“所有”目标构建为一个单元,并在有任何原因导致任何目标丢失或超出时要求重新构建它们-日期。
考虑这个简单的 Makefile:
b.foo :
touch b.foo
b.bar1 b.bar2 : b.foo
touch b.bar1
touch b.bar2
b.zoo1 : b.bar1
touch b.zoo1
b.zoo2 : b.bar2
touch b.zoo2
# Building b.zoo1 works as expected
> make4 b.zoo1
touch b.foo
touch b.bar1
touch b.bar2
touch b.zoo1
> make b.zoo1
make: 'b.zoo1' is up to date.
# Building b.zoo2 also works as expected
> make b.zoo2
touch b.zoo2
> make b.zoo2
make: 'b.zoo2' is up to date.
# Now I remove one of the peers built with the 2nd rule
> rm b.bar2
# I see that b.zoo1 stays up-to-date because its dependency still exists.
# However, this is NOT the behavior that I'm looking for. With b.bar2
# now missing, I want b.zoo1 AND b.zoo2 to be out-of-date.
> make b.zoo1
make: 'b.zoo1' is up to date.
# But it's not. Worse yet, building b.zoo2 does force b.bar1 and b.bar2 to be rebuilt
> make b.zoo2
touch b.bar1
touch b.bar2
touch b.zoo2
# which now makes b.zoo1 out-of-date
> make b.zoo1
touch b.zoo1
那么,有没有办法编写一个规则来构建多个目标以按照我的意愿行事?或者有没有办法使用 gnumake 标准库来完成这个?