Skip to content

Instantly share code, notes, and snippets.

@csgillespie
Created October 9, 2015 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csgillespie/5f45077549790fcabae3 to your computer and use it in GitHub Desktop.
Save csgillespie/5f45077549790fcabae3 to your computer and use it in GitHub Desktop.
Example Makefile used when dealing with Sweave
## $* = filename without extension
## $@ = the output file
## $< = the input file
.SUFFIXES: .tex .pdf .Rnw .R
MAIN = lecture
INCLUDES = chapter1 chapter2 chapter3
TEX = $(INCLUDES:=.tex)
RFILES = $(INCLUDES:=.R)
RNWFILES = $(INCLUDES:=.Rnw)
all: $(TEX) $(MAIN).pdf
$(MAIN).pdf: $(TEX) $(MAIN).tex
R: $(RFILES)
view: all
xpdf $(MAIN).pdf &
.Rnw.R:
R CMD Stangle $<
.Rnw.tex:
Rscript -e "require(highlight); \
driver = HighlightWeaveLatex(boxes = TRUE);\
Sweave('$*.Rnw', driver = driver ); "
.tex.pdf:
rubber --pdf $*.tex # Or use pdflatex
clean:
rm -fv $(MAIN).pdf $(TEX) $(RFILES)
rm -fv *.aux *.dvi *.log *.toc *.bak *~ *.blg *.bbl *.lot *.lof
rm -fv *.nav *.snm *.out *.pyc \#*\# _region_* _tmp.* *.vrb
rm -fv Rplots.pdf *.RData movie.csv.gz mygraph*
cleaner:
make clean
rm -fv ../graphics/*.pdf
rm -fvr auto/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment