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