[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: if defined(a) || defined(b)
From: |
Mike Shal |
Subject: |
Re: if defined(a) || defined(b) |
Date: |
Tue, 15 Dec 2009 23:16:45 -0500 |
On 12/15/09, Shaun Jackman <address@hidden> wrote:
> How in make do I achieve the equivalent of
>
> if defined(a) || defined(b)
>
You can be explicit and use two ifdefs:
tmp=0
ifdef a
tmp=1
endif
ifdef b
tmp=1
endif
ifeq ($(tmp),1)
do stuff
endif
Or if you just want to see if either variable is non-empty, you can do
something like:
ifneq (,$(a)$(b))
do stuff
endif
That will execute if either variable is non-empty.
Note that these aren't equivalent in all cases. If 'a' is empty and
b=$(a), then the first case will be true (since 'b' is defined), but
in the single ifneq test it will be false since both variables expand
to be empty. So I guess it depends on what you mean by "defined".
-Mike