#!/usr/bin/make -f
# This debian/rules file is provided as a template for normal perl
# packages. It was created by Marc Brockschmidt <marc@dch-faq.de> for
# the Debian Perl Group (http://pkg-perl.alioth.debian.org/) but may
# be used freely wherever it is useful.

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

# If set to a true value then MakeMaker's prompt function will
# always return the default without waiting for user input.
export PERL_MM_USE_DEFAULT=1

PACKAGE=$(shell dh_listpackages)

ifndef PERL
PERL = /usr/bin/perl
endif

TMP     =$(CURDIR)/debian/$(PACKAGE)

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	export DEB_CFLAGS_MAINT_APPEND:=-Wall
else
	export DEB_CFLAGS_MAINT_APPEND:=-Wall -ffunction-sections
endif

export DEB_LDFLAGS_MAINT_APPEND:=-Wl,--as-needed

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

configure: configure-stamp
configure-stamp:
	dh_testdir
	# Add here commands to configure the package
	dh_auto_configure

	touch configure-stamp


build-arch: build
build-indep: build

build: build-stamp
build-stamp: configure
	dh_testdir

	# As this is a architecture dependent package, we are not
	# supposed to install stuff to /usr/share. MakeMaker creates
	# the dirs, we prevent this by setting the INSTALLVENDORARCH
	# and VENDORARCHEXP environment variables.

	# Add commands to compile the package here
	$(MAKE) LD_RUN_PATH=""

	touch $@

test: test-stamp
test-stamp: build-stamp
	dh_testdir
	-$(MAKE) TEST_VERBOSE=1 DISPLAY="" test
	touch test-stamp

clean:
	dh_testdir
	dh_testroot

	dh_clean build-stamp configure-stamp install-stamp

	# Add commands to clean up after the build process here
	[ ! -f Makefile ] || $(MAKE) realclean

install: install-stamp
install-stamp: build-stamp test
	dh_testdir
	dh_testroot
	dh_prep

	# Add commands to install the package into debian/$PACKAGE_NAME here
	$(MAKE) install DESTDIR=$(TMP) PREFIX=/usr

	touch $@

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do here for an architecture-dependent package

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installexamples 
	dh_installdocs README
	dh_installchangelogs Changes
	dh_shlibdeps
	dh_strip
	dh_perl
	dh_pdl
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
