#!/bin/csh -f
#
# gethere -- make a local copy of a system file and set up the Makefile
# to compile it locally


set pathname = $1
shift
set file = $1 
shift
set fileroot = $file:r

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

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

cp $pathname/$file .
if ($status) then
    echo Can not copy \"$pathname/$file\" to \"$file\"
    exit (2)
endif


#
# Edit the Makefile to indicate that the object file is compiled locally
#
cat > makeed$$ << theend
/PRIVOBJ =/ a\
\	\${HOW}/$fileroot.o \\\\
/PRIVSRC =/ a\
\	$file \\\\
theend
cp -p Makefile Makefile.bak
sed -f makeed$$ < Makefile > newMakefile
mv newMakefile Makefile
rm -f makeed$$
