タイトルのとおり、makefile GNU では、obj_$(variable)と$(addprefix "obj_", $(variable)) の違いは何ですか。前者は文字列と比較でき、後者は文字列として認識できないため、違いがあると確信しています。私が間違っている場合はお知らせください。2 番目のものを文字列として機能させたいので、 $($(addprefix "obj_", $(variable))) を変数として使用できます (現在は機能しません)。
君たちありがとう。
自分でテストしてください:
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:
PS別の質問への回答で言ったように、引用符は間違いなくあなたが望むものではありません.
プレーンを使用obj_
:
$(addprefix obj_,$(variable))
それ以外の:
$(addprefix "obj_",$(variable))