#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export PYBUILD_NAME=psycopg2
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_build-indep: export PYBUILD_NAME=psycopg2-doc-only
override_dh_auto_build-indep:
	dh_auto_build -i
	set -e; export PYTHONPATH=$(shell pybuild --print build_dir --interpreter python3) PYTHON_VERSION=3; \
	python3 doc/src/tools/make_sqlstate_docs.py psycopg/sqlstate_errors.h > doc/src/sqlstate_errors.rst; \
	cd $(CURDIR)/doc/src; make html; \
	cd $(CURDIR)/doc/src; make text; \
	rm -f _build/text/license.txt

override_dh_auto_test-arch:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ifneq ($(DEB_HOST_ARCH),hurd-i386)
	LANG=C.UTF-8 LC_ALL=C.UTF-8 \
	PSYCOPG2_TESTDB_HOST=localhost \
	PSYCOPG2_TESTDB=postgres \
	PSYCOPG2_TEST_FAST=1 \
	pg_virtualenv dh_auto_test
endif
endif

override_dh_auto_test-indep:
