-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
106 lines (80 loc) · 3.19 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
GUIX:=/usr/local/bin/guix
GUIXTM:=${GUIX} time-machine --channels=guix/channels.pinned.scm -- \
shell --manifest=guix/manifest.scm
RAWDATA:=raw-data
CRF=$(wildcard $(RAWDATA)/crfs/*.csv)
SETTING=$(RAWDATA)/setting.csv
MANUSCRIPT:=manuscript
SECTIONDIR:=manuscript/sections
RMD=$(wildcard $(SECTIONDIR)/*.Rmd)
DOCSRMD=$(wildcard docs/*.Rmd)
HTMLS=$(DOCSRMD:%.Rmd=%.html)
BIB=manuscript/bibliography/bibliography.bib
DISTDIR:=distribute
OUTPUTDIR:=manuscript/output
DATE=$(shell date +'%Y%m%d')
GITHEAD=$(shell git rev-parse --short HEAD)
GITHEADL=$(shell git rev-parse HEAD)
.DELETE_ON_ERROR:
all: manuscript
.PHONEY: manuscript
manuscript: $(OUTPUTDIR)/$(MANUSCRIPT).html
$(OUTPUTDIR):
@mkdir -p $(OUTPUTDIR)
$(OUTPUTDIR)/$(MANUSCRIPT).html: manuscript/$(MANUSCRIPT).Rmd $(RMD) $(BIB) guix/manifest.scm | $(OUTPUTDIR)
${GUIXTM} -- \
Rscript -e "rmarkdown::render('$<', output_dir = '$(OUTPUTDIR)')"
$(OUTPUTDIR)/$(MANUSCRIPT).docx: manuscript/$(MANUSCRIPT).Rmd $(RMD) $(BIB) guix/manifest.scm | $(OUTPUTDIR)
${GUIXTM} -- \
Rscript -e "rmarkdown::render('$<', output_format = 'bookdown::word_document2', output_dir = '$(OUTPUTDIR)')"
$(DISTDIR):
@mkdir -p $(DISTDIR)
dist: $(OUTPUTDIR)/$(MANUSCRIPT).docx | $(DISTDIR)
@cp $< $(DISTDIR)/"$(DATE)_$(GITHEAD)_$(MANUSCRIPT).docx"
progress: docs/progress.html docs/validate.html
docs/%.html: docs/%.Rmd $(CRF) $(SETTING)
${GUIXTM} -- \
Rscript -e "rmarkdown::render('$<', output_dir = 'docs')"
docs: $(HTMLS) docs/manuscript.html
docs/manuscript.html: manuscript
sed 's#</h4>#</h4> \
<div style="background-color: \#ffc107; padding: 10px; text-align: center;"> \
<strong>This study is work-in-progress!</strong><br /> \
Please find details at <a href="https://github.com/umg-minai/vct-or-mc">https://github.com/umg-minai/vct-or-mc</a>.<br /> \
Manuscript date: $(shell date +"%Y-%m-%d %H:%M"); Version: <a href="https://github.com/umg-minai/vct-or-mc/commit/$(GITHEADL)">$(GITHEAD)</a> \
</div>#' $(OUTPUTDIR)/$(MANUSCRIPT).html > docs/manuscript.html
.PHONEY: validate
validate: validate-crf
validate-crf: $(CRF)
${GUIX} time-machine --channels=guix/channels.pinned.scm -- \
shell --manifest=guix/manifest.scm -- \
Rscript -e "source('validation/validate.R'); validate_all()"
.PHONEY: generate-umg-crfs
generate-umg-crfs:
${GUIX} time-machine --channels=guix/channels.pinned.scm -- \
shell --manifest=guix/manifest.scm -- \
Rscript -e "source('raw-data/04-umg/create-umg-crfs.R')"
.PHONEY: export-agcs-for-zeosys
export-agcs-for-zeosys:
${GUIX} time-machine --channels=guix/channels.pinned.scm -- \
shell --manifest=guix/manifest.scm r-writexl -- \
Rscript -e "source('raw-data/scripts/export-agcs-for-zeosys.R')"
.PHONEY:
shell:
${GUIX} time-machine --channels=guix/channels.pinned.scm -- \
shell --manifest=guix/manifest.scm
## pinning guix channels to latest commits
.PHONEY: guix-pin-channels
guix-pin-channels: guix/channels.pinned.scm
guix/channels.pinned.scm: guix/channels.scm FORCE
${GUIX} time-machine --channels=guix/channels.scm -- \
describe -f channels > guix/channels.pinned.scm
.PHONEY: clean
clean: clean-dist clean-output
.PHONEY: clean-dist
clean-dist:
@rm -rf $(DISTDIR)
.PHONEY: clean-output
clean-output:
@rm -rf $(OUTPUTDIR)
FORCE: