#!/usr/bin/make -f

docdir := $(CURDIR)/debian/debian-history/usr/share/doc/debian-history

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp:
	dh_testdir

	# ensure our SGML is valid and build deliverables out of it
	#$(MAKE) validate all
	$(MAKE) all

	touch build-stamp

clean:
	dh_testdir
	dh_testroot

	$(MAKE) clean

	dh_clean build-stamp

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	# Install the translations.
	# The ps and pdf for the CJK languages are not generated
	set -ex; for i in project-history.*.txt; do \
          nosuffix=$${i%.txt}; \
          lang=$${nosuffix#project-history.}; \
          cp -a project-history.$$lang.html $(docdir)/$$lang; \
          ln -s index.$$lang.html $(docdir)/$$lang/index.html; \
          cp -a project-history.$$lang.txt $(docdir)/$$lang; \
          if [ "$$lang" != "ko" ]; then \
            cp -a project-history.$$lang.ps project-history.$$lang.pdf $(docdir)/$$lang; \
          fi; \
        done
	

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	set -ex; for i in debian/debian-history.doc-base.*; do \
          lang=$${i#debian/debian-history.doc-base.}; \
          cp debian/debian-history.doc-base.$$lang \
             debian/debian-history/usr/share/doc-base/debian-history.$$lang; \
        done
	dh_installchangelogs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch: build install

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install 
