#!/usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE = 1

export PYBUILD_NAME=django-taggit

%:
	dh $@ --buildsystem=pybuild

override_dh_clean:
	dh_clean
	rm -rf .mypy_cache

override_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=. python3 -m sphinx -b html -N docs/ $(CURDIR)/debian/python-django-taggit-doc/usr/share/doc/python-django-taggit-doc/html
	dh_sphinxdoc
endif

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	python3 -m django test --settings=tests.settings
endif

override_dh_auto_build: rebuild-locale
	dh_auto_build

rebuild-locale:
	@echo
	@echo "Rebuild the GNU message catalogs..."
	@echo
	for lang in `find taggit/locale/ -maxdepth 1 -type d | sort`; do \
	    if [ -f $${lang}/LC_MESSAGES/django.po ]; then \
	        LANG=`basename $${lang}` ;\
	        echo "Create message catalog for '$${LANG}'" ;\
	        msgfmt -v $${lang}/LC_MESSAGES/django.po -o $${lang}/LC_MESSAGES/django.mo ;\
	    fi ;\
	done
