# this shell script can be used to create a hol98 tar ball.

if [ $# -ne 1 ]
then
        echo "Must provide one argument -- the name of the release"
        exit 1
fi
name=$1

mosmldir=/local/scratch/kxs/144
cd /tmp
# use -r release-name for known release
CVSROOT=/usr/groups/hol/repository cvs export -r $name hol98
sed "s|^val mosmldir.*\$|val mosmldir = \"$mosmldir\"|" \
   < hol98/tools/configure.sml | \
   sed 's|^val holdir.*$|val holdir = "/tmp/hol98"|' > new-config
mv hol98/tools/configure.sml /tmp
mv new-config hol98/tools/configure.sml

echo Removing all .cvsignore files
find hol98 -name .cvsignore -exec /bin/rm \{} \;

echo Building filter.c
cd hol98/src/quote-filter
make filter.c
cd /tmp/hol98
mv bin/README /tmp/bin-README
mv sigobj/README /tmp/sigobj-README

echo "Running configure script (original in /tmp)"
cd /tmp/hol98
$mosmldir/bin/mosml < tools/configure.sml

echo Now building whole system
echo "Working in directories:"
if bin/build 2>&1 | tee build-log | perl developers/prettifier.pl
then
  :
else
  echo "Build failed!!" ; echo ; echo
  echo "See /tmp/hol98/build-log file for details"
  exit 1
fi

echo Now building help index
cd developers/help
make

echo Now building documentation
for man_name in Reference Description Tutorial
do
    lcname=$(echo $man_name | tr A-Z a-z)
    echo Making $man_name
    cd /tmp/hol98/Manual/$man_name
    make all
    for i in .dvi .ps .pdf
    do
        mv $lcname$i /tmp/$name-$lcname$i
    done
done
#Note (kxs): previous doesn't produce .ps files

echo Now starting to clean up and make tar ball
cd /tmp/hol98
cat /tmp/hol98/tools/documentation-directories | \
 while read foo ; do echo "Removing .doc files from $foo" ; \
                     /bin/rm /tmp/hol98/$foo/*.doc ; done
/bin/rm build-log
bin/build -cleanAll
/bin/rm -rf developers
/bin/rm -rf Manual
/bin/rm -rf src/arith src/ho_match src/lite src/utils
mv /tmp/configure.sml tools
(cd examples; cd MLsyntax; ../../bin/Holmake cleanAll; cd .. ; \
               cd RSA;      ../../bin/Holmake cleanAll; cd .. ; \
               cd ind_def;  ../../bin/Holmake cleanAll; cd .. ; \
               cd lambda;  ../../bin/Holmake cleanAll; cd ..)

/bin/rm bin/*
/bin/rm std.prelude
/bin/rm tools/build.sml tools/Holmake/*.{uo,ui} tools/hol98-mode.el
/bin/rm tools/Holmake/{Holmake,Parser,Lexer}.sml tools/Holmake/Parser.sig
<<<<<<< releasing-hol
(cd src/muddy/muddyC/buddy17/src; make clean ; rm -f libbdd.a)
=======
(cd src/muddy/muddyC ; /bin/rm -f *.o *.a *.so ; cd buddy17/src ; \
 /bin/rm -f *.o *.a *.so)
>>>>>>> 1.8
mv ../bin-README bin/README
mv ../sigobj-README sigobj/README

cd /tmp
echo "Creating tar file"
tar cvzf $name.tar.gz hol98
mv hol98/doc/$name.release .
