Build system: fix detection of SLICOT for MATLAB on RHEL

The MATLAB_CFLAGS variable was not injected when testing for the presence of
libslicot64_pic. In particular, on GNU/Linux system, this means that the -fPIC
flag was not injected when doing the test. This was not a problem on Debian,
where GCC now enables -fPIC by default. But this would fail on RHEL, where
-fPIC is not enabled by default.

By the way:
— rename ac_save_* variables to my_save_*, to avoid conflicts with internal
  autoconf variables;
— do not inject “$(mkoctfile -p LFLAGS)” into LDFLAGS when testing for SLICOT
  under Octave; this is no longer necessary, since those flags are already
  injected at the beginning of mex/build/octave/configure.ac.
pac-components
Sébastien Villemot 2021-08-31 17:57:16 +02:00
parent 4cf1a358ee
commit 3d6f86c234
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 9 additions and 5 deletions

View File

@ -37,7 +37,7 @@ AC_DEFUN([AX_SLICOT],
else
LDFLAGS_SLICOT=""
fi
ac_save_LDFLAGS=$LDFLAGS
my_save_LDFLAGS=$LDFLAGS
# 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
@ -47,9 +47,13 @@ AC_DEFUN([AX_SLICOT],
if test "$1" = matlab; then
LDFLAGS="$LDFLAGS $MATLAB_LDFLAGS_NOMAP $LDFLAGS_SLICOT"
# Add MATLAB_CFLAGS to get the -fPIC on Linux/x86_64 (otherwise linking fails)
my_save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $MATLAB_CFLAGS"
AC_CHECK_LIB([slicot64_pic], [$sb02od], [LIBADD_SLICOT="-lslicot64_pic"], [has_slicot=no], [$MATLAB_LIBS])
CFLAGS=$my_save_CFLAGS
else
LDFLAGS="$LDFLAGS $($MKOCTFILE -p LFLAGS) $LDFLAGS_SLICOT"
LDFLAGS="$LDFLAGS $LDFLAGS_SLICOT"
# Fallback on libslicot_pic if dynamic libslicot not found
AC_CHECK_LIB([slicot], [$sb02od], [LIBADD_SLICOT="-lslicot"],
[
@ -58,7 +62,7 @@ AC_DEFUN([AX_SLICOT],
[$($MKOCTFILE -p BLAS_LIBS) $($MKOCTFILE -p LAPACK_LIBS)])
fi
LDFLAGS=$ac_save_LDFLAGS
LDFLAGS=$my_save_LDFLAGS
AC_SUBST(LDFLAGS_SLICOT)
AC_SUBST(LIBADD_SLICOT)
])

View File

@ -88,10 +88,10 @@ if test "$enable_mex_kalman_steady_state" = yes; then
# FCFLAGS must be temporarily modified, because otherwise -fno-underscoring is not
# taken into account by AC_FC_FUNC in the AX_SLICOT macro.
# For some obscure reason, it is necessary to do it at this level and not within the macro.
ac_save_FCFLAGS=$FCFLAGS
my_save_FCFLAGS=$FCFLAGS
FCFLAGS="$FCFLAGS $MATLAB_FCFLAGS"
AX_SLICOT([matlab])
FCFLAGS=$ac_save_FCFLAGS
FCFLAGS=$my_save_FCFLAGS
test "$has_slicot" != yes && AC_MSG_ERROR([slicot cannot be found. If you want to skip the compilation of the kalman_steady_state MEX, pass the --disable-mex-kalman-steady-state flag.])
fi