首页 文章

静态模式的规则失败

提问于
浏览
0

我有一个makefile,可以从一个BibTex文件中为不同的作者创建HTML发布列表 . 导出使用bibtex2html完成,就像一个魅力 . 但我坚持规则命名 . 我希望makefile尽可能通用,只有在新同事开始或有人完成博士学位时才能调整结果列表 .

工作流程如下:

给出了

  • bib.bib

  • results 中所有作者的出版物提取到单独的文件中:`bib2bib -c 'author : 1127770 ' bib.bib'

  • 现在每个作者都有文件,例如bib-Author1.bib,bib-Author2.bib,...

  • 将文件转换为html: bibtex2html -d -r -o bib-$@.html bib-$@.bib

  • 现在有一个名为bib-Author1.html的文件,bib-Author2.html,....

这是我遇到的当前makefile:

objects = bib-*.bib
results = Author1 Author2

.PHONY : clean cleanall all $(results)
.INTERMEDIATE : bib-*.bib

all : $(results)

$(results) : % : bib-%.html

bib-%.bib :
  TMPDIR=. bib2bib -c 'author : "$*"' bib.bib

bib-%.html : %.html : %.bib
  TMPDIR=. bibtex2html -d -r -o bib-$@.html bib-$@.bib

#Left the clean and cleanall targets out to shorten the code snippet

现在我用一个简单的 make 调用这个makefile,它执行所有目标 . 这会调用 $(result) target,它会为结果中的每个作者调用bib - % . html目标 . 问题就出现了:当调用时,使用错误混合隐式和静态模式规则来停止 .

我想在这里做的是将规则名称与静态模式%.html一起使用并将其转换为先决条件%.bib . 但显然,我做错了什么 . 任何帮助赞赏 .

1 回答

  • 3

    在这个makefile中有几个错误 - 或者至少是奇怪的 - . 你的问题并不完全清楚,所以有些猜测是必要的 .

    首先,尝试使用简单诊断命令的规则,以使序列正确 . 我想这就是你想要的:

    bib-%.bib :
        @echo trying to build $@
    
    bib-%.html : bib-%.bib
        @echo trying to build $@ after $<
    

    然后完成一条规则并验证它是否符合您的要求:

    bib-%.bib :
        TMPDIR=. bibtex2html-1.96-osx-x86_64/bib2bib -c 'author : "$*"' -s '$$date' bib.bib
    
    bib-%.html : bib-%.bib
        @echo trying to build $@ after $<
    

    然后是另一个 . 你在html规则中使用自动变量很奇怪,我怀疑这更接近你的意图:

    bib-%.bib :
        TMPDIR=. bibtex2html-1.96-osx-x86_64/bib2bib -c 'author : "$*"' -s '$$date' bib.bib
    
    bib-%.html : bib-%.bib
        TMPDIR=. bibtex2html-1.96-osx-x86_64/bibtex2html -d -r --nodoc --nobibsource --no-header --no-footer -o $@ $<
    

相关问题