# Makefile for Sentry package.
# 
# Send problems/code hacks to crowland@psionic.com or crowland@vni.net

# Generic compiler
CC = cc
# GNU..
#CC = gcc 

# Normal systems flags
CFLAGS = -O
# Debug mode for sentry
#CFLAGS = -Wall  -g -DDEBUG

INSTALLDIR = /usr/local/abacus


all:
		@echo "Usage: make <systype>"
		@echo "<systype> is one of: linux, bsd, hpux, generic"
		@echo "" 
		@echo "Install: make install"
		@echo "" 
		@echo "NOTE: This will install the package in this" 
		@echo "      directory: $(INSTALLDIR)" 
		@echo "" 
		@echo "Edit the makefile if you wish to change these paths." 
		@echo "Any existing files will be overwritten."

clean:		
		/bin/rm ./sentry ./*.o 

uninstall:	
		/bin/rm $(INSTALLDIR)/sentry*
		/bin/rmdir $(INSTALLDIR)

install:	
		@echo "Creating abacus directory $(INSTALLDIR)"
		@if [ ! -d $(INSTALLDIR) ]; then /bin/mkdir $(INSTALLDIR); fi
		@echo "Setting directory permissions"
		chmod 700 $(INSTALLDIR)
		@echo "Copying files"
		cp ./sentry.conf $(INSTALLDIR)
		cp ./sentry.ignore $(INSTALLDIR)
		cp ./sentry $(INSTALLDIR)
		@echo "Setting permissions"
		chmod 600 $(INSTALLDIR)/sentry.ignore
		chmod 600 $(INSTALLDIR)/sentry.conf
		chmod 700 $(INSTALLDIR)/sentry
		@echo ""
		@echo ""
		@echo "Edit $(INSTALLDIR)/sentry.conf and change"
		@echo "your settings if you haven't already. (route, etc)" 
		@echo ""
		@echo ""

linux:		
		SYSTYPE=linux 
		@echo "Making $(SYSTYPE)"
		$(CC) $(CFLAGS) -DLINUX -o ./sentry ./sentry.c ./sentry_io.c

bsd:		
		SYSTYPE=bsd
		@echo "Making $(SYSTYPE)"
		$(CC) $(CFLAGS) -DBSD44 -o ./sentry ./sentry.c ./sentry_io.c

# Not well tested
hpux:		
		SYSTYPE=hpux
		@echo "Making $(SYSTYPE)"
		$(CC) $(HPUX_CFLAGS) -Ae -DHPUX -o ./sentry ./sentry.c ./sentry_io.c

generic:		
		SYSTYPE=generic
		@echo "Making $(SYSTYPE)"
		$(CC) $(CFLAGS) -o ./sentry ./sentry.c ./sentry_io.c
