TOPTEX=join
ALLTEX=$(wildcard *.tex)
ALLBIB=$(wildcard *.bib)

all: $(TOPTEX).bbl $(TOPTEX).pdf

words:
	echo estimate of word count which is usually too large
	detex $(TOPTEX).tex | wc

bundle:
	rm project.zip
	zip -9 project.zip $(ALLTEX) $(ALLBIB) $(TOPTEX).pdf

$(TOPTEX).bbl: $(ALLBIB)
	echo rebuilding after bibliopgraphy changed
	latex $(TOPTEX)
	latex $(TOPTEX)

$(TOPTEX).dvi: $(ALLTEX) $(ALLBIB)
	latex $(TOPTEX)

%.ps: %.dvi
	dvips -Ppdf -G0 -o $@ -t a4 $*

%.pdf: %.ps
	ps2pdf -dAutoFilterColorImages=false -dEncodeColorImages=false -dPreserveEPSInfo=true $*.ps
