10951
|
1 # =========================================================================== |
|
2 # http://www.gnu.org/software/autoconf-archive/ax_blas.html |
|
3 # =========================================================================== |
|
4 # |
|
5 # SYNOPSIS |
|
6 # |
|
7 # AX_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 AX_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 # LICENSE |
|
37 # |
|
38 # Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu> |
|
39 # |
|
40 # This program is free software: you can redistribute it and/or modify it |
|
41 # under the terms of the GNU General Public License as published by the |
|
42 # Free Software Foundation, either version 3 of the License, or (at your |
|
43 # option) any later version. |
|
44 # |
|
45 # This program is distributed in the hope that it will be useful, but |
|
46 # WITHOUT ANY WARRANTY; without even the implied warranty of |
|
47 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|
48 # Public License for more details. |
|
49 # |
|
50 # You should have received a copy of the GNU General Public License along |
|
51 # with this program. If not, see <http://www.gnu.org/licenses/>. |
|
52 # |
|
53 # As a special exception, the respective Autoconf Macro's copyright owner |
|
54 # gives unlimited permission to copy, distribute and modify the configure |
|
55 # scripts that are the output of Autoconf when processing the Macro. You |
|
56 # need not follow the terms of the GNU General Public License when using |
|
57 # or distributing such scripts, even though portions of the text of the |
|
58 # Macro appear in them. The GNU General Public License (GPL) does govern |
|
59 # all other use of the material that constitutes the Autoconf Macro. |
|
60 # |
|
61 # This special exception to the GPL applies to versions of the Autoconf |
|
62 # Macro released by the Autoconf Archive. When you make and distribute a |
|
63 # modified version of the Autoconf Macro, you may extend this special |
|
64 # exception to the GPL to apply to your modified version as well. |
|
65 |
|
66 #serial 8 |
|
67 |
|
68 AU_ALIAS([ACX_BLAS], [AX_BLAS]) |
|
69 AC_DEFUN([AX_BLAS], [ |
3887
|
70 AC_PREREQ(2.50) |
|
71 AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS]) |
10951
|
72 ax_blas_ok=no |
3887
|
73 |
|
74 AC_ARG_WITH(blas, |
5844
|
75 [AS_HELP_STRING([--with-blas=<lib>], [use BLAS library <lib>])]) |
3887
|
76 case $with_blas in |
|
77 yes | "") ;; |
10951
|
78 no) ax_blas_ok=disable ;; |
3887
|
79 -* | */* | *.a | *.so | *.so.* | *.o) BLAS_LIBS="$with_blas" ;; |
|
80 *) BLAS_LIBS="-l$with_blas" ;; |
|
81 esac |
|
82 |
|
83 # Get fortran linker names of BLAS functions to check for. |
10951
|
84 AC_F77_FUNC(sgemm) |
|
85 AC_F77_FUNC(dgemm) |
3887
|
86 |
10951
|
87 ax_blas_save_LIBS="$LIBS" |
3887
|
88 LIBS="$LIBS $FLIBS" |
|
89 |
|
90 # First, check BLAS_LIBS environment variable |
10951
|
91 if test $ax_blas_ok = no; then |
3887
|
92 if test "x$BLAS_LIBS" != x; then |
|
93 save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS" |
|
94 AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS]) |
10951
|
95 AC_TRY_LINK_FUNC($sgemm, [ax_blas_ok=yes], [BLAS_LIBS=""]) |
|
96 AC_MSG_RESULT($ax_blas_ok) |
3887
|
97 LIBS="$save_LIBS" |
|
98 fi |
|
99 fi |
|
100 |
|
101 # BLAS linked to by default? (happens on some supercomputers) |
10951
|
102 if test $ax_blas_ok = no; then |
3887
|
103 save_LIBS="$LIBS"; LIBS="$LIBS" |
10951
|
104 AC_CHECK_FUNC($sgemm, [ax_blas_ok=yes]) |
3887
|
105 LIBS="$save_LIBS" |
|
106 fi |
|
107 |
|
108 # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) |
10951
|
109 if test $ax_blas_ok = no; then |
3887
|
110 AC_CHECK_LIB(atlas, ATL_xerbla, |
|
111 [AC_CHECK_LIB(f77blas, $sgemm, |
|
112 [AC_CHECK_LIB(cblas, cblas_dgemm, |
10951
|
113 [ax_blas_ok=yes |
3887
|
114 BLAS_LIBS="-lcblas -lf77blas -latlas"], |
|
115 [], [-lf77blas -latlas])], |
|
116 [], [-latlas])]) |
|
117 fi |
|
118 |
|
119 # BLAS in PhiPACK libraries? (requires generic BLAS lib, too) |
10951
|
120 if test $ax_blas_ok = no; then |
3887
|
121 AC_CHECK_LIB(blas, $sgemm, |
|
122 [AC_CHECK_LIB(dgemm, $dgemm, |
|
123 [AC_CHECK_LIB(sgemm, $sgemm, |
10951
|
124 [ax_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"], |
3887
|
125 [], [-lblas])], |
|
126 [], [-lblas])]) |
|
127 fi |
|
128 |
10951
|
129 # BLAS in Intel MKL library? |
|
130 if test $ax_blas_ok = no; then |
|
131 AC_CHECK_LIB(mkl, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lmkl"]) |
|
132 fi |
|
133 |
|
134 # BLAS in Apple vecLib library? |
|
135 if test $ax_blas_ok = no; then |
|
136 save_LIBS="$LIBS"; LIBS="-framework vecLib $LIBS" |
|
137 AC_CHECK_FUNC($sgemm, [ax_blas_ok=yes;BLAS_LIBS="-framework vecLib"]) |
|
138 LIBS="$save_LIBS" |
|
139 fi |
|
140 |
3887
|
141 # BLAS in Alpha CXML library? |
10951
|
142 if test $ax_blas_ok = no; then |
|
143 AC_CHECK_LIB(cxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lcxml"]) |
3887
|
144 fi |
|
145 |
|
146 # BLAS in Alpha DXML library? (now called CXML, see above) |
10951
|
147 if test $ax_blas_ok = no; then |
|
148 AC_CHECK_LIB(dxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-ldxml"]) |
3887
|
149 fi |
|
150 |
|
151 # BLAS in Sun Performance library? |
10951
|
152 if test $ax_blas_ok = no; then |
3887
|
153 if test "x$GCC" != xyes; then # only works with Sun CC |
|
154 AC_CHECK_LIB(sunmath, acosp, |
|
155 [AC_CHECK_LIB(sunperf, $sgemm, |
10951
|
156 [BLAS_LIBS="-xlic_lib=sunperf -lsunmath" |
|
157 ax_blas_ok=yes],[],[-lsunmath])]) |
3887
|
158 fi |
|
159 fi |
|
160 |
|
161 # BLAS in SCSL library? (SGI/Cray Scientific Library) |
10951
|
162 if test $ax_blas_ok = no; then |
|
163 AC_CHECK_LIB(scs, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lscs"]) |
3887
|
164 fi |
|
165 |
|
166 # BLAS in SGIMATH library? |
10951
|
167 if test $ax_blas_ok = no; then |
3887
|
168 AC_CHECK_LIB(complib.sgimath, $sgemm, |
10951
|
169 [ax_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"]) |
3887
|
170 fi |
|
171 |
|
172 # BLAS in IBM ESSL library? (requires generic BLAS lib, too) |
10951
|
173 if test $ax_blas_ok = no; then |
3887
|
174 AC_CHECK_LIB(blas, $sgemm, |
|
175 [AC_CHECK_LIB(essl, $sgemm, |
10951
|
176 [ax_blas_ok=yes; BLAS_LIBS="-lessl -lblas"], |
3887
|
177 [], [-lblas $FLIBS])]) |
|
178 fi |
|
179 |
|
180 # Generic BLAS library? |
10951
|
181 if test $ax_blas_ok = no; then |
|
182 AC_CHECK_LIB(blas, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lblas"]) |
3887
|
183 fi |
|
184 |
|
185 AC_SUBST(BLAS_LIBS) |
|
186 |
10951
|
187 LIBS="$ax_blas_save_LIBS" |
3887
|
188 |
|
189 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: |
10951
|
190 if test x"$ax_blas_ok" = xyes; then |
3887
|
191 ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1]) |
|
192 : |
|
193 else |
10951
|
194 ax_blas_ok=no |
3887
|
195 $2 |
|
196 fi |
10951
|
197 ])dnl AX_BLAS |