-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (46 loc) · 1.53 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
SRC:=$(filter $(wildcard *-src.Rmd), $(wildcard *.Rmd))
SLIDES:=$(filter $(wildcard *-slides.Rmd), $(wildcard *.Rmd))
SLIDES_HTML:=$(patsubst %.Rmd, %.html, $(SLIDES))
SLIDES_PDF:=$(patsubst %.html, %.pdf, $(SLIDES_HTML))
SLIDES_PDF:=$(addprefix pdf/, $(SLIDES_PDF))
PRINT:=$(filter $(wildcard *-print.Rmd), $(wildcard *.Rmd))
PRINT_HTML:=$(patsubst %.Rmd, %.html, $(PRINT))
PRINT_PDF:=$(patsubst %.html, %.pdf, $(PRINT_HTML))
PRINT_PDF:=$(addprefix pdf/, $(PRINT_PDF))
TEX:=$(wildcard *.tex)
HANDOUT:=$(patsubst %-handout.tex, %-handout.pdf, $(TEX))
HANDOUT:=$(addprefix pdf/, $(HANDOUT))
.PHONY : all
all : html pdf print handout cleanup
.PHONY : test
test :
@echo TEX: $(TEX)
@echo HANDOUT: $(HANDOUT)
html : $(SLIDES_HTML)
pdf : $(SLIDES_PDF)
print: $(PRINT_PDF)
handout : $(HANDOUT) $(PRINT_PDF) $(PRINT_HTML)
# render RmD to html
%slides.html : %slides.Rmd
R -e 'rmarkdown::render("$<", output_file = "$@")'
%print.html : %print.Rmd
R -e 'rmarkdown::render("$<", output_file = "$@")'
# Convert html to pdf
pdf/%slides.pdf : %slides.html %print.html
R -e 'pagedown::chrome_print("$<", "$@")'
pdf/%print.pdf : %print.html
R -e 'pagedown::chrome_print("$<", "$@")'
# Create print version of slideshow
pdf/%-handout.pdf : %-handout.tex pdf/%-print.pdf
pdflatex -output-directory pdf $<
# Remove temporary files used in building pdf
.PHONY : cleanup
cleanup :
rm -f ./pdf/*.aux
rm -f ./pdf/*.log
rm -f ./pdf/*-print.pdf
@echo Everything is up to date.
clean :
rm -f ./*.html
rm -f ./pdf/*.pdf
.INTERMEDIATE : $(PRINT_HTML)