#!/usr/bin/make -f
# debian/rules file - for kernel-patch-2.0.33-m68k
# Copyright 1997,1998 by James Troup.
# 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

package=kernel-patch-2.0.33-m68k

SHELL=/bin/bash

build:
	$(checkdir)
	touch build

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

binary-indep:	checkroot build
	$(checkdir)
	-rm -rf debian/tmp
	install -d debian/tmp/{DEBIAN,usr/doc/$(package)}
	install -d debian/tmp/usr/src/kernel-patches/m68k/{apply,unpatch}
	install -m 644 2.0.33pl1.diff.gz \
			debian/tmp/usr/src/kernel-patches/m68k/
	install -m 755 apply_me debian/tmp/usr/src/kernel-patches/m68k/apply/
	install -m 755 unapply_me debian/tmp/usr/src/kernel-patches/m68k/unpatch/
	install -m 644 debian/changelog debian/tmp/usr/doc/$(package)/changelog.Debian
	install -m 644 README debian/tmp/usr/doc/$(package)/README
	gzip -9v debian/tmp/usr/doc/$(package)/*
	install -m 644 debian/copyright debian/tmp/usr/doc/$(package)/copyright

	dpkg-gencontrol -isp -p$(package)
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

binary-arch:	checkroot build
	$(checkdir)
	# Add the kernel-image and kernel-headers debs by hand to the
	# package, so that they have a .changes file to latch onto.

	dpkg-distaddfile kernel-headers-2.0.33_2.0.33-10_m68k.deb devel optional
	dpkg-distaddfile kernel-image-2.0.33-amiga_2.0.33-10_m68k.deb base optional
	dpkg-distaddfile kernel-image-2.0.33-atari_2.0.33-10_m68k.deb base optional


define checkdir
	test -f apply_me -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
