-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (36 loc) · 1.47 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
##
# Copyright 2017 - onwards Georgios Gousios <[email protected]>
#
##
R=Rscript -e
.PHONY: all html pdf book
CONTENT_DIRS := .
INPUTS = $(shell find $(CONTENT_DIRS) -type f -name '*.Rmd' | egrep -v "header|footer")
OUTPUTS_HTML = $(INPUTS:.Rmd=.html)
OUTPUTS_PDF = $(INPUTS:.Rmd=.pdf)
OUTPUTS_SLIDES = $(INPUTS:.Rmd=.reveal.html)
OUTPUTS_SLIDES_PDF = $(OUTPUTS_SLIDES:.reveal.html=.reveal.pdf)
%.html: %.Rmd $(DEPS)
$(R) "library(rmarkdown); render('$<', output_file=gsub(pattern = '.Rmd', '.html', basename('$<')), output_format = 'html_document')"
%.pdf: %.Rmd $(DEPS)
$(eval TMP := $(shell mktemp))
grep -v "\. \. \." < $< > $(TMP)
$(eval NEWTMP := $(shell dirname $<)/$(shell basename $(TMP)).Rmd)
mv $(TMP) $(NEWTMP)
$R "library(rmarkdown); render('$(NEWTMP)', output_file= gsub(pattern = '.Rmd', '.pdf', basename('$<')), output_format = 'pdf_document')"
rm $(NEWTMP)
%.reveal.html: %.Rmd $(DEPS)
$R "library(rmarkdown); render('$<', output_file=gsub(pattern = '.Rmd', '.reveal.html', basename('$<')), output_format = 'revealjs::revealjs_presentation')"
%.reveal.pdf: %.reveal.html $(DEPS)
docker run --rm -t -v `pwd`:/home/user astefanutti/decktape /home/user/$< /home/user/$@
all: html slides pdf
html: $(DEPS) $(INPUTS) $(OUTPUTS_HTML)
pdf: $(DEPS) $(INPUTS) $(OUTPUTS_PDF)
slides: $(DEPS) $(INPUTS) $(OUTPUTS_SLIDES)
slides_pdf: $(DEPS) $(OUTPUTS_SLIDES_PDF)
clean:
- rm *~
- rm $(OUTPUTS_PDF)
- rm $(OUTPUTS_HTML)
- rm $(OUTPUTS_SLIDES)
- rm $(OUTPUTS_SLIDES_PDF)