On Sun, Nov 05, 2006 at 09:04:47PM +0100, Jeremie Le Hen wrote:
> 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.
>
Command-line variables are of the highest precedence.
%%%
Index: parse.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/parse.c,v
retrieving revision 1.111
diff -u -p -r1.111 parse.c
--- parse.c 22 Jul 2006 14:00:31 -0000 1.111
+++ parse.c 5 Nov 2006 21:09:51 -0000
@@ -2231,7 +2231,7 @@ parse_message(char *line, int iserror, i
while (isspace((u_char)*line))
line++;
- line = Buf_Peel(Var_Subst(line, VAR_GLOBAL, FALSE));
+ line = Buf_Peel(Var_Subst(line, VAR_CMD, FALSE));
Parse_Error(iserror ? PARSE_FATAL : PARSE_WARNING, "%s", line);
free(line);
%%%
Cheers,
--
Ruslan Ermilov
[EMAIL PROTECTED]
FreeBSD committer
pgpK0Wu8zSnl8.pgp
Description: PGP signature

