#
#  Utility makefile for people working with mod_ifier
#


#
#  Only used to build distribution tarballs.
#
DIST_PREFIX = /tmp
VERSION     = 0.8
BASE        = mod-ifier




nop:
	@echo "Valid targets are (alphabetically) :"
	@echo " "
	@echo " all       - Build the module"
	@echo " install   - Build *and* install the module"
	@echo " "
	@echo " clean     - Remove bogus files."
	@echo " commit    - Commit changes, after running check."
	@echo " diff      - Run a 'cvs diff'."
	@echo " install   - Install the module"
	@echo " update    - Update from the CVS repository."
	@echo " "
	@echo " Steve specific:"
	@echo " "
	@echo " release   - Build a release tarball."
	@echo " "


.PHONY:
	@true

all:
	cd src && make VERSION=$(VERSION)


clean:
	cd src && make clean
	@find . -name '.*~' -exec rm \{\} \;
	@find . -name '.#*' -exec rm \{\} \;
	@find . -name 'configure-stamp' -exec rm \{\} \;
	@find . -name 'build-stamp' -exec rm \{\} \;
	@if [ -d debian/libapache2-mod-ifier ]; then rm -rf debian/libapache2-mod-ifier; fi


commit: 
	cvs -z3 commit


diff:
	cvs diff --unified 2>/dev/null


install:
	cd src && make install VERSION=$(VERSION)
	cp `pwd`/docs/mod_ifier.3 /usr/share/man/man3


release: clean
	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
	cd $(DIST_PREFIX) && tar --exclude=.cvsignore --exclude=debian -cvf $(DIST_PREFIX)/$(BASE)-$(VERSION).tar $(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


test:
	if [ ! -e 'src/.libs/mod_ifier.so' ]; then make all ; fi
	prove tests/


test-verbose:
	if [ ! -e 'src/.libs/mod_ifier.so' ]; then make all ; fi
	prove --verbose tests/


update:
	cvs -z3 update -A -d 2>/dev/null
