#
#   Environment setup script for Houdini.
#
#   To use this script you should "cd" to the hfs directory where this
#   script is located and "source" it into your bash shell or from your
#   .profile script.
#
#   Alternatively you may copy this script, remove the first if
#   statement and change the setting of the "HFS" variable to be
#   the location of your installed Houdini hfs directory.
#
#   Note that this script modifies your search path by inserting the
#   Houdini bin directory at the beginning. It also explicitly sets
#   the IRIX environment variable LD_LIBRARY_PATH which is used to
#   search for runtime libraries (see the IRIX man page rld(1) for
#   more information on this).
#
#   To run the script in quiet mode, specify the "-q" option on the
#   command line.
#
if [ ! -d houdini  -o  ! -d dsolib  -o  ! -d bin ]; then
    echo "You must cd to the Houdini installation directory before"
    echo "sourcing this script. This allows the script to determine"
    echo "the installed location."
else
    HFS=$PWD
    export HFS

    #
    #  The following are some handy shortcuts:
    #
    H=${HFS}
    HB=${H}/bin
    HDSO=${H}/dsolib
    HD=${H}/demo
    HH=${H}/houdini
    HHC=${HH}/config
    HT=${H}/toolkit
    HSB=${HH}/sbin
    HTB=${HT}/bin

    #
    #  The following is used as the generic /tmp path.  This is also
    # set on Windows to the temporary directory, so can be used for
    # system independent .hip files.
    #
    TEMP=/tmp
    export TEMP

    #
    # These environment variables are no longer supported.
    #
    HIH=${HOME}/houdini6.5
    # HIL=${HSITE}/houdini6.5
    HIS=$HH


    #
    #  Turn off any local character translation before looking at the
    #  output of the file command...
    #
    save_lang=""
    if [ "$LANG" != "" ]; then
	if [ "$LANG" != "C" ]; then
	    set save_lang="$LANG"
	    LANG="C"
	fi
    fi

    if [ `file $HDSO/libHoudiniUT.so | cut -d ' ' -f 2` = "N32" ]; then
	if [ "$LD_LIBRARYN32_PATH" != "" ]; then
	    LD_LIBRARYN32_PATH="${HDSO}:${LD_LIBRARYN32_PATH}"
	else
	    LD_LIBRARYN32_PATH="${HDSO}:/usr/lib32:/lib32"
	fi
	export LD_LIBRARYN32_PATH
    else
	if [ "$LD_LIBRARY_PATH" != "" ]; then
	    LD_LIBRARY_PATH="${HDSO}:${LD_LIBRARY_PATH}"
	else
	    LD_LIBRARY_PATH="${HDSO}:/usr/lib:/lib"
	fi
	export LD_LIBRARY_PATH
    fi
    PATH="${HB}:${HSB}:$PATH"
    export PATH

    #
    # HDK customers should replace the above line with this one:
    #
    # PATH="${HB}:${HSB}:${HTB}:$path"

    if [ "$save_lang" != "" ]; then
	LANG="$save_lang";
	unset save_lang
    fi

    HOUDINI_MAJOR_RELEASE=6
    HOUDINI_MINOR_RELEASE=5
    HOUDINI_BUILD_VERSION=67
    HOUDINI_VERSION=${HOUDINI_MAJOR_RELEASE}.${HOUDINI_MINOR_RELEASE}.${HOUDINI_BUILD_VERSION}

    if [ $?prompt ]; then
	if [ "$1" != "-q" ]; then
	    echo "The Houdini ${HOUDINI_VERSION} environment has been initialized."
	fi
    fi
fi
