问题
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.
The workflow is the following:
- bib.bib is given
- Extract the publications from all authors in
results
into seperate files: `bib2bib -c 'author : "$*"' bib.bib' - Now there are files for every author, e.g. bib-Author1.bib, bib-Author2.bib, ...
- Convert the files to html:
bibtex2html -d -r -o bib-$@.html bib-$@.bib
- Now there are file called bib-Author1.html, bib-Author2.html, ....
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
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.
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.
回答1:
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 $<
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 $@ $<
来源:https://stackoverflow.com/questions/25461602/rule-with-static-pattern-fails