#!/usr/bin/make -f

PYTHONS:=$(shell pyversions -r)

# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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

# We assume that the build machine is running the same environment as the
# target system.
ifeq ($(shell command -v systemctl > /dev/null && echo 1), 1)
	HELPERS = python2,systemd
else
	HELPERS = python2
endif

export PBR_VERSION=$(shell cat setup.py | grep 'version=' | awk -F \' '{print$$2}' )

%:
	dh $@ --buildsystem=python_distutils --with $(HELPERS)

override_dh_auto_install:
	set -e && for pyvers in $(shell pyversions -r); do \
		$$pyvers setup.py install --install-layout=deb \
		--root $(CURDIR)/debian/networking-cumulus; \
	done

override_dh_clean:
	dh_clean -O--buildsystem=python_distutils
	rm -rf build __pycache__
	rm -rf *.egg-info

override_dh_systemd_enable:
	dh_systemd_enable --no-enable

override_dh_systemd_start:
	dh_systemd_start --no-start

