On Fri, 17 May 2024, Edgar Fuß wrote:

What happens here is that the child "make -V" reads the complete Makefile
again, and after that, it prints the variable value.
Oh, then it's propably useless in the pkgsrc context the question came up.


There's a trick to do this, but for it to work, compat mode must be
turned off. I'm using `-j' for this.

$ cat Makefile
X != cat /usr/src/sys/kern/*.c
.PHONY: main
main:
        @wc -c <<\EoF${.newline}$X${.newline}EoF${.newline}
$ make -j1
 4936770
$

The description for `-j' says:

        When compatibility mode is off, all commands associated with a
        target are executed in a single shell invocation as opposed to
        the traditional one shell invocation per line.

So, in non-compat mode, make runs the shell with `-s' instead of `-c' and
therefore, here-docs will work.

-RVP

Reply via email to