#!/usr/bin/make -f
# Made with the aid of debmake, by Christoph Lameter,
# based on the sample debian/rules file for GNU hello by Ian Jackson.

package=jargon

INSTALLOPT=-o root -g root

DESTDIR=debian/tmp
DOCDIR=$(DESTDIR)/usr/share/doc/jargon
MANDIR=$(DESTDIR)/usr/share/man
INFODIR=$(DESTDIR)/usr/share/info

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp:
	$(checkdir)
	touch build-stamp

clean:
	$(checkdir)
	-rm -f jargon.info
	-rm -f build-stamp
	-rm -f `find . -name "*~"`
	-rm -rf debian/tmp debian/files* core debian/substvars

binary-indep:	checkroot build
	$(checkdir)
	rm -rf debian/tmp
	install -d debian/tmp
	# The actual info file
	install -d $(INSTALLOPT) -m 755 $(INFODIR)
	install $(INSTALLOPT) -m 644 jarg400.info $(INFODIR)/jargon.info
	gzip -9n $(INFODIR)/jargon.info
	# Lookup script
	install -d $(INSTALLOPT) -m 755  $(DESTDIR)/usr/bin
	install $(INSTALLOPT) -m 755  debian/jargon $(DESTDIR)/usr/bin/jargon
	install -d $(INSTALLOPT) -m 755 $(MANDIR)/man1
	install $(INSTALLOPT) -m 644 debian/jargon.1 $(MANDIR)/man1/jargon.1
	gzip -9n $(MANDIR)/man1/jargon.1
	# Docs
	install -d $(INSTALLOPT) -m 755 $(DOCDIR)
	install $(INSTALLOPT) -m 644 debian/jargon.html \
			$(DOCDIR)/jargon.html
	install $(INSTALLOPT) -m 644 debian/copyright $(DOCDIR)/copyright
	install $(INSTALLOPT) -m 644 debian/changelog $(DOCDIR)/changelog.Debian
	install $(INSTALLOPT) -m 644 debian/README.Debian $(DOCDIR)/README.Debian
	install $(INSTALLOPT) -m 644 jargon-README $(DOCDIR)/README
	gzip -9n $(DOCDIR)/changelog.Debian $(DOCDIR)/README

	# Control files
	install -d $(INSTALLOPTS) -m 755 $(DESTDIR)/DEBIAN
	install $(INSTALLOPTS) -m 755 debian/prerm $(DESTDIR)/DEBIAN/prerm
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

binary-arch:	checkroot build
	# There are no architecture specific components for this
	# package

define checkdir
	test -f debian/rules
endef

# Below here is fairly generic really

binary:		binary-indep binary-arch

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

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