2016-11-25 46 views
0

所以基本上我想对用户发出警告,当在“代码”目录中有别的东西比C文件,我找不到任何相关的东西。任何线索? 这是我当前的代码(不工作):如何执行一个makefile命令的时候,有一个除了c。文件以外的其他东西吗?

ifneq ("$(shell ls Code -I "*.c")","") 
    ls Code -I "*.c" 
    @echo "test" 
else 
    @echo "test2" 
endif 
+0

您需要更具体:什么是“不工作”你目前的设置? – aardvarkk

+0

它输出“test”是否在目录 – Keitio

+0

中有c文件以外的东西它看起来像你尝试列出找不到的匹配文件。该列表中有哪些文件名? – aardvarkk

回答

1

为什么不干脆:

extras := $(filter-out %.c,$(wildcard Code/*)) 
ifneq (,$(extras)) 
$(warn Extra files: $(extras)) 
endif 
+0

哦,工作非常感谢,我不知道过滤功能存在 – Keitio

+0

请参阅:https://www.gnu.org/software/make/manual/html_node/Functions.html,也许特别是本节: https://www.gnu.org/software/make/manual/html_node/Text-Functions.html – MadScientist

相关问题