#!/bin/csh -f
# copy-source dir target
if ($2 == "") then
  echo "Usage : $0 <current-dir> <target-dir>"
else if (! -d $2) then
  echo "$0 : no such directory '$2'"
else if (! -e $1/Makefile) then
  echo "$0 : no Makefile found in $1"
else
  cp $1/Makefile $2
  foreach file (`grep --max-count=1 SOURCES $1/Makefile`)
    if (-e $1/$file) then
      cp $1/$file $2
    endif
    if (-e "$1/$file"i) then
      cp "$1/$file"i $2
    endif
  end
endif
