#! /bin/csh
# $Header: /usr/local/devel/postgres/OBS_newconf/RCS/MakeLinks,v 1.18 1991/07/23 18:35:28 hong Exp $

if (`hostname` == "hermes.Berkeley.EDU") set PARALLELMAKELINKS
if ("$1" == "-q") then
	set quiet = 1
	shift
else
	set quiet = 0
endif

set OD = $argv[1]
set SD = $argv[2]

if ($quiet == 0) echo "... Linking files from $SD to $OD"

foreach i (`cat dirs.mk`) 
	if ((-e $SD/$i/RCS) && ($i !~ lib/H* ) && ($i !~ lib/Gen*)) then 
		if ($quiet == 0) echo "***" $i
		pushd $SD/$i >& /dev/null
		set x = ( `echo *.{c,h,y,lex,sed,sh}` )
		popd  >& /dev/null
		pushd $OD/$i >& /dev/null
		if (  -z "$x" ) then
			echo "why an RCS directory with no srcfiles"
		else
			foreach j ( $x )
				if ( ! -f $j ) then
				    if ($?PARALLELMAKELINKS) then
					(ln -s $SD/$i/$j $j & )
				    else
					ln -s $SD/$i/$j $j
				    endif
				else
				endif
			end
		endif
		popd >& /dev/null
	endif
end
if ($?PARALLELMAKELINKS) wait
