#!/usr/bin/make -f

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

BINDIR=$(CURDIR)/debian/$(DEB_SOURCE)/usr/bin

export PYBUILD_NAME = pbh5tools

%:
	LC_ALL=C.UTF-8 dh $@ --with python2 --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build
	$(MAKE) -C doc html
# Examples require cram
#	$(MAKE) example-rendered


override_dh_install:
	dh_install
	# We do this here rather than in .install files so that debhelper
	# takes care of the #!/usr/bin/env lines for us
	mv $(BINDIR)/bash5tools.py $(BINDIR)/bash5tools
	mv $(BINDIR)/cmph5tools.py $(BINDIR)/cmph5tools

# cram is not in Debian, but required to run some of the tests.
# This override skips building the tests to allow full package build in
# the meantime.
# cram's source is at https://bitbucket.org/brodie/cram
override_dh_auto_test:
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="{interpreter} setup.py test" \
	  dh_auto_test

override_dh_auto_clean:
	dh_auto_clean
	$(MAKE) clean
