.SILENT:

.PHONY : all clean

LATEX    = pdflatex
PAPER    = moosivp-helm

main: clear_material paper

full: tools_material paper

paper:
	$(LATEX) $(PAPER)
	bibtex $(PAPER)
	makeindex $(PAPER)
	makeindex $(PAPER).adx -o $(PAPER).and
	makeindex $(PAPER).bdx -o $(PAPER).bnd
	makeindex $(PAPER).cdx -o $(PAPER).cnd
	$(LATEX) $(PAPER)

clear_material:
	echo "% Empty file, built by makefile" > tools.tex

tools_material:
	./build_content.sh
	fgrep xchap ../toolsdoc/moosivp-tools.tex > tools.tex

quick: 
	$(LATEX) $(PAPER)

pdfo: main
	open $(PAPER).pdf &

pdfof: full
	open $(PAPER).pdf &

pdfv:
	open $(PAPER).pdf &

clean:
	rm -f $(PAPER).dvi *~  $(PAPER).log $(PAPER).pdf  $(PAPER).ind
	rm -f $(PAPER).bbl $(PAPER).blg $(PAPER).ps $(PAPER).aux
	rm -f $(PAPER).toc $(PAPER).idx $(PAPER).ilg
	rm -f $(PAPER).and $(PAPER).bnd  $(PAPER).cnd $(PAPER).mdx
	rm -f $(PAPER).out $(PAPER).adx $(PAPER).bdx $(PAPER).cdx
	rm -f xchap* figures/*.png tools.tex