#!/usr/bin/make -f

%:
	dh $@ --with linktree

override_dh_auto_install:
	dh_auto_install
	set -ex; for langdir in debian/tmp/usr/share/doc/debian-policy/*/policy.html; do	\
		lang=$${langdir%%/policy.html};							\
		lang=$${lang##*/};								\
		mkdir -p debian/debian-policy-$$lang/usr/share/doc/debian-policy;		\
		mv debian/tmp/usr/share/doc/debian-policy/$$lang				\
			debian/debian-policy-$$lang/usr/share/doc/debian-policy;		\
	done
	mv debian/tmp/* debian/debian-policy/
#	this file is not referenced by any HTML pages and we have no
#	idea what it does, so just delete it until further
#	investigation is possible
	rm -f debian/debian-policy/usr/share/doc/debian-policy/policy.html/_static/websupport.js

# Move libjs-sphinxdoc from ${misc:Depends} into ${linktree:Recommends}
#
# There are various inconveniences caused by having the
# libjs-sphinxdoc dependencies generated by dh_linktree in
# ${misc:Depends}; see #906139
#
# This hack (suggested by Ian Jackson) can be removed once #658238 is
# resolved, such that we can switch back to dh_sphinxdoc from
# dh_linktree
override_dh_linktree:
	set -ex; for f in debian/*.substvars; do		\
		if [ "$$f" != "debian/*.substvars" ]; then	\
			mv $$f $$f.new;				\
		fi 						\
	done
	dh_linktree
	set -ex; for f in debian/*.substvars; do				\
		sed 's/^misc:Depends/linktree:Recommends/' $$f >>$$f.new;	\
		mv $$f.new $$f;							\
	done
