.SUFFIXES: .aux .bbl .bib .blg .dvi .html .log .pdf .ps .tex .out
PDFS = conventions.pdf sites.pdf introduction.pdf
DVIS = conventions.dvi sites.dvi introduction.dvi
PSS = conventions.ps sites.ps introduction.ps
INSTALLDIR=~/html/stacks-0.1

all: clean $(PDFS) $(PSS) $(DVIS) install

sites.pdf: conventions.aux
sites.dvi: conventions.aux

%.pdf : %.tex %.bbl %.aux
	echo "2x pdflatex $<" >> logfile.log
	pdflatex $<
	pdflatex $<

%.dvi : %.tex %.bbl %.aux
	echo "2x latex $<" >> logfile.log
	latex $<
	latex $<

%.aux : %.tex
	echo "latex $<" >> logfile.log
	latex $<
	echo "rm $*.dvi" >> logfile.log
	rm $*.dvi

%.bbl : %.aux
	echo "bibtex $<" >> logfile.log
	bibtex $<

%.ps: %.dvi
	echo "dvips -o $@ $<" >> logfile.log
	dvips -o $@ $<

clean:
	rm -f *.aux *.bbl *.blg *.dvi *.log *.pdf *.ps *.out

install:
	cp *.pdf *.dvi *.ps *.html $(INSTALLDIR)
	cp Makefile *.tex *.html *.bib logfile.log $(INSTALDIR)/src
