makefile patternrule,目标文件名中带有其他通配符 [英] makefile patternrule with further wildcards in target file name
问题描述
我需要创建一个特殊的makefile规则,最好用一个示例来说明. 也许我们用规则创建文件
I need to create a special makefile rule, which is best explained by an example. Maybe we create files with the rules
%_test.pdf: %.tex
pdflatex -jobname=%_test %.tex
%_result.pdf: %.tex
pdflatex -jobname=%_result %.tex
,它工作正常.只是想到这里会出现更多类似的模板,人们可能会想到这样的通配符规则
and it is working fine. Just thinking there occur more templates like those above, one might think of one wildcard-rule like
%_WILDCARD.pdf: %.tex
pdflatex -jobname=%_$(WILDCARD) %.tex
其中WILDCARD由make决定.有可能建立这样的规则吗?
where WILDCARD is determined by make. Is it possible to build such a rule?
推荐答案
我以@eldar和@andres的答案为灵感,对自己有了解决方案
Inspired by the answers of @eldar and @andres I think, I got the solution on myself
.SECONDEXPANSION:
%.pdf: $$(firstword $$(subst _, ,%))
pdflatex -jobname=$* $+
这正是我需要的.有关此方法的详细信息,请参见 GNU make手册.
This does exactly, what I needed. Detailed information for this way may be found at GNU make manual.
这篇关于makefile patternrule,目标文件名中带有其他通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!