#!/usr/bin/make -f

%:
	dh $@ --with python2 -Spython_distutils

override_dh_fixperms:
	chmod +x `grep '^#!' debian/ansible/usr/share/ansible/*/* -n | grep ':1:' | cut -d: -f 1`
	dh_fixperms

override_dh_auto_build:
	dh_auto_build
	# html documentation
	cp -a docsite/ docbuild
	cp debian/missing-files/*.jpg docbuild
	PYTHONPATH=../lib make docs -C docbuild
	mv docbuild/htmlout html
	cp -r docbuild/man html/
	rm -rf docbuild
	# man pages for the "man3" section
	make docs

override_dh_auto_clean:
	# sphinx auto-build stuff
	rm -rf html docs/man/man3/*.3
	dh_auto_clean

override_dh_installchangelogs:
	dh_installchangelogs CHANGELOG.md

DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^+]+).*,\1,p')
get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=.
	rm -rf ansible-$(DEB_UPSTREAM_VERSION)
	tar -xf ansible_$(DEB_UPSTREAM_VERSION).orig.tar.gz
	rm ansible_$(DEB_UPSTREAM_VERSION).orig.tar.gz
	rm ansible-$(DEB_UPSTREAM_VERSION)/docsite/_static/jquery.js
	rm ansible-$(DEB_UPSTREAM_VERSION)/docsite/_static/underscore.js
	GZIP=--best tar -cz --owner root --group root --mode a+rX \
		-f ansible_$(DEB_UPSTREAM_VERSION)+dfsg.orig.tar.gz \
		ansible-$(DEB_UPSTREAM_VERSION)
	rm -r ansible-$(DEB_UPSTREAM_VERSION)
