#!/usr/bin/make -f
#
# rules file for Debian witalian package.
# $Id: rules,v 1.10 1998/04/09 17:05:52 salve Exp $
#
# Copyright  Davide G. M. Salvetti <salve@debian.org>, 1997, 1998.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to: The Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# On Debian GNU/Linux System you can find a copy of the GNU General Public
# License in /usr/doc/copyright/GPL.

package	:= witalian
DOCS	:= NEWS README TODO

tmp	:= $(shell pwd)/debian/tmp/
usr	:= $(tmp)/usr/
man	:= $(usr)/man/
DEBIAN	:= $(tmp)/DEBIAN/
doc	:= $(usr)/doc/$(package)/

SHELL		:= /bin/bash
INSTDIR		:= install -m 755 -d
INSTPROG	:= install -m 755 -s
INSTDATA	:= install -m 644
INSTSCRIPT	:= install -m 755

build:
	$(checkdir)
	$(MAKE)
	touch build

clean:
	$(checkdir)
	-rm -rf build core $(tmp) debian/files* debian/substvars
	-$(MAKE) clean

binary: binary-indep binary-arch

binary-arch: checkroot build
	$(checkdir)

binary-indep: checkroot build
	$(checkdir)
	-rm -rf $(tmp)

# install package
	$(MAKE) prefix=$(usr) install
	gzip -9frv $(man)

# install Debian doc
	$(INSTDIR) $(doc)
	$(INSTDATA) $(DOCS) $(doc)
	$(INSTDATA) debian/README $(doc)/README.Debian
	$(INSTDATA) ChangeLog $(doc)/changelog
	$(INSTDATA) debian/changelog $(doc)/changelog.Debian
	gzip -9frv $(doc)
	$(INSTDATA) debian/copyright $(doc)

# install Debian control files
	$(INSTDIR) $(DEBIAN)
	$(INSTSCRIPT) debian/{postinst,prerm,postrm} $(DEBIAN)

# standard stuff
#-#	cd $(tmp) && du -k * | grep -v 'DEBIAN' | sort -k 2 -o $(DEBIAN)/du
	cd $(tmp) && md5sum \
		$$(find ./ -path './DEBIAN' -prune -o -type f -printf "%P\n") \
		| sort -k 2 -o $(DEBIAN)/md5sums
	dpkg-gencontrol
	chown -R root.root $(tmp)
	chmod -R go=rX $(tmp)
	dpkg --build $(tmp) ..

checkdir = test -f debian/rules

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

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

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

### Local Variables:
### mode: makefile
### End:
