#!/bin/sh
#
# This script works for SunOS
#
TIME="`date +%H%M`"
DATE="`date +%d%h%y`"
#
# Get rid of blanks in the date
TAGVAL="distrib_${TIME}_${DATE}"
CURDIR="`pwd`"
#
# Get rid of space when day of the month is a single digit
ACT_TAG="`echo "$TAGVAL"|sed s/' '//g`"
rm -rf Zoltan ParMETIS3_1 siMPI
rm -f zoltan_distrib.tar.gz
cvs checkout -r Zoltan_v3_Release -P Zoltan
cvs checkout -P ParMETIS3_1
#cvs checkout -P siMPI
#Get siMPI directly from Pat Miller's sourceforge. miller2007
cvs -z3 -d:ext:knogard@pympi.cvs.sourceforge.net:/cvsroot/pympi co -P -d siMPI pyMPI/siMPI
find . -name 'CVS' -exec rm -rf {} \;
find . -name '*.sh' -exec rm -f {} \;
find . -name '.cvsignore' -exec rm -f {} \;
#
#
# Remove stuff we don't want to share.
cd Zoltan; /bin/rm -rf docs/internal; cd ..
cd Zoltan; /bin/rm -rf test/nem*; cd ..
cd Zoltan; /bin/rm -rf test/th; cd ..
cd ParMETIS3_1; /bin/rm -rf Graphs; cd ..
#
# Build zoltan script.
cd Zoltan; /bin/rm -f docs/Zoltan_html/lgpl.pl; gmake ZOLTAN_ARCH=zscript zscript; cd ..
#
# Move include files to correct locations.
cd Zoltan; /bin/mv Utilities/Memory/zoltan_mem.h include; cd ..
cd Zoltan; /bin/mv Utilities/Communication/zoltan_comm.h include; cd ..
cd Zoltan; /bin/mv Utilities/DDirectory/zoltan_dd.h include; cd ..
cd Zoltan; /bin/mv Utilities/Timer/zoltan_timer.h include; cd ..
cd Zoltan; /bin/mv Utilities/Communication/zoltan_comm_cpp.h include; cd ..
cd Zoltan; /bin/mv Utilities/DDirectory/zoltan_dd_cpp.h include; cd ..
cd Zoltan; /bin/mv Utilities/Timer/zoltan_timer_cpp.h include; cd ..
#
# Remove $ from Revision so that other people don't change Revision when
# checking Zoltan into their own CVS repositories.
rm -rf tmp
FLIST="`find Zoltan -name '*.[ch]' -print`"
for i in ${FLIST}  ; do \
  echo $i
  sed -e 's/\$Revision/Revision/' $i > tmp; \
  /bin/mv tmp $i; \
done;
FLIST="`find Zoltan -name '*.f??' -print`"
for i in ${FLIST}  ; do \
  echo $i
  sed -e 's/\$Revision/Revision/' $i > tmp; \
  /bin/mv tmp $i; \
done;
FLIST="`find Zoltan -name '[mM]akefile*' -print`"
for i in ${FLIST}  ; do \
  echo $i
  sed -e 's/\$Revision/Revision/' $i > tmp; \
  /bin/mv tmp $i; \
done;
FLIST="`find Zoltan -name 'Config*' -print`"
for i in ${FLIST}  ; do \
  echo $i
  sed -e 's/\$Revision/Revision/' $i > tmp; \
  /bin/mv tmp $i; \
done;
#
# Build tarball.
chmod -R ogu+r *
tar cvf zoltan_distrib.tar Zoltan ParMETIS3_1 siMPI
gzip zoltan_distrib.tar
#
# Tag repository.
cvs rtag -r Zoltan_v3_Release ${ACT_TAG} Zoltan 
cvs rtag ${ACT_TAG} ParMETIS3_1
#cvs rtag ${ACT_TAG} siMPI
#Tag Pat Miller's cvs repository on sourceforge miller2007
cvs -d:ext:knogard@pympi.cvs.sourceforge.net:/cvsroot/pympi rtag ${ACT_TAG} pyMPI/siMPI
exit 0
