#!/bin/sh
#-----------------------------------------------------------------------
#
# VISIT-BUILD-OPEN - Build the visit distributions on the open network.
#
# Author: Eric Brugger
# Date:   October 27, 2000
#
# Usage:
#    visit-build-open -d <distribution>
#
# Modifications:
#   Brad Whitlock, Fri Dec 15 09:51:55 PDT 2006
#   Added --enable-visitmodule for some platforms.
#
#   Hank Childs, Mon Oct 15 09:04:12 PDT 2007
#   Add some print statements for usability.  Also make sure that 
#   /usr/bin/X11 is in the path for yana and prism.  If you are a ksh
#   user, your environment will not get sourced and xmkmf will not be
#   found, leading configure to not find the right X libraries, which 
#   will lead to a compile error.
#
#   Hank Childs, Wed Oct 17 14:28:48 PDT 2007
#   Add support for ksh users on sunspot.  (Default environment
#   inherited by "sh" is not enough to do a compile.)
#
#   Hank Childs, Wed Oct 17 16:25:14 PDT 2007
#   Add a subject line to the status e-mails.  Also workaround problem
#   with quad mailing out.
#
#   Hank Childs, Mon Oct 22 09:25:47 PDT 2007
#   More ksh sunspot fixes.
#
#   Hank Childs, Sat Feb  9 14:18:54 PST 2008
#   Change clearcase_bin to svn_bin.
#
#   Brad Whitlock, Fri Oct 10 15:25:27 PST 2008
#   Added --enable-slivr to some of the Linux targets.
#
#   Brad Whitlock, Tue Dec  2 13:49:50 PST 2008
#   Add --prefix for Linux targets so we can use -rpath for the engine
#   wrapper library. I commented out sunspot since Qt4 does not build
#   there.
#
#   Brad Whitlock, Fri May 14 10:23:41 PDT 2010
#   I removed double builds and made the the packages always include
#   the 3rd party libs since the size difference isn't worth the
#   extra build time IMHO.
#
#   Cyrus Harrison, Thu Oct 14 09:59:13 PDT 2010
#   Added cyrush@llnl.gov to the email list & fixed problem with
#   creating proper config-site.cmake on alastor.
#
#   Eric Brugger, Fri Nov  5 15:21:42 PDT 2010
#   I replaced yana with aztec.
#
#   Eric Brugger, Fri Nov  5 16:06:28 PDT 2010
#   I removed up.
#
#   Cyrus Harrison, Tue Jan 11 11:42:58 PST 2011
#   Pass types on command line for cmake vars:
#      CMAKE_BUILD_TYPE & VISIT_THIRD_PARTY_INSTALL
#
#   Eric Brugger, Mon May 16 14:51:39 PDT 2011
#   I added glory and redsky.
#
#   Eric Brugger, Fri Jun 10 13:24:20 PDT 2011
#   I added -DVISIT_INSTALL_THIRD_PARTY:BOOL=ON to the cmake command
#   for ellipse.
#
#   Eric Brugger, Fri Aug  5 09:48:13 PDT 2011
#   I added kickit.
#
#   Eric Brugger, Tue Sep  6 13:58:32 PDT 2011
#   I added rzzeus.
#
#   Eric Brugger, Mon Jan 23 11:59:40 PST 2012
#   I added sidious.
#
#   Eric Brugger, Wed Feb 29 12:15:34 PST 2012
#   I added ubuntu1104_64.
#
#   Eric Brugger, Thu Mar  1 07:57:45 PST 2012
#   I modified the builds on hoth and sidious to use the serial config
#   site files.
#
#   Eric Brugger, Wed May  2 08:45:05 PDT 2012
#   I removed ellipse and xchem.  I modified hoth since it is now an x86_64
#   rhel6 system instead of an x86 rhel3 system.  I updated the e-mail
#   addresses.
#
#   Eric Brugger, Wed Jun 13 08:38:15 PDT 2012
#   I added atlas and rzthriller.
#
#   Eric Brugger, Thu Jun 21 16:17:04 PDT 2012
#   I modified many of the builds to use cmake 2.8.8.
#
#   Eric Brugger, Wed Jun 27 11:40:14 PDT 2012
#   I deleted alastor.
#
#   Eric Brugger, Mon Jul 30 10:13:05 PDT 2012
#   I replaced atlas with prism.
#
#   Eric Brugger, Wed Sep 26 17:09:04 PDT 2012
#   I deleted prism.
#
#   Eric Brugger, Wed Nov 14 09:15:07 PST 2012
#   I deleted hoth.
#
#   Eric Brugger, Wed Nov 14 14:22:16 PST 2012
#   I made the sidious build off by default. I modified the kickit build
#   since it is now a linux-x86_64 system instead of a linux-intel system.
#
#   Eric Brugger, Wed Nov 14 15:53:56 PST 2012
#   I modified the carver build to point to the new cmake.
#
#   Eric Brugger, Wed Nov 28 08:38:09 PST 2012
#   I modified the ubuntu1104_64 build to point to the new cmake.
#
#   Brad Whitlock, Fri May 31 10:21:17 PDT 2013
#   Replace "carver" with "carver". Add build for rzuseq.
#
#   Eric Brugger, Tue Oct 22 11:05:47 PDT 2013
#   I removed rzthriller. I modified many of the builds to use cmake
#   2.8.10.2.
#
#   Eric Brugger, Fri Aug 29 09:51:18 PDT 2014
#   I modified the cmake execute line to build the paraDIS reader to
#   several of the LLNL builds.
#
#   Eric Brugger, Wed Dec 10 13:26:12 PST 2014
#   I added ubuntu1404_64.
#
#   Eric Brugger, Thu Feb 19 09:05:16 PST 2015
#   I removed redsky. I modified many of the builds to use cmake 3.0.2.
#
#   Kathleen Biagas, Thu May  7 09:33:43 PDT 2015
#   Added build for vulcan (copied from rzuseq).
#
#   Eric Brugger, Fri Sep 25 09:04:35 PDT 2015
#   I removed sidious.
#
#   Eric Brugger, Tue Nov 22 16:07:04 PST 2016
#   I added quartz.
#
#   Eric Brugger, Mon Jan  9 13:46:38 PST 2017
#   I replaced aztec with surface.
#
#   Eric Brugger, Tue Feb  7 08:58:27 PST 2017
#   I added rztrona.
#
#   Eric Brugger, Wed Jun 21 10:11:10 PDT 2017
#   I replaced surface with cab.
#
#   Eric Brugger, Fri Sep 22 11:32:57 PDT 2017
#   I replaced rzzeus with rzalastor.
#
#   Eric Brugger, Tue Apr  3 08:50:33 PDT 2018
#   I deleted ubuntu1104_64 and added ifyou (Fedora Core 27).
#
#   Eric Brugger, Wed Oct 17 16:55:41 PDT 2018
#   I deleted cab.
#
#   Eric Brugger, Fri Nov 30 09:56:06 PST 2018
#   I added lassen.
#
#   Eric Brugger, Fri Dec 14 11:50:07 PST 2018
#   I updated quartz for 3.0.0b.
#
#   Eric Brugger, Mon Feb 25 12:30:13 PST 2019
#   I updated rztrona for 3.0.0b and removed rzalastor.
#
#   Eric Brugger, Mon Mar  4 08:19:03 PST 2019
#   I added cooley.
#
#   Eric Brugger, Tue Mar  5 11:19:39 PST 2019
#   I added rzansel. I removed carver and glory.
#
#   Eric Brugger, Wed May  1 09:36:56 PDT 2019
#   I updated the 3.0.0b cmake paths to 3.0.0.
#
#   Eric Brugger, Thu Sep 26 17:35:20 PDT 2019
#   I removed ifyou and ubuntu1404_64.
#
#   Eric Brugger, Fri Dec 13 14:04:47 PST 2019
#   I updated the 3.0.0 cmake paths to 3.1.0 and added a "make manuals"
#   step to build the sphinx manuals.
#
#   Eric Brugger, Mon Jan 13 15:28:16 PST 2020
#   I removed rzuseq, vulcan.
#
#   Eric Brugger, Tue Feb 11 08:23:59 PST 2020
#   I modified the kickit builds to do one build against the system
#   OpenGL and the second against MesaGL.
#
#-----------------------------------------------------------------------

test=no

user=`whoami`

#
# Set the user e-mail address.
#
emailName=brugger1@llnl.gov
case $user in
   biagas2)
      emailName=biagas2@llnl.gov
      ;; 
   kbonnell)
      emailName=biagas2@llnl.gov
      ;; 
   brugger1)
      emailName=brugger1@llnl.gov
      ;;
   brugger)
      emailName=brugger1@llnl.gov
      ;;
   harrison37)
      emailName=cyrush@llnl.gov
      ;;
   cyrush)
      emailName=cyrush@llnl.gov
      ;;
   mcmiller)
      emailName=miller86@llnl.gov
      ;;
   miller)
      emailName=miller86@llnl.gov
      ;;
esac

#
# Parse the execute line, providing default values for error checking.
#
kickit=true
quartz=true
lassen=true
rztrona=true
rzansel=true
cooley=true

dist=undefined

#
# The loop is executed once for each symbol on the execute line.  This means
# that $1 may be blank for later executions of the loop if any "shift 2"
# commands are executed.  The variable abc is not used in the loop.  
#
for abc
do
   case $1 in
      -none)
         kickit=false
         quartz=false
         lassen=false
         rztrona=false
         rzansel=false
         cooley=false
         shift
         ;;
      -kickit)
         kickit=false
         shift
         ;;
      +kickit)
         kickit=true
         shift
         ;;
      -quartz)
         quartz=false
         shift
         ;;
      +quartz)
         quartz=true
         shift
         ;;
      -lassen)
         lassen=false
         shift
         ;;
      +lassen)
         lassen=true
         shift
         ;;
      -rztrona)
         rztrona=false
         shift
         ;;
      +rztrona)
         rztrona=true
         shift
         ;;
      -rzansel)
         rzansel=false
         shift
         ;;
      +rzansel)
         rzansel=true
         shift
         ;;
      -cooley)
         cooley=false
         shift
         ;;
      +cooley)
         cooley=true
         shift
         ;;
      -d)
         dist=$2
         shift 2
         ;;
   esac
done

#
# Check that the distribution name was provided.
#
if [ $dist = undefined ]
then
   echo "Usage: [-none] [-<machine name>] -d <distribution>"
   echo "Valid machine names:"
   echo "    kickit (B-Div, Linux, x86_64),"
   echo "    quartz (LC, Linux, x86_64),"
   echo "    lassen (LC, Linux, power9),"
   echo "    rztrona (LC, Linux, x86_64),"
   echo "    rzansel (LC, Linux, power9),"
   echo "    rzuesq (LC, Linux, ppc64-BG/Q),"
   exit
fi

#
# Check that the distribution exists.
#
distfile=$dist.tar.gz
if [ ! -f $distfile ]
then
   echo "Distribution file doesn't exist."
   exit
fi

#
# Build on kickit.
#
rm -f kickit
cat <<EOF > kickit
#!/bin/sh
if test ! -e /home/$user/kickit ; then
   mkdir /home/$user/kickit
fi
rm -rf /home/$user/kickit/visitbuild
mkdir /home/$user/kickit/visitbuild
mv kickit_$dist.tar.gz /home/$user/kickit/visitbuild/$dist.tar.gz
cd /home/$user/kickit/visitbuild
gunzip -c $dist.tar.gz | tar xvf - > buildlog 2>&1
cd $dist/src
ver=\`cat VERSION\`
ver2=\`echo \$ver | tr "." "_"\`
/usr/gapps/visit/thirdparty_shared/3.1.1/opengl/cmake/3.9.3/linux-x86_64_gcc-4.8/bin/cmake . -DCMAKE_BUILD_TYPE:STRING=Release -DVISIT_INSTALL_THIRD_PARTY:BOOL=ON -DVISIT_ENABLE_XDB:BOOL=ON -DVISIT_PARADIS:BOOL=ON >> ../../buildlog 2>&1
make manuals >> ../../buildlog 2>&1
make -j 4 package >> ../../buildlog 2>&1
mv visit\$ver2.linux-x86_64.tar.gz ../..
cd ../..
rm -f resultlog
echo "        build of visit on kickit"       > resultlog 2>&1
echo "       --------------------------"      >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
ls -l                                         >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "number of database plugins = "\`ls $dist/src/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls $dist/src/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls $dist/src/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "The database plugins:"                  >> resultlog 2>&1
ls $dist/src/plugins/databases/libI* | sed "s/$dist\/src\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
rm -rf $dist
gunzip -c $dist.tar.gz | tar xvf - >> buildlog 2>&1
cd $dist/src
/usr/gapps/visit/thirdparty_shared/3.1.1/mesagl/cmake/3.9.3/linux-x86_64_gcc-4.8/bin/cmake . -DCMAKE_BUILD_TYPE:STRING=Release -DVISIT_INSTALL_THIRD_PARTY:BOOL=ON -DVISIT_ENABLE_XDB:BOOL=ON -DVISIT_PARADIS:BOOL=ON -DVISIT_CONFIG_SITE="config-site/kickit.mesagl.cmake" >> ../../buildlog 2>&1
make manuals >> ../../buildlog 2>&1
make -j 4 package >> ../../buildlog 2>&1
mv visit\$ver2.linux-x86_64.tar.gz ../../visit\$ver2.linux-x86_64-wmesa.tar.gz
cd ../..
echo ""                                       >> resultlog 2>&1
echo "        build of visit on kickit"       >> resultlog 2>&1
echo "       --------------------------"      >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
ls -l                                         >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "number of database plugins = "\`ls $dist/src/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls $dist/src/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls $dist/src/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "The database plugins:"                  >> resultlog 2>&1
ls $dist/src/plugins/databases/libI* | sed "s/$dist\/src\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
EOF

if [ $kickit = true ]
then
   if [ $test = no ]
   then
      echo "Building on kickit"
      scp kickit kickit:kickit_buildit
      scp $dist.tar.gz kickit:kickit_$dist.tar.gz
      ssh kickit "chmod 750 kickit_buildit;./kickit_buildit" &
   fi
fi

#
# Build on quartz.
#
rm -f quartz
cat <<EOF > quartz
#!/bin/sh
XLOCALEDIR=/usr/lib/X11/locale
PATH=/usr/bin/X11:\$PATH
if test ! -d /usr/tmp/$user ; then
   mkdir /usr/tmp/$user
fi
if test ! -d /usr/tmp/$user/quartz ; then
   mkdir /usr/tmp/$user/quartz
fi
rm -rf /usr/tmp/$user/quartz/visitbuild
mkdir /usr/tmp/$user/quartz/visitbuild
mv quartz_$dist.tar.gz /usr/tmp/$user/quartz/visitbuild/$dist.tar.gz
cd /usr/tmp/$user/quartz/visitbuild
gunzip -c $dist.tar.gz | tar xvf - > buildlog 2>&1
cd $dist/src
ver=\`cat VERSION\`
ver2=\`echo \$ver | tr "." "_"\`
/usr/workspace/wsa/visit/visit/thirdparty_shared/3.1.0/toss3/cmake/3.9.3/linux-x86_64_gcc-4.9/bin/cmake . -DCMAKE_BUILD_TYPE:STRING=Release -DVISIT_INSTALL_THIRD_PARTY:BOOL=ON -DVISIT_PARADIS:BOOL=ON >> ../../buildlog 2>&1
make manuals >> ../../buildlog 2>&1
make -j 12 package >> ../../buildlog 2>&1
mv visit\$ver2.linux-x86_64.tar.gz ../..
cd ../..
rm -f resultlog
echo "        build of visit on quartz"       > resultlog 2>&1
echo "       --------------------------"      >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
ls -l                                         >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "number of database plugins = "\`ls $dist/src/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls $dist/src/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls $dist/src/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "The database plugins:"                  >> resultlog 2>&1
ls $dist/src/plugins/databases/libI* | sed "s/$dist\/src\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
EOF

if [ $quartz = true ]
then
   if [ $test = no ]
   then
      echo "Building on quartz"
      scp quartz quartz386:quartz_buildit
      scp $dist.tar.gz quartz386:quartz_$dist.tar.gz
      ssh quartz386 "chmod 750 quartz_buildit;./quartz_buildit" &
   fi
fi

#
# Build on lassen.
#
rm -f lassen
cat <<EOF > lassen
#!/bin/sh
if test ! -d /usr/tmp/$user ; then
   mkdir /usr/tmp/$user
fi
if test ! -d /usr/tmp/$user/lassen ; then
   mkdir /usr/tmp/$user/lassen
fi
rm -rf /usr/tmp/$user/lassen/visitbuild
mkdir /usr/tmp/$user/lassen/visitbuild
mv lassen_$dist.tar.gz /usr/tmp/$user/lassen/visitbuild/$dist.tar.gz
cd /usr/tmp/$user/lassen/visitbuild
gunzip -c $dist.tar.gz | tar xvf - > buildlog 2>&1
cd $dist/src
ver=\`cat VERSION\`
ver2=\`echo \$ver | tr "." "_"\`
/usr/workspace/wsa/visit/visit/thirdparty_shared/3.1.0/blueos/cmake/3.9.3/linux-ppc64le_gcc-4.9/bin/cmake . -DCMAKE_BUILD_TYPE:STRING=Release -DVISIT_INSTALL_THIRD_PARTY:BOOL=ON >> ../../buildlog 2>&1
make manuals >> ../../buildlog 2>&1
make -j 6 package >> ../../buildlog 2>&1
mv visit\$ver2.linux-intel.tar.gz ../..
cd ../..
rm -f resultlog
echo "        build of visit on lassen"       > resultlog 2>&1
echo "       -------------------------- "     >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
ls -l                                         >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "number of database plugins = "\`ls $dist/src/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls $dist/src/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls $dist/src/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "The database plugins:"                  >> resultlog 2>&1
ls $dist/src/plugins/databases/libI* | sed "s/$dist\/src\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
EOF

if [ $lassen = true ]
then
   if [ $test = no ]
   then
      echo "Building on lassen"
      scp lassen lassen708:lassen_buildit
      scp $dist.tar.gz lassen708:lassen_$dist.tar.gz
      ssh lassen708 "chmod 750 lassen_buildit;./lassen_buildit" &
   fi
fi

#
# Build on rztrona.
#
rm -f rztrona
cat <<EOF > rztrona
#!/bin/sh
if test ! -d /usr/tmp/$user ; then
   mkdir /usr/tmp/$user
fi
if test ! -d /usr/tmp/$user/rztrona ; then
   mkdir /usr/tmp/$user/rztrona
fi
rm -rf /usr/tmp/$user/rztrona/visitbuild
mkdir /usr/tmp/$user/rztrona/visitbuild
mv rztrona_$dist.tar.gz /usr/tmp/$user/rztrona/visitbuild/$dist.tar.gz
cd /usr/tmp/$user/rztrona/visitbuild
gunzip -c $dist.tar.gz | tar xvf - > buildlog 2>&1
cd $dist/src
ver=\`cat VERSION\`
ver2=\`echo \$ver | tr "." "_"\`
export PATH=\$PATH:/usr/bin/X11
/usr/workspace/visit/visit/thirdparty_shared/3.1.0/toss3/cmake/3.9.3/linux-x86_64_gcc-4.9/bin/cmake . -DCMAKE_BUILD_TYPE:STRING=Release -DVISIT_INSTALL_THIRD_PARTY:BOOL=ON -DVISIT_PARADIS:BOOL=ON >> ../../buildlog 2>&1
make manuals >> ../../buildlog 2>&1
make -j 12 package >> ../../buildlog 2>&1
mv visit\$ver2.linux-x86_64.tar.gz ../..
cd ../..
rm -f resultlog
echo "        build of visit on rztrona"      > resultlog 2>&1
echo "       ---------------------------"     >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
ls -l                                         >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "number of database plugins = "\`ls $dist/src/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls $dist/src/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls $dist/src/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "The database plugins:"                  >> resultlog 2>&1
ls $dist/src/plugins/databases/libI* | sed "s/$dist\/src\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
mail  -s "VisIt build ($dist): rztrona" $emailName < resultlog
EOF

if [ $rztrona = true ]
then
   if [ $test = no ]
   then
      echo "Building on rztrona"
      scp rztrona rztrona:rztrona_buildit
      scp $dist.tar.gz rztrona:rztrona_$dist.tar.gz
      ssh rztrona5 "chmod 750 rztrona_buildit;./rztrona_buildit" &
   fi
fi

#
# Build on rzansel
#
rm -f rzansel
cat <<EOF > rzansel
#!/bin/sh
if test ! -d /usr/tmp/$user ; then
   mkdir /usr/tmp/$user
fi
if test ! -d /usr/tmp/$user/rzansel ; then
   mkdir /usr/tmp/$user/rzansel
fi
rm -rf /usr/tmp/$user/rzansel/visitbuild
mkdir /usr/tmp/$user/rzansel/visitbuild
mv rzansel_$dist.tar.gz /usr/tmp/$user/rzansel/visitbuild/$dist.tar.gz
cd /usr/tmp/$user/rzansel/visitbuild
gunzip -c $dist.tar.gz | tar xvf - > buildlog 2>&1
cd $dist/src
ver=\`cat VERSION\`
ver2=\`echo \$ver | tr "." "_"\`
export PATH=\$PATH:/usr/bin/X11
/usr/workspace/visit/visit/thirdparty_shared/3.1.0/blueos/cmake/3.9.3/linux-ppc64le_gcc-4.9/bin/cmake . -DCMAKE_BUILD_TYPE:STRING=Release -DVISIT_INSTALL_THIRD_PARTY:BOOL=ON -DVISIT_PARADIS:BOOL=ON >> ../../buildlog 2>&1
make manuals >> ../../buildlog 2>&1
make -j 12 package >> ../../buildlog 2>&1
mv visit\$ver2.linux-intel.tar.gz ../..
cd ../..
rm -f resultlog
echo "        build of visit on rzansel"      > resultlog 2>&1
echo "       ---------------------------"     >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
ls -l                                         >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "number of database plugins = "\`ls $dist/src/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls $dist/src/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls $dist/src/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "The database plugins:"                  >> resultlog 2>&1
ls $dist/src/plugins/databases/libI* | sed "s/$dist\/src\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
mail  -s "VisIt build ($dist): rzansel" $emailName < resultlog
EOF

if [ $rzansel = true ]
then
   if [ $test = no ]
   then
      echo "Building on rzansel"
      scp rzansel rzansel:rzansel_buildit
      scp $dist.tar.gz rzansel:rzansel_$dist.tar.gz
      ssh rzansel61 "chmod 750 rzansel_buildit;./rzansel_buildit" &
   fi
fi

#
# Build on cooley
#
rm -f cooley
cat <<EOF > cooley
#!/bin/sh
if test ! -d /home/ebrugger/cooley; then
   mkdir /home/ebrugger/cooley
fi
rm -rf /home/ebrugger/cooley/visitbuild
mkdir /home/ebrugger/cooley/visitbuild
mv cooley_$dist.tar.gz /home/ebrugger/cooley/visitbuild/$dist.tar.gz
cd /home/ebrugger/cooley/visitbuild
gunzip -c $dist.tar.gz | tar xvf - > buildlog 2>&1
cd $dist/src
ver=\`cat VERSION\`
ver2=\`echo \$ver | tr "." "_"\`
/home/ebrugger/buildvisit/third_party/cmake/3.9.3/linux-rhel_7-x86_64_gcc-4.8/bin/cmake . -DCMAKE_BUILD_TYPE:STRING=Release >> ../../buildlog 2>&1
make manuals >> ../../buildlog 2>&1
make -j 6 package >> ../../buildlog 2>&1
mv visit\$ver2.linux-x86_64.tar.gz ../..
cd ../..
rm -f resultlog
echo "        build of visit on cooley"       > resultlog 2>&1
echo "       --------------------------"      >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
ls -l                                         >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "number of database plugins = "\`ls $dist/src/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls $dist/src/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls $dist/src/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                       >> resultlog 2>&1
echo "The database plugins:"                  >> resultlog 2>&1
ls $dist/src/plugins/databases/libI* | sed "s/$dist\/src\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
mail  -s "VisIt build ($dist): cooley" $emailName < resultlog
EOF

if [ $cooley = true ]
then
   if [ $test = no ]
   then
      echo "Building on cooley"
      cp cooley cooley_buildit
      cp $dist.tar.gz cooley_$dist.tar.gz
      chmod 750 cooley_buildit;./cooley_buildit &
   fi
fi


#
# Clean up.
#
if [ $test = no ]
then
   rm -f kickit quartz lassen rztrona rzansel cooley
fi
