## $Id$
#
# serial 1 (yat 0.11)
#
# SYNOPSIS
#
# YAT_LIB_CBLAS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# DESCRIPTION
#
# This macro looks for a library that implements the BLAS C API. The
# macro adds a configure option --with-cblas=LIB that can be used to
# select a specific CBLAS library.
#
# On success it sets the YAT_CBLAS_LIB variable and execute
# ACTION-IF-FOUND. Otherise ACTION-IF-NOT-FOUND is executed.
#
# COPYLEFT
#
# Copyright (C) 2009, 2012, 2013 Peter Johansson
#
# This file is part of the yat library, http://dev.thep.lu.se/yat
#
# The yat library is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# The yat library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with yat. If not, see .
#
# This macro is a slimmed and modified version of the ACX_BLAS macro
# available from http://autoconf-archive.cryp.to/acx_blas.html
# written by Steven G. Johnson
AC_DEFUN([YAT_LIB_CBLAS],
[
AC_PREREQ([2.60]) dnl we use AS_CASE
yat_cblas_ok=no;
save_LIBS=$LIBS;
AC_ARG_WITH([cblas],
[AS_HELP_STRING([--with-cblas=LIB], [use CBLAS library LIB])])
AS_CASE([$with_cblas],
[yes | ""], ,
[no], [yat_cblas_ok=disable],
[-* | */* | *.a | *.so | *.so.* | *.o], [CBLAS_LIB="$with_blas"],
[CBLAS_LIB="-l$with_blas"])
# First, check CBLAS_LIB environment variable
AS_IF([test $yat_cblas_ok = no && test "x$CBLAS_LIB" != x],
[AC_LINK_IFELSE([AC_LANG_CALL(,[cblas_sgemm])],
[yat_cblas_ok=yes],
[CBLAS_LIB=""])])
# CBLAS linked to by default (or with current LIBS)
if test $yat_cblas_ok = no; then
AC_MSG_CHECKING([for cblas_sgemm])
AC_LINK_IFELSE([AC_LANG_CALL(,[cblas_sgemm])],
[yat_cblas_ok=yes CBLAS_LIB=""])
AC_MSG_RESULT([$yat_cblas_ok])
fi
# CBLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
if test $yat_cblas_ok = no; then
AC_SEARCH_LIBS([ATL_xerbla], [atlas],
[AC_SEARCH_LIBS([cblas_sgemm], [cblas],
[yat_cblas_ok=yes;
CBLAS_LIB="-lcblas -latlas"])])
LIBS=$save_LIBS;
fi
if test $yat_cblas_ok = no; then
AC_CHECK_LIB([cblas], [cblas_sgemm], [yat_cblas_ok=yes; CBLAS_LIB="-lcblas";])
fi
# Openblas available from http://xianyi.github.com/OpenBLAS/
if test $yat_cblas_ok = no; then
AC_CHECK_LIB([opencblas], [cblas_sgemm],
[yat_cblas_ok=yes; CBLAS_LIB="-lopencblas";])
fi
# CBLAS in Intel MKL library?
if test $yat_cblas_ok = no; then
AC_CHECK_LIB([mkl_core], [cblas_sgemm],
[acx_blas_ok=yes; CBLAS_LIBS="-lmkl_core"])
fi
# CBLAS in SCSL library? (SGI/Cray Scientific Library)
if test $yat_cblas_ok = no; then
AC_CHECK_LIB([scs], [cblas_sgemm], [yat_cblas_ok=yes; CBLAS_LIB="-lscs"])
fi
# Execute ACTION-IF-FOUND or ACTION-IF-NOT-FOUND
AS_IF([test x"$yat_cblas_ok" = xyes],
[m4_default([$1], [:])],
[yat_cblas_ok=no; m4_default([$2], [:])])
])dnl YAT_CBLAS