dnl -----------------------------------------------------------------
dnl $Id: configure.in,v 1.1 2001/03/01 19:04:52 pwessel Exp $
dnl
dnl Run GNU autoconf to produce a configure script from this input.
dnl
dnl -----------------------------------------------------------------
dnl
AC_REVISION(configure for GMT 3.3.5 mex directory)
AC_INIT(README.mex)
MATLAB=${MATLAB:-/usr/local/matlab}
AC_CONFIG_AUX_DIR(../..)
AC_CANONICAL_SYSTEM
AC_LANG_C
AC_PROG_CC
dnl
dnl -----------------------------------------------------------------
dnl Get current OS type
dnl -----------------------------------------------------------------
dnl
os=`uname -s`
dnl
dnl -----------------------------------------------------------------
dnl Determine Matlab mex extensions and dirs for this platform
dnl -----------------------------------------------------------------
dnl
AC_MSG_CHECKING(compiler options for Matlab)
if test "$os" = "Linux" ; then		# Linux systems
	MATLAB_EXT='mexlx'
elif test "$os" = "SunOS" ; then	# Sun Workshop
	MATLAB_EXT='mexsol'
elif test "$os" = "IRIX64" ; then	# SGI Irix 64
	MATLAB_EXT='mexsg64'
elif test "$os" = "IRIX" ; then		# SGI Irix
	MATLAB_EXT='mexsg'
elif test "$os" = "HP-UX" ; then	# HP
	MATLAB_EXT='mexhp7'
elif test "$os" = "AIX" ; then		# IBM AIX
	MATLAB_EXT='mexrs6'
elif test "$os" = "OSF1" ; then		# Dec Alpha
	MATLAB_EXT='mexds'
elif test "$os" = "ULTRIX" ; then	# Dec Ultrix
	MATLAB_EXT='mexvx'
else					# Other
	MATLAB_EXT='mex'
fi

if test "$os" = "Linux" ; then		# Linux
	MATLAB_MEX='lnx86'
	MATLAB_LIB='mat'
elif test "$os" = "SunOS" ; then	# Sun Workshop
	MATLAB_MEX='sol2'
	MATLAB_LIB='mat'
elif test "$os" = "AIX" ; then		# IBM AIX
	MATLAB_MEX='ibm_rs'
	MATLAB_LIB='mat'
else					# Other (Users: pls supply your input)
	AC_MSG_RESULT([Matlab mex-file extension and Matlab library name not known - guessed to be mex])
	AC_MSG_RESULT([If incorrect, please modify makefile manually and notify gmt@soest.hawaii.edu])
	MATLAB_MEX='mex'
	MATLAB_LIB='mex'
fi

AC_SUBST(MATLAB)
AC_SUBST(MATLAB_EXT)
AC_SUBST(MATLAB_MEX)
AC_SUBST(MATLAB_LIB)
AC_OUTPUT(makefile)
if test "x$MATLAB" = "xNONE" ; then	# No Matlab on this system
	touch .skip
else
	rm -f .skip
fi
