public software.sextractor

[/] [trunk/] [acx_atlas.m4] - Blame information for rev 235

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 233 bertin
dnl
2
dnl                             acx_atlas.m4
3
dnl
4
dnl Figure out if the ATLAS library and header files are installed.
5
dnl
6
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7
dnl
8
dnl     This file part of:      AstrOmatic software
9
dnl
10 235 bertin
dnl     Copyright:              (C) 2003-2010 Emmanuel Bertin -- IAP/CNRS/UPMC
11 233 bertin
dnl
12
dnl     License:                GNU General Public License
13
dnl
14
dnl     AstrOmatic software is free software: you can redistribute it and/or
15
dnl     modify it under the terms of the GNU General Public License as
16
dnl     published by the Free Software Foundation, either version 3 of the
17
dnl     License, or (at your option) any later version.
18
dnl     AstrOmatic software is distributed in the hope that it will be useful,
19
dnl     but WITHOUT ANY WARRANTY; without even the implied warranty of
20
dnl     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
dnl     GNU General Public License for more details.
22
dnl     You should have received a copy of the GNU General Public License
23
dnl     along with AstrOmatic software.
24
dnl     If not, see <http://www.gnu.org/licenses/>.
25
dnl
26
dnl     Last modified:          10/10/2010
27
dnl
28
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29
dnl
30
dnl @synopsis ACX_ATLAS([ATLAS_LIBDIR, ATLAS_INCDIR, ATLAS_PFLAG,
31
dnl                     [ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
32 100 bertin
dnl You may wish to use these variables in your default LIBS:
33 84 bertin
dnl
34 100 bertin
dnl        LIBS="$ATLAS_LIBS $LIBS"
35 84 bertin
dnl
36
dnl ACTION-IF-FOUND is a list of shell commands to run if BLAS/LAPACK
37
dnl is found (HAVE_ATLAS is defined first), and ACTION-IF-NOT-FOUND
38
dnl is a list of commands to run it if it is not found.
39
 
40
AC_DEFUN([ACX_ATLAS], [
41
AC_REQUIRE([AC_CANONICAL_HOST])
42
 
43 100 bertin
dnl --------------------
44
dnl Search include files
45
dnl --------------------
46
 
47 84 bertin
acx_atlas_ok=no
48 100 bertin
if test x$2 = x; then
49
  if test x$1 = x; then
50
    AC_CHECK_HEADERS([cblas.h clapack.h],[acx_atlas_ok=yes])
51 84 bertin
    if test x$acx_atlas_ok = xyes; then
52 100 bertin
      AC_DEFINE(ATLAS_BLAS_H, "cblas.h", [BLAS header filename.])
53
      AC_DEFINE(ATLAS_LAPACK_H, "clapack.h", [CLAPACK header filename.])
54 93 bertin
    else
55 100 bertin
      AC_CHECK_HEADERS([atlas/cblas.h atlas/clapack.h],[acx_atlas_ok=yes])
56
      if test x$acx_atlas_ok = xyes; then
57
        AC_DEFINE(ATLAS_BLAS_H, "atlas/cblas.h", [BLAS header filename.])
58
        AC_DEFINE(ATLAS_LAPACK_H, "atlas/clapack.h", [CLAPACK header filename.])
59
      else
60
        atlas_def=/usr/local/atlas
61
        AC_CHECK_HEADERS(
62
                [$atlas_def/include/cblas.h $atlas_def/include/clapack.h],
63
                [acx_atlas_ok=yes])
64
        if test x$acx_atlas_ok = xyes; then
65
          AC_DEFINE_UNQUOTED(ATLAS_BLAS_H, "$atlas_def/include/cblas.h",
66
                [BLAS header filename.])
67
          AC_DEFINE_UNQUOTED(ATLAS_LAPACK_H, "$atlas_def/include/clapack.h",
68
                [CLAPACK header filename.])
69
        else
70
          atlas_def=/usr/atlas
71
          AC_CHECK_HEADERS(
72
                [$atlas_def/include/cblas.h $atlas_def/include/clapack.h],
73
                [acx_atlas_ok=yes])
74
          if test x$acx_atlas_ok = xyes; then
75
            AC_DEFINE_UNQUOTED(ATLAS_BLAS_H, "$atlas_def/include/cblas.h",
76
                [BLAS header filename.])
77
            AC_DEFINE_UNQUOTED(ATLAS_LAPACK_H, "$atlas_def/include/clapack.h",
78
                [CLAPACK header filename.])
79
          else
80
            ATLAS_ERROR="CBLAS/LAPack include files not found!"
81
          fi
82
        fi
83
      fi
84
    fi
85
  else
86
    AC_CHECK_HEADERS([$1/include/cblas.h $1/include/clapack.h],
87
                [acx_atlas_ok=yes])
88
    if test x$acx_atlas_ok = xyes; then
89 93 bertin
      AC_DEFINE_UNQUOTED(ATLAS_BLAS_H, "$1/include/cblas.h",
90 100 bertin
                [BLAS header filename.])
91 93 bertin
      AC_DEFINE_UNQUOTED(ATLAS_LAPACK_H, "$1/include/clapack.h",
92 100 bertin
                [CLAPACK header filename.])
93
    else
94
      AC_CHECK_HEADERS([cblas.h clapack.h],[acx_atlas_ok=yes])
95
      if test x$acx_atlas_ok = xyes; then
96
        AC_DEFINE_UNQUOTED(ATLAS_BLAS_H, "cblas.h",
97
                [BLAS header filename.])
98
        AC_DEFINE_UNQUOTED(ATLAS_LAPACK_H, "clapack.h",
99
                [CLAPACK header filename.])
100
      else
101
        ATLAS_ERROR="CBLAS/LAPack include files not found in $1/include!"
102
      fi
103 84 bertin
    fi
104 100 bertin
  fi
105 84 bertin
else
106 100 bertin
  AC_CHECK_HEADERS([$2/cblas.h $2/clapack.h], [acx_atlas_ok=yes])
107
  if test x$acx_atlas_ok = xyes; then
108
    AC_DEFINE_UNQUOTED(ATLAS_BLAS_H, "$2/cblas.h",
109
                [BLAS header filename.])
110
    AC_DEFINE_UNQUOTED(ATLAS_LAPACK_H, "$2/clapack.h",
111
                [CLAPACK header filename.])
112
  else
113
    ATLAS_ERROR="CBLAS/LAPack include files not found in $2!"
114
  fi
115 84 bertin
fi
116 100 bertin
 
117
dnl --------------------
118
dnl Search library files
119
dnl --------------------
120
 
121 84 bertin
if test x$acx_atlas_ok = xyes; then
122 100 bertin
  OLIBS="$LIBS"
123
  LIBS=""
124
  if test x$1 = x; then
125
    AC_CHECK_LIB(lapack, [clapack_dpotrf],, [acx_atlas_ok=no],
126 84 bertin
                [-lcblas -latlas -lm])
127 100 bertin
    AC_CHECK_LIB(cblas, cblas_dgemm,, [acx_atlas_ok=no],
128 84 bertin
                [-latlas -lm])
129 100 bertin
    if test x$acx_atlas_ok = xyes; then
130 93 bertin
      ATLAS_LIBPATH=""
131 84 bertin
    else
132 100 bertin
      atlas_def=/usr/local/atlas
133
      unset ac_cv_lib_lapack_clapack_dpotrf
134
      unset ac_cv_lib_cblas_cblas_dgemm
135
      acx_atlas_ok=yes
136 84 bertin
      AC_CHECK_LIB(lapack, [clapack_dpotrf],, [acx_atlas_ok=no],
137 100 bertin
                [-L$atlas_def/lib -lcblas -latlas -lm])
138
      AC_CHECK_LIB(cblas, cblas_dgemm,, [acx_atlas_ok=no],
139
                [-L$atlas_def/lib -latlas -lm])
140 93 bertin
      if test x$acx_atlas_ok = xyes; then
141 100 bertin
        ATLAS_LIBPATH="-L$atlas_def/lib"
142 93 bertin
      else
143 135 bertin
        atlas_def=/usr/lib64/atlas
144 100 bertin
        unset ac_cv_lib_lapack_clapack_dpotrf
145
        unset ac_cv_lib_cblas_cblas_dgemm
146 93 bertin
        acx_atlas_ok=yes
147
        AC_CHECK_LIB(lapack, [clapack_dpotrf],, [acx_atlas_ok=no],
148 135 bertin
                [-L$atlas_def -lcblas -latlas -lm])
149 100 bertin
        AC_CHECK_LIB(cblas, cblas_dgemm,, [acx_atlas_ok=no],
150 135 bertin
                [-L$atlas_def -latlas -lm])
151 100 bertin
        if test x$acx_atlas_ok = xyes; then
152 135 bertin
          ATLAS_LIBPATH="-L$atlas_def"
153 100 bertin
        else
154 135 bertin
          atlas_def=/usr/lib/atlas
155
          unset ac_cv_lib_lapack_clapack_dpotrf
156
          unset ac_cv_lib_cblas_cblas_dgemm
157
          acx_atlas_ok=yes
158
          AC_CHECK_LIB(lapack, [clapack_dpotrf],, [acx_atlas_ok=no],
159
                [-L$atlas_def -lcblas -latlas -lm])
160
          AC_CHECK_LIB(cblas, cblas_dgemm,, [acx_atlas_ok=no],
161
                [-L$atlas_def -latlas -lm])
162
          if test x$acx_atlas_ok = xyes; then
163
            ATLAS_LIBPATH="-L$atlas_def"
164
          else
165
            atlas_def=/usr/atlas
166
            unset ac_cv_lib_lapack_clapack_dpotrf
167
            unset ac_cv_lib_cblas_cblas_dgemm
168
            acx_atlas_ok=yes
169
            AC_CHECK_LIB(lapack, [clapack_dpotrf],, [acx_atlas_ok=no],
170
                [-L$atlas_def/lib -lcblas -latlas -lm])
171
            AC_CHECK_LIB(cblas, cblas_dgemm,, [acx_atlas_ok=no],
172
                [-L$atlas_def/lib -latlas -lm])
173
            if test x$acx_atlas_ok = xyes; then
174
              ATLAS_LIBPATH="-L$atlas_def/lib"
175
            else
176
              ATLAS_ERROR="CBLAS/LAPack library files not found at usual locations!"
177
            fi
178
          fi
179 100 bertin
        fi
180
      fi
181
    fi
182
  else
183
    AC_CHECK_LIB(lapack, [clapack_dpotrf],, [acx_atlas_ok=no],
184
                [-L$1 -lcblas -latlas -lm])
185
    AC_CHECK_LIB(cblas, cblas_dgemm,, [acx_atlas_ok=no],
186
                [-L$1 -latlas -lm])
187
    if test x$acx_atlas_ok = xyes; then
188
      ATLAS_LIBPATH="-L$1"
189
    else
190
      unset ac_cv_lib_lapack_clapack_dpotrf
191
      unset ac_cv_lib_cblas_cblas_dgemm
192
      acx_atlas_ok=yes
193
      AC_CHECK_LIB(lapack, [clapack_dpotrf],, [acx_atlas_ok=no],
194 93 bertin
                [-L$1/lib -lcblas -latlas -lm])
195 100 bertin
      AC_CHECK_LIB(cblas, cblas_dgemm,, [acx_atlas_ok=no],
196 93 bertin
                [-L$1/lib -latlas -lm])
197 100 bertin
      if test x$acx_atlas_ok = xyes; then
198 93 bertin
        ATLAS_LIBPATH="-L$1/lib"
199 100 bertin
      else
200
        ATLAS_ERROR="CBLAS/LAPack library files not found in $1!"
201 93 bertin
      fi
202 84 bertin
    fi
203 100 bertin
  fi
204
  LIBS="$OLIBS"
205 84 bertin
fi
206
 
207 93 bertin
AC_SUBST(ATLAS_LIBPATH)
208 84 bertin
AC_SUBST(ATLAS_CFLAGS)
209
 
210 100 bertin
dnl -------------------------------------------------------------------------
211
dnl Finally, check MP version and execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND
212
dnl -------------------------------------------------------------------------
213 84 bertin
if test x"$acx_atlas_ok" = xyes; then
214 100 bertin
  AC_DEFINE(HAVE_ATLAS,1,
215
        [Define if you have the ATLAS libraries and header files.])
216
  if test x$3 = xyes; then
217
dnl Check whether the multithreaded version of ATLAS is there too:
218 197 bertin
    AC_CHECK_LIB(ptcblas, cblas_dgemm, [acx_atlast_ok=yes], [acx_atlast_ok=no],
219 108 bertin
        [$ATLAS_LIBPATH -lcblas -latlas -lm])
220 197 bertin
    if test x$acx_atlast_ok = xyes; then
221 100 bertin
      ATLAS_LIB="$ATLAS_LIBPATH -llapack -lptcblas -lcblas -latlas"
222 138 bertin
      LIBS="$OLIBS"
223 100 bertin
      AC_SUBST(ATLAS_LIB)
224
      AC_DEFINE(HAVE_ATLAS_MP,1,
225
        [Define if you have the parallel ATLAS libraries.])
226
      $4
227
    else
228 197 bertin
      ATLAS_LIB="$ATLAS_LIBPATH -llapack -lcblas -latlas"
229
      LIBS="$OLIBS"
230
      AC_SUBST(ATLAS_LIB)
231
      ATLAS_WARN="CBLAS/LAPack was compiled without multithreading support!"
232
      AC_SUBST(ATLAS_WARN)
233
      $4
234 100 bertin
    fi
235
  else
236
    ATLAS_LIB="$ATLAS_LIBPATH -llapack -lcblas -latlas"
237 138 bertin
    LIBS="$OLIBS"
238 100 bertin
    AC_SUBST(ATLAS_LIB)
239
    $4
240
  fi
241 84 bertin
else
242 100 bertin
  AC_SUBST(ATLAS_ERROR)
243
  $5
244 84 bertin
fi
245
 
246
])dnl ACX_ATLAS