bin/68534: make(1) - ${.MAKEFLAGS} does not contain cmd line args

John E Hein jhein at timing.com
Wed Jun 30 18:30:10 PDT 2004


The following reply was made to PR bin/68534; it has been noted by GNATS.

From: John E Hein <jhein at timing.com>
To: Giorgos Keramidas <keramida at ceid.upatras.gr>
Cc: bug-followup at freebsd.org
Subject: Re: bin/68534: make(1) - ${.MAKEFLAGS} does not contain cmd line args
Date: Wed, 30 Jun 2004 19:22:20 -0600

 This is interesting env var precedence weirdness...
 
 $ cat Makefile
 FOO?=0
 X?=0
 .PHONY: x
 x:
 	@echo MAKEFLAGS: ${MAKEFLAGS}
 	@echo .MAKEFLAGS: ${.MAKEFLAGS}
 	@echo FOO: ${FOO}
 .if $X != 1
 	make X=1
 .endif
 
 $ env FOO=1 MAKEFLAGS=FOO=3 make FOO=2
 MAKEFLAGS: FOO=3
 .MAKEFLAGS:
 FOO: 2
 make X=1
 MAKEFLAGS: FOO=3
 .MAKEFLAGS:
 FOO: 3
 
 $ env FOO=1 make FOO=2
 MAKEFLAGS:
 .MAKEFLAGS:
 FOO: 2
 make X=1
 MAKEFLAGS:
 .MAKEFLAGS:
 FOO: 2
 
 
 In the first case FOO=3 is inserted in the environment by make via
 MAKEFLAGS.
 
 In the second case FOO=1 is inserted in the environment in a more
 generic way.
 
 Why does FOO=2 (the cmd line variable) override FOO in the environment
 in the first case, but not the second?  I'm going to have a look in
 the source.
 
 And finally...
 
 $ env FOO=1 make -E FOO FOO=2
 MAKEFLAGS: -E FOO
 .MAKEFLAGS: -E FOO
 FOO: 2
 make X=1
 MAKEFLAGS: -E FOO
 .MAKEFLAGS: -E FOO
 FOO: 2
 
 But that is as expected.  It's case 2 that puzzles me.
 
 Whoa, wait a second.  There's some stuff from the command line
 in MAKEFLAGS now.
 
 So I guess the bug is that only CERTAIN things from the command
 line show up in MAKEFLAGS>


More information about the freebsd-bugs mailing list