#!/usr/bin/make -f

export PYBUILD_TEST_PYTEST=1
export PYBUILD_TEST_ARGS=-v
export PYBUILD_NAME=box2d

# Get version from changelog as well as lsb_release
# to compute unique build version (useful for repo mirroring systems doing file pooling)
PKG_VERSION  := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
DIST_NAME    := $(shell lsb_release -si)
DIST_RELEASE := $(shell lsb_release -sc)
DIST_VERSION := $(shell lsb_release -sr)
PKG_VERSION_TAG := $(PKG_VERSION)+$(DIST_NAME).$(DIST_RELEASE).$(DIST_VERSION)
SUBSTVARS_BINARY_VERSION := -Vbinary:Version="$(PKG_VERSION_TAG)"
SUBSTVARS_SOURCE_VERSION := -Vsource:Version="$(PKG_VERSION_TAG)"

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

override_dh_auto_clean:
	dh_auto_clean
	rm -rf library/Box2D/__init__.py \
	       library/Box2D/*.so \
	       library/Box2D/Box2D.py \
	       Box2D/Box2D_wrap.h \
	       Box2D/Box2D_wrap.cpp \
	       library/Box2D.egg-info \
	       .cache

override_dh_install:
	dh_install -X.py -X.txt -X.ttf

override_dh_gencontrol:
	dh_gencontrol -- -v"$(PKG_VERSION_TAG)" $(SUBSTVARS_BINARY_VERSION) $(SUBSTVARS_SOURCE_VERSION)
