ALL: all-redirect
SHELL = @SHELL@
srcdir = @srcdir@
MPICH_VERSION = @MPICH_VERSION@

.SUFFIXES: .pdf .dvi .tex

# Set these to the location of the web and ftp locations for the documents
WEBDIR = /mcs/www/mpi/mpich2/docs
FTPDIR = /home/ftp/pub/mpi/mpich2

@VPATH@

LATEX      = TEXINPUTS=".:$(srcdir):" ; export TEXINPUTS ; latex
BIBTEX     = BIBINPUTS=".:$(srcdir):" ; export BIBINPUTS ; bibtex
DVIPDFM    = TEXINPUTS=".:$(srcdir):" ; export TEXINPUTS ; dvipdfm
LATEX2HTML = latex2html

# Update the %MPICH_VERSION% with current version string.
windev.tex: windev.tex.vin
	sed -e "s/%MPICH_VERSION%/${MPICH_VERSION}/g" $? > $@

windev.dvi: windev.tex
	-$(LATEX) windev.tex
	-$(LATEX) windev.tex
	$(LATEX)  windev.tex

windev.pdf: windev.dvi
	$(DVIPDFM) windev.dvi

# Use latex2html to create the HTML version.  There are several 
# steps needed to workaround features of latex2html
# 1. latex2html needs the windev.aux file, so we run a latex step if
#    necessary
# 2. latex2html is not compatible with VPATH builds (it runs in the
#    directory that contains the source file), so we copy the source
#    file.  If more source files are added, this step will need to 
#    be changed
windev.aux: windev.tex
	$(LATEX) windev.tex

windev/windev.html: windev.aux windev.tex
	$(LATEX2HTML) windev.tex

# Here are some thoughts on using tohtml
#	tohtml -debugfile -default -dosnl -gaudy \
#              -basedef $(srcdir)/../mpiman.def $(srcdir)/windev.tex
#	tohtml -default -dosnl -gaudy -basedef $(srcdir)/../mpiman.def \
#	$(srcdir)/windev.tex

all-redirect: windev.pdf

mandoc:

htmldoc:

latexdoc: ALL

clean:
	-rm -f *.dvi *.log *.out *.aux *.toc *.bbl *.blg *.pdf *.ps

distclean: clean

install: windev.pdf windev/windev.html
	@if [ -z "$(WEBDIR)" ] ; then echo "No WEBDIR set" ; exit 1 ; fi
	@if [ ! -d $(WEBDIR) ] ; then echo "Create $(WEBDIR) first" ; exit 1 ;fi
	@if [ -z "$(FTPDIR)" ] ; then echo "No FTPDIR set" ; exit 1 ; fi
	@if [ ! -d $(FTPDIR) ] ; then echo "Create $(FTPDIR) first" ; exit 1 ;fi
	cp windev.pdf $(WEBDIR)/windev.pdf
	cp -rp windev $(WEBDIR)/windev-new
	rm -rf $(WEBDIR)/windev
	mv -f $(WEBDIR)/windev-new $(WEBDIR)/windev
	cp windev.pdf $(FTPDIR)/windev.pdf
	cp -rp windev $(FTPDIR)/windev-new
	rm -rf $(WEBDIR)/windev
	mv -f $(FTPDIR)/windev-new $(FTPDIR)/windev
