# for building vignettes independently of package

SOURCES = Bioconductor-slides.Rnw \
        Annotation-slides.Rnw Annotation-exercises.Rnw \
        Ranges-exercises.Rnw Ranges-slides.Rnw \
        Variants-slides.Rnw Variants-exercises.Rnw \
        ReadCounting-exercises.Rnw \
        Visualization-slides.Rnw BestPractices-slides.Rnw

.PHONY: usage

%.R: %.Rnw
	@echo "Stangle $<"
	"$(R_HOME)/bin/R" CMD Stangle $<

%.tex: %.Rnw
	@echo "Sweave $<"
	"$(R_HOME)/bin/R" -e "knitr::knit('$<')"

%.pdf: %.tex
	@echo "making $@"
	"$(R_HOME)/bin/R" CMD texi2dvi --pdf $<
	"$(R_HOME)/bin/R" CMD pdflatex $<

all: usage $(SOURCES:%.Rnw=%.pdf)

scripts: usage $(SOURCES:%.Rnw=%.R)

usage:
	@if [ -z $(R_HOME) ]; then \
	  echo "usage:\n \
		R CMD make -j -f AMakefile\n \
		SWEAVE_OPTIONS=\"eval=FALSE\" R CMD make -f AMakefile\n \
		make -f AMakefile clean\n" ; \
	  exit 1 ; \
	fi

clean:
	@rm -f *log *aux *out *blg *bbl *toc *tex *png *nav *vrb *snm
	@rm -rf indexes
	@rm -f $(SOURCES:%.Rnw=%.R)
