在GNU Make中连接列表的元素 [英] Joining elements of a list in GNU Make
本文介绍了在GNU Make中连接列表的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的makefile文件中,我有一个带有目录列表的变量,如下所示:
In my makefile I have a variable with a list of directories, like this:
DIRS = /usr /usr/share/ /lib
现在,我需要从中创建PATH变量,该变量基本相同,但是使用分号作为分隔符:
Now, I need to create PATH variable from it, which is basically the same, but uses semicolon as a separator:
PATH = /usr:/usr/share/:/lib
我该怎么做?我的意思是,如何将DIRS列表的元素与分号(而不是空格)连接起来?
How do I do that? I mean, how do I join elements of DIRS list with semicolons, instead of spaces?
推荐答案
您可以使用$(subst)
命令,并结合使用一些技巧来获得具有单个空格值的变量:
You can use the $(subst)
command, combined with a little trick to get a variable that has a value of a single space:
p = /usr /usr/share /lib
noop=
space = $(noop) $(noop)
all:
@echo $(subst $(space),:,$(p))
希望有帮助,
埃里克·梅尔斯基
这篇关于在GNU Make中连接列表的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文