#!/usr/bin/make -f
# debian/rules file - for Ruari Diff (0.15)
# Based on the sample debian/rules file - for GNU Hello (1.3).
# Copyright 1994,1995 by Ian Jackson.
# Copyright 1887,1998 by James Troup.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself.  (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified

build:
	$(checkdir)
	./configure --prefix=/usr
	$(MAKE) CFLAGS="-O2 -g -Wall" 
	touch build

clean:
	$(checkdir)
	-rm -f build
	-$(MAKE) -i distclean || $(MAKE) -f Makefile.in distclean
	-rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars*

binary-indep: checkroot build
	$(checkdir)

binary-arch: checkroot build
	$(checkdir)
	-rm -rf debian/tmp
	install -d debian/tmp/DEBIAN/

	$(MAKE) CFLAGS=-O2 INSTALL_PROGRAM='install -s' \
		prefix=debian/tmp/usr install

	install -d debian/tmp/usr/man/man1/
	install -m 644 ruari-diff.1 debian/tmp/usr/man/man1/
	gzip -9v debian/tmp/usr/man/man1/*

	install -d debian/tmp/usr/doc/ruari-diff/examples
	install -m 644 README NEWS TODO debian/tmp/usr/doc/ruari-diff/
	install -m 644 debian/changelog \
			debian/tmp/usr/doc/ruari-diff/changelog.Debian
	install -m 644 ChangeLog debian/tmp/usr/doc/ruari-diff/changelog
	install -m 644 ruari1.sh ruari2.sh \
			 debian/tmp/usr/doc/ruari-diff/examples/
	find debian/tmp/usr/doc/ruari-diff -type f | xargs gzip -9v
	install -m 644 debian/copyright debian/tmp/usr/doc/ruari-diff/

	dpkg-shlibdeps ./ruari-diff
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f hash.c -a -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
