#!/usr/bin/make -f

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

BUILDHOME = $(shell perl -MDebian::Debhelper::Dh_Lib -e 'Debian::Debhelper::Dh_Lib::setup_home_and_xdg_dirs; print $$ENV{"HOME"};')

%:
	dh $@

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	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) git config --global init.defaultBranch "main"
	dh_auto_test
endif

override_dh_auto_install:
	dh_auto_install
	# remove a manpage 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/*
