#!/usr/bin/make -f

# export GEM2DEB_TEST_RUNNER = --check-dependencies
export DH_RUBY_GEMSPEC=gphys.gemspec

MANSRC = $(notdir $(wildcard bin/*))

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

override_dh_auto_clean:
	[ ! -f $(CURDIR)/ext/numru/gphys/Makefile ] \
	  || ( cd $(CURDIR)/ext/numru/gphys && make distclean )
	dh_auto_clean

override_dh_auto_install:
	dh_auto_install
	mkdir -p  $(CURDIR)/debian/gphys/usr/share/man/man1
	for f in $(MANSRC) ; do \
		( cd $(CURDIR)/bin/ && rd2 -r rd/rd2man-lib $$f  | \
		perl -pe 's/fi\.TP/fi\n.TP/g' | perl -pe 's/fi\.SS/fi\n.SS/g' \
		> $(CURDIR)/debian/gphys/usr/share/man/man1/$$f.1 ) ;\
	done
