#!/usr/bin/make -f

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

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

LIBPERL_VERSION := $(shell \
 pm_ver=$$(perl -MExtUtils::MM -e 'print MM->parse_version("bindings/perl/lib/Net/Oping.pm");'); \
 echo -n "$${DEB_VERSION%-*}-$${pm_ver}-$${DEB_VERSION\#\#*-}")

%:
	dh $@

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

override_dh_auto_build:
	-rm --verbose src/mans/*.[1-8] # always rebuild man pages
	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

override_dh_fixperms:
	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)
