tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

VAR.${SEL}?=value doesn't always do what you think it should


I've stumbled over that idiosyncrasy of make(1)'s parser tonight for
native X.Org work.

The make(1) in NetBSD prior to 20080331 and therefore bmake in pkgsrc
(it was last sync'd in February I think) won't do what you expect when
you write the following:

VAR.${SEL}?=    value

Those make(1) will not evaluate the lhs before testing if it is defined,
and therefore will always overwrite the value of the variable (because
it *is* evaluated when it is assigned the value).

sjg@ changed the behaviour for the expected (IMHO) one in March.

If you grep for such uses in pkgsrc, you will find a lot of them, but
there is a trick:  they're usually used inside .for loops, using the
loop variables.  Those cases are handled as expected because of the
funky way .for loop variables are handled.

However, I don't think it is the case for every use of that construct,
although most of them are likely to be variables the user is supposed
to be able to set in mk.conf (which, incidentally, will not work).

It'd be great if Someone(R) could audit our use of the construct and
add the necessary documentation bits in the pkgsrc guide.  Any taker?

Quentin Garnier - -
"See the look on my face from staying too long in one place
[...] every time the morning breaks I know I'm closer to falling"
KT Tunstall, Saving My Face, Drastic Fantastic, 2007.

Attachment: pgpFr0Q_s2Ha7.pgp
Description: PGP signature

Home | Main Index | Thread Index | Old Index