#!/bin/csh -f
#Usage: fix_for_gcc 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_gcc: Unknown second argument, exiting ..."
	goto BAD_EXIT
endif
endif

FOR_INSTALL_DSTOOL:

if ( ! (-d $1) ) then
	echo "fix_for_gcc: Incorrect directory location, exiting ..."
	goto BAD_EXIT
else
	echo "Fixing site_specific/lib_incl.mk for gcc: "
endif

cd $1/site_specific

mv -f lib_incl.mk lib_incl.mk.tmp

sed '/^CC/s/cc/gcc/;/#USING_GCC/s/#USING/USING/' lib_incl.mk.tmp > lib_incl.mk


rm -f lib_incl.mk.tmp

exit(0)



FOR_INSTALL_DSUSER:

exit(0)

BAD_EXIT:
	exit(1)
