#!/usr/bin/make -f

# determine upstream version to be used in other env vars
export DEB_UPSTREAM_VERSION = \
	$(shell dpkg-parsechangelog -SVersion | cut -d- -f1)

# setuptools-scm's heuristics fail to determine the package version
# which causes the build to fail, so just override it
export SETUPTOOLS_SCM_PRETEND_VERSION = ${DEB_UPSTREAM_VERSION}

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

override_dh_installchangelogs:
	dh_installchangelogs RELEASE_NOTES.rst

# the pybuild build system does not yet support running py.test tests
# with pytest-runner  (pytest-runner is necessary to run the test
# suite in advance of ocrmypdf being installed)
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	python3 setup.py test
endif

# requires ocrmypdf already installed!
.PHONY: gen-man-page
gen-man-page:
	help2man ocrmypdf --no-info \
		-n "add an OCR text layer to PDF files" \
		> debian/ocrmypdf.1
