为什么 makefile 有时会有“true”作为构建脚本的一部分?
例如:
# Some stuff
all: some dependencies
@$(CC) -o foo.o foo.c
@true foo.o
@some other operation
“true foo.o”行有什么用途?
For example:
# Some stuff
all: some dependencies
@$(CC) -o foo.o foo.c
@true foo.o
@some other operation
What purpose does the 'true foo.o' line serve?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,这是 Makefile 生成器(例如
automake
)的输出。true
将在需要它的平台上替换为实际命令。最常见的情况是平台不自动维护静态归档索引;代码看起来像这样,但在某些平台上(没有 System V 或 GNU
ar
的平台),它会是。它不被简单删除的原因是它在
m4
中更容易code> 和其他宏处理器替换一行上的文本而不是有条件地删除该行。 (这是可以做到的,但是高级的m4
黑客已知会导致疯狂。:)Typically this is output from a Makefile generator such as
automake
. Thetrue
will be replaced with an actual command on platforms which require it. The most common case is platforms which don't maintain static archive indexes automatically; the code will look something likebut on some platforms (those without either System V or GNU
ar
) it will instead beThe reason it's not simply removed is that it's a lot easier in
m4
and other macro processors to substitute text on a line than it is to conditionally delete the line. (It can be done, but advancedm4
hackery has been known to cause insanity. :)