forked from casact/technology_survey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
103 lines (83 loc) · 3.35 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
####################
# Makefile
ROOT_DIR = ./
GATHER_DIR = $(ROOT_DIR)gather/
GATHERED_DIR = $(ROOT_DIR)gathered/
GATHER_SOURCE = $(sort $(wildcard $(GATHER_DIR)*.Rmd))
GATHERED = $(patsubst $(GATHER_DIR)%.Rmd, $(GATHERED_DIR)%.rda, $(GATHER_SOURCE))
COOK_DIR = $(ROOT_DIR)cook/
COOKED_DIR = $(ROOT_DIR)cooked/
COOK_SOURCE = $(sort $(wildcard $(COOK_DIR)*.Rmd))
COOKED = $(patsubst $(COOK_DIR)%.Rmd, $(COOKED_DIR)%.rda, $(COOK_SOURCE))
ANALYZE_DIR = $(ROOT_DIR)analyze/
ANALYZED_DIR = $(ROOT_DIR)analyzed/
ANALYZE_SOURCE = $(sort $(wildcard $(ANALYZE_DIR)*.Rmd))
ANALYZED = $(patsubst $(ANALYZE_DIR)%.Rmd, $(ANALYZED_DIR)%.rda, $(ANALYZE_SOURCE))
PRESENT_DIR = $(ROOT_DIR)present/
PRESENTED_DIR = $(ROOT_DIR)presented/
PRESENT_SOURCE = $(sort $(wildcard $(PRESENT_DIR)*.Rmd))
PRESENTED = $(patsubst $(PRESENT_DIR)%.Rmd, $(PRESENTED_DIR)%.rda, $(PRESENT_SOURCE))
KNIT = Rscript -e "library(rmarkdown); rmarkdown::render('$<')"
GATHER = Rscript -e "library(rmarkdown); rmarkdown::render('$(<:.sql=.Rmd)', output_dir = '$(GATHERED_DIR)')"
COOK = Rscript -e "library(rmarkdown); rmarkdown::render('$<', output_dir = '$(COOKED_DIR)')"
ANALYZE = Rscript -e "library(rmarkdown); rmarkdown::render('$<', output_dir = '$(ANALYZED_DIR)')"
PRESENT = Rscript -e "library(rmarkdown); rmarkdown::render('$<', output_dir = '$(PRESENTED_DIR)')"
#///////////////////////////////////////////////////
## M A I N R E C I P E
all: $(GATHERED) $(COOKED) $(ANALYZED) $(PRESENTED)
## End Main recipe
##==================================================
#///////////////////////////////////////////////////
## O N L Y C O O K
no_gather: $(COOKED) $(ANALYZED) $(PRESENTED)
## End no_gather
##==================================================
#///////////////////////////////////////////////////
## G A T H E R
gather: $(GATHERED)
$(GATHER_DIR)%.Rmd:$(GATHER_DIR)%.sql
@echo =============================================
@echo == SQL updated for $(@:.Rmd=.)
@echo =============================================
touch $@
$(GATHERED_DIR)%.rda:$(GATHER_DIR)%.Rmd
@echo =============================================
@echo == Working on $(<:.Rmd=.)
@echo =============================================
$(GATHER)
## End Gather
##==================================================
#///////////////////////////////////////////////////
# C O O K
cook: $(COOKED)
$(COOKED_DIR)%.rda:$(COOK_DIR)%.Rmd $(GATHERED)
@echo =============================================
@echo == Working on $(<:.Rmd=.)
@echo =============================================
$(COOK)
## End Cook
##==================================================
#///////////////////////////////////////////////////
## A N A L Y Z E
analyze: $(ANALYZED)
$(ANALYZED_DIR)%.rda:$(ANALYZE_DIR)%.Rmd $(COOKED)
@echo =============================================
@echo == Analyze $(<:.Rmd=)
@echo =============================================
$(ANALYZE)
## End Anaylze
##==================================================
#///////////////////////////////////////////////////
## P R E S E N T
$present: $(PRESENTED)
$(PRESENTED_DIR)%.rda:$(PRESENT_DIR)%.Rmd $(ANALYZED)
@echo =============================================
@echo == Working on $(<:.Rmd=)
@echo =============================================
$(PRESENT)
## End Present
##==================================================
clean:
rm -fv $(COOKED_DIR)/*
rm -fv $(ANALYZED_DIR)/*
rm -fv $(PRESENTED_DIR)/*