# Make file for inetd directory
#
# Things you might want to change.  Pass them in on the command line:
# ROOT - should point to the root where the commands will be installed
#        (e.g. /deliver/INETSVCS/indnetwk)

ROOT=

PRODUCTS=/usr/sbin/inetd

# Defaults file containing the shell, compiler options, etc
BUILDRULES=/source/INETSVCS/$(LOGNAME)/config/defaults

include ${BUILDRULES}

INCLUDES=-I. -I../include -I/usr/include

SRCS=   config.c internal.c signal.c inetd.c sem.c vers.c

HDRS= inetd.h pathnames.h

OBJS=   config.o internal.o signal.o inetd.o sem.o vers.o

CCFLAGS=$(INCLUDES) -DAUDIT -DSETPROCTITLE $(CFLAGS)

LDLIBRARIES=    ../util/libutil.a

#Install database name
INSTALLDB=/source/INETSVCS/$(LOGNAME)/config/installdb

#Script called to parse the install deliverable
INSTALLSCPT=/source/INETSVCS/$(LOGNAME)/config/install_script

default: all

all: clean build install

clean:
	$(RM) -f *.o
	$(RM) -f core
	$(RM) -f inetd
	$(RM) -f vers.c
	
build:  inetd

vers.c:
	$(SHELL) newvers.sh
	$(CC) $(CCFLAGS) -c vers.c

inetd:  $(HDRS) $(SRCS)
	$(ECHO) "Building inetd..."
	$(CC) -c $(CCFLAGS) $(SRCS)
	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBRARIES)
	
install:
	for file in $(PRODUCTS) ; do \
		$(INSTALLSCPT) $$file $(INSTALLDB) ;  \
	done

versionlog:
	$(RM) -f version.log
	VERSION=`awk '{print $$2}' version` ; \
	$(ECHO) "Revision $$VERSION contains the following inetd sources:\n" >version.log
	for i in $(SRCS) $(HDRS) ; do \
		if [ "$$i" = "vers.c" ] ; then \
			continue; \
		fi ; \
		ident $$i | grep Revision | \
		awk ' {printf ("%-20s %-20s\n", FILE, $$2)}' FILE=$$i ; \
	done | sort | pr -2 -t >>version.log
