2013年11月28日 星期四

how to use logical OR on makefile conditionals

Src:
http://osdir.com/ml/gnu.make.windows/2004-03/msg00063.html

Notes:
How to have OR logic condition in Makefile? Please use "filter".




Subject: Re: how to use logical OR on makefile conditionals
- msg#00063

List: gnu.make.windows

gnu.make.windows Navigation: 
Date: Prev Date Index Thread: Prev Thread Index
%% lucy.allevato@xxxxxxxxxxxx writes:

la> Is there a way to use logical OR on a makefile
la> Something like:

la> ifeq ($(A),$(B) || $(A),$(C)) ,
la> or
la> ifeq ($(A),$(B)) || ifeq ($(A),$(C))

As I'm sure you've seen from the GNU make manual, there is no logical OR
in makefile syntax.


You have to use filter:

ifneq (,$(filter $(A),$(B) $(C)))

The filter will return B and/or C if they match A, and the ifneq empty
string will be true if the filter returns any value.

Note this only works if A, B, and C consist of a single word. If not
you'll have to get even fancier, using something built around
$(subst ...) probably.

--
-------------------------------------------------------------------------------
Paul D. Smith <psmith@xxxxxxx> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist

沒有留言:

張貼留言