#!/usr/bin/make -f

# Verbose mode
#export DH_VERBOSE=1

DEBVERS ?= $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
VERSION ?= $(shell echo '$(DEBVERS)' | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//')
export OSLO_PACKAGE_VERSION=$(VERSION)

%:
	dh $@ --with python2

get-orig-source:
	uscan --verbose --force-download --rename --destdir=../build-area

override_dh_install:
	dh_install --fail-missing

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	testr init && testr run
endif

override_dh_auto_build:
	dh_auto_build
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	mkdir -p doc/build/man
	mkdir -p doc/build/html
	sphinx-build -b man doc/source doc/build/man
	sphinx-build -b html doc/source doc/build/html
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -rf doc/build
	rm -rf glance.sqlite

override_dh_installinit:
	dh_installinit --name glance-api
	dh_installinit --name glance-registry
