
#
#  Only used to build distribution tarballs.
#
DIST_PREFIX = /tmp
VERSION     = 1.5
BASE        = debian-builder


PREFIX = /


clean:
	find . -name '*~' -exec rm \{\} \;
	find . -name 'install-stamp' -exec rm \{\} \;
	find . -name 'build-stamp' -exec rm \{\} \;
	find . -name 'debian-builder.1' -exec rm \{\} \;

install: manpage
	-mkdir -p $(PREFIX)var/cache/debian-builder
	-mkdir -p $(PREFIX)var/cache/debian-builder/tmp
	-mkdir -p $(PREFIX)var/cache/debian-builder/log
	-mkdir -p $(PREFIX)var/cache/debian-builder/deb
	-mkdir -p $(PREFIX)etc/debian-builder/
	-mkdir -p $(PREFIX)usr/bin
	-mkdir -p $(PREFIX)usr/share/man/man1
	chmod -R 775 $(PREFIX)var/cache/debian-builder
	cp bin/debian-builder $(PREFIX)usr/bin
	cp etc/debian-builder.conf $(PREFIX)etc/debian-builder
	cp doc/debian-builder.1 $(PREFIX)usr/share/man/man1
	gzip -9 $(PREFIX)usr/share/man/man1/debian-builder.1

uninstall:
	-rm -rf /var/cache/debian-builder/tmp
	-rm -rf /var/cache/debian-builder/deb
	-rm -rf /var/cache/debian-builder/log
	-rmdir /var/cache/debian-builder/
	-rm /usr/bin/debian-builder
	-rm /etc/debian-builder/debian-builder.conf
	-rm /usr/share/man/man1/debian-builder.1.gz

test:
	prove --shuffle tests/

test-verbose:
	prove --shuffle --verbose tests/

manpage:
	pod2man bin/debian-builder > doc/debian-builder.1

release:   clean manpage
	rm -rf $(DIST_PREFIX)/$(BASE)-$(VERSION)
	rm -f $(DIST_PREFIX)/$(BASE)-$(VERSION).tar.gz
	cp -R . $(DIST_PREFIX)/$(BASE)-$(VERSION)
	find  $(DIST_PREFIX)/$(BASE)-$(VERSION) -name "CVS" -print | xargs rm -rf
	find  $(DIST_PREFIX)/$(BASE)-$(VERSION) -name ".cvsignore" -exec rm -f \{\} \;
	cd $(DIST_PREFIX) && tar -cvf $(DIST_PREFIX)/$(BASE)-$(VERSION).tar --exclude=debian/* $(BASE)-$(VERSION)/
	gzip $(DIST_PREFIX)/$(BASE)-$(VERSION).tar
	mv $(DIST_PREFIX)/$(BASE)-$(VERSION).tar.gz .
	rm -rf $(DIST_PREFIX)/$(BASE)-$(VERSION)
	gpg --armour --detach-sign $(BASE)-$(VERSION).tar.gz


