# spc2sun
# script to copy the spc toolbox to the current directory on a sun
# workstation.  you should be in the "spctools" directory when
# you execute this.

# Dennis W. Brown 2-22-94
# Naval Postgraduate School, Monterey, CA


unset verbose

if $#argv == 0 then
	set drive = 'a'
else if $#argv == 1 then 
        set drive = $1
else
	echo "use: spc2sun (a|b)"
	exit 1
endif

# get directory filenames from disk
set d = `mdir $drive\:\\ | grep "<DIR>" | lower | awk '{ print $1 }' | grep  spctools`

# if d contains "spctools" the floppy is the correct one
if $d == spctools then

	# copy x:spctools files to current directory
	echo "Copying files from spctools directory"
	mcopy -tn $drive\:\/spctools\/\*.m   .
	mcopy -n  $drive\:\/spctools\/\*.voc .
	mcopy -n  $drive\:\/spctools\/\*.mat .
	mcopy -n  $drive\:\/spctools\/\*.txt .

	# get directory filenames from disk
	set d = `mdir $drive\:\/spctools | grep "<DIR>" | grep -v '\.' | lower | awk '{ print $1 }'`

	# copy m-files from directories
	foreach dname ( $d )
		if (! -d $dname) then
			echo "Creating directory '$dname'"
			md $dname
		endif
		cd $dname

		echo "Copying files from spctools\$dname"
		mcopy -tn $drive\:\/spctools\/$dname\/\*.m .
		mcopy -tn $drive\:\/spctools\/$dname\/\*.c .

		# compile mex files if any
		set c = `ls *.c`
		foreach cname ($c)
			echo "Compiling $cname ..."
			cmex -D__UNIX__ $cname
		end
		unset c
		cd ..
	end

else
	echo "SPCTOOLS directory not on floppy"
endif
unset d
