在规则的同一行上定义的变量的含义是针对先决条件,例如"a:x = 0".在GNU Make中? [英] What is the meaning of a variable defined on the same line of a rule targets prerequisites such as "a: x = 0" in GNU Make?

查看:61
本文介绍了在规则的同一行上定义的变量的含义是针对先决条件,例如"a:x = 0".在GNU Make中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Makefile中看到了类似以下代码的代码:

I have seen code like the following following code in a Makefile:

a: x = 0

这行是什么意思?这是规则还是其他?

What does this line mean? Is it a rule, or something else?

推荐答案

即称为目标特定变量,请参见:

That is called a target specific variable, see: https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html

它给给定目标内的变量一个不同的值.

It gives a different value to a variable inside a given target.

样品用量:

x := 0

a: x := 1
a:
    @echo $x

b:
    @echo $x

现在:

$ make a
1
$ make b
0

这篇关于在规则的同一行上定义的变量的含义是针对先决条件,例如"a:x = 0".在GNU Make中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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