#!/usr/bin/make -f
#
# Last updated: Sun Jun  1 15:46:49 BST 1997 by and1000.
#
# To make the binary distribution package, the ``Debianized'' source package
# and the context diff to the original package, type `./debian.rules dist'.
# Make sure that `debian.rules' is executable before the final distribution
# is made.
#
# Invoke each target with `./debian.rules <target>'.  All targets should be
# invoked with the package root as the current directory.
#
# The `binary' target must be run as root, as it needs to install files with
# specific ownerships.  The `diff' target assumes that you have the original
# source package available, unpacked, in ../$(p)-$(v).orig, or that you have
# the previous revision of the ``Debianized'' source package and context diff
# in the parent directory.

package=bsdutils

build:
	make
	touch build

clean:
	make clean
	rm -f build
	rm -rf debian/tmp
	rm -f debian/*~ debian/substvars debian/files

binary-indep:   checkroot build

binary-arch:    checkroot build
	install -d -o root -g root -m 755 debian/tmp debian/tmp/DEBIAN
	install -d -o root -g root -m 755 debian/tmp/usr/doc/$(package)
	make install \
          bindir=debian/tmp/bin \
          sbindir=debian/tmp/sbin \
          usrbindir=debian/tmp/usr/bin \
          usrsbindir=debian/tmp/usr/sbin \
          libdir=debian/tmp/usr/lib \
          mandir=debian/tmp/usr/man
	chmod -R g-w debian/tmp
	rm -f debian/tmp/usr/man/man8/chroot.8
	gzip -9v debian/tmp/usr/man/man?/*
	install -o root -g root -m 644 debian/copyright \
	  debian/tmp/usr/doc/$(package)/copyright
	install -o root -g root -m 644 debian/changelog \
	  debian/tmp/usr/doc/$(package)/changelog.Debian
	gzip -9v debian/tmp/usr/doc/$(package)/changelog.Debian
#
	dpkg-shlibdeps kill logger renice script wall
	dpkg-gencontrol -isp
	dpkg --build debian/tmp ..


binary:         binary-indep binary-arch
checkroot:
	test root = "`whoami`"

.PHONY: binary binary-arch binary-indep clean checkroot
