Joining elements of a list in GNU Make

Viewed 15143

In my makefile I have a variable with a list of directories, like this:

DIRS = /usr /usr/share/ /lib

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

How do I do that? I mean, how do I join elements of DIRS list with semicolons, instead of spaces?

3 Answers

You use ':' as separator, so you are on Linux. Consider using bash tool chain to replace continuous spaces by single colon

PATH := $(shell echo $(DIRS) | sed "s/ \+/:/g")
Related