#!/usr/bin/make -f

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

%:
	dh $@

override_dh_auto_install:
	dh_auto_install

	# handle POD/manpage fun. cf. https://rt.cpan.org/Ticket/Display.html?id=97176
	# 1) recreate manpage from .pod instead of fragment in .pm
	pod2man --section=3pm --utf8 $(CURDIR)/lib/Module/Install.pod > $(TMP)/usr/share/man/man3/Module::Install.3pm
	# 2) remove manpage fragments
	for m in \
		Module::Install::Admin::Bundle.3pm \
		Module::Install::Admin::Compiler.3pm \
		Module::Install::Admin::Find.3pm \
		Module::Install::Admin::Makefile.3pm \
		Module::Install::Admin::Manifest.3pm \
		Module::Install::Admin::Metadata.3pm \
		Module::Install::Admin::ScanDeps.3pm \
		Module::Install::Admin::WriteAll.3pm \
		Module::Install::AutoInstall.3pm \
		Module::Install::DSL.3pm \
		Module::Install::Fetch.3pm \
		Module::Install::Include.3pm \
		Module::Install::Inline.3pm \
		Module::Install::MakeMaker.3pm \
		Module::Install::Metadata.3pm \
		Module::Install::Run.3pm \
		Module::Install::Scripts.3pm \
		Module::Install::Win32.3pm \
		Module::Install::WriteAll.3pm \
	; do $(RM) -v $(TMP)/usr/share/man/man3/$$m ; done
