4

I want check for a condition in makefile using ifeq, & not sure how to go about:

ifeq ( cond1 = yes || cond2 = yes )   
  set value x = 1;   
else  
  set value x = 2;  
endif 

Please suggest the proper way to do it?

Chnossos
  • 9,971
  • 4
  • 28
  • 40
Monkey_play
  • 73
  • 1
  • 8
  • 2
    possible duplicate of [Makefile ifeq logical or](http://stackoverflow.com/questions/7656425/makefile-ifeq-logical-or) – Chnossos Oct 29 '14 at 08:29

3 Answers3

11

In addition to the correct answer given above:if you want to check if x=4 or x=6

ifeq ($(x),$(filter $(x),4 6))   
   x is either 4 or 6. do whatever you like with it
else  
   x is neither 4 nor 6  
endif
4
ifeq ($(filter $(cond1) $(cond2),yes),)
    x := 2
else  
    x := 1
endif 
Mark Galeck
  • 6,155
  • 1
  • 28
  • 55
1

Alternate answer is:

ifneq (,$(filter yes,$(cond1) $(cond2)))   
   x := 1
else  
   x := 2
endif
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
  • 1
    Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P Dec 03 '22 at 11:03