# $Header: /nocol/src/RCS/Makefile,v 1.5 1992/06/19 00:30:50 aggarwal Exp $
#
# Makefile for 'nocol'. This file simply calls on other Makefiles in
# the subdirectories to do all the work. All the definitions are used
# by the other Makefiles which then do all the compile time definitions.
#
# Check: SRCSDIR, TOP, PING
#
# To 'make' for only one program, use 
#	make "SRCS=perfmon" [install|clean]
#

##
# CHECK THE VALUE OF IPPING and OSIPING below.

##
# Set TOP here to a directory where everything will be installed (etc, data)
# 'nocol' does a chroot to this directory when it runs.
TOP  =		/nocol

##
# Set SRCDIR to the toplevel location of the NOCOL sources (this directory ?)
SRCDIR=		$(TOP)/src

##
# Set MANDIR for the manpages and MANEXT for the man pages extension
MANDIR = /usr/man/mann
MANEXT = n

##
# If  your system does not have putenv() in your library, then define
# NEEDOBJS to putenv.o
#NEEDOBJS =	putenv.o

##
# If you also want to make the OSI version of 'pingmon', then set MAKEOSI
# to 'YES', else set to NO
MAKEOSI = "NO"

## 
# The special system definitions. Define:
#  -DNFS		If compiling on NFS shared disk for 'fcntl'
#  -DMULTIPING		If setting IPPING to use 'multiping'
SYSDEFS =	-DMULTIPING

##
# Domain name for which the tested servers are authoratative. The query
# type is SOA (needed for nsmon)
DOMAINNAME=	jvnc.net

##
# special defines for  pingmon. Can have an IP ping and/or OSI ping.
#	Set IPPING to /etc/ping or $(BINDIR)/ping or $(BINDIR)/multiping
#	Make sure that the output of the ping command is something like:
#		% ping -s nisc.jvnc.net 100 5
#	See INSTALL or pingmon/poll_sites.c for more details.
#
#	If using 'multiping', also set SYSDEFS value.
IPPING =        $(BINDIR)/multiping
OSIPING =       /usr/sunlink/osi/etc/osi_ping

# Which programs are to be compiled and installed.
#	netmon		the nocol display (installed as nocol)
#	nsmon		Nameserver monitor
#	pingmon		Reachability monitor via 'ping'
#	tpmon		Data thruput monitor
#	tsmon		Terminal server line usage monitor
#	trapmon		SNMP trap monitor
#	utility		Small utility programs
#	doc		Documentation and manual pages
#
SRCS =   	netmon nsmon pingmon tpmon tsmon trapmon \
		utility doc

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

# These are defined here so that install can create these directories
# if they do not exist.
#	BINDIR		where the programs are installed
#	ETCDIR		location of configuration files
#	DATADIR		where datafiles for monitoring programs are created
BINDIR= 	$(TOP)/bin
ETCDIR=		$(TOP)/etc
DATADIR=	$(TOP)/data

# Directory/file definitions that override the ones in the other 'Makefile's
DIRDEFS=	TOP="$(TOP)" \
		SRCDIR="$(SRCDIR)" \
		BIN="$(BINDIR)" \
		ETC="$(ETCDIR)" \
		DATADIR="$(DATADIR)" \
		MANDIR="$(MANDIR)" \
                IPPING="$(IPPING)" \
                OSIPING="$(OSIPING)"

# General definitions that override the ones in the other 'Makefile's
MAKEDEFS=	DOMAINNAME="$(DOMAINNAME)" \
		MANEXT="$(MANEXT)" CO="$(CO)" \
		NEEDOBJS="$(NEEDOBJS)" SYSDEFS="$(SYSDEFS)"
##
# Compile defs
#	CO	location of the 'RCS' check-out program
#	CC	which C compiler. 'GCC' earlier than 2.x might fail on Sparc
#	CFLAGS	-I<location of includes> -DDEBUG
CO=		co			# the '
CC =		cc
CFLAGS=		-g  -I$(SRCDIR)/include

##
# This is the list of files that need to be 'tar-red'. Using the FF option
# in the tar command and also excluding the RCS directories further down.
DIST =	COPYRIGHT HISTORY INSTALL README Makefile version.h \
	cmu-snmp doc include support utility \
	netmon nsmon pingmon tpmon trapmon tsmon


all:
	@-for i in $(SRCS); do \
		( echo "MAKING IN $$i" ; cd $$i ; \
		make  CC="$(CC)" CFLAGS="$(CFLAGS)" $(MAKEDEFS) $(DIRDEFS) ; \
		if [ $$i = "pingmon" ]; then\
		  if [ $(MAKEOSI) = "YES" ]; then \
			make osipingmon PROTOCOL=OSI CC="$(CC)" \
			  CFLAGS="$(CFLAGS)" $(MAKEDEFS) $(DIRDEFS) ;\
		  else \
			: ;\
		  fi ;\
		else \
		  : ;\
		fi ;\
		 ) \
	 done


install:
	[ -d $(TOP) ] || mkdir  $(TOP)
	[ -d $(DATADIR) ] || mkdir $(DATADIR)
	[ -d $(ETCDIR) ] || mkdir $(ETCDIR)
	[ -d $(BINDIR) ] || mkdir $(BINDIR)
	@-for i in $(SRCS); do \
	  ( echo "MAKING IN $$i" ; cd $$i ; \
		make CC="$(CC)" CFLAGS="$(CFLAGS)" \
			$(MAKEDEFS) $(DIRDEFS) install ; ) ;\
	done

tar:	nocol.tar

nocol.tar:
	@( if [ ! -d /var/tmp/t ]; then mkdir /var/tmp/t ;fi ;\
	   if [ ! -d /var/tmp/t/nocol ]; then \
		mkdir /var/tmp/t/nocol /var/tmp/t/nocol/src ; fi ;\
	   if [ ! -d /var/tmp/t/nocol ]; then \
		echo "Fatal error: cannot create directory  /var/tmp/t/nocol";\
		exit 1 ; fi ;\
	   (cd /var/tmp/t/nocol/ ; rm -rf XCLUDEFILES src/) ;\
	   for i in $(DIST) ; do \
		find $$i -name RCS -print >> /var/tmp/t/nocol/XCLUDEFILES ;\
	   done ;\
	   tar cfX - /var/tmp/t/nocol/XCLUDEFILES $(DIST) |\
			 ( cd /var/tmp/t/nocol/src ; tar xf -) ;\
	   rm -f /var/tmp/t/nocol/XCLUDEFILES ;\
	   cd /var/tmp/t/ ;\
	   echo "*** Present working directory is `pwd` ***" ;\
	   if [ ! `pwd` = '/var/tmp/t' ]; then \
		echo "FATAL ERROR, couldn't cd to tmp dir" ;\
		exit 1 ;\
	   fi ;\
	   tar cf nocol.tar nocol )
	@( mv /var/tmp/t/nocol.tar nocol.tar ;\
	    /bin/rm -rf /var/tmp/t ;\
	    tar tf nocol.tar )
	@echo "CREATED nocol.tar"
	    

clean:
	@for i in $(SRCS); do \
		( cd $$i ; make $(DIRDEFS) $(MAKEDEFS) clean ; ) ;\
	done

rcs:
	@-for i in $(SRCS); do \
		( cd $$i ; make $(MAKEDEFS) rcs ; ) ;\
	done 
###
