#!/bin/csh -f

setenv USE_TCL_833 1

if ( -e "$ICEM_ACN/bin/wish8.4.11" ) then
    setenv TK_LIBRARY "$ICEM_ACN/lib/tk8.4.11"
    setenv TCL_LIBRARY "$ICEM_ACN/lib/tcl8.4.11"
    echo "Using tk8.4.11 / tcl8.4.11" 
    set bltwish = wish8.4.11
else
    if ( -e "$ICEM_ACN/bin/wish8.3.3" && $?USE_TCL_833 ) then

        setenv TK_LIBRARY "$ICEM_ACN/lib/tk8.3.3"
        setenv TCL_LIBRARY "$ICEM_ACN/lib/tcl8.3.3"
        echo "Using tk8.3.3 / tcl8.3.3" 
        set bltwish = wish8.3.3

    else
    
        setenv TK_LIBRARY "$ICEM_ACN/lib/tk8.0"
        setenv TCL_LIBRARY "$ICEM_ACN/lib/tcl8.0"
        setenv BLT_LIBRARY "$ICEM_ACN/lib/blt2.4"
        echo "Using tk8.0 / tcl8.0" 
        set bltwish = bltwish

    endif
endif

if ( -e "$ICEM_ACN/lib/hexa/guibase" ) then
      set guibase = "$ICEM_ACN/lib/hexa/guibase"
else
      set guibase = "$ICEM_ACN/lib/guibase"
endif

set tooldir = "$ICEM_ACN/lib/hexa"
if $?GUIBASE_DIR then
        set guibase = "$GUIBASE_DIR"
else
	setenv GUIBASE_DIR "$guibase"
endif
if $?HEXA_DIR then
        set tooldir = $HEXA_DIR
endif

# All this wierd quoting is needed to make it work with arguments that have
# spaces in them
set cmd = "'$ICEM_ACN/bin/$bltwish' -f '$guibase/guibase.tcl' -tool '$tooldir/hexa.tcl'"

foreach arg ( $* )
    set cmd = "$cmd '$arg'"
end

echo "running $cmd"
eval $cmd
