#!/usr/bin/make -f

PACKAGE = $(shell dh_listpackages)

# This include gives us DEB_VERSION
include /usr/share/dpkg/pkg-info.mk

%:
	dh $@

override_dh_auto_test:
	prove -r t/
	rm -f perltidy.LOG

override_dh_auto_install:
	rsync -C --recursive --links --perms --times --delete \
	    --exclude debian --exclude t --exclude .gitignore --exclude README \
	    $(CURDIR)/ debian/$(PACKAGE)
	install -d debian/$(PACKAGE)/usr/share/man/man1
	install -d debian/$(PACKAGE)/usr/share/man/man8
	for script in `ls usr/bin` ; do \
	    pod2man --release=$(DEB_VERSION) --section 1 \
		--center="User Commands" usr/bin/$${script} \
		> debian/$(PACKAGE)/usr/share/man/man1/$${script}.1 ; \
	done
	for script in `ls usr/sbin` ; do \
	    pod2man --release=$(DEB_VERSION) --section 8 \
		--center="System Commands" usr/sbin/$${script} \
		> debian/$(PACKAGE)/usr/share/man/man8/$${script}.8 ; \
	done
