#!/usr/bin/make -f
# Made with the aid of debmake, by Christoph Lameter,
# based on the sample debian/rules file for GNU hello by Ian Jackson.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
SHELL=/bin/sh
 
build: build-stamp

ifndef PERL
PERL=/usr/bin/perl
endif
 
TMP =`pwd`/../debian/tmp
archlib=`$(PERL) -MConfig -e 'print $$Config{installarchlib}'`
config=INSTALLARCHLIB=$(TMP)$(archlib) \
INSTALLDIRS=perl INSTALLMAN1DIR=$(TMP)/usr/share/man/man1 \
INSTALLMAN3DIR=$(TMP)/usr/share/man/man3 INSTALLPRIVLIB=$(TMP)/usr/lib/perl5 

-include debian/debiandirs

debian/debiandirs: admin/debianrules
	perl -w admin/debianrules echodirs > debian/debiandirs

build-stamp:
	dh_testdir
	if test ! -f configure; then \
	  $(MAKE) -f admin/Makefile.common ;\
	fi
	./configure $(configkde)
	$(MAKE)
	cp dcopperl/Makefile.PL debian/Makefile.back
	cp debian/Makefile.Debian.PL dcopperl/Makefile.PL
	(cd dcopperl ; $(PERL) Makefile.PL $(config) ; make )

	touch build-stamp

debian-clean:
	dh_testdir
	-rm -f build-stamp
	dh_clean

clean: debian-clean
	-rm -f debian/debiandirs
	-cp debian/Makefile.back dcopperl/Makefile.PL
	if test -d CVS; then \
	  $(MAKE) -f admin/Makefile.common cvs-clean ;\
	fi
	-make distclean

binary-indep:	build
	dh_testdir
	dh_testroot


binary-arch:  build
	dh_testdir
	dh_testroot
	dh_clean -a
	dh_installdirs
	cp debian/dcoppython.override debian/tmp/usr/share/lintian/overrides/dcoppython
	$(MAKE) DESTDIR=`pwd`/debian/tmp/ install
	$(MAKE) -C dcopperl pure_install
	-rm -f `find debian/tmp/usr/lib/` -name ".packlist"`
	perl -w admin/debianrules cleanup
	dh_installdocs -a
	dh_undocumented
	dh_movefiles -a
	dh_installchangelogs -a 
	dh_strip -a
	dh_perl -a
	dh_link -a
	dh_compress -a
	dh_fixperms -a
	dh_makeshlibs -a -V
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol 
	dh_md5sums 
	dh_builddeb -a

# Below here is fairly generic really

binary:		binary-indep binary-arch

.PHONY: binary binary-arch clean
