Date: Mon, 6 Nov 2006 00:14:13 +0300 From: Ruslan Ermilov <ru@freebsd.org> To: Jeremie Le Hen <jeremie@le-hen.org> Cc: freebsd-hackers@freebsd.org Subject: Re: Puzzling variables behaviour in make(1) Message-ID: <20061105211413.GA72777@rambler-co.ru> In-Reply-To: <20061105200447.GY20405@obiwan.tataz.chchile.org> References: <20061105200447.GY20405@obiwan.tataz.chchile.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Nov 05, 2006 at 09:04:47PM +0100, Jeremie Le Hen wrote: > Hello, >=20 > I wrote the following piece of Makefile: >=20 > % .warning "VAR contains: ${VAR}" > % > % VAR_BACKUP:=3D ${VAR} > % VAR:=3D value2 > %=20 > % .if ${VAR} =3D=3D "value2" > % .warning "VAR is overwritable: ${VAR}" > % .else > % .warning "VAR is NOT overwritable: ${VAR}" > % .endif > %=20 > % VAR:=3D ${VAR_BACKUP} > % > % all: >=20 > If I define VAR within the Makefile (VAR:=3D value1), I get: > % jarjarbinks:~/test/makevars:230# make > % "Makefile", line 3: warning: "VAR contains: value1" > % "Makefile", line 7: warning: "VAR is overwritable: value2" >=20 > If I remove the VAR assignment in the Makefile and define it from > the command -line, I get: > % jarjarbinks:~/test/makevars:232# make VAR=3Dvalue1 > % "Makefile", line 3: warning: "VAR contains: value1" > % "Makefile", line 9: warning: "VAR is NOT overwritable: value2" >=20 > 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". >=20 > Finally, if I define VAR both from the command-line and within the > Makefile: > % jarjarbinks:~/test/makevars:242# make VAR=3Dvalue1 > % "Makefile", line 3: warning: "VAR contains: value1" > % "Makefile", line 11: warning: "VAR is NOT overwritable: value2" >=20 > Same weird behaviour. >=20 >=20 > 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". >=20 >=20 > If this is the expected behaviour, I'd be glad to understand the magic > behind this. >=20 Command-line variables are of the highest precedence. %%% Index: parse.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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++; =20 - line =3D Buf_Peel(Var_Subst(line, VAR_GLOBAL, FALSE)); + line =3D Buf_Peel(Var_Subst(line, VAR_CMD, FALSE)); Parse_Error(iserror ? PARSE_FATAL : PARSE_WARNING, "%s", line); free(line); =20 %%% Cheers, --=20 Ruslan Ermilov ru@FreeBSD.org FreeBSD committer --M9NhX3UHpAaciwkO Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFTlQlqRfpzJluFF4RAsb2AJ45WBt0jlkF6PBmWGMg9u5acizRzACfYDpA ouPTKSBUnD+37c3z7XNn1Q0= =hxDh -----END PGP SIGNATURE----- --M9NhX3UHpAaciwkO--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061105211413.GA72777>