#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export PYBUILD_NAME=fluster
export PYBUILD_SYSTEM=pyproject
# Most functional tests download conformance vectors from the internet,
# which is not available during the build, so only run the offline ones.
# debian/pybuild.testfiles copies in the CLI script and test suites they
# need.
export PYBUILD_TEST_ARGS=tests \
	--deselect=tests/test_functional.py::TestDownload \
	--deselect=tests/test_functional.py::TestReference \
	--deselect=tests/test_functional.py::TestRun
# Some tests serve files from a local HTTP server on 127.0.0.1, so keep
# it out of the unreachable proxy pybuild sets up.
export no_proxy=localhost,127.0.0.1

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

# pybuild removes the whole build/ directory on clean, but upstream ships
# its decoder build scripts there, so only remove what the build creates.
override_dh_auto_clean:
	rm -rf .pybuild build/lib build/bdist.* *.egg-info
	find . -name __pycache__ -prune -exec rm -rf {} +

ifeq (,$(filter nodoc,$(DEB_BUILD_PROFILES)))
override_dh_auto_build:
	pandoc docs/fluster.1.md -s -t man > debian/fluster.1
	dh_auto_build
endif

# Check the staged package finds its test suites without -tsd
execute_after_dh_python3:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	DESTDIR=$(CURDIR)/debian/fluster debian/tests/list-test-suites
endif
