#!/usr/bin/make -f

PACKAGE = $(shell dh_listpackages)
TMP     = $(CURDIR)/debian/$(PACKAGE)
SCRIPTS = SOAPsh stubmaker


%:
	dh $@

override_dh_auto_test:
	# explicitly turn off author tests, 2 of 4 fail horribly
	TEST_AUTHOR=0 dh_auto_test

override_dh_auto_install:
	dh_auto_install
	# fix extension, hashbang, and script names
	for F in $(SCRIPTS); do \
		mv $(TMP)/usr/bin/$$F.pl $(TMP)/usr/bin/$$F ; \
		mv $(TMP)/usr/share/man/man1/$$F.pl.1p $(TMP)/usr/share/man/man1/$$F.1p ; \
		sed -i -e '1 s,^#.*perl,#!/usr/bin/perl,' $(TMP)/usr/bin/$$F ; \
		sed -i -e 's,\.pl,,g' $(TMP)/usr/bin/$$F ; \
		sed -i -e 's,\.pl,,g' $(TMP)/usr/share/man/man1/$$F.1p ; \
	done

override_dh_installexamples:
	dh_installexamples
	find $(TMP)/usr/share/doc/$(PACKAGE)/examples/ -type f -print0 | \
		xargs -r0 sed -i -e '1 s,^#.*perl,#!/usr/bin/perl,'

override_dh_fixperms:
	dh_fixperms
	chmod 0644 $(TMP)/usr/share/doc/$(PACKAGE)/examples/COM/*.bat
