#!/usr/bin/make -f
export DH_VERBOSE=1
export PYBUILD_NAME=llvmlite
export LLVM_CONFIG=/usr/lib/llvm-7/bin/llvm-config
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

export CXXFLAGS := $(shell DEB_CXXFLAGS_MAINT_APPEND=-fPIC dpkg-buildflags --get CXXFLAGS)

%:
ifeq (,$(findstring nodoc, $(DEB_BUILD_PROFILES)))
	dh $@ --with python2,python3,sphinxdoc --buildsystem=pybuild
else
	dh $@ --with python2,python3 --buildsystem=pybuild
endif

override_dh_auto_test:
# prevent tests break if armhf/armel is build for, see #917252
ifneq (,$(filter $(DEB_HOST_ARCH),armhf armel))
	dh_auto_test || true
else
	dh_auto_test
endif

override_dh_installdocs:
	dh_installdocs -A README.rst
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	http_proxy='127.0.0.1:9' sphinx-build -N -bhtml docs/source/ debian/llvmlite-doc/usr/share/doc/llvmlite-doc/html/
endif

override_dh_installchangelogs:
	dh_installchangelogs -A CHANGE_LOG

override_dh_python2:
	dh_python2 --no-ext-rename

override_dh_python3:
	dh_python3 --no-ext-rename

override_dh_gencontrol:
	dh_gencontrol
	if [ -f debian/.debhelper/python-llvmlite/dbgsym-root/DEBIAN/control ]; then \
	echo "Conflicts: python3-llvmlite-dbgsym" >> debian/.debhelper/python-llvmlite/dbgsym-root/DEBIAN/control; \
	echo "Conflicts: python-llvmlite-dbgsym" >> debian/.debhelper/python3-llvmlite/dbgsym-root/DEBIAN/control; fi
	# this is a fix for #868564 until debug interpreter symbols are shipped (which need to be coninstallable)
