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

SHELL=/bin/sh

BUILDDIR = ./build

build: $(BUILDDIR)/build-stamp

-include debian/debiandirs

debian/debiandirs: admin/debianrules
	perl -w admin/debianrules echodirs > debian/debiandirs

$(BUILDDIR)/build-stamp:
	dh_testdir
	if test ! -f configure; then \
	  $(MAKE) -f admin/Makefile.common ;\
	fi
	test -d $(BUILDDIR) || mkdir $(BUILDDIR) ;\
	cd $(BUILDDIR) ;\
	$$PWD/../configure $(configkde) \
	--libdir=/$(kde_libdir) --includedir=/$(kde_includedir) 
	make -C $(BUILDDIR)

	touch $(BUILDDIR)/build-stamp

debian-clean:
	dh_testdir
	-rm -f $(BUILDDIR)/build-stamp

clean: debian-clean
	-rm -rf $(BUILDDIR)
	-rm -f debian/debiandirs
	if test -d CVS; then \
	  make -f admin/Makefile.common cvs-clean ;\
	else \
	  -rm -rf $(BUILDDIR) ;\
	  -rm -rf debian/debiandirs ;\
	  dh_clean ; \
	fi

binary-indep:	build
	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 
	dh_installdirs
	make -C $(BUILDDIR) DESTDIR=`pwd`/debian/tmp/ install
	debianrc=debian/tmp/$(kde_confdir)/system.kdeglobals ;\
	install -d `dirname $$debianrc` ;\
	echo "[Directories]" > $$debianrc ;\
	echo "dir_config=/$(kde_confdir)" >> $$debianrc ;\
	echo "dir_html=/$(kde_htmldir)" >> $$debianrc

	perl -w admin/debianrules kdelibs3-cvs
	dh_installdocs
	if test -f /usr/bin/qt2kdoc; then \
	  (mkdir -p debian/tmp/usr/share/kdoc/index) ; \
	  (mkdir -p debian/kdelibs3-doc-cvs/usr/share/doc/kdelibs3-doc-cvs/html/kdoc-reference) ; \
	  qt2kdoc --url=/usr/share/doc/qt2.1-doc/doc/html \
	  --outdir=`pwd`/debian/tmp/usr/share/doc/kdelibs3-doc-cvs/html/kdoc-reference \
	  --compress \
	  /usr/share/doc/qt2.1-doc/doc/html ; \
	  makekdedoc --libdir=`pwd`/debian/tmp/usr/share/doc/kdelibs3-doc-cvs/html/kdoc-reference \
	  --outputdir=`pwd`/debian/kdelibs3-doc-cvs/usr/share/doc/kdelibs3-doc-cvs/html ; \
	fi

# libraries not starting with lib are modules
	dh_movefiles -pkdelibs3-dev-cvs $(kde_includedir) $(kde_libdir)/lib*.so $(kde_libdir)/lib*.la $(kde_libdir)/lib*.a
	dh_installchangelogs
	dh_undocumented
	dh_link
	dh_strip 
	dh_perl
	dh_compress 
	dh_fixperms 
	dh_suidregister 
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps 
	dh_gencontrol
	cd debian/tmp && find ./$(kde_confdir) -type f -print | sed -e 's#^./#/#' > DEBIAN/conffiles
	chmod 644 debian/tmp/DEBIAN/conffiles
	dh_md5sums
	perl -w admin/debianrules update
	dh_builddeb

# Below here is fairly generic really

binary:		binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean
