#!/bin/sh
##############################################################################
# If not stated otherwise in this file or this component's LICENSE file the
# following copyright and licenses apply:
#
# Copyright 2020 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################

. /etc/include.properties
. /etc/device.properties

PROCESS_NAME=$1
PORTS=$2 # optional single port number, ALL for all process ports (default is ALL)
PROTO=$3 # optional protocol type UDP, TCP, BOTH (default is BOTH)
INTERFACE=$4 # optional interface variable defined in device.properties (default is MOCA_INTERFACE)
MAX_RETRY=10

if [ -z $PORTS ]; then
    PORTS=ALL
fi

if [ -z $PROTO ]; then
    PROTO=BOTH
fi

if [ -z $INTERFACE ]; then
    INTERFACE=MOCA_INTERFACE
fi

getPortUsedByProcess() {
   processName=$1
   processPid=`pidof $processName`
   # Port listing should be unique and no restriction on the sount
   portUsedByProcess=`netstat -lntup 2>&1 | grep -v 'netstat' | grep "$processPid/" | tr -s ' ' | cut -d ' ' -f4 | cut -d ':' -f2 | uniq`
   echo "$portUsedByProcess"
}

if [ ! "$PROCESS_NAME" ]; then
    echo "Process name is empty. Exiting !!!!"
fi

if [ $PORTS == "ALL" ]; then
    loop=1
    retryCount=0
    while [ $loop -eq 1 ]
    do
        PORTS=$(getPortUsedByProcess $PROCESS_NAME)
        if [ ! "$PORTS" ]; then
            echo "Port used by $PROCESS_NAME is empty. Waiting for $PROCESS_NAME to be up !!! "
            sleep 10
            retryCount=$((retryCount + 1))
            if [ $retryCount -ge $MAX_RETRY ] ; then
                echo "Waiting for port identification used by $PROCESS_NAME failed. Giving up..."
                loop=0
                exit 0
            fi
        else
            loop=0;
        fi
    done
fi

# Enable firewall rule to accept traffic on port over MOCA interface
if [ ! -f /etc/os-release ];then
     IPV6_BIN="/sbin/ip6tables -w "
     IPV4_BIN="/sbin/iptables -w "
else
     IPV6_BIN="/usr/sbin/ip6tables -w "
     IPV4_BIN="/usr/sbin/iptables -w "
fi

echo "Ports used by $PROCESS_NAME on interface $INTERFACE are : "
echo "$PORTS"

for i in $PORTS ; do

    # Avoid errors due to adding firewall rule on string observed during race around condition
    if [ "${i//[0-9]}" != "" ]; then
        echo "$i is not a valid port. "
        continue
    fi

    if [[ $PROTO == "BOTH" || $PROTO == "TCP" ]]; then
        $IPV4_BIN -A INPUT -i $(eval echo "\$${INTERFACE}") -p tcp --dport $i -j ACCEPT
        $IPV6_BIN -A INPUT -i $(eval echo "\$${INTERFACE}") -p tcp --dport $i -j ACCEPT
    fi

    if [[ $PROTO == "BOTH" || $PROTO == "UDP" ]]; then
        $IPV4_BIN -A INPUT -i $(eval echo "\$${INTERFACE}") -p udp --dport $i -j ACCEPT
        $IPV6_BIN -A INPUT -i $(eval echo "\$${INTERFACE}") -p udp --dport $i -j ACCEPT
    fi
done


<filename>scripts/backend/detach_vol.sh
#!/bin/bash

cd `dirname $0`
source ../cloudrc

[ $# -lt 3 ] && echo "$0 <vm_ID> <volume> <device>" && exit -1

vm_ID=$1
vol_name=$2
device=$3
vol_file=$volume_dir/$vol_name.disk

virsh detach-disk $vm_ID $device
[ $? -eq 0 ] && echo "|:-COMMAND-:| /opt/cloudland/scripts/frontback/`basename $0` '$vm_ID' '$vol_name' '$device'"


#!/bin/sh

NAME_OF_IMAGE=disk_image.img
SECTOR_SIZE=512
SIZE_IN_BYTES=67108864
SIZE_IN_SECTORS=$((SIZE_IN_BYTES/SECTOR_SIZE));

echo $SIZE_IN_BYTES
echo $SIZE_IN_SECTORS

dd if=/dev/zero of=$NAME_OF_IMAGE bs=$SECTOR_SIZE count=$SIZE_IN_SECTORS
sfdisk $NAME_OF_IMAGE < partition_layout.sfdisk

/usr/local/sbin/mkfs.fat --offset=2048 -F32 $NAME_OF_IMAGE

# TODO(patrik): Change the 1048576 (2048 * 512) to not be hardcoded
mcopy -i disk_image.img@@1048576 fs/* ::/
mdir -i disk_image.img@@1048576


#!/usr/bin/env bash
NODE_JS_VERSION=13.6
nvm install $NODE_JS_VERSION --latest-npm
npm install


<reponame>Kaixi26/org.alloytools.alloy
#!/usr/bin/env sh

CLASS_REF="edu.mit.csail.sdg.alloy4whole.RepairCLI"

if test -f "slf4j-nop-1.7.28.jar"; then
	LOGGER="slf4j-nop-1.7.28.jar"
fi

PROGRAM_JAR=$1
shift

java -cp "$PROGRAM_JAR:$LOGGER" $CLASS_REF $@


<reponame>limpygnome/rpi-misc<filename>deploy/deploy_apps_config.sh<gh_stars>0
#!/bin/bash
./deploy.sh "config,apps,reboot"


#!/usr/bin/env bash
usage()
{
    echo "Usage:"
    echo "  "`basename $0`" 'commit message'"
    echo "Example:"
    echo "  "`basename $0`" FML"
    exit 1
}
[[ "$#" -ne 1 ]] && usage;
MSG=$1

git add .
git commit -m "${MSG}"
git push
echo "Done."


#!/bin/bash

echo -n "Enter the name of a country: "
read COUNTRY

echo -n "The official language of $COUNTRY is "

case $COUNTRY in

  Lithuania)
    echo -n "Lithuanian"
    ;;

  Romania | Moldova)
    echo -n "Romanian"
    ;;

  Italy | "San Marino" | Switzerland | "Vatican City")
    echo -n "Italian"
    ;;

  *)
    echo -n "unknown"
    ;;
esac


#!/bin/bash
exec unicorn -nc "$0" "$@"
!#

import scala.io.Source
import unicorn.json._
import unicorn.bigtable.rocksdb._
import unicorn.unibase._
import unicorn.unibase.graph._

def feat(graph: Graph, files: String*): Unit = {
  files.foreach { file =>
    val feats = new Array[String](20000)
    Source.fromFile(file + ".featnames").getLines.foreach { line =>
      val feat = line.split(" ", 2)
      feats(feat(0).toInt) = feat(1)
    }

    Source.fromFile(file + ".feat").getLines.foreach { line =>
      val feat = line.split(" ")
      val id = feat(0)

      if (!graph.contains(id)) {
        val data = JsObject()

        for (i <- 1 until feat.length) {
          if (feat(i) == "1") {
            val f = feats(i-1).split(":")
            if (f.length > 1) data(f(0)) = f(1)
          }
        }

        graph.addVertex(id, data)
      }
    }
  }
}

def edges(graph: Graph, files: String*): Unit = {
  files.foreach { file =>
    Source.fromFile(file + ".edges").getLines.foreach { line =>
      val edge = line.split(" ")
      val source = edge(0)
      val target = edge(1)
      graph.addEdge(source, "e", target, JsNull)
    }
  }
}

val db = Unibase(RocksDB.create("/tmp/unicorn-gplus"))
db.createGraph("gplus")
val gplus = db.graph("gplus", new Snowflake(0))

feat(gplus, "../../data/gplus/100129275726588145876")
feat(gplus, "../../data/gplus/100329698645326486178")
feat(gplus, "../../data/gplus/100466178325794757407")
feat(gplus, "../../data/gplus/100500197140377336562")
feat(gplus, "../../data/gplus/100518419853963396365")
feat(gplus, "../../data/gplus/100521671383026672718")
feat(gplus, "../../data/gplus/100535338638690515335")
feat(gplus, "../../data/gplus/100637660947564674695")
feat(gplus, "../../data/gplus/100668989009254813743")
feat(gplus, "../../data/gplus/100715738096376666180")
feat(gplus, "../../data/gplus/100720409235366385249")
feat(gplus, "../../data/gplus/100962871525684315897")
feat(gplus, "../../data/gplus/101130571432010257170")
feat(gplus, "../../data/gplus/101133961721621664586")
feat(gplus, "../../data/gplus/101185748996927059931")
feat(gplus, "../../data/gplus/101263615503715477581")
feat(gplus, "../../data/gplus/101373961279443806744")
feat(gplus, "../../data/gplus/101499880233887429402")
feat(gplus, "../../data/gplus/101541879642294398860")
feat(gplus, "../../data/gplus/101560853443212199687")
feat(gplus, "../../data/gplus/101626577406833098387")
feat(gplus, "../../data/gplus/101848191156408080085")
feat(gplus, "../../data/gplus/101997124338642780860")
feat(gplus, "../../data/gplus/102170431816592344972")
feat(gplus, "../../data/gplus/102340116189726655233")
feat(gplus, "../../data/gplus/102615863344410467759")
feat(gplus, "../../data/gplus/102778563580121606331")
feat(gplus, "../../data/gplus/103236949470535942612")
feat(gplus, "../../data/gplus/103241736833663734962")
feat(gplus, "../../data/gplus/103251633033550231172")
feat(gplus, "../../data/gplus/103338524411980406972")
feat(gplus, "../../data/gplus/103503116383846951534")
feat(gplus, "../../data/gplus/103537112468125883734")
feat(gplus, "../../data/gplus/103752943025677384806")
feat(gplus, "../../data/gplus/103892332449873403244")
feat(gplus, "../../data/gplus/104076158580173410325")
feat(gplus, "../../data/gplus/104105354262797387583")
feat(gplus, "../../data/gplus/104226133029319075907")
feat(gplus, "../../data/gplus/104290609881668164623")
feat(gplus, "../../data/gplus/104607825525972194062")
feat(gplus, "../../data/gplus/104672614700283598130")
feat(gplus, "../../data/gplus/104905626100400792399")
feat(gplus, "../../data/gplus/104917160754181459072")
feat(gplus, "../../data/gplus/104987932455782713675")
feat(gplus, "../../data/gplus/105565257978663183206")
feat(gplus, "../../data/gplus/105646458226420473639")
feat(gplus, "../../data/gplus/106186407539128840569")
feat(gplus, "../../data/gplus/106228758905254036967")
feat(gplus, "../../data/gplus/106328207304735502636")
feat(gplus, "../../data/gplus/106382433884876652170")
feat(gplus, "../../data/gplus/106417861423111072106")
feat(gplus, "../../data/gplus/106724181552911298818")
feat(gplus, "../../data/gplus/106837574755355833243")
feat(gplus, "../../data/gplus/107013688749125521109")
feat(gplus, "../../data/gplus/107040353898400532534")
feat(gplus, "../../data/gplus/107203023379915799071")
feat(gplus, "../../data/gplus/107223200089245371832")
feat(gplus, "../../data/gplus/107296660002634487593")
feat(gplus, "../../data/gplus/107362628080904735459")
feat(gplus, "../../data/gplus/107459220492917008623")
feat(gplus, "../../data/gplus/107489144252174167638")
feat(gplus, "../../data/gplus/107965826228461029730")
feat(gplus, "../../data/gplus/108156134340151350951")
feat(gplus, "../../data/gplus/108404515213153345305")
feat(gplus, "../../data/gplus/108541235642523883716")
feat(gplus, "../../data/gplus/108883879052307976051")
feat(gplus, "../../data/gplus/109130886479781915270")
feat(gplus, "../../data/gplus/109213135085178239952")
feat(gplus, "../../data/gplus/109327480479767108490")
feat(gplus, "../../data/gplus/109342148209917802565")
feat(gplus, "../../data/gplus/109596373340495798827")
feat(gplus, "../../data/gplus/109602109099036550366")
feat(gplus, "../../data/gplus/110232479818136355682")
feat(gplus, "../../data/gplus/110241952466097562819")
feat(gplus, "../../data/gplus/110538600381916983600")
feat(gplus, "../../data/gplus/110581012109008817546")
feat(gplus, "../../data/gplus/110614416163543421878")
feat(gplus, "../../data/gplus/110701307803962595019")
feat(gplus, "../../data/gplus/110739220927723360152")
feat(gplus, "../../data/gplus/110809308822849680310")
feat(gplus, "../../data/gplus/110971010308065250763")
feat(gplus, "../../data/gplus/111048918866742956374")
feat(gplus, "../../data/gplus/111058843129764709244")
feat(gplus, "../../data/gplus/111091089527727420853")
feat(gplus, "../../data/gplus/111213696402662884531")
feat(gplus, "../../data/gplus/111278293763545982455")
feat(gplus, "../../data/gplus/112317819390625199896")
feat(gplus, "../../data/gplus/112463391491520264813")
feat(gplus, "../../data/gplus/112573107772208475213")
feat(gplus, "../../data/gplus/112724573277710080670")
feat(gplus, "../../data/gplus/112737356589974073749")
feat(gplus, "../../data/gplus/112787435697866537461")
feat(gplus, "../../data/gplus/113112256846010263985")
feat(gplus, "../../data/gplus/113122049849685469495")
feat(gplus, "../../data/gplus/113171096418029011322")
feat(gplus, "../../data/gplus/113356364521839061717")
feat(gplus, "../../data/gplus/113455290791279442483")
feat(gplus, "../../data/gplus/113597493946570654755")
feat(gplus, "../../data/gplus/113718775944980638561")
feat(gplus, "../../data/gplus/113799277735885972934")
feat(gplus, "../../data/gplus/113881433443048137993")
feat(gplus, "../../data/gplus/114054672576929802335")
feat(gplus, "../../data/gplus/114104634069486127920")
feat(gplus, "../../data/gplus/114122960748905067938")
feat(gplus, "../../data/gplus/114124942936679476879")
feat(gplus, "../../data/gplus/114147483140782280818")
feat(gplus, "../../data/gplus/114336431216099933033")
feat(gplus, "../../data/gplus/115121555137256496805")
feat(gplus, "../../data/gplus/115273860520983542999")
feat(gplus, "../../data/gplus/115360471097759949621")
feat(gplus, "../../data/gplus/115455024457484679647")
feat(gplus, "../../data/gplus/115516333681138986628")
feat(gplus, "../../data/gplus/115573545440464933254")
feat(gplus, "../../data/gplus/115576988435396060952")
feat(gplus, "../../data/gplus/115625564993990145546")
feat(gplus, "../../data/gplus/116059998563577101552")
feat(gplus, "../../data/gplus/116247667398036716276")
feat(gplus, "../../data/gplus/116315897040732668413")
feat(gplus, "../../data/gplus/116450966137824114154")
feat(gplus, "../../data/gplus/116807883656585676940")
feat(gplus, "../../data/gplus/116825083494890429556")
feat(gplus, "../../data/gplus/116899029375914044550")
feat(gplus, "../../data/gplus/116931379084245069738")
feat(gplus, "../../data/gplus/117412175333096244275")
feat(gplus, "../../data/gplus/117503822947457399073")
feat(gplus, "../../data/gplus/117668392750579292609")
feat(gplus, "../../data/gplus/117734260411963901771")
feat(gplus, "../../data/gplus/117798157258572080176")
feat(gplus, "../../data/gplus/117866881767579360121")
feat(gplus, "../../data/gplus/118107045405823607895")
feat(gplus, "../../data/gplus/118255645714452180374")
feat(gplus, "../../data/gplus/118379821279745746467")

edges(gplus, "../../data/gplus/100129275726588145876")
edges(gplus, "../../data/gplus/100329698645326486178")
edges(gplus, "../../data/gplus/100466178325794757407")
edges(gplus, "../../data/gplus/100500197140377336562")
edges(gplus, "../../data/gplus/100518419853963396365")
edges(gplus, "../../data/gplus/100521671383026672718")
edges(gplus, "../../data/gplus/100535338638690515335")
edges(gplus, "../../data/gplus/100637660947564674695")
edges(gplus, "../../data/gplus/100668989009254813743")
edges(gplus, "../../data/gplus/100715738096376666180")
edges(gplus, "../../data/gplus/100720409235366385249")
edges(gplus, "../../data/gplus/100962871525684315897")
edges(gplus, "../../data/gplus/101130571432010257170")
edges(gplus, "../../data/gplus/101133961721621664586")
edges(gplus, "../../data/gplus/101185748996927059931")
edges(gplus, "../../data/gplus/101263615503715477581")
edges(gplus, "../../data/gplus/101373961279443806744")
edges(gplus, "../../data/gplus/101499880233887429402")
edges(gplus, "../../data/gplus/101541879642294398860")
edges(gplus, "../../data/gplus/101560853443212199687")
edges(gplus, "../../data/gplus/101626577406833098387")
edges(gplus, "../../data/gplus/101848191156408080085")
edges(gplus, "../../data/gplus/101997124338642780860")
edges(gplus, "../../data/gplus/102170431816592344972")
edges(gplus, "../../data/gplus/102340116189726655233")
edges(gplus, "../../data/gplus/102615863344410467759")
edges(gplus, "../../data/gplus/102778563580121606331")
edges(gplus, "../../data/gplus/103236949470535942612")
edges(gplus, "../../data/gplus/103241736833663734962")
edges(gplus, "../../data/gplus/103251633033550231172")
edges(gplus, "../../data/gplus/103338524411980406972")
edges(gplus, "../../data/gplus/103503116383846951534")
edges(gplus, "../../data/gplus/103537112468125883734")
edges(gplus, "../../data/gplus/103752943025677384806")
edges(gplus, "../../data/gplus/103892332449873403244")
edges(gplus, "../../data/gplus/104076158580173410325")
edges(gplus, "../../data/gplus/104105354262797387583")
edges(gplus, "../../data/gplus/104226133029319075907")
edges(gplus, "../../data/gplus/104290609881668164623")
edges(gplus, "../../data/gplus/104607825525972194062")
edges(gplus, "../../data/gplus/104672614700283598130")
edges(gplus, "../../data/gplus/104905626100400792399")
edges(gplus, "../../data/gplus/104917160754181459072")
edges(gplus, "../../data/gplus/104987932455782713675")
edges(gplus, "../../data/gplus/105565257978663183206")
edges(gplus, "../../data/gplus/105646458226420473639")
edges(gplus, "../../data/gplus/106186407539128840569")
edges(gplus, "../../data/gplus/106228758905254036967")
edges(gplus, "../../data/gplus/106328207304735502636")
edges(gplus, "../../data/gplus/106382433884876652170")
edges(gplus, "../../data/gplus/106417861423111072106")
edges(gplus, "../../data/gplus/106724181552911298818")
edges(gplus, "../../data/gplus/106837574755355833243")
edges(gplus, "../../data/gplus/107013688749125521109")
edges(gplus, "../../data/gplus/107040353898400532534")
edges(gplus, "../../data/gplus/107203023379915799071")
edges(gplus, "../../data/gplus/107223200089245371832")
edges(gplus, "../../data/gplus/107296660002634487593")
edges(gplus, "../../data/gplus/107362628080904735459")
edges(gplus, "../../data/gplus/107459220492917008623")
edges(gplus, "../../data/gplus/107489144252174167638")
edges(gplus, "../../data/gplus/107965826228461029730")
edges(gplus, "../../data/gplus/108156134340151350951")
edges(gplus, "../../data/gplus/108404515213153345305")
edges(gplus, "../../data/gplus/108541235642523883716")
edges(gplus, "../../data/gplus/108883879052307976051")
edges(gplus, "../../data/gplus/109130886479781915270")
edges(gplus, "../../data/gplus/109213135085178239952")
edges(gplus, "../../data/gplus/109327480479767108490")
edges(gplus, "../../data/gplus/109342148209917802565")
edges(gplus, "../../data/gplus/109596373340495798827")
edges(gplus, "../../data/gplus/109602109099036550366")
edges(gplus, "../../data/gplus/110232479818136355682")
edges(gplus, "../../data/gplus/110241952466097562819")
edges(gplus, "../../data/gplus/110538600381916983600")
edges(gplus, "../../data/gplus/110581012109008817546")
edges(gplus, "../../data/gplus/110614416163543421878")
edges(gplus, "../../data/gplus/110701307803962595019")
edges(gplus, "../../data/gplus/110739220927723360152")
edges(gplus, "../../data/gplus/110809308822849680310")
edges(gplus, "../../data/gplus/110971010308065250763")
edges(gplus, "../../data/gplus/111048918866742956374")
edges(gplus, "../../data/gplus/111058843129764709244")
edges(gplus, "../../data/gplus/111091089527727420853")
edges(gplus, "../../data/gplus/111213696402662884531")
edges(gplus, "../../data/gplus/111278293763545982455")
edges(gplus, "../../data/gplus/112317819390625199896")
edges(gplus, "../../data/gplus/112463391491520264813")
edges(gplus, "../../data/gplus/112573107772208475213")
edges(gplus, "../../data/gplus/112724573277710080670")
edges(gplus, "../../data/gplus/112737356589974073749")
edges(gplus, "../../data/gplus/112787435697866537461")
edges(gplus, "../../data/gplus/113112256846010263985")
edges(gplus, "../../data/gplus/113122049849685469495")
edges(gplus, "../../data/gplus/113171096418029011322")
edges(gplus, "../../data/gplus/113356364521839061717")
edges(gplus, "../../data/gplus/113455290791279442483")
edges(gplus, "../../data/gplus/113597493946570654755")
edges(gplus, "../../data/gplus/113718775944980638561")
edges(gplus, "../../data/gplus/113799277735885972934")
edges(gplus, "../../data/gplus/113881433443048137993")
edges(gplus, "../../data/gplus/114054672576929802335")
edges(gplus, "../../data/gplus/114104634069486127920")
edges(gplus, "../../data/gplus/114122960748905067938")
edges(gplus, "../../data/gplus/114124942936679476879")
edges(gplus, "../../data/gplus/114147483140782280818")
edges(gplus, "../../data/gplus/114336431216099933033")
edges(gplus, "../../data/gplus/115121555137256496805")
edges(gplus, "../../data/gplus/115273860520983542999")
edges(gplus, "../../data/gplus/115360471097759949621")
edges(gplus, "../../data/gplus/115455024457484679647")
edges(gplus, "../../data/gplus/115516333681138986628")
edges(gplus, "../../data/gplus/115573545440464933254")
edges(gplus, "../../data/gplus/115576988435396060952")
edges(gplus, "../../data/gplus/115625564993990145546")
edges(gplus, "../../data/gplus/116059998563577101552")
edges(gplus, "../../data/gplus/116247667398036716276")
edges(gplus, "../../data/gplus/116315897040732668413")
edges(gplus, "../../data/gplus/116450966137824114154")
edges(gplus, "../../data/gplus/116807883656585676940")
edges(gplus, "../../data/gplus/116825083494890429556")
edges(gplus, "../../data/gplus/116899029375914044550")
edges(gplus, "../../data/gplus/116931379084245069738")
edges(gplus, "../../data/gplus/117412175333096244275")
edges(gplus, "../../data/gplus/117503822947457399073")
edges(gplus, "../../data/gplus/117668392750579292609")
edges(gplus, "../../data/gplus/117734260411963901771")
edges(gplus, "../../data/gplus/117798157258572080176")
edges(gplus, "../../data/gplus/117866881767579360121")
edges(gplus, "../../data/gplus/118107045405823607895")
edges(gplus, "../../data/gplus/118255645714452180374")
edges(gplus, "../../data/gplus/118379821279745746467")


/usr/bin/perl -w /usr/bin/sec -conf=/etc/sec.conf -input=/var/log/apache2/error.log -pid=/var/run/sec.pid -detach -syslog=daemon


<reponame>aws-greengrass/aws-greengrass-component-examples
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

#!/bin/bash
. $(dirname "$0")/utils.sh

set -eux

while getopts ":i:" opt; do
  case ${opt} in
    i )
      use_installer=$OPTARG
      ;;
    \? )
      echo "Invalid option: $OPTARG" 1>&2
      exit;;
    : )
      echo "Invalid option: $OPTARG requires an argument" 1>&2
      exit;;
  esac
done

if [ "$use_installer" = true ]; then
  echo "Running DLR install script...";
else
  echo "Skipping installation of component dependencies.";
  exit 0;
fi

kernel=$(uname -s)
dlr_version="1.6.0"
min_py_version="3.0.0"
dlr_directory="neo-ai-dlr"
min_kernel_version="4.9.9"
min_pip_version="20.2.4"
machine=$(uname -m)
python_version=$(echo $(python3 --version) | cut -d' ' -f 2)
pip3_version=$(echo $(pip3 --version) | cut -d' ' -f 2)
jetson_device_chip="/sys/module/tegra_fuse/parameters/tegra_chip_id"
# Supported dlr pip wheels for different devices and dlr versions can be fount at
# https://github.com/neo-ai/neo-ai-dlr/releases
dlr_link="https://neo-ai-dlr-release.s3-us-west-2.amazonaws.com/v"$dlr_version

case "$kernel" in
"Linux")
    if check_dlr "$machine"; then
        echo "Skipping DLR installation as it already exists."
    else
        if is_debian; then
            if [[ "$machine" == "x86_64" ]]; then
                install_python3_libraries
                echo "Installing DLR..."
                pip3 install dlr=="$dlr_version" --user
            elif [[ "$machine" == "armv7l" ]]; then
                install_python3_libraries
                echo "Installing DLR..."
                pip3 install $dlr_link"/rasp3b/dlr-"$dlr_version"-py3-none-any.whl" --user
            elif [[ "$machine" == "aarch64" ]]; then
                install_python3_libraries
                if [ -f "$jetson_device_chip" ]; then
                    echo "Installing DLR..."
                    pip3 install $dlr_link"/jetpack4.4/dlr-"$dlr_version"-py3-none-any.whl" --user
                else
                    echo "Installing DLR..."
                    pip3 install $dlr_link"/rasp4b/dlr-"$dlr_version"-py3-none-any.whl" --user
                fi
            fi
        elif is_centos; then
            if [[ "$machine" == "x86_64" ]]; then
                install_python3_libraries
                echo "Installing DLR..."
                pip3 install dlr=="$dlr_version" --user
            fi
        fi
    fi
    ;;
"Darwin")
    if check_dlr "$machine"; then
        echo "Skipping DLR installation as it already exists."
    else
        install_python3_libraries
        echo "Installing DLR..."
        pip3 install dlr=="$dlr_version" --user
    fi
    ;;
esac


<filename>hooks/shell_expansion.sh
#!/usr/bin/env bash
echo 'cat <<END_OF_TEXT' >  temp.sh
cat "$1"                 >> temp.sh
echo 'END_OF_TEXT'       >> temp.sh
source temp.sh > "$2"
rm -f temp.sh


#!/bin/bash

# This will kill all Docker containers and then remove volumes for some of the containers used by tcapy
# This will often be necessary to do when we are switching between test and product docker-compose

docker-compose rm -f mysql
docker-compose rm -f mongo
docker-compose rm -f redis
docker-compose rm -f memcached
docker-compose rm -f mysql
docker-compose rm -f celery
docker-compose rm -f gunicorn_tcapy
docker-compose rm -f gunicorn_tcapyboard nginx

docker-compose rm -v -f mysql
docker-compose rm -v -f mongo
docker-compose rm -v -f redis
docker-compose rm -v -f memcached
docker-compose rm -v -f mysql
docker-compose rm -v -f celery
docker-compose rm -v -f gunicorn_tcapy
docker-compose rm -v -f gunicorn_tcapyboard
docker-compose rm -v -f nginx

docker kill $(docker ps -q)


#!/usr/bin/env bash

set -euo pipefail; [[ -z ${TRACE:-} ]] || set -x

user=${deployer_user:-srv}
home=${deployer_home:-/srv}
uid=${deployer_uid:-10000}

goss -g - validate --format documentation <<-EOF
	user:
	  $user:
	    exists: true
	    home: $home
	    uid:  $uid
	    groups:
	    - $user
EOF


<filename>deploy-book.sh<gh_stars>0
#!/bin/bash

set -eu

rev=$(git rev-parse --short HEAD)

cd _book

git init
git config user.name "<NAME>"
git config user.email "<EMAIL>"
git remote add upstream "https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git"
git fetch upstream
git reset upstream/gh-pages

touch .

git add -A .
git commit -m "update book at ${rev}"
git push upstream HEAD:gh-pages


<gh_stars>0
cd /slamdoom/tmp/orbslam2/
./build.sh || exit 1

cd /home/slam_data/pyORBSLAM2/src
./build.sh || exit 1

export PYTHONPATH=/home/slam_data/pyORBSLAM2/src/build:$PYTHONPATH
cd /home/slam_data/pyORBSLAM2/scripts
#python3 test_slam_with_webcam.py
#python3 temp.py


<reponame>IlyaFinkelshteyn/evlog
#!/bin/bash

# This script pushes the local image to dockerhub.
# You must be a collaborator for this to work for you.
# If you're running it locally, make sure you're logged in with the correct dockerhub account first.
# If you're invoking this on CI, set the following environment variables:
#   1. $CI: Must be true. Most CI environments already have this set by default.
#   2. $DOCKER_USERNAME: Your dockerhub username.
#   3. $DOCKER_PASSWORD: <PASSWORD>.

if [ "$CI" = true ] ; then
    docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
fi

docker push gldraphael/evlog
docker push gldraphael/evlog-self-contained


<filename>src/lib/sttp.net.lib/buildso.sh
# Verify "SWIG_LIB " is defined
if [[ -z "$SWIG_LIB" ]]; then
    echo 'The "SWIG_LIB" environmental variable not found, abroting compile.'
    exit
fi

echo ' Compiling inpendendent debug version of "libsttp.a"...'
mkdir -p bin/Debug
pushd bin/Debug
cmake ../../../cppapi/src -DCMAKE_BUILD_TYPE=Debug -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_FLAGS="-Wno-unknown-pragmas"
make -j6
popd

echo ' Compiling debug version of "sttp.net.lib.so"...'
mkdir -p obj/Debug
gcc -g -D SWIG -c -fPIC sttp.net.lib.cpp -o obj/Debug/sttp.net.lib.o
gcc -g -shared obj/Debug/sttp.net.lib.o bin/Debug/Libraries/libsttp.a -o bin/Debug/sttp.net.lib.so

echo ' Compiling inpendendent release version of "libsttp.a"...'
mkdir -p bin/Release
pushd bin/Release
cmake ../../../cppapi/src -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_FLAGS="-Wno-unknown-pragmas"
make -j6
popd

echo ' Compiling release version of "sttp.net.lib.so"...'
mkdir -p obj/Release
gcc -D SWIG -c -fPIC sttp.net.lib.cpp -o obj/Release/sttp.net.lib.o
gcc -shared obj/Release/sttp.net.lib.o bin/Release/Libraries/libsttp.a -o bin/Release/sttp.net.lib.so

# Copy resulting compiled "sttp.net.lib.so" files to target folders:
cp bin/Debug/sttp.net.lib.so ../../../build/output/x64/Debug/lib
cp bin/Release/sttp.net.lib.so ../../../build/output/x64/Release/lib


<reponame>texpomru13/espnet<gh_stars>1000+
for x in test_st dev_st train_st_sp; do
  utils/fix_data_dir.sh data/${x}
  utils/data/get_utt2dur.sh data/${x}
  awk 'BEGIN{SUM=0}{SUM+=$2}END{print SUM/3600}' data/${x}/utt2dur
done


<filename>bin/utils.sh
#!/usr/bin/env bash

export compose_file="../docker-compose.yml"

function announce() {
    BLUE='\033[0;34m'
    NC='\033[0m' # No Color
    echo -e "$BLUE
    ================================
     ${1}
    ================================
    $NC"
}

exec_on() {
  local container="$1"; shift

  docker exec "$(docker-compose ps -q $container)" "$@"
}

oss_only(){
  [ "$TEST_VERSION" == "oss" ]
}

function teardown {
  docker-compose down -v
}


#! /bin/bash

#
# Extra installation script
#
# See CK LICENSE.txt for licensing details.
# See CK COPYRIGHT.txt for copyright details.
#
# Developer(s):
# - <NAME>, <EMAIL>, 2018
#

module load EasyBuild

ck detect soft:compiler.gcc --extra_tags=veasybuild --extra_name="(easybuild)" --search_dir=${EASYBUILD_PREFIX}/software


<filename>dev-support/build-ambari.sh<gh_stars>1000+
#!/usr/bin/env bash
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

# Clean up files from previous build to make sure there are no artifacts that would trigger rat failure.
pushd .
cd $WORKSPACE
git clean -xdf
popd

# We stash node.js installation into this weird place
# because on one hand we want it to be somewhere inside
# the current workspace and on the other hand we don't
# want RAT to be ran on files that comprise it. The following
# location is excluded from RAT by default
REPO_NAME=contrib/views/node.js/target

[ -d "$REPO_NAME"  ] && exit 0

rm -rf $REPO_NAME
mkdir -p $REPO_NAME.tmp
pushd $REPO_NAME.tmp
  curl --retry 3 --retry-delay 5 -k http://nodejs.org/dist/v4.5.0/node-v4.5.0-linux-x64.tar.gz | tar xzvf -
  mv node-v4.5.0-linux-x64/* .
  rmdir node-v4.5.0-linux-x64
popd
mv $REPO_NAME.tmp $REPO_NAME

export PATH=`pwd`/$REPO_NAME/bin:$PATH
npm install -g brunch@1.7.20

export _JAVA_OPTIONS="-Xmx2048m -Djava.awt.headless=true"
export JAVA_HOME=/home/jenkins/tools/java/latest1.8
export MAVEN_HOME=/home/jenkins/tools/maven/latest
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
PATH=`pwd`/contrib/views/node.js/target/bin:$PATH
echo "Checking Hudson Java"
ls -l /home/hudson/tools/java
echo "Checking Jenkins Java"
ls -l /home/jenkins/tools/java
which java
java -version
python -V
uname -a

cd $WORKSPACE
$MAVEN_HOME/bin/mvn -fae clean install


#!/bin/bash
# Copyright 2019 Johns Hopkins University (<NAME>)
# Apache 2.0.
#

set -e

cmd=run.pl
p_tel=0.05
l2_reg=1e-4
sre_weight=0.1
extra_args=""
extra_tag=""

if [ -f path.sh ]; then . ./path.sh; fi
. parse_options.sh || exit 1;

if [ $# -ne 1 ]; then
  echo "Usage: $0 <score-dir>"
  exit 1;
fi

score_dir=$1
cal_score_dir=${score_dir}_cal_v1
if [ -n "$extra_tag" ];then
  cal_score_dir=${cal_score_dir}_${extra_tag}
fi

mkdir -p $cal_score_dir

echo "$0 train calibration v1 for $score_dir"
awk '{ print $1,NF-1}' \
    data/sre16_eval40_yue_enroll/spk2utt \
    > $cal_score_dir/sre16_nenr

if [ -d data/sre_cts_superset_8k_dev ];then
  superset=sre_cts_superset_8k_dev
else
  superset=sre_cts_superset_16k_dev
fi

model_file=$cal_score_dir/cal_tel.h5
$cmd $cal_score_dir/train_cal_tel.log \
     hyp_utils/conda_env.sh \
     steps_be/train-calibration-v1.py \
     --score-file-sre16 $score_dir/sre16_eval40_yue_scores \
     --score-file-sre $score_dir/sre_cts_superset_dev_scores \
     --score-file-sre21 $score_dir/sre21_audio_dev_scores \
     --key-file-sre16 data/sre16_eval40_yue_test/trials \
     --key-file-sre data/$superset/trials \
     --key-file-sre21 data/sre21_audio_dev_test/trials \
     --nenr-sre16 $cal_score_dir/sre16_nenr \
     --model-file $model_file \
     --prior $p_tel --lambda-reg $l2_reg --sre-weight $sre_weight $extra_args

echo "$0 eval calibration v1 for sre16-yue"
$cmd $cal_score_dir/eval_cal_sre16_yue.log \
     hyp_utils/conda_env.sh \
     steps_be/eval-calibration-v1-sre16.py \
     --in-score-file $score_dir/sre16_eval40_yue_scores \
     --ndx-file data/sre16_eval40_yue_test/trials \
     --nenr-file $cal_score_dir/sre16_nenr \
     --model-file $model_file \
     --out-score-file $cal_score_dir/sre16_eval40_yue_scores &

echo "$0 eval calibration v1 for sre-superset"
$cmd $cal_score_dir/eval_cal_sre_superset.log \
     hyp_utils/conda_env.sh \
     steps_be/eval-calibration-v1-sre-superset.py \
     --in-score-file $score_dir/sre_cts_superset_dev_scores \
     --ndx-file data/$superset/trials \
     --model-file $model_file \
     --out-score-file $cal_score_dir/sre_cts_superset_dev_scores &

echo "$0 eval calibration v1 for sre21-audio-dev"
$cmd $cal_score_dir/eval_cal_sre21_audio_dev.log \
     hyp_utils/conda_env.sh \
     steps_be/eval-calibration-v1-sre21-dev.py \
     --in-score-file $score_dir/sre21_audio_dev_scores \
     --ndx-file data/sre21_audio_dev_test/trials \
     --model-file $model_file \
     --out-score-file $cal_score_dir/sre21_audio_dev_scores &

echo "$0 eval calibration v1 for sre21-audio-visual-dev"
$cmd $cal_score_dir/eval_cal_sre21_audio-visual_dev.log \
     hyp_utils/conda_env.sh \
     steps_be/eval-calibration-v1-sre21-dev.py \
     --in-score-file $score_dir/sre21_audio-visual_dev_scores \
     --ndx-file data/sre21_audio-visual_dev_test/trials \
     --model-file $model_file \
     --out-score-file $cal_score_dir/sre21_audio-visual_dev_scores &

utils/utt2spk_to_spk2utt.pl \
  data/sre21_audio_eval_enroll/utt2model | \
  awk '{ print $1,NF-1}' \
    > $cal_score_dir/sre21eval_nenr

awk -v u2l=data/sre21_audio_eval_enroll/utt2est_lang '
BEGIN{
  while(getline < u2l)
  {
     lang[$1]=$2
  }
}
{ if(!($2 in done)){
    print $2,lang[$1];
    done[$2]=1;
   }
}' data/sre21_audio_eval_enroll/utt2model > $cal_score_dir/sre21eval_e2l

echo "$0 eval calibration v1 for sre21-audio-eval"
$cmd $cal_score_dir/eval_cal_sre21_audio_eval.log \
     hyp_utils/conda_env.sh \
     steps_be/eval-calibration-v1-sre21-eval.py \
     --in-score-file $score_dir/sre21_audio_eval_scores \
     --ndx-file data/sre21_audio_eval_test/trials \
     --model-file $model_file \
     --out-score-file $cal_score_dir/sre21_audio_eval_scores \
     --nenr-file $cal_score_dir/sre21eval_nenr \
     --enroll-lang $cal_score_dir/sre21eval_e2l \
     --test-lang data/sre21_audio_eval_test/utt2est_lang &

echo "$0 eval calibration v1 for sre21-audio-eval"
$cmd $cal_score_dir/eval_cal_sre21_audio-visual_eval.log \
     hyp_utils/conda_env.sh \
     steps_be/eval-calibration-v1-sre21-eval.py \
     --in-score-file $score_dir/sre21_audio-visual_eval_scores \
     --ndx-file data/sre21_audio-visual_eval_test/trials \
     --model-file $model_file \
     --out-score-file $cal_score_dir/sre21_audio-visual_eval_scores \
     --nenr-file $cal_score_dir/sre21eval_nenr \
     --enroll-lang $cal_score_dir/sre21eval_e2l \
     --test-lang data/sre21_audio-visual_eval_test/utt2est_lang &

wait


#!/bin/bash

##========================================
## Run GeoServer
##========================================

## Setup the JRE and GDAL for GeoServer
source ./setup.sh

## Environment variables for GeoServer
source ./env.sh

## Start the Jetty servlet container and the GeoServer webapp
cd ${GEOSERVER_HOME}/bin
./startup.sh


#!/bin/bash

composer install
npm install
php artisan migrate:refresh --seed
npm run dev

cat './resources/css/csstemplate.css' >> './public/css/app.css'

php artisan serve


publish_binaries() {
    VERSION=$1

    echo "Publish version $VERSION from git tag $VERSION"
    ( bintray_create_version $VERSION && echo "Bintray: Version $VERSION created" ) || ( exit 1 )

    for os in linux darwin windows ; do
        for arch in amd64 ; do
          fileName=werf-$os-$arch-$VERSION
          if [ "$os" == "windows" ] ; then
              fileName=$fileName.exe
          fi

          localFile=$RELEASE_BUILD_DIR/$VERSION/$fileName

          ( bintray_upload_file_into_version $VERSION $localFile $fileName ) || ( exit 1 )
        done
      done

    ( bintray_upload_file_into_version $VERSION $RELEASE_BUILD_DIR/$VERSION/SHA256SUMS SHA256SUMS ) || ( exit 1 )
}

sign_binaries() {
    VERSION=$1

    dlUrl="https://dl.bintray.com/${BINTRAY_SUBJECT}/${BINTRAY_REPO}/${VERSION}/SHA256SUMS"

    signDir="$RELEASE_BUILD_DIR/$VERSION/sign"

    mkdir -p $signDir

    curl $dlUrl -o $signDir/SHA256SUMS

    # TODO
    cp $signDir/SHA256SUMS $signDir/SHA256SUMS.dsc

    ( bintray_upload_file_into_version $VERSION $signDir/SHA256SUMS.dsc SHA256SUMS.dsc ) || ( exit 1 )
}


#!/bin/bash -x
# Extract and run the OpenBMC robot test suite
#
# The robot test results will be copied to ${HOME}
#
#  Requires following env variables be set:
#   IP_ADDR     IP Address of openbmc
#   SSH_PORT    SSH port of openbmc
#   HTTPS_PORT  HTTPS port of openbmc
#
#  Optional env variable
#   ROBOT_CODE_HOME  Location to extract the code
#                    Default will be a temp location in /tmp/
#   ROBOT_TEST_CMD   Command to execute from within obmc robot test framework
#                    Default will be "tox -e qemu -- --include QEMU_CI tests"
#   MACHINE          Type of system to run tests against
#                    Default is qemu

# we don't want to fail on bad rc since robot tests may fail

MACHINE=${MACHINE:-"qemu"}
ROBOT_CODE_HOME=${ROBOT_CODE_HOME:-/tmp/$(whoami)/${RANDOM}/obmc-robot/}
ROBOT_TEST_CMD=${ROBOT_TEST_CMD:-"python3 -m robot\
    -v OPENBMC_HOST:${IP_ADDR}\
    -v SSH_PORT:${SSH_PORT}\
    -v HTTPS_PORT:${HTTPS_PORT}\
    --argumentfile ./test_lists/QEMU_CI ./tests"}

git clone https://github.com/openbmc/openbmc-test-automation.git \
        ${ROBOT_CODE_HOME}

cd ${ROBOT_CODE_HOME}

chmod ugo+rw -R ${ROBOT_CODE_HOME}/*

# Execute the CI tests
"$($ROBOT_TEST_CMD)"

cp ${ROBOT_CODE_HOME}/*.xml ${HOME}/
cp ${ROBOT_CODE_HOME}/*.html ${HOME}/
if [ -d logs ] ; then
    cp -Rf ${ROBOT_CODE_HOME}/logs ${HOME}/ ;
fi

#rm -rf ${ROBOT_CODE_HOME}


<reponame>pnieves2019/MAELAS
#!/bin/bash

atomsk cell.lmp pos

mv POSCAR POSCAR_rlx

maelas -g -mode 1 -i POSCAR_rlx -s 0.005 -n 9

for i in {1..2}

do

for j in {1..9}

do

atomsk POSCAR_${i}_${j} -alignx lmp -ow

myFile="POSCAR_${i}_${j}.lmp"

n=1
while read line; do
	if [ $n -gt 15 ];
	then

	echo  $line "  0.0 0.0 0.0 0.0" >> POSCAR_${i}_${j}_new.lmp
	else
	echo  $line  >> POSCAR_${i}_${j}_new.lmp
	fi

	n=$((n+1))
done < $myFile

mv POSCAR_${i}_${j}_new.lmp POSCAR_${i}_${j}.lmp

done

done


###
# Use this script to release to pypi.
# 1. Update version in setup.up
# 2. COMMIT everything
# 3. Run this script from project root:
# ```
#   $ scripts/release.sh
# ```
##

if [ -n "$(git status --porcelain)" ]; then
  echo "!Error: Changes need to be committed or stashed first!"
  exit 1
fi

echo "Creating and pushing tag: $(python setup.py --version)."
git tag $(python setup.py --version)
git push --tags

echo "Complete."


<filename>test/sample-test/hack/update_requirements.sh<gh_stars>0
#!/bin/bash

set -ex

cat ../../sdk/python/requirements.in ../../backend/api/python_http_client/requirements.txt ../../backend/requirements.in requirements.in | \
    ../../backend/update_requirements.sh google/cloud-sdk:315.0.0 >requirements.txt


export PROJECTS_DIR="$HOME/Work/Projects"

function _work_complete () {
  reply = ()
  IFS=$(echo -en "\n\b")
  for f in $PROJECTS_DIR/*; do
    reply=( ${reply[@]} ${f##*/})
  done
}

function work() {
  cd $PROJECTS_DIR/$1
}
compctl -K _work_complete work

function ow() {
  cd $PROJECTS_DIR/$1/Code/
  (open *.xcworkspace 2>/dev/null) || (open *.xcodeproj 2>/dev/null)
}
compctl -K _work_complete ow


<reponame>jlashner/ares<gh_stars>1-10
mpirun -np 2 python test_parallel_grid.py order_2_4 1
mpirun -np 4 python test_parallel_grid.py order_2_4 1000

mpirun -np 4 python test_parallel_grid.py order_4_2 1
mpirun -np 2 python test_parallel_grid.py order_4_2 1000

mpirun -np 2 python test_parallel_grid.py order_2_2 1
mpirun -np 2 python test_parallel_grid.py order_2_2 1000

mpirun -np 4 python test_parallel_grid.py order_4_4 1
mpirun -np 4 python test_parallel_grid.py order_4_4 1000

mpirun -np 4 python test_parallel_grid.py order_4 1000


<filename>src/tools/dev/scripts/bv_support/bv_main.sh
# --------------------------------------------------------------------------- #
#   checking compiler minimum version                                         #
# --------------------------------------------------------------------------- #
function vercomp ()
{
    if [[ $1 == $2 ]]
    then
        return 0
    fi
    local IFS=.
    local i ver1=($1) ver2=($2)
    # fill empty fields in ver1 with zeros
    for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
    do
        ver1[i]=0
    done
    for ((i=0; i<${#ver1[@]}; i++))
    do
        if [[ -z ${ver2[i]} ]]
        then
            # fill empty fields in ver2 with zeros
            ver2[i]=0
        fi
        if [[ 10#${ver1[i]} > 10#${ver2[i]} ]]
        then
            return 1
        fi
        if [[ 10#${ver1[i]} < 10#${ver2[i]} ]]
        then
            return 2
        fi
    done
    return 0
}

function testvercomp ()
{
    vercomp $1 $2
    case $? in
        0) op='=';;
        1) op='>';;
        2) op='<';;
    esac
    if [[ $op != $3 ]]
    then
        return 1
    else
        return 0
    fi
}

function check_minimum_compiler_version()
{
   if [[ "$CXX_COMPILER" == "g++" ]] ; then
        VERSION=$(g++ -v 2>&1 | grep "gcc version" | cut -d' ' -f3 )
        echo "g++ version $VERSION"
        testvercomp $VERSION 4.8 '<'
        if [[ $? == 0 ]] ; then
            echo "Need g++ version >= 4.8"
            exit 1
        fi
    elif [[ "$OPSYS" == "Darwin"  &&  "$CXX_COMPILER" == "clang++" ]] ; then
        VERSION=$(clang++ -v 2>&1 | grep "clang version" | cut -d' ' -f3 )
        echo "apple clang version $VERSION"
        testvercomp $VERSION 5.0 '<'
        if [[ $? == 0 ]] ; then
            echo "Need clang++ version >= 0.0"
            exit 1
        fi
    elif [[ "$CXX_COMPILER" == "clang++" ]] ; then
        VERSION=$(clang++ -v 2>&1 | grep "clang version" | cut -d' ' -f3 )
        echo "clang version $VERSION"
        testvercomp $VERSION 3.3 '<'
        if [[ $? == 0 ]] ; then
            echo "Need clang++ version >= 3.3"
            exit 1
        fi
    elif [[ "$CXX_COMPILER" == "icpc" ]] ; then
        VERSION=$(icpc -v 2>&1 | grep "icpc version" | cut -d' ' -f3 )
        if [[ $VERSION == "" ]] ; then
            VERSION=$(icpc -v 2>&1 | grep "icpc.orig version" | cut -d' ' -f3 )
        fi
        echo "icpc version $VERSION"
        testvercomp $VERSION 14.0 '<'
        if [[ $? == 0 ]] ; then
            echo "Need icpc version >= 14.0"
            exit 1
        fi
    fi
}

# --------------------------------------------------------------------------- #
#   checking opengl context creation (minimum required is 3.2)
# --------------------------------------------------------------------------- #

function check_opengl_context()
{
    # Check if we can create a 3.2 context with system gl
    echo "#include <GL/gl.h>" >> checkogl.cpp
    echo "#include <GL/glx.h>" >> checkogl.cpp
    echo "#include <cstring>" >> checkogl.cpp
    echo "#include <cstdlib>" >> checkogl.cpp
    echo "#define GLX_CONTEXT_MAJOR_VERSION_ARB       0x2091" >> checkogl.cpp
    echo "#define GLX_CONTEXT_MINOR_VERSION_ARB       0x2092" >> checkogl.cpp
    echo "typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);" >> checkogl.cpp
    echo "static bool isExtensionSupported(const char *extList, const char *extension) {" >> checkogl.cpp
    echo "  const char *start;" >> checkogl.cpp
    echo "  const char *where, *terminator;" >> checkogl.cpp
    echo "  where = strchr(extension, ' ');" >> checkogl.cpp
    echo "  if (where || *extension == '\0')" >> checkogl.cpp
    echo "    return false;" >> checkogl.cpp
    echo "  for (start=extList;;) {" >> checkogl.cpp
    echo "    where = strstr(start, extension);" >> checkogl.cpp
    echo "    if (!where)" >> checkogl.cpp
    echo "      break;" >> checkogl.cpp
    echo "    terminator = where + strlen(extension);" >> checkogl.cpp
    echo "    if ( where == start || *(where - 1) == ' ' )" >> checkogl.cpp
    echo "      if ( *terminator == ' ' || *terminator == '\0' )" >> checkogl.cpp
    echo "        return true;" >> checkogl.cpp
    echo "    start = terminator;" >> checkogl.cpp
    echo "  }" >> checkogl.cpp
    echo "  return false;" >> checkogl.cpp
    echo "}" >> checkogl.cpp
    echo "static bool ctxErrorOccurred = false;" >> checkogl.cpp
    echo "static int ctxErrorHandler( Display *dpy, XErrorEvent *ev )" >> checkogl.cpp
    echo "{" >> checkogl.cpp
    echo "    ctxErrorOccurred = true;" >> checkogl.cpp
    echo "    return 0;" >> checkogl.cpp
    echo "}" >> checkogl.cpp
    echo "int main(int argc, char* argv[])" >> checkogl.cpp
    echo "{" >> checkogl.cpp
    echo "  Display *display = XOpenDisplay(NULL);" >> checkogl.cpp
    echo "  if (!display)" >> checkogl.cpp
    echo " {" >> checkogl.cpp
    echo "    exit(1);" >> checkogl.cpp
    echo "  }" >> checkogl.cpp
    echo "  static int visual_attribs[] =" >> checkogl.cpp
    echo "    {" >> checkogl.cpp
    echo "      GLX_X_RENDERABLE    , True," >> checkogl.cpp
    echo "      GLX_DRAWABLE_TYPE   , GLX_WINDOW_BIT," >> checkogl.cpp
    echo "      GLX_RENDER_TYPE     , GLX_RGBA_BIT," >> checkogl.cpp
    echo "      GLX_X_VISUAL_TYPE   , GLX_TRUE_COLOR," >> checkogl.cpp
    echo "      GLX_RED_SIZE        , 8," >> checkogl.cpp
    echo "      GLX_GREEN_SIZE      , 8," >> checkogl.cpp
    echo "      GLX_BLUE_SIZE       , 8," >> checkogl.cpp
    echo "      GLX_ALPHA_SIZE      , 8," >> checkogl.cpp
    echo "      GLX_DEPTH_SIZE      , 24," >> checkogl.cpp
    echo "      GLX_STENCIL_SIZE    , 8," >> checkogl.cpp
    echo "      GLX_DOUBLEBUFFER    , True," >> checkogl.cpp
    echo "      //GLX_SAMPLE_BUFFERS  , 1," >> checkogl.cpp
    echo "      //GLX_SAMPLES         , 4," >> checkogl.cpp
    echo "      None" >> checkogl.cpp
    echo "    };" >> checkogl.cpp
    echo "  int glx_major, glx_minor;" >> checkogl.cpp
    echo "  if ( !glXQueryVersion( display, &glx_major, &glx_minor ) || ( ( glx_major == 1 ) && ( glx_minor < 3 ) ) || ( glx_major < 1 ) )" >> checkogl.cpp
    echo "  {" >> checkogl.cpp
    echo "    exit(1);" >> checkogl.cpp
    echo "  }" >> checkogl.cpp
    echo "  int fbcount;" >> checkogl.cpp
    echo "  GLXFBConfig* fbc = glXChooseFBConfig(display, DefaultScreen(display), visual_attribs, &fbcount);" >> checkogl.cpp
    echo "  if (!fbc)" >> checkogl.cpp
    echo "  {" >> checkogl.cpp
    echo "    exit(1);" >> checkogl.cpp
    echo "  }" >> checkogl.cpp
    echo "  int best_fbc = -1, worst_fbc = -1, best_num_samp = -1, worst_num_samp = 999;" >> checkogl.cpp
    echo "  int i;" >> checkogl.cpp
    echo "  for (i=0; i<fbcount; ++i)" >> checkogl.cpp
    echo "  {" >> checkogl.cpp
    echo "    XVisualInfo *vi = glXGetVisualFromFBConfig( display, fbc[i] );" >> checkogl.cpp
    echo "    if ( vi )" >> checkogl.cpp
    echo "    {" >> checkogl.cpp
    echo "      int samp_buf, samples;" >> checkogl.cpp
    echo "      glXGetFBConfigAttrib( display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf );" >> checkogl.cpp
    echo "      glXGetFBConfigAttrib( display, fbc[i], GLX_SAMPLES       , &samples  );" >> checkogl.cpp
    echo "      if ( best_fbc < 0 || samp_buf && samples > best_num_samp )" >> checkogl.cpp
    echo "        best_fbc = i, best_num_samp = samples;" >> checkogl.cpp
    echo "      if ( worst_fbc < 0 || !samp_buf || samples < worst_num_samp )" >> checkogl.cpp
    echo "        worst_fbc = i, worst_num_samp = samples;" >> checkogl.cpp
    echo "    }" >> checkogl.cpp
    echo "    XFree( vi );" >> checkogl.cpp
    echo "  }" >> checkogl.cpp
    echo "  GLXFBConfig bestFbc = fbc[ best_fbc ];" >> checkogl.cpp
    echo "  XFree( fbc );" >> checkogl.cpp
    echo "  XVisualInfo *vi = glXGetVisualFromFBConfig( display, bestFbc );" >> checkogl.cpp
    echo "  XSetWindowAttributes swa;" >> checkogl.cpp
    echo "  Colormap cmap;" >> checkogl.cpp
    echo "  swa.colormap = cmap = XCreateColormap( display, RootWindow( display, vi->screen ), vi->visual, AllocNone );" >> checkogl.cpp
    echo "  swa.background_pixmap = None ;" >> checkogl.cpp
    echo "  swa.border_pixel      = 0;" >> checkogl.cpp
    echo "  swa.event_mask        = StructureNotifyMask;" >> checkogl.cpp
    echo "  Window win = XCreateWindow( display, RootWindow( display, vi->screen ), 0, 0, 100, 100, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel|CWColormap|CWEventMask, &swa );" >> checkogl.cpp
    echo "  if ( !win )" >> checkogl.cpp
    echo "  {" >> checkogl.cpp
    echo "    exit(1);" >> checkogl.cpp
    echo " }" >> checkogl.cpp
    echo "  XFree( vi );" >> checkogl.cpp
    echo "  XStoreName( display, win, \"GL 3.0 Window\" );" >> checkogl.cpp
    echo "  XMapWindow( display, win );" >> checkogl.cpp
    echo "  const char *glxExts = glXQueryExtensionsString( display, DefaultScreen( display ) );" >> checkogl.cpp
    echo "  glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;" >> checkogl.cpp
    echo "  glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddressARB( (const GLubyte *) \"glXCreateContextAttribsARB\" );" >> checkogl.cpp
    echo "  GLXContext ctx = 0;" >> checkogl.cpp
    echo "  ctxErrorOccurred = false;" >> checkogl.cpp
    echo "  int (*oldHandler)(Display*, XErrorEvent*) = XSetErrorHandler(&ctxErrorHandler);" >> checkogl.cpp
    echo "  if ( !isExtensionSupported( glxExts, \"GLX_ARB_create_context\" ) || !glXCreateContextAttribsARB )" >> checkogl.cpp
    echo "  {" >> checkogl.cpp
    echo "      exit(1);" >> checkogl.cpp
    echo "  }" >> checkogl.cpp
    echo "  else" >> checkogl.cpp
    echo "  {" >> checkogl.cpp
    echo "    int context_attribs[] =" >> checkogl.cpp
    echo "      {" >> checkogl.cpp
    echo "        GLX_CONTEXT_MAJOR_VERSION_ARB, 3," >> checkogl.cpp
    echo "        GLX_CONTEXT_MINOR_VERSION_ARB, 2," >> checkogl.cpp
    echo "        //GLX_CONTEXT_FLAGS_ARB        , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB," >> checkogl.cpp
    echo "        None};" >> checkogl.cpp
    echo "    ctx = glXCreateContextAttribsARB( display, bestFbc, 0, True, context_attribs );" >> checkogl.cpp
    echo "    XSync( display, False );" >> checkogl.cpp
    echo "    if ( ctxErrorOccurred || !ctx ){" >> checkogl.cpp
    echo "        exit(1);" >> checkogl.cpp
    echo "    }" >> checkogl.cpp
    echo "  }" >> checkogl.cpp
    echo "  XCloseDisplay( display );" >> checkogl.cpp
    echo "  return 0;" >> checkogl.cpp
    echo "}" >> checkogl.cpp

    $CXX_COMPILER checkogl.cpp -Wl,-lGL -lSM -lICE -lX11 -lXext
    if [[ $? != 0 ]]; then
        echo "failed to compile checkogl.cpp"
        rm -f checkogl.cpp
        rm -f a.out
        exit 1
    fi
    ./a.out
    if [[ $? != 0 ]]; then
        echo "Could not obtain a 3.2 context with system GL."
        echo "You may want to add --mesagl to the command line."
        echo "To disable this check use --skip-opengl-context-check"
        rm -f checkogl.cpp
        rm -f a.out
        exit 1
    fi
    rm -f checkogl.cpp
    rm -f a.out
}

# ************************************************************************** #
#                       Section 1, setting up inputs                          #
# --------------------------------------------------------------------------- #
# This section sets up the inputs to the VisIt script.  This is where you can #
# specify which compiler to use, which versions of the third party libraries, #
# etc.  Note that this script is really only known to work with gcc.          #
# *************************************************************************** #

function initialize_build_visit()
{
    # This env. variable is NOT to be overriden by user. It is intended to
    # contain user's env. just prior to running build_visit.
    export BUILD_VISIT_ENV=$(env | cut -d'=' -f1 | sort | uniq)

    # allow users to set an external hostname for output filename
    export EXTERNAL_HOSTNAME=""

    # Can cause problems in some build systems.
    unset CDPATH

    # Some systems tar command does not support the deep directory hierarchies
    # used in Qt, such as AIX. Gnu tar is a good alternative.
    ### export TAR=/usr/local/bin/tar # Up and Purple
    export TAR=tar

    #
    # we have logic that assumes lib dirs are named "lib", not "lib64". On
    # openSuSe some of the autoconf based 3rd party libs will install to "lib64"
    # unless the "CONFIG_SITE" env var is cleared
    #
    export CONFIG_SITE=""

    # Determine if gfortran is present. This overly complex coding is to prevent
    # the "which" command from echoing failure to the user.
    which gfortran >& /dev/null
    if [[ $? == 0 ]]; then
        export GFORTRAN=`which gfortran | grep '^/'`
    else
        export GFORTRAN=""
    fi

    export OPSYS=${OPSYS:-$(uname -s)}
    export PROC=${PROC:-$(uname -p)}
    export REL=${REL:-$(uname -r)}
    # Determine architecture
    if [[ "$OPSYS" == "Darwin" ]]; then
        export ARCH=${ARCH:-"${PROC}-apple-darwin${REL%%.*}"}
        #  export VISITARCH=${VISITARCH-${ARCH}}
        export SO_EXT="dylib"
        VER=$(uname -r)
        # Check for Panther, because MACOSX_DEPLOYMENT_TARGET will
        # default to 10.1

        # Used http://en.wikipedia.org/wiki/Darwin_(operating_system)
        # to map Darwin Kernel versions to OSX version numbers.  Other
        # options for dealing with MACOSX_DEPLOYMENT_TARGET didn't
        # work See issue #1499 (https://visitbugs.ornl.gov/issues/1499)

        # use gcc for 10.9 & earlier

	VER_MAJOR=${VER%%.*}

	# bash script educational note:
	# The less than sign "<" is an arithmetic expression and
	# as such one must use parenthesis (( .. )) and not square brackets.
	# i.e. if (( ${VER_MAJOR} < 8 )) ; then

	# Square brackets are for contionals only. To make it a
	# conditional one must use "-lt"
        # i.e. if [[ ${VER_MAJOR} -lt 8 ]] ; then

        if [[ ${VER_MAJOR} -lt 8 ]] ; then
            export MACOSX_DEPLOYMENT_TARGET=10.3
        elif [[ ${VER_MAJOR} == 8 ]] ; then
            export MACOSX_DEPLOYMENT_TARGET=10.4
        elif [[ ${VER_MAJOR} == 9 ]] ; then
            export MACOSX_DEPLOYMENT_TARGET=10.5
        elif [[ ${VER_MAJOR} == 10 ]] ; then
            export MACOSX_DEPLOYMENT_TARGET=10.6
        elif [[ ${VER_MAJOR} == 11 ]] ; then
            export MACOSX_DEPLOYMENT_TARGET=10.7
        elif [[ ${VER_MAJOR} == 12 ]] ; then
            export MACOSX_DEPLOYMENT_TARGET=10.8
        elif [[ ${VER_MAJOR} == 13 ]] ; then
            export MACOSX_DEPLOYMENT_TARGET=10.9
            export C_COMPILER=${C_COMPILER:-"clang"}
            export CXX_COMPILER=${CXX_COMPILER:-"clang++"}
        elif [[ ${VER_MAJOR} == 14 ]] ; then
            export MACOSX_DEPLOYMENT_TARGET=10.10
            export C_COMPILER=${C_COMPILER:-"clang"}
            export CXX_COMPILER=${CXX_COMPILER:-"clang++"}
        elif [[ ${VER_MAJOR} == 15 ]] ; then
            export MACOSX_DEPLOYMENT_TARGET=10.11
            export C_COMPILER=${C_COMPILER:-"clang"}
            export CXX_COMPILER=${CXX_COMPILER:-"clang++"}
        elif [[ ${VER_MAJOR} == 16 ]] ; then
            export MACOSX_DEPLOYMENT_TARGET=10.12
            export C_COMPILER=${C_COMPILER:-"clang"}
            export CXX_COMPILER=${CXX_COMPILER:-"clang++"}
        elif [[ ${VER_MAJOR} == 17 ]] ; then
            export MACOSX_DEPLOYMENT_TARGET=10.13
            export C_COMPILER=${C_COMPILER:-"clang"}
            export CXX_COMPILER=${CXX_COMPILER:-"clang++"}
        else
            export MACOSX_DEPLOYMENT_TARGET=10.13
            export C_COMPILER=${C_COMPILER:-"clang"}
            export CXX_COMPILER=${CXX_COMPILER:-"clang++"}
        fi

        export C_COMPILER=${C_COMPILER:-"gcc"}
        export CXX_COMPILER=${CXX_COMPILER:-"g++"}
        export FC_COMPILER=${FC_COMPILER:-$GFORTRAN}
        export C_OPT_FLAGS=${C_OPT_FLAGS:-"-O2"}
        export CFLAGS=${CFLAGS:-"-fno-common -fexceptions"}
        export CXX_OPT_FLAGS=${CXX_OPT_FLAGS:-"-O2"}
        export CXXFLAGS=${CXXFLAGS:-"-fno-common -fexceptions"}
        export FCFLAGS=${FCFLAGS:-$CFLAGS}
        export MESA_TARGET=${MESA_TARGET:-"darwin"}

    elif [[ "$OPSYS" == "Linux" ]]; then
        export ARCH=${ARCH:-"linux-$(uname -m)"} # You can change this to say RHEL, SuSE, Fedora.
        export SO_EXT="so"
        if [[ "$(uname -m)" == "i386" ]] ; then
            ###   export MESA_TARGET=${MESA_TARGET:-"linux-x86"} # Mesa-6.x
            export MESA_TARGET=${MESA_TARGET:-"linux"}
        elif [[ "$(uname -m)" == "i686" ]] ; then
            ###   export MESA_TARGET=${MESA_TARGET:-"linux-x86"} # Mesa-6.x
            export MESA_TARGET=${MESA_TARGET:-"linux"}
        elif [[ "$(uname -m)" == "x86_64" ]] ; then
            CFLAGS="$CFLAGS -m64 -fPIC"
            FCFLAGS="$FCFLAGS -m64 -fPIC"
            if [[ "$C_COMPILER" == "gcc" || "$C_COMPILER" == "" ]]; then
                C_OPT_FLAGS="$C_OPT_FLAGS -O2"
            fi
            CXXFLAGS="$CXXFLAGS -m64 -fPIC"
            if [[ "$CXX_COMPILER" == "g++" || "$CXX_COMPILER" == "" ]]; then
                CXX_OPT_FLAGS="$CXX_OPT_FLAGS -O2"
            fi
            ###   export MESA_TARGET=${MESA_TARGET:-"linux-x86-64"} # Mesa-6.x
            export MESA_TARGET=${MESA_TARGET:-"linux"}
        elif [[ "$(uname -m)" == "ppc64" ]] ; then
            if [[ "$C_COMPILER" == "xlc" ]] ; then
                CFLAGS="$CFLAGS -qpic"
                FCFLAGS="$FCFLAGS -qpic"
                CXXFLAGS="$CXXFLAGS -qpic"
                export CXX_COMPILER=${CXX_COMPILER-"xlC"}
                export MESA_TARGET=${MESA_TARGET-"linux"}
            elif [[ "$C_COMPILER" == "bgxlc" ]] ; then
                export CXX_COMPILER=${CXX_COMPILER-"bgxlC"}
            else
                CFLAGS="$CFLAGS -fPIC"
                FCFLAGS="$FCFLAGS -fPIC"
                if [[ "$C_COMPILER" == "gcc" || "$C_COMPILER" == "" ]]; then
                    C_OPT_FLAGS="$C_OPT_FLAGS -O2"
                fi
                CXXFLAGS="$CXXFLAGS -fPIC"
                if [[ "$CXX_COMPILER" == "g++" || "$CXX_COMPILER" == "" ]]; then
                    CXX_OPT_FLAGS="$CXX_OPT_FLAGS -O2"
                fi
                export MESA_TARGET=${MESA_TARGET-"linux"}
            fi
        elif [[ "$(uname -m)" == "ppc64le" ]] ; then
            if [[ "$C_COMPILER" == "xlc" ]] ; then
                CFLAGS="$CFLAGS -qpic"
                FCFLAGS="$FCFLAGS -qpic"
                CXXFLAGS="$CXXFLAGS -qpic"
                export CXX_COMPILER=${CXX_COMPILER-"xlC"}
                export MESA_TARGET=${MESA_TARGET-"linux"}
                QT_PLATFORM="linux-xlc" #aix-xlc"
            else
                CFLAGS="$CFLAGS -fPIC"
                FCFLAGS="$FCFLAGS -fPIC"
                if [[ "$C_COMPILER" == "gcc" || "$C_COMPILER" == "" ]]; then
                    C_OPT_FLAGS="$C_OPT_FLAGS -O2"
                fi
                CXXFLAGS="$CXXFLAGS -fPIC"
                if [[ "$CXX_COMPILER" == "g++" || "$CXX_COMPILER" == "" ]]; then
                    CXX_OPT_FLAGS="$CXX_OPT_FLAGS -O2"
                fi
                export MESA_TARGET=${MESA_TARGET-"linux"}
                QT_PLATFORM="linux-g++"
            fi
        elif [[ "$(uname -m)" == "ia64" ]] ; then
            CFLAGS="$CFLAGS -fPIC"
            FCFLAGS="$FCFLAGS -fPIC"
            if [[ "$C_COMPILER" == "gcc" || "$C_COMPILER" == "" ]]; then
                C_OPT_FLAGS="$C_OPT_FLAGS -O2"
            fi
            CXXFLAGS="$CXXFLAGS -fPIC"
            if [[ "$CXX_COMPILER" == "g++" || "$CXX_COMPILER" == "" ]]; then
                CXX_OPT_FLAGS="$CXX_OPT_FLAGS -O2"
            fi
        fi
        export C_COMPILER=${C_COMPILER:-"gcc"}
        export CXX_COMPILER=${CXX_COMPILER:-"g++"}
        export FC_COMPILER=${FC_COMPILER:-$GFORTRAN}
        export C_OPT_FLAGS=${C_OPT_FLAGS:-"-O2"}
        export CXX_OPT_FLAGS=${CXX_OPT_FLAGS:-"-O2"}
        export MESA_TARGET=${MESA_TARGET:-"linux"}
    elif [[ "$OPSYS" == "AIX" ]]; then
        export ARCH="aix" # You can change this to say RHEL, SuSE, Fedora, etc.
        export SO_EXT="a"
        export C_COMPILER=${C_COMPILER:-"xlc"}
        export FC_COMPILER=${FC_COMPILER:-$(which xlf | grep '^/')}
        export CXX_COMPILER=${CXX_COMPILER:-"xlC"}
        export C_OPT_FLAGS=${C_OPT_FLAGS:-"-O2"}
        export CXX_OPT_FLAGS=${CXX_OPT_FLAGS:-"-O2"}
        export MAKE=${MAKE:-"gmake"}
        export MESA_TARGET=${MESA_TARGET:-"aix"}
    elif [[ "$OPSYS" == "IRIX64" ]]; then
        export ARCH="irix64" # You can change this to say RHEL, SuSE, Fedora, etc.
        export SO_EXT="so"
        export C_COMPILER=${C_COMPILER:-"gcc"}
        export FC_COMPILER=${FC_COMPILER:-$GFORTRAN}
        export CXX_COMPILER=${CXX_COMPILER:-"g++"}
        export C_OPT_FLAGS=${C_OPT_FLAGS:-"-O2"}
        export CXX_OPT_FLAGS=${CXX_OPT_FLAGS:-"-O2"}
        export MAKE=${MAKE:-"gmake"}
        export MESA_TARGET=${MESA_TARGET:-"irix6-64-dso"}
    elif [[ "$OPSYS" == "SunOS" ]]; then
        export ARCH=${ARCH:-"sunos5"}
        export SO_EXT="so"
        export C_COMPILER=${C_COMPILER:-"gcc"}
        export FC_COMPILER=${FC_COMPILER:-$GFORTRAN}
        export CXX_COMPILER=${CXX_COMPILER:-"g++"}
        export C_OPT_FLAGS=${C_OPT_FLAGS:-"-O2"}
        export CXX_OPT_FLAGS=${CXX_OPT_FLAGS:-"-O2"}
        export MAKE=${MAKE:-"make"}
        export MESA_TARGET=${MESA_TARGET:-"sunos5-gcc"}
    else
        export ARCH=${ARCH:-"linux-$(uname -m)"} # You can change this to say RHEL, SuSE, Fedora.
        export SO_EXT="so"
        if [[ "$(uname -m)" == "x86_64" ]] ; then
            CFLAGS="$CFLAGS -m64 -fPIC"
            FCFLAGS="$FCFLAGS -m64 -fPIC"
            if [[ "$C_COMPILER" == "gcc" || "$C_COMPILER" == "" ]]; then
                C_OPT_FLAGS="$C_OPT_FLAGS -O2"
            fi
            CXXFLAGS="$CXXFLAGS -m64 -fPIC"
            if [[ "$CXX_COMPILER" == "g++" || "$CXX_COMPILER" == "" ]]; then
                CXX_OPT_FLAGS="$CXX_OPT_FLAGS -O2"
            fi
        fi
        if [[ "$(uname -m)" == "ia64" ]] ; then
            CFLAGS="$CFLAGS -fPIC"
            FCFLAGS="$FCFLAGS -fPIC"
            if [[ "$C_COMPILER" == "gcc" || "$C_COMPILER" == "" ]]; then
                C_OPT_FLAGS="$C_OPT_FLAGS -O2"
            fi
            CXXFLAGS="$CXXFLAGS -fPIC"
            if [[ "$CXX_COMPILER" == "g++" || "$CXX_COMPILER" == "" ]]; then
                CXX_OPT_FLAGS="$CXX_OPT_FLAGS -O2"
            fi
        fi
        export C_COMPILER=${C_COMPILER:-"gcc"}
        export FC_COMPILER=${FC_COMPILER:-$GFORTRAN}
        export CXX_COMPILER=${CXX_COMPILER:-"g++"}
        export C_OPT_FLAGS=${C_OPT_FLAGS:-"-O2"}
        export CXX_OPT_FLAGS=${CXX_OPT_FLAGS:-"-O2"}
    fi

    export MAKE=${MAKE:-"make"}
    export THIRD_PARTY_PATH=${THIRD_PARTY_PATH:-"./third_party"}
    export GROUP=${GROUP:-"visit"}
    #export LOG_FILE=${LOG_FILE:-"${0##*/}_log"}
    export GITREVISION=${GITREVISION:-"HEAD"}
    # Created a temporary value because the user can override most of
    # the components, which for the GUI happens at a later time.
    # the tmp value is useful for user feedback.
    if [[ $VISITARCH == "" ]] ; then
        export VISITARCHTMP=${ARCH}_${C_COMPILER}
        if [[ "$CXX_COMPILER" == "g++" ]] ; then
            VERSION=$(g++ -v 2>&1 | grep "gcc version" | cut -d' ' -f3 | cut -d'.' -f1-2)
            if [[ ${#VERSION} == 3 ]] ; then
                VISITARCHTMP=${VISITARCHTMP}-${VERSION}
            fi
        fi
    else
        # use environment variable value
        export VISITARCHTMP=$VISITARCH
    fi

    REDIRECT_ACTIVE="no"
    ANY_ERRORS="no"

    #initialize VisIt
    bv_visit_initialize

    #
    # OPTIONS
    #
    #initialize required libraries..

    for (( bv_i=0; bv_i<${#reqlibs[*]}; ++bv_i ))
    do
        initializeFunc="bv_${reqlibs[$bv_i]}_initialize"
        $initializeFunc
    done

    for (( bv_i=0; bv_i<${#optlibs[*]}; ++bv_i ))
    do
        initializeFunc="bv_${optlibs[$bv_i]}_initialize"
        $initializeFunc
    done

    export DO_HOSTCONF="yes"
    export DO_QT_SILENT="yes"

    export DO_DEBUG="no"
    export DO_GROUP="no"
    export DO_LOG="no"
    parallel="no"
    export DO_GIT="no"
    export DO_GIT_ANON="no"
    export DO_REVISION="no"
    USE_VISIT_FILE="no"
    export DO_PATH="no"
    export DO_VERSION="no"
    export DO_VERBOSE="no"
    export DO_JAVA="no"
    export DO_FORTRAN="no"
    export DO_PARADIS="no"
    export PREVENT_ICET="no"
    verify="no"
    export DO_OPTIONAL="yes"
    export DO_OPTIONAL2="no"
    export DO_MORE="no"
    export DO_DBIO_ONLY="no"
    export DO_ENGINE_ONLY="no"
    export DO_SERVER_COMPONENTS_ONLY="no"
    export DO_STATIC_BUILD="no"
    export DO_THREAD_BUILD="no"
    export USE_VISIBILITY_HIDDEN="no"
    export VISIT_INSTALL_PREFIX=""
    export VISIT_BUILD_MODE="Release"
    export VISIT_SELECTED_DATABASE_PLUGINS=""
    export DO_XDB="no"
    export CREATE_RPM="no"
    export DO_CONTEXT_CHECK="yes"
    export VISIT_INSTALL_NETWORK=""
    DOWNLOAD_ONLY="no"

    if [[ "$CXX_COMPILER" == "g++" ]] ; then
        VERSION=$(g++ -v 2>&1 | grep "gcc version" | cut -d' ' -f3 | cut -d'.' -f1-1)
        if [[ ${VERSION} -ge 4 ]] ; then
            export USE_VISIBILITY_HIDDEN="yes"
        fi
    fi

    # Setup git path
    export GIT_ANON_ROOT_PATH="http://github.com/visit-dav/visit.git"
    export GIT_REPO_ROOT_PATH="ssh://git@github.com/visit-dav/visit.git"

    if [[ "$OPSYS" != "Darwin" ]]; then
        WGET_MINOR_VERSION=$(wget --version| head -n 1|cut -d. -f 2)
        # version 1.7 pre-dates ssl integration
        if [[ "${WGET_MINOR_VERSION}" == "8" ]] ; then
            export WGET_OPTS=${WGET_OPTS=""}
        elif [[ "${WGET_MINOR_VERSION}" == "9" ]] ; then
            export WGET_OPTS=${WGET_OPTS:="--sslcheckcert=0"}
        else
            export WGET_OPTS=${WGET_OPTS:-"--no-check-certificate"}
        fi
    fi

    #get visit information..
    bv_visit_info

    #
    # TARBALL LOCATIONS AND VERSIONS
    #
    if [[ "$VISIT_FILE" != "" ]] ; then
        USE_VISIT_FILE="yes"
    fi
    export VISIT_FILE=${VISIT_FILE:-"visit${VISIT_VERSION}.tar.gz"}

    for (( bv_i=0; bv_i<${#reqlibs[*]}; ++bv_i ))
    do
        initializeFunc="bv_${reqlibs[$bv_i]}_info"
        $initializeFunc
    done

    for (( bv_i=0; bv_i<${#optlibs[*]}; ++bv_i ))
    do
        initializeFunc="bv_${optlibs[$bv_i]}_info"
        $initializeFunc
    done

    WRITE_UNIFIED_FILE=""
    VISIT_INSTALLATION_BUILD_DIR=""
    VISIT_DRY_RUN="no"
    DO_SUPER_BUILD="no"
    DO_MANGLED_LIBRARIES="no"
}

# *************************************************************************** #
# Function: starts_with_quote                                                 #
#                                                                             #
# Purpose: Meant to be used in `if $(starts_with_quote "$var") ; then`        #
#          conditionals.                                                      #
#                                                                             #
# Programmer: <NAME>                                                       #
# Date: Thu Oct  9 15:24:04 MDT 2008                                          #
#                                                                             #
# *************************************************************************** #

function starts_with_quote
{
    if test "${1:0:1}" = "\""; then #"
        return 0
    fi
    if test "${1:0:1}" = "'" ; then
        return 0
    fi
    return 1
}

# *************************************************************************** #
# Function: ends_with_quote                                                   #
#                                                                             #
# Purpose: Meant to be used `if $(ends_with_quote "$var") ; then`             #
#          conditionals.                                                      #
#                                                                             #
# Programmer: <NAME>                                                       #
# Date: Thu Oct  9 15:24:13 MDT 2008                                          #
#                                                                             #
# *************************************************************************** #

function ends_with_quote
{
    if test "${1: -1:1}" = "\""; then #"
        return 0
    fi
    if test "${1: -1:1}" = "'"; then
        return 0
    fi
    return 1
}

# *************************************************************************** #
# Function: strip_quotes                                                      #
#                                                                             #
# Purpose: Removes all quotes from the given argument.  Meant to be used in   #
#          $(strip_quotes "$some_string") expressions.                        #
#                                                                             #
# Programmer: <NAME>                                                       #
# Date: Thu Oct  9 16:04:25 MDT 2008                                          #
#                                                                             #
# *************************************************************************** #

function strip_quotes
{
    local arg="$@"
    str=""
    while test -n "$arg" ; do
        if test "${arg:0:1}" != "\"" ; then
            str="${str}${arg:0:1}"
        fi
        arg="${arg:1}"
    done
    echo "${str}"
}

function bv_enable_group
{
    local name=${1/--}
    local match=0

    for (( bv_i=0; bv_i < ${#grouplibs_name[*]}; ++bv_i ))
    do
        #replace | with space
        group_flag=${grouplibs_name[$bv_i]}
        group_flag=${group_flag//\|/ }
        for group in `echo $group_flag`;
        do
            if [[ "$group" == "$name" ]]; then
                echo "executing group $name"
                if [[ "$group" == "dbio-only" ]]; then
                    DO_DBIO_ONLY="yes"
                fi
                match=1
                for group_dep in `echo ${grouplibs_deps[$bv_i]}`;
                do
                    if [[ "$group_dep" == no-* ]]; then
                        group_dep=${group_dep/no-}
                        #info "disabling $group_dep"
                        initializeFunc="bv_${group_dep}_disable"
                        $initializeFunc
                    else
                        #info "enabling $group_dep"
                        initializeFunc="bv_${group_dep}_enable"
                        $initializeFunc
                    fi
                done
            fi
        done
    done

    return $match
}

function enable_dependent_libraries
{
    local depends_on=""

    for (( bv_i=0; bv_i<${#reqlibs[*]}; ++bv_i ))
    do
        $"bv_${reqlibs[$bv_i]}_is_enabled"

        #if not enabled then skip
        if [[ $? == 0 ]]; then
            continue
        fi

        #enabled library, check dependencies..
        depends_on=$("bv_${reqlibs[$bv_i]}_depends_on")

        #replace commas with spaces if there are any..
        depends_on=${depends_on//,/ }

        for depend_lib in `echo $depends_on`;
        do
            $"bv_${depend_lib}_is_enabled"
            if [[ $? == 0 ]]; then
                error "ERROR: library ${depend_lib} was not set ${reqlibs[$bv_i]} depends on it, please enable"
                #echo "library ${depend_lib} was not set but another library depends on it, enabling it"
                #$"bv_${depend_lib}_enable"
            fi
        done
    done

    for (( bv_i=0; bv_i<${#optlibs[*]}; ++bv_i ))
    do
        $"bv_${optlibs[$bv_i]}_is_enabled"

        #if not enabled then skip
        if [[ $? == 0 ]]; then
            continue
        fi

        #enabled library, check dependencies..
        depends_on=$("bv_${optlibs[$bv_i]}_depends_on")

        #replace commas with spaces if there are any..
        depends_on=${depends_on//,/ }

        for depend_lib in `echo $depends_on`;
        do
            $"bv_${depend_lib}_is_enabled"
            if [[ $? == 0 ]]; then
                error "ERROR: library ${depend_lib} was not set ${optlibs[$bv_i]} depends on it, please enable"
                echo "library ${depend_lib} was not set but another library depends on it, enabling it"
                $"bv_${depend_lib}_enable"
            fi
        done
    done
}

#TODO: enable this feature and remove this from ensure..
function initialize_module_variables
{
    info "initializing module variables"
    for (( bv_i=0; bv_i<${#reqlibs[*]}; ++bv_i ))
    do
        $"bv_${reqlibs[$bv_i]}_is_enabled"

        #if not enabled then skip
        if [[ $? == 0 ]]; then
            continue
        fi

        declare -F "bv_${reqlibs[$bv_i]}_initialize_vars" &>/dev/null

        if [[ $? == 0 ]]; then
            info "initialize module variables for ${reqlibs[$bv_i]}"
            $"bv_${reqlibs[$bv_i]}_initialize_vars"
        fi
    done

    for (( bv_i=0; bv_i<${#optlibs[*]}; ++bv_i ))
    do
        $"bv_${optlibs[$bv_i]}_is_enabled"

        #if not enabled then skip
        if [[ $? == 0 ]]; then
            continue
        fi

        declare -F "bv_${optlibs[$bv_i]}_initialize_vars" &>/dev/null

        if [[ $? == 0 ]]; then
            info "initialize module variables for ${optlibs[$bv_i]}"
            $"bv_${optlibs[$bv_i]}_initialize_vars"
        fi
    done
}

function build_library
{
    local build_lib=$1
    local depends_on=""

    #check if library is already installed..
    $"bv_${build_lib}_is_installed"

    if [[ $? == 1 ]]; then
        info "$build_lib is already installed, skipping"
        return
    fi

    #Make sure that the recursive enable feature is working properly
    $"bv_${build_lib}_is_enabled"

    if [[ $? == 0 ]]; then
        error "$build_lib was disabled, but seems that another library requires it "
    fi

    depends_on=$("bv_${build_lib}_depends_on")

    if [[ $depends_on != "" ]]; then
        info "library $build_lib depends on $depends_on"
    fi

    #replace commas with spaces if there are any..
    depends_on=${depends_on//,/ }

    for depend_lib in `echo $depends_on`;
    do
        build_library $depend_lib
    done

    #build ..
    $"bv_${build_lib}_build"
}

function build_libraries_serial
{
    info "building required libraries"
    for (( bv_i=0; bv_i<${#reqlibs[*]}; ++bv_i ))
    do
        $"bv_${reqlibs[$bv_i]}_is_enabled"

        if [[ $? == 0 ]]; then
            continue
        fi

        $"bv_${reqlibs[$bv_i]}_is_installed"

        if [[ $? == 0 ]]; then
            cd "$START_DIR"
            build_library ${reqlibs[$bv_i]}
        else
            info "${reqlibs[$bv_i]} already installed, skipping"
        fi
    done

    info "building optional libraries"
    for (( bv_i=0; bv_i<${#optlibs[*]}; ++bv_i ))
    do
        $"bv_${optlibs[$bv_i]}_is_enabled"

        if [[ $? == 0 ]]; then
            continue
        fi

        $"bv_${optlibs[$bv_i]}_is_installed"

        if [[ $? == 0 ]]; then
            cd "$START_DIR"
            build_library ${optlibs[$bv_i]}
        else
            info "${optlibs[$bv_i]} already installed, skipping"
        fi
    done
}

function build_libraries_parallel
{
    #launch all non dependent libraries in parallel..
    info "building parallel required libraries"
    for (( bv_i=0; bv_i<${#reqlibs[*]}; ++bv_i ))
    do
        $"bv_${reqlibs[$bv_i]}_is_enabled"

        if [[ $? == 0 ]]; then
            continue
        fi

        $"bv_${reqlibs[$bv_i]}_is_installed"
        if [[ $? == 0 ]]; then

            depends_on=$("bv_${reqlibs[$bv_i]}_depends_on")
            if [[ "$depends_on" == "" ]]; then
                (cd "$START_DIR" && build_library ${reqlibs[$bv_i]}) &
            fi
        else
            info "${reqlibs[$bv_i]} already installed, skipping"
        fi
    done

    wait

    #load the serial ones..
    for (( bv_i=0; bv_i<${#reqlibs[*]}; ++bv_i ))
    do
        $"bv_${reqlibs[$bv_i]}_is_enabled"

        if [[ $? == 0 ]]; then
            continue
        fi

        $"bv_${reqlibs[$bv_i]}_is_installed"

        if [[ $? == 0 ]]; then
            cd "$START_DIR"
            build_library ${reqlibs[$bv_i]}
        else
            info "${reqlibs[$bv_i]} already installed, skipping"
        fi
    done

    info "building parallel optional libraries"
    for (( bv_i=0; bv_i<${#optlibs[*]}; ++bv_i ))
    do
        $"bv_${optlibs[$bv_i]}_is_enabled"

        if [[ $? == 0 ]]; then
            continue
        fi
        $"bv_${optlibs[$bv_i]}_is_installed"
        if [[ $? == 0 ]]; then

            depends_on=$("bv_${optlibs[$bv_i]}_depends_on")
            if [[ "$depends_on" == "" ]]; then
                (cd "$START_DIR" && build_library ${optlibs[$bv_i]}) &
            fi
        else
            info "${optlibs[$bv_i]} already installed, skipping"
        fi
    done

    wait

    #load serial
    for (( bv_i=0; bv_i<${#optlibs[*]}; ++bv_i ))
    do
        $"bv_${optlibs[$bv_i]}_is_enabled"

        if [[ $? == 0 ]]; then
            continue
        fi

        $"bv_${optlibs[$bv_i]}_is_installed"

        if [[ $? == 0 ]]; then
            cd "$START_DIR"
            build_library ${optlibs[$bv_i]}
        else
            info "${optlibs[$bv_i]} already installed, skipping"
        fi
    done

}

# *************************************************************************** #
#                       Section 2, building VisIt                             #
# --------------------------------------------------------------------------- #
# This section does some set up for building VisIt, and then calls the        #
# functions to build the third party libraries and VisIt itself.              #
# *************************************************************************** #
function run_build_visit()
{
    declare -a arguments

    # Will be set if the next argument is an argument to an argument (I swear that
    # makes sense).  Make sure to unset it after pulling the argument!
    next_arg=""
    # If the user gives any deprecated options, we'll append command line options
    # we think they should use here.
    deprecated=""
    # A few options require us to perform some action before we start building
    # things, but we'd like to finish option parsing first.  We'll set this
    # variable in those cases, and test it when we finish parsing.
    next_action=""

    #handle groups first since they affect multiple libraries..
    for arg in "$@" ;
    do
        bv_enable_group "$arg"
        #not part of a group, add to argument list..
        if [[ $? == 0 ]]; then
            local match=0

            #suppress licenses from argument list
            for license in `echo $defaultLicenses`
            do
                if [[ "${arg/--}" == "$license" ]]; then
                    match=1
                    break
                fi
            done

            #suppress licenses as well..
            if [[ $match == 0 ]]; then
                arguments[${#arguments[*]}]="$arg"
            fi
        fi
    done

    for arg in "${arguments[@]}" ; do

        # Was the last option something that took an argument?
        if test -n "$next_arg" ; then
            # Yep.  Which option was it?
            case $next_arg in
                extra_commandline_arg) $EXTRA_COMMANDLINE_ARG_CALL "$arg";;
                visit-build-hostname) EXTERNAL_HOSTNAME="$arg";;
                installation-build-dir) VISIT_INSTALLATION_BUILD_DIR="$arg";;
                write-unified-file) WRITE_UNIFIED_FILE="$arg";;
                append-cflags) C_OPT_FLAGS="${C_OPT_FLAGS} ${arg}";;
                append-cxxflags) CXX_OPT_FLAGS="${CXX_OPT_FLAGS} ${arg}";;
                arch) VISITARCH="${arg}";;
                build-mode) VISIT_BUILD_MODE="${arg}";;
                cflags) C_OPT_FLAGS="${arg}";;
                cxxflags) CXX_OPT_FLAGS="${arg}";;
                cc) C_COMPILER="${arg}";;
                cxx) CXX_COMPILER="${arg}";;
                database-plugins) VISIT_SELECTED_DATABASE_PLUGINS="${arg}";;
                fc) FC_COMPILER="${arg}"; DO_FORTRAN="yes";;
                log-file) LOG_FILE="${arg}";;
                makeflags) MAKE_OPT_FLAGS="${arg}";;
                prefix) VISIT_INSTALL_PREFIX="${arg}";;
                install-network) VISIT_INSTALL_NETWORK="${arg}";;
                group) GROUP="${arg}";;
                git) GITREVISION="${arg}";;
                tarball) VISIT_FILE="${arg}";;
                thirdparty-path) THIRD_PARTY_PATH="${arg}";;
                version) VISIT_VERSION="${arg}"
                         VISIT_FILE="visit${VISIT_VERSION}.tar.gz";;
                *) error "Unknown next_arg value '$next_arg'!"
            esac
            # Make sure we process the next option as an option and not an
            # argument to an option.
            next_arg=""
            continue
        fi

        if [[ ${#arg} -gt 2 ]] ; then #has --

            #one module at a time
            resolve_arg=${arg:2} #remove --
            declare -F "bv_${resolve_arg}_enable" &>/dev/null

            if [[ $? == 0 ]] ; then
                #echo "enabling $resolve_arg"
                initializeFunc="bv_${resolve_arg}_enable"
                #argument is being explicitly set by the user so add a "force" flag
                $initializeFunc force
                continue
            elif [[ ${#resolve_arg} -gt 3 ]] ; then #in case it is --no-
                resolve_arg_no_opt=${resolve_arg:3}
                #disable library if it does not exist..
                declare -F "bv_${resolve_arg_no_opt}_disable" &>/dev/null
                if [[ $? == 0 ]] ; then
                    #echo "disabling ${resolve_arg_no_opt}"
                    initializeFunc="bv_${resolve_arg_no_opt}_disable"
                    $initializeFunc
                    #if disabling icet, prevent it as well
                    if [[ ${resolve_arg_no_opt} == "icet" ]]; then
                        echo "preventing icet from starting"
                        PREVENT_ICET="yes"
                    fi
                    continue
                fi
            fi

            #command line arguments created by modules
            #checking to see if additional command line arguments were requested
            resolve_arg=${arg:2} #remove --
            local match=0
            for (( bv_i=0; bv_i<${#extra_commandline_args[*]}; bv_i += 5 ))
            do
                local module_name=${extra_commandline_args[$bv_i]}
                local command=${extra_commandline_args[$bv_i+1]}
                local args=${extra_commandline_args[$bv_i+2]}
                local comment=${extra_commandline_args[$bv_i+3]}
                local fp=${extra_commandline_args[$bv_i+4]}
                if [[ "$command" == "$resolve_arg" ]]; then
                    if [ $args -eq 0 ] ; then
                        #call function immediately
                        $fp
                    else
                        #call function with next argument
                        next_arg="extra_commandline_arg"
                        EXTRA_COMMANDLINE_ARG_CALL="$fp"
                    fi
                    match=1
                    break;
                fi
            done

            #found a match in the modules..
            if [[ $match -eq 1 ]]; then
                continue
            fi
        fi

        case $arg in
            --visit-build-hostname) next_arg="visit-build-hostname";;
            --installation-build-dir) next_arg="installation-build-dir";;
            --write-unified-file) next_arg="write-unified-file";;
            --parallel-build) DO_SUPER_BUILD="yes";;
            --dry-run) VISIT_DRY_RUN="yes";;
            --arch) next_arg="arch";;
            --build-mode) next_arg="build-mode";;
            --cflag) next_arg="append-cflags";;
            --cflags) next_arg="cflags";;
            --cxxflag) next_arg="append-cxxflags";;
            --cxxflags) next_arg="cxxflags";;
            --cc) next_arg="cc";;
            --cxx) next_arg="cxx";;
            --create-rpm) CREATE_RPM="yes";;
            --log-file) next_arg="log-file";;
            --database-plugins) next_arg="database-plugins";;
            --debug) C_OPT_FLAGS="${C_OPT_FLAGS} -g"; CXX_OPT_FLAGS="${CXX_OPT_FLAGS} -g"; VISIT_BUILD_MODE="Debug";;
            --bv-debug) set -vx;;
            --download-only) DOWNLOAD_ONLY="yes";;
            --engine-only) DO_ENGINE_ONLY="yes";;
            --flags-debug) C_OPT_FLAGS="${C_OPT_FLAGS} -g"; CXX_OPT_FLAGS="${CXX_OPT_FLAGS} -g"; VISIT_BUILD_MODE="Debug";;
            --gdal) DO_GDAL="yes";;
            --fc) next_arg="fc";;
            --fortran) DO_FORTRAN="yes";;
            --group) next_arg="group"; DO_GROUP="yes";;
            -h|--help) next_action="help";;
            --install-network) next_arg="install-network";;
            --java) DO_JAVA="yes";;
            --makeflags) next_arg="makeflags";;
            --no-hostconf) DO_HOSTCONF="no";;
            --no-boost) DO_BOOST="no";;
            --no-qt-silent) DO_QT_SILENT="no";;
            --parallel) parallel="yes"; DO_ICET="yes";;
            --prefix) next_arg="prefix";;
            --print-vars) next_action="print-vars";;
            --server-components-only) DO_SERVER_COMPONENTS_ONLY="yes";;
            --paradis) DO_PARADIS="yes";;
            --static) DO_STATIC_BUILD="yes"
                      export USE_VISIBILITY_HIDDEN="no"
                      CXXFLAGS=$(echo $CXXFLAGS | sed "s/-fPIC//g")
                      CFLAGS=$(echo $CFLAGS | sed "s/-fPIC//g")
                      ;;
            --thread) DO_THREAD_BUILD="yes";;
            --stdout) LOG_FILE="/dev/tty";;
            --git) DO_GIT="yes"; export GIT_ROOT_PATH=$GIT_REPO_ROOT_PATH;;
            --git-anon) DO_GIT="yes"; DO_GIT_ANON="yes" ; export GIT_ROOT_PATH=$GIT_ANON_ROOT_PATH ;;
            --git-anonymous) DO_GIT="yes"; DO_GIT_ANON="yes" ; export GIT_ROOT_PATH=$GIT_ANON_ROOT_PATH ;;
            --git-revision) next_arg="git"; DO_GIT="yes"; DO_REVISION="yes"; DO_GIT_ANON="yes" ; export GIT_ROOT_PATH=$GIT_ANON_ROOT_PATH ;;
            --tarball) next_arg="tarball"
                       USE_VISIT_FILE="yes";;
            --thirdparty-path) next_arg="thirdparty-path";;
            --version) next_arg="version";;
            --xdb) DO_XDB="yes";;
            --console) ;;
            --skip-opengl-context-check) DO_CONTEXT_CHECK="no";;
            *)
                echo "Unrecognized option '${arg}'."
                ANY_ERRORS="yes";;
        esac
    done

    #error check to make sure that next arg is not left blank..
    if [[ $next_arg != "" ]] ; then
        echo "command line arguments are used incorrectly: argument $next_arg not fullfilled"
        exit 1
    fi

    if [[ "$ANY_ERRORS" == "yes" ]] ; then
        echo "command line arguments are used incorrectly. unrecognized options..."
        exit 1
    fi

    if test -n "${deprecated}" ; then
        summary="You are using some deprecated options to $0.  Please re-run"
        summary="${summary} $0 with a command line similar to:"
        echo "$summary"
        echo ""
        echo "$0 ${deprecated}"
        exit 1
    fi

    if test -n "${next_action}" ; then
        case ${next_action} in
            print-vars) printvariables; exit 2;;
            help) usage; exit 2;;
        esac
    fi

    #
    # Echo the current invocation command line to the log file
    #
    info "[build_visit invocation arguments] $@"

    #
    # Write a unified file
    #
    if [[ $WRITE_UNIFIED_FILE != "" ]] ; then
        bv_write_unified_file $WRITE_UNIFIED_FILE
        exit 0
    fi

    #
    # If we doing a trunk build then make sure we are using GIT
    #
    if [[ "$TRUNK_BUILD" == "yes" ]]; then
        if [[ "$DO_GIT" == "no" ]]; then
            DO_GIT="yes"
            DO_GIT_ANON="yes"
            export GIT_ROOT_PATH=$GIT_ANON_ROOT_PATH
        fi
    fi

    check_minimum_compiler_version

    if [[ "$OPSYS" != "Darwin" && $DO_MESAGL == "no" && $DO_CONTEXT_CHECK != "no"  && $DO_DBIO_ONLY == "no" ]] ; then
        if [[ $DO_VTK == "yes" || $DO_VISIT == "yes" ]] ; then
            check_opengl_context
        fi
    fi

    #
    # If we are AIX, make sure we are using GNU tar.
    #
    if [[ "$OPSYS" == "AIX" ]]; then
        TARVERSION=$($TAR --version >/dev/null 2>&1)
        if [[ $? != 0 ]] ; then
            echo "Error in build process. You are using the system tar on AIX."
            echo "Change the TAR variable in the script to the location of the"
            echo "GNU tar command."
            exit 1
        fi
    fi

    # Disable fortran support unless --fortran specified and a fortran compiler
    # was specified or found.
    if [[ $DO_FORTRAN == "no" || $FC_COMPILER == "" ]]; then
        export FC_COMPILER="no";
        warn "Fortran support for thirdparty libraries disabled."
    fi

    # make all VisIt related builds in its own directory..
    if [[ $VISIT_INSTALLATION_BUILD_DIR != "" ]] ; then
        if [[ -d $VISIT_INSTALLATION_BUILD_DIR ]]; then
            echo "Using already existing directory: $VISIT_INSTALLATION_BUILD_DIR"
        else
            mkdir -p $VISIT_INSTALLATION_BUILD_DIR
        fi

        if [[ ! -d $VISIT_INSTALLATION_BUILD_DIR ]]; then
            echo "Directory does not exist or I do not have permission to create it. Quitting"
            exit 0
        fi
        cd $VISIT_INSTALLATION_BUILD_DIR
    fi

    #
    # Log build_visit invocation w/ arguments & the start time.
    # Especially helpful if there are multiple starts dumped into the
    # same log.
    #
    LINES="------------------------------------------------------------"
    log $LINES
    log $0 $@
    log "Started:" $(date)
    log $LINES

    if [[ "$DO_GIT" == "yes" ]] ; then
        check_git_client
        if [[ $? != 0 ]]; then
            error "Fatal Error: GIT mode selected, but git client is not available."
        fi
    fi

    #enabling any dependent libraries, handles both dependers and dependees..
    #TODO: handle them seperately
    info "enabling any dependent libraries"
    enable_dependent_libraries

    # At this point we are after the command line and the visual selection
    # dry run, don't execute anything just run the enabled stuff..
    # happens before any downloads have taken place..
    if [[ $VISIT_DRY_RUN == "yes" ]]; then
        for (( bv_i=0; bv_i<${#reqlibs[*]}; ++bv_i ))
        do
            initializeFunc="bv_${reqlibs[$bv_i]}_dry_run"
            $initializeFunc
        done

        for (( bv_i=0; bv_i<${#optlibs[*]}; ++bv_i ))
        do
            initializeFunc="bv_${optlibs[$bv_i]}_dry_run"
            $initializeFunc
        done

        bv_visit_dry_run
        exit 0
    fi

    START_DIR="$PWD"

    if [[ "$DOWNLOAD_ONLY" == "no" ]] ; then
        if [[ ! -d "$THIRD_PARTY_PATH" ]] ; then
            if [[ "$THIRD_PARTY_PATH" == "./visit" ]] ; then
                mkdir "$THIRD_PARTY_PATH"
                if [[ $? != 0 ]] ; then
                    error "Unable to write files to the third party library location." \
                          "Bailing out."
                fi
            else
                info "The third party library location does not exist. Create it?"
                read RESPONSE
                if [[ "$RESPONSE" != "yes" ]] ; then
                    error "The third party library location does not exist." \
                          "Bailing out."
                else
                    mkdir "$THIRD_PARTY_PATH"
                    if [[ $? != 0 ]] ; then
                        error "Unable to write files to the third party library location." \
                              "Bailing out."
                    fi
                fi
            fi
        fi

        cd "$THIRD_PARTY_PATH"
        if [[ $? != 0 ]] ; then
            error "Unable to access the third party location. Bailing out."
        fi
    fi

    if [[ $VISITARCH == "" ]] ; then
        C_COMPILER_BASENAME=$(basename ${C_COMPILER})
        CXX_COMPILER_BASENAME=$(basename ${CXX_COMPILER})
        export VISITARCH=${ARCH}_${C_COMPILER_BASENAME}
        if [[ "$CXX_COMPILER_BASENAME" == "g++" ]] ; then
            VERSION=$(${CXX_COMPILER} -v 2>&1 | grep "gcc version" | cut -d' ' -f3 | cut -d'.' -f1-2)
            if [[ ${#VERSION} == 3 ]] ; then
                VISITARCH=${VISITARCH}-${VERSION}
            fi
        elif [[ "$CXX_COMPILER_BASENAME" == "icpc" ]] ; then
            VERSION=$(${CXX_COMPILER} --version | cut -d' ' -f3 | head -n1)
            VISITARCH=${VISITARCH}-${VERSION}
        fi
    fi

    export VISITDIR=${VISITDIR:-$(pwd)}
    cd "$START_DIR"

    #
    # See if the user wants to build a parallel version.
    #
    check_parallel
    if [[ $? != 0 ]] ; then
        error "Stopping build because necessary parallel options are not set."
    fi

    if [[ "$DO_ICET" == "yes" && "$PREVENT_ICET" != "yes" ]] ; then
        DO_CMAKE="yes"
    fi

    # initialize module variables, since all of VisIt's variables should
    # be set by now..
    initialize_module_variables

    #
    # Disable qt,qwt if it is not needed
    #
    if [[ "$DO_ENGINE_ONLY" == "yes" || "$DO_DBIO_ONLY" == "yes" || "$DO_SERVER_COMPONENTS_ONLY" == "yes" ]] ; then
        if [[ "$DO_ENGINE_ONLY" == "yes" ]] ; then
           info "disabling qt, qwt because --engine-only used"
        elif [[ "$DO_DBIO_ONLY" == "yes" ]] ; then
           info "disabling qt, qwt because --dbio-only used"
        elif [[ "$DO_SERVER_COMPONENTS_ONLY" == "yes" ]] ; then
           info "disabling qt, qwt because --server-components-only used"
        fi
        bv_qt_disable
        bv_qwt_disable
    fi

    #
    # Later we will build Qt.  We are going to bypass their licensing agreement,
    # so echo it here.
    #
    if [[ "$USE_SYSTEM_QT" != "yes" && "$DO_QT" == "yes" ]]; then
        BYPASS_QT_LICENSE="no"
        check_if_installed "qt" $QT_VERSION
        if [[ $? == 0 ]] ; then
            BYPASS_QT_LICENSE="yes"
        fi

        if [[ "$BYPASS_QT_LICENSE" == "no" && "$DOWNLOAD_ONLY" == "no" ]] ; then
            qt_license_prompt
            if [[ $? != 0 ]] ;then
                error "Qt4 Open Source Edition License Declined. Bailing out."
            fi
        fi
    fi

    #
    # Save stdout as stream 3, redirect stdout and stderr to the log file.
    # After this maks sure to use the info/warn/error functions to display
    # messages to the user
    #

    if [[ "${LOG_FILE}" != "/dev/tty" ]] ; then
        exec 3>&1 >> ${LOG_FILE} 2>&1
        REDIRECT_ACTIVE="yes"
    else
        exec 2>&1
    fi

    #
    #
    # Now make sure that we have everything we need to build VisIt, so we can bail
    # out early if we are headed for failure.
    #
    check_files
    if [[ $? != 0 ]] ; then
        error "Stopping build because necessary files aren't available."
    fi

    #
    # Exit if we were told to only download the files.
    #
    if [[ "$DOWNLOAD_ONLY" == "yes" ]] ; then
        info "Successfully downloaded the specified files."
        exit 0
    fi

    if [[ $DO_MANGLED_LIBRARIES == "yes" ]]; then
        info "Mangling libraries while building"
        info "Any libraries that support mangling will do so"
    fi

    if [[ "$DO_SUPER_BUILD" == "yes" ]]; then
        build_libraries_parallel
    else
        build_libraries_serial
    fi

    #
    # Create the host.conf file
    #

    if [[ "$DO_HOSTCONF" == "yes" ]] ; then
        info "Creating host.conf"
        build_hostconf
    fi

    #build visit itself..
    bv_visit_build
}


<filename>tests/misc/typecheck.sh
#!/bin/bash

# run tests with no retries
# this should expose, for example, the problem i'm seeing with
# 130-fmri failing once on my mac

export CF=swift.properties.no-retries

cd ../language-behaviour

swift -tc.file ./tc.data -typecheck 061-cattwo.swift
if [ "$?" -ne "0" ]; then echo "SWIFT RETURN CODE NON-ZERO"; exit 1; fi

swift -tc.file ./tc.data -typecheck 130-fmri.swift
if [ "$?" -ne "0" ]; then echo "SWIFT RETURN CODE NON-ZERO"; exit 1; fi


#!/bin/bash

source "install/common.sh"

if [ -z "$install_dir" ] || [ ! -d "$install_dir" ]; then
  echo "Install directory does not exist."
  exit 1
fi

for filename in ${script_manifest[@]}; do
  rm -i "$install_dir/$filename"
done

for filename in ${provides[@]}; do
  rm -i "$bin_dir/$filename"
done

rmdir $install_dir