-
Notifications
You must be signed in to change notification settings - Fork 2
/
make.inc
57 lines (43 loc) · 1.21 KB
/
make.inc
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
# Credit for ROOTDIR implementation:
# kenorb (https://stackoverflow.com/users/55075/kenorb),
# How to get current relative directory of your Makefile?,
# URL (version: 2017-05-23): https://stackoverflow.com/a/35698978
ROOTDIR = $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword \
$(MAKEFILE_LIST))))))
SHELL = /bin/sh
RM = rm
COPY = cp
LN = ln
R = Rscript
MD =
XARINGAN =
BUILD_DIR = $(ROOTDIR)/build
MODULE_NAME =
OUTPUT_DIR = $(patsubst %/,%,$(BUILD_DIR)/$(MODULE_NAME))
MD_OUTPUT = github_document
XARINGAN_OUTPUT = xaringan::moon_reader
MD_EXT = $(OUTPUT_DIR)/%.md : %.Rmd
XARINGAN_EXT = $(OUTPUT_DIR)/%.html : %.Rmd
ALL_FILES = $(MD) \
$(XARINGAN)
CLEAN_FILES = *_files/ \
*_cache/
define make_all
@echo All builds in $(CURDIR) complete!
endef
define setup_build_directory
mkdir -p "$@"
endef
define cleanup
-$(RM) -rf $(CLEAN_FILES)
-$(RM) -f $(ALL_FILES)
-$(RM) -rf $(BUILD_DIR)
endef
define install_deps
$(R) -e "install.packages('remotes', repos = 'https://cran.rstudio.com')" \
-e "remotes::install_deps()"
endef
define rmarkdown_render
$(R) -e "rmarkdown::render(input = '$<', output_file = '$@', \
output_format = '$(1)')"
endef