为什么不 Make 合并模式规则先决条件,我如何让它做到这一点?

Why won't Make merge pattern rule prerequisites, and how do I make it do this?

当我 运行 这个 Makefile:

foo.x:
.PHONY: a b
%.x: a
%.x: b
    $(error [$^])

我明白了:

Makefile:5: *** [b].  Stop.

为什么我看不到 [a b] 而不是 [b]?我如何让 Make 包括它们?

你不能这样。 make 手册说模式规则没有配方 cancel the pattern rule.

您可以在同一规则中编写具有所有先决条件的模式规则:

%.x: a b
        $(error [$^])

或者您可以在 non-pattern 目标上定义额外的先决条件:

foo.x: a
%.x: b
        $(error [$^])