-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (40 loc) · 1.27 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
# Usually, only these lines need changing
TEXFILE= main
RDIR= ./R
RMDDIR= ./Rmd
TEXDIR= ./tex
FIGDIR= ./figs
# list R files
RFILES := $(wildcard $(RDIR)/*.R)
RDEPS := $(wildcard $(RDIR)/comp/*.R) $(wildcard $(RDIR)/generators/*.R) $(wildcard $(RDIR)/graphics/*.R)
# Indicator files to show R file has run
OUT_FILES:= $(RFILES:.R=.Rout)
# list R-markdown files
RMD_FILES:= $(wildcard $(RMDDIR)/*.Rmd)
MD_FILES:= $(RMD_FILES:.Rmd=.md)
TEX_RMD_FILES:= $(RMD_FILES:.Rmd=.tex)
TEX_FILES:= $(wildcard $(TEXDIR)/*.tex)
all: $(TEXFILE).pdf $(OUT_FILES) $(TEX_FILES) $(TEX_RMD_FILES) $(MD_FILES)
# RUN EVERY R FILE
$(RDIR)/%.Rout: $(RDIR)/%.R $(RDEPS)
R CMD BATCH --vanilla $< $@
# Run Rmd>md>tex
$(RMDDIR)/%.md: $(RMDDIR)/%.Rmd
Rscript build.R $< $@
$(RMDDIR)/%.tex : $(RMDDIR)/%.md
pandoc --biblatex --data-dir=./ -o $@ $<
# Compile main tex file and show errors
$(TEXFILE).pdf: ./*.tex ./*.bib $(TEX_FILES) $(TEX_RMD_FILES) $(OUT_FILES)
latexmk -pdf -quiet $(TEXFILE)
latexmk -c
rm -fv *.fls
watch:
Rscript -e 'wahaniMiscs::watch()'
clean:
rm -fv $(OUT_FILES)
rm -fv *.aux *.log *.toc *.blg *.bbl *.synctex.gz
rm -fv *.out *.bcf *blx.bib *.run.xml *.lol
rm -fv *.fdb_latexmk *.fls
rm -fv $(RMDDIR)/*.aux $(RMDDIR)/*.tex.aux
rm -fv $(TEXDIR)/*.aux $(TEXDIR)/*.tex.aux
.PHONY: clean watch