#!/usr/bin/make -f
export DEB_BUILD_OPTIONS=nocheck
export DH_RUBY_INSTALL_PREFIX=/opt/rock/master-18.09
arch=$(shell gcc -print-multiarch)
ruby_ver=$(shell ruby --version)
ruby_arch_dir=$(shell ruby -r rbconfig -e "print RbConfig::CONFIG['archdir']")
ruby_libdir=$(shell ruby -r rbconfig -e "print RbConfig::CONFIG['rubylibdir']")
rockruby_archdir=$(subst /usr,,$(ruby_arch_dir))
rockruby_libdir=$(subst /usr,,$(ruby_libdir))

master1809_install_dir = /opt/rock/master-18.09
env_setup =  PATH=$(master1809_install_dir)/bin:$(PATH)
env_setup += RUBYLIB=$(master1809_install_dir)/$(rockruby_libdir):$(master1809_install_dir)/$(rockruby_archdir):$(master1809_install_dir)/lib/ruby/vendor_ruby/standard:$(master1809_install_dir)/lib/ruby/vendor_ruby/core:$(master1809_install_dir)/lib/ruby/vendor_ruby:$(RUBYLIB)
env_setup += PKG_CONFIG_PATH=$(master1809_install_dir)/lib/pkgconfig:$(master1809_install_dir)/lib/$(arch)/pkgconfig:/usr/share/pkgconfig:/usr/lib/$(arch)/pkgconfig:$(PKG_CONFIG_PATH)
env_setup += Rock_DIR=$(master1809_install_dir)/share/rock/cmake:$(Rock_DIR)
env_setup += LD_LIBRARY_PATH=$(master1809_install_dir)/lib:$(master1809_install_dir)/lib/$(arch):$(LD_LIBRARY_PATH)
env_setup += CMAKE_PREFIX_PATH=$(master1809_install_dir):$(CMAKE_PREFIX_PATH)
env_setup += OROGEN_PLUGIN_PATH=$(master1809_install_dir)/share/orogen/plugins:$(OROGEN_PLUGIN_PATH)
export TYPELIB_CXX_LOADER=gccxml
export DEB_CPPFLAGS_APPEND=-std=c++11
export npm_config_cache=/tmp/npm
rock_library_dirs=$(master1809_install_dir)/lib:$(master1809_install_dir)/lib/$(arch):
rock_install_dir=/opt/rock/master-18.09
env_setup += RUBY_CMAKE_INSTALL_PREFIX=debian/rock-master-18.09-ruby-mustermann/opt/rock/master-18.09

export GEM2DEB_TEST_RUNNER = --check-dependencies

%:
	$(env_setup) dh $@ --buildsystem=ruby --with ruby
