Makefile、条件和带变量的通配符
Makefile, conditional and wildcard with variables
我的 makefile 有问题。我想要一个 "master" 目标,它可以自动处理各种目录并将它们复制到特定位置。但是不知何故,带有通配符的 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.
为什么会这样?看不出我做错了什么。
感谢您的帮助!
在计算 ifeq
时变量 $@
为空。
可能改用 运行 时间检查:
% :
test -d $(TOP)/flow/$@/
我的 makefile 有问题。我想要一个 "master" 目标,它可以自动处理各种目录并将它们复制到特定位置。但是不知何故,带有通配符的 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.
为什么会这样?看不出我做错了什么。
感谢您的帮助!
在计算 ifeq
时变量 $@
为空。
可能改用 运行 时间检查:
% :
test -d $(TOP)/flow/$@/