2012-09-18 13:18:27 +02:00
|
|
|
dnl Detect the SLICOT Library.
|
|
|
|
dnl Called with an argument of either 'matlab' or 'octave', depending
|
|
|
|
dnl on the configure script from which we're calling it
|
|
|
|
dnl
|
|
|
|
dnl AX_SLICOT([matlab])
|
|
|
|
dnl AX_SLICOT([octave])
|
|
|
|
dnl
|
2021-05-09 17:20:41 +02:00
|
|
|
dnl Copyright © 2012-2021 Dynare Team
|
2012-09-18 13:18:27 +02:00
|
|
|
dnl
|
|
|
|
dnl This file is part of Dynare.
|
|
|
|
dnl
|
|
|
|
dnl Dynare is free software: you can redistribute it and/or modify
|
|
|
|
dnl it under the terms of the GNU General Public License as published by
|
|
|
|
dnl the Free Software Foundation, either version 3 of the License, or
|
|
|
|
dnl (at your option) any later version.
|
|
|
|
dnl
|
|
|
|
dnl Dynare 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
|
2021-06-09 17:33:48 +02:00
|
|
|
dnl along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2012-09-18 13:18:27 +02:00
|
|
|
|
|
|
|
AC_DEFUN([AX_SLICOT],
|
|
|
|
[
|
2019-03-25 16:14:36 +01:00
|
|
|
if test "$1" != matlab && test "$1" != octave; then
|
2012-09-18 13:18:27 +02:00
|
|
|
AC_MSG_ERROR([Argument to autoconf slicot macro must be either 'matlab' or 'octave'])
|
|
|
|
fi
|
|
|
|
|
|
|
|
AC_ARG_WITH(slicot, AC_HELP_STRING([--with-slicot=DIR], [prefix to SLICOT installation]),
|
|
|
|
slicot_prefix="$withval", slicot_prefix="")
|
|
|
|
has_slicot=yes
|
|
|
|
|
2019-03-25 16:14:36 +01:00
|
|
|
if test -n "$slicot_prefix"; then
|
2012-09-18 13:18:27 +02:00
|
|
|
LDFLAGS_SLICOT="-L$withval/lib"
|
|
|
|
else
|
|
|
|
LDFLAGS_SLICOT=""
|
|
|
|
fi
|
2021-08-31 17:57:16 +02:00
|
|
|
my_save_LDFLAGS=$LDFLAGS
|
2012-09-18 13:18:27 +02:00
|
|
|
|
2021-05-09 18:00:42 +02:00
|
|
|
# At this point we should add MATLAB_FCFLAGS to FCFLAGS for Windows (which has -fno-underscoring),
|
|
|
|
# but that does not work. The actual underscore test seems to happen at the very beginning of the
|
|
|
|
# macro. Hence the modification of FCFLAGS was moved higher (in mex/build/matlab/configure.ac).
|
2019-12-03 16:17:00 +01:00
|
|
|
AC_FC_FUNC(sb02od)
|
2012-09-18 13:18:27 +02:00
|
|
|
|
2019-03-25 16:14:36 +01:00
|
|
|
if test "$1" = matlab; then
|
2020-12-17 19:11:54 +01:00
|
|
|
LDFLAGS="$LDFLAGS $MATLAB_LDFLAGS_NOMAP $LDFLAGS_SLICOT"
|
2012-09-28 17:21:12 +02:00
|
|
|
|
2021-08-31 17:57:16 +02:00
|
|
|
# Add MATLAB_CFLAGS to get the -fPIC on Linux/x86_64 (otherwise linking fails)
|
|
|
|
my_save_CFLAGS=$CFLAGS
|
|
|
|
CFLAGS="$CFLAGS $MATLAB_CFLAGS"
|
2021-05-09 17:20:41 +02:00
|
|
|
AC_CHECK_LIB([slicot64_pic], [$sb02od], [LIBADD_SLICOT="-lslicot64_pic"], [has_slicot=no], [$MATLAB_LIBS])
|
2021-08-31 17:57:16 +02:00
|
|
|
CFLAGS=$my_save_CFLAGS
|
2012-09-18 13:18:27 +02:00
|
|
|
else
|
2021-08-31 17:57:16 +02:00
|
|
|
LDFLAGS="$LDFLAGS $LDFLAGS_SLICOT"
|
2012-10-01 15:06:17 +02:00
|
|
|
# Fallback on libslicot_pic if dynamic libslicot not found
|
2012-09-18 13:18:27 +02:00
|
|
|
AC_CHECK_LIB([slicot], [$sb02od], [LIBADD_SLICOT="-lslicot"],
|
|
|
|
[
|
2019-03-25 16:14:36 +01:00
|
|
|
AC_CHECK_LIB([slicot_pic], [$sb02od], [LIBADD_SLICOT="-lslicot_pic"], [has_slicot=no], [$($MKOCTFILE -p BLAS_LIBS) $($MKOCTFILE -p LAPACK_LIBS)])
|
2012-10-01 15:06:17 +02:00
|
|
|
],
|
2019-03-25 16:14:36 +01:00
|
|
|
[$($MKOCTFILE -p BLAS_LIBS) $($MKOCTFILE -p LAPACK_LIBS)])
|
2012-09-18 13:18:27 +02:00
|
|
|
fi
|
|
|
|
|
2021-08-31 17:57:16 +02:00
|
|
|
LDFLAGS=$my_save_LDFLAGS
|
2012-09-18 13:18:27 +02:00
|
|
|
AC_SUBST(LDFLAGS_SLICOT)
|
|
|
|
AC_SUBST(LIBADD_SLICOT)
|
|
|
|
])
|