#!/usr/bin/make -f
# -*- 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.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

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

export PYBUILD_NAME=dms

# This has to be exported to make some magic below work.
export DH_OPTIONS

# This variable is used to infomr DMS Makefile that it is being dpkg packaged!
# and stop it chowning chmodding
DMS_DEB_BUILD:=$(shell py3versions -vr)
export DMS_DEB_BUILD

PYTHON3:=$(shell py3versions -vr)

%:
	dh $@ --with python3

override_dh_python3:
	dh_python3 /usr/share/dms

override_dh_auto_install:
	$(MAKE) PREFIX=/usr DESTDIR=$(CURDIR)/debian/tmp install
	- find $(CURDIR)/debian/tmp -name __pycache__ | xargs rm -rf 

override_dh_install:
	dh_install

override_dh_installinit:
	dh_installinit --name dmsdmd

override_dh_auto_clean:
	dh_auto_clean
	rm -rf build
	rm -rf *.egg-info
	find . -type f -name '*.pyc' | xargs rm -f 
	find . -type d -name '__pycache__' | xargs rm -rf 
