在我的 Makefile 中,我有一些检查网络连接的代码。该代码需要相当多的时间来运行,我只想在另一个目标无法构建时运行它。
当前的生成文件
all: files network
# compile files
files:
# get files from network resources
network:
# check for network connectivity
# echo and return an error if it's not available
执行顺序:
if not network:
# exit with error
if not files:
# exit with error
if not all:
# exit with error
所需的生成文件
在上面的例子中,我想要network
目标被“制定”,只有当files
目标未能“实现”。
执行顺序:
if not files:
if not network:
# exit with error
if not all:
# exit with error
恐怕递归 make 是你的朋友。
.PHONY: all
all:
${MAKE} files || ${MAKE} network
If make files
成功,您的工作已完成,退出代码为成功。失败时,退出代码是make network
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)