#!/usr/bin/make -f

PACKAGE = $(shell dh_listpackages)
TMP     = $(CURDIR)/debian/$(PACKAGE)

# maybe we only need the patchlevel and not the subversion here?
# better safe than sorry, and better consistent with other packages ...
PERL_CURRENT := $(shell perl -MConfig -e 'print "$$Config{revision}.$$Config{patchlevel}.$$Config{subversion}"')
PERL_NEXT    := $(shell perl -MConfig -e 'print "$$Config{revision}.$$Config{patchlevel}." . ($$Config{subversion} + 1)')

include      /usr/share/dpkg/architecture.mk
PERLVER      := $(shell perl -MConfig -e 'print $$Config{version}')
ARCHLIB      := $(shell perl -I/usr/lib/$(DEB_HOST_MULTIARCH)/perl/cross-config-$(PERLVER) -MConfig -e 'print $$Config{vendorarch}')

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

override_dh_auto_install:
	dh_auto_install
	chmod 0644 debian/tmp/usr/share/man/man3/common::sense.3pm
#	pod2man --name "common::sense" --utf8 --section 3pm \
#		$(TMP)$(ARCHLIB)/common/sense.pod > \
#		debian/tmp/usr/share/man/man3/common::sense.3pm
	dh_install --sourcedir=debian/tmp usr/lib/x86_64-linux-gnu/perl5/5.44/*
	dh_install --sourcedir=debian/tmp usr/share/man/man3/*

override_dh_gencontrol:
	dh_gencontrol -- -V'sameperl:Depends=perl (>= $(PERL_CURRENT)~), perl (<< $(PERL_NEXT)~)'
