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?
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))
Basically -Wl,-rpath
is just the short variant of -Xlinker -rpath=
:
LDFLAGS += $(addprefix -Xlinker -rpath=,$(lib_paths))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With