>Date: Tue, 04 Oct 2011 02:11:28 -0400 >From: Paul Smith <[email protected]> >To: Steve Sylvain <[email protected]> >Cc: [email protected] >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>>
_______________________________________________ Help-make mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-make
