RSCRIPT=/usr/bin/Rscript --vanilla
MKDIR=/bin/mkdir -p
ADMB=/opt/admb/bin/admb
RM=/bin/rm -r

AvonData/data/AvonOutbreaks.RData: AvonData/R/data-prep.r
	install -d AvonData/data && cd AvonData/data && $RSCRIPT ../../run-data-prep.r

EpiGLM/data/estData.RData: get-ests.r
	install -d EpiGLM/data && cd EpiGLM/data && $RSCRIPT ../../get-ests.r

AvonData_0.0-1.tar.gz: AvonData/data/AvonOutbreaks.RData
	R CMD build AvonData && R CMD INSTALL AvonData

EpiGLM_0.0-1.tar.gz: EpiGLM/inst/simo/simo_pb2.py EpiGLM/inst/admb/epiglm EpiGLM/data/estData.RData
	R CMD build EpiGLM && R CMD INSTALL EpiGLM

EpiGLM/inst/simo/simo_pb2.py: EpiGLM/inst/proto/simo.proto
	protoc -I=EpiGLM/inst/proto --python_out=EpiGLM/inst/simo EpiGLM/inst/proto/simo.proto

EpiGLM/inst/admb/epiglm: EpiGLM/inst/admb/epiglm.tpl
	cd EpiGLM/inst/admb && admb epiglm && cp epiglm{,-$(uname -m)}

estBoot.RData: est-bootstrap.r EpiGLM_0.0-1.tar.gz
	scp est-bootstrap.r phylo: && echo "Run est bootstrap on cluster with new version of EpiGLM"

estBoot-reduction.RData: est-bootstrap-reduce.r estBoot.RData EpiGLM_0.0-1.tar.gz
	scp est-bootstrap-reduce.* phylo: && ssh phylo "qsub est-bootstrap-reduce.sge" && echo "Wait for cluster job to finish and then copy estBoot-reduction.RData back here"

estBoot-post.RData: est-bootstrap-post.r estBoot-reduction.RData
	$RSCRIPT est-bootstrap-post.r

fig1.eps: plot-bootstrap.r EpiGLM_0.0-1.tar.gz estBoot-post.RData
	$RSCRIPT plot-bootstrap.r 

simStudy.RData: sim-study2.r EpiGLM_0.0-1.tar.gz
	scp sim-study2.r phylo: && echo "Run sim study on cluster with new version of EpiGLM"

tab_tr.tex: sim-study-post2.r EpiGLM_0.0-1.tar.gz simStudy.RData
	scp sim-study-post2.* phylo: && ssh "qsub sim-study-post2.sge" && echo "Wait for cluster job to finish and then copy tab*.tex back here"
