开发者

GNU Make with patsubst: need two substitutions

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

O23=$(OROOTS:%=开发者_JAVA技巧$(ODIR)/overx-%2wk-%3wk.mlb)

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


In fact, Jack got it almost right -- foreach to the rescue! We know the full stem anyway and stick it into a var, and foreach expands all occurrences of the var:

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

I'll check Beta's anyway for the new perspective.


By kludgery:

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


By $(shell):

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

I think Beta's kludgery is probably better, since it doesn't have to fork out to awk for every word in $(OROOTS).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜