为什么makefile有时有时具有"true< filename>"作为构建脚本的一部分? [英] Why do makefiles sometimes have 'true <filename>' as part of the build script?
问题描述
例如:
# Some stuff
all: some dependencies
@$(CC) -o foo.o foo.c
@true foo.o
@some other operation
'true foo.o'行的作用是什么?
What purpose does the 'true foo.o' line serve?
推荐答案
通常,这是从Makefile生成器(例如automake
)输出的. true
将在需要它的平台上被实际命令替换.最常见的情况是平台不会自动维护静态存档索引;代码看起来像
Typically this is output from a Makefile generator such as automake
. The true
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 like
foo.a: foo.o bar.o baz.o ...
ar rv foo.a foo.o bar.o baz.o ...
true foo.a
,但是在某些平台(那些没有System V或GNU ar
的平台)上,它将是
but on some platforms (those without either System V or GNU ar
) it will instead be
foo.a: foo.o bar.o baz.o ...
ar rv foo.a foo.o bar.o baz.o ...
ranlib foo.a
之所以不能简单地删除它,是因为在m4
和其他宏处理器中替换行上的文本比有条件地删除该行要容易得多. (可以做到的,但是已知先进的m4
黑客会引起精神错乱.:)
The 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 advanced m4
hackery has been known to cause insanity. :)
这篇关于为什么makefile有时有时具有"true< filename>"作为构建脚本的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!