This repository has been archived by the owner on Sep 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
GNUmakefile
136 lines (115 loc) · 4.68 KB
/
GNUmakefile
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
PKGNAME := $(shell sed -n "s/Package: *\([^ ]*\)/\1/p" DESCRIPTION)
PKGVERS := $(shell sed -n "s/Version: *\([^ ]*\)/\1/p" DESCRIPTION)
PKGSRC := $(shell basename $(PWD))
# Specify the directory holding R binaries. To use an alternate R build (say a
# pre-prelease version) use `make RBIN=/path/to/other/R/` or `export RBIN=...`
# If no alternate bin folder is specified, the default is to use the folder
# containing the first instance of R on the PATH.
RBIN ?= $(shell dirname "`which R`")
# Check for environment variables that contain arguments to pass to testing
# scripts.
ifneq ($(R_GCT),)
gc_torture:=--use-gctorture
else
gc_torture:=
endif
# Controls which tests to run. Use thusly:
#
# make test TESTS=list,of,comma,seperated,tags
#
# Tags must be single words
ifneq ($(TESTS),)
test_tags:=--run-tests=$(TESTS)
else
test_tags:=
endif
.PHONY: help news
help:
@echo "\nExecute development tasks for $(PKGNAME)\n"
@echo "Usage: \`make <task>\` where <task> is one of:"
@echo ""
@echo "Development Tasks"
@echo "-----------------"
@echo " deps Install dependencies for package development"
@echo " docs Invoke roxygen to generate Rd files in a seperate"
@echo " directory"
@echo " news Create NEWS.Rd and NEWS.pdf from NEWS.md. Requires"
@echo " GHC and Pandoc to be installed."
@echo " vignette Build a copy of the package vignette"
@echo " build Invoke docs and then create a package"
@echo " check Invoke build and then check the package"
@echo " install Invoke build and then install the result"
@echo " test Install a new copy of the package and run it "
@echo " through the testsuite"
@echo " valgrind Run package testsuite through the Valgrind debugger"
@echo " to check for memory leaks"
@echo ""
@echo "Packaging Tasks"
@echo "---------------"
@echo " release Populate a release branch"
@echo ""
@echo "Using R in: $(RBIN)"
@echo "Set the RBIN environment variable to change this."
@echo ""
#------------------------------------------------------------------------------
# Development Tasks
#------------------------------------------------------------------------------
# Set a default CRAN mirror because otherwise R refuses to install anything.
deps:
"$(RBIN)/R" --slave -e "options(repos = c(CRAN = 'http://cran.cnr.Berkeley.edu'));install.packages(c('filehash','roxygen2','testthat','ggplot2','maps'))"
docs:
cd ..;\
"$(RBIN)/R" --vanilla --slave -e "library(roxygen2); roxygenize('$(PKGSRC)', '$(PKGSRC).build', overwrite=TRUE, unlink.target=TRUE)"
# Cripple the new folder so you don't get confused and start doing
# development in there.
cd ../$(PKGSRC).build;\
rm GNUmakefile
news:
rm -f NEWS.pdf
./md2news.hs NEWS.md
# Use this instead of Rd2txt. Rd2txt *does not* produce plaintext. The output
# has a bunch of formatting junk for underlines and such.
"$(RBIN)/R" --vanilla --slave -e "require(tools);Rd2txt('NEWS.Rd', 'NEWS', options=list(underline_titles=FALSE))"
R CMD Rd2pdf --no-preview NEWS.Rd
# Move news into the inst directory so that it will be available to users
# after installing the package.
mv NEWS.Rd inst
vignette:
cd inst/doc;\
"$(RBIN)/R" CMD Sweave $(PKGNAME).Rnw;\
texi2dvi --pdf $(PKGNAME).tex;\
"$(RBIN)/R" --vanilla --slave -e "tools:::compactPDF(getwd(), gs_quality='printer')"
build: docs
cd ..;\
"$(RBIN)/R" CMD build --no-vignettes $(PKGSRC).build
install: build
cd ..;\
"$(RBIN)/R" CMD INSTALL $(PKGNAME)_$(PKGVERS).tar.gz
check: build
cd ..;\
"$(RBIN)/R" CMD check --as-cran --no-tests $(PKGNAME)_$(PKGVERS).tar.gz
test: install
cd tests;\
"$(RBIN)/Rscript" unit_tests.R $(gc_torture) $(test_tags)
valgrind: install
cd tests;\
"$(RBIN)/R" -d "valgrind --tool=memcheck --leak-check=full --dsymutil=yes" --vanilla < unit_tests.R --args $(gc_torture) $(test_tags)
#------------------------------------------------------------------------------
# Packaging Tasks
#------------------------------------------------------------------------------
release:
@git checkout r-forge
@git clean -fdx
@git merge --no-edit master -s recursive -Xtheirs
@cd ..;\
"$(RBIN)/R" --vanilla --slave -e "library(roxygen2); roxygenize('$(PKGSRC)','$(PKGSRC)', copy.package=FALSE, overwrite=TRUE)"
@echo "\nCreating Vignette..."
@make vignette >> build.log 2>&1
@echo "Creating NEWS...\n"
@make news >> build.log 2>&1
@./updateVersion.sh
@git commit --amend -m "Build `cat inst/GIT_VERSION`"
@echo "\nMaster branch merged. Documentation rebuilt. Version number updated."
@echo 'Perform final touchups and commit with `git commit --amend`.'
@echo 'Remember to run `git svn dcommit` before `git push` as synching with'
@echo 'R-Forge SVN will alter the SHA.'