
# Makefile for swish-e Documentation
#
# $Id: Makefile.in,v 1.20 2003/04/08 00:32:30 whmoseley Exp $
#
# Any suggestions to improve this makefile are welcome -- Bill Moseley swish@hank.org
#
# To Do: get a portable way to use "echo -e"

prefix      = /usr/local
mandir      = ${prefix}/man/man1
datadir     = ${prefix}/share
VERSION     = 2.4.3
SHELL       = /usr/bin/sh
top_srcdir  = ..
INSTALL     = ../config/install-sh -c
POD2MAN     = pod2man

INSTALL_DATA    = ${INSTALL} -m 644
MKINSTALLDIRS   = $(SHELL) $(top_srcdir)/mkinstalldirs

docdir      = $(datadir)/doc/swish-e

SOURCEPODS = ../pod/CHANGES.pod    ../pod/README.pod   ../pod/SWISH-CONFIG.pod  ../pod/SWISH-LIBRARY.pod \
             ../pod/SWISH-RUN.pod  ../pod/INSTALL.pod  ../pod/SWISH-3.0.pod     ../pod/SWISH-FAQ.pod \
             ../pod/SWISH-PERL.pod ../pod/SWISH-SEARCH.pod

MANPAGES = SWISH-RUN.1 SWISH-CONFIG.1 SWISH-FAQ.1 SWISH-LIBRARY.1 SWISH-PERL.1

HTMLDOCS = ../html/API.html          ../html/CHANGES.html     ../html/Filter.html \
           ../html/index.html        ../html/index_long.html  ../html/INSTALL.html \
           ../html/README.html       ../html/search.cgi       ../html/spider.html \
           ../html/style.css         ../html/SWISH-3.0.html   ../html/SWISH-BUGS.html \
           ../html/SWISH-CONFIG.html ../html/SWISH-FAQ.html   ../html/swish.html \
           ../html/SWISH-LIBRARY.html ../html/SWISH-PERL.html ../html/SWISH-RUN.html \
           ../html/SWISH-SEARCH.html


HTMLIMAGES = ../html/images/dotrule1.gif \
             ../html/images/swish2b.gif \
             ../html/images/swish2.gif \
             ../html/images/swishbanner1.gif \
             ../html/images/swish.gif


# How portable is .PHONY?
.PHONY: all html pod readme pdf man install-man clean realclean

.SUFFIXES:          # remove default rules



all: readme installpage html man

#--- convert README.pod to README ---

../README: ../pod/README.pod
	pod2text ../pod/README.pod > ../README && chmod 644 ../README

readme: ../README	

#--- convert INSTALL.pod to INSTALL ---

../INSTALL: ../pod/INSTALL.pod
	pod2text ../pod/INSTALL.pod > ../INSTALL && chmod 644 ../INSTALL

installpage: ../INSTALL


#--- create/install man pages ----------

# Does every 

%.1: ../pod/%.pod
	pod2man --center="SWISH-E Documentation" --lax --release='$(VERSION)' $< > $@

$(MANPAGES): ../configure

man: $(MANPAGES)

install-man: man
	@echo "Installing man pages $(MANPAGES) to $(mandir)"
	@$(MKINSTALLDIRS) $(mandir)
	@list='$(MANPAGES)'; \
	for p in $$list; do $(INSTALL_DATA) $$p $(mandir); done


install-docs:
	@echo "Instaling HTML files to $(docdir)/html"
	@$(MKINSTALLDIRS) $(docdir)/html/images
	@list='$(HTMLDOCS)'; \
	for p in $$list; do $(INSTALL_DATA) $$p $(docdir)/html; done
	@list='$(HTMLIMAGES)'; \
	for p in $$list; do $(INSTALL_DATA) $$p $(docdir)/html/images; done
	
# Check to see if the HTML docs exist
# should always be able to install man because pod2man is part of perl

# Question: should filter-bin, example, prog-bin, conf be installed?

install-docs-test:
	@if test -f ../html/index.html; then \
		$(MAKE) $(MFLAGS) $(MVARS) install-docs; \
	else \
		echo "  *** No HTML docs to install - may need to run make docs first ***"; \
	fi
	@if test $(POD2MAN)x = x; then \
		echo "  *** No pod2man command -- not installing man pages ***"; \
	else \
		$(MAKE) $(MFLAGS) $(MVARS) install-man; \
	fi
	@if test -f ../README; then \
		$(MKINSTALLDIRS) $(docdir); $(INSTALL_DATA) ../README $(docdir); \
	fi
	@if test -f ../INSTALL; then \
		$(MKINSTALLDIRS) $(docdir); $(INSTALL_DATA) ../INSTALL $(docdir); \
	fi


#--- create html pages ------



# This is to display the version in the documetation

./Version.pm: Makefile
	@echo 'package SWISHE::Doc;$$VERSION=q[$(VERSION)];1' > ./Version.pm

html: ./Version.pm
	@bin/build


#--- split version (for searchable version of documentation ) ---

split: ./Version.pm
	@echo "Checking for swish binary..."
	test -x ../src/swish-e

	bin/build -s

	cp ../src/swish-e ../html/split/swish-e
	../html/split/swish-e -c split.conf
	chmod 755 ../html/split/search.cgi
	perl -i.orig -pe 's{<!-- SEARCH -->}{<center>[<a href="split/search.cgi">Search The Documentation</a>]</center>}' ../html/index.html ../html/index_long.html
	perl -i.orig -pe 's{<!-- SEARCH -->}{<center>[<a href="search.cgi">Search</a>] [<a href="../index.html">Back to Non-Split Documentation</a>]</center>}' ../html/split/index.html ../html/split/index_long.html
	@echo -e "\n** Don't forget to refresh in your browser to see the new pages! **\n"


#--- create PDF and PostScript ----

pdf: ./Version.pm
	bin/build -d
	cp -f rel_ps/swish-e_documentation.pdf ..
	cp -f rel_ps/swish-e_documentation.ps ..
	rm -rf rel_ps
	@echo "swish-e_documentation.pdf"


#---- clean -------------

# This cleans split and pdf/ps and man pages
clean:
	rm -rf rel_ps
	rm -f ../swish-e_documentation.pdf ../swish-e_documentation.ps
	rm -rf ../html

	rm -f ./*.1
	-chmod 644 ../pod/*.pod
	
realclean: clean
	rm -f Makefile
	rm -f ./pod2html-dircache ./pod2html-itemcache

distclean: realclean


