#!/usr/bin/make -f

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

include /usr/share/dpkg/pkg-info.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

PERL_VERSION := $(shell perl -MExtUtils::MM -e 'print MM->parse_version("bindings/perl/lib/Net/Oping.pm");')
DEB_DELTA := $(shell echo $(DEB_VERSION) | sed s/$(DEB_VERSION_EPOCH_UPSTREAM)-//)
LIBPERL_VERSION := $(DEB_VERSION_EPOCH_UPSTREAM)-$(PERL_VERSION)-$(DEB_DELTA)

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --with-perl-bindings="INSTALLDIRS=vendor"

execute_before_dh_auto_build:
	@echo "delete any existing man pages to force rebuilding"
	-rm --verbose src/mans/*.[1-8]

execute_after_dh_auto_build:
	-chrpath --list bindings/perl/blib/arch/auto/Net/Oping/Oping.so
	chrpath --delete bindings/perl/blib/arch/auto/Net/Oping/Oping.so

execute_after_dh_fixperms:
	chmod u+s debian/oping/usr/bin/oping debian/oping/usr/bin/noping

override_dh_gencontrol:
	dh_gencontrol -Nlibnet-oping-perl
	dh_gencontrol -plibnet-oping-perl -- -v$(LIBPERL_VERSION)
