# -*- sh -*-
#
# To create the SGML files, you will need to install the tm-utils
# package.  See http://www.jedsoft.org/ for more information.
#
TMDIST = $(HOME)/sys# src/web/tm-dist
TMEXPAND = $(TMDIST)/bin/tmexpand
MACRODIR = $(TMDIST)/share/tmexpand

DOC = pvm

TXT_FILES = $(DOC).txt
SGML_FILES = $(DOC).sgml
HTML_FILES = $(DOC).html
TEX_FILES = $(DOC).tex
PS_FILES = $(DOC).ps 
PDF_FILES = $(DOC).pdf
HLP_FILE = $(DOC).hlp

HLP_TM_FILE = helpfile.tm
HLPFUNS_TM = pvmfuns.tm pvm_msfuns.tm

SGML2LATEX = sgml2latex -p letter -o tex
SGML2HTML = sgml2html
SGML2TXT = sgml2txt -f
LATEX = latex
PDFLATEX = pdflatex

TEXTDIR = ../text
PSDIR = ../ps
PDFDIR = ../pdf
HTMLDIR = ../html
SGMLDIR = ../sgml
HELPDIR = ../help

SUBDIRS = $(TEXTDIR) $(HTMLDIR) $(PSDIR) $(PDFDIR) $(SGMLDIR) $(HELPDIR)
SRCDIR = `pwd`

all: $(SGML_FILES) $(HTML_FILES) $(TEX_FILES) $(TXT_FILES) $(HLP_FILE)
text-files: $(TXT_FILES)
#----- SGML Files -----------------------------------------------------------
$(DOC).sgml : $(DOC).tm  $(HLPFUNS_TM)
	$(TMEXPAND) -I$(MACRODIR) $(DOC).tm $(DOC).sgml
#----- HTML Files -----------------------------------------------------------
$(DOC).html : $(DOC).sgml
	$(SGML2HTML) $(DOC).sgml
#----- TeX Files ------------------------------------------------------------
$(DOC).tex : $(DOC).sgml
	$(SGML2LATEX) $(DOC).sgml
	jed -script ./fixtex.sl $(DOC).tex
#----- PDF Files -----------------------------------------------------------
$(DOC).pdf : $(DOC).tex
	$(MAKE) texclean
	$(PDFLATEX) $(DOC).tex
	$(PDFLATEX) $(DOC).tex
	$(PDFLATEX) $(DOC).tex
#----- PS Files -----------------------------------------------------------
$(DOC).ps : $(DOC).tex texclean
	$(LATEX) $(DOC).tex
	$(LATEX) $(DOC).tex
	$(LATEX) $(DOC).tex
	dvips -o $(DOC).ps $(DOC).dvi
#----- Text Files -----------------------------------------------------------
$(DOC).txt: $(DOC).sgml
	$(SGML2TXT) $(DOC).sgml
#----------------------------------------------------------------------------
help-files: $(HLP_FILE)
$(HLP_FILE): $(HLP_TM_FILE) $(HLPFUNS_TM)
	$(TMEXPAND) -I$(MACRODIR) $(HLP_TM_FILE) $(HLP_FILE)
texclean:
	-rm -f *.dvi *.log *.aux *.toc *.out
clean: texclean
	-rm -f *~ rtl/*.BAK rtl/*~ *.tmp
distclean: clean
	-rm -f *.html *.ps $(HLP_FILE) $(TXT_FILES) $(TEX_FILES) $(SGML_FILES) $(PDF_FILES)
install-txt-files: $(TXT_FILES)
	-mv $(TXT_FILES) ../text

install: all $(PS_FILES) $(PDF_FILES)
	-mkdir $(SUBDIRS)
	-mv $(TXT_FILES) $(TEXTDIR)
	-mv *.html $(HTMLDIR)
	-mv $(PS_FILES) $(PSDIR)
	-mv $(SGML_FILES) $(SGMLDIR)
	-mv $(PDF_FILES) $(PDFDIR)
	-mv $(HLP_FILE) $(HELPDIR)
