help-make
[Top][All Lists]
Advanced

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

Re: Problem with $(or


From: John Dill
Subject: Re: Problem with $(or
Date: Tue, 4 Oct 2011 12:32:00 -0400

>Date: Tue, 04 Oct 2011 02:11:28 -0400
>From: Paul Smith <address@hidden>
>To: Steve Sylvain <address@hidden>
>Cc: address@hidden
>Subject: Re: Problem with $(or
>
>On Mon, 2011-10-03 at 18:11 -0700, Steve Sylvain wrote:
>> I'm trying to use the $(or built-in function.  I stripped my problem
>> down to this:
>> $(if $(OR "TEST"), $(warning PASS), $(warning FAILED))
>> 
>> I always get the FAILED message.  Is my syntax correct?  Any pointers
>> to help debug this issue?
>> 
>> I'm using make.exe V3.80 on Windows.
>
>First, the function is $(or ...) not $(OR ...) (make, like all
>UNIX-based tools, is case-sensitive).
>
>Second, this function was added in GNU make 3.81 so it's not available
>in your version.  Because of that it expands to the empty string, like
>any other unknown variable name, hence the FAILED message.

While that is true, it is not difficult to add one of your own, at least the 
binary version.

\code snippet
##! This variable represents a \c true boolean value.
true:=true

##! This variable represents a \c false boolean value.
false:=

##! Test the existence of \mkfunc{or} (3.81).
__make_have_or:=$(or $(true),$(false))

#!
# \brief Perform the logical \c or operation.
# \param $1 The first argument.
# \param $2 The second argument.
# \return The first non-empty text string in arguments \mkarg{1}
#         or \mkarg{2}, \mkvar{false} otherwise.
#
# Unlike the native \mkfunc{or} function provided with \c make
# version 3.81, this substitute is limited to two parameters.
#/
ifndef __make_have_or
or=$(if $(strip $1),$1,$(if $(strip $2),$2,$(false)))
endif
\endcode

Of course one must remember to use '$(call or,...' to invoke the function.  The 
'and' function is left to the reader as an exercise.

Best regards,
John D.

<<winmail.dat>>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]