
# Athena Documentation Root Makefile (23 Jan 91 -- kcunning)
# (revised 27 June 94 to add html -- kcunning)
#
# This file includes the commands to generate whole documents from
# individual .olh modules.  This file is used by /mit/docsourc/kmake
# in conjunction with actual per-directory information kept in files
# named Make in each appropriate directory (see Make.sample).  It assumes
# that the Make file is concatenated with this file before running "make".


# Definitions of Variables

TMP =		/tmp/kmake.tmp

CONV1 =		/bin/sed -f /mit/logos/lib/conv1
CONV2 =		/bin/sed -f /mit/logos/lib/conv2
CONV3 =		/bin/sed -f /mit/logos/lib/conv3
CONV4 =		/bin/sed -f /mit/logos/lib/conv4

PAGE =		/mit/logos/lib/page.olh
PAGE0 =		/mit/logos/lib/page0.olh
PAGE1 =		/mit/logos/lib/page1.olh

HF =		/mit/logos/lib/headfoot.olh
TOCHACK =	/mit/logos/lib/tochack.olh

WEBPATH = 	/mit/logos/lib/webconv
CONVRTF =	/bin/sed -f $(WEBPATH)/convrtf
EZ2RTF =	2rtf
RTF2HTML =	rtftohtml
CONVHTML =	/bin/sed -f $(WEBPATH)/convhtml
CONVTOC =	/bin/sed -f $(WEBPATH)/convtoc
CONVGIF =	$(WEBPATH)/convgif
CONVINFO =	$(WEBPATH)/convinfo
CONVANCHOR =	$(WEBPATH)/convanchor

TIDIR =		/mit/logos/olh/techinfo

# Default Naming Conventions for some standard elements (assumes FILE_NAME)

FRONT =		Front
COVER =		Cover
INFO =		Info
FRONT_MATTER =	$(COVER).olh $(PAGE0) $(INFO).olh
HEADFOOT =	/tmp/Header$(FILE_NAME)
OUT_LIST =	$(FILE_NAME).out


# Non-target-generating commands

.SUFFIXES:	.olh .1 .2 .3 .4 .all .rtf .html .techinfo .mss .PS .tex .dvi .out

#.SILENT:


# Target-generating commands

.olh.1:
	$(CONV1) $*.olh > $@

.olh.2:
	$(CONV2) $*.olh > $@
	
.olh.3:
	$(CONV3) $*.olh > $@

.olh.4:
	$(CONV4) $*.olh > $@

.olh.html:
	rm -f $(TMP) $*.rtf $*.html TMP.raster
	echo "Preconverting special olh styles, separating rasters out..."
	$(CONVRTF) $*.olh > $(TMP)
	echo "Converting the EZ file to RTF..."
	$(EZ2RTF) $(TMP) $*.rtf
	rm -f $(TMP)
	echo "Converting the RTF file to HTML..."
	$(RTF2HTML) $*.rtf
	echo "Cleaning up the HTML file ..."
	$(CONVHTML) $*.html | $(CONVTOC) | rfirst '<hr>' '' > $(TMP)
	echo "</body>" >> $(TMP)
	rm -f $*.html
	sed -e 's/\*TITLE\*/$(DOC_TITLE)/' $(TMP) > $*.html
	echo "Restore GIFs, if any..."
	$(CONVGIF) $*
	echo "Creating Revision info from Info.olh file"
	$(CONVINFO) $(INFO)
	/bin/sed -e 's/\*TITLE\*/$(DOC_TITLE) <br>\
Revision History/' \
		/tmp/$(INFO).tmp > Revision.html
	echo "Creating Table of Contents and anchors"
	 $(CONVANCHOR) $* $(TMP)
	/bin/sed -e 's/<title>\*TITLE\*/<title>$(DOC_TITLE)/' temp > $(TMP)
	/bin/sed -e 's/href=\"\*TITLE\*/href=\"$*/' $(TMP) > TOC.html
	rm -f /tmp/$(INFO) /tmp/$(INFO).rtf /tmp/$(INFO).html /tmp/$(INFO).tmp
	echo "Done"
	rm -f $(TMP) TMP.raster

$(INFO).html:	$(INFO).olh
	

$(FRONT).olh:	$(FRONT_MATTER)
	echo -n "Concatenating files to form front matter ... "
	datacat -v -I -o Front.olh $(FRONT_MATTER)
	echo "Done"

$(FILE_NAME).olh:	$(HF) $(TOCHACK) $(BODY_LIST) Make
	sed -e 's/Document/$(DOC_TITLE)/' \
		-e 's/Date/$(DOC_DATE)/' $(HF) > $(HEADFOOT)
	echo -n "Concatenating files to form body of document ... "
	datacat -v -I -o $(FILE_NAME).olh $(HEADFOOT) $(BODY_LIST)
	echo "Done"
	echo "File is $(FILE_NAME).olh"

$(FILE_NAME).all:	$(FRONT).olh $(FILE_NAME).olh
	echo -n "Concatenating files to form full document ... "
	datacat -v -I -o $(FILE_NAME).all \
		$(FRONT).olh $(PAGE1) $(FILE_NAME).olh
	echo "Done"
	echo "File is $(FILE_NAME).all"

.all.out:
	ezprint -c -E $*.all

.html.out:
	echo "Sending document to Mosaic... "
	Mosaic $*.html &

.all.techinfo:
	echo "Converting $*.all to ascii ... "
	sed -e "s/\\\symbola{7}/\*/g"< $*.all | ez2ascii> $(TIDIR)/$@

front:	$(FRONT).olh

doc:	$(FILE_NAME).olh

all:	$(FILE_NAME).all

html:	$(FILE_NAME).html
	echo "Sending full document to Mosaic window... "
	Mosaic $(FILE_NAME).html &

#This may not generate table of contents...
preview: $(FILE_NAME).all
	echo "Sending full document to EZ preview window... "
	ezprint -c -E -p $(FILE_NAME).all

	
.mss.PS:
	scribe $*.mss

.PS.out:
	lpr $*.PS


.tex.dvi:
	latex $*.tex

.dvi.out:
	dvi2ps $*.dvi | lpr


out:	$(OUT_LIST)

clean:
	delete *.1 *.2 *.3 *~ *.tmp *.rtf




