#
# Makefile for statis
# by Stewart Wilkinson G0LGS Jan 2004
# for XFBB V7.01+

MAINT=/usr/lib/fbb/script/maintenance
TOOLS=/usr/lib/fbb/tool

# Number of Days History to Keep
DAYS=30

# Where is Perl ?
PERL=/usr/bin/perl

TMPDIR=/tmp

# ------- NOTHING BELOW THIS LINE SHOULD NEED CHANGING ---------

TMP = $(TMPDIR)/statis-install

PROGS = statis showstatis

all:
	@echo "Use:"
	@echo "make install"

install:	config-scripts
	@cd $(TMP) ; install -m 750 $(PROGS) $(TOOLS)
	@rm -fr $(TMP)
	@echo -en "#!/bin/sh\n#\n# Remove Connection Statistics Older than" $(DAYS) "days\n#\n\n" > $(MAINT)/statis
	@echo "#" $(TOOLS)/statis $(DAYS) >> $(MAINT)/statis
	@echo -en "\n\n# Mail Results to Sysop ?\n"  >> $(MAINT)/statis
	@echo -en $(TOOLS)/statis $(DAYS) " --summary | mail -s \"FBB Statistics Report\" " sysop "\n" >> $(MAINT)/statis
	@echo -en "\n" >> $(MAINT)/statis
	@chmod 750 $(MAINT)/statis
	@echo Done

config-scripts:
	@echo "Testing for perl ($(PERL))...."
	@test -f $(PERL) -a -x $(PERL) || \
		{ echo "You need to edit the Makefile so I can find where Perl is."; exit 1;}
	@rm -fr $(TMP) ; mkdir $(TMP)
	@echo "Configuring ...."
	@cp $(PROGS) $(TMP)
	@cd $(TMP) ; $(PERL) -p -i -e 's@^#!\S+perl.*@#!$(PERL)@' $(PROGS)

dist:
	@tar -zcf g0lgs-statis.tar.gz Makefile README CHANGES statis showstatis
	@echo Created g0lgs-statis.tar.gz
