#!/bin/csh -f
#Usage: fix_for_no_tcl dstool_val top_makefile_locn calling_script_name

#The value of dstool_val will be the same as $DSTOOL in the calling script.

#The value of top_makefile_locn will typically be either $DSTOOL/src or
#the root directory of the user dstool heirarchy.

#The possible values of calling_script_name are:
#	install_dstool and install_dsuser

if ($3 == "install_dstool") then
	goto FOR_INSTALL_DSTOOL
else if ($3 == "install_dsuser") then
	goto FOR_INSTALL_DSUSER
else
	echo "fix_for_no_tcl: Unknown second argument, exiting ..."
	goto BAD_EXIT
endif
endif

FOR_INSTALL_DSTOOL:

if ( ! (-d $1) ) then
	echo "fix_for_no_tcl: Incorrect directory location, exiting ..."
	goto BAD_EXIT
else
	echo "Removing TCL references in: "
	echo "	site_specific/lib_incl.mk and src/Makefile..."
endif

cd $1/site_specific

mv -f lib_incl.mk lib_incl.mk.tmp

sed '/^TCL/s/TCL/#TCL/;/^USING_TCL/s/USING_TCL/#USING_TCL/' lib_incl.mk.tmp > lib_incl.mk

rm -f lib_incl.mk.tmp

cd $1/src

mv -f Makefile Makefile.tmp

sed '/tcllib/d;/tclwinlib/d' Makefile.tmp > Makefile

rm -f Makefile.tmp

exit(0)



FOR_INSTALL_DSUSER:

if ( ! (-d $1) ) then
	echo "fix_for_no_tcl: Incorrect directory location, exiting ..."
	goto BAD_EXIT
else
	echo "Removing TCL references in: "
	echo " Makefile..."
endif

cd $2

mv -f Makefile Makefile.tmp

sed '/tcllib/d;/tclwinlib/d' Makefile.tmp > Makefile

rm -f Makefile.tmp

exit(0)

BAD_EXIT:
	exit(1)
