#!/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)
	make
	touch build-stamp

clean: debian-clean
	dh_clean

debian-clean:
	dh_testdir
	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 install DESTDIR=`pwd`/debian/tmp/
	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
	list=`cd debian/tmp && find ./ -type l -name "lib*.so" | sed -e 's#^./##'` ;\
	dh_movefiles -pkdepim-dev $$list usr/lib/*.a
	dh_movefiles -pabbrowser usr/share/apps/abbrowser/* \
		usr/share/icons/hicolor/32x32/apps/abbrowser.png \
		usr/share/icons/locolor/16x16/apps/abbrowser.png \
		etc/kde2/applnk/Utilities/abbrowser.desktop \
		usr/share/man/man1/abbrowser* \
		usr/bin/abbrowser
	dh_movefiles -pkorganizer usr/bin/* usr/share/apps/korganizer/* \
		usr/share/icons/hicolor/32x32/apps/korganizer.png \
		usr/share/icons/hicolor/48x48/apps/korganizer.png \
		usr/share/icons/locolor/16x16/apps/korganizer.png \
		usr/share/icons/locolor/32x32/apps/korganizer.png \
		etc/kde2/applnk/Applications/korganizer.desktop \
		usr/share/doc/korganizer/* etc/kde2/korganizerrc \
		usr/share/man/man1/korganizer* usr/lib/*korganizer* \
		usr/share/man/man1/alarmd* \
		usr/share/man/man1/ical2vcal*
	dh_installdocs
	dh_installmenu
	dh_installmime
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_suidregister
	dh_makeshlibs
	dh_perl
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	-for package in `cat debian/control | grep Package | grep -v kdepim | sed -e 's#^Package: ##'`; do \
		cd debian/$$package ;\
		find ./etc/kde2 -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
