#
#   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 c-shell or from your
#   .login script.
#
#   Alternatively you may copy this script, remove the first if
#   statement and change the setting of the "here" 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  ||  ! -d dsolib  ||  ! -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
    if ( ! $?cwd ) set cwd=`/bin/pwd`
    set here=$cwd
    setenv HFS	$here

    #
    #  The following are some handy shortcuts:
    #
    setenv H	${HFS}
    setenv HB	${H}/bin
    setenv HDSO	${H}/dsolib
    setenv HD	${H}/demo
    setenv HH	${H}/houdini
    setenv HHC	${HH}/config
    setenv HT   ${H}/toolkit
    setenv HSB  ${HH}/sbin
    setenv 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.
    #
    setenv TEMP /tmp

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


    #
    #  Turn off any local character translation before looking at the
    #  output of the file command...
    #
    set save_lang=""
    if ( $?LANG ) then
	if ( "$LANG" != "C" ) then
	    set save_lang="$LANG"
	    setenv LANG "C"
	endif
    endif

    set f=`file $HDSO/libHoudiniUT.so`
    if ( $#f > 3  &&  $f[3] == "N32" ) then
	if ( $?LD_LIBRARYN32_PATH ) then
	    setenv LD_LIBRARYN32_PATH "${HDSO}:${LD_LIBRARYN32_PATH}"
	else
	    setenv LD_LIBRARYN32_PATH "${HDSO}:/usr/lib32:/lib32"
	endif
    else
	if ( $?LD_LIBRARY_PATH ) then
	    setenv LD_LIBRARY_PATH "${HDSO}:${LD_LIBRARY_PATH}"
	else
	    setenv LD_LIBRARY_PATH "${HDSO}:/usr/lib:/lib"
	endif
    endif
    set path=(${HB} ${HSB} $path)

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

    rehash

    if ( "$save_lang" != "" ) setenv LANG "$save_lang"

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

    if ( $?prompt && ( $#argv < 1 || $1 != "-q" ) ) then
	echo "The Houdini ${HOUDINI_VERSION} environment has been initialized."
    endif
endif
