GNU Make Convert Spaces to Colons
gnu-make, makefile, path, space
Solution
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))
Problem
Given a colon-delimited list of paths, getting a space-delimited list with GNU Make is straightforward: ``` CPATHS := /usr/bin/foo:/usr/bin/baz:/usr/bin/baz SPATHS := $(subst :, ,$(CPATHS)) ``` However, I couldn't find a nice way to go the opposite direction. The following hack does work (at least if sed is installed) but I'm pretty sure there will be a nicer way to solve this just using Make's internal functions. ``` SPATHS := /usr/bin/foo /usr/bin/baz /usr/bin/baz CPATHS := $(shell echo $(SPATHS) > tmp; sed 's/ \+/:/g' tmp; rm tmp) ```