aboutsummaryrefslogtreecommitdiffstats
path: root/resources/Makefile-common
blob: ce35c92e9ae86b3a58f71f87a9406e44b52c2ab3 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- mode: makefile ; -*-
# This Makefile is used as common denominator for the compilation of a
# PDF file from a minutes.
#
# Commands
# 
#   compile:     Create the pdf file
#   
#     Mandatory arguments
#       FILE -- name of tex file without surfixes
#     Optional arguments
#       PREAMBLE -- path to preamble without surfixes (defaults)
#       FILES_TEX -- list of dependency tex-files without surfixes
#       FILES_JPG -- list of dependency jgp-images without surfixes
#
#   send:     Sends pdf files to server
#
#     Mandatory arguments
#       SEND_FILES -- list of files to send (without prefixes)
#
#   clean:     clears all generated files
#

FILE =
PREAMBLE = ../preamble/preamble
FILES_TEX =
FILES_JPG =
FILES_PDF =
SEND_FILES =

input = $(FILE).tex
output = $(FILE).pdf
preamble = $(PREAMBLE).tex
files-tex = $(foreach f, $(FILES_TEX), $(f).tex)
files-jpg = $(foreach f, $(FILES_JPG), $(f).jpg)
files-pdf = $(foreach f, $(FILES_PDF), $(f).pdf)
send-files = $(foreach f, $(SEND_FILES), $(f).pdf)

compile: $(output)

# The most general latex compilation command
$(output): $(input) $(preamble) $(files-tex) $(files-jpg) $(files-pdf)
	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;

# Special treatment of minutes complemented with secrets
%-complete.tex: %.tex %.sed.gpg
	gpg --decrypt < $(subst .tex,.sed.gpg,$<) > $(subst .tex,_.sed,$<)
	sed -f $(subst .tex,_.sed,$<) < $< > $@
	rm -f $(subst .tex,_.sed,$<)

# Clean up
clean:
	rm -f *.aux *.bbl *.dvi *.log *.nav *.out *.snm *.toc *~

# Sends to fripost.org for publication
send:
	rsync -ruvp --chmod=Dugo+rx,Fugo+r $(send-files) www.fripost.org:/var/www/fripost.org/minutes
	@echo; echo Now avialable as; for f in $(send-files); do echo " - https://fripost.org/minutes/$$f"; done


# Help
help:
	@echo 'This script do not run without arguments. Run for example:'
	@echo
	@for f in $(SEND_FILES) ; do echo "    $ make $$f"; done
	@echo '    $ make all'
	@echo '    $ make send'
	@echo '    $ make clean'