#!/usr/bin/make -f
# Sample debian.rules file - for GNU Hello (1.3).
# Copyright 1994,1995 by Ian Jackson.
# 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
#
# Modified to be a prototype for debmake by Christoph Lameter <clameter@debian.org>

package=yorick
SHELL=/bin/bash

build:
	$(checkdir)
# expect the HOSTTYPE environment variable to be set and
# passed along by make, e.g.-  HOSTTYPE=i386
	make prefix=/usr ysite
	make
	make docs
	cd doc; make yorick.info
	strip gist/gist
	strip yorick/yorick
	touch build

clean:
	$(checkdir)
	-rm -f build
	-make distclean
	-rm -f Yorick/doc/yorick.info*
	-rm -f Yorick/doc/*.doc
	-rm -f `find . -name "*~"`
	-rm -rf debian/tmp debian/files* core

binary-indep:	checkroot build
	$(checkdir)
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.
# Actually, there are architecture independent files, but Yorick's install
# target installs them together with the architecture dependent files
# in /usr/share/yorick.

binary-arch:	checkroot build
	$(checkdir)
	-rm -rf debian/tmp
	install -d debian/tmp/usr/{bin,lib}
	make INSTALL_ROOT=debian/tmp Y_BINDIR=debian/tmp/usr/bin install
	install -d debian/tmp/usr/share/man/man1
	cp doc/yorick.1 doc/gist.1 debian/tmp/usr/share/man/man1
	install -d debian/tmp/usr/share/{info,doc}
	cp doc/yorick.info* debian/tmp/usr/share/info
	install -d debian/tmp/usr/share/yorick/1.6/contrib
	cp emacs/yorick.el debian/tmp/usr/share/yorick/1.6
	sed emacs/yorick-auto.el >debian/tmp/usr/share/yorick/1.6/yorick-auto.el -e s%'"'yorick%'"'/usr/share/yorick/1.6/yorick%g
	debstd
	dpkg-gencontrol -isp -p$(package)
	chown -R root.root debian/tmp
	chmod -R go=rX 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
