-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmakefile
executable file
·111 lines (79 loc) · 3.02 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
# makefile: Rnw -> tex -> pdf
# v 2.0
# .Rnw extension is automatically added
file_name = probability_hse_exams
.PHONY: R clean
auto_tikz_folder = auto_figures_tikz
r_plots_folder = R_plots
# get the list of all .R files
r_full_plots_files = $(wildcard $(r_plots_folder)/*.R)
# remove R_plots before
r_plots_files = $(r_full_plots_files:R_plots/%=%)
# replace .R by .Rdone for evey file
r_done_files = $(r_full_plots_files:.R=.Rdone)
# replace .R by .tex for every file
tikz_from_R_files = $(r_plots_files:.R=.tex)
# replace .R by .pdf for every file
pdf_from_R_files = $(r_plots_files:.R=.pdf)
# add folder before each file
pdf_full_from_R_files = $(addprefix $(auto_tikz_folder)/, $(pdf_from_R_files))
all: $(r_done_files) $(file_name).pdf excerpt_minima.pdf excerpt_exam_questions.pdf
# to build "all" target we need updated .Rdone files for each R script and main pdf file
# to build main pdf file we need: main tex file, chapters tex files, pdf files of plots
# to build pdf files of plots we need tex files of plots
# to build .Rdone file we just execute script and touch file
# each sript creates png and tex (tikz) file of plot
# so :)
# 1. all R sripts will be run and png and tex plot files will be produced and .Rdone will be touched
# 2. all tex plots will be transformed to small pdfs
# 3. main tex file will be proceeded
excerpt_minima.pdf: excerpt_minima.tex chapters/minima.tex chapters/sol_minima.tex
# protection against biber error
# http://tex.stackexchange.com/questions/140814/
rm -rf `biber --cache`
# create pdf
# will automatically run pdflatex/biber if necessary
latexmk -xelatex -latexoption=-shell-escape excerpt_minima.tex
# clean
latexmk -c excerpt_minima.tex
excerpt_exam_questions.pdf: excerpt_exam_questions.tex chapters/exam_questions.tex
# protection against biber error
# http://tex.stackexchange.com/questions/140814/
rm -rf `biber --cache`
# create pdf
# will automatically run pdflatex/biber if necessary
latexmk -xelatex -latexoption=-shell-escape excerpt_exam_questions.tex
# clean
latexmk -c excerpt_exam_questions.tex
$(file_name).pdf: $(file_name).tex chapters/*.tex $(pdf_full_from_R_files)
# protection against biber error
# http://tex.stackexchange.com/questions/140814/
rm -rf `biber --cache`
# create pdf
# will automatically run pdflatex/biber if necessary
latexmk -xelatex -latexoption=-shell-escape $(file_name).tex
# arara -v $(file_name).tex
# clean
# latexmk -c $(file_name).tex
# $(file_name).tex: $(file_name).Rnw
# Rscript -e "library(knitr); knit('$(file_name).Rnw')"
$(auto_tikz_folder)/%.pdf: $(auto_tikz_folder)/%.tex
latexmk -xelatex -cd $<
latexmk -c $<
# $< means the name of the first prerequisite
# %.pdf is a wildcard (every .pdf)
R_plots/%.Rdone: R_plots/%.R
Rscript $<
touch $@
R: $(r_done_files)
clean:
latexmk -c $(file_name).tex
-rm $(file_name).amc
-rm $(file_name).bbl
-rm $(file_name).log
-rm $(file_name).fdb_latexmk
-rm $(file_name).fls
-rm $(file_name).xdv
-rm $(file_name).pyg
-rm $(file_name).out.pyg
-rm $(file_name).synctex.gz