-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
165 lines (110 loc) · 3.39 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
## 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
# VIGDIR := vignettes
# VIGHTMLDIR := doc
# DOCDIR := doc
# 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: check
####
clean: clean_check clean_readme
########### readme ###########
readme: $(READMEMD)
Readme.md: $(READMERMD)
@Rscript -e "rmarkdown::render('$(READMERMD)', output_format = 'rmarkdown::github_document')"
rm -f $(READMEHTML)
########### pkgdown ###########
pkgdown: readme
@Rscript -e "pkgdown::build_site()"
clean_pkgdown:
@Rscript -e "pkgdown::clean_site()"
preview_pkgdown:
@Rscript -e "pkgdown::preview_site( preview = TRUE )"
####
########### vignettes ###########
# vignettes: $(VIGHTML)
# $(VIGHTML): $(VIGRMD)
# @Rscript -e "devtools::build_vignettes()"
# clean_vignettes:
# @Rscript -e "devtools::clean_vignettes()"
########### html ###########
# html: $(HTML)
## %.html: %.Rmd
# $(OUTDIR)/%.html: $(SRCDIR)/%.Rmd
# @Rscript -e "rmarkdown::render('$<', output_format = 'prettydoc::html_pretty', output_dir = './$(OUTDIR)/')"
# clean_html:
# rm -f $(HTML)
########### web ###########
web: pkgdown
clean_web: clean_pkgdown
# rm -f VIGHTMLOUT
# rm -rf $(DATADIR)
####
########### Package ###########
####
docs:
Rscript -e "devtools::document(roclets = c('rd', 'collate', 'namespace', 'vignette'))"
Rscript -e "codemetar::write_codemeta()"
build:
cd ..;\
R CMD build $(PKGSRC)
####
build-cran:
cd ..;\
R CMD build $(PKGSRC)
####
install: build
cd ..;\
R CMD INSTALL $(PKGNAME)_$(PKGVERS).tar.gz
####
check: build-cran
cd ..;\
R CMD check $(PKGNAME)_$(PKGVERS).tar.gz --as-cran
clean_check:
$(RM) -r ./../$(PKGNAME).Rcheck/
drat: docs build
cd
@Rscript -e "drat::insertPackage('./../$(PKGNAME)_$(PKGVERS).tar.gz', repodir = './../drat/', commit = TRUE)"
####
####
# 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 update clean clean_check clean_readme docs web pkgdown, clean_pkgdown clean_web