-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (47 loc) · 1.69 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
68
69
70
## All Rmarkdown files in the working directory
SRCDIR := source
OUTDIR := docs
PLANTUML := $(wildcard $(SRCDIR)/*.plantuml)
RMD := $(wildcard $(SRCDIR)/*.Rmd)
HTML := $(RMD:.Rmd=.html)
HTML := ${subst $(SRCDIR),$(OUTDIR),$(HTML)}
PDF := $(RMD:.Rmd=.pdf)
PDF := ${subst $(SRCDIR),$(OUTDIR),$(PDF)}
all: clean figs html pdf
############# figs #############
figs:
plantuml $(PLANTUML) -o figs
plantuml $(PLANTUML) -tsvg -o figs
clean_figs:
rm -rf figs
############# html #############
html: $(HTML)
$(OUTDIR)/%.html: $(SRCDIR)/%.Rmd
@Rscript -e "rmarkdown::render('$<', output_dir = './$(OUTDIR)/', output_format = 'html_document')"
clean_html:
rm -f $(HTML)
############# pdf #############
pdf: html
wkhtmltopdf ./docs/index.html ./docs/index.pdf
clean_pdf:
rm -f $(PDF)
############# Help targets #############
clean: clean_pdf clean_html clean_figs
############# Help targets #############
list_variables:
@echo
@echo "#############################################"
@echo "## Variables ################################"
@make -pn | grep -A1 "^# makefile"| grep -v "^#\|^--" | sort | uniq
@echo "#############################################"
@echo ""
## from https://stackoverflow.com/a/26339924/632423
list_targets:
@echo
@echo "#############################################"
@echo "## Targets ###############################"
@make -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
@echo "#############################################"
@echo
list: list_variables list_targets
.PHONY: list clean clean_pdf clean_html clean_figs figs all