Substitute variable in sed inside Makefile
<p>I've been throught all possible answers in SO but still I cannot make my script work.</p>

<p>I have a query script in SPARQL with a line that needs to substitute the mark <strong>%contributor%</strong> by a variable between "&lt;>"  </p>

<pre><code>?link dcterms:contributor %contributor%
</code></pre>

<p>Into</p>

<pre><code> ?link dcterms:contributor &lt;http://newurl&gt;
</code></pre>

<p>If I execute the code in the shell, the substitution is done properly and I see my query with the <strong>%contributor%</strong> tag successfully substituted. But when executed inside a Makefile, even with the double <strong>$$</strong> dollar to allow the expansion of variables I don't manage to get it done.</p>

<pre><code>for l in `cat sref.csv`; do \
    QUERY=$$(cat queries/table_knowledge.rq | sed "s@%contributor%@&lt;$$l&gt;@g") ; \
    echo $$QUERY ; \
done
</code></pre>

<p>Also like this it does not work:</p>

<pre><code>QUERY=$$(cat queries/table_knowledge.rq | sed 's/%contributor%/&lt;$(l)&gt;/g') ; \
</code></pre>

<p>or</p>

<pre><code>QUERY=$$(cat queries/table_knowledge.rq | sed 's/%contributor%/&lt;${l}&gt;/g') ; \
</code></pre>