> ... the section "Communicating Variables to a Sub-`make'" ...
but I wasn't communicating with a sub-make.
No recursive make was involved.

> ... says make exports a variable to a sub-command ...

the relevant section *appears* to be saying that make exports variables
to sub-`make' invocations, though I agree it *could* be construed as
saying that it is passed down to all sub-shells.

If the latter is really true, the section Commands -> Execution should
explain that each sub-shell is executed in an environment which is
augmented with every (sensibly-named) make variable set in the invoking
Makefile, exported as an environment variable; and much of the text
currently given in connection with passing environment down to
subordinate $(MAKE)s should be transferred to this discussion, in so far
as it applies to all commands, not just to subordinate invocations of
$(MAKE); in particular, this new section should mention (un)export.

Further, given that MAKEFLAGS would be holding a copy of the TIME=time I
put on my command line, a recursive $(MAKE) doesn't *need* TIME passed
down to it via the environment - it's already got it via MAKEFLAGS - and
if I wanted to frob the TIME environment variable seen by time, I could
have exploited /bin/sh's handy hook for frobbing the environment:

dummy:
        TIME=$(TIME) time echo 'WTF?'

or (being a little more careful about setting TIME to an empty value)

ifdef TIME
SetFmt=TIME=$(TIME)
endif
dummy:
        $(SetFmt) time echo 'WTF?'

I note, however, that

unexport TIME

does prevent TIME from being exported to time, lending weight to the
view that GNU make *does* export its variables into the environment by
default.  This being so, although I don't like it, as long as it's the
intent of the GNU make developers, I'll accept we don't have a code bug:
but, in such a case, the documentation is badly confusing and fails to
mention this where it most needs mentioned: Commands -> Execution.

        Eddy.

Reply via email to