#!/usr/bin/make -f
# -*- makefile -*-

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

export PYBUILD_NAME=pycountry
export PYBUILD_TEST_PYTEST=1
export PYBUILD_TEST_ARGS=$(CURDIR)/src/pycountry/tests

CURVER=$(shell dpkg-parsechangelog --show-field Version)
DEBVER=$(shell echo $(CURVER) | cut -d- -f1)
UPVER=$(shell echo $(DEBVER) | cut -d+ -f1)


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

override_dh_auto_install:
	dh_auto_install
	rm -vrf $(CURDIR)/debian/python*-pycountry/usr/lib/python*/*-packages/pycountry/README.txt

override_dh_clean:
	rm -vrf $(CURDIR)/src/pycountry.egg-info/
	dh_clean

get-orig-source:
	uscan --verbose \
		--download-version $(UPVER) \
		--force-download \
		--destdir .
	unzip pycountry-$(UPVER).zip
	rm -vrf pycountry-$(UPVER)/src/pycountry/databases
	rm -vrf pycountry-$(UPVER)/src/pycountry/locales
	tar cf pycountry_$(DEBVER).orig.tar pycountry-$(UPVER)
	gzip -9 pycountry_$(DEBVER).orig.tar
	rm -vrf pycountry-$(UPVER)/ pycountry-$(UPVER).tar.gz
