source: trunk/m4/yat_cblas.m4 @ 3453

Last change on this file since 3453 was 3453, checked in by Peter, 6 years ago

closes #839

Simplify code by looping over different cblas implementations using
AC_SEARCH_LIBS rather than repeating code. Include search for satlas
and tatlas, which are the names in new versions of ATLAS.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 3.3 KB
Line 
1## $Id: yat_cblas.m4 3453 2015-12-08 03:53:16Z peter $
2
3#
4# serial 2 (yat 0.14)
5#
6
7# SYNOPSIS
8#
9#   YAT_LIB_CBLAS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
10#
11# DESCRIPTION
12#
13#   This macro looks for a library that implements the BLAS C API. The
14#   macro adds a configure option --with-cblas=LIB that can be used to
15#   select a specific CBLAS library.
16#
17#   On success it sets the YAT_CBLAS_LIB variable and execute
18#   ACTION-IF-FOUND. Otherise ACTION-IF-NOT-FOUND is executed.
19#
20# COPYLEFT
21#
22#   Copyright (C) 2009, 2012, 2013, 2015 Peter Johansson
23#
24#   This file is part of the yat library, http://dev.thep.lu.se/yat
25#
26#   The yat library is free software; you can redistribute it and/or
27#   modify it under the terms of the GNU General Public License as
28#   published by the Free Software Foundation; either version 3 of the
29#   License, or (at your option) any later version.
30#
31#   The yat library is distributed in the hope that it will be useful,
32#   but WITHOUT ANY WARRANTY; without even the implied warranty of
33#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
34#   General Public License for more details.
35#
36#   You should have received a copy of the GNU General Public License
37#   along with yat. If not, see <http://www.gnu.org/licenses/>.
38#
39
40#   This macro is a slimmed and modified version of the ACX_BLAS macro
41#   available from http://autoconf-archive.cryp.to/acx_blas.html
42#   written by Steven G. Johnson <stevenj@alum.mit.edu>
43
44
45
46AC_DEFUN([YAT_LIB_CBLAS],
47[
48AC_PREREQ([2.60]) dnl we use AS_CASE
49yat_cblas_ok=no;
50save_LIBS=$LIBS;
51
52AC_ARG_WITH([cblas],
53            [AS_HELP_STRING([--with-cblas=LIB], [use CBLAS library LIB])])
54
55AS_CASE([$with_cblas],
56        [yes | ""], ,
57        [no], [yat_cblas_ok=disable],
58        [-* | */* | *.a | *.so | *.so.* | *.o], [CBLAS_LIB="$with_blas"],
59        [CBLAS_LIB="-l$with_blas"])
60
61# First, check CBLAS_LIB environment variable
62AS_IF([test $yat_cblas_ok = no && test "x$CBLAS_LIB" != x],
63      [AC_LINK_IFELSE([AC_LANG_CALL(,[cblas_sgemm])],
64                      [yat_cblas_ok=yes],
65                      [CBLAS_LIB=""])])
66
67# Find library that implements cblas; search in the following order
68# - CBLAS linked by default (or with current $LIBS)
69# - CBLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
70#   - tatlas
71#   - satlas
72# - CBLAS as -lcblas
73# - Openblas available from http://xianyi.github.com/OpenBLAS/
74# - CBLAS in Intel MKL library?
75# - CBLAS in SCSL library (SGI/Cray Scientific Library)
76AS_IF([test $yat_cblas_ok = no], [
77  AC_SEARCH_LIBS([cblas_sgemm],
78                 [tatlas satlas cblas opencblas mkl_core scs],
79                 [yat_cblas_ok=yes;
80                  AS_IF([test "$ac_cv_search_cblas_sgemm" != "none required"],[
81                    CBLAS_LIB=$ac_cv_search_cblas_sgemm
82                  ])
83                 ])
84  LIBS=$save_LIBS
85])
86
87# CBLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
88# Old atlas is linked in with -latlas -lcblas
89AS_IF([test $yat_cblas_ok = no], [
90  AC_CHECK_LIB([ATL_xerbla], [atlas],
91               [AC_CHECK_LIB([cblas_sgemm], [cblas],
92                             [yat_cblas_ok=yes;
93                              CBLAS_LIB="-lcblas -latlas"])
94               ])
95  LIBS=$save_LIBS;
96])
97
98# Execute ACTION-IF-FOUND or ACTION-IF-NOT-FOUND
99AS_IF([test x"$yat_cblas_ok" = x"yes"],
100      [m4_default([$1], [:])],
101      [yat_cblas_ok=no; m4_default([$2], [:])])
102])dnl YAT_CBLAS
Note: See TracBrowser for help on using the repository browser.