# Run script for DOS compiler manual
# dos1 has the table of contents
# dos2.$i has manual text.
# dos3 has Lexicon.
# dos4 has the logic tree.
# dos5 has the index.
#
troff -r#1 -rX1 -mdostext -mroff fonts.r top.r ../text/intro.r \
	>/tmp/doc/mwc/dos2.1 2>dos.x
tail -1 dos.x >pgn.r
echo ".nr @1 1" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -r#1 -rX1 -mdostext -mroff fonts.r pgn.r top.r ../text/dosinstall.r \
	>/tmp/doc/mwc/dos2.2 2>dos.x
tail -1 dos.x >pgn.r
echo ".nr @1 2" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX1 -mdostext -mroff fonts.r pgn.r top.r ../text/beginners.r \
	>/tmp/doc/mwc/dos2.3 2>>dos.x
tail -1 dos.x >pgn.r
echo ".nr @1 3" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX1 -mdostext -mroff fonts.r pgn.r top.r ../text/compiling.r \
	>/tmp/doc/mwc/dos2.4 2>>dos.x
tail -1 dos.x >pgn.r
echo ".nr @1 4" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX1 -mdostext -mroff fonts.r pgn.r top.r ../text/emacs.r \
	>/tmp/doc/mwc/dos2.5 2>>dos.x
tail -1 dos.x >pgn.r
echo ".nr @1 5" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX1 -mdostext -mroff fonts.r pgn.r top.r ../text/make.r \
	>/tmp/doc/mwc/dos2.6 2>>dos.x
tail -1 dos.x >pgn.r
echo ".nr @1 6" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX1 -mdostext -mroff fonts.r pgn.r top.r ../text/dosq_and_a.r \
	>/tmp/doc/mwc/dos2.7 2>>dos.x
tail -1 dos.x >pgn.r
echo ".nr @1 7" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX1 -mdostext -mroff fonts.r pgn.r top.r ../text/errors.r \
	>/tmp/doc/mwc/dos2.8 2>>dos.x
tail -1 dos.x >pgn.r
echo ".nr @1 8" >>pgn.r
echo ".if \n#%2=0 .nr # \\\n+#" >>pgn.r
#
troff -rX1 -mdostext -mroff fonts.r pgn.r top.r ../text/lexicon.r \
	>/tmp/doc/mwc/dos2.9 2>>dos.x
tail -1 dos.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 LC ../lx/MULTI/$i* >TEMPFILE
	egrep -l LC ../lx/ANSI/$i* >>TEMPFILE
	ls ../lx/DOS/$i* >>TEMPFILE
	sort -t/ +3 TEMPFILE >FILES.$i
done
rm TEMPFILE
#
# and do the troffing
# 
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 -rX1 -mdoslex -mroff fonts.r pgn.r top.r ../alphabet/$i.r \
		`cat FILES.$i` 	>/tmp/doc/mwc/dos3.$i 2>>dos.x
	tail -1 dos.x >pgn.r
done
#
# make the logic tree
#
troff -rX1 -mdostext -mroff fonts.r pgn.r top.r logictree.dos \
	>/tmp/doc/mwc/dos4 2>>dos.x
#
# see Run.extra for extra stuff to do
#
