GNU Make Convert Spaces to Colons
The only tricky part here is to define a literal space:
space := $(subst ,, )
SPATHS := /usr/bin/foo /usr/bin/baz /usr/bin/baz
CPATHS := $(subst $(space),:,$(SPATHS))
The shortest way to get a literal space would be via $() $()
. Thus:
$(subst $() $(),:,$(CPATHS))
Or, for brevity:
_=$() $()
$(subst $(_),:,$(CPATHS))
It is perhaps an interesting curiosity that the same trick works with cmake's macros, i.e. that ${}
is a separator but introduces no whitespace by itself.