#!/bin/csh -f
#
# compilehere -- make a symbolic link to 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

ln -s $pathname/$file .

#
# 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$$
