Date: Sun, 5 Nov 2006 21:04:47 +0100 From: Jeremie Le Hen <jeremie@le-hen.org> To: freebsd-hackers@FreeBSD.org Subject: Puzzling variables behaviour in make(1) Message-ID: <20061105200447.GY20405@obiwan.tataz.chchile.org>
next in thread | raw e-mail | index | archive | help
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 >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061105200447.GY20405>