简体   繁体   English

GNU Make:使用`define var =`时无输出

[英]GNU Make: no output when using `define var =`

Snippet 1: 片段1:

define HELP_TEXT
This is the help text.
endef

.PHONY: help
help:
      @echo $(HELP_TEXT)

Test: 测试:

$ make help
This is the help text.
$

Snippet 2: 片段2:

define HELP_TEXT =
This is the help text.
endef

.PHONY: help
help:
      @echo $(HELP_TEXT)

Test: 测试:

$ make help

$

What is going on here? 这里发生了什么? According to the documentation there should be no difference in behaviour between both syntaxes. 根据文档,两种语法之间的行为应该没有差异。

NOTE: My GNU Make version is 3.81. 注意:我的GNU Make版本是3.81。

The NEWS file for version 3.82 (28 Jul 2010) mentions this: 版本3.82(2010年7月28日)的NEWS文件提到:

  • The define make directive now allows a variable assignment operator after the variable name, to allow for simple, conditional, or appending multi-line variable assignment. 现在, define make指令允许在变量名称之后使用变量赋值运算符,以允许简单,有条件或附加多行变量赋值。

So it's simply a feature not present in GNU make 3.81. 因此,它只是GNU make 3.81中不存在的功能。 In fact, in earlier make versions, the variable is called HELP_TEXT = , as can be seen if you try this: 实际上,在较早的make版本中,该变量称为HELP_TEXT = ,如果您尝试这样做,可以看到:

define HELP_TEXT =
This is the help text.
endef

.PHONY: help
help:
    @echo $(HELP_TEXT =)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM