#!/usr/bin/make -f
# debian/rules file - for atmel-firmware.
# Copyright 2004 by Simon Kelley
# Based on the sample in the debian hello package which carries the following:
# 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=atmel-firmware

build:
	$(checkdir)

clean:
	$(checkdir)
	rm -rf atmel_fwl *~ images/*~ images.usb/*~ debian/tmp debian/*~ debian/files* debian/substvars

binary-arch:	checkroot 
	$(checkdir)
# There are no architecture-dependent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-indep:	checkroot
	$(checkdir)
	rm -rf debian/tmp
	install -d debian/tmp/DEBIAN\
		-d debian/tmp/usr/sbin\
	        -d debian/tmp/lib/firmware\
		-d debian/tmp/etc/pcmcia\
		-d debian/tmp/usr/share/man/man8\
	        -d debian/tmp/usr/share/doc/$(package)
	install -m 755 debian/postinst debian/tmp/DEBIAN
	install -m 755 atmel_fwl.pl debian/tmp/usr/sbin/atmel_fwl
	install -m 644 atmel.conf debian/tmp/etc/pcmcia
	install -m 644 images/* debian/tmp/lib/firmware
	install -m 644 images.usb/* debian/tmp/lib/firmware
	cp README debian/tmp/usr/share/doc/$(package)/README
	gzip debian/tmp/usr/share/doc/$(package)/README
	cp debian/changelog debian/tmp/usr/share/doc/$(package)/changelog.Debian
	gzip -9 debian/tmp/usr/share/doc/$(package)/changelog.Debian
	cp debian/copyright debian/tmp/usr/share/doc/$(package)/copyright
	cp atmel_fwl.8 debian/tmp/usr/share/man/man8
	gzip -9 debian/tmp/usr/share/man/man8/atmel_fwl.8
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -d images -a -f debian/rules
endef

# Below here is fairly generic really

binary:		binary-indep binary-arch

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

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


