#=======================================================================
# Makefile for TUBboat article and GNU Emacs info documentation 
# on latex-mode.
# [28-Dec-1993]
#=======================================================================
BIBTEX		= bibtex
CP		= /bin/cp
DETEX		= detex
LATEX		= latex
MAKEINDEX 	= makeindex
MV		= /bin/mv
RM		= /bin/rm -f
SED		= /bin/sed
SHAR		= shar -c -v
SHARFILES 	= Makefile ltxinfo.bib ltxinfo.ltx ltxmode.bbl \
		  ltxmode.bib ltxmode.ispell-okay ltxmode.ltx \
		  ltxmode.spell-okay makeinfo \
		  latex-mode.info latex-mode.info-?
TEXINDEX 	= texindex

ALL:	ltxmode.dvi ltxinfo.dvi latex-mode.info

all:	ltxmode.spell ltxinfo.spell dw ltxmode.dvi ltxinfo.dvi

bundle:	$(SHARFILES)
	$(SHAR) $(SHARFILES) >$@

clean:
	$(RM) *.blg
	$(RM) *.dvi*
	$(RM) *.idw
	$(RM) *.ilg
	$(RM) *.log
	$(RM) *.o
	$(RM) *.spell
	$(RM) *.tmp
	$(RM) *~
	$(RM) \#*
	$(RM) bundle
	$(RM) core

clobber:	clean
	$(RM) *.aux
	$(RM) *.bbl
	$(RM) *.idx
	$(RM) *.ind
	$(RM) *.toc

dw:
	@echo '==================== doubled words ===================='
	$(DETEX) ltxmode.ltx | dw
	$(DETEX) ltxinfo.ltx | dw

latex-mode.info:	ltxinfo.ltx
	./makeinfo ltxinfo.ltx

ltxinfo.aux:
	if [ !  -f ltxinfo.aux ] ; then touch ltxinfo.aux ; fi

ltxinfo.bbl:	ltxinfo.aux
	- $(BIBTEX) ltxinfo
	$(MV) ltxinfo.bbl /tmp
	$(SED) -e 's/~/ /g' </tmp/ltxinfo.bbl >ltxinfo.bbl
	$(RM) /tmp/ltxinfo.bbl

ltxinfo.cps:	ltxinfo.cp
	$(TEXINDEX) ltxinfo.cp
	$(MV) ltxinfo.cps /tmp
	$(SED) -e 's/initial {\\}/initial {\\back}/' \
		</tmp/ltxinfo.cps >ltxinfo.cps
	$(RM) /tmp/ltxinfo.cps

ltxinfo.dvi:	Makefile ltxinfo.ltx ltxinfo.bbl
	$(LATEX) ltxinfo.ltx
	make ltxinfo.cps ltxinfo.fns ltxinfo.kys ltxinfo.pgs ltxinfo.tps \
		ltxinfo.vrs
	$(LATEX) ltxinfo.ltx

ltxinfo.fns:	ltxinfo.fn
	$(TEXINDEX) ltxinfo.fn

ltxinfo.ispell:	ltxinfo.ltx
	if [ ! -f ltxinfo.ispell-okay ] ; then touch ltxinfo.ispell-okay ; fi
	@echo '==================== spelling exceptions ===================='
	$(DETEX) ltxinfo.ltx | ispell -l | sort -u >ltxinfo.ispell
	-diff ltxinfo.ispell ltxinfo.ispell-okay

ltxinfo.kys:	ltxinfo.ky
	$(TEXINDEX) ltxinfo.ky

ltxinfo.pgs:	ltxinfo.pg
	$(TEXINDEX) ltxinfo.pg
	$(MV) ltxinfo.pgs /tmp
	$(SED) -e 's/initial {\\}/initial {\\back}/' \
		</tmp/ltxinfo.pgs >ltxinfo.pgs
	$(RM) /tmp/ltxinfo.pgs


ltxinfo.spell:	ltxinfo.ltx
	if [ ! -f ltxmode.spell-okay ] ; then touch ltxmode.spell-okay ; fi
	@echo '==================== spelling exceptions ===================='
	$(DETEX) ltxinfo.ltx | spell +ltxmode.spell-okay >ltxinfo.spell
	cat ltxinfo.spell

ltxinfo.tps:	ltxinfo.tp
	$(TEXINDEX) ltxinfo.tp

ltxinfo.vrs:	ltxinfo.vr
	$(TEXINDEX) ltxinfo.vr

ltxmode.aux:
	if [ ! -f ltxmode.aux ] ; then touch ltxmode.aux ; fi

ltxmode.bbl:	ltxmode.bib ltxmode.aux
	if [ ! -f ltxmode.aux ] ; then touch ltxmode.aux ; fi
	-$(BIBTEX) ltxmode

ltxmode.dvi:	ltxmode.bbl ltxmode.ltx ltxmode.ind
	$(LATEX) ltxmode.ltx
	$(MAKE) ltxmode.bbl ltxmode.ind
	$(LATEX) ltxmode.ltx

ltxmode.idx:
	if [ ! -f ltxmode.idx ] ; then touch ltxmode.idx ; fi

ltxmode.ind:	ltxmode.idx Makefile
	$(MV) ltxmode.idx ltxmode.idw
	$(SED) -e 's/{\\tt <}@/<@/' -e 's/{\\tt >}@/>@/' \
		<ltxmode.idw >ltxmode.idx
	-$(MAKEINDEX) ltxmode

ltxmode.ispell:	ltxmode.ltx
	if [ ! -f ltxmode.ispell-okay ] ; then touch ltxmode.ispell-okay ; fi
	@echo '==================== spelling exceptions ===================='
	$(DETEX) ltxmode.ltx | ispell -l | sort -u >ltxmode.ispell
	-diff ltxmode.ispell ltxmode.ispell-okay

ltxmode.spell:	ltxmode.ltx
	if [ ! -f ltxmode.spell-okay ] ; then touch ltxmode.spell-okay ; fi
	@echo '==================== spelling exceptions ===================='
	$(DETEX) ltxmode.ltx | spell +ltxmode.spell-okay >ltxmode.spell
	cat ltxmode.spell
