#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

export LC_ALL=C.UTF-8

export PYBUILD_NAME=biom-format
export PYBUILD_DESTDIR=debian/python3-$(PYBUILD_NAME)
export PYBUILD_BEFORE_TEST=cp -r {dir}/examples {build_dir}
export PYBUILD_AFTER_TEST=rm -rf {build_dir}/examples

## When trying better hardening the build fails
# export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

%:
	dh $@ --with bash-completion,sphinxdoc,numpy3 --buildsystem=pybuild

override_dh_auto_build:
	# arch
	USE_CYTHON=true dh_auto_build
	# indep:
	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build -N -b html doc build/html
	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build -N -b man doc build/man

execute_after_dh_installdocs-indep:
	dh_sphinxdoc --indep

execute_after_dh_fixperms:
	find debian -name exercise_cli.sh -exec chmod +x \{\} \;

execute_after_dh_installexamples:
	find debian -name "*.c" -delete
	find debian -name "*.pyx" -delete
	# move tests from Python3 package to examples package
	if [ ! -d biom/tests ] ; then \
	    mv `find debian/python*$(PYBUILD_NAME) -name tests -type d` biom ; \
	else \
	    find debian/python*$(PYBUILD_NAME) -name tests -type d | xargs rm -rf ; \
	fi

execute_after_dh_auto_install:
	find $(PYBUILD_DESTDIR) -name .coverage -delete

execute_after_dh_python3:
	rm -rf debian/*/usr/lib/python3.14/dist-packages/biom_format-2.1.17.dist-info
	rmdir debian/*/usr/lib/python3.14/dist-packages
	rmdir debian/*/usr/lib/python3.14
