Makefile 品牌:圆形b<;-b依赖关系已删除

Makefile 品牌:圆形b<;-b依赖关系已删除,makefile,gnu-make,Makefile,Gnu Make,对于下面的示例Makefile,我期望 预期产出: x/x_a x/x_b x/x_c x/x_d 代码: 但我得到的是 echo x/x_a x/x_a make: Circular b <- b dependency dropped. make: Circular c <- b dependency dropped. make: Circular c <- c dependency dropped. make: Circular d <- b dependency

对于下面的示例Makefile,我期望

预期产出:

x/x_a
x/x_b
x/x_c
x/x_d
代码:

但我得到的是

echo x/x_a
x/x_a
make: Circular b <- b dependency dropped.
make: Circular c <- b dependency dropped.
make: Circular c <- c dependency dropped.
make: Circular d <- b dependency dropped.
make: Circular d <- c dependency dropped.
make: Circular d <- d dependency dropped.
echo d
d
echo c
c
echo b
b
echo x/x\u a
x/x_a

make:Circular b这些线条并不像你想象的那样:

$(letters):x/x_$(letters)
x/x_$(letters):
Make变量是直接替换。您假设
x/x$(字母)
将对
$(字母)
中的每个单词应用前缀
x/x
,但事实并非如此。它是简单的文本替换,因此它的扩展是
x/x_a b c d
,因此上面的行是:

a b c d:x/x_a b c d
x/x_a b c d:
这就解释了你看到的行为。如果要将前缀应用于每个单词,则需要一个函数(因为您使用的是GNU make):

a b c d:x/x_a b c d
x/x_a b c d:
letters := a b c d
xletters := $(addprefix x/x_,$(letters))

$(letters): $(xletters)
$(xletters):