3887
|
1 dnl @synopsis ACX_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) |
|
2 dnl |
|
3 dnl This macro looks for a library that implements the BLAS |
|
4 dnl linear-algebra interface (see http://www.netlib.org/blas/). |
|
5 dnl On success, it sets the BLAS_LIBS output variable to |
|
6 dnl hold the requisite library linkages. |
|
7 dnl |
|
8 dnl To link with BLAS, you should link with: |
|
9 dnl |
|
10 dnl $BLAS_LIBS $LIBS $FLIBS |
|
11 dnl |
|
12 dnl in that order. FLIBS is the output variable of the |
|
13 dnl AC_F77_LIBRARY_LDFLAGS macro (called if necessary by ACX_BLAS), |
|
14 dnl and is sometimes necessary in order to link with F77 libraries. |
|
15 dnl Users will also need to use AC_F77_DUMMY_MAIN (see the autoconf |
|
16 dnl manual), for the same reason. |
|
17 dnl |
|
18 dnl Many libraries are searched for, from ATLAS to CXML to ESSL. |
|
19 dnl The user may also use --with-blas=<lib> in order to use some |
|
20 dnl specific BLAS library <lib>. In order to link successfully, |
|
21 dnl however, be aware that you will probably need to use the same |
|
22 dnl Fortran compiler (which can be set via the F77 env. var.) as |
|
23 dnl was used to compile the BLAS library. |
|
24 dnl |
|
25 dnl ACTION-IF-FOUND is a list of shell commands to run if a BLAS |
|
26 dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands |
|
27 dnl to run it if it is not found. If ACTION-IF-FOUND is not specified, |
|
28 dnl the default action will define HAVE_BLAS. |
|
29 dnl |
|
30 dnl This macro requires autoconf 2.50 or later. |
|
31 dnl |
|
32 dnl @version $Id: acx_blas.m4,v 1.2 2001/12/13 01:03:06 simons Exp $ |
|
33 dnl @author Steven G. Johnson <stevenj@alum.mit.edu> |
|
34 dnl |
|
35 AC_DEFUN([ACX_BLAS], [ |
|
36 AC_PREREQ(2.50) |
|
37 AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS]) |
|
38 acx_blas_ok=no |
|
39 |
|
40 AC_ARG_WITH(blas, |
|
41 [AC_HELP_STRING([--with-blas=<lib>], [use BLAS library <lib>])]) |
|
42 case $with_blas in |
|
43 yes | "") ;; |
|
44 no) acx_blas_ok=disable ;; |
|
45 -* | */* | *.a | *.so | *.so.* | *.o) BLAS_LIBS="$with_blas" ;; |
|
46 *) BLAS_LIBS="-l$with_blas" ;; |
|
47 esac |
|
48 |
|
49 # Get fortran linker names of BLAS functions to check for. |
|
50 AC_F77_FUNC(sgemm) |
|
51 AC_F77_FUNC(dgemm) |
|
52 |
|
53 acx_blas_save_LIBS="$LIBS" |
|
54 LIBS="$LIBS $FLIBS" |
|
55 |
|
56 # First, check BLAS_LIBS environment variable |
|
57 if test $acx_blas_ok = no; then |
|
58 if test "x$BLAS_LIBS" != x; then |
|
59 save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS" |
|
60 AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS]) |
|
61 AC_TRY_LINK_FUNC($sgemm, [acx_blas_ok=yes], [BLAS_LIBS=""]) |
|
62 AC_MSG_RESULT($acx_blas_ok) |
|
63 LIBS="$save_LIBS" |
|
64 fi |
|
65 fi |
|
66 |
|
67 # BLAS linked to by default? (happens on some supercomputers) |
|
68 if test $acx_blas_ok = no; then |
|
69 save_LIBS="$LIBS"; LIBS="$LIBS" |
|
70 AC_CHECK_FUNC($sgemm, [acx_blas_ok=yes]) |
|
71 LIBS="$save_LIBS" |
|
72 fi |
|
73 |
|
74 # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) |
|
75 if test $acx_blas_ok = no; then |
|
76 AC_CHECK_LIB(atlas, ATL_xerbla, |
|
77 [AC_CHECK_LIB(f77blas, $sgemm, |
|
78 [AC_CHECK_LIB(cblas, cblas_dgemm, |
|
79 [acx_blas_ok=yes |
|
80 BLAS_LIBS="-lcblas -lf77blas -latlas"], |
|
81 [], [-lf77blas -latlas])], |
|
82 [], [-latlas])]) |
|
83 fi |
|
84 |
4157
|
85 # BLAS in Apple vecLib framework? (Mac OS X) |
|
86 if test $acx_blas_ok = no; then |
|
87 vlib_flags="-framework vecLib" |
|
88 save_LIBS="$LIBS"; LIBS="$vlib_flags $LIBS" |
|
89 AC_MSG_CHECKING([for $sgemm in $vlib_flags]) |
|
90 AC_TRY_LINK_FUNC($sgemm, [acx_blas_ok=yes; BLAS_LIBS="$vlib_flags"], |
|
91 [BLAS_LIBS=""]) |
|
92 AC_MSG_RESULT($acx_blas_ok) |
|
93 LIBS="$save_LIBS" |
|
94 fi |
|
95 |
3887
|
96 # BLAS in PhiPACK libraries? (requires generic BLAS lib, too) |
|
97 if test $acx_blas_ok = no; then |
|
98 AC_CHECK_LIB(blas, $sgemm, |
|
99 [AC_CHECK_LIB(dgemm, $dgemm, |
|
100 [AC_CHECK_LIB(sgemm, $sgemm, |
|
101 [acx_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"], |
|
102 [], [-lblas])], |
|
103 [], [-lblas])]) |
|
104 fi |
|
105 |
|
106 # BLAS in Alpha CXML library? |
|
107 if test $acx_blas_ok = no; then |
|
108 AC_CHECK_LIB(cxml, $sgemm, [acx_blas_ok=yes;BLAS_LIBS="-lcxml"]) |
|
109 fi |
|
110 |
|
111 # BLAS in Alpha DXML library? (now called CXML, see above) |
|
112 if test $acx_blas_ok = no; then |
|
113 AC_CHECK_LIB(dxml, $sgemm, [acx_blas_ok=yes;BLAS_LIBS="-ldxml"]) |
|
114 fi |
|
115 |
|
116 # BLAS in Sun Performance library? |
|
117 if test $acx_blas_ok = no; then |
|
118 if test "x$GCC" != xyes; then # only works with Sun CC |
|
119 AC_CHECK_LIB(sunmath, acosp, |
|
120 [AC_CHECK_LIB(sunperf, $sgemm, |
|
121 [BLAS_LIBS="-xlic_lib=sunperf -lsunmath" |
|
122 acx_blas_ok=yes],[],[-lsunmath])]) |
|
123 fi |
|
124 fi |
|
125 |
|
126 # BLAS in SCSL library? (SGI/Cray Scientific Library) |
|
127 if test $acx_blas_ok = no; then |
|
128 AC_CHECK_LIB(scs, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lscs"]) |
|
129 fi |
|
130 |
|
131 # BLAS in SGIMATH library? |
|
132 if test $acx_blas_ok = no; then |
|
133 AC_CHECK_LIB(complib.sgimath, $sgemm, |
|
134 [acx_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"]) |
|
135 fi |
|
136 |
|
137 # BLAS in IBM ESSL library? (requires generic BLAS lib, too) |
|
138 if test $acx_blas_ok = no; then |
|
139 AC_CHECK_LIB(blas, $sgemm, |
|
140 [AC_CHECK_LIB(essl, $sgemm, |
|
141 [acx_blas_ok=yes; BLAS_LIBS="-lessl -lblas"], |
|
142 [], [-lblas $FLIBS])]) |
|
143 fi |
|
144 |
|
145 # Generic BLAS library? |
|
146 if test $acx_blas_ok = no; then |
|
147 AC_CHECK_LIB(blas, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lblas"]) |
|
148 fi |
|
149 |
|
150 AC_SUBST(BLAS_LIBS) |
|
151 |
|
152 LIBS="$acx_blas_save_LIBS" |
|
153 |
|
154 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: |
|
155 if test x"$acx_blas_ok" = xyes; then |
|
156 ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1]) |
|
157 : |
|
158 else |
|
159 acx_blas_ok=no |
|
160 $2 |
|
161 fi |
|
162 ])dnl ACX_BLAS |