#! /usr/bin/make -f
# -*- Makefile -*-

# Written by Antti-Juhani Kaijanaho <ajk@debian.org>.  Use, distribute
# and modify as you please.

install_exec = install -m 755 -s
install_dir = install -m 755 -d
install_nonex = install -m 644
install_script = install -m 755
install_zipped = gzip -9vc
install_symlink = ln -s

package    = hugs-doc
builddir   = $(shell pwd)
rootdir    = $(builddir)/debian/tmp
docdir     = $(rootdir)/usr/share/doc/$(package)

build:
	true # nothing to be done on build

binary: binary-arch binary-indep

binary-arch:
	$(checkdir)

binary-indep: build
	$(checkdir)
	test root = "`whoami`"
#	Create the filesystem
	$(install_dir) $(rootdir)
	$(install_dir) $(rootdir)/DEBIAN
	$(install_dir) $(docdir)
#	Install copyright file.
	$(install_nonex) debian/copyright $(docdir)
#	Install the change logs.
	$(install_zipped) debian/changelog > $(docdir)/changelog.Debian.gz
#	Install the installation scripts
	$(install_script) debian/prerm debian/postinst $(rootdir)/DEBIAN
#	Install the doc-base support files
	$(install_dir) $(rootdir)/usr/share/doc-base/
	$(install_nonex) debian/hugs.doc-base $(rootdir)/usr/share/doc-base/hugs
#	Install the system.
	$(install_nonex) *.html $(docdir)
#	Generate the binary control file.
	dpkg-gencontrol -isp
#	Fix permissions.
	chown -R root.root $(rootdir)
	chmod -R g-ws $(rootdir)
#	Genearate the deb.
	dpkg --build $(rootdir) ..

define checkdir
	test -f hugs.html -a -f debian/rules
endef

clean:
	-rm -rf debian/tmp debian/*~ debian/files debian/substvars

