aboutsummaryrefslogtreecommitdiffstats
path: root/operational-plans/Makefile
blob: ea32c494f3c6f6f71a25000adb64183e534a90db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
PDF = \
  operational-plan-2021 \
  operational-plan-2020 \
  operational-plan-2019 \
  operational-plan-2018 \
  operational-plan-2015 \
  operational-plan-2013 \
  operational-plan-2012 \

TEX = \
  operational-policy-2018_ \
  operational-policy-2018__ \


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

pdf: $(addsuffix .pdf, $(PDF))

tex: $(addsuffix .tex, $(TEX))

all: \
  $(addsuffix .pdf, $(PDF)) \
  $(addsuffix .tex, $(TEX))

# General cases

%.pdf: %.main.tex %._.tex
	pdflatex -jobname=$(basename $@) $<
	! grep -q "Rerun to get cross-references right" $(basename $@).log || \
	pdflatex -jobname=$(basename $@) $<

%._.tex: %.mdwn
	pandoc -f markdown -t latex < $< > $@

%.pdf: %.main.tex %.tex ../preamble/preamble.tex
	latex_count=5 ;\
	latex_log=$$(echo $< | sed 's/.tex/.log/') ;\

	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 $@
%_.tex: ../by-laws/%.tex
	sed -e 's/\\\(.*\)section *{/\\sub\1section\*{/g' < $< > $@
%__.tex: ../by-laws/%.tex
	sed -e 's/\\\(.*\)section *{/\\subsub\1section\*{/g' < $< > $@

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

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