Re: Ignoring the whitespaces

Paul Smith <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Organization GNU's Not UNIX!
Message-ID <[email protected]>
On Wed, 2023-06-07 at 12:23 +0200, Bartłomiej Wójcik wrote:
> The GNU make documentation states:
> 
> *define myrule
> target:
>         echo built
> endef
> 
> $(myrule)
> *

To be clear, the documentation says that the above will NOT work (as
you intend).

> *The above makefile results in the definition of a target ‘target’
> with prerequisites ‘echo’ and ‘built’, as if the makefile contained
> target: echo built, rather than a rule with a recipe. Newlines still
> present in a line after expansion is complete are ignored as normal
> whitespace.*
> 
> Why in that macro the whitespaces between *target:* and *echo built*
> are ignored?

They are not ignored in the macro.  The macro contains the text:

  target:
          echo built

including the newlines and TAB etc.

They are ignored when the macro is expanded, then parsed as a rule.

That's because make's parser is fundamentally line-oriented, and
breaking up of lines happens BEFORE expansion.  That means that AFTER
expansion, all whitespace including newlines is just treated like
normal whitespace: newlines no longer have their special significance
that they do during parsing and that entire output is considered just a
single logical line.

You can imagine it like make is adding backslashes to the end of every
line in the expanded output; that's not what actually happens but you
can think of it like that.  So after expansion of the above, make sees:

  target: \
          echo built

>  What is this property and what exactly does it refer to?
> Where is it stated in the documentation?

I mean, it's stated right there in the text you quoted so I'm not sure
what you  mean.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.