2012-03-04 27 views

risposta

14

Vedere il codice qui sotto.

# 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)) 

Usage:

FOO = foo1 foo2 ... fooN 

COLON_SEPARATED_FOO := $(call join-with,:,$(FOO)) 
12

Si può semplicemente sostituire gli spazi con i due punti:

EMPTY := 
SPACE := $(EMPTY) $(EMPTY) 
FOO = foo1 foo2 ... fooN 
FOO_LIST = $(subst $(SPACE),:,$(FOO)) 

FOO_LIST è foo1:foo2:...:fooN.

+1

Perché non solo "FOO_LIST = $ (subst $ (SPACE),:, $ (FOO))'? – Beta

+0

@Beta Buon punto. Corretto. –

Problemi correlati