MAKEFLAGS not updated when it already exists?

2003-01-14 Thread Alexandre Duret-Lutz
Hi Paul,

POSIX documents MAKEFLAGS thusly:

 Before the makefile(s) are read, all of the make utility command line
 options (except -f and -p) and make utility command line macro
 definitions (except any for the MAKEFLAGS macro), not already included
 in the MAKEFLAGS macro, shall be added to the MAKEFLAGS macro, quoted in
 an implementation-defined manner such that when MAKEFLAGS is read by
 another instance of the make command, the original macro's value is
 recovered. Other implementation-defined options and macros may also be
 added to the MAKEFLAGS macro. If this modifies the value of the
 MAKEFLAGS macro, or, if the MAKEFLAGS macro is modified at any
 subsequent time, the MAKEFLAGS environment variable shall be modified to
 match the new value of the MAKEFLAGS macro. The result of setting
 MAKEFLAGS in the Makefile is unspecified.

As far as I understand the beginning, it means that when running
Make recursively, flags passed at each step should accumulate in
MAKEFLAGS.  (The comment about "such that ... the original
macro's value is recovered" is a bit confusing, I think they are
talking about the original command line macro definitions, not
the original MAKEFLAGS value itself.)

All Make implementations I've tried indeed accumulate flags in
MAKEFLAGS... expect GNU Make.  My impression is that GNU Make
will not modify MAKEFLAGS if it already exists.  (Except maybe
for the -w option?)

Here is a short test case:


MSG = 'Fails'

all:
@echo 'all:   MAKEFLAGS=$(MAKEFLAGS)'
MSG='Works.' $(MAKE) -e jump

jump:
@echo 'jump:  MAKEFLAGS=$(MAKEFLAGS)'
$(MAKE) print

print:
@echo 'print: MAKEFLAGS=$(MAKEFLAGS)'
echo $(MSG)

.PHONY: all jump print


Because `all' runs `$(MAKE) -e' I'd expect $(MAKEFLAGS) to
contains `e' at the time `jump' and `print' are executed.  So
`print' ought to display the MSG value from the environment, not
from the Makefile.

Compare GNU make to BSD make:

% make-3.80
all:   MAKEFLAGS=
MSG='Works.' make-3.80 -e jump
make-3.80[1]: Entering directory `/home/adl/tmp'
jump:  MAKEFLAGS=
make-3.80 print
make-3.80[2]: Entering directory `/home/adl/tmp'
print: MAKEFLAGS=w
echo 'Fails'
Fails
make-3.80[2]: Leaving directory `/home/adl/tmp'
make-3.80[1]: Leaving directory `/home/adl/tmp'
% pmake
all:   MAKEFLAGS=
MSG='Works.' pmake -e jump
jump:  MAKEFLAGS= -e
pmake print
print: MAKEFLAGS= -e
echo Works.
Works.

Solaris Make and Tru64 Make both show results similar to BSD
make.
-- 
Alexandre Duret-Lutz



___
Bug-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-make



Re: MAKEFLAGS not updated when it already exists?

2003-01-14 Thread Paul D. Smith
I would agree that GNU make's behavior here is not according to the
standard... it looks like you're right: the flags that are in MAKEFLAGS
as a consequence of the initial invocation of make take precedence and
no extra flags that are added to a "sub-make" will be added to
MAKEFLAGS.

I tested back as far as GNU make 3.75 and this has always been the case.

I'll look into it.  Please submit a bug against GNU make in Savannah on
this, thanks!

  https://savannah.gnu.org/projects/make/

-- 
---
 Paul D. Smith <[EMAIL PROTECTED]>  Find some GNU make tips at:
 http://www.gnu.org  http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


___
Bug-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-make