#!/usr/bin/make -f
# debian.rules file originally from GNU Hello (1.3).
# Copyright 1994,1995 by Ian Jackson.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself.  (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)

package=debiandoc-sgml

build:
	$(checkdir)
	$(MAKE) prefix=/usr

clean:
	$(checkdir)
	$(MAKE) clean
	-rm -rf *~ debian/tmp debian/*~ debian/files*

binary-arch:	checkroot build
	$(checkdir)

binary-indep:		checkroot build
	-rm -rf debian/tmp
	install -d debian/tmp debian/tmp/DEBIAN
	install -d debian/tmp/usr/doc/$(package)
	$(MAKE) prefix=debian/tmp/usr install
	find debian/tmp/usr/man -type f | xargs gzip -9v
	set -e; for f in html lout text textov; do \
		rm debian/tmp/usr/man/man1/debiandoc2$$f.1; \
		ln -s debiandoc2ps.1.gz debian/tmp/usr/man/man1/debiandoc2$$f.1.gz; \
	done
	cp debian/{copyright,changelog} debian/tmp/usr/doc/$(package)/.
	gzip -9v debian/tmp/usr/doc/$(package)/changelog
	dpkg-gencontrol >debian/tmp/DEBIAN/control
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f debiandoc.dtd -a -f debian/rules
endef

# Below here is fairly generic really

binary:		binary-indep binary-arch

checkroot:
	$(checkdir)
	test root = "`whoami`"

.PHONY: binary source diff clean checkroot
