source: trunk/m4/acx_blas.m4 @ 1914

Last change on this file since 1914 was 1914, checked in by Peter, 14 years ago

Using ACX_BLAS macro for blas detection. The behavior will likely be a
bit different from before. The major difference is that there are no
-m64 flags in the atlas tests, which implies you might need to add
-m64 to LDFLAGS (and possibly CXXFLAGS) at configure time. It also
implies that you might detect atlas on your 32bit machine, which
previously was not possible. fixes #349

There is a new configure option: '--with-blas' that can be used to
specify which blas should be used. fixes #524

refs #518

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 6.5 KB
Line 
1# ===========================================================================
2#                http://autoconf-archive.cryp.to/acx_blas.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   ACX_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
8#
9# DESCRIPTION
10#
11#   This macro looks for a library that implements the BLAS linear-algebra
12#   interface (see http://www.netlib.org/blas/). On success, it sets the
13#   BLAS_LIBS output variable to hold the requisite library linkages.
14#
15#   To link with BLAS, you should link with:
16#
17#     $BLAS_LIBS $LIBS $FLIBS
18#
19#   in that order. FLIBS is the output variable of the
20#   AC_F77_LIBRARY_LDFLAGS macro (called if necessary by ACX_BLAS), and is
21#   sometimes necessary in order to link with F77 libraries. Users will also
22#   need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same
23#   reason.
24#
25#   Many libraries are searched for, from ATLAS to CXML to ESSL. The user
26#   may also use --with-blas=<lib> in order to use some specific BLAS
27#   library <lib>. In order to link successfully, however, be aware that you
28#   will probably need to use the same Fortran compiler (which can be set
29#   via the F77 env. var.) as was used to compile the BLAS library.
30#
31#   ACTION-IF-FOUND is a list of shell commands to run if a BLAS library is
32#   found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it is
33#   not found. If ACTION-IF-FOUND is not specified, the default action will
34#   define HAVE_BLAS.
35#
36#   This macro requires autoconf 2.50 or later.
37#
38# LAST MODIFICATION
39#
40#   2008-04-12
41#
42# COPYLEFT
43#
44#   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
45#
46#   This program is free software: you can redistribute it and/or modify it
47#   under the terms of the GNU General Public License as published by the
48#   Free Software Foundation, either version 3 of the License, or (at your
49#   option) any later version.
50#
51#   This program is distributed in the hope that it will be useful, but
52#   WITHOUT ANY WARRANTY; without even the implied warranty of
53#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
54#   Public License for more details.
55#
56#   You should have received a copy of the GNU General Public License along
57#   with this program. If not, see <http://www.gnu.org/licenses/>.
58#
59#   As a special exception, the respective Autoconf Macro's copyright owner
60#   gives unlimited permission to copy, distribute and modify the configure
61#   scripts that are the output of Autoconf when processing the Macro. You
62#   need not follow the terms of the GNU General Public License when using
63#   or distributing such scripts, even though portions of the text of the
64#   Macro appear in them. The GNU General Public License (GPL) does govern
65#   all other use of the material that constitutes the Autoconf Macro.
66#
67#   This special exception to the GPL applies to versions of the Autoconf
68#   Macro released by the Autoconf Macro Archive. When you make and
69#   distribute a modified version of the Autoconf Macro, you may extend this
70#   special exception to the GPL to apply to your modified version as well.
71
72AC_DEFUN([ACX_BLAS], [
73AC_PREREQ(2.50)
74AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
75acx_blas_ok=no
76
77AC_ARG_WITH(blas,
78  [AC_HELP_STRING([--with-blas=<lib>], [use BLAS library <lib>])])
79case $with_blas in
80  yes | "") ;;
81  no) acx_blas_ok=disable ;;
82  -* | */* | *.a | *.so | *.so.* | *.o) BLAS_LIBS="$with_blas" ;;
83  *) BLAS_LIBS="-l$with_blas" ;;
84esac
85
86# Get fortran linker names of BLAS functions to check for.
87AC_F77_FUNC(sgemm)
88AC_F77_FUNC(dgemm)
89
90acx_blas_save_LIBS="$LIBS"
91LIBS="$LIBS $FLIBS"
92
93# First, check BLAS_LIBS environment variable
94if test $acx_blas_ok = no; then
95if test "x$BLAS_LIBS" != x; then
96  save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
97  AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS])
98  AC_TRY_LINK_FUNC($sgemm, [acx_blas_ok=yes], [BLAS_LIBS=""])
99  AC_MSG_RESULT($acx_blas_ok)
100  LIBS="$save_LIBS"
101fi
102fi
103
104# BLAS linked to by default?  (happens on some supercomputers)
105if test $acx_blas_ok = no; then
106  save_LIBS="$LIBS"; LIBS="$LIBS"
107  AC_CHECK_FUNC($sgemm, [acx_blas_ok=yes])
108  LIBS="$save_LIBS"
109fi
110
111# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
112if test $acx_blas_ok = no; then
113  AC_CHECK_LIB(atlas, ATL_xerbla,
114    [AC_CHECK_LIB(f77blas, $sgemm,
115    [AC_CHECK_LIB(cblas, cblas_dgemm,
116      [acx_blas_ok=yes
117       BLAS_LIBS="-lcblas -lf77blas -latlas"],
118      [], [-lf77blas -latlas])],
119      [], [-latlas])])
120fi
121
122# BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
123if test $acx_blas_ok = no; then
124  AC_CHECK_LIB(blas, $sgemm,
125    [AC_CHECK_LIB(dgemm, $dgemm,
126    [AC_CHECK_LIB(sgemm, $sgemm,
127      [acx_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"],
128      [], [-lblas])],
129      [], [-lblas])])
130fi
131
132# BLAS in Intel MKL library?
133if test $acx_blas_ok = no; then
134  AC_CHECK_LIB(mkl, $sgemm, [acx_blas_ok=yes;BLAS_LIBS="-lmkl"])
135fi
136
137# BLAS in Apple vecLib library?
138if test $acx_blas_ok = no; then
139  save_LIBS="$LIBS"; LIBS="-framework vecLib $LIBS"
140  AC_CHECK_FUNC($sgemm, [acx_blas_ok=yes;BLAS_LIBS="-framework vecLib"])
141  LIBS="$save_LIBS"
142fi
143
144# BLAS in Alpha CXML library?
145if test $acx_blas_ok = no; then
146  AC_CHECK_LIB(cxml, $sgemm, [acx_blas_ok=yes;BLAS_LIBS="-lcxml"])
147fi
148
149# BLAS in Alpha DXML library? (now called CXML, see above)
150if test $acx_blas_ok = no; then
151  AC_CHECK_LIB(dxml, $sgemm, [acx_blas_ok=yes;BLAS_LIBS="-ldxml"])
152fi
153
154# BLAS in Sun Performance library?
155if test $acx_blas_ok = no; then
156  if test "x$GCC" != xyes; then # only works with Sun CC
157    AC_CHECK_LIB(sunmath, acosp,
158      [AC_CHECK_LIB(sunperf, $sgemm,
159              [BLAS_LIBS="-xlic_lib=sunperf -lsunmath"
160                                 acx_blas_ok=yes],[],[-lsunmath])])
161  fi
162fi
163
164# BLAS in SCSL library?  (SGI/Cray Scientific Library)
165if test $acx_blas_ok = no; then
166  AC_CHECK_LIB(scs, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lscs"])
167fi
168
169# BLAS in SGIMATH library?
170if test $acx_blas_ok = no; then
171  AC_CHECK_LIB(complib.sgimath, $sgemm,
172         [acx_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"])
173fi
174
175# BLAS in IBM ESSL library? (requires generic BLAS lib, too)
176if test $acx_blas_ok = no; then
177  AC_CHECK_LIB(blas, $sgemm,
178    [AC_CHECK_LIB(essl, $sgemm,
179      [acx_blas_ok=yes; BLAS_LIBS="-lessl -lblas"],
180      [], [-lblas $FLIBS])])
181fi
182
183# Generic BLAS library?
184if test $acx_blas_ok = no; then
185  AC_CHECK_LIB(blas, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lblas"])
186fi
187
188AC_SUBST(BLAS_LIBS)
189
190LIBS="$acx_blas_save_LIBS"
191
192# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
193if test x"$acx_blas_ok" = xyes; then
194        ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1])
195        :
196else
197        acx_blas_ok=no
198        $2
199fi
200])dnl ACX_BLAS
Note: See TracBrowser for help on using the repository browser.