echo
echo "This script copies XDS sample programs to the current directory."
echo

if test -d $1 && test -r $1/bin/xm
then
	echo    Copying samples...
        cp -p -f -r $1/samples/* .
	chmod a+x `
	awk '{
		if ($1 == "cd") 
			if ($2 == "..") 
				dir = ""
			else { 
				dir = $2
				print dir "/buildc"
			}
		else 
			if (dir != "") print >dir "/buildc"
	}' buildc `	
	echo
	echo    DONE
	echo
else
	echo    "Usage:"
	echo    "  xdssamp path_to_XDS_root_directory"
	echo
	echo    "Example:"
	echo    "  xdssamp /usr/local/xds"
	echo
fi
echo "================================================================"
