#!/usr/bin/make

all: $(patsubst %.Rnw,%.pdf,$(wildcard *.Rnw)) 
pdf: all

%.tex: %.Rnw
	#python3 ../code/LDA/make_latex_files.py
	Rscript -e "library(knitr); knit('$<')"

%.pdf: %.tex vc
	grep -v -e '^.usepackage.longtable.$$' $<| sponge $<
	latexmk -f -pdf $<

clean: 
	latexmk -C *.tex
	rm -f *.tmp
	rm -f *.tex
	rm -rf figure/
	rm -f *.bbl
	rm -rf cache/
	rm -rf *.run.xml
	rm -f vc

viewpdf: all
	evince *.pdf

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

vc:
	resources/vc-git

.PHONY: clean all
.PRECIOUS: %.tex
