Re: Using logical oprators in GNU makefile

Ralf Wildenhues <[email protected]> Wed, 29 Apr 2009 23:14:41 +0200
Newsgroups gmane.comp.gnu.utils
Organization Department of Numerical Simulation, University of Bonn
Message-ID <[email protected]>
Hello,

please don't top-post, thank you.

* Koteswar16 wrote on Wed, Apr 29, 2009 at 06:37:21AM CEST:
> 
> But how to do ORing in make file ?
> i.e. 
> ifeq ($(var1), value1) || ($(var2), value2)

You can either repeat the expansion,
  ifeq ($(var1), value1)
    $(foo)
  endif

  ifeq ($(var2), value2)
    $(foo)
  endif

or factor into a new variable, for clarity and to avoid duplicate
expansion,

  cond =
  ifeq ($(var1), value1)
    cond = yes
  endif
  ifeq ($(var2), value2)
    cond = yes
  endif

  ifdef cond
    ...
  endif

or you can rewrite your makefile to use conditional operators, and then
use $(or ...).  See 'info make "Conditional Syntax"' and 'info make
"Conditional Functions"'.

Cheers,
Ralf