Joining elements of a list in GNU Make

后端 未结 3 364
后悔当初
后悔当初 2021-01-01 12:33

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 fr

3条回答
  •  生来不讨喜
    2021-01-01 12:54

    You can use the $(subst) command, combined with a little trick to get a variable that has a value of a single space:

    p = /usr /usr/share /lib
    noop=
    space = $(noop) $(noop)
    
    all:
            @echo $(subst $(space),:,$(p))
    

    Hope that helps,

    Eric Melski

提交回复
热议问题