#   FILE: Makefile -- 
# AUTHOR: Gyepi Sam <gyepi@praxis-sw.com>
#   DATE: 04 November 2004
#
# Copyright (C) 2004 Gyepi Sam <gyepi@praxis-sw.com>
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

.PHONY: clean install service

#Where to install the script
BINDIR=/usr/local/bin

#Where to install the application directory
APPDIR=/usr/local/etc/ssh-scanguard

#Where is the base supervise directory
SVCDIR=/service

INSTALL = install

all: log-run run

log-run: log-run.tmpl
	sed 's:%%BINDIR%%:$(BINDIR):; s:%%APPDIR%%:$(APPDIR):' < $< > $@

run: run.tmpl
	sed 's:%%BINDIR%%:$(BINDIR):; s:%%APPDIR%%:$(APPDIR):' < $< > $@


install: all 
	$(INSTALL) -d -m755 $(DESTDIR)$(APPDIR)/log
	$(INSTALL) -d -m755 $(DESTDIR)$(APPDIR)/env
	$(INSTALL) -D -m744 ssh-scanguard $(DESTDIR)$(BINDIR)/ssh-scanguard
	$(INSTALL) -D -m744 log-run $(DESTDIR)$(APPDIR)/log/run
	$(INSTALL) -D -m644 env-LOGFILE $(DESTDIR)$(APPDIR)/env/LOGFILE
	$(INSTALL) -D -m744 run $(DESTDIR)$(APPDIR)/run

service:
	touch $(APPDIR)/down
	ln -s $(APPDIR)	$(SVCDIR)/ssh-scanguard 

clean:
	rm -f  *~

dist: all
	d=`./ssh-scanguard --version 2>&1|sed 's/ version /-/;q'`;\
	mkdir $$d ;\
	cp `cat MANIFEST` $$d ;\
	tar -cvzf $${d}.tar.gz $$d;\
	rm -rf $$d

