-
Notifications
You must be signed in to change notification settings - Fork 10
/
rules.mk
232 lines (173 loc) · 6.17 KB
/
rules.mk
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
REXE = $(shell which R) --vanilla
RSESSION = emacs -f R
RCMD = $(REXE) CMD
RCMD_ALT = R --no-save --no-restore CMD
RSCRIPT = Rscript --vanilla
REPODIR = ../www
MANUALDIR = ../www/manuals/$(PKG)
PDFLATEX = pdflatex
BIBTEX = bibtex
MAKEIDX = makeindex
RM = rm -f
CP = cp
TOUCH = touch
INSTALL = install
PKG = $(shell perl -ne 'print $$1 if /Package:\s+((\w+[-\.]?)+)/;' DESCRIPTION)
VERSION = $(shell perl -ne 'print $$1 if /Version:\s+((\d+[-\.]?)+)/;' DESCRIPTION)
PKGVERS = $(PKG)_$(VERSION)
SOURCE=$(sort $(wildcard R/*R src/*.c src/*.h data/* examples/*))
CSOURCE=$(sort $(wildcard src/*.c))
TESTS=$(sort $(wildcard tests/*R))
default:
@echo $(PKGVERS)
.PHONY: binary check clean covr debug default fresh \
htmlhelp manual news publish qcheck qqcheck \
remove revdeps rhub rsession session vignettes win wind xcheck \
xcovr xxcheck ycheck
.dist manual vignettes: export R_QPDF=qpdf
.headers: export LC_COLLATE=C
.roxy .headers .dist manual vignettes: export R_HOME=$(shell $(REXE) RHOME)
check xcheck xxcheck: export FULL_TESTS=yes
.dist .tests revdeps session check xcheck xxcheck: export R_KEEP_PKG_SOURCE=yes
.tests revdeps xcheck: export R_PROFILE_USER=$(CURDIR)/.Rprofile
.tests revdeps session xxcheck vignettes data manual: export R_LIBS=$(CURDIR)/library
session: export R_DEFAULT_PACKAGES=datasets,utils,grDevices,graphics,stats,methods,tidyverse,$(PKG)
xcheck: export _R_CHECK_DEPENDS_ONLY_=true
debug: export RSESSION=R -d gdb
rsession: export RSESSION=R
inst/include/%.h: src/%.h
$(CP) $^ $@
dist: .dist
install: .install
roxy: .roxy
htmlhelp: install news manual
rsync --delete -a library/$(PKG)/html/ $(MANUALDIR)/html
rsync --delete --exclude=aliases.rds --exclude=paths.rds --exclude=$(PKG).rdb --exclude=$(PKG).rdx --exclude=macros -a library/$(PKG)/help/ $(MANUALDIR)/help
(cd $(MANUALDIR); (cat links.ed && echo w ) | ed - html/00Index.html)
$(CP) $(PKG).pdf $(MANUALDIR)
$(CP) $(REPODIR)/assets/R.css $(MANUALDIR)/html
vignettes: manual install
$(MAKE) -C www
news: library/$(PKG)/html/NEWS.html
NEWS: .NEWS
.NEWS: inst/NEWS
$(TOUCH) $@
inst/NEWS: inst/NEWS.Rd
$(RCMD) Rdconv -t txt $^ -o $@
library/$(PKG)/html/NEWS.html: inst/NEWS.Rd
$(RCMD) Rdconv -t html $^ -o $@
session: install
exec $(RSESSION)
debug: session
rsession: session
revdeps: install
mkdir -p library check
$(REXE) -e "pkgs <- strsplit('$(REVDEPS)',' ')[[1]]; download.packages(pkgs,destdir='library',repos='https://mirrors.nics.utk.edu/cran/')"
$(RCMD) check --as-cran --library=library -o check library/*.tar.gz
.roxy: .source .headers
$(REXE) -e "pkgbuild::compile_dll(); devtools::document(roclets=c('rd','collate','namespace'))"
$(TOUCH) $@
.headers: $(HEADERS)
make $(HEADERS)
$(TOUCH) $@
.includes: $(INCLUDES)
make $(INCLUDES)
$(TOUCH) $@
.source: $(SOURCE)
$(TOUCH) $@
.testsource: $(TESTS)
$(TOUCH) $@
.dist: .roxy .NEWS .source .testsource .includes .headers
$(RCMD) build --force --no-manual --resave-data --compact-vignettes=both --md5 .
$(TOUCH) $@
binary: dist
mkdir -p plib
$(RCMD) INSTALL --build --library=plib --preclean --clean $(PKGVERS).tar.gz
rm -rf plib
publish: dist manual htmlhelp
$(RSCRIPT) -e 'drat::insertPackage("$(PKGVERS).tar.gz",repodir="$(REPODIR)",action="prune")'
-$(RSCRIPT) -e 'drat::insertPackage("$(PKGVERS).tgz",repodir="$(REPODIR)",action="prune")'
-$(RSCRIPT) -e 'drat::insertPackage("$(PKGVERS).zip",repodir="$(REPODIR)",action="prune")'
rhub:
$(REXE) -e 'library(rhub); check_for_cran(); check_on_windows(); check(platform="macos-highsierra-release-cran");'
covr: covr.rds
covr.rds: DESCRIPTION
$(REXE) -e 'library(covr); package_coverage(type="all") -> cov; report(cov,file="covr.html",browse=TRUE); saveRDS(cov,file="covr.rds")'
xcovr: covr
$(REXE) -e 'library(covr); readRDS("covr.rds") -> cov; codecov(coverage=cov,quiet=FALSE)'
win: dist
curl -T $(PKGVERS).tar.gz ftp://win-builder.r-project.org/R-release/
wind: dist
curl -T $(PKGVERS).tar.gz ftp://win-builder.r-project.org/R-devel/
check: dist
mkdir -p check
$(RCMD) check --no-stop-on-test-error --library=check -o check $(PKGVERS).tar.gz
qcheck: dist
mkdir -p check
$(RCMD) check --library=check -o check --no-vignettes --no-tests $(PKGVERS).tar.gz
qqcheck: dist
mkdir -p check
$(RCMD) check --library=check -o check --no-codoc --no-examples --no-vignettes --no-manual --no-tests $(PKGVERS).tar.gz
xcheck: dist
mkdir -p check library
$(RCMD_ALT) check --no-stop-on-test-error --as-cran --library=library -o check $(PKGVERS).tar.gz
xxcheck: install xcheck
mkdir -p check
$(REXE) -d "valgrind --tool=memcheck --track-origins=yes --leak-check=full" < check/$(PKG).Rcheck/$(PKG)-Ex.R 2>&1 | tee $(PKG)-Ex.Rout
ycheck: dist install
mkdir -p check
$(RCMD_ALT) check --run-dontrun --run-donttest --as-cran --library=library -o check $(PKGVERS).tar.gz
manual: install $(PKG).pdf
$(PKG).pdf: $(SOURCE)
$(RCMD) Rd2pdf --internals --no-description --no-preview --pdf --force -o $(PKG).pdf .
$(RSCRIPT) -e "tools::compactPDF(\"$(PKG).pdf\")";
tests: .tests
.tests: .testsource
$(MAKE) .install
$(MAKE) -C tests
$(TOUCH) $@
install: .install
.install: .roxy .NEWS .source .includes .headers
mkdir -p library
$(RCMD) INSTALL --html --library=library .
$(TOUCH) .install
%.tex: %.Rnw
$(RSCRIPT) -e "library(knitr); knit(\"$*.Rnw\")"
%.R: %.Rnw
$(RSCRIPT) -e "library(knitr); purl(\"$*.Rnw\")"
%.pdf: %.tex
$(PDFLATEX) $*
-$(BIBTEX) $*
$(PDFLATEX) $*
$(PDFLATEX) $*
%.bbl: %.tex
-$(PDFLATEX) $*
$(BIBTEX) $*
%.idx: %.tex
-$(PDFLATEX) $*
%.ind: %.idx
$(MAKEIDX) $*
%.html: %.Rmd
PATH=/usr/lib/rstudio/bin/pandoc:$$PATH \
Rscript --vanilla -e "rmarkdown::render(\"$*.Rmd\")"
%.html: %.md
PATH=/usr/lib/rstudio/bin/pandoc:$$PATH \
Rscript --vanilla -e "rmarkdown::render(\"$*.md\")"
%.R: %.Rmd
Rscript --vanilla -e "knitr::purl(\"$*.Rmd\",output=\"$*.R\",documentation=2)"
clean:
$(RM) -r check
$(RM) src/*.o src/*.so src/symbols.rds
$(RM) -r lib
$(RM) -r *-Ex.Rout *-Ex.timings *-Ex.pdf Rplots.*
$(RM) *.tar.gz $(PKGVERS).zip $(PKGVERS).tgz $(PKG).pdf
$(MAKE) -C tests clean
$(RM) .dist
remove:
if [ -d library ]; then \
$(RCMD) REMOVE --library=library $(PKG); \
rmdir library; \
fi
fresh: clean remove
$(RM) .headers .includes .NEWS
$(RM) .install .roxy .source .testsource .roxy .tests