#!/usr/bin/make -f

export PYBUILD_NAME=mutagen

# This is generally a good idea to avoid littering the filesystem with unneeded
# pyc files, but it is also specifically needed to avoid byte-compilation of
# the binaries in tools/ when the test suite is run.
export PYTHONDONTWRITEBYTECODE=yes

# Set UTF-8 locale as the tests expect this
export LC_ALL=C.UTF-8


%:
	dh $@ --with python2,python3,pypy,sphinxdoc --buildsystem=pybuild


override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=$(CURDIR) docs/id3_frames_gen.py > docs/api/id3_frames.rst
	$(MAKE) -C docs
	mv docs/_build docs/html
	$(MAKE) -C docs/man


override_dh_auto_install:
	dh_auto_install
	# Don't ship binaries or manpages in the pypy or python3 packages
	rm -rf debian/pypy-mutagen/usr/bin \
	       debian/pypy-mutagen/usr/lib/pypy/share \
	       debian/python3-mutagen/usr/bin \
	       debian/python3-mutagen/usr/share


override_dh_installchangelogs:
	dh_installchangelogs NEWS


override_dh_clean:
	dh_clean
	rm -rf docs/html docs/man/_man


override_dh_auto_test:
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="{interpreter} setup.py test" dh_auto_test
