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

# For DEB_VERSION_UPSTREAM
include /usr/share/dpkg/pkg-info.mk

export PYBUILD_NAME=cxxheaderparser

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

#  Some targets choke if version.py doesn't exist, and it only gets created if
#  a .git  dir is present
create_version_file:
	echo "# Autogenerated by debian/rules" > cxxheaderparser/version.py
	echo "__version__ = '$(DEB_VERSION_UPSTREAM)'" >> cxxheaderparser/version.py

execute_before_dh_auto_configure: create_version_file
	:

# This should be execute_after_dh_auto_build, but that fails because the
# module cannot be found. I'll figure that out in the next upload
override_dh_installdocs:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	PYTHONPATH=$(CURDIR) \
		http_proxy='http://127.0.0.1:9' \
		https_proxy='https://127.0.0.1:9' \
		sphinx-build -b html docs html
endif
	dh_installdocs --package=python-cxxheaderparser-doc --doc-main-package=python3-cxxheaderparser
	dh_installdocs --remaining-packages


execute_before_dh_auto_clean: create_version_file
	:

execute_after_dh_auto_clean:
	rm -f cxxheaderparser/version.py
	rm -rf cxxheaderparser.egg-info/
	rm -rf html
