#!/usr/bin/make -f
# DH_VERBOSE := 1
export LC_ALL=C.UTF-8
include /usr/share/dpkg/default.mk
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

export PYBUILD_BEFORE_TEST=\
	mkdir -pv {build_dir}/src \
	&& cp -v src/version.h {build_dir}/src

export PYBUILD_AFTER_TEST=rm -rvf {build_dir}/src {build_dir}/non.fa

%:
	dh $@ --buildsystem pybuild --with python3

INDEXED_GZIP_DIR = /usr/lib/python3/dist-packages/indexed_gzip
execute_before_dh_auto_build:
	# Upstream originally vendored these files straight in src/, but
	# stopped for some reason.  We're pulling them instead from the
	# package python3-indexed-gzip.
	cp --update=none $(INDEXED_GZIP_DIR)/zran.c src/
	cp --update=none $(INDEXED_GZIP_DIR)/zran.h src/
	cp --update=none $(INDEXED_GZIP_DIR)/zran_file_util.c src/
	cp --update=none $(INDEXED_GZIP_DIR)/zran_file_util.h src/

execute_after_dh_installdocs:
	# Deduplicate changelog entries flagged by lintian.
	rm debian/pyfastx/usr/share/doc/pyfastx/docs/changelog.rst*
	cd debian/pyfastx/usr/share/doc/pyfastx/docs \
	&& ln -s ../changelog.gz changelog.rst.gz

execute_after_dh_installexamples:
	# Remove duplicate uncompressed files caused by the nature of the test;
	# we can get them back during the CLI test.
	rm debian/pyfastx/usr/share/doc/pyfastx/examples/test.fa
	rm debian/pyfastx/usr/share/doc/pyfastx/examples/test.fq
