#! /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

# The package
package = metamail

build:
	$(checkdir)
	make CFLAGS="-O2 -g -DLINUX"
	touch build

clean:
	$(checkdir)
	-make clobber
	# Remove all of the `bin' and `man' symbolic links we created.
	-rm -f bin/metamail bin/mmencode bin/mimencode bin/mailto    \
		bin/splitmail bin/richtext bin/richtoatk man/mimencode.1
	-rm -f build
	-rm -rf debian/tmp debian/files* core debian/substvars

binary-indep: checkroot build
	$(checkdir)

binary-arch: checkroot build
	$(checkdir)
	-rm -rf debian/tmp
	install -d debian/tmp debian/tmp/DEBIAN debian/tmp/usr/bin \
		debian/tmp/usr/man/man1 debian/tmp/usr/man/man4 \
		debian/tmp/usr/doc/$(package)

# Calling the upstream installation procedure.
	make install-all INSTROOT=`pwd`/debian/tmp/usr \
		MAILCAPDIR=`pwd`/debian/tmp/etc

# Some massaging
	ln -s mmencode.1.gz debian/tmp/usr/man/man1/mimencode.1.gz
	install -m 644 mailers.txt debian/mime.noinstall \
		debian/tmp/usr/doc/$(package)
	install debian/postinst debian/tmp/DEBIAN/postinst
	install debian/prerm debian/tmp/DEBIAN/prerm

# Undocumented links
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/mailserver.1.gz
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/mimeit.1.gz
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/rcvAppleSingle.1.gz
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/richtoatk.1.gz
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/sndAppleSingle.1.gz
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/sun-audio-file.1.gz
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/sun-message.1.gz
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/sun-message.csh.1.gz
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/sun-to-mime.1.gz
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/sun2mime.1.gz
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/uudepipe.1.gz
	ln -s ../man7/undocumented.7.gz debian/tmp/usr/man/man1/uuenpipe.1.gz

# Automation
	debstd CREDITS README
	chown -R root.root debian/tmp
	chmod og=rX debian/tmp
	dpkg-gencontrol
	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
