#!/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.
export DH_COMPAT=3

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 cvs;\
	fi 
	./configure $(configkde)
	$(MAKE)
	
	touch build-stamp

clean: debian-clean
	dh_clean

debian-clean:
	dh_testdir
	-$(MAKE) -f admin/Makefile.common cvs-clean

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
	$(MAKE) install DESTDIR=`pwd`/debian/tmp/
	for i in `find debian/ -type l -name "common"`; do \
		rm $$i ;\
		ln -s ../common $$i ;\
	done
	#-rm `find debian/ -name "kdbg*"`
	#-rm -rf `find debian/ -name "kdevelop*"`
	-for i in `cat subdirs`; do \
	case $$i in \
	  en_GB) \
	    dh_movefiles -pkde-i18n-engb usr/share/locale/en_GB usr/share/doc/kde-i18n/en_GB usr/share/doc/kde/HTML/en_GB ;\
	  ;; \
	  no_NY) \
	    dh_movefiles -pkde-i18n-nony usr/share/locale/no_NY usr/share/doc/kde-i18n/no_NY usr/share/doc/kde/HTML/no_NY ;\
	  ;; \
	  pt_BR) \
	    dh_movefiles -pkde-i18n-ptbr usr/share/locale/pt_BR usr/share/doc/kde-i18n/pt_BR usr/share/doc/kde/HTML/pt_BR ;\
	  ;; \
	  zh_CN.GB2312) \
	    dh_movefiles -pkde-i18n-zhcngb2312 usr/share/locale/zh_CN.GB2312 usr/share/doc/kde-i18n/zh_CN.GB2312 usr/share/doc/kde/HTML/zh_CN.GB2312 ;\
	  ;; \
	  zh_TW.Big5) \
	    dh_movefiles -pkde-i18n-zhtwbig5 usr/share/locale/zh_TW.Big5 usr/share/doc/kde-i18n/zh_TW.Big5 usr/share/doc/kde/HTML/zh_TW.Big5 ;\
	 ;; \
	 *) \
	  dh_movefiles -pkde-i18n-$$i usr/share/apps/amor/tips-$$i usr/share/apps/ktuberling/sounds/$$i usr/share/locale/$$i usr/share/doc/kde-i18n/$$i usr/share/doc/kde/HTML/$$i ;\
	 ;; \
	esac ;\
	done
	dh_undocumented 
	dh_installdocs
	dh_installmenu
	dh_installchangelogs
	dh_strip
	dh_compress -X.docbook -X.css -X-license -X.dcl -X.bz2
	dh_fixperms
	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
