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

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

UVERSION := $(shell dpkg-parsechangelog | sed -n -e's/^Version: \([0-9]:\)\(.*\)-[^-]\+/\2/p')
PACKAGE_NAME := $(shell dpkg-parsechangelog | sed -n -e's/^Source: \(.*\)\+/\1/p')
PYVERS = $(shell pyversions -r)
PY3VERS = $(shell py3versions -r)
export PYBUILD_NAME=$(PACKAGE_NAME)
export PYTHONPATH=$(CURDIR)/src

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

override_dh_auto_clean:
	rm -rf docs/_build
	rm -rf src/webassets.egg-info/
	rm -f debian/webassets.1
	dh_auto_clean

override_dh_auto_install:
	dh_auto_install -Xsix.py
	# Doc
	cd docs; \
		make html; \
		cd -
	rm -f debian/python-webassets/usr/bin/webassets
	help2man --version-string=$(UVERSION) \
				--name="Asset management application for Python web development" \
				--no-info \
				debian/python3-webassets/usr/bin/webassets > debian/webassets.1

override_dh_installexamples:
	dh_installexamples -X.gitignore

get-orig-source:
	@if [ ! -d "debian" ] ; then \
		echo 'Run this from the top directory of the Debian source' >&2; \
		exit 1; \
	fi
	uscan --noconf --verbose --rename --destdir=$(CURDIR) \
		--check-dirname-level=0 --force-download --download-version $(UVERSION)
