GNU在多行变量声明中有所作为 [英] GNU make differences in multiline variable declarations

查看:51
本文介绍了GNU在多行变量声明中有所作为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了这个问题,很惊讶它没有用:

I read this question, and I was surprised it wasn't working:

为什么GNU Make罐装食谱不起作用?

因此,我自己尝试了一下,并得到了相同的结果.这是一个示例makefile:

So I tried it myself and got the same results. Here's an example makefile:

define foo
bar
baz
endef

define bar = 
foo
baz
endef

$(info foo: $(foo))
$(info bar: $(bar))

all:

这是运行它的输出:

$ make
foo: bar
baz
bar: 
make: Nothing to be done for `all'.

这是怎么回事? GNU make手册似乎表明这两个变量声明应为一样-我在这里想念什么?

What's happening here? The GNU make manual seems to indicate that these two variable declarations should be the same - what am I missing here?

我指的是手册中的一些语录:

Some quotations from the manual that I was referring to:

3.7如何make读取Makefile

3.7 How make Reads a Makefile

define immediate
  deferred
endef

define immediate =
  deferred
endef

5.8定义罐头食谱

5.8 Defining Canned Recipes

以下是定义罐头食谱的示例:

Here is an example of defining a canned recipe:

 define run-yacc =
 yacc $(firstword $^)
 mv y.tab.c $@
 endef

6.8定义多行变量

6.8 Defining Multi-Line Variables

...如果愿意,可以省略变量赋值运算符.如果省略,make假定它为"="并创建一个递归扩展变量...

... You may omit the variable assignment operator if you prefer. If omitted, make assumes it to be ‘=’ and creates a recursively-expanded variable...

如您所见,罐头食谱部分明确地使用=大小写.我正在使用GNU Make 3.81.

As you can see, the canned recipes section explicitly uses the = case. I'm using GNU Make 3.81.

推荐答案

来自3.82中的CHANGELOG:

From the CHANGELOG in 3.82:

* read.c (do_define): Modify to allow assignment tokens (=, :=, etc.)
after a define, to create variables with those flavors.

define 语句中似乎不支持使用'='

It seems like using '=' isn't supported prior to that in define statements

这篇关于GNU在多行变量声明中有所作为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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