#!/usr/bin/make -f

export DH_OPTIONS
export LC_ALL=C.UTF-8

export PYBUILD_NAME=apertium-apy
export "DEB_BUILD_MAINT_OPTIONS=hardening=+all optimize=+lto reproducible=+fixfilepath"
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_test:
	#Disable broken tests as of now
#	mkdir $(CURDIR)/testbin && \
#	ln -s /usr/bin/python3-coverage $(CURDIR)/testbin/coverage && \
#	export PATH="$(PATH):$(CURDIR)/testbin" && \
#	dh_auto_test

override_dh_auto_install:
	dh_auto_install
	#Remove extra license file
	rm -f $(CURDIR)/debian/apertium-apy/usr/share/apertium-apy/COPYING
	#Remove docs outside usr/share/doc and install them properly
	rm -f $(CURDIR)/debian/apertium-apy/usr/share/apertium-apy/README.md
	rm -f $(CURDIR)/debian/apertium-apy/usr/share/apertium-apy/tools/systemd/README

override_dh_installdocs:
	dh_installdocs
	#Rename properly
	mv $(CURDIR)/debian/apertium-apy/usr/share/doc/apertium-apy/README \
	   $(CURDIR)/debian/apertium-apy/usr/share/doc/apertium-apy/README.systemd

override_dh_installman:
	dh_installman apertium-apy.1