#! /usr/bin/make -f
#
# 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.
#


package	:= tkhylafax

MAKEOPTS := TCLSH=/usr/bin/tclsh WISH=/usr/bin/wish

build:
# Builds the binary package.
	make build PREFIX=/usr $(MAKEOPTS) GHOSTVIEW=gv
	touch stamp-build

clean:
# Undoes the effect of `debian/rules build'.
	rm -f stamp-build
	rm -rf debian/tmp debian/files debian/substvars
	find . \( -name "*~" -o -name "#*" \) -exec rm -f {} \;
	rm -f tkhylafax

# Makes a binary package.
binary-indep:
	test -f stamp-build || make -f debian/rules build
	rm -rf debian/tmp
	#
	mkdir -p debian/tmp/DEBIAN debian/tmp/usr/doc/$(package)
	mkdir -p debian/tmp/usr/bin debian/tmp/usr/man/man1
	#
	$(MAKE) install PREFIX=debian/tmp/usr $(MAKEOPTS)
	#
	cd debian/tmp/usr/man && gzip -9v */*;
	#
	cp CHANGES debian/tmp/usr/doc/$(package)/changelog
	cp debian/changelog debian/tmp/usr/doc/$(package)/changelog.Debian
	cd debian/tmp/usr/doc/$(package) && gzip -9v *
	cp debian/copyright debian/tmp/usr/doc/$(package)/
	#
	dpkg-gencontrol -is -ip
	chown -R root.root debian/tmp
	chmod -R go=rX	   debian/tmp
	dpkg --build debian/tmp
	dpkg-name -o -s .. debian/tmp.deb

binary-arch:
	@echo "No architecture-dependant packages"

binary: binary-indep binary-arch
	@echo "Binaries made"
