#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/openstack-pkg-tools/pkgos.make

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

%:
	dh $@ --with python2,python3,systemd --buildsystem=python_distutils

override_dh_auto_install:
	pkgos-dh_auto_install

override_dh_install:
	# NOTE: generate configuration files directly
	for file in `ls etc/oslo-config-generator/*`; do \
	     PYTHONPATH=$(CURDIR) oslo-config-generator --config-file=$$file \
	        --output-file=etc/neutron/`basename $$file`; \
	done
	rm -rf $(CURDIR)/debian/python*-neutron-lbaas/usr/etc
	dh_install

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	PYTHON=python PYTHONPATH=$(CURDIR) python2-ostestr
	PYTHON=python3 PYTHONPATH=$(CURDIR) python3-ostestr
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -rf .testrepository build
	rm -f debian/*.upstart debian/*.init debian/*.service
	for file in `ls etc/oslo-config-generator/*`; do rm -f etc/neutron/`basename $$file`; done
