In a Makefile I have:
images/schematic.pdf: images/schematic.svg
inkscape -D -z --file=$^ --export-pdf=$@ --export-latex
sed -i "s:schematic:images/schematic:g" $@_tex
What this rule does is:
- Use inkscape to convert to a latex-ready
.pdf
PDF file + its corresponding.pdf_tex
text file (see this answer: https://tex.stackexchange.com/a/2107/104581) - Modify the mentioned
.pdf_tex
file so that it will not break latex compiling from a "higher" directory (namely.
when the.pdf_tex
file is in./images
)
My problem:
I have many rules in this form i. e. where only schematic
is changed. I would like to use a pattern-rule that replaces schematic
by %
. And to use %
in the recipe (in the sed command).
However the rule:
images/%.pdf: images/%.svg
inkscape -D -z --file=$^ --export-pdf=$@ --export-latex
sed -i "s:%:images/%:g" $@_tex
does not work: % is interpreted literally in the recipe.
I also tried to replace % in the recipe by $% but this variable seems to be empty.
Unsatisfactory solution:
Add a line in the recipe to create a (make) variable that will hold the result of notdir(removeprefix($<))
(using this question or a call to bash because there is no removeprefix in GNU Make).