-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
124 lines (102 loc) · 3.89 KB
/
Copy pathmakefile
File metadata and controls
124 lines (102 loc) · 3.89 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
## ---------------------------------------------------------------------------
# -- Global vars ------------------------------------------------------------
## ---------------------------------------------------------------------------
basedir=$(PWD)
sources := $(filter-out $(wildcard extras/*.md), $(wildcard */*.md))
inputdir=$(basedir)/source
outputdir=$(basedir)/output
templatedir=$(inputdir)/templates
styledir=$(basedir)/style
meta=$(basedir)/metadata.yaml
# CHANGE: The name of the generated files
out_name := thesis
# get everything but the pdf output on cleaning
remove := $(filter-out $(wildcard $(outputdir)/*.pdf),$(wildcard $(outputdir)/*))
# -- Bib Vars --------------------------------------------------------------
# the dir where all the citation styles are
bib_styles = $(styledir)/citation_styles
# this is your .bib file
bibfile = $(inputdir)/references.bib
# common citation styles for CS
bib_acm_long = $(bib_styles)/acm-sig-proceedings-long-author-list.csl
bib_acm_short = $(bib_styles)/acm-sig-proceedings.csl
bib_ieee = $(bib_styles)/ieee-with-url.csl
# CHANGE: change this to use your custom citation style
bib_style = $(bib_ieee)
## ---------------------------------------------------------------------------
# -- Rendering --------------------------------------------------------------
## ---------------------------------------------------------------------------
# pandoc custom command
# Don't change this unless you know what you're doing
# Errors are reported in $(outputdir)/pandoc.log
define pandoc
pandoc $(meta) \
$(sources) \
-o "$(outputdir)/$(1)" \
--template="$(styledir)/template.tex" \
--bibliography="$(bibfile)" \
--filter $(styledir)/pandoc-minted.py \
--csl="$(bib_style)" \
--chapters \
-N \
$(2) 2>"$(outputdir)"/pandoc.log
endef
all: pdf
single:
@echo "Building $(chapter_name) only"
pandoc $(meta) \
$(chapter_name) \
-o "$(outputdir)/single.tex" \
--template="$(styledir)/standalone.tex" \
--filter $(styledir)/pandoc-minted.py \
--bibliography="$(bibfile)" \
--csl="$(bib_style)" \
-N
latexmk -f -silent -xelatex -shell-escape -outdir=$(outputdir) single.tex \
&> $(outputdir)/latex.log
pdf:
@echo "Building $(out_name).pdf..."
@$(call pandoc,"$(out_name).tex")
latexmk -f -silent -xelatex -shell-escape -outdir=$(outputdir) $(out_name).tex \
&> $(outputdir)/latex.log
tex:
@echo "Building $(out_name).tex..."
@$(call pandoc,"$(out_name).tex")
docx:
@echo "Building $(out_name).docx..."
pandoc "$(inputdir)"/*.md \
-o "$(outputdir)/thesis.docx" \
--bibliography="$(bibfile)" \
--csl="$(bib_style)" \
--toc
html:
@echo "Building $(out_name).html..."
pandoc "$(inputdir)"/*.md \
-o "$(outputdir)/$(out_name).html" \
--standalone \
--template="$(styledir)/template.html" \
--bibliography="$(bibfile)" 2>"$(outputdir)"/pandoc.log \
--csl="$(bib_style)" \
--include-in-header="$(styledir)/style.css" \
--toc \
--number-sections
rm -rf "$(outputdir)/source"
mkdir "$(outputdir)/source"
cp -r figures "$(outputdir)/source/figures"
help:
@echo ' '
@echo 'Makefile for the Markdown thesis '
@echo ' '
@echo 'Usage: '
@echo ' make html generate a web version '
@echo ' make pdf generate a PDF file '
@echo ' make docx generate a Docx file '
@echo ' make tex generate a Latex file '
@echo ' '
@echo ' '
@echo ' '
@echo 'get local templates with: pandoc -D latex/html/etc '
@echo 'or generic ones from: https://github.com/jgm/pandoc-templates '
.PHONY: help pdf docx html tex
clean:
rm -r $(remove)