#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/pkg-info.mk

# XXX remember to regenerate debian/ruby.postinst when you change either of
# these variables.
#
# $ debian/rules debian/ruby.postinst
#
export DEBIAN_DEFAULT_RUBY_VERSION=2.7
export DEBIAN_RUBY_PROGRAMS = \
  erb \
  irb \
  rdoc \
  ri \
  ruby

%:
	dh $@

override_dh_auto_configure:
	debian/version-check "$(DEB_VERSION)" "$(DEBIAN_DEFAULT_RUBY_VERSION)"
	dh_auto_configure

debian/ruby.postinst: debian/ruby.postinst.in
	sed -e 's/@@DEBIAN_DEFAULT_RUBY_VERSION@@/$(DEBIAN_DEFAULT_RUBY_VERSION)/g; s/@@DEBIAN_RUBY_PROGRAMS@@/$(DEBIAN_RUBY_PROGRAMS)/g' $< > $@ || ($(RM) $@; false)

override_dh_gencontrol:
	./debian/ruby-all-dev-depends >> debian/ruby-all-dev.substvars
	dh_gencontrol

override_dh_auto_install-arch:
	dh_auto_install
	dh_link -pruby-dev /usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/ruby-$(DEBIAN_DEFAULT_RUBY_VERSION).pc \
		/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/ruby.pc
