Subject: Re: Problem in new toolchain builds (need comments)
To: None <jchacon@genuity.net>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-toolchain
Date: 10/25/2001 01:20:52
> Reading the source nothing except $MAKE gets actually evaluated (i.e. parsed)
> when a new make occurs. If the $.MAKE* vars act differently it isn't documented
> in any readable form nor was it obvious from a source perusal.

main() passes its argc and argv to MainParseArgs() to do the dirty
work. MainParseArgs() is also called by Main_ParseArgLine() which gets
called:

main.c:722:	Main_ParseArgLine(getenv("MAKEFLAGS"));
main.c:724:	Main_ParseArgLine(getenv("MAKE"));
parse.c:1173:	Main_ParseArgLine (line);

that last one is in response to assignments to .MAKEFLAGS, or more
strictly to any variable with a specType of MFlags (.MAKEFLAGS and
.MFLAGS are currently the only ones).

Look at main.c:ExportMAKEFLAGS() to see how MAKEFLAGS actually gets
propagated to the environment and hence sub-makes.
Essentially, .MAKEFLAGS is used to hold options like -dx etc
and .MAKEOVERRIDES is used to hold the list of variable names that
should be exported.  Thus setting .MAKEOVERRIDES to "" disables the
POSIX export of command line variables, and appending to
.MAKEOVERRIDES has the expected effect - with one caveat.

make TOP=/tmp/src

and

TOP=/tmp/src
.MAKEOVERRIDES+= TOP

are subtly different.  In the first case the VAR_CMD context is used
for TOP, and so TOP=/tmp/src is actually exported directly to the
environment as well as via MAKEFLAGS.  In the 2nd case TOP is in the
VAR_GLOBAL context and is only exported via MAKEFLAGS.

--sjg