#!/usr/bin/make -f
# rules file for doc-base
#
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
package		:= doc-base

# directory abstraction
prefix		:= debian/$(package)
sbindir		:= $(prefix)/usr/sbin
sharedir	:= $(prefix)/usr/share/$(package)
lintiandir	:= $(prefix)/usr/share/lintian/overrides

# build abstraction
install_file	:= install -o root -g root -m 644
install_script	:= install -o root -g root -m 755

# determine our version number
DEB_VERSION	:= $(shell LC_ALL=C dpkg-parsechangelog | grep ^Version: | sed 's/^Version: *//')
DEB_DATE	:= $(shell dpkg-parsechangelog | sed -n 's/^Date: *//p')
# pretty-print the date; I wish this was dynamic like the top-level makefile but oh well
DATE_EN		:= $(shell LC_ALL=C     date --date="$(DEB_DATE)" '+%d %B, %Y')

build: build-stamp
build-stamp:
	dh_testdir
	
	perl -cw install-docs		# check perl script syntax
	rm -f version.ent
	echo "<!entity version \"$(DEB_VERSION)\">" >> version.ent
	echo "<!entity date    \"$(DATE_EN)\">"        >> version.ent
	nsgmls -wall -s -E20 doc-base.sgml	# check SGML syntax
	debiandoc2html doc-base.sgml
	debiandoc2text doc-base.sgml
	pod2man --section=8 --center="Debian Utilities"		\
		--release="doc-base v$(DEB_VERSION)"		\
		install-docs > install-docs.8
	pod2html --title "install-docs reference" 		\
		< install-docs > install-docs.html
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	rm -rf doc-base.html doc-base.txt* install-docs.8 install-docs.html
	rm -f pod2htm*.tmp version.ent
	rm -f `find . -name "*~"`
	dh_clean



install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(install_script) install-docs $(sbindir)/
	$(install_file) doc-base.desc $(sharedir)/doc-base
	$(install_file) install-docs.desc $(sharedir)/install-docs-man
	$(install_file) scrollkeeper.map $(sharedir)/data/
	$(install_file) debian/lintian-overrides $(lintiandir)/$(package)

	

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_installexamples
#	dh_installmenu
#	dh_installdebconf
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installcatalogs
#	dh_installpam
#	dh_installmime
#	dh_installinit
#	dh_installcron
#	dh_installinfo
#	dh_undocumented
	dh_installman install-docs.8
	dh_link
	dh_compress
	dh_fixperms
	dh_perl
#	dh_python
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install
# We have nothing to do by default.

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