ABu
ABu

Reputation: 12269

GNU Make: no output when using `define var =`

Snippet 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:

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.

Upvotes: 0

Views: 33

Answers (1)

Florian Weimer
Florian Weimer

Reputation: 33719

The NEWS file for version 3.82 (28 Jul 2010) mentions this:

  • 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.

So it's simply a feature not present in GNU make 3.81. In fact, in earlier make versions, the variable is called HELP_TEXT =, as can be seen if you try this:

define HELP_TEXT =
This is the help text.
endef

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

Upvotes: 1

Related Questions