#!/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: $(BUILDDIR)/build-stamp

-include debian/debiandirs

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

$(BUILDDIR)/build-stamp:
	-rm -f debian/control
	cat debian/control.in > debian/control
	for i in `cat subdirs` ; do \
	echo " ">>debian/control; \
	case $$i in \
	  en_GB) \
	    echo "Package: kde-i18n-engb-cvs">>debian/control; \
	  ;; \
	  no_NY) \
	    echo "Package: kde-i18n-nony-cvs">>debian/control; \
	  ;; \
	  pt_BR) \
	    echo "Package: kde-i18n-ptbr-cvs">>debian/control; \
	  ;; \
	  zh_CN.GB2312) \
	      echo "Package: kde-i18n-zhcngb2312-cvs">>debian/control; \
	  ;; \
	  zh_TW.Big5) \
	        echo "Package: kde-i18n-zhtwbig5-cvs">>debian/control; \
	  ;; \
	  *) \
	        echo "Package: kde-i18n-$$i-cvs">>debian/control; \
	  ;; \
	esac ;\
	echo "Architecture: all">>debian/control; \
	echo "Section: x11">>debian/control; \
	echo "Replaces: kdebase-i18n">>debian/control; \
	echo "Depends: kdebase-cvs">>debian/control; \
	echo "Conflicts: kdebase-i18n">>debian/control; \
	echo "Provides: kde-i18n">>debian/control; \
	echo "Description: $$i i18n files for KDE">>debian/control; \
	echo " This package contains the $$i i18n files for all KDE core">>debian/control; \
	echo " appliactions.">>debian/control; \
	done

	dh_testdir
	if test ! -f configure; then \
	  $(MAKE) -f admin/Makefile.common cvs;\
	fi 
	for dir in `cat subdirs`; do \
	   (echo "*** Building in $$dir"; cd $$dir && $(MAKE) -f ../Makefile.am langsubdir SUBDIRLANG=$$dir) \
	done
	for i in `cat subdirs`; do \
	  test -d $(BUILDDIR)/$$i || mkdir -p $(BUILDDIR)/$$i ;\
	  cd $(BUILDDIR)/$$i && $$PWD/../../$$i/configure $(configkde) ;\
	  cd ../.. ;\
	  echo "$$i i18n dir being built"; \
	  make -C $(BUILDDIR)/$$i ;\
	done 
	touch $(BUILDDIR)/build-stamp

clean: debian-clean
	dh_clean
	cp debian/fake.control debian/control

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

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
	for i in `cat subdirs`; do \
	case $$i in \
	  en_GB) \
	    mkdir debian/kde-i18n-engb-cvs/ ;\
	    make -C $(BUILDDIR)/$$i install DESTDIR=`pwd`/debian/kde-i18n-engb-cvs/ ;\
	  ;; \
	  no_NY) \
	    mkdir debian/kde-i18n-nony-cvs/ ;\
	    make -C $(BUILDDIR)/$$i install DESTDIR=`pwd`/debian/kde-i18n-nony-cvs/ ;\
	  ;; \
	  pt_BR) \
	    mkdir debian/kde-i18n-ptbr-cvs/ ;\
	    make -C $(BUILDDIR)/$$i install DESTDIR=`pwd`/debian/kde-i18n-ptbr-cvs/ ;\
	  ;; \
	  zh_CN.GB2312) \
	    mkdir debian/kde-i18n-zhcngb2312/ ;\
	    make -C $(BUILDDIR)/$$i install DESTDIR=`pwd`/debian/kde-i18n-zhcngb2312-cvs/ ;\
	  ;; \
	  zh_TW.Big5) \
	    mkdir debian/kde-i18n-zhtwbig5-cvs/ ;\
	    make -C $(BUILDDIR)/$$i install DESTDIR=`pwd`/debian/kde-i18n-zhtwbig5-cvs/ ;\
	 ;; \
	 *) \
	  mkdir debian/kde/i18n-$$i-cvs/ ;\
	  make -C $(BUILDDIR)/$$i install DESTDIR=`pwd`/debian/kde-i18n-$$i-cvs/ ;\
	 ;; \
	esac ;\
	done
	perl -w admin/debianrules
	dh_undocumented 
	dh_installdocs
	dh_installmenu
	cp debian/README.i18n debian/tmp/usr/share/doc/kde-i18n-cvs
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_suidregister
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	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
