From owner-freebsd-hackers@FreeBSD.ORG Sun Nov 5 20:04:19 2006 Return-Path: X-Original-To: freebsd-hackers@FreeBSD.org Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1101A16A494 for ; Sun, 5 Nov 2006 20:04:19 +0000 (UTC) (envelope-from tataz@tataz.chchile.org) Received: from smtp3-g19.free.fr (smtp3-g19.free.fr [212.27.42.29]) by mx1.FreeBSD.org (Postfix) with ESMTP id AE54D43D6A for ; Sun, 5 Nov 2006 20:04:12 +0000 (GMT) (envelope-from tataz@tataz.chchile.org) Received: from tatooine.tataz.chchile.org (tataz.chchile.org [82.233.239.98]) by smtp3-g19.free.fr (Postfix) with ESMTP id 7D5D84A0E6 for ; Sun, 5 Nov 2006 21:04:11 +0100 (CET) Received: from obiwan.tataz.chchile.org (unknown [192.168.1.25]) by tatooine.tataz.chchile.org (Postfix) with ESMTP id 56B569E6C2 for ; Sun, 5 Nov 2006 20:04:47 +0000 (UTC) Received: by obiwan.tataz.chchile.org (Postfix, from userid 1000) id 33738405B; Sun, 5 Nov 2006 21:04:47 +0100 (CET) Date: Sun, 5 Nov 2006 21:04:47 +0100 From: Jeremie Le Hen To: freebsd-hackers@FreeBSD.org Message-ID: <20061105200447.GY20405@obiwan.tataz.chchile.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) Cc: Subject: Puzzling variables behaviour in make(1) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Nov 2006 20:04:19 -0000 Hello, I wrote the following piece of Makefile: % .warning "VAR contains: ${VAR}" % % VAR_BACKUP:= ${VAR} % VAR:= value2 % % .if ${VAR} == "value2" % .warning "VAR is overwritable: ${VAR}" % .else % .warning "VAR is NOT overwritable: ${VAR}" % .endif % % VAR:= ${VAR_BACKUP} % % all: If I define VAR within the Makefile (VAR:= value1), I get: % jarjarbinks:~/test/makevars:230# make % "Makefile", line 3: warning: "VAR contains: value1" % "Makefile", line 7: warning: "VAR is overwritable: value2" If I remove the VAR assignment in the Makefile and define it from the command -line, I get: % jarjarbinks:~/test/makevars:232# make VAR=value1 % "Makefile", line 3: warning: "VAR contains: value1" % "Makefile", line 9: warning: "VAR is NOT overwritable: value2" Note that this behaviour is puzzling since it follows the path as if {VAR} didn't contain "value2" but the warning message shows it does contains "value2". Finally, if I define VAR both from the command-line and within the Makefile: % jarjarbinks:~/test/makevars:242# make VAR=value1 % "Makefile", line 3: warning: "VAR contains: value1" % "Makefile", line 11: warning: "VAR is NOT overwritable: value2" Same weird behaviour. Actually I am trying to find a way to tell whether a variable has been defined from make.conf(5) or src.conf(5) or from the command-line. According to the code path this method appears to work, but the value of ${VAR} isn't "correct". If this is the expected behaviour, I'd be glad to understand the magic behind this. Thank you. Best regards, -- Jeremie Le Hen < jeremie at le-hen dot org >< ttz at chchile dot org >