#!/usr/bin/make -f
## ----------------------------------------------------------------------
## debian/rules : package build and install script for debiandoc-sgml-doc
## ----------------------------------------------------------------------

## ----------------------------------------------------------------------
## uncomment this to turn on verbose mode
#export DH_VERBOSE=1

## ----------------------------------------------------------------------
## Document definitions
doc_name	= debiandoc-sgml
doc_lang	= en
doc_sgml	= $(doc_name).$(doc_lang).sgml
doc_pdf		= $(doc_name).$(doc_lang).pdf
doc_txt		= $(doc_name).$(doc_lang).txt
doc_html	= $(doc_name).html

## ----------------------------------------------------------------------
## General directory definitions
prefix		= debian/tmp
share_dir	= $(prefix)/usr/share
doc_dir		= $(share_dir)/doc

## ----------------------------------------------------------------------
## Package directory definitions
pkg_name 	= $(doc_name)
pkg_html	= $(pkg_name).html
pkg_doc_dir	= $(doc_dir)/$(pkg_name)
pkg_lang_dir	= $(pkg_doc_dir)/$(doc_lang)
pkg_html_dir	= $(pkg_doc_dir)/$(pkg_html)

## ----------------------------------------------------------------------
## General (un)install definitions
SHELL		= /bin/bash
PATH		:=:$(PATH)
INSTALL		= /usr/bin/install
INSTALL_DIR	= $(INSTALL) -d -m 755
INSTALL_FILE	= $(INSTALL) -m 644

## ----------------------------------------------------------------------
## Targets

build:		build-stamp
build-stamp:	$(doc_sgml)
		dh_testdir
		nsgmls -wall -E20 -gues $^
		debiandoc2html -l $(doc_lang) -b $(doc_name) -c $^
		ln -sf index.$(doc_lang).html $(doc_html)/index.html
		debiandoc2latexpdf -l $(doc_lang) -p letter $^
		debiandoc2text -l $(doc_lang) $^
		touch build-stamp

clean:
		dh_testdir
		dh_testroot
		rm -rf $(doc_html) $(doc_pdf) $(doc_txt)
		dh_clean
		rm -f build-stamp

binary-indep:	build
		dh_testdir
		dh_testroot
		dh_clean
		dh_installdirs
		$(INSTALL_DIR) $(pkg_doc_dir)
		$(INSTALL_FILE) $(doc_sgml) $(pkg_doc_dir)
		$(INSTALL_DIR) $(pkg_lang_dir)
		$(INSTALL_FILE) $(doc_lang)/* $(pkg_lang_dir)
		$(INSTALL_DIR) $(pkg_html_dir)
		$(INSTALL_FILE) $(doc_html)/* $(pkg_html_dir)
		$(INSTALL_FILE) debian/dhelp $(pkg_html_dir)/.dhelp
		$(INSTALL_FILE) $(doc_pdf) $(pkg_doc_dir)
		$(INSTALL_FILE) $(doc_txt) $(pkg_doc_dir)
		dh_installdocs
		dh_installchangelogs
		dh_compress
		dh_fixperms
		dh_installdeb
		dh_gencontrol
		dh_md5sums
		dh_builddeb

binary-arch:

binary:		binary-indep binary-arch

.PHONY:		clean binary-indep binary-arch binary

## ----------------------------------------------------------------------
