-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (60 loc) · 1.95 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
# Makefile
#
# Converts Markdown to other formats (HTML, PDF, DOCX, RTF, ODT, EPUB) using Pandoc
# <http://johnmacfarlane.net/pandoc/>
#
# Run "make" (or "make all") to convert to all other formats
#
# Run "make clean" to delete converted files
# Convert all files in this directory that have a .md suffix
SOURCE_DIR=src
OUTPUT_DIR=pdf
SOURCE_DOCS := $(wildcard $(SOURCE_DIR)/*.md $(SOURCE_DIR)/*/*.md)
EXPORTED_DOCS=$(SOURCE_DOCS:$(SOURCE_DIR)/%.md=$(OUTPUT_DIR)/%.pdf)
ALREADY_EXPORTED_DOCS=$(wildcard $(OUTPUT_DIR)/*.pdf $(OUTPUT_DIR)/*/*.pdf)
# $(SOURCE_DOCS:.md=.html) \
# $(SOURCE_DOCS:.md=.pdf) \
# $(SOURCE_DOCS:.md=.docx) \
# $(SOURCE_DOCS:.md=.rtf) \
# $(SOURCE_DOCS:.md=.odt) \
# $(SOURCE_DOCS:.md=.epub)
RM=rm
MKDIR=mkdir
PANDOC=pandoc
PANDOC_OPTIONS=
PANDOC_HTML_OPTIONS=--to html5
PANDOC_PDF_OPTIONS=--pdf-engine=xelatex -V mainfont="WenQuanYi Micro Hei"
PANDOC_DOCX_OPTIONS=
PANDOC_RTF_OPTIONS=
PANDOC_ODT_OPTIONS=
PANDOC_EPUB_OPTIONS=--to epub3
# Pattern-matching Rules
$(OUTPUT_DIR)/%.html : $(SOURCE_DIR)/%.md
$(MKDIR) -p $(dir $@)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_HTML_OPTIONS) -o $@ $<
$(OUTPUT_DIR)/%.pdf : $(SOURCE_DIR)/%.md
$(MKDIR) -p $(dir $@)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_PDF_OPTIONS) -o $@ $<
$(OUTPUT_DIR)/%.docx : $(SOURCE_DIR)/%.md
$(MKDIR) -p $(dir $@)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_DOCX_OPTIONS) -o $@ $<
$(OUTPUT_DIR)/%.rtf : $(SOURCE_DIR)/%.md
$(MKDIR) -p $(dir $@)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_RTF_OPTIONS) -o $@ $<
$(OUTPUT_DIR)/%.odt : $(SOURCE_DIR)/%.md
$(MKDIR) -p $(dir $@)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_ODT_OPTIONS) -o $@ $<
$(OUTPUT_DIR)/%.epub : $(SOURCE_DIR)/%.md
$(MKDIR) -p $(dir $@)
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_EPUB_OPTIONS) -o $@ $<
# Targets and dependencies
.PHONY: all clean
all : $(EXPORTED_DOCS)
clean:
ifneq ("$(ALREADY_EXPORTED_DOCS)", "")
$(RM) $(ALREADY_EXPORTED_DOCS)
endif
test:
@echo $(SOURCE_DOCS)
@echo $(EXPORTED_DOCS)
@echo $(ALREADY_EXPORTED_DOCS)