I can't seem to force make
to use a more specific rule. I'm working with version 3.81, which is supposed to use the first rule it comes to, but this doesn't seem to work when the more specific rule has a dependency that must be constructed with another rule. Here's the basic picture:
#rule for the dependency of the more specific rule
%.bbl: %.tex *.bib
<build the .bbl file>
#more specific rule
some_prefix%.pdf: some_prefix%.tex some_prefix%.bbl
<build the .pdf>
#general rule
%.pdf: %.tex
<build the .pdf>
So basically I want make
to build the pdf with the .bbl
file if it matches some_prefix
, otherwise use the more general rule. Unfortunately, unless I remove the dependency on the .bbl
file, the second rule never gets called.
I seem to be able to get it working by adding a hack to the general rule:
%.pdf: %.tex %.hack
<make the pdf with a more general rule>
%.hack: %.tex
touch $@
This seems to work, and the .hack
files are deleted automatically, but as the name implies, this is a terrible hack. It seems like there must be some better way to force the use of the specific rule.
How can I force make to use the more specific rule? Putting it first doesn't seem to help.
You are forgetting a very important aspect of the implicit rule search algorithm: make
always prefers implicit rules which have prerequisites which are explicit targets, over an implicit rule where one of the prerequisite patterns does not match a known target and must be built by rule chaining. See step #5 in the algorithm, vs. step #6. This is apart from the normal "first in the makefile" ordering of pattern rules.
If you want to do this you'll have to write the bbl
rule as a static pattern rule, not a real pattern rule, so that the bbl
files are explicit targets not implicit targets.
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