#! /usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
BINDIR=$(CURDIR)/debian/python3-trx-python/usr/bin

%:
	dh $@ --buildsystem=pybuild

override_dh_installman: export PYTHONPATH=$(CURDIR)
override_dh_installman:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	help2man $(BINDIR)/tff_concatenate_tractograms.py \
		--name="concatenate multiple tractograms into one" \
		--version-string="$(DEB_VERSION_UPSTREAM)" \
		--no-info \
	> debian/tff_concatenate_tractograms.py.1
	help2man $(BINDIR)/tff_convert_dsi_studio.py \
		--name="fix DSI-Studio TRK file" \
		--version-string="$(DEB_VERSION_UPSTREAM)" \
		--no-info \
	> debian/tff_convert_dsi_studio.py.1
	help2man $(BINDIR)/tff_convert_tractogram.py \
		--name="convert tractograms files to updated file format" \
		--version-string="$(DEB_VERSION_UPSTREAM)" \
		--no-info \
	> debian/tff_convert_tractogram.py.1
	help2man $(BINDIR)/tff_generate_trx_from_scratch.py \
		--name="generate a TRX file from CSV, TXT or NPY files" \
		--version-string="$(DEB_VERSION_UPSTREAM)" \
		--no-info \
	> debian/tff_generate_trx_from_scratch.py.1
	help2man $(BINDIR)/tff_manipulate_datatype.py \
		--name="manipulate TRX file array to change data type" \
		--version-string="$(DEB_VERSION_UPSTREAM)" \
		--no-info \
	> debian/tff_manipulate_datatype.py.1
	help2man $(BINDIR)/tff_simple_compare.py \
		--name="compare tractograms by data coordinates subtraction" \
		--version-string="$(DEB_VERSION_UPSTREAM)" \
		--no-info \
	> debian/tff_simple_compare.py.1
	help2man $(BINDIR)/tff_validate_trx.py \
		--name="validate a TRX file" \
		--version-string="$(DEB_VERSION_UPSTREAM)" \
		--no-info \
	> debian/tff_validate_trx.py.1
	help2man $(BINDIR)/tff_verify_header_compatibility.py \
		--name="compare tractrograms for headers compatibility" \
		--version-string="$(DEB_VERSION_UPSTREAM)" \
		--no-info \
	> debian/tff_verify_header_compatibility.py.1
	help2man $(BINDIR)/tff_visualize_overlap.py \
		--name="display a tractogram and its density map" \
		--version-string="$(DEB_VERSION_UPSTREAM)" \
		--no-info \
	> debian/tff_visualize_overlap.py.1
	dh_installman --language=C
endif

before-pybuild-autopkgtest:
	# Pull test items that are otherwise uncaught by pybuild-autodep8.
	cp -r /usr/lib/python3/dist-packages/trx/tests \
		../../autopkgtest_tmp/build
