#!/bin/csh -f
#
set link=()
foreach n ($*)
	if (-d $n) then
	echo Doing $n...
		mkdir $n:t
		cd $n:t
		if ($n =~ ../*) then
			set q=../$n
		else
			set q=$n
		endif
		set link1=()
		foreach m ($q/*)
			if (-d $m) then
				/mit/watchmaker/buildtree $m
			else
				set link1=($link1 $m)
			endif
		end
		if ($#link1) ln -s $link1 .
		cd ..
	echo Done $n.
	else
# Here is where other special cases can be inserted
#		if ($n:t == Makefile) then
#			echo Copying $n
#			cp $n .
#		else
			set link=($link $n)
#		endif
	endif
end
if ($#link) ln -s $link .
