makefile - 如何忽略 mv 错误?

标签 makefile

我正在制作一个 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/

相关文章:

Makefile:使用多个Makefile

python - 使用 $(shell ...) 从 makefile 执行 python

c++ - 用于 makefie 构建的 C++ 程序的图形化免费调试器 (Windows XP)

c++ - 我是否正确使用了 C++ 的 Makefile?

java - 在 autoconf 或 makefile 中禁用版本后缀/扩展

c - 使用 vpath 的简单 make 文件不起作用

c++ - 链接到G++中的复数库

C 生成文件,在 CCS 中, "The system cannot find the file specified"

c++ - 制作 Makefile

c++ - 如何解决具有多个派生类的抽象基类的继承