我正在尝试编译所有源文件,但排除的源文件除外。
考虑到我既不能控制目标,也不能控制先决条件,所以我只能控制配方。
由于某种原因,if条件无法正常运行。
即使输出为true,也始终满足第一个条件,当源文件位于custom_c_excludes变量中的排除文件中时,会发生此情况,因此正确的行为应该是ifep条件失败,并且应该执行else之前的块。 >
(条件输出:true =>不编译)
(条件输出:false =>编译)
$(OBJDIR)/%.$(OBJEXT): %.c ifeq (false,$(if $(findstring $<,$(custom_c_excludes)),true,false)) @echo 'This file is included and should be compiled.' @echo 'Condition output : $(if $(findstring $<,$(custom_c_excludes)),true,false)' else @echo 'This file is not included and should not be compiled.' @echo 'Condition output : $(if $(findstring $<,$(custom_c_excludes)),true,false)' endif
预期输出是:
此文件已包含,应进行编译。
条件输出:假
或
此文件不包括在内,不应编译。
条件输出:是
实际输出是:
此文件已包含,应进行编译。
条件输出:是
我正在尝试编译所有源文件,但排除的源文件除外。考虑到我既不能控制目标,也不能控制先决条件,所以我只能控制配方。 ...
ifeq
是在解析Makefile时而不是在执行配方时进行评估的,因此您的配方将始终生成相同的内容。您可以使用make -p
: