#!/usr/bin/make -f

#export DH_VERBOSE = 1

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

%:
	dh $@ --with ruby --buildsystem cmake

RUBY_VERSION=2.1.0

define newline


endef

override_dh_auto_configure: options+=-DRB_INSTALL_DIR=$(shell $(ruby) -rrbconfig -e 'puts RbConfig::CONFIG["vendorlibdir"]')
override_dh_auto_configure: options+=-DRB_ARCH_INSTALL_DIR=$(shell $(ruby) -rrbconfig -e 'puts RbConfig::CONFIG["vendorarchdir"]')

override_dh_auto_clean \
override_dh_auto_configure \
override_dh_auto_build \
override_dh_auto_test \
override_dh_auto_install:
	$(foreach ruby,$(shell find /usr/bin/ -name 'ruby[12]*' | xargs -n1 readlink -f | xargs -n1 basename),\
		$(subst override_,,$@) --builddirectory=$(ruby)-obj-$(DEB_HOST_MULTIARCH) -- $(options)$(newline))

