#!/bin/sh
#
# Everything after a `#' is ignored (in this shell script)
#
# remove the string `> /dev/null' if you want more log-output
# remove the line containing `batchmode' if you want even more 
#  log-information while running LaTeX
#
#----------------- create a `ltxdoc.cfg': --------------------------

# Put here a list of options to pass to the class:
OPT=a4paper

echo "Generating configuration file ltxdoc.cfg for youngtab.dtx"

# Write the file in one pass:
cat > ltxdoc.cfg <<EOF
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ltxdoc.cfg for youngtab.dtx, generated by makeydoc %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\PassOptionsToClass{$OPT}{article}
\batchmode

%% Do not uncomment the next 2 lines
%\AtBeginDocument{\RecordChanges}
%\AtEndDocument{\PrintChanges}

%% The next 3 lines produce full indexes and change logs
%% - you may not want those (commented out by default).
\AtBeginDocument{\CodelineIndex\EnableCrossrefs}
\AtEndDocument{\PrintIndex}
\AtEndDocument{\addcontentsline{toc}{section}{Index}}

%% If you do not want any code listings, just documentation, then instead
%% of the lines above, uncomment the following:
%\AtBeginDocument{\OnlyDescription}
EOF
#---------- latex the documentation using `ltxdoc.cfg': --------------

ThisDoc=youngtab.dtx
Base=youngtab

echo;echo "1st latex $ThisDoc"
if (latex $ThisDoc > /dev/null) 
then
  echo;echo "2nd latex $ThisDoc"
  latex $ThisDoc > /dev/null

  echo;echo "makeindex -s gind.ist $Base.idx"
  makeindex -s gind.ist $Base.idx
  echo;echo "3rd latex $ThisDoc"
  latex $ThisDoc > /dev/null
else
  echo;cat <<EOF
  !!! LaTeX ERROR: $ThisDoc. (See $Base.log.)
  Perhaps a new version of youngtab.sty is missing?
  (Then, generate it by "tex youngtab.ins")
EOF
fi
