#!/usr/bin/make -f

%:
	dh $@ --with=python2,sphinxdoc

.PHONY: override_dh_auto_build
override_dh_auto_build:
	PYTHONPATH=. sphinx-build -b html -d docs/.build/.doctrees -N docs docs/.build/html
	dh_auto_build

.PHONY: override_dh_auto_test
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	django-admin startproject testproject
	cp debian/settings.py testproject/settings.py
	for python in $(shell pyversions -r); do \
	  rm -f testproject/test.db3 ; \
	  PYTHONPATH=".:src" $$python testproject/manage.py syncdb --settings=testproject.settings --noinput ;\
	  PYTHONPATH=".:src" $$python testproject/manage.py test --settings=testproject.settings ; \
	done
	rm -rf testproject
endif

.PHONY: override_dh_clean
override_dh_clean:
	rm -rf docs/.build/
	dh_clean

.PHONY: override_dh_auto_install
override_dh_auto_install:
	dh_auto_install
	sed -i 's/Metadata-Version: 1\.0/Metadata-Version: 1\.1/' debian/tmp/usr/lib/python2.*/*-packages/django_auth_ldap-*.egg-info
