#!/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
P = w3-recs-2003

R = debian/tmp

RECS=$(R)/usr/share/doc/$(P)/RECS

DIRECTORIES = \
        $(R) \
        $(R)/DEBIAN \
        $(R)/usr \
        $(R)/usr/share/doc/$(P) \
        $(RECS) \
        $(R)/usr/share/doc-base \
	$(RECS)/ 

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

# Builds the binary package.
build:
	dh_testdir
	touch build

# Clean $(DIRECTORIES)
clean-dir:
	dh_testdir
	dh_clean

# Undoes the effect of `make -f rules build'.
clean: clean-dir
	dh_testdir
	[ ! -f Makefile ] || make distclean cleanconfig
	rm -f debian/files* debian/substvars core debian/*~ *~ 
	rm -f build

# Makes a binary package.
binary-indep: $(DIRECTORIES) build
	dh_testroot
	dh_testdir

binary-arch: $(DIRECTORIES) build
	dh_testroot
	dh_testdir

	unzip -d $(RECS) REC-SVG11-20030114.zip
	unzip -d $(RECS) REC-xml-events.zip
	unzip -d $(RECS)/REC-DOM-Level-2-HTML-20030109 DOM2-HTML.zip

	cp -p *.html *.gif *.jpg *.png *.css $(RECS)/.
	cp debian/w3rec-* $(R)/usr/share/doc-base/.
	cp debian/dhelp $(RECS)/.

	cd $(RECS) && find . -name "*.htm*" |\
		xargs $(shell pwd)/debian/fiximages
	
	dh_installdirs
	dh_installdocs
	dh_installexamples
	dh_installchangelogs
	gzip -9v $(R)/usr/share/doc/$(P)/changelog.Debian
	dh_movefiles
	dh_fixperms
	dh_gencontrol
	dh_installdeb
	dh_md5sums
	dh_builddeb

binary:		binary-indep binary-arch

.PHONY: binary binary-arch binary-indep clean
