makefile - GNU make equivalent to BSD make's $(var:Q)? -


bsd make has :q variable expansion modifier, documented in the freebsd make man page follows:

:q   quotes every shell meta-character in variable, can      passed safely through recursive invocations of make. 

if variable var has value a b\c"d'e$f, $(var:q) expands a\ b\\c\"d\'e\$f (or equivalent). useful pass strings shell without worrying shell interpret special characters.

does gnu make have equivalent? or have escape special characters own?

gnu make provides functions subst , patsubst can solve problem. more general, require more work developer since not solve specific problem. also, documentation not show use regular expressions, adding work.

for instance, in principle build expression this:

$(subst \\,\\\\,$(subst ",\", $(subst ',\', var))) 

for more discussion,


Comments