#!/usr/bin/make -f

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

BUILDHOME = $(CURDIR)/debian/build

%:
	dh $@ --with bash-completion

override_dh_clean:
	dh_clean
	rm -rf $(BUILDHOME)

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	mkdir -p $(BUILDHOME)
	HOME=$(BUILDHOME) git config --global user.name "Debian Perl Group"
	HOME=$(BUILDHOME) git config --global user.email "pkg-perl-maintainers@lists.alioth.debian.org"
	HOME=$(BUILDHOME) dh_auto_test
endif

override_dh_auto_install:
	dh_auto_install
	# remove empty manpages
	find $(TMP)/usr/share/man/man1 $(TMP)/usr/share/man/man3 -type f -empty -delete
	# a template
	$(RM) $(TMP)/usr/share/man/man3/Minilla::Profile::Base.3pm

override_dh_installexamples:
	dh_installexamples
	sed -i '1s|^#!/usr/bin/env perl|#!/usr/bin/perl|' $(TMP)/usr/share/doc/$(PACKAGE)/examples/*
