help-make
[Top][All Lists]
Advanced

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

Re: $(if-eq ...)


From: Philip Guenther
Subject: Re: $(if-eq ...)
Date: Fri, 29 Jun 2007 16:05:26 -0600

On 6/29/07, Stephan Beal <address@hidden> wrote:
...
i've got it working, but of course it's missing the short-circuit
features of built-ins, e.g. so that the $(error) in:
$(if X,,$(error this is an error))
will only be evaluated if !X. That works for built-ins of course, but i
don't see a way to do it with add-on funcs.

It can't be done.  To quote the info pages:
  The `call' function expands the PARAM arguments before assigning
  them to temporary variables.


The closest alternative I can think of is to instead pass the names of
variables to be evaluated for the 'then' and 'else' clauses:

mythen = $(warning this should happen)
myelse = $(warning this should not happen)
$(call if-eq-vars,abc,abc,mythen,myelse)


That's not hard to implement:

if-eq-vars = $(eval ${if-eq-vars-impl})
define if-eq-vars-impl
ifeq ($1,$2)
$(value $3)
else
$(value $4)
endif
endef


...but it's clunky to use, eliminating most the point of the function.


Philip Guenther




reply via email to

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