#!/usr/bin/make -f
# Verbose mode
export DH_VERBOSE=1

%:
	dh $@ --with python2

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	bash run_tests.sh -N
endif

override_dh_auto_build:
	dh_auto_build
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	python setup.py build_sphinx
else
	mkdir -p $(CURDIR)/build/sphinx/html
	mkdir -p $(CURDIR)/build/sphinx/man
	touch $(CURDIR)/build/sphinx/man/keystone-manage.1
endif

override_dh_install:
	dh_install
	chmod -x $(CURDIR)/debian/python-keystone/usr/lib/python*/dist-packages/keystone/test/etc/ldap.conf.template
	sed -i 's|^log_file = keystone.log$$|log_file = /var/log/keystone/keystone.log|' \
		$(CURDIR)/debian/keystone/etc/keystone/keystone.conf
	sed -i 's|^sqlite = sqlite:///keystone.db$$|sqlite = sqlite:///var/lib/keystone/keystone.db|' \
		$(CURDIR)/debian/keystone/etc/keystone/keystone.conf

override_dh_clean:
	rm -rf $(CURDIR)/build $(CURDIR)/keystone.egg-info
	rm -rf $(CURDIR)/keystone/test/*.log
	rm -rf $(CURDIR)/doc/source/sourcecode
	rm -rf $(CURDIR)/admin.log $(CURDIR)/keystone-legacy-auth.log
	dh_clean
