ALL = \
  operational-plan-2018 \
  operational-plan-2015 \
  operational-plan-2013 \
  operational-plan-2012 \

common-makefile = ../resources/Makefile-common

all: $(ALL)

$(ALL): %: %.pdf

# General cases

%.pdf: %.main.tex %.tex ../preamble/preamble.tex
	latex_count=5 ;\
	latex_log=$$(echo $< | sed 's/.tex/.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
	mv $$(echo $< | sed 's/.tex/.pdf/') $@

# Special cases

operational-plan-2018.main.tex: operational-policy-2018_.tex
	touch $@
operational-policy-2018_.tex: ../by-laws/operational-policy-2018.tex
	sed -e 's/\\\(.*\)section *{/\\sub\1section{/g' < $< > $@


send:
	make -f $(common-makefile) send SEND_FILES="$(ALL)"

clean:
	rm *.aux *.bbl *.dvi *.log *.nav *.out *.snm *.toc *~