GNU Make with patsubst: two replacements needed

I need to refer to the stem twice in replacement for a variable replacement:

O23=$(OROOTS:%=$(ODIR)/overx-%2wk-%3wk.mlb)

I need to do two replacements with the same base, but the substitution uses patsubst , which only does the first. How can we do both?

+7
source share
3 answers

From kludgery:

 O23=$(join $(OROOTS:%=$(ODIR)/overx-%2wk), $(OROOTS:%=-%3wk.mlb)) 
+4
source

In fact, Jack got it almost right - foreach to the rescue! We still know the full stitch and paste it into var, and foreach extends all var entries:

O23 := $(foreach root,$(OROOTS),$(ODIR)/overx-$(root)2wk-$(root)3wk.mlb)

In any case, I will check Beta for a new perspective.

+8
source

In $(shell) :

 O23 := $(foreach O,$(OROOTS),$(shell echo '$(O)' | awk '{print "overx-"$$0"2wk-"$$0"3wk.mlb"}')) 

I think Beta kludgery is probably better, since for every word in $(OROOTS) it should not fork out for awk .

0
source

All Articles