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