#!/usr/bin/make -f

VERSION = $(shell dpkg-parsechangelog | grep Version | sed "s/Version: //")
ORIG_VERSION = $(shell echo $(VERSION) | sed s/-.*//)
UPSTREAM_VERSION = $(shell echo $(ORIG_VERSION) | sed s/\.dfsg//)
TARBALL_VERSION = v$(shell echo $(UPSTREAM_VERSION) | sed s/\\.//)
TARBALL_NAME = p9m4-$(TARBALL_VERSION)
SRCDIR_NAME = p9m4-$(ORIG_VERSION)

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/simple-patchsys.mk
include /usr/share/cdbs/1/class/python-distutils.mk

DEB_PYTHON2_MODULE_PACKAGES := prover9-mace4

DEB_PYTHON_SETUP_CMD = debian/setup.py

binary-post-install/prover9-mace4::
	chmod 644 debian/prover9-mace4/usr/share/prover9-mace4/lib/*.py
#	mv debian/prover9-mace4/usr/bin/prover9-mace4.py debian/prover9-mace4/usr/bin/prover9-mace4

get-orig-source:
	-uscan --verbose --force-download --no-symlink --upstream-version $(UPSTREAM_VERSION)
	cd debian/ && tar xvzf ../../$(TARBALL_NAME).tar.gz
	rm -rf debian/$(TARBALL_NAME)/bin debian/$(TARBALL_NAME)/*.pyc
	mv debian/$(TARBALL_NAME) debian/$(SRCDIR_NAME)
	cd debian && tar cvzf ../../p9m4_$(ORIG_VERSION).orig.tar.gz $(SRCDIR_NAME)
	rm -rf debian/$(SRCDIR_NAME)

.PHONY: get-orig-source
