help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Which make-related variables are passed to subprocesses


From: Sébastien Hinderer
Subject: Re: Which make-related variables are passed to subprocesses
Date: Fri, 20 Apr 2018 23:33:20 +0200

Dear Paul,

Many thakns for your response!

Paul Smith (2018/04/20 13:46 -0400):
> On Fri, 2018-04-20 at 11:41 +0200, Sébastien Hinderer wrote:
> > Am I correct that variables like MAKEFLAGS and MAKEOVERRIDE are passed
> > to any subshell called by make, whereas MAKE is not?
> > 
> > May I ask why this is so?
> 
> The MAKE variable is set to the currently-executing make program.  It
> doesn't make sense to inherit that value from the parent process.

Well, perhaps the way I designed things is wrong, but it turns out that
in my case it would make a lot of sense. I am developiing a test driver
which needs to invoke make to build some tests. Ideally it should invoke
the same make that was used to invoke it, that's why having the MAKE
variable would be useful. Well I passed it explicitly to things do work
now.

Beyond that: among the platforms we are testing there are Open-BSD and
FreeBSD. They come with their own make, but we install GNUMake in
addition and use it. Before I passed theMAKE variable explicitly to my
test driver, it had no way to know which version of make it was supposed
to invoke to build the tests. So it invoked the make provided by the
system, that is, not GNU make. This would have been perfectly okay if,
simultaneously, the environment didn't define MAKEFLAGS which contained
options not understood by BSD's make.

That's why I came to think that there could be some benefit in not
passing make-related variables to sub shells. I mean, either to pass all
of them, including MAKE itself, or to pass non of them, but not just
all-except-MAKE.

> You can figure out which variables are passed down to the sub-makes
> using something like:
> 
>    echo 'all:;-env | sort' | make -f- FOO=bar

Quite impressive! Thanks!

> You can compare that with the variables exported from the current
> shell, or grep for 'MAKE' to see variables related to make (I think all
> the default ones contain that string).


Okay thanks a lot, Paul!

Sébastien.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]