#!/usr/bin/make -f

#export DH_VERBOSE = 1
export LC_ALL=C.UTF-8

export PYBUILD_NAME=consensuscore2

%:
	dh $@ --with python2,python3 --buildsystem=pybuild

# The python packages need to be installed as soon as they're built,
# otherwise, changing the version will overwrite the previous attempt.
define finalize
dh_auto_configure --package=$1
dh_auto_build --package=$1
dh_auto_install --package=$1
endef

# Configuration and build is done in one step.
override_dh_auto_configure:

override_dh_auto_build:
	$(call $(finalize),python-consensuscore2)
	$(call $(finalize),python3-consensuscore2)
# The static library is already built at this point.

override_dh_auto_clean:
	dh_auto_clean --buildsystem=cmake
	$(RM) include/pacbio/consensus/Version.h
	$(RM) swig/ConsensusCore2.i
	$(RM) lib/libpbconsensus.a

override_dh_clean:
	dh_clean -O--buildsystem=cmake

# The actual build uses a temporary directory for each invocation of setup.py,
# so we run a separate build for the purposes of testing.
override_dh_auto_test:
	dh_auto_configure --buildsystem=cmake
	dh_auto_build --buildsystem=cmake
	dh_auto_test --buildsystem=cmake

override_dh_python2:
	dh_python2
	dh_numpy

override_dh_python3:
	dh_python3
	dh_numpy3

# The python2 and python3 packages have the same compiled module, so their
# debug packages conflict (as reported by lintian).
# This unsuccessfully attempts to prevent producing the dbgsym package
# for one of them.
# See https://lists.debian.org/debian-devel/2015/12/msg00262.html
#override_dh_strip:
#	dh_strip --package python3-consensuscore2 --no-ddebs
#	dh_strip --remaining-packages
