-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
111 lines (86 loc) · 2.69 KB
/
Makefile
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
## parts from makespec
# path of this file
MAKEDOC = $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
ifeq ($(words $(MAKEFILE_LIST)),1)
NAME = makedoc
GITHUB = https://github.com/jakobib/makedoc/
SOURCE = README.md
TITLE = Creating documents with makedoc
AUTHOR = Jakob Voß
endif
include $(MAKEDOC)/executables.make
include $(MAKEDOC)/configuration.make
########################################################################
COMBINED = $(NAME)-tmp.md
.SUFFIXES:
.SUFFIXES: .md .html .pdf .tmp
.PHONY: info clean
KEYWORDS := $(shell perl -ne '/keywords\s*=(.*)/ && print $$1' metadata.ini 2>/dev/null)
# combine metadata as arguments to templates (FIXME: escaping)
V_METADATA=-V abstract:'$(ABSTRACT)' -V keywords:'$(KEYWORDS)'
# which template to use
TEMPLATE=default
# create HTML paper
HTML_CSS = $(MAKEDOC)/templates/$(TEMPLATE).css
HTML_TEMPLATE = $(MAKEDOC)/templates/$(TEMPLATE).html
SLIDES_PDF_TEMPLATE = $(MAKEDOC)/templates/$(TEMPLATE)-slides.tex
V_SLIDES_PDF=
info:
@echo NAME='$(NAME)'
@echo GITHUB='$(GITHUB)'
@echo SOURCE='$(SOURCE)'
@echo TITLE='$(TITLE)'
@echo AUTHOR='$(AUTHOR)'
html: $(NAME).html
$(NAME).md: $(SOURCE)
@cp $< $@
%.html: %.tmp
@$(PANDOC) -N $< -o $@ --template $(HTML_TEMPLATE) --css $(HTML_CSS) $(V_METADATA)\
--smart $(BIBARGS) -t html5
@echo created $@
%.odt: %.tmp
@$(PANDOC) -N $< -o $@ $(V_METADATA)\
--smart $(BIBARGS) -t odt
@echo created $@
%.tmp: %.md
@echo "% $(TITLE)" > $@
@echo "% $(AUTHOR)" >> $@
@echo "% $(DATE)" >> $@
@echo "" >> $@
@cat $< >> $@
# TODO: replace document variables
slides.pdf: slides.tmp
@$(PANDOC) $< --slide-level 2 $(TOC) -t beamer -o tmp.tex --template $(SLIDES_PDF_TEMPLATE) \
$(V_METADATA) $(V_SLIDES_PDF) $(BIBARGS) $(BIBLATEX)
@perl -p -i -e 's/^\\caption{}//' tmp.tex
@$(XELATEX) tmp.tex > /dev/null
@$(XELATEX) tmp.tex > /dev/null
@mv tmp.pdf $@
# @rm -f tmp.*
slides.html: slides.tmp
@$(PANDOC) -t slidy --self-contained -s $< -o $@ $(BIBARGS)
paper.tex: paper.tmp
@$(PANDOC) -t latex -o paper.tex $< \
--template $(MAKEDOC)/templates/paper.tex --smart -V "mainfont=DejaVu Serif" \
$(BIBARGS) $(BIBLATEX)
paper.pdf: paper.tex
@rm -f *.aux *.log *.out *.bbl *.blg *.bcf
@$(XELATEX) --halt-on-error paper.tex > /dev/null
@$(BIBER) paper
@$(XELATEX) --halt-on-error paper.tex > /dev/null
handout.pdf: handout.tmp
@$(PANDOC) -o $@ $< $(BIBARGS)
clean:
@rm -f *.tex *.aux *.log *.out *.bbl *.blg *.bcf *.run.xml *.bak tmp.* *.tmp
TMP := normalize.tmp
normalize: *.md
@for f in `ls *.md`; do \
$(PANDOC) --normalize -t markdown $$f > $(TMP); \
if `diff $$f $(TMP) > /dev/null`; then \
rm $(TMP); \
else \
cp -f "$$f" "$$f.bak"; \
mv $(TMP) "$$f"; \
echo "$$f - normalized"; \
fi \
done