-
Notifications
You must be signed in to change notification settings - Fork 0
/
old-Makefile
96 lines (66 loc) · 2.43 KB
/
old-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
# 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 the md subirectory that have a .md suffix
SOURCE_DOCS := $(wildcard *.md)
# I’d really prefer to keep outputs in their own subdirectories, but this is fine for now.
OUTPUT_DOCS=\
$(SOURCE_DOCS:.md=.html) \
$(SOURCE_DOCS:.md=.pdf) \
# $(SOURCE_DOCS:.md=.docx) \
# $(SOURCE_DOCS:.md=.rtf) \
# $(SOURCE_DOCS:.md=.odt) \
# $(SOURCE_DOCS:.md=.epub)
HTML_DOCS=$(SOURCE_DOCS:.md=.html)
LATEX_DOCS=$(SOURCE_DOCS:.md=.tex)
PDF_DOCS=$(SOURCE_DOCS:.md=.pdf)
RM=/bin/rm
PANDOC=/usr/local/bin/pandoc
PANDOC_OPTIONS=--standalone --number-sections
PANDOC_HTML_OPTIONS=--to html5 --default-image-extension=png --mathjax --template=easy_template.html -M fontsize=18px -M maxwidth=50em
PANDOC_PDF_OPTIONS=--default-image-extension=pdf
PANDOC_LATEX_OPTIONS=--default-image-extension=pdf
PANDOC_DOCX_OPTIONS=
PANDOC_RTF_OPTIONS=
PANDOC_ODT_OPTIONS=
PANDOC_EPUB_OPTIONS=--to epub3
PANDOC_BOOK_OPTIONS=--top-level-division=chapter --toc --toc-depth=2
# Pattern-matching Rules
%.html : %.md Makefile
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_HTML_OPTIONS) -o $@ $<
%.pdf : %.md Makefile
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_PDF_OPTIONS) -o $@ $<
%.tex : %.md Makefile
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_LATEX_OPTIONS) -o $@ $<
%.docx : %.md
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_DOCX_OPTIONS) -o $@ $<
%.rtf : %.md
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_RTF_OPTIONS) -o $@ $<
%.odt : %.md
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_ODT_OPTIONS) -o $@ $<
%.epub : %.md
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_EPUB_OPTIONS) -o $@ $<
# Targets and dependencies
.PHONY: all latex html pdf book clean # publish
all : $(OUTPUT_DOCS)
latex : $(LATEX_DOCS)
html : $(HTML_DOCS)
pdf : $(PDF_DOCS)
#
# I really want to use "-t chunkedhtml" but it doesn't play well with easy_template.html.
#
bookhtml : $(SOURCE_DOCS)
$(PANDOC) $(PANDOC_OPTIONS) --toc --toc-depth=2 ${PANDOC_HTML_OPTIONS} -o Book.html $(SOURCE_DOCS)
bookpdf : ${SOURCE_DOCS}
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_BOOK_OPTIONS) $(PANDOC_PDF_OPTIONS) -o Book.pdf $(SOURCE_DOCS)
books: bookhtml bookpdf
clean:
- $(RM) $(OUTPUT_DOCS)
# publish: all
# rsync -avu $(OUTPUT_DOCS) ../Web/notes
# rsync -avru Fig/*.pdf Fig/*.png Fig/derived-maps ../Web/notes/Fig/