source: trunk/m4/yat_cblas.m4

Last change on this file was 3728, checked in by Peter, 3 years ago

New macro YAT_SEARCH_LIBS, similar to AC_SEARCH_LIBS but does not
modify variable LIBS.

Use macro in macros: YAT_LIB_CBLAS, YAT_LIB_HTS, and _YAT_CHECK_ZLIB
to simplify code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 3.2 KB
Line 
1## $Id: yat_cblas.m4 3728 2018-03-16 04:12:53Z peter $
2
3#
4# serial 3 (yat 0.16)
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, 2018 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  YAT_SEARCH_LIBS([cblas_sgemm],
78                 [tatlas satlas cblas opencblas mkl_core scs],
79                 [yat_cblas_ok=yes;
80                  CBLAS_LIB=$yat_cv_search_cblas_sgemm
81                 ])
82])
83
84# CBLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
85# Old atlas is linked in with -latlas -lcblas
86AS_IF([test $yat_cblas_ok = no], [
87  AC_CHECK_LIB([ATL_xerbla], [atlas],
88               [AC_CHECK_LIB([cblas_sgemm], [cblas],
89                             [yat_cblas_ok=yes;
90                              CBLAS_LIB="-lcblas -latlas"])
91               ])
92  LIBS=$save_LIBS;
93])
94
95# Execute ACTION-IF-FOUND or ACTION-IF-NOT-FOUND
96AS_IF([test x"$yat_cblas_ok" = x"yes"],
97      [m4_default([$1], [:])],
98      [yat_cblas_ok=no; m4_default([$2], [:])])
99])dnl YAT_CBLAS
Note: See TracBrowser for help on using the repository browser.