-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (43 loc) · 1.15 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
SHELL = /bin/sh
RM = rm
ECHO = echo
COPY = cp
R = R
RSCRIPT = Rscript
ROPTS = --slave
RMD_FILENAME = simulations
HTML = $(RMD_FILENAME).html
PDF = $(RMD_FILENAME).pdf
MD = $(RMD_FILENAME).md
HTML_OUTPUT = html_document
PDF_OUTPUT = pdf_document
MD_OUTPUT = github_document
HTML_EXT = %.html : %.Rmd
PDF_EXT = %.pdf : %.Rmd
MD_EXT = %.md : %.Rmd
ALL_FILES = $(PDF) \
$(MD) \
$(HTML)
CLEAN_FILES = *_files/ \
*_cache/ \
$(PDF:.pdf=.synctex.gz) \
$(PDF:.pdf=.tex)
define cleanup
-$(RM) -rf $(CLEAN_FILES)
-$(RM) -f $(ALL_FILES)
endef
define rmarkdown_render
$(R) $(ROPTS) -e "rmarkdown::render(input='$<', output_file='$@', \
output_format='$(1)')"
endef
.SILENT :
.PHONY : all clean
all : $(ALL_FILES)
clean :
$(call cleanup)
$(HTML) : $(HTML_EXT)
$(call rmarkdown_render,$(HTML_OUTPUT))
$(PDF) : $(PDF_EXT)
$(call rmarkdown_render,$(PDF_OUTPUT))
$(MD) : $(MD_EXT)
$(call rmarkdown_render,$(MD_OUTPUT))