#!/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 
	./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
	mkdir -p debian/tmp/etc/kde2
	make DESTDIR=`pwd`/debian/tmp/ install
	-rm -f debian/tmp/usr/bin/kdessh
	perl -w admin/debianrules cleanup
	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 -pkhexedit usr/share/doc/kde/HTML/en/khexedit/bookmarks.html
	for package in `cat debian/control | grep Package | grep -v kdeutils | sed -e 's#^Package: ##'`; do \
		list=`cd debian/tmp && find ./ -name "*$$package*" | sed -e 's#^./##'` ;\
		dh_movefiles -p$$package $$list ;\
	done
	list=`cd debian/tmp && find ./ -name "*kcmdf*" | sed -e 's#^./##'` ;\
	list2=`cd debian/tmp && find ./ -name "*kwik*" | sed -e 's#^./##'` ;\
        dh_movefiles -pkdf $$list $$list2 usr/share/icons/locolor/16x16/devices/nfs*
	list=`cd debian/tmp && find ./ -name "*laptop*" | sed -e 's#^./##'` ;\
	list2=`cd debian/tmp && find ./ -name "*power*" | sed -e 's#^./##'` ;\
	dh_movefiles -pklaptopdaemon $$list $$list2 \
		etc/kde2/applnk/Settings/Information/pcmcia.desktop \
		etc/kde2/applnk/Settings/PowerControl/*
	dh_movefiles -pkedit etc/kde2/applnk/Editors/KEdit*
	dh_movefiles -pkfind etc/kde2/applnk/Kfind.desktop
	dh_movefiles -pkcharselect etc/kde2/applnk/Utilities/KCharSelect.desktop
	dh_movefiles -pkfloppy etc/kde2/applnk/Utilities/KFloppy.desktop
	dh_movefiles -pkljettool etc/kde2/applnk/Utilities/KLJetTool.desktop
	dh_movefiles -pklpq etc/kde2/applnk/Utilities/KLpq.desktop
	dh_movefiles -pkjots etc/kde2/applnk/Utilities/Kjots.desktop
	dh_installdocs
	dh_installmenu
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_perl
	dh_suidregister
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	-for package in `cat debian/control | grep Package | grep -v kdeutils | sed -e 's#^Package: ##'`; do \
		cd debian/$$package ;\
		find ./$(kde_confdir) -type f -print | sed -e 's#^./#/#' > DEBIAN/conffiles ;\
		chmod 644 debian/$$package/DEBIAN/conffiles ;\
		cd ../../ ;\
	done
	dh_md5sums
	dh_builddeb    

# Below here is fairly generic really

binary:		binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean
