折腾:
【已解决】Makefile中如何判断一个字符串变量存在另外一个字符串或列表中
期间,对于findstring
“$(findstring find,in)
Searches in for an occurrence of find. If it occurs, the value is find; otherwise, the value is empty. You can use this function in a conditional to test for the presence of a specific substring in a given string. Thus, the two examples,
$(findstring a,a b c)
$(findstring a,b c)
produce the values ‘a’ and ‘’ (the empty string), respectively. See Testing Flags, for a practical application of findstring.”
中返回的empty的话,接着去判断是否为空
结果用:
$(info BOOK_NAME=$(BOOK_NAME)) FOUND_BOOK := $(findstring $(BOOK_NAME), $(IGNORE_FILE_CONTENT)) $(info FOUND_BOOK=$(FOUND_BOOK)) ifeq ($(FOUND_BOOK), "") $(info not found $(BOOK_NAME) in $(IGNORE_FILE_CONTENT)) # else # $(info is found $(BOOK_NAME) in $(IGNORE_FILE_CONTENT)) endif
结果输出不对:没有输出。
后来自己研究了,发现是:
【总结】
要么不加””
ifeq ($(FOUND_BOOK), )
要么都加””
ifeq ("$(FOUND_BOOK)", "")
不能写成:
ifeq ($(FOUND_BOOK), "")
否则本身是空的empty的,逻辑是是null,但是和一个空字符串””去比较,就不对了。
转载请注明:在路上 » 【已解决】Makefile中判断变量是否为空无效