#!/usr/bin/make -f

%:
	dh $@ --buildsystem R

RMBVERSION := $(shell dpkg-query -W -f='$${Version}\n' r-cran-matrix)
RVERSION   := $(shell dpkg-query -W -f='$${source:Upstream-Version}\n' r-base-core)

override_dh_install:
	dh_install
	find debian -name COPYING -delete

override_dh_gencontrol:
	sed -i "s/r-cran-matrix[^,]*/r-cran-matrix (>= $(RMBVERSION))/"   debian/*substvars
	sed -i "s/\(r-api-[0-9.]\+\),/\1, r-base-core (>= $(RVERSION)),/" debian/*substvars
	dh_gencontrol
