#!/usr/bin/make -f

APP=doublex
VERSION=$(shell head -n 1 debian/changelog | cut -f2 -d " " | tr -d "()" | cut -f1 -d "-")

ORIG_REPO=git clone --branch v$(VERSION) https://github.com/davidvilla/python-doublex
ORIG_DIR=$(APP)-$(VERSION)
EXCLUDE=--exclude=debian --exclude=\*~ --exclude=.hg --exclude=.svn --exclude=\*.pyc

# http://wiki.debian.org/Python/LibraryStyleGuide

PYTHON2=$(shell pyversions -vr)
PYTHON3=$(shell py3versions -vr)

%:
	dh $@ --with python3


build-python%:
	python$* setup.py build

override_dh_auto_build: $(PYTHON3:%=build-python%)
	python setup.py build --force

install-python%:
	python$* setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb

override_dh_auto_install: $(PYTHON3:%=install-python%)
	python setup.py install --force --root=./debian/tmp --no-compile -O0 --install-layout=deb

override_dh_auto_clean:
	python setup.py clean -a
	rm -rf build
	rm -rf *.egg-info

get-orig-source:
	$(ORIG_REPO) $(ORIG_DIR)
	tar $(EXCLUDE) -czf $(APP)_$(VERSION).orig.tar.gz $(ORIG_DIR)
	$(RM) -r $(ORIG_DIR)
