#!/usr/bin/make -f
#export DH_VERBOSE=1
#
# Uncomment to ignore all test failures (but the tests will run anyway)
#export DH_RUBY_IGNORE_TESTS=all
#
# Uncomment to ignore some test failures (but the tests will run anyway).
# Valid values:
#export DH_RUBY_IGNORE_TESTS=ruby1.8 ruby1.9.1 require-rubygems
#
# If you need to specify the .gemspec (eg there is more than one)
#export DH_RUBY_GEMSPEC=

UPSTREAM_VERSION := $(shell dpkg-parsechangelog | grep "^Version:" | cut -d\  -f2 | cut -d- -f1)
export DH_RUBY_GEMSPEC=pg-${UPSTREAM_VERSION}.gemspec

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

override_dh_auto_build:
	# generate the gemspec from Rakefile
	rake debug_gem > pg-${UPSTREAM_VERSION}.gemspec
	ruby ext/errorcodes.rb ext/errorcodes.txt ext/errorcodes.def
	dh_auto_build

override_dh_installdocs:
	rdoc --op rdoc --main README.rdoc --title "pg: The Ruby Interface to PostgreSQL" lib/ ext/*.c README.rdoc
	dh_installdocs

override_dh_installchangelogs:
	dh_installchangelogs History.rdoc

override_dh_clean:
	rm -rf rdoc ext/errorcodes.def
	rm -f pg-${UPSTREAM_VERSION}.gemspec
	dh_clean
