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

include /usr/share/dpkg/pkg-info.mk

export PYBUILD_NAME=xmlschema

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_build:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH="$(shell pybuild --print {build_dir} --interpreter python3)" http_proxy="127.0.0.1:9" https_proxy="127.0.0.1:9" \
	$(MAKE) -C doc html
endif

execute_after_dh_auto_install:
	for CMD in xmlschema-json2xml xmlschema-validate xmlschema-xml2json ; \
	do \
		PYTHONPATH="debian/python3-xmlschema/$(shell pybuild --print {install_dir} --interpreter python3)" \
		help2man \
			--version-string $(DEB_VERSION_UPSTREAM) \
			--no-info \
			--output $$CMD.1  \
			--name "REPLACE" \
			debian/python3-xmlschema/usr/bin/$$CMD ;\
	done
	sed -i -e 's/REPLACE/XML to JSON converter/' xmlschema-xml2json.1
	sed -i -e 's/REPLACE/XML validator/' xmlschema-validate.1
	sed -i -e 's/REPLACE/JSON to XML converter/' xmlschema-json2xml.1

override_dh_installdocs:
	dh_installdocs --package=python-xmlschema-doc --doc-main-package=python3-xmlschema
	dh_installdocs --remaining-packages
