#!/bin/csh -f
set pathname = $1
shift
set file = $1 
shift
set fileroot = $file:r

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

if (-r $pathname/SCCS/s.$file) then
    sccs -d$pathname delta $file
    if ($status) then
	echo Can not sccs delta \"$file\"
	exit (2)
    endif

    (cd $pathname ; sccs get $file)
    if ($status) then
	echo Can not sccs get \"$file\" in \"$pathname\"
	exit (2)
    endif
else
    cp ./$file $pathname/$file
    if ($status) then
	echo Can not copy \"$file\" to \"$pathname/$file\"
	exit (2)
    endif
    rm ./$file
endif


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

cat > makeed$$ << theend
s;\./\${HOW}/$fileroot;$pathname/\${HOW}/$fileroot;
s;\./$file;$pathname/$file;
s;\./$fileroot ;$pathname/$fileroot ;
theend
cp -p Makefile Makefile.bak
sed -f makeed$$ < Makefile > newMakefile
mv newMakefile Makefile
rm -f makeed$$
