Escaping characters in Makefiles 'addprefix'

makefile

Solution

You have to put it in a variable. Make will break arguments on commas before it expands them, so:

comma = ,

LDFLAGS += $(addprefix -Wl$(comma)-rpath,$(lib_paths))

Problem

I have a list of libraries: ``` lib_paths := dir1 dir2 dir3 ``` that I would like to add to my rpath via ``` LDFLAGS += (addprefix -Wl,-rpath,$(lib_paths)) ``` Of course, this fails because `,` is the delimiter to the `addprefix` function in Makefiles. How can I escape the comma?

Original source