[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MAKEFLAGS not updated when it already exists?
From: |
Alexandre Duret-Lutz |
Subject: |
MAKEFLAGS not updated when it already exists? |
Date: |
Tue, 14 Jan 2003 22:27:13 +0100 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu) |
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
- MAKEFLAGS not updated when it already exists?,
Alexandre Duret-Lutz <=