-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
77 lines (56 loc) · 1.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
.PHONY: all clean default print
.SILENT: print
default: all
SOURCES_DOT = $(wildcard *.dot)
SOURCES_MD = $(wildcard *-cheat-sheet.md)
SOURCES_YML = $(wildcard *-cheat-sheet.yml)
OBJECTS_DOT_SVG = $(SOURCES_DOT:.dot=.svg)
OBJECTS_HTML = $(SOURCES_MD:.md=.html)
OBJECTS_PDF = $(SOURCES_MD:.md=.pdf)
OBJECTS_TEX = $(SOURCES_MD:.md=.tex)
META_URL_COLOR = "urlcolor"
META_LINK_COLOR = "linkcolor"
META_MONO_COLOR = "monospacecolor"
PRINT_COLOR = "black"
OBJECTS = \
$(OBJECTS_DOT_SVG) \
$(OBJECTS_HTML) \
$(OBJECTS_PDF) \
$(OBJECTS_TEX)
all: $(OBJECTS)
$(OBJECTS):
$(OBJECTS_HTML): $(OBJECTS_DOT_SVG)
$(OBJECTS_PDF): $(OBJECTS_DOT_SVG)
PANDOC = pandoc
PANDOC_PDF_ENGINE = xelatex
PANDOC_FLAGS = \
--standalone \
--from=markdown+yaml_metadata_block
PANDOC_HTML_FLAGS = \
$(PANDOC_FLAGS) \
--template=cheat-sheet.html
PANDOC_TEX_FLAGS = \
$(PANDOC_FLAGS) \
--template=cheat-sheet.tex \
PANDOC_PDF_FLAGS = \
$(PANDOC_TEX_FLAGS) \
--pdf-engine=$(PANDOC_PDF_ENGINE) \
PANDOC_PRINT_FLAGS = \
--metadata=$(META_LINK_COLOR):$(PRINT_COLOR) \
--metadata=$(META_MONO_COLOR):$(PRINT_COLOR) \
--metadata=$(META_URL_COLOR):$(PRINT_COLOR) \
%.svg: %.dot
dot -Tsvg -o $@ $<
%.html: %.md %.yml cheat-sheet.html
$(PANDOC) $(PANDOC_HTML_FLAGS) -o $@ $*.yml $<
%.pdf: %.md %.yml cheat-sheet.tex
$(PANDOC) $(PANDOC_PDF_FLAGS) -o $@ $*.yml $<
%.tex: %.md %.yml cheat-sheet.tex
$(PANDOC) $(PANDOC_TEX_FLAGS) -o $@ $*.yml $<
print:
$(foreach file, $(SOURCES_YML), \
echo Creating printer friendly pdf for $(patsubst %.yml, %, $(file)); \
$(PANDOC) $(PANDOC_TEX_FLAGS) $(PANDOC_PRINT_FLAGS) -o $(patsubst %.yml, %_print.pdf, $(file)) $(file) $(patsubst %.yml, %.md, $(file)); \
)\
clean:
rm -f $(OBJECTS)