From owner-freebsd-bugs@FreeBSD.ORG Thu Jul 1 09:10:51 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0DD9616A502 for ; Thu, 1 Jul 2004 09:10:51 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E356343D58 for ; Thu, 1 Jul 2004 09:10:50 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i619ANxW093844 for ; Thu, 1 Jul 2004 09:10:23 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i619ANXx093843; Thu, 1 Jul 2004 09:10:23 GMT (envelope-from gnats) Date: Thu, 1 Jul 2004 09:10:23 GMT Message-Id: <200407010910.i619ANXx093843@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Ruslan Ermilov Subject: Re: bin/68534: make(1) - ${.MAKEFLAGS} does not contain cmd line args X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Ruslan Ermilov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jul 2004 09:10:51 -0000 The following reply was made to PR bin/68534; it has been noted by GNATS. From: Ruslan Ermilov To: John E Hein Cc: bug-followup@FreeBSD.org Subject: Re: bin/68534: make(1) - ${.MAKEFLAGS} does not contain cmd line args Date: Thu, 1 Jul 2004 12:05:57 +0300 On Thu, Jul 01, 2004 at 01:30:10AM +0000, John E Hein wrote: > > 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 > As documented, MAKEFLAGS value (FOO=3) is parsed just like if it were a part of the command line, so this is equivalent to ``env FOO=1 make FOO=3 FOO=2'', so `2' is printed. > make X=1 > MAKEFLAGS: FOO=3 > .MAKEFLAGS: > FOO: 3 > Now, we just call ``make'' with FOO=2 and MAKEFLAGS=FOO=3 in environment. New make parses MAKEFLAGS, so this becomes equivalent to ``env FOO=2 make FOO=3'', so `3' is printed. > $ env FOO=1 make FOO=2 > MAKEFLAGS: > .MAKEFLAGS: > FOO: 2 > Here, `2' is printed, and FOO is entered into environment with value 2. > make X=1 > MAKEFLAGS: > .MAKEFLAGS: > FOO: 2 > Here, ${FOO} is fetched from the environment with value 2. > In the first case FOO=3 is inserted in the environment by make via > MAKEFLAGS. > Not quite. What's in environment is FOO=2 and MAKEFLAGS=FOO=3 (see above). > In the second case FOO=1 is inserted in the environment in a more > generic way. > And then FOO=2 causes FOO in environment to be reset to `2'. > 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. > I don't quite understand what you're asking, but I hope my explanations answer this. ;) > And finally... > > $ env FOO=1 make -E FOO FOO=2 > MAKEFLAGS: -E FOO > .MAKEFLAGS: -E FOO > FOO: 2 > Here, you say to prefer environment variable FOO over global FOO (there's no global FOO, FOO?=0). Then, FOO=2 is parsed and FOO in environment is re-assigned the value of 2, and it's what gets printed. > make X=1 > MAKEFLAGS: -E FOO > .MAKEFLAGS: -E FOO > FOO: 2 > Here, we just print FOO from environment, which is `2'. > Whoa, wait a second. There's some stuff from the command line > in MAKEFLAGS now. > Like I said in another email, only variable=value is not saved in MAKEFLAGS. Cheers, -- Ruslan Ermilov ru@FreeBSD.org FreeBSD committer