#
# ident "@(#) Makefile 1.1 /dsk2/users/len/named/sol251/SCCS/s.Makefile"
# ident "@(#) Last modified 10/29/96 13:09:17"
#

HEADERS= analogic.zone.header analogic.rev.header
ZONE_FILES= named.boot named.local named.ca
ZONE_NEW= analogic.zone.new analogic.rev.new
SCRIPTS= update_hosts update_serial hosts2dns build_ns install_ns

# Make is broken.  install-ns will not work correctly without the following:

.POSIX:
.IGNORE: install-ns


all: build-ns build-msg
	@echo ""

scripts: ${SCRIPTS}
${SCRIPTS}:
	sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@ -G$@
	chmod 544 $@; \

update-hosts: update_hosts
	@update_hosts

build-ns: update-hosts hosts2dns update_serial ${HEADERS}
	@hosts2dns 
	@update_serial analogic.zone.new
	@update_serial analogic.rev.new

build-msg:
	@echo "\nType: \"make install-ns\" to install and restart the Nameserver."

install-build:
	@if [ ! -f analogic.zone.new -o ! -f analogic.rev.new ]; then \
	   make build-ns; \
	fi

install-ns:  install-build ${ZONE_FILES}
	@echo "Installing zone files..." 
	/bin/cp named.boot named.local named.ca /etc 
	/bin/cp analogic.zone.new /etc/analogic.zone
	/bin/cp analogic.rev.new /etc/analogic.rev 
	@echo "" 
	@echo "Restarting the Nameserver...\c" 
	@if [ `ps -fu root | grep -c '[^]]named'` -gt 0 ]; then \
	   kill -HUP `cat /etc/named.pid`; \
	else \
	   /usr/sbin/in.named; \
	fi
	@if [ `ps -fu root | grep -c '[^]]named'` -eq 0 ]; then \
	   echo "Start of Nameserver failed!!"; \
	else \
	   echo "done."; \
	fi

clean:
	/bin/rm -f hosts.master ${HEADERS} ${ZONE_FILES} ${ZONE_NEW} ,* *~

veryclean: clean
	sccs clean
