BASENAME=linear_regression
PYFILES=$(wildcard *.py)
PYPDFFILES=$(PYFILES:.py=.pdf)

pdf : $(BASENAME).pdf $(PYPDFFILES)

$(BASENAME).pdf : $(BASENAME).tex
	pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && pdflatex -interaction=scrollmode $< || true

$(PYPDFFILES) : %.pdf : %.py
	python $<

clean :
	rm -f *~ $(BASENAME).aux $(BASENAME).log $(BASENAME).out $(BASENAME).toc $(BASENAME).nav $(BASENAME).snm $(BASENAME).vrb

cleanall : clean
	rm -f $(BASENAME).pdf

watch :
	while true; do ! make -q pdf && make pdf; sleep 0.5; done


