Re: [cc65] Please critique this makefile

From: Oliver Schmidt <ol.sc1web.de>
Date: 2010-04-25 00:08:58
Hi,

>> Actually, even when writing the "ifndef", I already was having doubts
>> about whether that not assigning a value is the same as not mentioning
>> the variable, at all. After all, it had to be processed. My doubts
>> were proven valid. Other possibility would be to use "ifndef",
>> and comment out the variables at the top. But then, it potentially
>> could be prone to errors caused, e.g., by bogus values passed
>> from the outside. That is something that we both don't like. :-)
>
> To put it another way:
> Assigning an empty string to a variable _does_ define it!  Therefore,
> "ifndef" cannot be used in that context.

1. The 'GNU Make Manual' explicitly says:

"The value of that variable has a non-empty value, the text-if-true is
effective; otherwise, the text-if-false, if any, is effective.
Variables that have never been defined have an empty value."

2. 'Managing Projects with GNU Make' even more explicitly says:

"The difference is that the conditional assignment operator will skip
the assignment if the variable has
been set in any way, even to the empty value, while the ifdef and
ifndef operators test for a
nonempty value."

3. In the GNU make source file read.c there's the code fragment:

      v = lookup_variable (var, i);
      conditionals->ignoring[o] =
        ((v != 0 && *v->value != '\0') == (cmdtype == c_ifndef));

Even without understanding the context fully one can easily see the
explicit test for an empty variable value.

4. I tried it with GNU make 3.81 on Cygwin and it works exactly as
implemented and documented - meaning that "ifndef" _can_ be used in
that context.

Regards,
Oliver
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Apr 25 00:09:06 2010

This archive was generated by hypermail 2.1.8 : 2010-04-25 00:09:08 CEST