#!/bin/csh -f
#
# compileback -- A system file which was being compiled locally via
# a previous run of 'compilehere' is no longer to be compiled
# locally.

if ($#argv != 2) then
    set cmd = $0
    echo "usage: $cmd:t dir file"
    exit (1)
endif
set dir = $1
set file = $2 
set fileroot = $file:r

if (! -r $file) then
    echo "$file is not here"
    exit (2)
endif

rmlink $file

#
# remove the local .o file
#
set nonomatch
rm -f {DEBUG,OPTIMIZE}*/$fileroot.o
unset nonomatch

#
# edit the Makefile to indicate that this is no longer locally compiled
#
cat > makeed$$ << theend
/\\	\${HOW}\\/$fileroot.o \\\\/d
/\\	$file \\\\/d
theend
cp -p Makefile Makefile.bak
sed -f makeed$$ < Makefile > newMakefile
mv newMakefile Makefile
rm -f makeed$$
