diff m4/acinclude.m4 @ 15969:139f4b19a3ac

build: Improve detection of FFTW multi-threading * build-aux/common.mk: Remove FFTW3_THREADS_LIBS and FFTW3F_THREADS_LIB. * m4/acinclude.m4 (OCTAVE_CHECK_FFTW_THREADS): New macro to encapsulate checking for multi-threading support in the FFTW library. * configure.ac: Call it.
author Mike Miller <mtmiller@ieee.org>
date Mon, 21 Jan 2013 01:58:07 -0500
parents b316429bfa89
children ca37c6023a79
line wrap: on
line diff
--- a/m4/acinclude.m4	Fri Jan 18 16:48:12 2013 -0500
+++ b/m4/acinclude.m4	Mon Jan 21 01:58:07 2013 -0500
@@ -93,6 +93,57 @@
   fi
 ])
 dnl
+dnl Check whether the FFTW library supports multi-threading. This macro
+dnl should be called once per FFTW precision passing in the library
+dnl variant (e.g. "fftw3") and a function in the thread support API
+dnl (e.g. "fftw_plan_with_nthreads"). Depending on how FFTW was built,
+dnl the thread functions could be compiled into the main FFTW library or
+dnl could be a separate add-on library that is passed to the linker
+dnl ahead of the main FFTW library.
+dnl
+AC_DEFUN([OCTAVE_CHECK_FFTW_THREADS], [
+  ac_octave_save_CPPFLAGS="$CPPFLAGS"
+  ac_octave_save_LDFLAGS="$LDFLAGS"
+  ac_octave_save_LIBS="$LIBS"
+  CPPFLAGS="$m4_toupper([$1])_CPPFLAGS $CPPFLAGS"
+  LDFLAGS="$m4_toupper([$1])_LDFLAGS $LDFLAGS"
+  LIBS="$m4_toupper([$1])_LIBS $LIBS"
+  AC_CACHE_CHECK([for $1 multi-threading support],
+    [octave_cv_[$1]_threads_lib],
+    [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+      #include <fftw3.h>
+      ]], [[
+      $2 (2);
+      ]])],
+      [octave_cv_[$1]_threads_lib=yes],
+      [LIBS="-l[$1]_threads $LIBS"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+        #include <fftw3.h>
+        ]], [[
+        $2 (2);
+        ]])],
+        [octave_cv_[$1]_threads_lib="-l[$1]_threads"],
+        [octave_cv_[$1]_threads_lib=no])
+    ])
+  ])
+  case $octave_cv_[$1]_threads_lib in
+    -l*)
+      m4_toupper([$1])_LIBS="$octave_cv_[$1]_threads_lib $m4_toupper([$1])_LIBS"
+      ;;
+    no)
+      AC_MSG_WARN([No $1 multi-threading support found.])
+      AC_MSG_WARN([The single-threaded library will be used instead.])
+      ;;
+  esac
+  if test $octave_cv_[$1]_threads_lib != no; then
+    AC_DEFINE([HAVE_]m4_toupper([$1])[_THREADS], 1,
+      [Define to 1 if ]m4_toupper([$1])[ has multi-threading support.])
+  fi
+  CPPFLAGS="$ac_octave_save_CPPFLAGS"
+  LDFLAGS="$ac_octave_save_LDFLAGS"
+  LIBS="$ac_octave_save_LIBS"
+])
+dnl
 dnl Check whether a math mapper function is available in <cmath>.
 dnl Will define HAVE_CMATH_FUNC if there is a double variant and
 dnl HAVE_CMATH_FUNCF if there is a float variant.