forked from gastonstat/tutorial-R-web-data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (29 loc) · 1.08 KB
/
Makefile
File metadata and controls
41 lines (29 loc) · 1.08 KB
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
# Title: Makefile for tutorial-R-web-data
# Author: Gaston Sanchez
#
# Note:
# This makefile makes use of "Automatic-Variables" extensively. Specifically:
# $(@D) the directory part of the file name of the target
# $(<F) the directory part and the file-within-directory part of the first prerequisite
# $(@F) the file-within-directory part of the file name of the target
# names of all the slide directories
dirs = $(wildcard ls -d [0-9]*)
# names of all Rnw files
rnws = $(foreach dir,$(dirs),$(join $(dir)/,$(dir).Rnw))
# Outcome tex and pdf files
texs = $(patsubst %.Rnw,%.tex,$(rnws))
pdfs = $(patsubst %.Rnw,%.pdf,$(rnws))
.PHONY: clean
all: $(texs)
# Instead of using pdfs as targets, it's better to tell knit2pdf() to generate the tex files
# Specifying .tex file will avoid texi2dvi error
%.tex: %.Rnw header.tex
cd $(@D); Rscript -e "library(knitr); knit2pdf('$(<F)', output = '$(@F)')"
# remove all secondary files
cd $(@D); rm -f *.{aux,log,nav,out,snm,vrb,toc}
clean:
for d in $(dirs); \
do \
echo "removing tex file inside $$d"; \
rm -f $$d/*.tex; \
done