-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (61 loc) · 2.88 KB
/
Makefile
File metadata and controls
78 lines (61 loc) · 2.88 KB
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
72
73
74
75
76
77
78
# Makefile for the cpr package
PKG_ROOT = .
PKG_VERSION = $(shell gawk '/^Version:/{print $$2}' $(PKG_ROOT)/DESCRIPTION)
PKG_NAME = $(shell gawk '/^Package:/{print $$2}' $(PKG_ROOT)/DESCRIPTION)
CRAN = "https://cran.rstudio.com"
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 = $(PKG_ROOT)/vignettes/cpr.Rmd
VIGNETTES += $(PKG_ROOT)/vignettes/cnr.Rmd
.PHONY: all check 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
if [ -e "$(PKG_ROOT)/data-raw/Makefile" ]; then $(MAKE) -C $(PKG_ROOT)/data-raw/; else echo "Nothing to do"; fi
Rscript --vanilla --quiet -e "options(repo = c('$(CRAN)', '$(BIOC)'))" \
-e "devtools::document('$(PKG_ROOT)')"
@touch $@
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 $@
# for testing a vignette without having to install the package
%.html : vignettes/%.Rmd
R -e "setwd('vignettes')"\
-e "devtools::document()"\
-e "rmarkdown::render('$(addsuffix .Rmd, $(basename $(notdir $<)))')"
mv $(addsuffix .html, $(basename $<)) $@
################################################################################
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
################################################################################
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
################################################################################