#!/usr/bin/make -f
# debian.rules file - for xdemineur (2.4)
# Based on sample debian.rules file (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.)

package=chimera2

ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALLOPT=
else
	INSTALLOPT=-s
endif

build:
	$(checkdir)
	xmkmf -a
	$(MAKE)
	touch build

clean:
	$(checkdir)
	-rm -f build
	-$(MAKE) clean
	-rm Makefile */Makefile
	-rm -rf *~ debian/tmp debian/*~ debian/files*

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.

binary-arch:	checkroot build
	$(checkdir)
	-rm -rf debian/tmp
	# First create directories
	install -d debian/tmp debian/tmp/DEBIAN
	install -d debian/tmp/usr/share/doc/$(package)
	install -d debian/tmp/usr/bin
	install -d debian/tmp/usr/share/man/man1
	install -d debian/tmp/usr/share/menu
	# Copy documentation
	cp debian/copyright debian/tmp/usr/share/doc/$(package)/.
	cp debian/changelog debian/tmp/usr/share/doc/$(package)/changelog.Debian
	gzip -9v debian/tmp/usr/share/doc/$(package)/changelog.Debian
	install -m 0644 doc/INFO debian/tmp/usr/share/doc/$(package)/INFO
	install -m 0644 doc/HINTS debian/tmp/usr/share/doc/$(package)/HINTS
	install -m 0644 debian/README.Debian debian/tmp/usr/share/doc/$(package)
	# Copy other files
	install -m 0644 chimera/chimera.man \
				debian/tmp/usr/share/man/man1/chimera2.1
	install -m 0644 debian/menu debian/tmp/usr/share/menu/chimera2
	gzip -9v debian/tmp/usr/share/man/man1/chimera2.1
	install $(INSTALLOPT) chimera/chimera debian/tmp/usr/bin/chimera2; \
	# Various bits and pieces needed to build package
	cp debian/postinst debian/postrm debian/prerm debian/tmp/DEBIAN/.
	chmod +x debian/tmp/DEBIAN/postinst debian/tmp/DEBIAN/postrm debian/tmp/DEBIAN/prerm
	dpkg-shlibdeps chimera/chimera
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f chimera/chimera.man -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