#!/usr/bin/make -f
export DH_VERBOSE=1

%:
	dh $@ --with python2,python3

override_dh_auto_build:
	dh_auto_build
	python3 setup.py build

override_dh_auto_install:
	dh_auto_install
	python3 setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb
	cp feedparser/sgmllib3.py $(CURDIR)/debian/tmp/usr/lib/python3/dist-packages/feedparser_sgmllib3.py

override_dh_auto_clean:
	dh_auto_clean
	rm -rf build .*egg-info

override_dh_auto_test:
	# Add back data files which were missing in upstream tarball for 5.1
	cp $(CURDIR)/debian/upstream/*.z feedparser/tests/compression
	cp $(CURDIR)/debian/upstream/*.gz feedparser/tests/compression
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	cd feedparser && python ./feedparsertest.py
	# FIXME: run tests for python3 too.  This requires running 2to3 over
	# feedparsertest.py also, and then running it against the already
	# converted feedparser.py, but still being able to find the test
	# directory.
else
	@echo "nocheck set, not running tests"
endif

override_dh_installdocs:
	dh_installdocs -Xtests

override_dh_installchangelogs:
	dh_installchangelogs NEWS
