#!/usr/bin/make -f

DEB_BUILD_GNU_TYPE      := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE       := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
        HOST_PERL = $(shell which perl)
        PERL_VER = $(shell $(HOST_PERL) -v | $(HOST_PERL) -e 'while(<>) {/v(\d+\.\d+\.\d+)/ and print "$$1\n";}')

        export PERL5LIB=/usr/$(DEB_HOST_GNU_TYPE)/lib/perl/$(PERL_VER)
clean:
	@if [ ! -f $(PERL5LIB)/Config.pm ] || [ ! -f $(PERL5LIB)/Config_heavy.pl ]	;\
	then	\
		echo "Config.pm & Config_heavy.pl for cross building not found in $(PERL5LIB)"	;\
	exit 1	;\
	fi
	dh $@
endif

%:
	dh $@

# this package works with only perl-base, it should not depend on perl
override_dh_perl:
	dh_perl -d
