#! /bin/sh

#
# Portions of this file Copyright 1999-2005 University of Chicago
# Portions of this file Copyright 1999-2005 The University of Southern California.
#
# This file or a portion of this file is licensed under the
# terms of the Globus Toolkit Public License, found at
# http://www.globus.org/toolkit/download/license.html.
# If you redistribute this file, with or without
# modifications, you must include this notice in the file.
#



#
# Displays the Globus version
#
# Synopsis: globus-version [-help] [-full] [-dirt]
#

set -f

#
#  We should really do something smart here instead of just hard coding
#  the version number. However, as it can not be determined by just looking
#  at the set of packages installed, nor be determined at build time,
#  we are stuck with this solution for a while. See 
#  http://bugzilla.globus.org/globus/show_bug.cgi?id=1723 for more
#  information about this.
#
GLOBUS_VERSION="4.0.8"
GLOBUS_FULL_VERSION="Globus Toolkit $GLOBUS_VERSION"

DIRT_TIMESTAMP="1217736000"
DIRT_BRANCH_ID="63"



usage()
{
    . ${GLOBUS_LOCATION}/libexec/globus-script-initializer
    globus_source ${libexecdir}/globus-sh-tools.sh

    ${GLOBUS_SH_CAT-cat} 1>&2 <<EOF

globus-version [-help] [-full] [-dirt]

    Displays the installed Globus version. Can also show the dirt
    timestamp and tag id.

    Options:
        -help        Shows help and exits
        -full        Show expanded version description
        -dirt        Shows dirt info and exits

    If no option is given, displays the Globus version.

EOF
}



case "$1" in
    -h|-help|-usage|--help)
        usage
        exit 0
        ;;
    -dirt)
        echo "$DIRT_TIMESTAMP-$DIRT_BRANCH_ID"
        exit 0
        ;;
    -full)
        echo $GLOBUS_FULL_VERSION
        exit 0
        ;;
    *)
        echo $GLOBUS_VERSION
        exit 0
        ;;
esac

