#
# Dlint Web Package
# Copyright (C) 1997 by Paul Balyoz
#
# Distribute CGI executables to CGI web directory, and
# regular html, gif, txt files to ordinary web directory.
#

# Don't change this
VERSION=1.0.0

# ------------------------------------------------------------------
# Configure the following - make sure paths exist before continuing!
# ------------------------------------------------------------------

# Where sysadmin utilities get installed
SBIN=/usr/local/sbin

# Where CGI scripts should be installed
cgidir=	/home/wwwtest/cgi-bin
# What's the URL of that? (absolute or relative, no ending slash)
cgiurl=	/cgi-bin

# Where HTML code should be installed for local testing
htmldir=	/home/wwwtest/html
# What's the URL of that? (absolute or relative, no ending slash)
htmlurl=	

# Subdirectory to create within cgi-bin directory (name of this package)
# Note: this directory will be created if it doesn't exist.
thisdir=	domtools

# Where were Domtools installed, that your web server can run them from?
domtoolsbin=	/usr/local/bin/domtools

# Path to Perl 5 on your web server
PERL=/usr/bin/perl

# BSD-style install utility (specify full path if needed)
INSTALL=install
#INSTALL=ginstall

# Administrator's real name
adminname = "Paul Balyoz"

# Administrator email address is built as:   admin@site
admin = pab
site = domtools.com

# Path to the bsd-style mail sender the appropriate httpd server uses
# (must understand "-s subject" on the command line)
mail = /bin/mail

# Library directory - where "domtoolscgi.log" log file is created by nph-domtools.
# Make sure it's outside of cgi and www areas.
lib = /home/wwwtest/lib

# Where graphics files should be stored (will be created if doesn't exist)
imagesdir = /home/wwwtest/html/domtools

# URLs to those graphics areas
imagesurl = /domtools


# ================================ END CONFIGURATION SECTION ===========================


# Name of temporary sed macros files:
MACRO=		macros.sed

# CGI scripts, libraries, config files to install
# (Macro substitutes will occur)
CGIS=		nph-domtools

# Files we copy to VNB CGI directory without substitutions
# (Macro substitutes will *NOT* occur)
CGIEXTERNS=	cgi-lib.pl

# HTML files to install
# (Macro substitutes will occur)
HTMLS=		index.shtml

# Misc files to include in distribution
MISC=		README Makefile

# Images to install
IMAGES=		left-arrow.gif invispixel.gif

# Utilities to install
UTILS=		domtoolsstat

# Graphics we should build but never delete
BUTTONGIFS=	any.gif cname.gif gensubnetlist1.gif gensubnetlist2.gif \
		gw.gif hosts.gif invispixel.gif mx.gif netname.gif \
		ns.gif nsroot.gif owner.gif ptr.gif siteinfo.gif \
		soalist.gif subzone.gif zone.gif network.gif \
		netmask.gif subnetmask.gif

BUTTONSRCS=	any.button cname.button gensubnetlist1.button gensubnetlist2.button \
		gw.button hosts.button invispixel.button mx.button netname.button \
		ns.button nsroot.button owner.button ptr.button siteinfo.button \
		soalist.button subzone.button zone.button network.button \
		netmask.button subnetmask.button


all:		$(BUTTONGIFS)
		@echo 'now you should "make install".'

.SUFFIXES:	.button .gif
.button.gif:
		./makebutton $<


$(MACRO):	Makefile
		-rm -f $(MACRO)
		echo "s,CGIDIR,$(cgidir),g" >> $(MACRO)
		echo "s,CGIURL,$(cgiurl),g" >> $(MACRO)
		echo "s,HTMLDIR,$(htmldir)/$(thisdir),g" >> $(MACRO)
		echo "s,HTMLURL,$(htmlurl)/$(thisdir),g" >> $(MACRO)
		echo "s,DOMTOOLSBIN,$(domtoolsbin),g" >> $(MACRO)
		echo "s,PERL,$(PERL),g" >> $(MACRO)
		echo "s,MAILPROG,$(mail),g" >> $(MACRO)
		echo "s,ADMINNAME,$(adminname),g" >> $(MACRO)
		echo "s,ADMINUSER,$(admin),g" >> $(MACRO)
		echo "s,ADMINSITE,$(site),g" >> $(MACRO)
		echo "s,LIB,$(lib),g" >> $(MACRO)
		echo "s,IMAGESURL,$(imagesurl),g" >> $(MACRO)
		echo "s,VERSION,$(VERSION),g" >> $(MACRO)

#-------------------

install:	$(MACRO) $(HTMLS) $(CGIS) $(CGIEXTERNS) $(IMAGES) $(UTILS) $(BUTTONGIFS)
#	Install utilities into system-bin directory
	for file in $(UTILS); do \
		sed -f $(MACRO) < $$file > xxxtool; \
		$(INSTALL) -c -m 755 xxxtool $(SBIN)/$$file; \
	done
#	Create html directory if it doesn't exist
	-test -d $(htmldir) || mkdir $(htmldir)
	-chmod 755 $(htmldir)
	-test -d $(htmldir)/$(thisdir) || mkdir $(htmldir)/$(thisdir)
	-chmod 755 $(htmldir)/$(thisdir)
#	Install all html files
	for file in $(HTMLS); do \
		sed -f $(MACRO) < $$file > xxxtool; \
		$(INSTALL) -m 664 xxxtool $(htmldir)/$(thisdir)/$$file; \
	done
#	Create images directory if it doesn't exist
	-test -d $(imagesdir) || mkdir $(imagesdir)
	-chmod 755 $(imagesdir)
#	Install all images and buttons
	cp $(IMAGES) $(BUTTONGIFS) $(imagesdir)
	cd $(imagesdir); chmod 644 $(IMAGES) $(BUTTONGIFS)

#	Create CGI directory if it doesn't exist
	-test -d $(cgidir) || mkdir $(cgidir)
	-chmod 755 $(cgidir)
#	Macro substitute & install all CGI scripts
	for file in $(CGIS); do \
		sed -f $(MACRO) < $$file > xxxtool; \
		$(INSTALL) -m 755 xxxtool $(cgidir)/$$file; \
	done
#	Install cgi external progs
	for file in $(CGIEXTERNS); do \
		test -f $(lib)/$$file || $(INSTALL) -m 755 $$file $(lib)/$$file; \
	done

#-------------------

clean:
	-rm -f $(MACRO) xxxtool core


#
# Developer's section ---------------------------------
#

PUB=/home/wwwtest/html/pub
dist:	clean
	d=`pwd`; d=`basename $$d`; cd ..; tar czf /tmp/$$d.tar.gz \
			--exclude RCS \
			--exclude Old \
			--exclude CGIDIR \
			--exclude HTMLDIR \
			$$d; echo "done.  distribution file is /tmp/$$d.tar.gz"

dist-install:   dist
	$(INSTALL) -m 664 -o pab -g www /tmp/domtoolsweb$(VERSION).tar.gz $(PUB)
	$(INSTALL) -m 664 -o pab -g www README $(PUB)/domtoolsweb$(VERSION)-readme.txt
	$(INSTALL) -m 664 -o pab -g www CHANGES $(PUB)/domtoolsweb$(VERSION)-changes.txt
#---
