# for building vignettes independently of package

SOURCES = Introduction.Rnw Introduction_slides.Rnw \
	R.Rnw R_slides.Rnw \
	Sequencing_workflows_slides.Rnw \
	Bioconductor_sequences.Rnw Bioconductor.Rnw Bioconductor_slides.Rnw \
	Ranges.Rnw Ranges_slides.Rnw \
	RNASeq.Rnw \
	Annotation_slides.Rnw Annotation.Rnw \
	Visualization.Rnw

.PHONY: usage

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

%.tex: %.Rnw
	@echo "knit $<"
	"$(R_HOME)/bin/R" -e "library(knitr); 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 \
		R CMD make -f AMakefile Introduction.pdf\n \
		make -f AMakefile clean\n" ; \
	  exit 1 ; \
	fi

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