如何根据grep结果对makefile进行条件化? [英] How to conditionalize a makefile based upon grep results?
本文介绍了如何根据grep结果对makefile进行条件化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果要在检查工具的版本时找不到某个字符串,我正在寻找一种从makefile中退出的方法.
I'm looking for a way to bail out of a makefile if a certain string is not found when checking the version of a tool.
我要匹配的grep表达式是:
The grep expression I'm looking to match is:
dplus -VV | grep 'build date and time: Nov 1 2009 19:31:28'
如果已安装正确版本的dplus,则返回匹配行.
which returns a matching line if the proper version of dplus is installed.
如何根据此表达式将条件条件放入我的Makefile中?
How do I work a conditional into my makefile based upon this expression?
推荐答案
这是在GNU Make中工作的另一种方式:
Here's another way that works in GNU Make:
DPLUSVERSION = $(shell dplus -VV | grep 'build date and time: Nov 1 2009 19:31:28')
target_of_interest: do_things do_things_that_uses_dplus
do_things:
...
do_things_that_uses_dplus:
ifeq ($(DPLUSVERSION),)
$(error proper version of dplus not installed)
endif
...
该目标可以是真实的目标,也可以是真实目标所依赖的PHONY目标.
This target can be something real, or just a PHONY target on which the real ones depend.
这篇关于如何根据grep结果对makefile进行条件化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文