ALL: visual_statistics.pdf

%.pdf: %.tex Makefile
	xelatex --enable-write18 $< && xelatex $< && xelatex $<

clean:
	rm -rf *.*~ 01_20.* *.rd trees.txt graph.pdf data/bugs_new.txt

script:
	grep "^\\\\chapter\|^\\\\section\|^\\\\subsection\|^> \|^+ \|^%> " visual_statistics.tex | sed -e "s/^\\\/\n# \\\/g" | sed -e "s/^%*> /\n/g" | sed -e "s/^+ //g" > visual_statistics.r

plots:
	cd supp/sweave/ && R CMD Sweave test_sweave.rnw && pdflatex test_sweave.tex && cp -f test_sweave.pdf ../../pics/ && cd ../../
	Rresults visual_statistics.r && cd pics && . ./crop_all && . ./svg2pdf_all

new:
	make script && make plots && make clean
