#!/usr/bin/make -f

# Base on the sample debian/rules file for GNU Hello (1.3)

package=backup2l

build:

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

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/share/doc/$(package)\
		-d debian/tmp/usr/share/man/man8\
		-d debian/tmp/usr/sbin\
		-d debian/tmp/etc/cron.daily
	install -m 755 debian/prerm debian/tmp/DEBIAN
	install -m 644 debian/conffiles debian/tmp/DEBIAN
	./install-sh -fc debian/tmp/usr/share debian/tmp/usr/sbin debian/tmp/etc
	cp -a debian/copyright debian/tmp/usr/share/doc/$(package)/
	cp -a debian/changelog debian/tmp/usr/share/doc/$(package)/changelog
	cp -a README debian/tmp/usr/share/doc/$(package)/
	cp -a first-time.conf debian/tmp/usr/share/doc/$(package)/
	cd debian/tmp/usr/share/doc/$(package) && gzip -9 changelog
	cd debian/tmp/usr/share/doc/$(package) && gzip -9 README
	dpkg-gencontrol -isp
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f install-sh -a -f debian/rules
endef

# Below here is fairly generic really

binary:	 binary-indep binary-arch

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

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