Subject: Re: make: allow quoted lhs in conditionals
To: None <tech-toolchain@NetBSD.org>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-toolchain
Date: 04/08/2004 09:33:18
On Thu, 8 Apr 2004 04:21:39 -0500, James Chacon writes:
>> The only reason for passing termc (0 or ')') is to mimmic the previous
>> behavior for
>> 
>> .if (${VAR})
>> 
>> which isn't legal - according to the grama in cond.c, not sure what it
>> would/should mean anyway.
>
>In general I've seen this used to simply test "does this var have a value"?

Yes, and as for previous versions of make
.if ${VAR}
still behaves that way - though it chokes if VAR isn't defined - which
makes it of limited use.

But no version of make that I've checked will accept
.if (${VAR})
so I was simply preserving that behavior. 

Its a trivial variation though, to allow:
.if "${VAR}"
or
.if "${VAR}" != ""
to work even if VAR isn't defined - we just use the fact that ${VAR}
is in a quoted string, to tell Var_Parse that an undefined variable
isn't an error.

While this would make lots of makefiles eaier to write, it would also
make them non-portable.   Of course supporting "${VAR}" on the lhs
already puts us there ;-)

Being _able_ to use quoted lhs makes some complex (and to me at least,
useful) expressions possible.  That doesn't mean that quoted lhs
should be used liberally ;-)

Anyway, if we allow quoted vars on lhs, should we also accept
.if (${VAR})
and/or
.if ("${VAR}")
?

--sjg