#!/usr/bin/make
all: $(patsubst %.Rtex,%.pdf,$(wildcard *.Rtex)) 

# refs.bib:

# 	wget -r -q -O refs.bib "http://127.0.0.1:23119/better-bibtex/export/collection?/2/Nate//Change - Population Ecology.bibtex"

sync.remember:
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/remembr.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/remember_irr.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/remember_grid_sweep.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/robustness_1.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/robustness_2.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/robustness_3.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/robustness_3_proflik.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/robustness_4.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/robustness_1_dv.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/robustness_2_dv.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/robustness_3_dv.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/robustness_3_dv_proflik.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/simulations/robustness_4_dv.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/civil_comments/dv_perspective_example.RDS .
	scp klone:/gscratch/comdata/users/nathante/ml_measurement_error_public/civil_comments/iv_perspective_example.RDS .


%.tex: %.Rtex remembr.RDS resources/*.R # refs.bib
	Rscript -e "library(knitr); knit('$<')"

autoupdate:
	latexmk -f -xelatex -pvc $<

%.pdf: %.tex
	latexmk -f -pdf $<

clean: 
	latexmk -C *.tex
	rm -f article.tex
	rm -f *.bbl
	rm -f *.run.xml

viewpdf: all
	evince *.pdf

spell:
	aspell -c -t --tex-check-comments -b text.tex

pdf: all

.PHONY: clean all refs.bib autoupdate
.PRECIOUS: %.tex
