为什么makefile有时有时具有"true< filename>"作为构建脚本的一部分? [英] Why do makefiles sometimes have 'true <filename>' as part of the build script?

查看:119
本文介绍了为什么makefile有时有时具有"true< filename>"作为构建脚本的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

# 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆