-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
71 lines (56 loc) · 2.81 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
71
PKG_ROOT = .
PKG_VERSION = $(shell gawk '/^Version:/{print $$2}' $(PKG_ROOT)/DESCRIPTION)
PKG_NAME = $(shell gawk '/^Package:/{print $$2}' $(PKG_ROOT)/DESCRIPTION)
SRC = $(wildcard $(PKG_ROOT)/src/*.cpp)
RFILES = $(wildcard $(PKG_ROOT)/R/*.R)
TESTS = $(wildcard $(PKG_ROOT)/tests/*.R)
RAWDATAR = $(wildcard $(PKG_ROOT)/data-raw/*.R)
VIGNETTES = $(addsuffix .Rmd, $(PKG_ROOT)/vignettes/$(notdir $(basename $(wildcard $(PKG_ROOT)/vignette-spinners/*.R))))
.PHONY: all check site install clean
#all: $(PKG_NAME)_$(PKG_VERSION).tar.gz
################################################################################
# build the tar ball
$(PKG_NAME)_$(PKG_VERSION).tar.gz: .document.Rout $(TESTS) .Rbuildignore
R CMD build --md5 $(build-options) $(PKG_ROOT)
.document.Rout: $(RFILES) $(SRC) $(RAWDATAR) $(VIGNETTES) $(PKG_ROOT)/DESCRIPTION README.md inst/CITATION
if [ -e "$(PKG_ROOT)/data-raw/Makefile" ]; then $(MAKE) -C $(PKG_ROOT)/data-raw/; else echo "Nothing to do"; fi
Rscript --vanilla --quiet -e "devtools::document('$(PKG_ROOT)')"
@touch $@
README.md : README.Rmd
Rscript --vanilla -e "devtools::load_all('$(PKG_ROOT)')"\
-e "knitr::knit('$(PKG_ROOT)/README.Rmd', output = 'README.md')"
check: $(PKG_NAME)_$(PKG_VERSION).tar.gz
R CMD check $(PKG_NAME)_$(PKG_VERSION).tar.gz
install: $(PKG_NAME)_$(PKG_VERSION).tar.gz
R CMD INSTALL $(PKG_NAME)_$(PKG_VERSION).tar.gz
################################################################################
# Recipes for Vignettes
$(PKG_ROOT)/vignettes/%.Rmd : $(PKG_ROOT)/vignette-spinners/%.R
R --vanilla --quiet -e "knitr::spin(hair = '$<', knit = FALSE)"
mv $(basename $<).Rmd $@
################################################################################
covr-report-%.html : $(PKG_NAME)_$(PKG_VERSION).tar.gz
R --vanilla --quiet \
-e 'library(covr)'\
-e 'x <- package_coverage(type = "$*")'\
-e 'report(x, file = "$@")'
covr-report-tests.html : $(PKG_NAME)_$(PKG_VERSION).tar.gz
R --vanilla --quiet \
-e 'library(covr)'\
-e 'x <- package_coverage(type = "tests", function_exclusions = c("plot\\\\.", "print\\\\.", "\\\\.onLoad", "\\\\.onUnload"), line_exclusions = list("R/cpr-defunct.R"))'\
-e 'report(x, file = "$@")'
covr : covr-report-all.html covr-report-tests.html covr-report-examples.html covr-report-vignettes.html
site: $(PKG_NAME)_$(PKG_VERSION).tar.gz
R --vanilla --quiet -e "pkgdown::build_site()"
################################################################################
clean:
$(RM) -f $(PKG_NAME)_$(PKG_VERSION).tar.gz
$(RM) -rf $(PKG_NAME).Rcheck
$(RM) -f .document.Rout
$(RM) -f src/*.o
$(RM) -f src/*.so
$(RM) -f vignettes/*.html
$(RM) -f *.html
################################################################################
## End of File
################################################################################