我最近遇到了这个结构:
ifneq ("$(findstring needle, $(HAYSTACK))", "")
do_some_stuff
endif
引号真的有用吗,还是我可以放心地省略它们?
编辑:
刚刚发现:ifeq ("a b ", "a b ")
行为不同于ifeq (a b , a b )
第一个匹配,而不是第二个。所以引号确实很重要。现在的问题是为什么。
I'll go out on a limb and say:
They are equivalent to nothing and you can safely omit them.
(Now watch the creator of GNUMake show up and say that if you try that when HAYSTACK
contains a double-escaped unicode Sanscrit triple-quote your processor will catch fire.)
EDIT:
Dammit, dammit, dammit! They do matter. Just try playing around with HAYSTACK := $(shell echo bang)
. You'd better have a fire extinguisher handy.