# @(#) pg-toolbox GNU Makefile

PREFIX?=/usr/local

MANPAGES=pgcomment.1 pgstat.1 listdb.1
TOOLS=pgstat pgcomment listdb

all:	$(MANPAGES)
	perl -c pgcomment

install:	all
	for t in $(TOOLS) ; do install -m 755 $$t $(PREFIX)/bin/ ; done
	for m in $(MANPAGES) ; do install -m 644 $$m $(PREFIX)/share/man/man1 ; done

uninstall:
	for t in $(TOOLS) ; do rm -f $(PREFIX)/bin/$$t ; done
	for m in $(MANPAGES) ; do rm -f $(PREFIX)/share/man/man1/$$m ; done

clean:
	rm -f $(MANPAGES) *~ htdocs/*~
	$(MAKE) -C examples $@

%.1:	%
	pod2man --section=1 $< $@

###########

RELEASE=1
NAME=pg-toolbox-$(RELEASE)
DIR=/tmp/$(NAME)
TAR=/tmp/$(NAME).tar

release:	clean
	rm -rf $(DIR) $(TAR).gz
	mkdir -p $(DIR)
	cp -rfv * $(DIR)/
	rm -rf $(DIR)/htdocs
	find $(DIR) -depth -type d -name CVS -exec rm -rf {} ';'
	cd /tmp; tar cfv $(TAR) $(NAME)
	gzip -9 $(TAR)
