DOCUMENT = python-ioc

# FIGURES += fb-on-off-integ.png
# 
# FIGURES += binning.eps
# 
# DEPENDS += feedback.tikz


default: $(DOCUMENT).pdf

CONVERTED = $(patsubst %.eps,%.pdf,$(filter %.eps,$(FIGURES)))

$(DOCUMENT).pdf: $(CONVERTED) $(DEPENDS) $(FIGURES)

CITE_GREP = There were undefined references.
REF_GREP = Rerun to get cross-references right.
NOFILE_GREP = ^No file

LATEX = pdflatex

%.pdf: %.tex
	$(LATEX) </dev/null -halt-on-error $*
	if grep -q '$(CITE_GREP)\|$(REF_GREP)\|$(NOFILE_GREP)' $*.log; then \
            $(LATEX) </dev/null -halt-on-error $*; \
        fi
	rm -f $*.log

%.pdf: %.eps
	epstopdf -o $@ $<


# An insane collection of auxilliary files generated by LaTeX
CLEAN += *.dvi *.aux *.log *.out *.snm *.toc *.vrb *.nav

clean:
	rm -f $(CLEAN) $(CONVERTED)

clean-all: clean
	rm -f $(DOCUMENT).pdf $(CONVERTED) *.ps


.PHONY: default clean clean-all
