-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
148 lines (97 loc) · 2.94 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
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
## R parts based on https://github.com/yihui/knitr/blob/master/Makefile
PKGNAME := $(shell sed -n "s/^Package: *\([^ ]*\)/\1/p" DESCRIPTION)
PKGVERS := $(shell sed -n "s/^Version: *\([^ ]*\)/\1/p" DESCRIPTION)
PKGSRC := $(shell basename `pwd`)
# SRCDIR = source
# OUTDIR = docs
# DATADIR = $(OUTDIR)/data
# INSTDIR = inst
# VIGHTMLDIR = doc
# DOCDIR = doc
VIGDIR = vignettes
VIGRMD = $(wildcard $(VIGDIR)/*.Rmd)
TMP1 = $(VIGRMD:.Rmd=.html)
VIGHTML = ${subst $(VIGDIR),$(VIGHTMLDIR),$(TMP1)}
# VIGHTMLOUT = ${subst $(VIGDIR),$(OUTDIR),$(TMP1)}
# EXAMPLEXML = $(wildcard $(INSTDIR)/dmdScheme_example.xml)
# RMD = $(wildcard $(SRCDIR)/*.Rmd)
# TMP2 = $(RMD:.Rmd=.html)
# HTML = ${subst $(SRCDIR),$(OUTDIR),$(TMP2)}
READMERMD = Readme.Rmd
READMEMD = Readme.md
READMEHTML = Readme.html
#############
all: readme docs vignettes build
#############
clean: clean_check clean_readme clean_vignettes
########### Readme ###########
####
readme: $(READMEMD)
Readme.md: $(READMERMD)
@Rscript -e "rmarkdown::render('$(READMERMD)', output_format = 'rmarkdown::github_document')"
rm -f $(READMEHTML)
clean_readme:
rm -f $(READMEMD)
####
########### Package ###########
####
deps:
Rscript -e 'if (!require("Rd2roxygen")) install.packages("Rd2roxygen", repos="http://cran.rstudio.com")'
####
docs:
Rscript -e "devtools::document(roclets = c('rd', 'collate', 'namespace', 'vignette'))"
Rscript -e "codemetar::write_codemeta()"
####
vignettes: $(VIGHTML)
$(VIGHTML): $(VIGRMD)
@Rscript -e "devtools::build_vignettes()"
clean_vignettes:
@Rscript -e "devtools::clean_vignettes()"
####
build: docs
cd ..;\
R CMD build $(PKGSRC)
####
build-cran: docs
cd ..;\
R CMD build $(PKGSRC)
####
install: build
cd ..;\
R CMD INSTALL $(PKGNAME)_$(PKGVERS).tar.gz
####
drat: docs build
cd
@Rscript -e "drat::insertPackage('./../$(PKGNAME)_$(PKGVERS).tar.gz', repodir = './../../drat/', commit = TRUE)"
####
check: build-cran
cd ..;\
R CMD check $(PKGNAME)_$(PKGVERS).tar.gz --as-cran
clean_check:
$(RM) -r ./../$(PKGNAME).Rcheck/
####
# check_rhub
# @Rscript -e "rhub::check_for_cran(".")
####
test:
@Rscript -e "devtools::test()"
####
############# Help targets #############
list_variables:
@echo
@echo "#############################################"
@echo "## Variables ################################"
@$(MAKE) -pn | grep -A1 "^# makefile"| grep -v "^#\|^--" | sort | uniq
@echo "#############################################"
@echo ""
## from https://stackoverflow.com/a/26339924/632423
list_targets:
@echo
@echo "#############################################"
@echo "## Targets ###############################"
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
@echo "#############################################"
@echo
list: list_variables list_targets
#############
.PHONY: list files clean