[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU make: Please give an example for the 'if' function (chapter 8 .5
Re: GNU make: Please give an example for the 'if' function (chapter 8 .5 of 'make.html')
Tue, 23 Sep 2003 22:56:49 +0200
On Tue, Sep 23, 2003 at 02:42:36PM +0200, Haeusler Reinhard wrote:
> I wanted to set a variable depending on another variable to different
You need to use a few tricks to do this.
I have rewritten the code you provided:
> VAR2 = $(if ??? $(VAR1), S1, s, $(if ??? $(VAR1), M, m)) # ??? means: don't
VAR2 := $(if $(filter S1,$(VAR1)),s)
VAR2 := $(if $(filter M, $(VAR1)),m,$(VAR2))
So what happens here:
The expression $(filter S1,$(VAR1)) result in 'S1' when VAR1 equals S1.
Therefore $(if select the first part, which is s.
The second line have $(VAR2) in the else clause to avoid overwriting the
You can use filter-out, filter, patsubst to obtain the same functionality.