#!/usr/bin/make -f
# debian/rules file - for dnsmasq.
# Copyright 2001 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=dnsmasq

build:
	$(checkdir)
	make
	touch build

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

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
	install -d debian/tmp/DEBIAN\
		-d debian/tmp/usr/sbin\
	        -d debian/tmp/usr/share/doc/$(package)\
		-d debian/tmp/usr/share/man/man8\
                -d debian/tmp/etc/init.d\
                -d debian/tmp/etc/default
	install -m 644 debian/conffiles debian/tmp/DEBIAN
	install -m 755 debian/postinst debian/postrm debian/prerm debian/tmp/DEBIAN
	strip -R .note -R .comment dnsmasq
	install -m 755 dnsmasq debian/tmp/usr/sbin
	install -m 755 debian/init debian/tmp/etc/init.d/dnsmasq
	install -m 644 debian/default debian/tmp/etc/default/dnsmasq
	cp doc.html debian/tmp/usr/share/doc/$(package)/.
	cp CHANGELOG debian/tmp/usr/share/doc/$(package)/changelog
	gzip -9 debian/tmp/usr/share/doc/$(package)/changelog
	cp debian/changelog debian/tmp/usr/share/doc/$(package)/changelog.Debian
	gzip -9 debian/tmp/usr/share/doc/$(package)/changelog.Debian
	cp debian/readme debian/tmp/usr/share/doc/$(package)/readme.Debian
	cp debian/copyright debian/tmp/usr/share/doc/$(package)/copyright
	cp dnsmasq.8 debian/tmp/usr/share/man/man8
	gzip -9 debian/tmp/usr/share/man/man8/dnsmasq.8
	dpkg-shlibdeps dnsmasq
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f $(package).c -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


