#!/usr/bin/make -f

export PYBUILD_NAME=psycopg2
DEFAULT_PYTHON3 = $(shell py3versions -d)
DEFAULT_BUILDIR = $(shell $(DEFAULT_PYTHON3) -c 'from distutils.command.build import build; from distutils.core import Distribution; b = build(Distribution()); b.finalize_options(); print(b.build_platlib)')
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

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

override_dh_auto_build:
	dh_auto_build -a

build-indep:
	$(DEFAULT_PYTHON3) setup.py build
	export PYTHONPATH=$(CURDIR)/$(DEFAULT_BUILDIR)/; \
	cd $(CURDIR)/doc/src; \
	make -f Makefile html; \
	make -f Makefile text; \
	rm -f _build/text/license.txt

override_dh_link:
	rm -rf $(CURDIR)/debian/python-psycopg2-dbg/usr/share/doc/python-psycopg2-dbg
	rm -rf $(CURDIR)/debian/python3-psycopg2-dbg/usr/share/doc/python3-psycopg2-dbg
	dh_link

override_dh_strip:
	dh_strip --no-automatic-dbgsym

override_dh_auto_clean:
	dh_auto_clean
	rm -rf $(CURDIR)/doc/src/_build
	rm -rf $(CURDIR)/build

override_dh_auto_test:
	# Needs running pg server
