带有静态模式的规则失败 [英] Rule with static pattern fails

查看:71
本文介绍了带有静态模式的规则失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个makefile,可以从一个BibTex文件中为不同的作者创建HTML发布列表.导出是使用bibtex2html完成的,并且像超级按钮一样工作.但是我坚持规则命名.我希望makefile尽可能通用,以便仅在新同事开始或某人完成博士学位时改编结果列表.

I have a makefile to create HTML publication lists for different authors out of one BibTex file. The export is done using bibtex2html and works like a charm. But I'm stuck at the rule naming. I want to have the makefile as generic as possible to only adapt the results list when a new colleague starts or someone finishes his PhD.

工作流程如下:

  1. bib.bib已给出
  2. results中所有作者的出版物提取到单独的文件中:`bib2bib -c'author:"$ *"'bib.bib'
  3. 现在每个作者都有文件,例如bib-Author1.bib,bib-Author2.bib,...
  4. 将文件转换为html:bibtex2html -d -r -o bib-$@.html bib-$@.bib
  5. 现在有一个名为bib-Author1.html,bib-Author2.html,...的文件.
  1. bib.bib is given
  2. Extract the publications from all authors in results into seperate files: `bib2bib -c 'author : "$*"' bib.bib'
  3. Now there are files for every author, e.g. bib-Author1.bib, bib-Author2.bib, ...
  4. Convert the files to html: bibtex2html -d -r -o bib-$@.html bib-$@.bib
  5. Now there are file called bib-Author1.html, bib-Author2.html, ....

这是我当前使用的makefile文件:

Here is the current makefile I'm stuck with:

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,该文件执行all目标.这将调用$(result)目标,该目标将为结果中的每个作者调用bib-%.html目标. 问题就来了:被调用时,出现错误混合的隐式和静态模式规则.

Right now I call this makefile with a simple make, which executes the all target. This calls the $(result) target, which calls the bib-%.html target for every author in result. And here comes the problem: When called, make stops with the error mixed implicit and static pattern rules.

我在这里想要做的是使用带有静态模式%.html的规则名称,并将其转换为前提条件%.bib.但显然,我做错了.任何帮助表示赞赏.

What I wanted to do here is take the rule name with the static pattern %.html and have this converted to the prerequisite %.bib. But apparently, I'm doing something wrong. Any help appreciated.

推荐答案

在此makefile中有几处错误-或至少是奇怪的.您的问题尚不完全清楚,因此需要进行一些猜测.

There are several things that are wrong -- or at least odd -- in this makefile. Your question is not entirely clear, so some guesswork will be necessary.

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

First, try rules with simple diagnostic commands, in order to get the sequence right. I think this is what you want:

bib-%.bib :
    @echo trying to build $@

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

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

Then finish one rule and verify that it does what you want:

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规则中使用自动变量很奇怪,我怀疑这与您的意图更接近:

Then the other. Your use of automatic variables in the html rule is strange, and I suspect that this is closer to what you intend:

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 $@ $<

这篇关于带有静态模式的规则失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆