#!/bin/sh

# $Id: getMATLABDirs,v 1.2 1996/03/15 11:00:36 svein Exp $

# Determine the MATLAB directory parameters

if test -z "$MATLAB_INC" -o -z "$MATLAB_LIB" -o -z "$MATLAB_MEX_DEST"
then

cat <<EOF 1>&2

This software provides converters between the XITE image file
format and the binary file format used by the MATLAB software.

If the MATLAB software is installed on your platform, you may want
these converters installed also.

EOF

	echo "If you want the MATLAB converters, you will need to specify where" 1>&2
	echo "the MATLAB library and MATLAB include files are located." 1>&2
	$echoNl "Would you like to install the converters between MATLAB and " 1>&2
	$echoNl "XITE? ([y]/n) " 1>&2

	read matlab_install

	if test -z "$matlab_install" -o "$matlab_install" = "yes" \
		-o "$matlab_install" = "y"
	then
		matlab_install="y"
	else
		matlab_install="n"
	fi

	if test "$matlab_install" = "y"
	then
		matlab_def=/usr/local/matlab
		MATLAB=`$getDir "$MATLAB" "$matlab_def" 'MATLAB home directory' "$TMP_INSTALL" "stderr" 1`

		matlab_inc_def=$MATLAB/extern/include

    MATLAB_HOSTTYPE=`$matlab_hosttype "$XITE_HOSTTYPE"`
		matlab_lib_def=$MATLAB/extern/lib/$MATLAB_HOSTTYPE
		matlab_mex_dest_def=$MATLAB/toolbox/local
	fi
elif test "$MATLAB_INC" = "-" -o "$MATLAB_LIB" = "-" -o \
          "$MATLAB_MEX_DEST" = "-"
then
	matlab_install="n"
	matlab_inc_def=""
	matlab_lib_def=""
  matlab_mex_dest_def=""
else
	matlab_install="y"
	matlab_inc_def=""
	matlab_lib_def=""
  matlab_mex_dest_def=""
fi

if test "$matlab_install" = "y"
then
	MATLAB_INC=`$getDir "$MATLAB_INC" "$matlab_inc_def" 'MATLAB include directory' "$TMP_INSTALL" "stderr" 1`

	MATLAB_LIB=`$getDir "$MATLAB_LIB" "$matlab_lib_def" 'MATLAB library directory' "$TMP_INSTALL" "stderr" 1`

	MATLAB_MEX_DEST=`$getDir "$MATLAB_MEX_DEST" "$matlab_mex_dest_def" 'MATLAB mex-file destination directory' "$TMP_INSTALL" "stderr" 1`
else
	MATLAB_INC="-"
	MATLAB_LIB="-"
	MATLAB_MEX_DEST="-"
	exceptionDirs="$exceptionDirs matlab"
fi

echo "MATLAB_INC=$MATLAB_INC; MATLAB_LIB=$MATLAB_LIB"
echo "MATLAB_MEX_DEST=$MATLAB_MEX_DEST; matlab_install=$matlab_install"
echo "exceptionDirs='$exceptionDirs'"
echo "export MATLAB_INC MATLAB_LIB MATLAB_MEX_DEST matlab_install"
echo "export exceptionDirs"
