# This is a modification of Medlock's makefile
# I'm not happy with it, but it is better than
# what I had.

#export TEXINPUTS:=.:/home/treluga/.texmf:

all: foils.pdf

ftp:
	scp foils.pdf amath.washington.edu:~/

FIGS = 
PDFFIGS = 
BIB = foils.bib

.PHONY : 	clean all 

pdffigs:	$(PDFFIGS)

# the native image format for pdfelatex seems to be jpg
figures/%.jpg:	figures/%.eps
	convert $< $@

figures/%.pdf:	figures/%.eps
	epstopdf $<

%.dvi: %.tex foilheader.tex
	@if [ -f $(BIB) ]; \
		then if [ ! -f $*.aux ]; \
			then elatex --interactive errorstopmode $*; \
		fi; \
		if [ ! -f $*.bbl ]; \
			then bibtex $* && elatex --interaction batchmode $*; \
		fi; \
	fi
	elatex  --interaction errorstopmode  $*
	@if grep -s "Rerun to get cross" $*.log; \
		then elatex --interaction batchmode  $*; \
	fi

%.ps: %.dvi
	dvips -K -t landscape -o $@ $<
#	dvips -o $@ $*
#	dvips -q -D1000 -Z -t landscape -o $@ $<
#	dvips -q -N -K -D1000 -Z -t landscape -o $@ $<
#	dvips -o $@ $<
#	dvips -t landscape -Pamz -Pcmz -D8000 -o $@ $<

%.pdf:		%.tex foilheader.tex pdffigs
	@if [ -f $(BIB) ]; \
		then if [ ! -f $*.aux ]; \
			then pdfelatex -interaction=errorstopmode $*; \
		fi; \
		if [ ! -f $*.bbl ]; \
			then bibtex $* && pdfelatex --interaction=batchmode $*; \
		fi; \
	fi
	pdfelatex --interaction=errorstopmode $*
	@if grep -s "Rerun to get cross" $*.log; \
		then pdfelatex --interaction=batchmode  $*; \
	fi

clean:
		/bin/rm *.aux *.bbl *.blg *.dvi *.log *.ps *.pdf
