#!/bin/csh
#
# yet another HORRIBLE script we have to get rid of.
#
#  This creates .html pages for each PETSc man section
#
foreach dir ($1/docs/manualpages/man?)
  pushd $dir
  ls > .tmp
    set REF = $dir:t
    echo $dir |\
    awk '{if (NR == 1) {REF = substr($1,length($1)-3,4) ;} \
else {RNAME = substr($1,1,length($1)-5) ; \
printf("<LI><A HREF=\"%s/%s\">%s</A>\n",REF, $1, RNAME );}}' - .tmp > ../$REF.html
    /bin/rm -f .tmp
    echo "<MENU>" | cat - ../$REF.html > .tmp
#
# Possibly add header to each index page, with link to users manual chapter.
#    cat ../sec/$REF.head .tmp > .tmp2
#    mv .tmp2 .tmp
#    /bin/rm -f .tmp2
    /bin/rm -f ../$REF.html
    echo "</MENU>" | cat .tmp - > ../$REF.html
    echo "<BR><A HREF="manualpages.html"><IMG SRC="up.xbm">Table of Contents</A>" >> ../$REF.html
    /bin/rm -f .tmp
    popd
end
