dnl dnl Filename : octave.m4 dnl Description : Autoconf macro for Octave configuration dnl Author(s) : Mike Hucka dnl Created : 2007-08-26 dnl Revision : $Id: octave.m4 8909 2009-01-19 07:16:58Z mhucka $ dnl $HeadURL: https://sbml.svn.sourceforge.net/svnroot/sbml/trunk/libsbml/config/octave.m4 $ dnl dnl */ dnl Unlike the others, this takes 2 args: octave version and mkoctfile version. dnl CONFIG_PROG_OCTAVE(oversion, mversion) AC_DEFUN([CONFIG_PROG_OCTAVE], [ AC_ARG_WITH([octave], AC_HELP_STRING([--with-octave=PREFIX], [Generate Octave interface library [[default=no]]]), [with_octave=$withval], [with_octave=no]) if test $with_octave != no; then if test $with_octave != yes; then dnl Remove needless trailing slashes because it can confuse tests later. with_octave=`echo $with_octave | sed -e 's,\(.*\)/$,\1,g'` AC_PATH_PROG([OCTAVE], [octave], [no], [$with_octave/bin]) AC_PATH_PROG([MKOCTFILE], [mkoctfile], [no], [$with_octave/bin]) AC_PATH_PROG([OCTAVE_CONFIG], [octave-config], [no], [$with_octave/bin]) else AC_PATH_PROG([OCTAVE], [octave]) AC_PATH_PROG([MKOCTFILE], [mkoctfile]) AC_PATH_PROG([OCTAVE_CONFIG], [octave-config]) fi if test -z "$OCTAVE" -o "$OCTAVE" = "no"; then AC_MSG_ERROR([Could not find 'octave' executable for Octave.]) elif test -z "$MKOCTFILE" -o "$MKOCTFILE" = "no"; then AC_MSG_ERROR([Could not find 'mkoctfile' executable for Octave.]) fi dnl If we got this far, we have octave and mkoctfile executables. dnl Now check their versions against what was requested (if anything). OCTAVE_REQUEST_VERSION=$1 MKOCTFILE_REQUEST_VERSION=$2 AC_MSG_CHECKING(octave version) changequote(<<, >>) octave_version=`"$OCTAVE" --version 2>&1 | head -n 1 | sed 's/.* \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p; d'` octave_major_ver=`expr $octave_version : '\([0-9]*\)\.[0-9]*\.[0-9]*'` octave_minor_ver=`expr $octave_version : '[0-9]*\.\([0-9]*\)\.[0-9]*'` octave_micro_ver=`expr $octave_version : '[0-9]*\.[0-9]*\.\([0-9]*\)' '|' 0` changequote([, ]) AC_MSG_RESULT($octave_version) OCTAVEVERNUM=`printf "%02d%02d%02d" $octave_major_ver $octave_minor_ver $octave_micro_ver` if test -n "$OCTAVE_REQUEST_VERSION"; then AC_MSG_CHECKING(if octave version >= (found $OCTAVE_REQUEST_VERSION)) changequote(<<, >>) octave_major_req=`expr $OCTAVE_REQUEST_VERSION : '\([0-9]*\)\.[0-9]*\.[0-9]*'` octave_minor_req=`expr $OCTAVE_REQUEST_VERSION : '[0-9]*\.\([0-9]*\)\.[0-9]*'` octave_micro_req=`expr $OCTAVE_REQUEST_VERSION : '[0-9]*\.[0-9]*\.\([0-9]*\)'` changequote([, ]) if test $octave_major_ver -gt $octave_major_req \ || (test $octave_major_ver -eq $octave_major_req && \ test $octave_minor_ver -gt $octave_minor_req) \ || (test $octave_major_ver -eq $octave_major_req && \ test $octave_minor_ver -eq $octave_minor_req && \ test $octave_micro_ver -ge $octave_micro_req) then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) AC_MSG_ERROR(installed version of octave is too old!) fi fi AC_MSG_CHECKING(mkoctfile version) changequote(<<, >>) mkoctfile_version=`"$MKOCTFILE" --version 2>&1 | head -n 1 | sed 's/.* \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p; d'` mkoctfile_major_ver=`expr $mkoctfile_version : '\([0-9]*\)\.[0-9]*\.[0-9]*'` mkoctfile_minor_ver=`expr $mkoctfile_version : '[0-9]*\.\([0-9]*\)\.[0-9]*'` mkoctfile_micro_ver=`expr $mkoctfile_version : '[0-9]*\.[0-9]*\.\([0-9]*\)' '|' 0` changequote([, ]) AC_MSG_RESULT($mkoctfile_version) MKOCTFILEVERNUM=`printf "%02d%02d%02d" $mkoctfile_major_ver $mkoctfile_minor_ver $mkoctfile_micro_ver` if test -n "$MKOCTFILE_REQUEST_VERSION"; then AC_MSG_CHECKING(if mkoctfile version >= (found $MKOCTFILE_REQUEST_VERSION)) changequote(<<, >>) mkoctfile_major_req=`expr $MKOCTFILE_REQUEST_VERSION : '\([0-9]*\)\.[0-9]*\.[0-9]*'` mkoctfile_minor_req=`expr $MKOCTFILE_REQUEST_VERSION : '[0-9]*\.\([0-9]*\)\.[0-9]*'` mkoctfile_micro_req=`expr $MKOCTFILE_REQUEST_VERSION : '[0-9]*\.[0-9]*\.\([0-9]*\)'` changequote([, ]) if test $mkoctfile_major_ver -gt $mkoctfile_major_req \ || (test $mkoctfile_major_ver -eq $mkoctfile_major_req && \ test $mkoctfile_minor_ver -gt $mkoctfile_minor_req) \ || (test $mkoctfile_major_ver -eq $mkoctfile_major_req && \ test $mkoctfile_minor_ver -eq $mkoctfile_minor_req && \ test $mkoctfile_micro_ver -ge $mkoctfile_micro_req) then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) AC_MSG_ERROR(installed version of mkoctfile is too old!) fi fi MKOCTFILE_FLAGS="--mex" OCTAVEEXT="mex" dnl get rid of prefix part from the directory name of the local oct file dnl repository in order to rebase it later. LOCALOCTFILEDIR=`"$OCTAVE_CONFIG" -p LOCALOCTFILEDIR | sed -e "s#^\`\"$OCTAVE_CONFIG\" -p PREFIX\`##"` AC_DEFINE([USE_OCTAVE], 1, [Define to 1 to use Octave]) AC_SUBST(USE_OCTAVE, 1) AC_SUBST(OCTAVE) AC_SUBST(MKOCTFILE) AC_SUBST(MKOCTFILE_FLAGS) AC_SUBST(OCTAVEEXT) AC_SUBST(LOCALOCTFILEDIR) fi dnl We record the USE_XXX flag, for later testing in Makefiles. LIBSBML_OPTIONS="$LIBSBML_OPTIONS USE_OCTAVE" ])