Strength will force you to use a more specific rule.

I cannot force make use a more specific rule. I am working with version 3.81, which should use the first rule to which it applies , but this does not seem to work when a more specific rule has a dependency that needs to be built with another rule. Here is the main 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, I want make create a pdf file with a .bbl file if it matches some_prefix , otherwise use a more general rule. Unfortunately, if I do not remove the dependency on the .bbl file, the second rule will never be invoked.

It seems I can make it work 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 suggests, this is a terrible hack. There seems to be some better way to get a specific rule to be used.

How to force to use a more specific rule? Assuming this at first does not seem to help.

+5
source share
1 answer

You forget a very important aspect of the implicit rule search algorithm : make always prefers implicit rules that have prerequisites that are explicit goals, by an implicit rule, where one of the prerequisite patterns does not match the known goal and must be built according to the rules chain. See Step # 5 in the algorithm, as well as Step # 6. This is different from the usual “first in makefile” ordering of template rules.

If you want to do this, you need to write a bbl rule as a static template rule, not a real template rule, so bbl files will be explicit targets, not implicit targets.

+4
source

Source: https://habr.com/ru/post/1214614/


All Articles