# $Id: Makefile,v 1.9 1994/09/21 01:02:51 vikas Exp $
#
# Makefile for 'trapmon'
#

## SET THIS
# Directories needed by the Makefile. See description in ../Makefile
#
TOP = 		/usr/nocol
SRCDIR =	$(TOP)/src
BINDIR = 	$(TOP)/bin

# directory for CMU snmp sources
CMUSNMP =	$(SRCDIR)/cmu-snmp
INCLUDEDIR = 	$(SRCDIR)/include
LIBDIR =	$(SRCDIR)/lib

## SET THIS
# Directories needed by the program.
#

## SET THIS
# Set the various defines for compile time defines:
#
#
SYSDEFS =
INSTALL =	install

####
#### Can leave the rest alone #######
####

##
# The various directories that are needed in the program. Should NOT
# have trailing '/'.
DIRDEFS =	

## Compilation definitions
#  The CDEF specs are specific to this sub-module. The CFLAGS can be
#  over-ridden by the top level makefile.
CC =		cc
CDEFS =		$(DIRDEFS) $(SYSDEFS) -DHAVE_FD_MACROS  \
		-I$(CMUSNMP)/include -I$(CMUSNMP)/snmplib
LIBS =		-L$(CMUSNMP)/lib -lsnmp -lnocol $(SYSLIBS)
CFLAGS = 	-g -I$(INCLUDEDIR) -L$(LIBDIR)

TARG  =		trapmon
OBJECTS = 	trapmon.o


$(TARG): CMU $(OBJECTS) Makefile
	$(CC) $(CFLAGS) $(OBJECTS) $(LIBS) -o $@

CMU:
	@echo 'Making the CMU SNMP library under $(CMUSNMP)'
	cd $(CMUSNMP)/snmplib ; \
	 make CC="$(CC)" CFLAGS="$(CFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" \
		all install

.c.o:
	$(CC) -c $(CFLAGS) $(CDEFS) $<

## The dependencies in case 'mkdep' not used
#
$(OBJECTS): $(INCLUDEDIR)/nocol.h  $(INCLUDEDIR)/trapmon.h

install: $(TARG)
	$(INSTALL) -c -m 4750 $(TARG) $(BINDIR)/
	@if [ `whoami` = "root" ]; then \
		chown root $(BINDIR)/$(TARG) ;\
		ls -lg $(BINDIR)/$(TARG) ;\
	 else \
		echo "";echo "___Installed $(TARG) needs to be root suid___" ;\
		echo "Do as root manually" ;\
	 fi

clean:
	/bin/rm -f $(TARG) $(OBJECTS) core a.out
	@-cd $(CMUSNMP) ; make clean

rcs:
	@echo "Doing 'rcs' in 'nsmon'
	@-for i in $(OBJS); do \
		$(CO) -q `basename $$i .o`.c ;\
	  done
