# Run script for TOS compiler manual
# tos1 has the table of contents
# tos2.$i has manual text.
# tos3.$i has the Lexicon.
# tos4 has the permuted lexicon contents.
# tos5 has the index.
#
troff -r#1 -rX2 -mtostext -mroff fonts.txt top.r /v/doc/mwc/text/intro.r \
	>/tmp/doc/mwc/tos2.1 2>tos.x
tail -1 tos.x >pgn.r
echo ".nr @1 1" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -r#1 -rX2 -mtostext -mroff fonts.txt pgn.r top.r \
	/v/doc/mwc/text/tosinstall.r >/tmp/doc/mwc/tos2.2 2>>tos.x
tail -1 tos.x >pgn.r
echo ".nr @1 2" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX2 -mtostext -mroff fonts.txt pgn.r top.r /v/doc/mwc/text/compiling.r \
	>/tmp/doc/mwc/tos2.3 2>>tos.x
tail -1 tos.x >pgn.r
echo ".nr @1 3" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX2 -mtostext -mroff fonts.txt pgn.r top.r /v/doc/mwc/text/emacs.r \
	>/tmp/doc/mwc/tos2.4 2>>tos.x
tail -1 tos.x >pgn.r
echo ".nr @1 4" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX2 -mtostext -mroff fonts.txt pgn.r top.r /v/doc/mwc/text/make.r \
	>/tmp/doc/mwc/tos2.5 2>>tos.x
tail -1 tos.x >pgn.r
echo ".nr @1 5" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
# First time through for this boyo!
troff -rX2 -mtostext -mroff -mstscreen fonts.txt pgn.r top.r \
	/v/doc/mwc/text/resource.r >/tmp/doc/mwc/tos2.6 2>tmp.x
/u/carol/bin/hpgcmd150 <tmp.x >foo.bar
chmod +x foo.bar
foo.bar
#
# Second time through!
troff -rX2 -mtostext -mroff -mstscreen fonts.txt pgn.r top.r \
	/v/doc/mwc/text/resource.r >/tmp/doc/mwc/tos2.6 2>>tos.x
tail -1 tos.x >pgn.r
echo ".nr @1 6" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX2 -mtostext -mroff fonts.txt pgn.r top.r /v/doc/mwc/text/rescomp.r \
	>/tmp/doc/mwc/tos2.7 2>>tos.x
tail -1 tos.x >pgn.r
echo ".nr @1 7" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX2 -mtostext -mroff fonts.txt pgn.r top.r /v/doc/mwc/text/errors.r \
	>/tmp/doc/mwc/tos2.8 2>>tos.x
tail -1 tos.x >pgn.r
echo ".nr @1 8" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX2 -mtostext -mroff fonts.txt pgn.r top.r /v/doc/mwc/text/lexicon.r \
	>/tmp/doc/mwc/tos2.9 2>>tos.x
tail -1 tos.x >pgn.r
#
# Now, assemble list of lexicon files to be troff'd
#
for i in _ a b c d e f g h i j k l m n o p q r s t u v w x
do
	egrep -l TOS /v/doc/mwc/lx/MULTI/$i* >TEMPFILE
	egrep -l TOS /v/doc/mwc/lx/ANSI/$i* >>TEMPFILE
	ls /v/doc/mwc/lx/AESVDI/$i* >>TEMPFILE
	ls /v/doc/mwc/lx/TOS/$i* >>TEMPFILE
	sort -t/ +7 TEMPFILE >FILES.$i
done
rm TEMPFILE
#
# ... and troff the Lexicon
#
troff -rX2 -mtoslex -mroff fonts.lex pgn.r top.r /v/doc/mwc/lx/MULTI/EXAMPLE \
	>/tmp/doc/mwc/tos3.E 2>>tos.x
tail -1 tos.x >pgn.r
for i in _ a b c d e f g h i j k l m n o p q r s t u v w x
do
	troff -rX2 -mtoslex -mroff fonts.lex pgn.r top.r /v/doc/mwc/alphabet/$i.r \
		`cat FILES.$i` 	>/tmp/doc/mwc/tos3.$i 2>>tos.x
	tail -1 tos.x >pgn.r
done
troff -mtostext -mroff fonts.txt top.r pgn.r logic.tree \
	>tos4 2>>tos.x
#
# Now look at the file Run.extra to see what else must be done.
#
