noarg:
	echo -e '\nThis script do not run without arguments. Run for example:\n\n    make 2011-02-13-board-notes.pdf\n    make all\n'


all: \
2013-03-23-annual.pdf \
2013-02-12-board.pdf

%.pdf: %.tex ../preamble/preamble.tex
	latex_count=5 ;\
	latex_log=$$(echo $@ | sed 's/.pdf/.log/') ;\
	pdflatex $< ;\
	while egrep -s 'Rerun (LaTeX|to get cross-references right)' $$latex_log && [ $$latex_count -gt 0 ] ;\
	   do echo "Rerunning latex...." ;  pdflatex $< ;\
	   latex_count=`expr $$latex_count - 1`;\
	done;

2013-03-23-annual.pdf: 2013-03-23-annual.tex \
../preamble/preamble.tex \
../annual-reports/annual-report-2013.tex \
../by-laws/by-laws-2013.tex \
../operational-plans/operational-plan-2013.tex \
../annual-reports/2013-03-23-revisionsberaettelse.jpg
	latex_count=5 ;\
	latex_log=$$(echo $@ | sed 's/.pdf/.log/') ;\
	pdflatex $< ;\
	while egrep -s 'Rerun (LaTeX|to get cross-references right)' $$latex_log && [ $$latex_count -gt 0 ] ;\
	   do echo "Rerunning latex...." ;  pdflatex $< ;\
	   latex_count=`expr $$latex_count - 1`;\
	done;

# Sends to fripost.org for publication
send:
	rsync -ruvp --chmod=Dugo+rx,Fugo+r *.pdf fripost@fripost.org:fripost.org/minutes/

# Clean up
clean:
	rm *.aux *.bbl *.dvi *.log *.nav *.out *.snm *.toc *~; rm -f test test.d/test; rmdir test.d