#!/usr/bin/make -f
#
# Invoke each target with `./debian/rules <target>'.  All targets should be
# invoked with the package root as the current directory.

# The name of the package
L = ko
P = doc-linux-$(L)

R = debian/tmp

# Builds the binary package.
build:
	$(checkdir)
	touch build

# Clean $(DIRECTORIES)
clean-dir:
	$(checkdir)
	rm -rf $(R)

# Undoes the effect of `make -f rules build'.
clean: clean-dir
	$(checkdir)
	rm -f debian/files* core debian/*~ HOWTO/*~ 
	rm -f HOWTO/mini/*~ build

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

binary-arch: checkroot build
	$(checkdir)
	rm -rf $(R)

	install -d -g root -o root -m 755 $(R)/usr/doc/LANG/$(L)/HOWTO
	install -d -g root -o root -m 755 $(R)/usr/doc/$(P)

	cp -a HOWTO/* $(R)/usr/doc/LANG/$(L)/HOWTO
	cp README $(R)/usr/doc/$(P)
	
	debstd -m -c
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f debian/rules
endef

# Below here is fairly generic really

binary:		binary-indep binary-arch

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

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

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