-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (52 loc) · 2.05 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
GUIX:=/usr/local/bin/guix
GUIXTM:=${GUIX} time-machine --channels=guix/channels.pinned.scm -- \
shell --manifest=guix/manifest.scm
RSCRIPT=Rscript --vanilla
DATA:=data/extdata/cvc.csv
MANUSCRIPT:=manuscript
SECTIONDIR:=sections
OUTPUTDIR:=output
DISTDIR:=distribute
RMD=$(wildcard $(SECTIONDIR)/*.Rmd)
DATE=$(shell date +'%Y%m%d')
GITHEAD=$(shell git rev-parse --short HEAD)
.DELETE_ON_ERROR:
.PHONEY: \
clean clean-dist clean-output \
dist guix-pin-channels \
regenerate-data env
all: manuscript
manuscript: $(OUTPUTDIR)/$(MANUSCRIPT).html
$(OUTPUTDIR):
@mkdir -p $(OUTPUTDIR)
$(OUTPUTDIR)/%.html: %.Rmd $(RMD) $(DATA) guix/channels.pinned.scm guix/manifest.scm | $(OUTPUTDIR)
${GUIXTM} -- \
${RSCRIPT} -e "rmarkdown::render('$<', output_dir = '$(OUTPUTDIR)')"
$(OUTPUTDIR)/%.docx: %.Rmd $(RMD) $(DATA) guix/channels.pinned.scm 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 $(OUTPUTDIR)/$(MANUSCRIPT).html | $(DISTDIR)
cp $(OUTPUTDIR)/$(MANUSCRIPT).docx $(DISTDIR)/"$(DATE)_$(GITHEAD)_$(MANUSCRIPT).docx"
cp $(OUTPUTDIR)/$(MANUSCRIPT).html $(DISTDIR)/"$(DATE)_$(GITHEAD)_$(MANUSCRIPT).html"
## manual pinning guix channels to latest commits
guix-pin-channels: FORCE guix/channels.pinned.scm
${GUIX} time-machine --channels=guix/channels.scm -- \
describe -f channels > guix/channels.pinned.scm
FORCE:
guix/channels.pinned.scm: guix/channels.scm
${GUIX} time-machine --channels=guix/channels.scm -- \
describe -f channels > guix/channels.pinned.scm
## data/intdata and data/scripts are not part of the git repository
regenerate-data: \
data/intdata/ZVK-Doku.xlsx \
data/scripts/01-anonymize-and-prepare.R
${GUIX} time-machine --channels=guix/channels.pinned.scm -- \
shell --manifest=guix/manifest-data-preparation.scm -- \
Rscript data/scripts/01-anonymize-and-prepare.R
clean: clean-dist clean-output
clean-dist:
@rm -rf $(DISTDIR)
clean-output:
@rm -rf $(OUTPUTDIR)