#!/bin/bash
#######################################################################
#
# silo-release-closed - Build and install a tarball on the closed network.
#
# Author: Thomas Treadway
# Date: Fri Dec 14 15:13:23 PST 2007
#
# Usage:
#    silo-release-closed version [host-options]
#
# Modifications:
#    Thomas R. Treadway, Wed Oct  3 13:48:15 PDT 2007
#    Removed gps, added up
#    Added build of silex, and included szip
#
#    Thomas R. Treadway, Fri Nov  2 16:17:59 PDT 2007
#    Tunning for release 4.6
#
#    Thomas R. Treadway, Wed Nov 14 12:54:37 PST 2007
#    Corrected some of the pathc issues.
#
#    Thomas R. Treadway, Thu Dec 27 14:06:40 PST 2007
#    reformatted, added -final, -clean, all-lc, and all-bdiv  options.
#
#######################################################################
#
function usage() {
  printf "Usage: %s version [-lc-username <lc-username>] [-check-install | -no-install | -final | -clean] [-bdiv-username <username>] [-bdiv-host <hostname>] [all|all-lc|all-bdiv|localhost|sunset|purple|uv|gauss|lilac|rhea|bgl]" $0

  printf "\n"
  printf "Build options\n"
  printf "                  -- default, runs make install\n"
  printf -- "-check-install -- runs make check before make install\n"
  printf -- "-no-install    -- runs make only no make install step\n"
  printf -- "-final {host}  -- creates links to silo/current directory\n"
  printf "                  and other convenient symbolic links\n"
  printf -- "-clean {host}  -- removes the build directories\n"
  printf "\n"
  printf "Host select options\n"
  printf "all            -- tries to build on both BDiv, and LC host\n"
  printf "all-lc         -- tries to build on LC host only\n"
  printf "all-bdiv       -- tries to build on both BDiv host only\n"
  printf "{hostopt}      -- host, host list or host option list, such as:\n"
  printf "               localhost, localhostgcc, localhosticc, localhostpgc,\n"  printf "               sunset, sunsetcc, purple, purple32, purple64,\n"
  printf "               purple32gcc, purple64gcc, gauss, gaussgcc, gaussicc,\n"
  printf "               rhea, rheagcc, rheaicc, lilac, lilacgcc, lilacicc,\n"
  printf "               all, all-lc, all-bd, etc.\n"
  printf "{host}         -- host name or host name list, such as:\n"
  printf "               localhost, sunset, purple, uv, gauss, lilac, rhea,\n"
  printf "               all, all-lc, all-bd\n"
  printf "\n"
  printf "Silo release installing script. Assumes a tarball exist in\n"
  printf "current directory, named something like silo-\$1.tar.gz.\n"
  printf "This script will attempt to:\n"
  printf "  1) copy tarball to B Div's /usr/gapps/silo/$VERSION and\n"
  printf "     LC's /usr/gapps/silo/$VERSION.\n"
  printf "  2) untar in /usr/gapps/silo/$VERSION/test.\n"
  printf "  3) start remote scripts on the target machines that\n"
  printf "     perform a configure, make check, followed by a make install\n"
  printf "     into directories /usr/gapps/silo/$VERSION/$ARCH.\n"
  printf "Log files are stored at ./ARCH.log\n"
  printf "You may want to run this script on both the LC and BDiv network.\n"
  printf "Typical usage:\n"
  printf "ssh lilac\n"
  printf "ftp fis\n"
  printf "cd FROM\n"
  printf "get silo-4.6.1.tar.gz\n"
  printf "quit\n"
  printf "tar zxf silo-4.6.1.tar.gz\n"
  printf "cp silo-4.6.1/clearcase_bin/silo-release-closed .\n"
  printf "./silo-release-closed 4.6.1 all-lc\n"
  printf "./silo-release-closed 4.6.1 final all-lc\n"
  printf "./silo-release-closed 4.6.1 clean all-lc\n"
}

function build() {
    ssh ${HOSTS} "/bin/bash" << EOF > ${ARCH}.log 2>&1 &
    $*
    umask 002
    rm -rf $TOPDIR/$VERSION/test/$ARCH
    mkdir $TOPDIR/$VERSION/test/$ARCH
    cd $TOPDIR/$VERSION/test/$ARCH
    unsetenv QTDIR
    ../$TOPSRCDIR/configure \
--prefix=$TOPDIR/$VERSION/$ARCH \
--disable-browser --disable-silex --without-hdf5 --without-szlib $CONFOPTS
    $MAKE $MAKEOPTS
    if [ "$DOCHECK" = "yes" ] ; then
       $MAKE $MAKEOPTS check && $MAKE $MAKEOPTS install
    elif [ "$DOINSTALL" = "yes" ] ; then
       $MAKE $MAKEOPTS install
    fi
    $MAKE $MAKEOPTS clean
    chmod -R g+w $TOPDIR/$VERSION/$ARCH
    unsetenv QTDIR
    ../$TOPSRCDIR/configure \
--prefix=$TOPDIR/$VERSION/$ARCH $CONFOPTS
    $MAKE $MAKEOPTS
    if [ "$DOCHECK" = "yes" ] ; then
       $MAKE $MAKEOPTS check && $MAKE $MAKEOPTS install
    elif [ "$DOINSTALL" = "yes" ] ; then
       $MAKE $MAKEOPTS install
    fi
    chmod -R a+rX,ug+w $TOPDIR/$VERSION/test/$ARCH
    chgrp -R visit $TOPDIR/$VERSION/test/$ARCH
    chmod -R a+rX,ug+w $TOPDIR/$VERSION/$ARCH
    chgrp -R visit $TOPDIR/$VERSION/$ARCH
EOF
}
function build2() {
    ssh ${HOSTS} "/bin/bash" << EOF > ${ARCH}.log 2>&1 &
    $*
    umask 002
    rm -rf $TOPDIR/$VERSION/test/$ARCH
    mkdir $TOPDIR/$VERSION/test/$ARCH
    cd $TOPDIR/$VERSION/test/$ARCH
    unsetenv QTDIR
    ../$TOPSRCDIR/configure \
--prefix=$TOPDIR/$VERSION/$ARCH \
--disable-browser --disable-silex --without-hdf5 --without-szlib $CONFOPTS
    $MAKE $MAKEOPTS
    if [ "$DOCHECK" = "yes" ] ; then
       $MAKE $MAKEOPTS check && $MAKE $MAKEOPTS install
    elif [ "$DOINSTALL" = "yes" ] ; then
       $MAKE $MAKEOPTS install
    fi
    $MAKE $MAKEOPTS clean
    chmod -R g+w $TOPDIR/$VERSION/$ARCH
    unsetenv QTDIR
    ../$TOPSRCDIR/configure \
--prefix=$TOPDIR/$VERSION/$ARCH $CONFOPTS2
    $MAKE $MAKEOPTS
    if [ "$DOCHECK" = "yes" ] ; then
       $MAKE $MAKEOPTS check && $MAKE $MAKEOPTS install
    elif [ "$DOINSTALL" = "yes" ] ; then
       $MAKE $MAKEOPTS install
    fi
    chmod -R a+rX,ug+w $TOPDIR/$VERSION/test/$ARCH
    chgrp -R visit $TOPDIR/$VERSION/test/$ARCH
    chmod -R a+rX,ug+w $TOPDIR/$VERSION/$ARCH
    chgrp -R visit $TOPDIR/$VERSION/$ARCH
EOF
}

function localhost() {
  localhostgcc
#  localhostpgc - fails to find include file float.h during compile
#  localhosticc - fails to find libstdc++_shared during configure
}
function localhostfinal() {
    ssh ${bdun}@${bdhost} "/bin/bash" << EOF >> linux_rhel3-gcc-3.2.3.log 2>&1
    umask 002
    cd $TOPDIR/$VERSION/test/linux_rhel3-gcc-3.2.3
    for FILE in $BININSTALLS
    do if [[ -e /misc/gapps/Linux/bin/\$FILE ]] ; then
          rm -f /misc/gapps/Linux/bin/\$FILE
       fi
    done
    PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/atria/bin:\
/usr/lib/jre/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/apps/bin:/usr/security/bin
    LD_LIBRARY_PATH=/usr/lib:/lib
    export PATH LD_LIBRARY_PATH
    gmake bindir=/misc/gapps/Linux/bin install-exec
    for FILE in $BININSTALLS
    do chmod a+rX,ug+w /misc/gapps/Linux/bin/\$FILE
       chgrp visit /misc/gapps/Linux/bin/\$FILE
    done
    for ARCHDIR in "linux_rhel3-gcc-3.2.3" "linux_rhel3-pgc-4.0" \
        "linux_rhel3-icc-8.1"
    do
       if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview ]] ; then
          rm -f $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
       fi
       ln -s $TOPDIR/hdfview/linux/hdfview \
          $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
       chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
    done
    for ARCHDIR in "linux_rhel3-pgc-4.0" "linux_rhel3-icc-8.1"
    do
       if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/silex ]] ; then
          rm -f $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
       fi
       ln -s $TOPDIR/$VERSION/linux_rhel3-gcc-3.2.3/bin/silex \
          $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
       chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
    done
EOF
}
function localhostclean() {
    ssh ${bdun}@${bdhost} "/bin/bash" << EOF >> linux_rhel3-gcc-3.2.3.log 2>&1
    for ARCHDIR in "linux_rhel3-gcc-3.2.3" "linux_rhel3-pgc-4.0" \
        "linux_rhel3-icc-8.1"
    do if [[ -d $TOPDIR/$VERSION/test/\$ARCHDIR ]] ; then
          rm -rf $TOPDIR/$VERSION/test/\$ARCHDIR
       fi
    done
EOF
}

function localhostgcc() {
    HOSTS="${bdun}@${bdhost}"
    ARCH="linux_rhel3-gcc-3.2.3"
    CONFOPTS="FC=g77 F77=g77 \
    FFLAGS=-Wno-globals F77FLAGS=-Wno-globals FCFLAGS=-Wno-globals LDFLAGS=-L/usr/X11R6/lib"
    export HOSTS ARCH CONFOPTS
    build \
    "PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/atria/bin:\
/usr/lib/jre/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/apps/bin:\
/usr/security/bin" \
    "LD_LIBRARY_PATH=/usr/lib:/lib" \
    "export PATH LD_LIBRARY_PATH"
}
function localhostpgc() {
    HOSTS="${bdun}@${bdhost}"
    ARCH="linux_rhel3-pgc-4.0"
    CONFOPTS="CC=pgcc CXX=pgCC FC=pgf77 --disable-silex"
    export HOSTS ARCH CONFOPTS
    build \
    "PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/atria/bin:\
/sbin:/usr/sbin:/opt/bin:/usr/local/apps/bin:/usr/local/pgi/linux86/bin" \
    "LD_LIBRARY_PATH=/usr/lib:/lib:/usr/local/pgi/linux86/lib" \
    "LM_LICENSE_FILE=/usr/local/flexlm/licenses/license.dat:\
7128@helios.llnl.gov:7127@helios.llnl.gov" \
    "export PATH LD_LIBRARY_PATH LM_LICENSE_FILE"
}
function localhosticc() {
    HOSTS="${bdun}@${bdhost}"
    ARCH="linux_rhel3-icc-8.1"
    CONFOPTS="CC=icc CXX=icpc FC=ifort LDFLAGS=-lstdc++ --disable-silex"
    export HOSTS ARCH CONFOPTS
    build \
    "PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/atria/bin:\
/usr/lib/jre/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/apps/bin:\
/usr/local/pgi/linux86/6.0/bin:/usr/security/bin:\
/usr/local/intel/compiler81/bin" \
    "LD_LIBRARY_PATH=/usr/lib:/lib:/usr/local/intel/compiler81/lib" \
    "INTEL_LICENSE_FILE=7127@helios.llnl.gov" \
    "LM_LICENSE_FILE=/usr/local/flexlm/licenses/license.dat:\
7128@helios.llnl.gov:7127@helios.llnl.gov" \
    "export PATH LD_LIBRARY_PATH INTEL_LICENSE_FILE LM_LICENSE_FILE"
}

function sunset() {
  sunsetgcc
  sunsetcc
}
function sunsetfinal() {
    ssh sunset "/bin/bash" << EOF >> sunos_57.log 2>&1
    umask 002
    cd $TOPDIR/$VERSION/test/sunos_57
    for FILE in $BININSTALLS
    do if [[ -e /misc/gapps/SunOS/bin/\$FILE ]] ; then
          rm -f /misc/gapps/SunOS/bin/\$FILE
       fi
    done
    PATH=/usr/bin:/bin:/usr/local/apps/bin:/usr/local/bin:/usr/ccs/bin:\
/opt/SUNWspro/bin:/usr/ucb:/etc:/usr/openwin/bin:/usr/dt/bin:/usr/java/bin
    LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib
    export PATH LD_LIBRARY_PATH
    gmake bindir=/misc/gapps/SunOS/bin install-exec
    for FILE in $BININSTALLS
    do chmod a+rX,ug+w /misc/gapps/SunOS/bin/\$FILE
       chgrp visit /misc/gapps/SunOS/bin/\$FILE
    done
    ln -s $TOPDIR/$VERSION/sunos_57/bin/silex \
       $TOPDIR/$VERSION/sunos_57-cc-5.2/bin/silex
    chgrp visit $TOPDIR/$VERSION/sunos_57-cc-5.2/bin/silex
EOF
}
function sunsetclean() {
    ssh sunset "/bin/bash" << EOF >> sunos_57.log 2>&1
    for ARCHDIR in "sunos_57" "sunos_57-cc-5.2"
    do rm -rf $TOPDIR/$VERSION/test/\$ARCHDIR
    done
EOF
}
function sunsetgcc() {
    HOSTS="sunset"
    ARCH="sunos_57"
    CONFOPTS="FC=g77 F77=g77 \
    FFLAGS=-Wno-globals F77FLAGS=-Wno-globals FCFLAGS=-Wno-globals"
    MAKE="make"
    export HOSTS ARCH CONFOPTS MAKE
    build \
    "PATH=/usr/bin:/bin:/usr/local/apps/bin:/usr/local/bin:/usr/ccs/bin:\
/opt/SUNWspro/bin:/usr/ucb:/etc:/usr/openwin/bin:/usr/dt/bin:/usr/java/bin" \
    "LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib" \
    "export PATH LD_LIBRARY_PATH"
}
function sunsetcc() {
    HOSTS="sunset"
    ARCH="sunos_57-cc-5.2"
    CONFOPTS="FC=g77 F77=g77 \
    FFLAGS=-Wno-globals F77FLAGS=-Wno-globals FCFLAGS=-Wno-globals"
    CONFOPTS2="CC=cc CXX=CC FC=f77 \
LDFLAGS=-L/usr/local/lib --disable-silex --without-readline \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/sparc-sun-solaris-cc-5.2 \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/sparc-sun-solaris-cc-5.2/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/sparc-sun-solaris-cc-5.2/lib"
    MAKE="make"
    export HOSTS ARCH CONFOPTS CONFOPTS2 MAKE
    build2 \
    "PATH=/usr/bin:/bin:/usr/local/apps/bin:/usr/local/bin:/usr/ccs/bin:\
/opt/SUNWspro/bin:/usr/ucb:/etc:/usr/openwin/bin:/usr/dt/bin:/usr/java/bin" \
    "LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib" \
    "export PATH LD_LIBRARY_PATH"
}

function macosfinal() {
    ssh macos "/bin/bash" << EOF
    cd $TOPDIR/$VERSION/test/i386-apple-darwin8-gcc-4.0.1
    PATH=/bin:/usr/bin:/usr/X11R6/bin:/sbin:/usr/sbin
    export PATH
    make bindir=/misc/gapps/Darwin/bin install-exec
    for FILE in $BININSTALLS
    do chmod a+rX,ug+w /misc/gapps/Darwin/bin/\$FILE
       chgrp visit /misc/gapps/Darwin/bin/\$FILE
    done
    ln -s $TOPDIR/hdfview/MacOSX-i386/hdfview/HDFView.app \
       $TOPDIR/$VERSION/i386-apple-darwin8-gcc-4.0.1/bin/HDFView.app
    chgrp visit $TOPDIR/$VERSION/i386-apple-darwin8-gcc-4.0.1/bin/HDFView.app
EOF
}
function macosclean() {
    ssh macos "/bin/bash" << EOF
    rm -rf $TOPDIR/$VERSION/test/i386-apple-darwin8-gcc-4.0.1
EOF
}
function macos() {
    HOSTS="macos"
    ARCH="i386-apple-darwin8-gcc-4.0.1"
    CONFOPTS="--enable-shared"
    MAKE="make" 
    export HOSTS ARCH CONFOPTS MAKE
    build \
    "PATH=/bin:/usr/bin:/usr/X11R6/bin:/sbin:/usr/sbin" \
    "export PATH"
}

function purple() {
# not using gcc
# use gmake for parallel seems to hang
# 32-bit and 64-bit compiles
  purple64
  purple32
  purplegcc
}
function purplefinal() {
    ssh ${lcun}@purple "/bin/bash" << EOF >> aix_5_64_fed.log 2>&1
    umask 002
    cd $TOPDIR/$VERSION/test/aix_5_64_fed
    for ARCHDIR in "aix_5_64" "aix_5_64_fed" "aix_5_ll"
    do
       for FILE in $BININSTALLS
       do if [[ -e /usr/gapps/bin/\$ARCHDIR/\$FILE ]] ; then
             rm -f /usr/gapps/bin/\$ARCHDIR/\$FILE
          fi
       done
       PATH=/usr/local/bin:/usr/bin:/usr/sbin:/usr/ucb:/usr/local/gnu/bin:\
/usr/local/scripts:/usr/apps/bin:/usr/gapps/bin
       OBJECT_MODE=64
       export PATH OBJECT_MODE
       gmake bindir=/usr/gapps/bin/\$ARCHDIR install-exec
       for FILE in $BININSTALLS
       do
          if [[ -e /usr/gapps/bin/\$ARCHDIR/\$FILE ]] ; then
             chmod a+rX,ug+w /usr/gapps/bin/\$ARCHDIR/\$FILE
             chgrp visit /usr/gapps/bin/\$ARCHDIR/\$FILE
          fi
       done
    done
    for ARCHDIR in "aix_5_ll" "aix_5_64_fed" "aix_5_ll-gcc" "aix_5_64_fed-gcc"
    do
       if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview ]] ; then
          rm -f $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
       fi
       if [[ -d $TOPDIR/$VERSION/\$ARCHDIR/bin ]] ; then
          ln -s $TOPDIR/hdfview/AIX/hdfview \
             $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
          chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
       fi
    done
    for ARCHDIR in "aix_5_ll" "aix_5_ll-gcc" "aix_5_64_fed-gcc"
    do
       if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/silex ]] ; then
          rm -f $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
       fi
       if [[ -d $TOPDIR/$VERSION/\$ARCHDIR/bin ]] ; then
          ln -s $TOPDIR/$VERSION/aix_5_64_fed/bin/silex \
             $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
          chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
       fi
    done
EOF
}
function purpleclean() {
    ssh ${lcun}@purple "/bin/bash" << EOF >> aix_5_64_fed.log 2>&1
    for ARCHDIR in "aix_5_ll" "aix_5_64_fed" "aix_5_ll-gcc" "aix_5_64_fed-gcc" \
        "linux_rhel3-icc-9.1"
    do if [[ -d $TOPDIR/$VERSION/test/\$ARCHDIR ]] ; then
          rm -rf $TOPDIR/$VERSION/test/\$ARCHDIR
       fi
    done
EOF
}
function purple32() {
    HOSTS="${lcun}@purple"
    ARCH="aix_5_ll"
    CONFOPTS="CFLAGS=-q32 LDFLAGS=-q32 AR=\"ar -X32\" --disable-silex"
    CONFOPTS2="CFLAGS=-q32 LDFLAGS=-q32 AR=\"ar -X32\" --disable-silex \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/aix_5_ll \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/aix_5_ll/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/aix_5_ll/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/usr/local/bin:/usr/bin:/usr/sbin:/usr/ucb:/usr/local/gnu/bin:\
/usr/local/scripts:/usr/apps/bin:/usr/gapps/bin" \
    "OBJECT_MODE=32" \
    "export PATH OBJECT_MODE"
}
function purple64() {
    HOSTS="${lcun}@purple"
    ARCH="aix_5_64_fed"
    CONFOPTS="CFLAGS=-q64 LDFLAGS=-q64 AR=\"ar -X64\""
    CONFOPTS2="CFLAGS=-q64 LDFLAGS=-q64 AR=\"ar -X64\" --enable-silex \
--with-Qt-include-dir=/usr/gapps/silo/qt/3.3.8/aix_5_64_fed/include \
--with-Qt-bin-dir=/usr/gapps/silo/qt/3.3.8/aix_5_64_fed/bin \
--with-Qt-lib-dir=/usr/gapps/silo/qt/3.3.8/aix_5_64_fed/lib \
--with-Qt-lib=\"qt-mt -lSM -lICE  -L/usr/X11R6/lib -lX11 -lXext -lXt -lXi\""
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/usr/local/bin:/usr/bin:/usr/sbin:/usr/ucb:/usr/local/gnu/bin:\
/usr/local/scripts:/usr/apps/bin:/usr/gapps/bin" \
    "OBJECT_MODE=64" \
    "export PATH OBJECT_MODE"
}

function purplegcc() {
# use gmake for parallel seems to hang
# 32-bit and 64-bit compiles
  purplegcc32
  purplegcc64
}
function purplegcc32() {
    HOSTS="${lcun}@purple"
    ARCH="aix_5_ll-gcc"
    CONFOPTS="CC=gcc CXX=g++ FC=g77 F77=g77 \
CFLAGS=\"-maix32 -mminimal-toc\" CXXFLAGS=\"-maix32 -mminimal-toc\" \
LDFLAGS=-maix32 AR=\"ar -X32\""
    CONFOPTS2="CC=gcc CXX=g++ FC=g77 F77=g77 \
CFLAGS=\"-maix32 -mminimal-toc\" CXXFLAGS=\"-maix32 -mminimal-toc\" \
LDFLAGS=-maix32 AR=\"ar -X32\" --disable-silex \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/aix_5_ll-gcc \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/aix_5_ll-gcc/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/aix_5_ll-gcc/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/usr/local/bin:/usr/bin:/usr/sbin:/usr/ucb:/usr/local/gnu/bin:\
/usr/local/scripts:/usr/apps/bin:/usr/gapps/bin" \
    "OBJECT_MODE=32" \
    "export PATH OBJECT_MODE"
}
function purplegcc64() {
    HOSTS="${lcun}@purple"
    ARCH="aix_5_64_fed-gcc"
    CONFOPTS="CC=gcc CXX=g++ FC=g77 F77=g77 \
CFLAGS=\"-maix64 -mminimal-toc\" CXXFLAGS=\"-maix64 -mminimal-toc\" \
LDFLAGS=-maix64 AR=\"ar -X64\" \
PYTHON_CPPFLAGS=-I/usr/apps/python64/include/python2.4"
    CONFOPTS2="CC=gcc CXX=g++ FC=g77 F77=g77 \
CFLAGS=\"-maix64 -mminimal-toc\" CXXFLAGS=\"-maix64 -mminimal-toc\" \
LDFLAGS=-maix64 AR=\"ar -X64\" --disable-silex \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/aix_5_64_fed-gcc \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/aix_5_64_fed-gcc/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/aix_5_64_fed-gcc/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/usr/local/bin:/usr/bin:/usr/sbin:/usr/ucb:/usr/local/gnu/bin:\
/usr/local/scripts:/usr/apps/bin:/usr/gapps/bin" \
    "OBJECT_MODE=64" \
    "export PATH OBJECT_MODE"
}

function lilac() {
  lilacgcc
  lilacicc
}

function lilacfinal() {
    ssh ${lcun}@lilac "/bin/bash" << EOF >> chaos_3_x86_elan3.log 2>&1
    umask 002
    cd $TOPDIR/$VERSION/test/chaos_3_x86_elan3
    for FILE in $BININSTALLS
    do if [[ -e /usr/gapps/bin/chaos_3_x86_elan3/\$FILE ]] ; then
          rm -f /usr/gapps/bin/chaos_3_x86_elan3/\$FILE
       fi
    done
    PATH=/usr/local/intel/compiler91/bin:/usr/local/bin:/bin:/usr/bin:\
/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin
    export PATH
    gmake bindir=/usr/gapps/bin/chaos_3_x86_elan3 install-exec
    for FILE in $BININSTALLS
    do
       if [[ -e /usr/gapps/bin/chaos_3_x86_elan3/\$FILE ]] ; then
          chmod a+rX,ug+w /usr/gapps/bin/chaos_3_x86_elan3/\$FILE
          chgrp visit /usr/gapps/bin/chaos_3_x86_elan3/\$FILE
       fi
    done
    for ARCHDIR in "chaos_3_x86_elan3" "chaos_3_x86_elan3-icc"
    do
       if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview ]] ; then
          rm -f $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
       fi
       if [[ -d $TOPDIR/$VERSION/\$ARCHDIR/bin ]] ; then
          ln -s $TOPDIR/hdfview/Linux/hdfview \
             $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
          chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
       fi
    done
    for ARCHDIR in "chaos_3_x86_elan3-icc"
    do
       if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/silex ]] ; then
          rm -f $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
       fi
       if [[ -d $TOPDIR/$VERSION/\$ARCHDIR/bin ]] ; then
          ln -s $TOPDIR/$VERSION/chaos_3_x86_elan3/bin/silex \
             $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
          chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
       fi
    done
EOF
}
function lilacclean() {
    ssh ${lcun}@lilac "/bin/bash" << EOF >> chaos_3_x86_elan3.log 2>&1
    for ARCHDIR in "chaos_3_x86_elan3" "chaos_3_x86_elan3-icc"
    do if [[ -d $TOPDIR/$VERSION/test/\$ARCHDIR ]] ; then
          rm -rf $TOPDIR/$VERSION/test/\$ARCHDIR
       fi
    done
EOF
}

function lilacgcc() {
    HOSTS="${lcun}@lilac"
    ARCH="chaos_3_x86_elan3"
    CONFOPTS="CC=gcc CXX=g++ FC=g77 F77=g77 CFLAGS=-fPIC CXXFLAGS=-fPIC \
        FFLAGS=\"-fno-second-underscore -Wno-globals\" "
    export HOSTS ARCH CONFOPTS
    build \
    "PATH=/usr/local/intel/compiler91/bin:/usr/local/bin:/bin:/usr/bin:\
/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin" \
    "export PATH"
}

function lilacicc() {
    HOSTS="${lcun}@lilac"
    ARCH="chaos_3_x86_elan3-icc"
    CONFOPTS="CC=icc CXX=icc FC=ifort LDFLAGS=-lstdc++ \
CFLAGS=-fPIC CXXFLAGS=-fPIC"
    CONFOPTS2="CC=icc CXX=icc FC=ifort LDFLAGS=-lstdc++ \
CFLAGS=-fPIC CXXFLAGS=-fPIC --disable-silex \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/chaos_3_x86_elan3-icc \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/chaos_3_x86_elan3-icc/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/chaos_3_x86_elan3-icc/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/usr/local/intel/compiler100_025/bin:/usr/local/bin:/bin:\
/usr/bin:/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin" \
    "LD_LIBRARY_PATH=/usr/local/intel/compiler100_025/lib" \
    "INTEL_LICENSE_FILE=${INTEL_LICENSE_FILE}:\
/usr/local/intel/compiler100_025/licenses:/opt/intel/licenses" \
    "export PATH LD_LIBRARY_PATH INTEL_LICENSE_FILE"
}

function gauss() {
  gaussgcc
  gaussicc
}

function gaussfinal() {
    ssh ${lcun}@gauss "/bin/bash" << EOF >> chaos_3_x86_64_ib-gcc.log 2>&1
    umask 002
    cd $TOPDIR/$VERSION/test/chaos_3_x86_64_ib-gcc
#   for FILE in $BININSTALLS
#   do if [[ -e /usr/gapps/bin/chaos_3_x86_elan3/\$FILE ]] ; then
#         rm -f /usr/gapps/bin/chaos_3_x86_elan3/\$FILE
#      fi
#   done
#   gmake bindir=/usr/gapps/bin/chaos_3_x86_elan3 install-exec
#   for FILE in $BININSTALLS
#   do chmod a+rX,ug+w /usr/gapps/bin/chaos_3_x86_elan3/\$FILE
#      chgrp visit /usr/gapps/bin/chaos_3_x86_elan3/\$FILE
#   done
    for ARCHDIR in "chaos_3_x86_64_ib-gcc" "chaos_3_x86_64_ib-icc"
    do
       if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview ]] ; then
          rm -f $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
       fi
       ln -s $TOPDIR/hdfview/Linux64/hdfview \
          $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
       chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
    done
#   for ARCHDIR in "chaos_3_x86_64_ib-icc"
#   do
#      if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/silex ]] ; then
#         rm -f $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
#      fi
#      ln -s $TOPDIR/$VERSION/chaos_3_x86_64_ib-gcc/bin/silex \
#         $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
#      chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
#   done
EOF
}
function gaussclean() {
    ssh ${lcun}@gauss "/bin/bash" << EOF >> chaos_3_x86_64_ib-gcc.log 2>&1
    for ARCHDIR in "chaos_3_x86_64_ib-gcc" "chaos_3_x86_64_ib-icc"
    do if [[ -d $TOPDIR/$VERSION/test/\$ARCHDIR ]] ; then
          rm -rf $TOPDIR/$VERSION/test/\$ARCHDIR
       fi
    done
EOF
}

function gaussgcc() {
    HOSTS="${lcun}@gauss"
    ARCH="chaos_3_x86_64_ib-gcc"
    CONFOPTS="CC=gcc CXX=g++ FC=g77 F77=g77 CFLAGS=-fPIC CXXFLAGS=-fPIC \
FFLAGS=-Wno-globals F77FLAGS=-Wno-globals FCFLAGS=-Wno-globals"
    export HOSTS ARCH CONFOPTS
    build \
    "PATH=/usr/local/bin:/bin:/usr/bin:/usr/bin/X11:/usr/apps/bin:/usr/gapps/bin" \
    "export PATH"
}

function gaussicc() {
    HOSTS="${lcun}@gauss"
    ARCH="chaos_3_x86_64_ib-icc"
    CONFOPTS="CC=icc CXX=icc FC=ifort LDFLAGS=-lstdc++ \
CFLAGS=-fPIC CXXFLAGS=-fPIC"
    CONFOPTS2="CC=icc CXX=icc FC=ifort LDFLAGS=-lstdc++ \
CFLAGS=-fPIC CXXFLAGS=-fPIC --enable-silex \
--with-Qt-dir=/usr/gapps/silo/qt/$QTRELEASE/$ARCH \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/$ARCH \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/$ARCH/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/$ARCH/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/usr/local/intel/compiler100_025/bin:/usr/local/bin:/bin:\
/usr/bin:/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin" \
    "LD_LIBRARY_PATH=/usr/local/intel/compiler100_025/lib" \
    "INTEL_LICENSE_FILE=${INTEL_LICENSE_FILE}:\
/usr/local/intel/compiler100_025/licenses:/opt/intel/licenses" \
    "export PATH LD_LIBRARY_PATH INTEL_LICENSE_FILE"
}

function rhea() {
  rheagcc
  rheaicc
# rheapgc
# rheapsc
}
function rheafinal() {
    ssh ${lcun}@rhea "/bin/bash" << EOF >> chaos_3_x86_64 2>&1
    umask 002
#   cd $TOPDIR/$VERSION/test/chaos_3_x86_64
#   gmake bindir=/usr/gapps/bin/chaos_3_x86_64 install-exec
#   gmake bindir=/usr/gapps/bin/chaos_3_x86_64_elan4 install-exec
#   gmake bindir=/usr/gapps/bin/chaos_3_x86_64_ib install-exec
    for ARCHDIR in "chaos_3_x86_64" "chaos_3_x86_64_elan4" "chaos_3_x86_64_ib"
    do
       for FILE in $BININSTALLS
       do
          if [[ -e /usr/gapps/bin/\$ARCHDIR/\$FILE ]] ; then
             rm -f /usr/gapps/bin/\$ARCHDIR/\$FILE
          fi
          if [[ -d /usr/gapps/bin/\$ARCHDIR ]] ; then
             ln -s $TOPDIR/$VERSION/chaos_3_x86_64/bin/\$FILE \
                /usr/gapps/bin/\$ARCHDIR/\$FILE
             chmod a+rX,ug+w /usr/gapps/bin/\$ARCHDIR/\$FILE
             chgrp visit /usr/gapps/bin/\$ARCHDIR/\$FILE
          fi
       done
       if [[ -e /usr/gapps/bin/\$ARCHDIR/hdfview ]] ; then
          rm -f /usr/gapps/bin/\$ARCHDIR/hdfview
       fi
       if [[ -d /usr/gapps/bin/\$ARCHDIR ]] ; then
          ln -s $TOPDIR/hdfview/linux64amd/hdfview \
             /usr/gapps/bin/\$ARCHDIR/hdfview
          chgrp visit /usr/gapps/bin/\$ARCHDIR/hdfview
       fi
    done
    for ARCHDIR in "chaos_3_x86_64" "chaos_3_x86_64-icc-10.0" \
        "chaos_3_x86_64-pc-2.4" "chaos_3_x86_64-pgc-6.2"
    do
       if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview ]] ; then
          rm -f $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
       fi
       if [[ -d $TOPDIR/$VERSION/\$ARCHDIR/bin ]] ; then
          ln -s $TOPDIR/hdfview/Linux64/hdfview \
             $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
          chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
       fi
    done
    for ARCHDIR in "chaos_3_x86_64-icc-10.0" "chaos_3_x86_64-pc-2.4" \
       "chaos_3_x86_64-pgc-6.2"
    do
       if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/silex ]] ; then
          rm -f $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
       fi 
       if [[ -d $TOPDIR/$VERSION/\$ARCHDIR/bin ]] ; then
          ln -s $TOPDIR/$VERSION/chaos_3_x86_64/bin/silex \
             $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
          chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
       fi
    done
EOF
}
function rheaclean() {
    ssh ${lcun}@rhea "/bin/bash" << EOF >> chaos_3_x86_64 2>&1
    for ARCHDIR in "chaos_3_x86_64" "chaos_3_x86_64-icc-10.0" \
        "chaos_3_x86_64-pc-2.4" "chaos_3_x86_64-pgc-6.2"
    do rm -rf $TOPDIR/$VERSION/test/\$ARCHDIR
    done
EOF
}
function rheagcc() {
    HOSTS="${lcun}@rhea"
    ARCH="chaos_3_x86_64"
    CONFOPTS="CC=gcc CXX=g++ FC=g77 F77=g77 CFLAGS=-fPIC CXXFLAGS=-fPIC \
FFLAGS=-Wno-globals F77FLAGS=-Wno-globals FCFLAGS=-Wno-globals"
    export HOSTS ARCH CONFOPTS
    build \
    "PATH=/usr/local/intel/compiler91/bin:/usr/local/bin:/bin:/usr/bin:\
/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin" \
    "export PATH"
}

function rheaicc() {
    HOSTS="${lcun}@rhea"
    ARCH="chaos_3_x86_64-icc-10.0"
    CONFOPTS="CC=icc CXX=icc FC=ifort F77=ifort LDFLAGS=-lstdc++ \
CFLAGS=-fPIC CXXFLAGS=-fPIC"
    CONFOPTS2="CC=icc CXX=icc FC=ifort F77=ifort LDFLAGS=-lstdc++ \
CFLAGS=-fPIC CXXFLAGS=-fPIC --disable-silex \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/chaos_3_x86_64-icc-10.0 \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/chaos_3_x86_64-icc-10.0/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/chaos_3_x86_64-icc-10.0/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/usr/local/intel/compiler100_025/bin:/usr/local/bin:/bin:/usr/bin:\
/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin:/usr/kerberos/bin" \
    "LD_LIBRARY_PATH=/usr/local/intel/compiler100_025/lib" \
    "INTEL_LICENSE_FILE=${INTEL_LICENSE_FILE}:\
/usr/local/intel/compiler100_025/licenses:/opt/intel/licenses" \
    "export PATH LD_LIBRARY_PATH INTEL_LICENSE_FILE"
}
function rheapsc() {
    HOSTS="${lcun}@rhea"
    ARCH="chaos_3_x86_64-pc-2.4"
    CONFOPTS="CC=pathcc CXX=pathCC FC=pathf90 F77=pathf90 \
CFLAGS=-fPIC CXXFLAGS=-fPIC"
    CONFOPTS2="CC=pathcc CXX=pathCC FC=pathf90 F77=pathf90 \
CFLAGS=-fPIC CXXFLAGS=-fPIC --disable-silex \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/chaos_3_ia64-pc-2.4 \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/chaos_3_ia64-pc-2.4/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/chaos_3_ia64-pc-2.4/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/usr/global/tools/RSI/bin:\
/usr/local/tools/pathscale/pathscale-2.4/bin2:/usr/local/bin:/bin:/usr/bin:\
/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin:/usr/kerberos/bin" \
    "LM_LICENSE_FILE=/usr/local/etc/license.client" \
    "PATHSCALE_SUBSCRIPTION_DAEMON=license1ocf.llnl.gov" \
    "export PATH LM_LICENSE_FILE PATHSCALE_SUBSCRIPTION_DAEMON"
}
function rheapgc() {
    HOSTS="${lcun}@rhea"
    ARCH="chaos_3_x86_64-pgc-6.2"
    CONFOPTS="CC=pgcc CXX=pgCC FC=\"pgf77 -g77libs\" \
CFLAGS=-fPIC CXXFLAGS=-fPIC"
    CONFOPTS2="CC=pgcc CXX=pgCC FC=\"pgf77 -g77libs\" \
CFLAGS=-fPIC CXXFLAGS=-fPIC --disable-silex --disable-silex \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/chaos_3_ia64-pgc-6.2 \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/chaos_3_ia64-pgc-6.2/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/chaos_3_ia64-pgc-6.2/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/usr/global/tools/RSI/bin:\
/usr/local/tools/pgi6.23/linux86-64/6.2/bin:/usr/local/bin:/bin:/usr/bin:\
/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin:/usr/kerberos/bin" \
    "LM_LICENSE_FILE=/usr/local/etc/license.client" \
    "export PATH LM_LICENSE_FILE"
}

function thunder() {
  thundergcc
  thundericc
}
function thunderfinal() {
    ssh ${lcun}@thunder "/bin/bash" << EOF >> chaos_3_ia64-gcc-3.4.4.log 2>&1
    umask 002
    cd $TOPDIR/$VERSION/test/chaos_3_ia64-gcc-3.4.4
    for ARCHDIR in "chaos_3_ia64" "chaos_3_ia64_elan4"
    do
       for FILE in $BININSTALLS
       do if [[ -e /usr/gapps/bin/\$ARCHDIR/\$FILE ]] ; then
             rm -f /usr/gapps/bin/\$ARCHDIR/\$FILE
          fi
       done
       PATH=/usr/local/intel/compiler91/bin:/usr/local/bin:/bin:/usr/bin:\
/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin
       export PATH
       gmake bindir=/usr/gapps/bin/\$ARCHDIR install-exec
       for FILE in $BININSTALLS
       do chmod a+rX,ug+w /usr/gapps/bin/\$ARCHDIR/\$FILE
          chgrp visit /usr/gapps/bin/\$ARCHDIR/\$FILE
       done
    done
#   for ARCHDIR in "chaos_3_ia64-gcc-3.4.4" "chaos_3_ia64-icc"
#   do if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview ]] ; then
#         rm -rf $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
#      fi
#      ln -s $TOPDIR/hdfview/linuxia64/hdfview \
#         $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
#      chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/hdfview
#   done
    for ARCHDIR in "chaos_3_ia64-icc"
    do
       if [[ -e $TOPDIR/$VERSION/\$ARCHDIR/bin/silex ]] ; then
          rm -f $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
       fi
       ln -s $TOPDIR/$VERSION/chaos_3_ia64-gcc-3.4.4/bin/silex \
          $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
       chgrp visit $TOPDIR/$VERSION/\$ARCHDIR/bin/silex
    done
EOF
}
function thunderclean() {
    ssh ${lcun}@thunder "/bin/bash" << EOF >> chaos_3_ia64-gcc-3.4.4.log 2>&1
    for ARCHDIR in "chaos_3_ia64-gcc-3.4.4" "chaos_3_ia64-icc"
    do if [[ -d $TOPDIR/$VERSION/test/\$ARCHDIR ]] ; then
          rm -rf $TOPDIR/$VERSION/test/\$ARCHDIR
       fi
    done
EOF
}
function thundergcc() {
    HOSTS="${lcun}@thunder"
    ARCH="chaos_3_ia64-gcc-3.4.4"
    CONFOPTS="CC=gcc CXX=g++ FC=g77 F77=g77 CFLAGS=-fPIC CXXFLAGS=-fPIC"
    export HOSTS ARCH CONFOPTS
    build \
    "PATH=/usr/local/intel/compiler91/bin:/usr/local/bin:/bin:/usr/bin:\
/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin" \
    "export PATH"
}
function thundericc() {
    HOSTS="${lcun}@thunder"
    ARCH="chaos_3_ia64-icc-10.0"
    CONFOPTS="CC=icc CXX=icc FC=ifort F77=ifort LDFLAGS=-lstdc++ \
CFLAGS=-fPIC CXXFLAGS=-fPIC"
    CONFOPTS2="CC=icc CXX=icc FC=ifort LDFLAGS=-lstdc++ \
CFLAGS=-fPIC CXXFLAGS=-fPIC --enable-silex \
--with-Qt-dir=/usr/gapps/silo/qt/$QTRELEASE/chaos_3_ia64-icc \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/chaos_3_ia64-icc-10.0 \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/chaos_3_ia64-icc-10.0/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/chaos_3_ia64-icc-10.0/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build \
    "PATH=/usr/local/intel/compiler100_025/bin:/usr/local/bin:/bin:/usr/bin:\
/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin" \
    "LD_LIBRARY_PATH=/usr/local/intel/compiler100_025/lib" \
    "INTEL_LICENSE_FILE=${INTEL_LICENSE_FILE}:\
/usr/local/intel/compiler100_025/licenses:/opt/intel/licenses" \
    "export PATH LD_LIBRARY_PATH INTEL_LICENSE_FILE"
}

function quad() {
# not using gcc
# IRIX make doesn't support VPATH
# 32-bit and 64-bit compiles
  quad32
  quad64
}
function quadfinal() {
    ssh ${lcun}@quad "/bin/bash" << EOF >> irix_6.5_n32.log 2>&1
    umask 002
    cd $TOPDIR/$VERSION/test/irix_6.5_n32
    for FILE in $BININSTALLS
    do if [[ -e /usr/gapps/bin/irix_6.5_64/\$FILE ]] ; then
          rm -f /usr/gapps/bin/irix_6.5_64/\$FILE
       fi
    done
    PATH=/usr/sbin:/usr/bsd:/sbin:/usr/bin:/usr/bin/X11:/usr/freeware/bin
    LD_LIBRARY_PATH=/usr/gapps/silo/qt/$QTRELEASE/irix_6.5-gcc-3.3/lib:\
$LD_LIBRARY_PATH
    PARALLEL=4
    export PATH LD_LIBRARY_PATH PARALLEL
    gmake bindir=/usr/gapps/bin/irix_6.5_64 install-exec
    for FILE in $BININSTALLS
    do chmod a+rX,ug+w /usr/gapps/bin/irix_6.5_64/\$FILE
       chgrp visit /usr/gapps/bin/irix_6.5_64/\$FILE
    done
    for FILE in $BININSTALLS
    do ln -s $TOPDIR/$VERSION/irix_6.5_n32/bin/\$FILE \
       $TOPDIR/$VERSION/irix_6.5_64/bin/\$FILE
       chmod a+rX,ug+w $TOPDIR/$VERSION/irix_6.5_64/bin/\$FILE
       chgrp visit $TOPDIR/$VERSION/irix_6.5_64/bin/\$FILE
    done
EOF
}
function quadclean() {
    ssh ${lcun}@quad "/bin/bash" << EOF >> irix_6.5_n32.log 2>&1
    for ARCHDIR in "irix_6.5_n32" "irix_6.5_64"
    do if [[ -d $TOPDIR/$VERSION/test/\$ARCHDIR ]] ; then
          rm -rf $TOPDIR/$VERSION/test/\$ARCHDIR
       fi
    done
EOF
}
function quad32() {
    HOSTS="${lcun}@quad"
    ARCH="irix_6.5_n32"
    CONFOPTS="CC=\"cc -n32\" CXX=\"CC -n32\" FC=\"f77 -n32\" \
LDFLAGS=-n32 CFLAGS=\"-O2 -c99\" \
PYTHON_CPPFLAGS=-I/usr/freeware/include/python2.1"
    CONFOPTS2="CC=\"cc -n32\" CXX=\"CC -n32\" FC=\"f77 -n32\" \
LDFLAGS=-n32 CFLAGS=\"-O2 -c99\" --enable-silex \
--with-Qt-dir=/usr/gapps/silo/qt/$QTRELEASE/irix_6.5-gcc-3.3 \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/irix_6.5_n32 \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/irix_6.5_n32/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/irix_6.5_n32/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/usr/sbin:/usr/bsd:/sbin:/usr/bin:/usr/bin/X11:/usr/freeware/bin" \
    "LD_LIBRARY_PATH=/usr/gapps/silo/qt/$QTRELEASE/irix_6.5-gcc-3.3/lib:\
$LD_LIBRARY_PATH" \
    "PARALLEL=4" \
    "export PATH LD_LIBRARY_PATH PARALLEL"
}
function quad64() {
    HOSTS="${lcun}@quad"
    ARCH="irix_6.5_64"
    CONFOPTS="CC=\"cc -64\" CXX=\"CC -64\" FC=\"f77 -64\" \
LDFLAGS=-64 CFLAGS=\"-O2 -c99\" \
PYTHON_CPPFLAGS=-I/usr/freeware/include/python2.1"
    CONFOPTS2="CC=\"cc -64\" CXX=\"CC -64\" FC=\"f77 -64\" \
LDFLAGS=-64 CFLAGS=\"-O2 -c99\" \
PYTHON_CPPFLAGS=-I/usr/freeware/include/python2.1 \
--disable-silex --disable-browser \
--with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/irix_6.5_n32 \
--with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/irix_6.5_n32/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/irix_6.5_n32/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/usr/sbin:/usr/bsd:/sbin:/usr/bin:/usr/bin/X11:/usr/freeware/bin" \
    "PARALLEL=4" \
    "export PATH PARALLEL"
}

function bgl() {
    HOSTS="${lcun}@bgl"
    ARCH="sles_9_ppc64-blrts_xlc"
    CONFOPTS="CC=/opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlc FC=blrts_xlf \
    CXX=/opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlC \
    ac_cv_type_off64_t=yes ac_cv_sizeof_off64_t=8 \
    CFLAGS=\"-O -qlanglvl=extended -qmaxmem=64000\" \
    CXXFLAGS=\"-O -qlanglvl=extended -qmaxmem=64000\" "
    CONFOPTS2="CC=/opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlc FC=blrts_xlf \
    CXX=/opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlC \
    ac_cv_type_off64_t=yes ac_cv_sizeof_off64_t=8 \
    CFLAGS=\"-O -qlanglvl=extended -qmaxmem=64000\" \
    CXXFLAGS=\"-O -qlanglvl=extended -qmaxmem=64000\" \
    --disable-silex --disable-browser --without-readline \
    --with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/$ARCH \
    --with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/$ARCH/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/$ARCH/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/opt/ibmcmp/vacpp/bg/8.0/bin:/opt/ibmcmp/xlf/bg/10.1/bin:/usr/local/bin:\
/bin:/usr/bin:/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin" \
    "export PATH"
    ARCH="sles_9_ppc64-xlc"
    CONFOPTS="CC=/opt/ibmcmp/vacpp/bg/8.0/bin/xlc FC=xlf \
    CXX=/opt/ibmcmp/vacpp/bg/8.0/bin/xlC \
    ac_cv_type_off64_t=yes ac_cv_sizeof_off64_t=8 \
    CFLAGS=\"-O -qlanglvl=extended -qmaxmem=64000\" \
    CXXFLAGS=\"-O -qlanglvl=extended -qmaxmem=64000\" "
    CONFOPTS2="CC=/opt/ibmcmp/vacpp/bg/8.0/bin/xlc FC=xlf \
    CXX=/opt/ibmcmp/vacpp/bg/8.0/bin/xlC \
    ac_cv_type_off64_t=yes ac_cv_sizeof_off64_t=8 \
    CFLAGS=\"-O -qlanglvl=extended -qmaxmem=64000\" \
    CXXFLAGS=\"-O -qlanglvl=extended -qmaxmem=64000\" \
    --enable-silex --with-Qt-dir=/usr/local/tools/qt/3.3.2-g++ \
    --with-szlib=/usr/gapps/silo/szip/$SZIPRELEASE/$ARCH \
    --with-hdf5=/usr/gapps/silo/hdf5/$HDF5RELEASE/$ARCH/include,\
/usr/gapps/silo/hdf5/$HDF5RELEASE/$ARCH/lib"
    export HOSTS ARCH CONFOPTS CONFOPTS2
    build2 \
    "PATH=/opt/ibmcmp/vacpp/bg/8.0/bin:/opt/ibmcmp/xlf/bg/10.1/bin:/usr/local/bin:\
/bin:/usr/bin:/usr/bin/X11:/usr/lib/mpi/bin:/usr/apps/bin:/usr/gapps/bin" \
    "export PATH"
}

TOPDIR="/usr/gapps/silo"
SZIPRELEASE=2.1
HDF5RELEASE=1.6.6
QTRELEASE=3.3.8
lcun=$USER
bdun=$USER
bdhost="vader"
BININSTALLS="browser silex silock silodiff"
declare -i i
declare -af list
MAKE="gmake"
#MAKEOPTS="-s LIBTOOLFLAGS=--silent"   # low noise
MAKEOPTS="-j 4"
DOINSTALL="yes"
DOCHECK="no"
DOFINAL="no"
DOCLEAN="no"
DOBDIV="no"
DOLC="no"

if (( $# < 1 )) ; then
  usage
  exit 2
fi
umask 002
VERSION=$1
shift
TARFILE="silo-$VERSION.tar.gz"
TOPSRCDIR="silo-$VERSION"

if (( $# < 1 )) ; then
    list=("localhost" "sunset" "purple" "gauss" "lilac" "rhea" "bgl")
    DOBDIV="yes";DOLC="yes"
else
 i=0
 while [[ "$*" != "" ]]
 do
  case $1 in
    all-lc*|-all-lc*|lc-in*|-lc-in*)
      list[i]="purple" ; i=i+1
      list[i]="gauss" ; i=i+1
      list[i]="lilac" ; i=i+1
      list[i]="rhea" ; i=i+1
      list[i]="bgl" ; i=i+1
      DOLC="yes"
      shift;;
    all-bd*|-all-bd*|bd-in*|-bd-in*)
      list[i]="localhost" ; i=i+1
      list[i]="sunset" ; i=i+1
      DOBDIV="yes"
      shift;;
    all|-a*)
      list[i]="localhost" ; i=i+1
      list[i]="sunset" ; i=i+1
      list[i]="purple" ; i=i+1
      list[i]="gauss" ; i=i+1
      list[i]="lilac" ; i=i+1
      list[i]="rhea" ; i=i+1
      list[i]="bgl" ; i=i+1
      DOBDIV="yes";DOLC="yes"
      shift;;
    local*pgc|-local*pgc)
      list[i]="localhostpgc" ; i=i+1
      DOBDIV="yes"
      shift;;
    local*icc|-local*icc)
      list[i]="localhosticc" ; i=i+1
      DOBDIV="yes"
      shift;;
    local*gcc|-local*gcc)
      list[i]="localhostgcc" ; i=i+1
      DOBDIV="yes"
      shift;;
    localhost|-lo*)
      list[i]="localhost" ; i=i+1
      DOBDIV="yes"
      shift;;
    sun*gcc|-sun*gcc)
      list[i]="sunsetgcc" ; i=i+1
      DOBDIV="yes"
      shift;;
    sun*cc|-sun*cc)
      list[i]="sunsetcc" ; i=i+1
      DOBDIV="yes"
      shift;;
    sun*|-sun*)
      list[i]="sunset" ; i=i+1
      DOBDIV="yes"
      shift;;
    purplegcc32|-purple*gcc32)
      list[i]="purplegcc32" ; i=i+1
      DOLC="yes"
      shift;;
    purple32|-purple*32)
      list[i]="purple32" ; i=i+1
      DOLC="yes"
      shift;;
    purplegcc64|-purple*gcc64)
      list[i]="purplegcc64" ; i=i+1
      DOLC="yes"
      shift;;
    purple64|-purple*64)
      list[i]="purple64" ; i=i+1
      DOLC="yes"
      shift;;
    purplegcc|-purplegcc)
      list[i]="purplegcc" ; i=i+1
      DOLC="yes"
      shift;;
    purple|-purple*)
      list[i]="purple" ; i=i+1
      DOLC="yes"
      shift;;
    gaus*icc|-ga*icc)
      list[i]="gaussicc" ; i=i+1
      DOLC="yes"
      shift;;
    gaus*gcc|-ga*gcc)
      list[i]="gaussgcc" ; i=i+1
      DOLC="yes"
      shift;;
    gaus*|-ga*)
      list[i]="gauss" ; i=i+1
      DOLC="yes"
      shift;;
    rhea*pgc|-rh*pgc)
      list[i]="rheapgc" ; i=i+1
      DOLC="yes"
      shift;;
    rhea*psc|-rh*psc)
      list[i]="rheapsc" ; i=i+1
      DOLC="yes"
      shift;;
    rhea*icc|-rh*icc)
      list[i]="rheaicc" ; i=i+1
      DOLC="yes"
      shift;;
    rhea*gcc|-rh*gcc)
      list[i]="rheagcc" ; i=i+1
      DOLC="yes"
      shift;;
    rhea*|-rh*)
      list[i]="rhea" ; i=i+1
      DOLC="yes"
      shift;;
    lil*icc|-li*icc)
      list[i]="lilacicc" ; i=i+1
      DOLC="yes"
      shift;;
    lil*gcc|-li*gcc)
      list[i]="lilacgcc" ; i=i+1
      DOLC="yes"
      shift;;
    lil*|-li*)
      list[i]="lilac" ; i=i+1
      DOLC="yes"
      shift;;
    quad32|-quad32)
      list[i]="quad32" ; i=i+1
      DOLC="yes"
      shift;;
    quad64|-quad64)
      list[i]="quad64" ; i=i+1
      DOLC="yes"
      shift;;
    quad|-quad)
      list[i]="quad" ; i=i+1
      DOLC="yes"
      shift;;
     bgl|-bgl)
       list[i]="bgl" ; i=i+1
       DOLC="yes"
       shift;;
    macos|-macos)
      list[i]="macos" ; i=i+1
      DOBDIV="yes"
      shift;;
    lc-use*|-lc-use*)
      lcun=$2
      shift 2;;
    bdiv-use*|-bdiv-use*)
      bdun=$2
      shift 2;;
    bdiv-ho*|-bdiv-ho*)
      bdhost=$2
      shift 2;;
    check*|-check*)
      DOCHECK="yes"
      shift;;
    no*|-no*)
      DOINSTALL="no"
      shift;;
    fin*|-fin*)
      DOFINAL="yes"
      shift;;
    cle*|-cle*)
      DOCLEAN="yes"
      shift;;
    debug*|-debug*)
      set -vx
      shift;;
    trace*|-trace*)
      set -vx
      shift;;
    *)
      shift;;
  esac
 done
fi
if [[ "$DOFINAL" == "yes" ]] ; then
   if [[ "$DOBDIV" == "yes" ]] ; then
      ssh ${bdun}@${bdhost} "/bin/bash" << EOF
      umask 002
      if [ -d $TOPDIR/current ] ; then
         rm $TOPDIR/current
      fi
      ln -s $TOPDIR/$VERSION $TOPDIR/current
      chgrp visit $TOPDIR/current
      if [ -f $TOPDIR/$VERSION/test/$TOPSRCDIR/docs/Silo.book.pdf ] ; then
         cp $TOPDIR/$VERSION/test/$TOPSRCDIR/docs/Silo.book.pdf \
            $TOPDIR/$VERSION
         chgrp visit $TOPDIR/$VERSION/Silo.book.pdf
      fi
EOF
   fi
   if [ "$DOLC" = "yes" ] ; then
      ssh ${lcun}@lilac "/bin/bash" << EOF
      umask 002
      if [ -d $TOPDIR/current ] ; then
         rm $TOPDIR/current
      fi
      ln -s $TOPDIR/$VERSION $TOPDIR/current
      chgrp visit $TOPDIR/current
      if [ -f $TOPDIR/$VERSION/test/$TOPSRCDIR/docs/Silo.book.pdf ] ; then
         cp $TOPDIR/$VERSION/test/$TOPSRCDIR/docs/Silo.book.pdf \
            $TOPDIR/$VERSION
         chgrp visit $TOPDIR/$VERSION/Silo.book.pdf
      fi
EOF
   fi
   i=0
   while (( i < ${#list[*]} ))
   do
      ${list[i]}final
      i=i+1
   done
elif [[ "$DOCLEAN" == "yes" ]] ; then
   i=0
   while (( i < ${#list[*]} ))
   do
      ${list[i]}clean
      i=i+1
   done
   if [[ "$DOBDIV" == "yes" ]] ; then
      ssh ${bdun}@${bdhost} "/bin/bash" << EOF
      umask 002
      if [ -d $TOPDIR/$VERSION/test ] ; then
         rm -rf $TOPDIR/$VERSION/test
         rm -rf $TOPDIR/$VERSION/test
      fi
EOF
   fi
   if [ "$DOLC" = "yes" ] ; then
      ssh ${lcun}@lilac "/bin/bash" << EOF
      umask 002
      if [ -d $TOPDIR/$VERSION/test ] ; then
         rm -rf $TOPDIR/$VERSION/test
         rm -rf $TOPDIR/$VERSION/test
      fi
EOF
   fi
else
   if [[ "$DOBDIV" == "yes" ]] ; then
      ssh ${bdun}@${bdhost} "/bin/bash" << EOF
      umask 002
      if [ ! -d $TOPDIR/$VERSION ] ; then
         mkdir $TOPDIR/$VERSION
      fi
      chgrp visit $TOPDIR/$VERSION
      chmod a+rX,u+w,o-w,g+s $TOPDIR/$VERSION
      if [ ! -d $TOPDIR/$VERSION/test ] ; then
         mkdir $TOPDIR/$VERSION/test
         chgrp visit $TOPDIR/$VERSION/test
         chmod a+rX,ug+w $TOPDIR/$VERSION/test
      fi
EOF
      if [ -e $TARFILE ] ; then
         scp $TARFILE ${bdun}@${bdhost}:$TOPDIR/$VERSION
         ssh ${bdun}@${bdhost} "/bin/bash" << EOF
         umask 002
         cd $TOPDIR/$VERSION/test
         chmod a+r,ug+w ../$TARFILE
         chgrp visit ../$TARFILE
         tar zxf ../$TARFILE
         chgrp -R visit $TOPSRCDIR
         chmod -R a+rX,ug+w $TOPSRCDIR
EOF
      fi
   fi
   if [ "$DOLC" == "yes" ] ; then
      ssh ${lcun}@lilac "/bin/bash" << EOF
      umask 002
      if [ ! -d $TOPDIR/$VERSION ] ; then
         mkdir $TOPDIR/$VERSION
      fi
      chgrp visit $TOPDIR/$VERSION
      chmod a+rX,u+w,o-w,g+s $TOPDIR/$VERSION
      if [ ! -d $TOPDIR/$VERSION/test ] ; then
         mkdir $TOPDIR/$VERSION/test
         chgrp visit $TOPDIR/$VERSION/test
         chmod a+rX,ug+w $TOPDIR/$VERSION/test
      fi
EOF
      if [ -e $TARFILE ] ; then
         scp $TARFILE ${lcun}@lilac:$TOPDIR/$VERSION
         ssh ${lcun}@lilac "/bin/bash" << EOF
         umask 002
         cd $TOPDIR/$VERSION/test
         chmod a+r,ug+w ../$TARFILE
         chgrp visit ../$TARFILE
         tar zxf ../$TARFILE
         chgrp -R visit $TOPSRCDIR
         chmod -R a+rX,ug+w $TOPSRCDIR
EOF
      fi
   fi
   i=0
   while (( i < ${#list[*]} ))
   do
      ${list[i]}
      i=i+1
   done
fi
