#!/usr/bin/make -f
# Made with the aid of debmake, by Christoph Lameter,
# games on the sample debian/rules file for GNU hello by Ian Jackson.

BUILDDIR = ./build

build: build-stamp

-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 
	-mv subdirs subdirs.tmp
	-cat subdirs.tmp | grep -v kdessh > subdirs
	-rm -f subdirs.tmp
	./configure $(configkde)

	make

	touch build-stamp

clean: debian-clean
	dh_clean

debian-clean:
	dh_testdir
	-rm -f debian/debiandirs
	if test -d CVS; then \
	  make -f admin/Makefile.common cvs-clean ;\
	fi
	-make distclean

binary-indep:	build
	dh_testroot
	dh_testdir
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch: build
	dh_testdir
	dh_testroot
	dh_clean -k
	-rm -f debian/undocumented
	install -d debian/tmp/etc/kde2
	install -d debian/tmp/usr/share/lintian/overrides
	make DESTDIR=`pwd`/debian/tmp/ install
	perl -w admin/debianrules cleanup
	cp debian/*.override debian/tmp/usr/share/lintian/overrides/
	for i in `ls debian/tmp/usr/share/lintian/overrides/`; do \
		mv debian/tmp/usr/share/lintian/overrides/$$i debian/tmp/usr/share/lintian/overrides/`echo $$i | sed -e 's#.override##'`; \
	done
	for i in `find debian/tmp/usr/bin | sed -e 's#^debian/tmp/usr/bin/##'  | grep -v "debian/tmp"`; do \
	  echo "$$i.1" >> debian/undocumented ;\
	done
	for i in `cat debian/undocumented.in | grep -v "#"`; do \
	  echo "$$i.1" >> debian/undocumented ; \
	done
	for i in `find debian/ -type l -name "common"`; do \
		rm $$i; \
		ln -s ../common $$i ;\
	done
	dh_undocumented
	dh_movefiles
	-rm -rf debian/tmp/usr/share/doc/kde/HTML/en/kdf
	dh_installdocs
	dh_installmenu
	dh_installmime
	dh_installchangelogs -ptask-kdeutils
	dh_installchangelogs -pkdeutils-dev
	dh_installchangelogs -park ark/ChangeLog
	dh_installchangelogs -pkarm karm/ChangeLog
	dh_installchangelogs -pkcalc kcalc/ChangeLog
	dh_installchangelogs -pkedit kedit/ChangeLog
	dh_installchangelogs -pkfind kfind/ChangeLog
	dh_installchangelogs -pknotes knotes/ChangeLog
	dh_installchangelogs -pkjots kjots/CHANGES
	dh_installchangelogs -pklpq klpq/CHANGES
	dh_installchangelogs -pkpm kpm/CHANGES
	dh_installchangelogs -pkab
	dh_installchangelogs -pkcharselect
	dh_installchangelogs -pkdepasswd
	dh_installchangelogs -pkfloppy
	dh_installchangelogs -pkhexedit
	dh_installchangelogs -pklaptopdaemon
	dh_installchangelogs -pkljettool
	dh_installchangelogs -pktimemon
	dh_strip
	dh_compress
	dh_fixperms
	dh_perl
	dh_suidregister
	dh_makeshlibs -pktimemon
	dh_makeshlibs -pkedit
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	chmod 644 debian/knotes/DEBIAN/conffiles
	dh_md5sums
	dh_builddeb    

# Below here is fairly generic really

binary:		binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean
