Created
November 29, 2011 18:55
-
-
Save halpo/1405945 to your computer and use it in GitHub Desktop.
knitr makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# Copyright 2011 | |
# Andrew Redd | |
# 11/23/2011 | |
# | |
# Description of File: | |
# Makefile for knitr compiling | |
# | |
################################################################################ | |
all:pdf # default rule DO NOT EDIT | |
################################################################################ | |
MAINFILE := test | |
RNWFILES := | |
RFILES := | |
TEXFILES := | |
CACHEDIR := cache | |
FIGUREDIR := figures | |
LATEXMK_FLAGS := | |
##### Explicit Dependencies ##### | |
################################################################################ | |
RNWTEX = $(RNWFILES:.Rnw=.tex) | |
ROUTFILES = $(RFILES:.R=.Rout) | |
RDATAFILES= $(RFILES:.R=.Rdata) | |
MAINTEX = $(MAINFILE:=.tex) | |
MAINPDF = $(MAINFILE:=.pdf) | |
ALLTEX = $(MAINTEX) $(RNWTEX) $(TEXFILES) | |
# Dependencies | |
$(RNWTEX): $(RDATAFILES) | |
$(MAINTEX): $(RNWTEX) $(TEXFILES) | |
$(MAINPDF): $(MAINTEX) $(ALLTEX) | |
.PHONY:pdf tex clean clearcache cleanall | |
pdf: $(MAINPDF) | |
tex: $(RDATAFILES) $(ALLTEX) | |
$(CACHEDIR): | |
mkdir $(CACHEDIR) | |
$(FIGUREDIR): | |
mkdir $(FIGUREDIR) | |
%.tex:%.Rnw | |
Rscript \ | |
-e "library(knitr)" \ | |
-e "knitr::opts_chunk[['set']](fig.path='$(FIGUREDIR)/$*-')" \ | |
-e "knitr::opts_chunk[['set']](cache.path='$(CACHEDIR)/$*-')" \ | |
-e "knitr::knit('$<','$@')" | |
%.R:%.Rnw | |
Rscript -e "Sweave('$^', driver=Rtangle())" | |
%.Rout:%.R | |
R CMD BATCH "$^" "$@" | |
%.pdf: %.tex | |
latexmk -pdf $< | |
clean: | |
-latexmk -c -quiet $(MAINFILE).tex | |
-rm -f $(MAINTEX) $(RNWTEX) | |
-rm -rf $(FIGUREDIR) | |
-rm *tikzDictionary | |
-rm $(MAINPDF) | |
clearcache: | |
-rm -rf cache | |
cleanall: clean clearcache |
I replaced it in my personal copy but forgot here. Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
prefix.string
andprefix.cache
have been renamed tofig.path
andcache.path
respectively, so you might want to tweak line 28 and 29