Consider the following Makefile:
X = macro-X-value
foo:
echo $$X $(X)
The intention here is to use X both as a name of an environment variable and
of a macro. When using bmake, it works as intended:
$ env X=env-X-value /usr/bin/bmake
echo $X macro-X-value
env-X-value macro-X-value
$ env -i /usr/bin/bmake
echo $X macro-X-value
macro-X-value
But when using GNU Make (v. 4.2.1), the behaviour gets weird:
$ env X=env-X-value /usr/bin/gmake
echo $X macro-X-value
macro-X-value macro-X-value
$ env -i /usr/bin/gmake
echo $X macro-X-value
macro-X-value
So, it seems like gmake exports the value of the macro X as an
environment variable X, but only when the outer environment already
exports X.
I can't find anything about this in the POSIX Make description. In fact, there is this bit there:
Macros are not exported to the environment of commands to be run. […]
Is this behaviour documented? Is this a bug? Can it be disabled?