#!/bin/csh -f

if (! $?SUIFHOME) then
	echo SUIFHOME variable not set
	exit 1
endif
if (! $?MACHINE) then
	echo MACHINE variable not set
	exit 1
endif

if (! -d $MACHINE) mkdir $MACHINE
if (! -d $MACHINE/lib) mkdir $MACHINE/lib
if (! -d auto_init_libs) mkdir auto_init_libs
if (! -d include) mkdir include
if (! -d $MACHINE/bin) mkdir $MACHINE/bin

if (! -d src) then
	mkdir src
endif

if (! -r Makefile) then
	ln -s $SUIFHOME/Makefile.local ./Makefile
	ln -s $SUIFHOME/Makefile.defs .
	ln -s $SUIFHOME/Makefile.sub .
	ln -s $SUIFHOME/Makefile.std .
	ln -s $SUIFHOME/Makefile.rules .
endif

cd $MACHINE

foreach i ($argv)
	if (-d $i) then
		echo $i already exists - leaving it alone
	else
		if (! -d $SUIFHOME/RCS/$i) then
			echo Directory $SUIFHOME/RCS/$i does not exist
		else
			mkdir $i
			mkdir ../src/$i
			ln -s $SUIFHOME/RCS/$i $i/RCS
			(cd $i; co -q Makefile)
			if ($i == suif) then
				ln -s . suif/suif
			endif
		endif
	endif
end
