Makefile dependencies with Sweave

I am trying to compile a Sweave document with a makefile, using data stored in another directory, assembled by a script in the current directory. The workflow goes something like this:

datamaker.R > /otherdirectory/data > .rnw > .tex > .pdf

I currently have a makefile similar to the creation below:

MASTER = foo.pdf
VPATH = /otherdirectory
all: $(MASTER)
    open $<

data: datamaker.R
    R CMD BATCH 'datamaker.R'

foo.rnw: data

foo.tex: foo.rnw
    R CMD SWEAVE 'foo.rnw'

foo.pdf: foo.tex
    pdflatex foo.tex

The problem is that the R CMD BATCH command runs every time, even when 'datamaker' is older than 'data'. I'm sure that I'm missing something fairly obvious, but I've been pulling my hair out for several hours now.


Make is trying to use the data rule to build data , which is the prerequisite of foo.rnw , but the data rule doesn't actually build data , it builds otherdirectory/data . So Make runs it every time, because data is never there.

Try this:

...

otherdirectory/data: datamaker.R
    R CMD BATCH 'datamaker.R'

foo.rnw: otherdirectory/data

...
链接地址: http://www.djcxy.com/p/26912.html

上一篇: ESS + AUCTeX + Sweave。 从.Rnw <SyncteX集成

下一篇: Makeave与Sweave的依赖关系