Best way to do conditionals ?
David Chase
david.r.chase at oracle.com
Mon Apr 15 13:53:06 UTC 2013
It's good to know that there's two ways to screw up a Makefile to get the same wrong result.
Arrrrrrg.
David
On 2013-04-14, at 7:44 PM, David Holmes <david.holmes at oracle.com> wrote:
> Thanks David, I found my problem - can you see it: :)
>
> CLIENT_AND_SERVER := $(and $(findstring true, $(JVM_VARIANT_SERVER)), $(findstring true, $(JVM_VARIANT_CLIENT)))
>
> There's a space at the end of the line, hence CLIENT_AND_SERVER has the value "true " not "true". I'd suspected something like that and tried adding a strip around the $and, but still had the space at the end of the line. Doh!
>
> Thanks for helping out.
>
> David
>
> On 13/04/2013 11:24 PM, David Chase wrote:
>>
>> On 2013-04-12, at 7:00 PM, David Holmes <david.holmes at oracle.com> wrote:
>>>
>>> Thanks for the sanity check.
>>>
>>> This implies to me that either
>>>
>>> a) it is a phase 1 versus phase 2 issue, but given the content of spec.gmk I can't see how that can be the case; or
>>>
>>> b) the value of something is not what I naively thing it is ...
>>>
>>> but I have investigated both of those in depth and nothing seems to be wrong. Yet I always take the else path :(
>>
>> I think I have it, or at least, I can reproduce your results:
>> -------------------------------
>> JVM_VARIANT_SERVER := true
>> JVM_VARIANT_CLIENT := true
>>
>> ifeq ($(CLIENT_AND_SERVER1), true)
>> one: two
>> @echo one then C=$(JVM_VARIANT_CLIENT) S=$(JVM_VARIANT_SERVER) BOTH1=$(CLIENT_AND_SERVER1) BOTH2=$(CLIENT_AND_SERVER2)
>> else
>> one: two
>> @echo one else C=$(JVM_VARIANT_CLIENT) S=$(JVM_VARIANT_SERVER) BOTH1=$(CLIENT_AND_SERVER1) BOTH2=$(CLIENT_AND_SERVER2)
>> endif
>>
>> ifeq ($(CLIENT_AND_SERVER2), true)
>> two:
>> @echo two then C=$(JVM_VARIANT_CLIENT) S=$(JVM_VARIANT_SERVER) BOTH1=$(CLIENT_AND_SERVER1) BOTH2=$(CLIENT_AND_SERVER2)
>> else
>> two:
>> @echo two else C=$(JVM_VARIANT_CLIENT) S=$(JVM_VARIANT_SERVER) BOTH1=$(CLIENT_AND_SERVER1) BOTH2=$(CLIENT_AND_SERVER2)
>> endif
>>
>> CLIENT_AND_SERVER1 := $(and $(findstring true, $(JVM_VARIANT_SERVER)), $(findstring true, $(JVM_VARIANT_CLIENT)))
>> CLIENT_AND_SERVER2 := $(and $(JVM_VARIANT_SERVER), $(JVM_VARIANT_CLIENT))
>> --------------------------------------
>>
>> two else C=true S=true BOTH1=true BOTH2=true
>> one else C=true S=true BOTH1=true BOTH2=true
>>
>> This seems a little simple, but it is at least a reproduction.
>>
>>
>>
More information about the build-dev
mailing list