#! /usr/bin/make -f

build:
# Builds the binary package.
# empty

clean:
# Undoes the effect of `make -f debian.rules build'.
	$(checkdir)
	-rm -rf *~ *.orig "#*" debian/tmp debian/*~ debian/files*
	-find man? -name '*~' -exec rm {} \;

binary-indep:  checkroot build
	$(checkdir)

binary-arch:   checkroot build
# Makes a binary package.
	$(checkdir)

	/bin/bash debian/inst

	dpkg-gencontrol
	pushd debian/tmp >/dev/null ; \
	md5sum `find * -type f ! -regex "DEBIAN/.*"` >DEBIAN/md5sums </dev/null ; \
	chmod 644 DEBIAN/md5sums ; \
	popd >/dev/null
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg-deb --build debian/tmp ..

define checkdir
	test -d man2 -a -f debian/rules
endef

# Below here is fairly generic really

binary:                binary-indep binary-arch

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

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