#!/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.

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

DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

# Upstream does not use CPPFLAGS
CFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS) \
	$(shell dpkg-buildflags --get CFLAGS)
export CFLAGS

PYTHON2=$(shell pyversions -vr)

# Prevent setuptools/distribute from accessing the internet.
export http_proxy = http://127.0.0.1:9

%:
	dh  $@ --with python2

#ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
#test-python%:
#	cd python && python$* setup.py test -vv
#
#override_dh_auto_test: $(PYTHON2:%=test-python%) $(PYTHON3:%=test-python%)
#endif

.PHONY: override_dh_auto_build
override_dh_auto_build:
	dh_auto_build
	dh_auto_build --sourcedirectory=python --buildsystem=python_distutils

.PHONY: override_dh_auto_install
override_dh_auto_install:
	make install \
		DESTDIR=$(CURDIR)/debian/tmp \
		PREFIX=/usr \
		LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
		LDCONFIG=true
	dh_auto_install --sourcedirectory=python --buildsystem=python_distutils

.PHONY: override_dh_auto_clean
override_dh_auto_clean:
	dh_auto_clean
	dh_auto_clean --sourcedirectory=python --buildsystem=python_distutils
	dh_auto_clean --sourcedirectory=python --buildsystem=makefile

.PHONY: override_dh_makeshlibs
override_dh_makeshlibs:
	dh_makeshlibs -a -- -c4

.PHONY: override_dh_shlibdeps
override_dh_shlibdeps:
	dh_shlibdeps -a -- --warnings=7

.PHONY: override_dh_install
override_dh_install:
	dh_install --list-missing -X.pyc
