【发布时间】:2020-01-28 17:02:53
【问题描述】:
我的 makefile 有问题。我想要一个“主”目标,它会自动处理各种目录并将它们复制到特定位置。但不知何故,带有通配符的 ifneq 条件无法正常工作,无论条件是否满足,都会给我相同的结果。
我正在尝试:
# 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。 Make 目标继续进行,就好像它们都存在一样。
➜ 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.
为什么会这样?看不到我在这里做错了什么。
感谢您的帮助!
【问题讨论】:
-
那是相当密集的。我想我知道错误的根源是什么,但是您能否更清楚地解释一下您希望此 makefile 做什么?
-
我用一个更简单的用例重写了这个问题,但仍然失败了。感谢您的反馈!
标签: makefile conditional-statements wildcard