#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

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

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

ifndef PERL
     PERL = /usr/bin/perl
endif

TMP=$(CURDIR)/debian/libnet-dns-perl

# dh_strip handles nostrip option. INSTALL_PROGRAMM not used.
#ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
#        INSTALL_PROGRAM += -s
#endif


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

	touch configure-stamp

build: build-arch build-indep
build-arch: build-stamp configure-stamp
build-indep: build-stamp
build-stamp:
	dh_testdir

	# Add here commands to compile the package.
	#$(MAKE)
	#/usr/bin/docbook-to-man debian/Net-DNS.sgml > Net-DNS.1

	$(PERL) Makefile.PL INSTALLDIRS=vendor --noonline-tests
		# --online-tests --IPv6-tests

	# COMPRESS='gzip -9'

	$(MAKE) OPTIMIZE="$(CFLAGS)" OTHERLDFLAGS="$(LDFLAGS)"
		# CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
		# OPTIMIZE="$(CFLAGS)"

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) test
endif

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

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

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs

	# Add here commands to install the package into temporary directory.
	$(MAKE) install DESTDIR=$(TMP)

	# As this is a architecture dependent package, we are not supposed to install
	# stuff to /usr/share/perl5. MakeMaker creates the dirs, we delete them from 
	# the deb:
	[ ! -d $(TMP)/usr/share/perl5 ] || rmdir --ignore-fail-on-non-empty --parents --verbose $(TMP)/usr/share/perl5

	# add override as .pm files may go to /usr/lib/.. if they accompany binary parts
	# cp debian/lintian-override $(TMP)/usr/share/lintian/overrides/libnet-dns-perl

# Build architecture-independent files here.
binary-indep: build install

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
#	dh_installdebconf	
	dh_installdocs
	dh_installexamples contrib demo
	dh_installmenu
#	dh_installemacsen
#	dh_installpam
#	dh_installinit
	dh_installcron
	dh_installman
	dh_installinfo
#	dh_undocumented
	dh_installchangelogs Changes
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	# You may want to make some executables suid here.
#	dh_suidregister
#	dh_makeshlibs
	dh_installdeb
	dh_perl
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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