forked from PecanProject/pecan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
115 lines (88 loc) · 3.66 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
NCPUS ?= 1
BASE := utils db settings visualization
MODELS := biocro clm45 dalec ed fates gday jules linkages \
lpjguess maat maespa preles sipnet
MODULES := allometry assim.batch assim.sequential benchmark \
data.atmosphere data.hydrology data.land \
data.mining data.remote emulator meta.analysis \
photosynthesis priors rtm uncertainty
MODELS := $(MODELS:%=models/%)
MODULES := $(MODULES:%=modules/%)
ALL_PKGS := $(BASE) $(MODELS) $(MODULES) models/template
BASE_I := $(BASE:%=.install/%)
MODELS_I := $(MODELS:%=.install/%)
MODULES_I := $(MODULES:%=.install/%)
ALL_PKGS_I := $(BASE_I) $(MODELS_I) $(MODULES_I) .install/models/template
BASE_C := $(BASE:%=.check/%)
MODELS_C := $(MODELS:%=.check/%)
MODULES_C := $(MODULES:%=.check/%)
ALL_PKGS_C := $(BASE_C) $(MODELS_C) $(MODULES_C) .check/models/template
BASE_T := $(BASE:%=.test/%)
MODELS_T := $(MODELS:%=.test/%)
MODULES_T := $(MODULES:%=.test/%)
ALL_PKGS_T := $(BASE_T) $(MODELS_T) $(MODULES_T) .test/models/template
BASE_D := $(BASE:%=.doc/%)
MODELS_D := $(MODELS:%=.doc/%)
MODULES_D := $(MODULES:%=.doc/%)
ALL_PKGS_D := $(BASE_D) $(MODELS_D) $(MODULES_D) .doc/models/template
.PHONY: all install check test document
all: install
document: .doc/all
install: .install/all
check: .check/all
test: .test/all
### Dependencies
.doc/all: $(ALL_PKGS_D)
.install/all: $(ALL_PKGS_I)
.check/all: $(ALL_PKGS_C)
.test/all: $(ALL_PKGS_T)
depends = .install/$(1) .doc/$(1) .check/$(1) .test/$(1)
$(call depends,db): .install/utils
$(call depends,settings): .install/utils .install/db
$(call depends,visualization): .install/db
$(call depends,modules/data.atmosphere): .install/utils
$(call depends,modules/data.land): .install/db .install/utils
$(call depends,modules/meta.analysis): .install/utils .install/db
$(call depends,modules/priors): .install/utils
$(call depends,modules/assim.batch): .install/utils .install/db .install/modules/meta.analysis
$(call depends,modules/rtm): .install/modules/assim.batch
$(call depends,models/template): .install/utils
$(call depends,models/biocro): .install/utils .install/modules/data.atmosphere .install/modules/data.land
$(MODELS_I): .install/models/template
clean:
rm -rf .install .check .test .doc
find modules/rtm/src \( -name \*.mod -o -name \*.o -o -name \*.so \) -delete
.install/devtools:
Rscript -e "if(!require('devtools')) install.packages('devtools', repos = 'http://cran.rstudio.com', Ncpus = ${NCPUS})"
mkdir -p $(@D)
echo `date` > $@
.install/roxygen2:
Rscript -e "if(!require('roxygen2')) install.packages('roxygen2', repos = 'http://cran.rstudio.com', Ncpus = ${NCPUS})"
mkdir -p $(@D)
echo `date` > $@
.install/testthat:
Rscript -e "if(!require('testthat')) install.packages('testthat', repos = 'http://cran.rstudio.com', Ncpus = ${NCPUS})"
mkdir -p $(@D)
echo `date` > $@
install_R_pkg = Rscript -e "devtools::install('$(strip $(1))', Ncpus = ${NCPUS});"
check_R_pkg = Rscript scripts/check_with_errors.R $(strip $(1))
test_R_pkg = Rscript -e "devtools::test('"$(strip $(1))"', reporter = 'stop')"
doc_R_pkg = Rscript -e "devtools::document('"$(strip $(1))"')"
$(ALL_PKGS_I) $(ALL_PKGS_C) $(ALL_PKGS_T) $(ALL_PKGS_D): .install/devtools .install/roxygen2 .install/testthat
.SECONDEXPANSION:
.doc/%: $$(wildcard %/**/*) $$(wildcard %/*)
$(call doc_R_pkg, $(subst .doc/,,$@))
mkdir -p $(@D)
echo `date` > $@
.install/%: $$(wildcard %/**/*) $$(wildcard %/*)
$(call install_R_pkg, $(subst .install/,,$@))
mkdir -p $(@D)
echo `date` > $@
.check/%: $$(wildcard %/**/*) $$(wildcard %/*)
$(call check_R_pkg, $(subst .check/,,$@))
mkdir -p $(@D)
echo `date` > $@
.test/%: $$(wildcard %/**/*) $$(wildcard %/*)
$(call test_R_pkg, $(subst .test/,,$@))
mkdir -p $(@D)
echo `date` > $@