Reputation: 2399
I have a Makefile in which a couple of targets need to be made the same way, but one of the targets is a file whose basename is different from its prerequisite. Here is a minimal example:
ABOUT.html: README.md
help.html: help.md
%.html: %.md
pandoc --standalone --quiet -f gfm -H $(github-css) -o tmp.html $<
inliner -n < tmp.html > $@
rm -f tmp.html
With this Makefile, help.html
gets made but ABOUT.html
is never made. The reason, I presume, is because the base file name for %.html
and %.md
don't match up in the case of ABOUT.html
because that target depends on README.md
.
Is there a way to make this work without having to make a separate recipe for ABOUT.html
?
Upvotes: 0
Views: 267
Reputation: 136286
One option is to create ABOUT.md
symlink, so that your pattern rule works, by adding the following rule:
ABOUT.md : README.md
ln -s ${<F} ${@F}
You may like to avoid using the same temporary file in the recipe because that breaks in parallel builds. A better way is to use a unique temporary file for the target based on the target name:
%.html: %.md
pandoc --standalone --quiet -f gfm -H $(github-css) -o $@~ $<
inliner -n < $@~ > $@
rm -f $@~
Upvotes: 1