2012-05-29 67 views
0

作爲標題,在makefile GNU中,obj _ $(變量)$(addprefix「obj_」,$(variable))。我確定有區別,因爲第一個可以與字符串進行比較,後一個不能被識別爲字符串。如果我錯了,請讓我知道。我想讓第二個字符串工作,所以我可以使用$($(addprefix「obj_」,$(variable)))作爲變量(現在不起作用)。

謝謝你們。

+1

我不知道你想做什麼,但儘量留出雙引號。 – Beta

回答

0

測試它自己:

print_values = \ 
    $(warning Let the value of '$$(variable)' to be [$(variable)]) \ 
    $(warning then the value of obj_$$(variable) is [obj_$(variable)]) \ 
    $(warning $$(addprefix "obj_", $$(variable)) is [$(addprefix "obj_", $(variable))]) \ 
    $(warning) 

variable := foo 
$(print_values) 

variable := foo bar baz 
$(print_values) 

variable := 
variable += foo 
$(print_values) 

您將得到以下輸出:

makefile:10: Let the value of '$(variable)' to be [foo] 
makefile:10: then the value of obj_$(variable) is [obj_foo] 
makefile:10: $(addprefix "obj_", $(variable)) is ["obj_"foo] 
makefile:10: 
makefile:13: Let the value of '$(variable)' to be [foo bar] 
makefile:13: then the value of obj_$(variable) is [obj_foo bar] 
makefile:13: $(addprefix "obj_", $(variable)) is ["obj_"foo "obj_"bar] 
makefile:13: 
makefile:17: Let the value of '$(variable)' to be [ foo] 
makefile:17: then the value of obj_$(variable) is [obj_ foo] 
makefile:17: $(addprefix "obj_", $(variable)) is ["obj_"foo] 
makefile:17: 

附:正如我告訴過你the answer到另一個你的問題,報價絕對不是你想要的

使用純obj_

$(addprefix obj_,$(variable)) 

相反的:

$(addprefix "obj_",$(variable)) 
相關問題