Makefile技巧:执行make target1时如何强制跳过target0依赖?
如何在执行
make target1时跳过依赖target0? 问题背景
用户提供的Makefile内容如下:
.PHONY: target0 target1 target0: <command> target1: target0 <command>
需要实现:执行make target1时,强制跳过依赖目标target0。
解决方法
方法1:用
-t标记更新目标时间戳
先执行make -t target1更新target1的时间戳,让make判定它已处于最新状态,之后再执行make target1就不会触发target0的执行:make -t target1 && make target1方法2:用
-o选项忽略指定依赖
直接在命令行添加-o target0参数,告诉maketarget0始终是最新的,无需处理:make -o target0 target1方法3:临时覆盖依赖定义
通过命令行参数直接清空target1的依赖,临时修改Makefile的生效逻辑:make target1 target0=
内容的提问来源于stack exchange,提问作者user1334858
相关产品推荐
相关产品推荐

