#!/usr/bin/make -f

export BUILD_DATE=$(shell LC_ALL=C date -u "+%B %d, %Y" -d @"$(SOURCE_DATE_EPOCH)")
export PYBUILD_DESTDIR=debian/black/
export PYBUILD_TEST_ARGS=--run-optional no_jupyter,no_blackd -k "not (incompatible_with_mypyc or test_simple_format)"
export PYBUILD_BUILD_ARGS=--verbose
# TODO: Re-enable once upstream works properly with mypy 1.18 (many tests
# currently fail).
#export HATCH_BUILD_HOOKS_ENABLE=1
export HATCH_VERBOSE=3

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

execute_after_dh_auto_build:
	make -C docs/ html PYTHONPATH="..:../src/" SPHINXBUILD="/usr/share/sphinx/scripts/python3/sphinx-build" SPHINXOPTS="-j 4 -D today=\"$(BUILD_DATE)\""

execute_after_dh_auto_install:
	rm debian/black/usr/bin/blackd

execute_before_dh_installman:
	rst2man debian/manpage.rst > debian/black.1
	rst2man debian/manpage2.rst > debian/black-primer.1
