#!/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) --with-system-kpathsea \
	  --libdir=$(kde_libdir) --includedir=$(kde_includedir)

	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

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 `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 -a
	dh_installdocs -a
	dh_installmenu -a
	dh_installmime -a
	dh_installchangelogs -plibminimagick5
	dh_installchangelogs -plibminimagick-dev 
	dh_installchangelogs -pkview kdvi/ChangeLog
	dh_installchangelogs -pkfract kfract/ChangeLog
	dh_installchangelogs -pkghostview kghostview/ChangeLog
	dh_installchangelogs -pkpixmap2bitmap
	dh_installchangelogs -pksnapshot
	dh_installchangelogs -ppixie
	dh_installchangelogs -pkruler
	dh_installchangelogs -pkpaint kpaint/CHANGES
	dh_installchangelogs -pkiconedit
	dh_strip -a
	dh_compress -a
	dh_fixperms -a
	dh_installdeb -a
	dh_perl -a
	dh_makeshlibs -a -V
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

# Below here is fairly generic really

binary:		binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean
