#!/usr/bin/make -f

%:
	dh $@ --buildsystem R

# need inst/doc to exist before installing the vignettes, but we
# removed it from the tarball
inst/doc:
	mkdir -p $@

# convert .svg images to .png; otherwise texi2dvi fails
PNG_FILES = $(subst svg,png, $(wildcard vignettes/*.svg))
%.png: %.svg
	rsvg-convert $< -o $@

# we need to run dh_auto_install twice:
# 1. compile the package so dh_vignette can generate the vignettes
# 2. properly install the vignettes
override_dh_auto_install: inst/doc $(PNG_FILES)
	dh_auto_install
	R_LIBS=debian/r-cran-partitions/usr/lib/R/site-library dh_vignette
	dh_auto_install
	rm $(PNG_FILES)
