#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

PACKAGE = $(shell dh_listpackages)
TMP     = $(CURDIR)/debian/$(PACKAGE)
ARCHLIB := $(shell perl -MConfig -e 'print $$Config{vendorarch}')

export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

# don't run resource intensive test t/ucd.t on slow arches
include /usr/share/dpkg/architecture.mk
SLOW_ARCH = armel armhf mips mipsel sparc sparc64 m68k
ifeq (,$(filter $(DEB_HOST_ARCH), $(SLOW_ARCH)))
export TEXT_BIDI_SKIP_UCD=0
else
export TEXT_BIDI_SKIP_UCD=1
endif

%:
	dh $@

override_dh_auto_install:
	dh_auto_install
	# remove if it exists but doesn't not have a size > 0
	if [ -e $(TMP)$(ARCHLIB)/auto/Text/Bidi/private/private.bs -a \
	  ! -s $(TMP)$(ARCHLIB)/auto/Text/Bidi/private/private.bs ]; then \
	    $(RM) -v $(TMP)$(ARCHLIB)/auto/Text/Bidi/private/private.bs; \
	fi
	# Remove fribidi.pl script, installed as an example instead:
	$(RM) -rv $(TMP)/usr/bin
	$(RM) -rv $(TMP)/usr/share/man/man1

	# remove empty manpage
	$(RM) -v $(TMP)/usr/share/man/man3/Text::Bidi::private.3pm

override_dh_installexamples:
	dh_installexamples
	sed -i '1s|^#!perl|#!/usr/bin/perl|' $(TMP)/usr/share/doc/$(PACKAGE)/examples/*
