#!/usr/bin/make -f
# copied and modified from the rules file for docbook-xml
#
# Some bytes in this file may have been touched by Ian Jackson,
# so I can never remove his name from this file.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

package		:= gnome-doc-tools

# directory abstraction
prefix		:= debian/tmp
sgmldir		:= $(prefix)/usr/lib/sgml
dtddir		:= $(sgmldir)/dtd/$(package)
entitydir	:= $(sgmldir)/entities
dsssldir	:= $(sgmldir)/stylesheet/dsssl/$(package)
docdir		:= $(prefix)/usr/share/doc/$(package)
confdir		:= $(prefix)/etc/sgml/$(package)
bindir		:= $(prefix)/usr/bin
mandir		:= $(prefix)/usr/man/man1

# tool abstraction
install_file	:= install -o root -g root -m 644 -p
install_script	:= install -o root -g root -m 755 -p
make_dir	:= install -d -o root -g root -m 755
compress	:= gzip -9f


build:
#	nothing to be done

clean:
	$(checkdir)
	dh_clean
#	 specifically derived files
	rm -f debian/catalog debian/conffiles
	dh_clean

binary-indep:	build
	$(checkdir)
	$(checkroot)
	dh_clean -k
	$(make_dir) $(prefix)/DEBIAN				\
	  $(dtddir) $(entitydir) $(dsssldir)			\
	  $(confdir) $(bindir) $(mandir) $(docdir)
#	 clear conffiles
	: > debian/conffiles

#	 note that throughout we have to be careful to try to retain
#	 the expected system entity names (dir and file names) as 
#	 shipped, in the hope to accomodate XML tools that don't
#	 understand SGML Open Catalogs

#	 process our SGML catalog, using variables set here in the rules file
	sed -e 's|%{ENTITYDIR}|$(subst $(sgmldir)/,,$(entitydir))|;\
		s|%{DTDDIR}|$(subst $(sgmldir)/,,$(dtddir))|'	\
		debian/catalog.in > debian/catalog
	$(install_file) debian/catalog $(dtddir)/

#	 DTDs
	set -e; for file in *.dtd; do \
	  $(install_file) $$file $(dtddir)/	;\
	done

#	 documentation, examples
	$(install_file) README $(docdir)/
	$(compress) $(docdir)/README
	$(install_file) debian/README.Debian $(docdir)/
	$(compress) $(docdir)/README.Debian
	$(install_file) debian/copyright $(docdir)/copyright
	$(compress) $(docdir)/copyright
	$(install_file) debian/changelog $(docdir)/changelog.Debian
	$(compress) $(docdir)/changelog.Debian
	$(install_file) dbnochunks.1 $(mandir)/
	$(compress) $(mandir)/dbnochunks.1
	$(install_file) gnome-db2html.1 $(mandir)/
	$(compress) $(mandir)/gnome-db2html.1

#	 scripts
	$(install_file) dbnochunks $(bindir)/dbnochunks
	$(install_file) gnome-db2html $(bindir)/gnome-db2html

#	 stylesheets
	$(install_file) *dsl $(dsssldir)/

#	 create all the extended links as specified in the Debian SGML Guidelines
	[ -x /usr/share/sgml-data/sgml-catalog-check.pl ] ||	\
	  ( echo "ERROR: install the sgml-data package" && exit 1 )
#	 we have to ignore errors due to the symlink to /etc
	-usr/share/sgml-data/sgml-catalog-check.pl -l -v 0 debian/catalog

#	 check that maintainer scripts are good
	sh -n debian/postinst
	sh -n debian/prerm
	sh -n debian/postrm

	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch: build
# nothing to be done

define checkdir
	test -f png-support-3.0.dtd
	test -f png-support-3.1.dtd
	test -f debian/rules
endef

# Below here is fairly generic really

binary:		binary-indep binary-arch

define checkroot
	test `id -u` = 0
endef

.PHONY: binary binary-arch binary-indep clean

#Local variables:
#mode: makefile
#End:
