带变量的Makefile、条件和通配符
我的makefile有问题。我希望有一个“主”目标,它可以自动处理各种dir并将它们复制到特定位置。但不知何故,带有通配符的ifneq条件不能正常工作,无论条件是否满足,都会给我相同的结果 我正在尝试:带变量的Makefile、条件和通配符,makefile,conditional-statements,wildcard,Makefile,Conditional Statements,Wildcard,我的makefile有问题。我希望有一个“主”目标,它可以自动处理各种dir并将它们复制到特定位置。但不知何故,带有通配符的ifneq条件不能正常工作,无论条件是否满足,都会给我相同的结果 我正在尝试: # Basically the same thing for all targets % : ifeq ($(wildcard $(TOP)/flow/$@),) $(error Directory $(TOP)/flow/$@ not found. Aborting. Debug: $
# Basically the same thing for all targets
% :
ifeq ($(wildcard $(TOP)/flow/$@),)
$(error Directory $(TOP)/flow/$@ not found. Aborting. Debug: $(wildcard $(TOP)/flow/$@))
else
$(error Directory $(TOP)/flow/$@ found!. Debug: $(wildcard $(TOP)/flow/$@))
endif
例如,在$(TOP)/flow中存在一个目录core,但不存在pwr。使目标继续,就好像它们都存在一样
➜ work ✗ make core
Makefile:20: *** Directory TOPFOLDER/flow/core found!. Debug: TOPFOLDER/flow/core. Stop.
➜ work ✗ make pwr
Makefile:20: *** Directory TOPFOLDER/flow/pwr found!. Debug: . Stop.
为什么会这样?我看不出我做错了什么
谢谢你的帮助 计算
ifeq
时,变量$@
为空
可能改用运行时检查:
% :
test -d $(TOP)/flow/$@/
那相当密集。我想我知道错误的来源是什么,但是你能更清楚地解释一下你想要这个makefile做什么吗?我用一个更简单的用例重写了这个问题,但是失败了。谢谢你的反馈!