#!/usr/bin/make -f
# Sample debian.rules file - Copyright 1994,1995 by Ian Jackson.
#
# 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
P = doc-linux-de

R = debian/tmp

DIRECTORIES = \
        $(R) \
        $(R)/DEBIAN \
        $(R)/usr/share/doc/HOWTO/de-html/mini \
        $(R)/usr/share/doc/$(P)/FAQ \
#        $(R)/usr/doc/HOWTO 

$(DIRECTORIES):
	install -d -g root -o root -m 755 $@
	chmod g-s $@

# 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)
	[ ! -f Makefile ] || make distclean cleanconfig
	rm -f debian/files* debian/substvars core debian/*~ HOWTO/*~ 
	rm -f HOWTO/mini/*~ build debian/*.debhelper

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


binary-arch: $(DIRECTORIES) checkroot build
	$(checkdir)

	cp HOWTO/*.sgml.gz $(R)/usr/share/doc/HOWTO/de-html 
	gunzip $(R)/usr/share/doc/HOWTO/de-html/*.gz
	(cd $(R)/usr/share/doc/HOWTO/de-html && make -f ../../../../../../sgml-Makefile html && rm -f *.sgml)

	cp HOWTO/mini/*.sgml.gz $(R)/usr/share/doc/HOWTO/de-html/mini 
	gunzip $(R)/usr/share/doc/HOWTO/de-html/mini/*.gz
	(cd $(R)/usr/share/doc/HOWTO/de-html/mini && make -f ../../../../../../../sgml-Makefile html && rm -f *.sgml)

	cp icons/*.gif $(R)/usr/share/doc/HOWTO/de-html
	cp icons/*.gif $(R)/usr/share/doc/HOWTO/de-html/mini

	(cd $(R)/usr/share/doc/$(P)/FAQ; tar xvfz ../../../../../../../dcoul-faq_html.tar.gz)

	cp debian/changelog $(R)/usr/share/doc/$(P)
	cp debian/copyright $(R)/usr/share/doc/$(P)
	gzip -9 $(R)/usr/share/doc/$(P)/changelog

	dh_installchangelogs
	dh_compress
	dh_installdocs

	dh_installdeb 
	dh_md5sums

	dpkg-gencontrol -isp
	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
