带引用文件的pandoc的Makefile

Puz*_*d79 5 makefile pandoc

我正在尝试为pandoc编写一个Makefile.我希望能够键入make filename.ext,Makefile将自动编译filename.txtfilename.ext.文件名可以是任何名为.txt的文件名.这部分很容易.例如,我有一套规则,如:

%.pdf: %.txt
    pandoc -s --smart -f markdown -o $@ $<

%.html: %.txt
    pandoc -s --smart --bibliography $(bib) -f markdown -t html --standalone -o $@ $<

%.docx: %.txt
    pandoc -s --smart --bibliography references.bib -f markdown -t docx -o $@ $<

%.tex: %.txt
    pandoc -s --smart --bibliography references.bib -o $@ $<
Run Code Online (Sandbox Code Playgroud)

但是,我还想从同一个文件中添加引文filename.bib.因此,如果我键入make fudge.pdf,pandoc会将fudge.txt转换为fudge.pdf,同时合并来自fudge.bib的bibtex引用.我该怎么做呢?命令行就像

pandoc -s --smart --bibliography filename.bib -f markdown -o $@ $<
Run Code Online (Sandbox Code Playgroud)

...但我无法弄清楚如何从fudge.txt获取fudge.bib而不做这样的事情:

pandoc -s --smart --bibliography $(subst .txt,.bib,$<) -f markdown -o $@ $<
Run Code Online (Sandbox Code Playgroud)

这将工作,但a)我想首先对文件*.bib进行一些预处理(即生成它并添加缺少的引用)和b)在每一行都需要该宏.有什么更优雅的吗?

Bet*_*eta 7

pandoc -s --smart --bibliography $*.bib -f markdown -o $@ $<
Run Code Online (Sandbox Code Playgroud)