acx_fftw.m4 6.96 KB
Newer Older
Emmanuel Bertin's avatar
Emmanuel Bertin committed
1
2
3
4
5
6
7
8
9
10
11
dnl @synopsis ACX_FFTW([FFTW_DIR, FFTW_INCDIR, FFTW_PFLAG, FFTW_FFLAG, [ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
dnl This macro figures out if the FFTW3 libraries and header
dnl files are installed.
dnl You may wish to use these variables in your default LIBS and CFLAGS:
dnl
dnl        LIBS="$FFTW_LIBS $LIBS"
dnl
dnl ACTION-IF-FOUND is a list of shell commands to run if FFTW
dnl is found (HAVE_FFTWx are defined first), and ACTION-IF-NOT-FOUND
dnl is a list of commands to run it if it is not found.
dnl
12
dnl @version $Id: acx_fftw.m4,v 1.0 2009/06/26 21:30:17 bertin Exp $
Emmanuel Bertin's avatar
Emmanuel Bertin committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
dnl @author Emmanuel Bertin <bertin@iap.fr>

AC_DEFUN([ACX_FFTW], [
AC_REQUIRE([AC_CANONICAL_HOST])

dnl --------------------
dnl Search include files
dnl --------------------

acx_fftw_ok=no
if test x$2 = x; then
  if test x$1 = x; then
    AC_CHECK_HEADER(fftw3.h,[acx_fftw_ok=yes])
    if test x$acx_fftw_ok = xyes; then
27
      AC_DEFINE(FFTW_H, "fftw3.h", [FFTW header filename.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
28
29
30
31
32
33
34
35
36
37
38
    else
      AC_CHECK_HEADER(fftw/fftw3.h,[acx_fftw_ok=yes])
      if test x$acx_fftw_ok = xyes; then
        AC_DEFINE(FFTW_H, "fftw/fftw3.h", [FFTW header filename.])
      else
        FFTW_ERROR="FFTW include files not found in default location!"
      fi
    fi
  else
    AC_CHECK_HEADER($1/include/fftw3.h,[acx_fftw_ok=yes])
    if test x$acx_fftw_ok = xyes; then
39
      AC_DEFINE(FFTW_H, $1"/include/fftw3.h, [FFTW header filename.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
40
41
42
    else
      AC_CHECK_HEADER(fftw3.h,[acx_fftw_ok=yes])
      if test x$acx_fftw_ok = xyes; then
43
        AC_DEFINE(FFTW_H, "fftw3.h", [FFTW header filename.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
44
45
46
47
48
49
50
51
      else
        FFTW_ERROR="FFTW include files not found in $1/include!"
      fi
    fi
  fi
else
  AC_CHECK_HEADER($2/fftw3.h,[acx_fftw_ok=yes])
  if test x$acx_fftw_ok = xyes; then
52
    AC_DEFINE_UNQUOTED(FFTW_H, "$2/fftw3.h", [FFTW header filename.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  else
    FFTW_ERROR="FFTW include files not found in $2!"
  fi
fi

dnl --------------------
dnl Search library files
dnl --------------------

FFTW_LIBS=""
OLIBS="$LIBS"
LIBS=""

if test x$acx_fftw_ok = xyes; then
  if test x$1 = x; then
    if test x$4 = xyes; then
69
      AC_CHECK_LIB(fftw3f, fftwf_execute, [acx_fftw_ok=yes], [acx_fftw_ok=no], [-lm])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
70
      if test x$acx_fftw_ok = xyes; then
71
        AC_DEFINE(HAVE_FFTWF,1, [Define if you have the FFTW single precision libraries and header files.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
72
73
74
75
76
        FFTW_LIBS="-lfftw3f"
      else
        FFTW_ERROR="FFTW single precision library files not found at usual locations!"
      fi
    else
77
      AC_CHECK_LIB(fftw3, fftw_execute, [acx_fftw_ok=yes], [acx_fftw_ok=no], [-lm])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
78
      if test x$acx_fftw_ok = xyes; then
79
        AC_DEFINE(HAVE_FFTW,1, [Define if you have the FFTW double precision libraries and header files.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
80
81
82
83
84
85
86
        FFTW_LIBS="-lfftw3"
      else
        FFTW_ERROR="FFTW double precision library files not found at usual locations!"
      fi
    fi
    if test x$acx_fftw_ok = xyes && test x$3 = xyes; then
      if test x$4 = xyes; then
87
88
89
90
        AC_CHECK_LIB(fftw3f, fftwf_init_threads, [acx_fftwt_ok=yes], [acx_fftwt_ok=no], [-lm -lpthread])
        if test x$acx_fftwt_ok = xyes; then
          AC_DEFINE(HAVE_FFTWF_MP,1, [Define if you have the FFTW single precision multithreaded libraries and header files.])
          FFTW_LIBS="-lfftw3f"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
91
        else
92
93
94
95
96
97
98
99
          AC_CHECK_LIB(fftw3f_threads, fftwf_init_threads, [acx_fftwt_ok=yes], [acx_fftwt_ok=no], [-lfftw3f -lm -lpthread])
          if test x$acx_fftwt_ok = xyes; then
            AC_DEFINE(HAVE_FFTWF_MP,1, [Define if you have the FFTW single precision multithreaded libraries and header files.])
            FFTW_LIBS="-lfftw3f_threads -lfftw3f"
          else
            FFTW_WARN="FFTW single precision library was compiled without multithreading support!"
            AC_SUBST(FFTW_WARN)
          fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
100
101
        fi
      else
102
103
104
105
        AC_CHECK_LIB(fftw3, fftw_init_threads, [acx_fftwt_ok=yes], [acx_fftwt_ok=no], [-lm -lpthread])
        if test x$acx_fftwt_ok = xyes; then
          AC_DEFINE(HAVE_FFTW_MP,1, [Define if you have the FFTW double precision multithreaded libraries and header files.])
          FFTW_LIBS="-lfftw3"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
106
        else
107
108
109
110
111
112
113
114
          AC_CHECK_LIB(fftw3_threads, fftw_init_threads, [acx_fftwt_ok=yes], [acx_fftwt_ok=no], [-lfftw3 -lm -lpthread])
          if test x$acx_fftwt_ok = xyes; then
            AC_DEFINE(HAVE_FFTW_MP,1, [Define if you have the FFTW double precision multithreaded libraries and header files.])
            FFTW_LIBS="-lfftw3_threads -lfftw3"
          else
            FFTW_WARN="FFTW double precision library was compiled without multithreading support!"
            AC_SUBST(FFTW_WARN)
          fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
115
116
117
118
119
120
121
122
        fi
      fi
    fi
  else
dnl -------------------------
dnl Specific libdir specified
dnl -------------------------
    if test x$4 = xyes; then
123
      AC_CHECK_LIB(fftw3f, fftwf_execute, [acx_fftw_ok=yes], [acx_fftw_ok=no], [-L$1 -lm])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
124
      if test x$acx_fftw_ok = xyes; then
125
        AC_DEFINE(HAVE_FFTWF,1, [Define if you have the FFTW single precision libraries and header files.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
126
127
128
129
130
        FFTW_LIBS="-L$1 -lfftw3f"
      else
        FFTW_ERROR="FFTW single precision library files not found in $1!"
      fi
    else
131
      AC_CHECK_LIB(fftw3, fftw_execute, [acx_fftw_ok=yes], [acx_fftw_ok=no], [-L$1 -lm])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
132
      if test x$acx_fftw_ok = xyes; then
133
        AC_DEFINE(HAVE_FFTW,1, [Define if you have the FFTW double precision libraries and header files.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
134
135
136
137
138
139
140
        FFTW_LIBS="-L$1 -lfftw3"
      else
        FFTW_ERROR="FFTW double precision library files not found in $1!"
      fi
    fi
    if test x$acx_fftw_ok = xyes && test x$3 = xyes; then
      if test x$4 = xyes; then
141
142
143
144
        AC_CHECK_LIB(fftw3f, fftwf_init_threads, [acx_fftwt_ok=yes], [acx_fftwt_ok=no], [-L$1 -lm -lpthread])
        if test x$acx_fftwt_ok = xyes; then
          AC_DEFINE(HAVE_FFTWF_MP,1, [Define if you have the FFTW single precision multithreaded libraries and header files.])
          FFTW_LIBS="-L$1 -lfftw3f"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
145
        else
146
147
148
149
150
151
152
153
          AC_CHECK_LIB(fftw3f_threads, fftwf_init_threads, [acx_fftwt_ok=yes], [acx_fftwt_ok=no], [-L$1 -lfftw3f -lm -lpthread])
          if test x$acx_fftwt_ok = xyes; then
            AC_DEFINE(HAVE_FFTWF_MP,1, [Define if you have the FFTW single precision multithreaded libraries and header files.])
            FFTW_LIBS="-L$1 -lfftw3f_threads -lfftw3f"
          else
            FFTW_WARN="FFTW single precision library in $1 was compiled without multithreading support!"
            AC_SUBST(FFTW_WARN)
          fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
154
155
        fi
      else
156
157
158
        AC_CHECK_LIB(fftw3_threads, fftw_init_threads, [acx_fftwt_ok=yes], [acx_fftwt_ok=no], [-L$1 -lfftw3 -lm -lpthread])
        if test x$acx_fftwt_ok = xyes; then
          AC_DEFINE(HAVE_FFTW_MP,1, [Define if you have the FFTW double precision multithreaded libraries and header files.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
159
160
          FFTW_LIBS="-L$1 -lfftw3_threads -lfftw3"
        else
161
162
          FFTW_WARN="FFTW double precision library in $1 was compiled without multithreading support!"
          AC_SUBST(FFTW_WARN)
Emmanuel Bertin's avatar
Emmanuel Bertin committed
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
        fi
      fi
    fi
  fi
fi

LIBS="$OLIBS"
if test x$acx_fftw_ok = xyes; then
  AC_SUBST(FFTW_LIBS)
  $5
else
  AC_SUBST(FFTW_ERROR)
  $6
fi

])dnl ACX_FFTW