Publication List Makefiles

My publication lists are produced by an increasingly baroque sets of Makefiles based around bibtex2html. There has been (a little) bit of interest in these, so I thought I would put them online.

Essentially, I have a series of filters which do the following:

I wrote these over a number of years, which is why they are so bizarre.

VPATH=$(HOME)/documents/bibtex/phil_lord:$(HOME)/documents/cv/bibliograph



## First we need to hack the src bib file, to produce out something with an
## apppropriate download location.
##
## Need to refactor this into a external file, because this is getting daft.
## At the same time I can refactor this to blitz journal and page data which
## is not important.
%.out.bib: %.bib
	cat $< | ./bib_treatments.pl > $@


#	cp $< ../$<

## next we actually need to do the bibtex2html thing. We are using -nodoc as
## we are going to incorporate this into another file, and have added some
## extra link types. The TMPDIR thing is a workaround for linux.cs which is
## running an old version of bibtex2html
%.out.part.ht: %.out.bib
	export TMPDIR=.;\
	bibtex2html -nodoc -noabstract -sort-by-date --reverse-sort \
	-s abbrv -nf script "script" -nf slides "slides" \
	-nf inmem "in memoriam" -nf ppt "powerpoint" \
	--macros-from macros.tex \
	-nf link "link" -nofooter -nf f1000 "Faculty of 1000" \
        -nf hdl "hdl" -nf blog "blog" \
	-nf arxiv "arXiv" \
	-suffix .part.ht -nokeywords ./$<
	#dos2unix $@
	 #	-nf doi "doi" \


## having done all of this, and feeling very clever with myself, I
## realise that all of the links to the bib file have been broken, so
## I need to hack them back in. Also I want each file to have its own
## section. So hack that back in. 
%.fixed.ht: %.out.part.ht
	perl -p -e 's#["].*out_bib[.]part[.]ht#"./publications-bib.html#' \
	$< > $@ 

%.fixed.ht.title: %.out.part.ht
	echo "<h1>" > $@
        ## Upper case and remove underscores to make it look pretty
	echo $* | perl -p -e 's#_# #' | perl -p -e 's/\b(\w)/\U$$1/g' >> $@
	echo "</h1>" >> $@
#	echo "<a href=\""$*".src.bib\">[All as bib]</a>" >> $@

BIBFILES_BODY = journal_papers books conference_papers grants
BIBFILES_BODY_OTHERS = popular_press programme_committees invited_presentations journal_reviewing others 


BIBFILES_SRC := $(addsuffix .bib, $(BIBFILES_BODY)) $(addsuffix .bib, $(BIBFILES_BODY_OTHERS))
BIBFILES_OUT_BIB := $(addsuffix .out.bib, $(BIBFILES_BODY)) $(addsuffix .out.bib, $(BIBFILES_BODY_OTHERS))
BIBFILES_FIXED := $(addsuffix .fixed.ht, $(BIBFILES_BODY))
BIBFILES_FIXED_TITLE := $(addsuffix .fixed.ht.title, $(BIBFILES_BODY))

BIBFILES_FIXED_OTHERS := $(addsuffix .fixed.ht, $(BIBFILES_BODY_OTHERS))
BIBFILES_FIXED_TITLE_OTHERS := $(addsuffix .fixed.ht.title, $(BIBFILES_BODY_OTHERS))


all: ../publications.ht ../publications_others.ht macros.tex bibliography.pdf  Makefile-generated \
	../bibliography.bib Makefile

## Add an appropriate title to the HTML page, and then cat everything
## into one big ht file in the directory above. We can also combine
## this with the generating the linked to bib file, as that will also
## be out of date
../publications.ht: $(BIBFILES_FIXED) $(BIBFILES_FIXED_TITLE) ../publications-bib.ht
	cat $(foreach file,$(BIBFILES_FIXED),$(patsubst %.ht,%.ht.title,$(file)) $(file)) > ../publications.ht
        ## perl can't filter back into the same file it comes from. As I have two names 
        ## filter to one file then back again. 	
	perl -p -e 's#P[.]&nbsp;Lord#<strong>P.&nbsp;Lord</strong>#' ../publications.ht > ../publications.ht.tmp
	perl -p -e 's#P[.]W[.]Lord#<strong>P.W.&nbsp;Lord</strong>#' ../publications.ht.tmp > ../publications.ht
	rm ../publications.ht.tmp
	## delete this to ensure it gets regenerated above
	-rm ../publications.html
	-rm ../publications-bib.html


../publications_others.ht: $(BIBFILES_FIXED_OTHERS) $(BIBFILES_FIXED_TITLE_OTHERS) ../publications.ht
	cat $(foreach file,$(BIBFILES_FIXED_OTHERS),$(patsubst %.ht,%.ht.title,$(file)) $(file)) > ../publications_others.ht
        ## perl can't filter back into the same file it comes from. As I have two names 
        ## filter to one file then back again. 	
	perl -p -e 's#P[.]&nbsp;Lord#<strong>P.&nbsp;Lord</strong>#' ../publications_others.ht > ../publications_others.ht.tmp
	perl -p -e 's#P[.]W[.]Lord#<strong>P.W.&nbsp;Lord</strong>#' ../publications_others.ht.tmp > ../publications_others.ht
	rm ../publications_others.ht.tmp
	## delete this to ensure it gets regenerated above
	-rm ../publications_others.html


../publications-bib.ht: $(BIBFILES_FIXED) $(BIBFILES_FIXED_OTHERS)
	cat $(patsubst %.fixed.ht,%.out_bib.part.ht,$(BIBFILES_FIXED)) > ../publications-bib.ht
	cat $(patsubst %.fixed.ht,%.out_bib.part.ht,$(BIBFILES_FIXED_OTHERS)) >> ../publications-bib.ht

## want to add a sorted by year thing...here is the command line to sort referred publications by year. 
#bib2bib -ob 2006.bib -c 'year=2006' journal_papers.out.bib conference_papers.out.bib

../bibliography.bib: $(BIBFILES_OUT_BIB)
	cat $(BIBFILES_OUT_BIB) > ../bibliography.bib

clean: Makefile-generated
	-rm ../publications*.ht
	-rm bibliography.pdf
	-rm bibliography_tmp*
	-rm Makefile-generated
	-rm webbib_tmp.bst
	-rm *.out_bib.part.ht
	-rm *.fixed.ht
	-rm *.out.part.ht
	-rm *.out.bib
	-rm *.fixed.ht.title
	-rm -f *log

## generate the rest of the make file. There must
## be an easier way to do this. 
Makefile-generated: Makefile 
	./generate_makefile.pl $(BIBFILES_BODY) $(BIBFILES_BODY_OTHERS) > Makefile-generated

include Makefile-generated

## And this little bit is unrelated to all the rest...
bibliography.pdf: bibliography.tex $(BIBFILES_SRC) webbib_tmp.bst
	cp $< bibliography_tmp.tex	
	#perl -p -e's#webbib#webbib_tmp#' bibliography_tmp.tex  > bibliography_tmp.tex.tmp
	#mv bibliography_tmp.tex.tmp bibliography_tmp.tex
	-rm bibliography_tmp.aux
	pdflatex bibliography_tmp
	bibtex bibliography_tmp
        # hack my name
	perl -p -e's#(P[a-zA-Z~ .]*Lord)#\\textbf{$$1}#' bibliography_tmp.bbl > bibliography_tmp.bbl.tmp
        # hack underscores in DOI's
	perl -p -e's#([0-9]+)_([0-9]+)#$$1\\_$$2#' bibliography_tmp.bbl.tmp > bibliography_tmp.bbl
	pdflatex bibliography_tmp
	pdflatex bibliography_tmp
	cp bibliography_tmp.pdf bibliography.pdf

webbib_tmp.bst: webbib_generated.bst
	cp $< webbib_tmp.bst


Disclaimer: This is my personal website, and represents my opinion. My formal pages and those of the school and university are linked above.