#!/bin/sh

rm  -f source2e.gls source2e.ind source2e.toc

# First run: 
# Create new standard ltxdoc.cfg file
# Pass the (possibly empty) list of arguments supplied on the
# command line to article class.
#
# If you use A4 paper, running this script with argument
#    a4paper
# may save about 30 pages.
#
echo "\PassOptionsToClass{$*}{article}" > ltxdoc.cfg


# Now LaTeX the file with this cfg file.
#
latex2e source2e.tex


# Make the Change log and Glossary.
#
makeindex -s source2e.ist source2e.idx
makeindex -s gglo.ist -o source2e.gls source2e.glo


# Second run: append \includeonly{} to ltxdoc.cfg to speed up things
# (this run needed only to get changes and index listed in .toc file)
#
# Note that the index will not be made incorrect by the insertion
# of the table of contents as the front matter uses a diferent page
# numbering scheme.
#
echo "\includeonly{}" >> ltxdoc.cfg

latex2e source2e.tex


# Third and final run, to put everything together.
# First restore the cfg file:
#
echo "\PassOptionsToClass{$*}{article}" > ltxdoc.cfg
latex2e source2e.tex


#==============
#!/bin/sh

# Running this script will process all the dtx fdd and *guide.tex
# and ltnews*.tex files in the LaTeX distribution, except the dtx
# files included in source2e.tex. 
# (The shell first script in the comments of source2e.tex will
#  process those.)

# Any command line arguments (eg a4paper) are taken as options to the
# article class.

# This script is likely to take ages!

echo "\PassOptionsToClass{$*}{article}"                  > ltxdoc.cfg
echo "\batchmode"                                       >> ltxdoc.cfg

# The next four lines produce full indexes and change logs
# you may not want those.
echo "\AtBeginDocument{\RecordChanges}"                 >> ltxdoc.cfg
echo "\AtEndDocument{\PrintChanges}"                    >> ltxdoc.cfg
echo "\AtBeginDocument{\CodelineIndex\EnableCrossrefs}" >> ltxdoc.cfg
echo "\AtEndDocument{\PrintIndex}"                      >> ltxdoc.cfg

# If you do not want any code listings, just documentation, then instead
# of the above four lines, uncomment the following:
# echo "\AtBeginDocument{\OnlyDescription}"                >> ltxdoc.cfg

echo "\PassOptionsToClass{$*}{article}"                  > ltxguide.cfg
echo "\batchmode"                                       >> ltxguide.cfg

cp ltxguide.cfg ltnews.cfg


for i in *dtx *fdd *guide.tex ltnews*.tex
do
B=`basename $i .dtx`

if (grep "Include{$B}" source2e.tex >/dev/null ; )
then
echo In source2e: $i
else
echo latex2e $i
  if (latex2e $i > /dev/null) 
  then
    echo latex2e $i
    latex2e $i > /dev/null
    echo makeindex -s gind.ist $B.idx
    makeindex -s gind.ist $B.idx > /dev/null 2> /dev/null
    echo makeindex -s gglo.ist -o $B.gls $B.glo
    makeindex -s gglo.ist -o $B.gls $B.glo > /dev/null 2> /dev/null
    echo latex2e $i
    latex2e $i > /dev/null
  else
    echo "!!! LaTeX ERROR: $i. (See $B.log.)"
  fi
fi

done
