#!/bin/ksh
# Berkeley IPC programs  for setting time over the Internet
#  R. Schmidt, Time Service, USNO
#
CFLAGS = -O
#  For SunOS 4.x  uncomment the next line:
#CFLAGS = -O -DSUN
#
BIN = /usr/local/bin
MAN = /usr/local/man/man1
INETD = /etc
# for Sun:  uncomment the next line:
# INETD = /usr/etc

all:	time_set timecheck  timesrv
#  This line replaces the above if you want to provide the timer server
#  on your local machine through inetd:
#all:	time_set timecheck timesrv install_serv

time_set:	time_set.c
	$(CC) $(CFLAGS) -o time_set time_set.c

timecheck:	timecheck.c
	$(CC) $(CFLAGS) -o timecheck timecheck.c 

timesrv:	timesrv.c
	$(CC) $(CFLAGS) -o timesrv timesrv.c

install:
	chmod 744 time_set
	chmod 755 timecheck
	cp  time_set timecheck TIME_SET $(BIN)
	cat etc.services>>/etc/services
	cp *.1 $(MAN)

#  Only if you also want to be a time server:
install_serv:
	chmod 744 timesrv
	chmod 744 time_set
	chmod 755 timecheck
	cp  timesrv time_set timecheck TIME_SET $(BIN)
	cat etc.services>>/etc/services
	cat etc.inetd.conf>>/etc/inetd.conf

#  On Sun, send SIGHUP to inetd:  Uncomment this line:
#/bin/kill -1  `ps -ax | grep inetd | grep -v grep | cut -c 1-5 `
#
#  On HP, the restart for inetd is /etc/inetd -c :
#  Comment out the next line for SunOS 4.x : 
	$(INETD)/inetd -c
	cp *.1 $(MAN)

# create shell archive:
shar:
	rm time.sh
	shar -cmos * >time.sh
