Commit 27a884f9 authored by sebastien's avatar sebastien
Browse files

Build system: adding M4 macros from package m-config 4.0 for testing MATLAB from configure


git-svn-id: https://www.dynare.org/svn/dynare/trunk@2814 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 3692d5f9
dnl matlab.m4 --- check for Matlab.
dnl
dnl Copyright (C) 2000--2003 Ralph Schleicher
dnl
dnl This program is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU General Public License as
dnl published by the Free Software Foundation; either version 2,
dnl or (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; see the file COPYING. If not, write to
dnl the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
dnl Boston, MA 02111-1307, USA.
dnl
dnl As a special exception to the GNU General Public License, if
dnl you distribute this file as part of a program that contains a
dnl configuration script generated by GNU Autoconf, you may include
dnl it under the same distribution terms that you use for the rest
dnl of that program.
dnl
dnl Code:
# AX_MATLAB
# ---------
# Check for Matlab.
AC_DEFUN([AX_MATLAB],
[dnl
AC_PREREQ([2.50])
ax_enable_matlab=
AC_ARG_WITH([matlab], AC_HELP_STRING([--with-matlab=ARG], [check for Matlab [[yes]]]),
[case $withval in
yes | no)
# Explicitly enable or disable Matlab but determine
# Matlab prefix automatically.
ax_enable_matlab=$withval
;;
*)
# Enable Matlab and use ARG as the Matlab prefix.
# ARG must be an existing directory.
ax_enable_matlab=yes
MATLAB=`cd "${withval-/}" > /dev/null 2>&1 && pwd`
if test -z "$MATLAB" ; then
AC_MSG_ERROR([invalid value '$withval' for --with-matlab])
fi
;;
esac])
AC_CACHE_CHECK([for Matlab prefix], [ax_cv_matlab],
[if test "${MATLAB+set}" = set ; then
ax_cv_matlab=`cd "${MATLAB-/}" > /dev/null 2>&1 && pwd`
else
ax_cv_matlab=
IFS=${IFS= } ; ax_ifs=$IFS ; IFS=:
for ax_dir in ${PATH-/opt/bin:/usr/local/bin:/usr/bin:/bin} ; do
if test -z "$ax_dir" ; then
ax_dir=.
fi
if test -x "$ax_dir/matlab" ; then
ax_dir=`echo "$ax_dir" | sed 's,/bin$,,'`
# Directory sanity check.
ax_cv_matlab=`cd "${ax_dir-/}" > /dev/null 2>&1 && pwd`
if test -n "$ax_cv_matlab" ; then
break
fi
fi
done
IFS=$ax_ifs
fi
if test -z "$ax_cv_matlab" ; then
ax_cv_matlab="not found"
fi])
if test "$ax_cv_matlab" = "not found" ; then
unset MATLAB
else
# Strip trailing dashes.
MATLAB=`echo "$ax_cv_matlab" | sed 's,/*$,,'`
fi
AC_MSG_CHECKING([whether to enable Matlab support])
if test x$ax_enable_matlab != xno ; then
if test "${MATLAB+set}" = set && test -d "$MATLAB/extern/include" ; then
ax_enable_matlab=yes
elif test x$ax_enable_matlab = x ; then
ax_enable_matlab=no
else
# Fail if Matlab was explicitly enabled.
AC_MSG_RESULT([failure])
AC_MSG_ERROR([check your Matlab setup])
fi
fi
AC_MSG_RESULT([$ax_enable_matlab])
if test x$ax_enable_matlab = xyes ; then
AC_DEFINE([HAVE_MATLAB], [1], [Define if you have Matlab.])
fi
AC_SUBST([MATLAB])
])
# AX_REQUIRE_MATLAB
# -----------------
# Like AX_MATLAB but fail if Matlab support is disabled.
AC_DEFUN([AX_REQUIRE_MATLAB],
[dnl
AC_PREREQ([2.50])
AC_REQUIRE([AX_MATLAB])
if test x$ax_enable_matlab = xno ; then
AC_MSG_ERROR([can not enable Matlab support])
fi
])
# AX_MATLAB_CONDITIONAL
# ---------------------
# Define Matlab conditional for GNU Automake.
AC_DEFUN([AX_MATLAB_CONDITIONAL],
[dnl
AC_PREREQ([2.50])
AC_REQUIRE([AX_MATLAB])
AM_CONDITIONAL([MATLAB], [test x$ax_enable_matlab = xyes])
])
dnl matlab.m4 ends here
dnl matlabarch.m4 --- check for Matlab machine architecture.
dnl
dnl Copyright (C) 2002, 2003 Ralph Schleicher
dnl
dnl This program is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU General Public License as
dnl published by the Free Software Foundation; either version 2,
dnl or (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; see the file COPYING. If not, write to
dnl the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
dnl Boston, MA 02111-1307, USA.
dnl
dnl As a special exception to the GNU General Public License, if
dnl you distribute this file as part of a program that contains a
dnl configuration script generated by GNU Autoconf, you may include
dnl it under the same distribution terms that you use for the rest
dnl of that program.
dnl
dnl Code:
# AX_MATLAB_ARCH
# --------------
# Check for Matlab machine architecture.
AC_DEFUN([AX_MATLAB_ARCH],
[dnl
AC_PREREQ([2.50])
AC_REQUIRE([AX_MEXEXT])
AC_CACHE_CHECK([for Matlab machine architecture], [ax_cv_matlab_arch],
[if test "${MATLAB_ARCH+set}" = set ; then
ax_cv_matlab_arch="$MATLAB_ARCH"
else
case $MEXEXT in
dll)
ax_cv_matlab_arch=win32
;;
mex)
ax_cv_matlab_arch=mac
;;
mexaxp)
ax_cv_matlab_arch=alpha
;;
mexglx)
ax_cv_matlab_arch=glnx86
;;
mexhp7)
ax_cv_matlab_arch=hp700
;;
mexhpux)
ax_cv_matlab_arch=hpux
;;
mexrs6)
ax_cv_matlab_arch=ibm_rs
;;
mexsg)
ax_cv_matlab_arch=sgi
;;
mexsol)
ax_cv_matlab_arch=sol2
;;
*)
ax_cv_matlab_arch=unknown
;;
esac
fi])
MATLAB_ARCH="$ax_cv_matlab_arch"
AC_SUBST([MATLAB_ARCH])
])
dnl matlabarch.m4 ends here
dnl matlabver.m4 --- check for Matlab version number.
dnl
dnl Copyright (C) 2000--2003 Ralph Schleicher
dnl
dnl This program is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU General Public License as
dnl published by the Free Software Foundation; either version 2,
dnl or (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; see the file COPYING. If not, write to
dnl the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
dnl Boston, MA 02111-1307, USA.
dnl
dnl As a special exception to the GNU General Public License, if
dnl you distribute this file as part of a program that contains a
dnl configuration script generated by GNU Autoconf, you may include
dnl it under the same distribution terms that you use for the rest
dnl of that program.
dnl
dnl Code:
# AX_MATLAB_VERSION
# -----------------
# Check for Matlab version number.
AC_DEFUN([AX_MATLAB_VERSION],
[dnl
AC_PREREQ([2.50])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AX_MATLAB])
AC_CACHE_CHECK([for Matlab version], [ax_cv_matlab_version],
[if test "${MATLAB_VERSION+set}" = set ; then
ax_cv_matlab_version=$MATLAB_VERSION
else
ax_cv_matlab_version=
# Loop over all known architectures. The final dot covers
# Matlab R11 and Matlab V4 for Windows.
for ax_arch in alpha glnx86 hp700 hpux ibm_rs sgi sol2 win32 . ; do
ax_matlab_exec=$MATLAB/bin/$ax_arch/matlab$EXEEXT
if test -f $ax_matlab_exec ; then
# For Matlab R12, the version number is stored in a
# shared library.
ax_matlab_exec_2=`find $MATLAB/bin/$ax_arch -type f -name libmwservices\* -print 2> /dev/null`
if test -n "$ax_matlab_exec_2" ; then
ax_cv_matlab_version=`strings $ax_matlab_exec_2 2> /dev/null | egrep '^\|build_version_\|@<:@0-9@:>@+\.@<:@0-9@:>@+\.@<:@0-9@:>@+\.@<:@0-9@:>@+' | head -1 | sed 's/^|build_version_|\(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/'`
if test -n "$ax_cv_matlab_version" ; then
break
fi
fi
# For Matlab R11 and Matlab V4, the version number
# is stored in the executable program.
ax_cv_matlab_version=`strings $ax_matlab_exec 2> /dev/null | egrep '^@<:@0-9@:>@+\.@<:@0-9@:>@+\.@<:@0-9@:>@+\.@<:@0-9@:>@+' | head -1 | sed 's/^\(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/'`
if test -n "$ax_cv_matlab_version" ; then
break
fi
fi
done
if test -z "$ax_cv_matlab_version" ; then
ax_cv_matlab_version="not found"
fi
fi])
case $ax_cv_matlab_version in
@<:@1-9@:>@.@<:@0-9@:>@ | @<:@1-9@:>@@<:@0-9@:>@.@<:@0-9@:>@)
MATLAB_VERSION=$ax_cv_matlab_version
MATLAB_MAJOR=`echo $MATLAB_VERSION | sed -e 's/^\(@<:@0-9@:>@*\)\.@<:@0-9@:>@*.*/\1/'`
MATLAB_MINOR=`echo $MATLAB_VERSION | sed -e 's/^@<:@0-9@:>@*\.\(@<:@0-9@:>@*\).*/\1/'`
;;
*)
if test x$ax_enable_matlab = xyes ; then
AC_MSG_ERROR([can not determine Matlab version number])
fi
MATLAB_VERSION=
MATLAB_MAJOR=
MATLAB_MINOR=
;;
esac
AC_SUBST([MATLAB_VERSION])
AC_SUBST([MATLAB_MAJOR])
AC_SUBST([MATLAB_MINOR])
if test x$MATLAB_VERSION != x ; then
AC_DEFINE_UNQUOTED([MATLAB_MAJOR], [$MATLAB_MAJOR], [Define to the Matlab major version number.])
AC_DEFINE_UNQUOTED([MATLAB_MINOR], [$MATLAB_MINOR], [Define to the Matlab minor version number.])
fi
])
# AX_REQUIRE_MATLAB_VERSION([MINIMUM-VERSION])
# --------------------------------------------
# Check if Matlab version number is sufficient.
AC_DEFUN([AX_REQUIRE_MATLAB_VERSION],
[dnl
AC_PREREQ([2.50])
AC_REQUIRE([AX_MATLAB_VERSION])
if test x$MATLAB_VERSION = x ; then
AC_MSG_ERROR([can not determine Matlab version number])
fi
m4_if([$1], [], [],
[AC_MSG_CHECKING([if Matlab version is sufficient])
ax_version='$1'
case $ax_version in
@<:@1-9@:>@ | @<:@1-9@:>@@<:@0-9@:>@)
ax_major=$ax_version
ax_minor=''
;;
@<:@1-9@:>@.@<:@0-9@:>@ | @<:@1-9@:>@@<:@0-9@:>@.@<:@0-9@:>@)
ax_major=`echo $ax_version | sed 's/^\(@<:@0-9@:>@*\)\.@<:@0-9@:>@*.*/\1/'`
ax_minor=`echo $ax_version | sed 's/^@<:@0-9@:>@*\.\(@<:@0-9@:>@*\).*/\1/'`
;;
*)
AC_MSG_RESULT([failure])
AC_MSG_NOTICE([report this bug to the responsible package maintainer])
AC_MSG_ERROR([invalid Matlab version number argument to AX_REQUIRE_MATLAB_VERSION])
;;
esac
ax_ans=yes
if test $MATLAB_MAJOR -eq $ax_major ; then
if test x$ax_minor != x && test $MATLAB_MINOR -lt $ax_minor ; then
ax_ans=no
fi
elif test $MATLAB_MAJOR -lt $ax_major ; then
ax_ans=no
fi
AC_MSG_RESULT([$ax_ans])
if test x$ax_ans = xno ; then
AC_MSG_ERROR([require Matlab version $ax_version or above])
fi])
])
dnl matlabver.m4 ends here
dnl mex.m4 --- check for mex(1) command.
dnl
dnl Copyright (C) 2000--2003 Ralph Schleicher
dnl
dnl This program is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU General Public License as
dnl published by the Free Software Foundation; either version 2,
dnl or (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; see the file COPYING. If not, write to
dnl the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
dnl Boston, MA 02111-1307, USA.
dnl
dnl As a special exception to the GNU General Public License, if
dnl you distribute this file as part of a program that contains a
dnl configuration script generated by GNU Autoconf, you may include
dnl it under the same distribution terms that you use for the rest
dnl of that program.
dnl
dnl Code:
# AX_PATH_MEX
# -----------
# Check for mex(1) command.
AC_DEFUN([AX_PATH_MEX],
[dnl
AC_PREREQ([2.50])
AC_REQUIRE([AX_MATLAB])
AC_REQUIRE([AX_MEX_OPTIONS])
AC_REQUIRE([AC_CANONICAL_HOST])
if test "${MEX+set}" != set ; then
case $host_os in
*cygwin* | *mingw32*)
ax_list='mextool mex mex.bat'
;;
*)
ax_list='mex'
;;
esac
AC_PATH_PROGS([MEX], $ax_list, mex, $MATLAB/bin:$PATH)
fi
AC_SUBST([MEX])
if test "${MEXFLAGS+set}" != set ; then
MEXFLAGS=-O
fi
AC_SUBST([MEXFLAGS])
if test "${MEXLDADD+set}" != set ; then
MEXLDADD=
fi
AC_SUBST([MEXLDADD])
])
dnl mex.m4 ends here
dnl mexext.m4 --- check for MEX-file suffix.
dnl
dnl Copyright (C) 2000--2003 Ralph Schleicher
dnl
dnl This program is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU General Public License as
dnl published by the Free Software Foundation; either version 2,
dnl or (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; see the file COPYING. If not, write to
dnl the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
dnl Boston, MA 02111-1307, USA.
dnl
dnl As a special exception to the GNU General Public License, if
dnl you distribute this file as part of a program that contains a
dnl configuration script generated by GNU Autoconf, you may include
dnl it under the same distribution terms that you use for the rest
dnl of that program.
dnl
dnl Code:
# AX_MEXEXT
# ---------
# Check for MEX-file suffix.
AC_DEFUN([AX_MEXEXT],
[dnl
AC_PREREQ([2.50])
AC_REQUIRE([AX_PATH_MEX])
AC_CACHE_CHECK([for MEX-file suffix], [ax_cv_mexext],
[if test "${MEXEXT+set}" = set ; then
ax_cv_mexext="$MEXEXT"
else
echo 'mexFunction () {}' > ax_c_test.c
$MEX $MEXOPTS $MEXFLAGS -output ax_c_test ax_c_test.c $MEXLDADD 2> /dev/null 1>&2
if test -f ax_c_test.dll ; then
ax_cv_mexext=dll
elif test -f ax_c_test.mex ; then
ax_cv_mexext=mex
elif test -f ax_c_test.mexaxp ; then
ax_cv_mexext=mexaxp
elif test -f ax_c_test.mexglx ; then
ax_cv_mexext=mexglx
elif test -f ax_c_test.mexhp7 ; then
ax_cv_mexext=mexhp7
elif test -f ax_c_test.mexhpux ; then
ax_cv_mexext=mexhpux
elif test -f ax_c_test.mexrs6 ; then
ax_cv_mexext=mexrs6
elif test -f ax_c_test.mexsg ; then
ax_cv_mexext=mexsg
elif test -f ax_c_test.mexsol ; then
ax_cv_mexext=mexsol
else
ax_cv_mexext=unknown
fi
rm -f ax_c_test*
fi])
MEXEXT="$ax_cv_mexext"
AC_SUBST([MEXEXT])
])
# AX_DOT_MEXEXT
# -------------
# Check for MEX-file suffix with leading dot.
AC_DEFUN([AX_DOT_MEXEXT],
[dnl
AC_REQUIRE([AX_MEXEXT])
case $MEXEXT in
.*)
;;
*)
if test -n "$MEXEXT" ; then
MEXEXT=.$MEXEXT
AC_MSG_RESULT([setting MEX-file suffix to $MEXEXT])
AC_SUBST([MEXEXT])
fi
;;
esac
])
dnl mexext.m4 ends here
dnl mexopt.m4 --- check for MEX options file.
dnl
dnl Copyright (C) 2001--2003 Ralph Schleicher
dnl
dnl This program is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU General Public License as
dnl published by the Free Software Foundation; either version 2,
dnl or (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; see the file COPYING. If not, write to
dnl the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
dnl Boston, MA 02111-1307, USA.
dnl
dnl As a special exception to the GNU General Public License, if
dnl you distribute this file as part of a program that contains a
dnl configuration script generated by GNU Autoconf, you may include
dnl it under the same distribution terms that you use for the rest
dnl of that program.
dnl
dnl Code:
# AX_MEX_OPTIONS
# --------------
# Check for MEX options file.
AC_DEFUN([AX_MEX_OPTIONS],
[dnl
AC_PREREQ([2.50])
mex_options=yes
AC_ARG_WITH([mex-options], AC_HELP_STRING([--with-mex-options=ARG], [use MEX options file ARG [[standard]]]),
[mex_options=$withval])
AC_MSG_CHECKING([for MEX options file handling])
case $mex_options in
yes)
AC_MSG_RESULT([standard])
mexopts_sh=
;;
no)
AC_MSG_RESULT([disabled])
mexopts_sh=$ac_aux_dir/noopts.sh
;;
*)
AC_MSG_RESULT([enabled])
mexopts_sh=$mex_options
;;
esac
if test -n "$mexopts_sh" ; then
AC_MSG_CHECKING([whether MEX options file exists])
if test -f "$mexopts_sh" ; then
AC_MSG_RESULT([yes])
# Canonicalize file name.
mexopts_sh_dir=`echo "$mexopts_sh" | sed 's,[[^/]]*$,,'`
mexopts_sh_dir=`cd "${mexopts_sh_dir-.}" && pwd`
mexopts_sh_name=`echo "$mexopts_sh" | sed 's,.*/,,'`
mexopts_sh="$mexopts_sh_dir/$mexopts_sh_name"
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([$mexopts_sh: no such file])
fi
MEXOPTS="-f $mexopts_sh"
else
MEXOPTS=
fi
AC_SUBST([mexopts_sh])
AC_SUBST([MEXOPTS])
])
dnl mexopt.m4 ends here
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment