#!/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.


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) \
	--libdir=$(kde_libdir) --includedir=$(kde_includedir)

	make

	touch build-stamp

clean: debian-clean
	-rm -f debian/debiandirs
	dh_clean

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

install: build
	dh_testroot
	dh_testdir
	dh_clean
	-rm -f debian/undocumented
	install -d debian/tmp/etc/kde2
	install -d debian/tmp/usr/share/lintian/overrides
	make install DESTDIR=`pwd`/debian/tmp/
	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

	
binary-indep: build install
	dh_testroot
	dh_testdir


binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdirs
	install -d debian/task-koffice/usr/share/doc/task-koffice/
	for i in `find debian/ -type l -name "common"`; do \
		rm $$i ;\
		ln -s ../common $$i ;\
	done
	cp debian/README.task debian/task-koffice/usr/share/doc/task-koffice/README
	-rm -f debian/tmp/usr/share/icons/locolor/16x16/actions/wizard.png
	-rm -f debian/tmp/usr/share/icons/locolor/16x16/actions/bottom.png
	-rm -f debian/tmp/usr/share/icons/locolor/16x16/actions/rotate.png
	-rm -f debian/tmp/usr/share/icons/locolor/16x16/actions/top.png 

	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
	dh_undocumented
	dh_movefiles
	dh_installdocs
	dh_installmenu
	dh_installchangelogs -ptask-koffice
	dh_installchangelogs -pkoffice-libs
	dh_installchangelogs -pkword kword/CHANGES
	dh_installchangelogs -pkspread kspread/ChangeLog
	dh_installchangelogs -pkpresenter kpresenter/CHANGES
	dh_installchangelogs -pkoshell
	dh_installchangelogs -pkillustrator
	dh_installchangelogs -pkchart kchart/CHANGES
	dh_installchangelogs -pkoffice-dev
	dh_installmime
	dh_strip
	dh_perl
	dh_compress
	dh_fixperms
	-chmod 644 debian/kpresenter/usr/bin/kprconverter.pl
	dh_suidregister
	dh_makeshlibs -pkoffice-libs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums 
	dh_builddeb

# Below here is fairly generic really

binary:		binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean
