#!/usr/bin/make -f
# Sample debian/rules file - for GNU Hello.
# 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

DEBIAN_DIR = debian

package = mini-rc
docdir := $(DEBIAN_DIR)/tmp/usr/share/doc/$(package)

build:
	touch build

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

binary-arch:	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-indep:	checkroot build
	$(checkdir)
	rm -rf $(DEBIAN_DIR)/tmp
	install -d $(DEBIAN_DIR)/tmp/DEBIAN $(docdir)

	make install DESTDIR=$(DEBIAN_DIR)/tmp

#	install -m 755 debian/postinst debian/tmp/DEBIAN
	cp -a debian/copyright $(docdir)
#	cp -a debian/changelog $(docdir)/changelog.Debian
	install -m 644 $(DEBIAN_DIR)/conffiles  $(DEBIAN_DIR)/tmp/DEBIAN
	dpkg-gencontrol -isp
	chown -R root:root debian/tmp
	chmod -R u+w,go=rX debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f debian/rules
endef

binary: binary-indep binary-arch

checkroot:
	$(checkdir)
	test $$(id -u) = 0

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