我正在制作一个 Makefile,将输出文件 (foo.o
) 移动到不同的目录 (baz
)。
输出文件根据需要移动到目录。但是,由于如果我再次输入 make
,make 不会重新编译输出文件,因此 mv
在尝试将不存在的空文件移动到目录 时会收到错误>巴兹
。
这就是我在所有编译后在规则 make all
中定义的内容:
-test -e "foo.o" || mv -f foo.o ../baz
不幸的是,我仍然收到错误。
最佳答案
Errors in Recipes (来自TFM)
To ignore errors in a recipe line, write a
-
at the beginning of the line's text (after the initial tab).
所以目标会是这样的:
moveit:
-mv foo.o ../baz
关于makefile - 如何忽略 mv 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3143635/