acx_fftw.m4 7.97 KB
Newer Older
1
2
3
4
5
6
7
8
9
dnl
dnl				acx_fftw.m4
dnl
dnl Figure out if the FFTW3 library and header files are installed.
dnl
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dnl
dnl	This file part of:	AstrOmatic software
dnl
Emmanuel Bertin's avatar
Emmanuel Bertin committed
10
dnl	Copyright:		(C) 2003-2010 Emmanuel Bertin -- IAP/CNRS/UPMC
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
dnl
dnl	License:		GNU General Public License
dnl
dnl	AstrOmatic software is free software: you can redistribute it and/or
dnl	modify it under the terms of the GNU General Public License as
dnl	published by the Free Software Foundation, either version 3 of the
dnl	License, or (at your option) any later version.
dnl	AstrOmatic software 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	You should have received a copy of the GNU General Public License
dnl	along with AstrOmatic software.
dnl	If not, see <http://www.gnu.org/licenses/>.
dnl
dnl	Last modified:		10/10/2010
dnl
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dnl
dnl @synopsis ACX_FFTW([FFTW_DIR, FFTW_INCDIR, FFTW_PFLAG, FFTW_FFLAG,
dnl                    [ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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.

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
54
      AC_DEFINE(FFTW_H, "fftw3.h", [FFTW header filename.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
55
56
57
58
59
60
61
62
63
64
65
    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
66
      AC_DEFINE(FFTW_H, $1"/include/fftw3.h, [FFTW header filename.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
67
68
69
    else
      AC_CHECK_HEADER(fftw3.h,[acx_fftw_ok=yes])
      if test x$acx_fftw_ok = xyes; then
70
        AC_DEFINE(FFTW_H, "fftw3.h", [FFTW header filename.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
71
72
73
74
75
76
77
78
      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
79
    AC_DEFINE_UNQUOTED(FFTW_H, "$2/fftw3.h", [FFTW header filename.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  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
96
      AC_CHECK_LIB(fftw3f, fftwf_execute, [acx_fftw_ok=yes], [acx_fftw_ok=no], [-lm])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
97
      if test x$acx_fftw_ok = xyes; then
98
        AC_DEFINE(HAVE_FFTWF,1, [Define if you have the FFTW single precision libraries and header files.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
99
100
101
102
103
        FFTW_LIBS="-lfftw3f"
      else
        FFTW_ERROR="FFTW single precision library files not found at usual locations!"
      fi
    else
104
      AC_CHECK_LIB(fftw3, fftw_execute, [acx_fftw_ok=yes], [acx_fftw_ok=no], [-lm])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
105
      if test x$acx_fftw_ok = xyes; then
106
        AC_DEFINE(HAVE_FFTW,1, [Define if you have the FFTW double precision libraries and header files.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
107
108
109
110
111
112
113
        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
114
115
116
117
        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
118
        else
119
120
121
122
123
124
125
126
          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
127
128
        fi
      else
129
130
131
132
        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
133
        else
134
135
136
137
138
139
140
141
          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
142
143
144
145
146
147
148
149
        fi
      fi
    fi
  else
dnl -------------------------
dnl Specific libdir specified
dnl -------------------------
    if test x$4 = xyes; then
150
      AC_CHECK_LIB(fftw3f, fftwf_execute, [acx_fftw_ok=yes], [acx_fftw_ok=no], [-L$1 -lm])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
151
      if test x$acx_fftw_ok = xyes; then
152
        AC_DEFINE(HAVE_FFTWF,1, [Define if you have the FFTW single precision libraries and header files.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
153
154
155
156
157
        FFTW_LIBS="-L$1 -lfftw3f"
      else
        FFTW_ERROR="FFTW single precision library files not found in $1!"
      fi
    else
158
      AC_CHECK_LIB(fftw3, fftw_execute, [acx_fftw_ok=yes], [acx_fftw_ok=no], [-L$1 -lm])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
159
      if test x$acx_fftw_ok = xyes; then
160
        AC_DEFINE(HAVE_FFTW,1, [Define if you have the FFTW double precision libraries and header files.])
Emmanuel Bertin's avatar
Emmanuel Bertin committed
161
162
163
164
165
166
167
        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
168
169
170
171
        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
172
        else
173
174
175
176
177
178
179
180
          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
181
182
        fi
      else
183
184
185
        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
186
187
          FFTW_LIBS="-L$1 -lfftw3_threads -lfftw3"
        else
188
189
          FFTW_WARN="FFTW double precision library in $1 was compiled without multithreading support!"
          AC_SUBST(FFTW_WARN)
Emmanuel Bertin's avatar
Emmanuel Bertin committed
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
        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