GNU Make:如何加入列表并将其与分隔符分开? [英] GNU Make: how to join list and separate it with separator?
本文介绍了GNU Make:如何加入列表并将其与分隔符分开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个:
FOO = foo1 foo2 ... fooN
,并希望将所有这些字符串连接起来,并用例如冒号分隔它:
and want to get join all these string and separate it with, for instance, colong:
foo1:foo2:foo3:...:fooN
如何在不使用外部UNIX工具的情况下在GNU Make中做到这一点?
How to do this in GNU Make, without using external UNIX tools?
推荐答案
请参见下面的代码.
# A literal space.
space :=
space +=
# Joins elements of the list in arg 2 with the given separator.
# 1. Element separator.
# 2. The list.
join-with = $(subst $(space),$1,$(strip $2))
用法:
FOO = foo1 foo2 ... fooN
COLON_SEPARATED_FOO := $(call join-with,:,$(FOO))
这篇关于GNU Make:如何加入列表并将其与分隔符分开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文