1# -*- Autoconf -*- 2# 3# Copyright (C) 2015 Yann Pouillon 4# 5# This file is part of the Libvdwxc software package. For license information, 6# please see the COPYING file in the top-level directory of the Libvdwxc source 7# distribution. 8# 9 10 11 12# VDW_FFTW3_DETECT() 13# ------------------ 14# 15# Check whether the FFTW3 library is working. 16# 17AC_DEFUN([VDW_FFTW3_DETECT],[ 18 dnl Init 19 vdw_fftw3_ok="unknown" 20 vdw_fftw3_has_hdrs="unknown" 21 vdw_fftw3_has_libs="unknown" 22 23 dnl Backup environment 24 vdw_saved_CPPFLAGS="${CPPFLAGS}" 25 vdw_saved_LIBS="${LIBS}" 26 27 dnl Prepare build parameters 28 CPPFLAGS="${CPPFLAGS} ${vdw_fftw3_incs}" 29 LIBS="${vdw_fftw3_libs} ${LIBS}" 30 31 dnl Look for C includes 32 AC_LANG_PUSH([C]) 33 AC_CHECK_HEADERS([fftw3.h], 34 [vdw_fftw3_has_hdrs="serial"], [vdw_fftw3_has_hdrs="no"]) 35 if test "${vdw_fftw3_has_hdrs}" = "serial"; then 36 if test "${enable_mpi}" = "yes"; then 37 AC_CHECK_HEADERS([fftw3-mpi.h], 38 [vdw_fftw3_has_hdrs="yes"], [vdw_fftw3_has_hdrs="no"]) 39 else 40 vdw_fftw3_has_hdrs="yes" 41 fi 42 fi 43 AC_LANG_POP([C]) 44 45 dnl Look for C libraries and routines 46 if test "${vdw_fftw3_has_hdrs}" = "yes"; then 47 AC_LANG_PUSH([C]) 48 AC_MSG_CHECKING([whether the serial FFTW3 libraries work]) 49 AC_LINK_IFELSE([AC_LANG_PROGRAM( 50 [[ 51#include <fftw3.h> 52 ]], 53 [[ 54 fftw_plan *plan; 55 fftw_complex *a1, *a2; 56 fftw_execute_dft(plan, a1, a2); 57 ]])], [vdw_fftw3_has_libs="yes"], [vdw_fftw3_has_libs="no"]) 58 AC_MSG_RESULT([${vdw_fftw3_has_libs}]) 59 if test "${vdw_fftw3_has_libs}" = "yes"; then 60 if test "${enable_mpi}" = "yes"; then 61 AC_MSG_CHECKING([whether the MPI FFTW3 libraries work]) 62 AC_LINK_IFELSE([AC_LANG_PROGRAM( 63 [[ 64#include <fftw3-mpi.h> 65 ]], 66 [[ 67 fftw_mpi_init(); 68 ]])], [vdw_fftw3_has_libs="yes"], [vdw_fftw3_has_libs="no"]) 69 AC_MSG_RESULT([${vdw_fftw3_has_libs}]) 70 fi 71 fi 72 AC_LANG_POP([C]) 73 fi 74 75 dnl Take final decision 76 AC_MSG_CHECKING([whether we have a full FFTW3 support]) 77 if test "${vdw_fftw3_has_hdrs}" = "yes" -a \ 78 "${vdw_fftw3_has_libs}" = "yes"; then 79 vdw_fftw3_ok="yes" 80 else 81 vdw_fftw3_ok="no" 82 fi 83 AC_MSG_RESULT([${vdw_fftw3_ok}]) 84 85 dnl Restore environment 86 CPPFLAGS="${vdw_saved_CPPFLAGS}" 87 LIBS="${vdw_saved_LIBS}" 88]) # VDW_FFTW3_DETECT 89