#!/bin/csh -f
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 .

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

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