# Makefile for SWISH
# Miles O'Neal, 04/Aug/98

#### CONFIGURATION SECTION (see also src/config.h and src/Makefile)
#
# BINDIR - where the swish executable should go.
# CGIDIR - where the CGI scripts should go.
# SCRDIR - where the other scripts should go.
#
BINDIR = /www/httpd/cgi-bin
CGIDIR = /www/httpd/cgi-bin
SCRDIR = /www/httpd/cgi-bin
#
# CONFDIR - directory to hold configuration files for SWISH indexes
#
CONFDIR = /www/httpd/conf/swish
#
# DOCDIR - where the HTML docs will go
#
DOCDIR = /www/pages/netads/Doc/swish
#
# ICONDIR - where the SWISH icon should go
#
ICONDIR = /www/icons
#
# PERLBIN - perl binary's path
#
PERLBIN = /usr/local/bin/perl
#
#### YOU SHOULD NOT HAVE TO CHANGE ANYTHING BELOW HERE

DOCFILES = \
    index.cgi \
    index.html \
    index-l.html \
    1-overview.html \
    2-license.html \
    3-installation.html \
    4-configuration.html \
    5-users.html \
    6-faq.html \
    a-usage-summary.html \
    b-conf-example.html \
    c-changes.html \
    d-related.html \

ICONS = $(ICONDIR)/swish.gif $(ICONDIR)/swish-bg.gif

all: swish

swish:
	cd src; make
	cd src; mv swish ..

clean:
	rm -f ./swish ./Test/index.swish
	cd src; make clean

test: swish
	cd Test ; \
	../swish -i test.html -v -f index.swish ; \
	../swish -f index.swish -w test

install: all
	@if [ ! -d $(BINDIR) ] ; then \
		mkdir $(BINDIR) ] ; \
	fi
	cp swish $(BINDIR)
	strip $(BINDIR)/swish
	@if [ ! -d $(ICONDIR) ] ; then \
		mkdir $(ICONDIR) ] ; \
	fi

install-icons:
	cp Icons/swish.gif $(ICONDIR)
	cp Icons/swish-bg.gif $(ICONDIR)

install-docs:
	@if [ ! -d $(DOCDIR) ] ; then \
		mkdir $(DOCDIR) ] ; \
	fi
	cd Docs ; \
	cp $(DOCFILES) $(DOCDIR)

install-scripts:
	sed -e 's,@@SWISH_CONF_DIR@@,${CONFDIR},' \
		-e 's,@@SWISH_BIN_DIR@@,${CGIDIR},' \
		-e 's,@@PERL_BIN@@,${PERLBIN},' \
		< Scripts/index-cust.cgi > ${CGIDIR}/index-cust.cgi
	sed -e 's,@@SWISH_CONF_DIR@@,${CONFDIR},' \
		-e 's,@@SWISH_BIN_DIR@@,${CGIDIR},' \
		-e 's,@@PERL_BIN@@,${PERLBIN},' \
		< Scripts/rebuild-index.cgi > ${CGIDIR}/rebuild-index.cgi
	chmod 755 ${CGIDIR}/index-cust.cgi ${CGIDIR}/rebuild-index.cgi
	sed -e 's,@@SWISH_CONF_DIR@@,${CONFDIR},' \
		-e 's,@@SWISH_BIN_DIR@@,${SCRDIR},' \
		-e 's,@@PERL_BIN@@,${PERLBIN},' \
		< Scripts/mkswishconf > ${SCRDIR}/mkswishconf
	chmod 755 ${SCRDIR}/mkswishconf

world: install install-docs install-scripts install-icons
