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


FOR_INSTALL_DSTOOL:


if ( ! (-d $1) ) then
	echo "fix_for_no_fortran: Incorrect directory location, exiting ..."
	goto BAD_EXIT
else
	echo "Removing FORTRAN 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 '/^FORT/s/FORT/#FORT/;/^F_LIB/s/F_LIB/#F_LIB/;/^USING_FORT/s/USING_FORT/#USING_FORT/' lib_incl.mk.tmp > lib_incl.mk

rm -f lib_incl.mk.tmp

cd $1/src

mv -f Makefile Makefile.tmp

sed '/locbif/d' Makefile.tmp > Makefile

rm -f Makefile.tmp

exit(0)



FOR_INSTALL_DSUSER:

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


cd $2

mv -f Makefile Makefile.tmp

sed '/locbif/d;/lbfpanels/d;/lb_main/d' Makefile.tmp > Makefile

rm -f Makefile.tmp

exit(0)

BAD_EXIT:
	exit(1)
