#!/usr/bin/make -f

PKG:=$(shell dh_listpackages)
TMP:=$(CURDIR)/debian/$(PKG)

%:
	dh $@ --with components

override_dh_auto_install:
	dh_auto_install
	sed -i -e'1s/#!\/usr\/local\/bin\/perl/#/' $(TMP)/usr/share/perl5/WWW/Search/*.pm

override_dh_auto_test:
	NO_NETWORK=1 PERL5LIB=blib/lib PATH=blib/script:${PATH} dh_auto_test

override_dh_components:
	dh_components
	mv $(TMP)/usr/bin/googlism.pl $(TMP)/usr/bin/googlism
	mv $(TMP)/usr/share/man/man1/googlism.pl.1p $(TMP)/usr/share/man/man1/googlism.1p

# We had to patch Makefile.PL as otherwise the sub-directory Makefile.PL's
# are found, run and failed. Then as the patch is unapplied at the end
# Makefile is older than Makefile.PL. Makefile.PL then tries to recreate
# Makefile but is now unpatched.
override_dh_auto_clean:
	if [ -f Makefile ]; then touch Makefile; fi
	dh_auto_clean
