"Fossies" - the Fresh Open Source Software Archive

Member "harminv-1.4.2/m4/ax_blas.m4" (14 Jun 2021, 8257 Bytes) of package /linux/privat/harminv-1.4.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "ax_blas.m4": 1.4.1_vs_1.4.2.

    1 # ===========================================================================
    2 #         https://www.gnu.org/software/autoconf-archive/ax_blas.html
    3 # ===========================================================================
    4 #
    5 # SYNOPSIS
    6 #
    7 #   AX_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
    8 #
    9 # DESCRIPTION
   10 #
   11 #   This macro looks for a library that implements the BLAS linear-algebra
   12 #   interface (see http://www.netlib.org/blas/). On success, it sets the
   13 #   BLAS_LIBS output variable to hold the requisite library linkages.
   14 #
   15 #   To link with BLAS, you should link with:
   16 #
   17 #     $BLAS_LIBS $LIBS $FLIBS
   18 #
   19 #   in that order. FLIBS is the output variable of the
   20 #   AC_F77_LIBRARY_LDFLAGS macro (called if necessary by AX_BLAS), and is
   21 #   sometimes necessary in order to link with F77 libraries. Users will also
   22 #   need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same
   23 #   reason.
   24 #
   25 #   Many libraries are searched for, from ATLAS to CXML to ESSL. The user
   26 #   may also use --with-blas=<lib> in order to use some specific BLAS
   27 #   library <lib>. In order to link successfully, however, be aware that you
   28 #   will probably need to use the same Fortran compiler (which can be set
   29 #   via the F77 env. var.) as was used to compile the BLAS library.
   30 #
   31 #   ACTION-IF-FOUND is a list of shell commands to run if a BLAS library is
   32 #   found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it is
   33 #   not found. If ACTION-IF-FOUND is not specified, the default action will
   34 #   define HAVE_BLAS.
   35 #
   36 # LICENSE
   37 #
   38 #   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
   39 #   Copyright (c) 2019 Geoffrey M. Oxberry <goxberry@gmail.com>
   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 <https://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 17
   68 
   69 AU_ALIAS([ACX_BLAS], [AX_BLAS])
   70 AC_DEFUN([AX_BLAS], [
   71 AC_PREREQ([2.55])
   72 AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
   73 AC_REQUIRE([AC_CANONICAL_HOST])
   74 ax_blas_ok=no
   75 
   76 AC_ARG_WITH(blas,
   77 	[AS_HELP_STRING([--with-blas=<lib>], [use BLAS library <lib>])])
   78 case $with_blas in
   79 	yes | "") ;;
   80 	no) ax_blas_ok=disable ;;
   81 	-* | */* | *.a | *.so | *.so.* | *.dylib | *.dylib.* | *.o)
   82 		BLAS_LIBS="$with_blas"
   83 	;;
   84 	*) BLAS_LIBS="-l$with_blas" ;;
   85 esac
   86 
   87 # Get fortran linker names of BLAS functions to check for.
   88 AC_F77_FUNC(sgemm)
   89 AC_F77_FUNC(dgemm)
   90 
   91 ax_blas_save_LIBS="$LIBS"
   92 LIBS="$LIBS $FLIBS"
   93 
   94 # First, check BLAS_LIBS environment variable
   95 if test $ax_blas_ok = no; then
   96 if test "x$BLAS_LIBS" != x; then
   97 	save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
   98 	AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS])
   99 	AC_LINK_IFELSE([AC_LANG_CALL([], [$sgemm])], [ax_blas_ok=yes], [BLAS_LIBS=""])
  100 	AC_MSG_RESULT($ax_blas_ok)
  101 	LIBS="$save_LIBS"
  102 fi
  103 fi
  104 
  105 # BLAS linked to by default?  (happens on some supercomputers)
  106 if test $ax_blas_ok = no; then
  107 	save_LIBS="$LIBS"; LIBS="$LIBS"
  108 	AC_MSG_CHECKING([if $sgemm is being linked in already])
  109 	AC_LINK_IFELSE([AC_LANG_CALL([], [$sgemm])], [ax_blas_ok=yes])
  110 	AC_MSG_RESULT($ax_blas_ok)
  111 	LIBS="$save_LIBS"
  112 fi
  113 
  114 # BLAS in OpenBLAS library? (http://xianyi.github.com/OpenBLAS/)
  115 if test $ax_blas_ok = no; then
  116 	AC_CHECK_LIB(openblas, $sgemm, [ax_blas_ok=yes
  117 			                BLAS_LIBS="-lopenblas"])
  118 fi
  119 
  120 # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
  121 if test $ax_blas_ok = no; then
  122 	AC_CHECK_LIB(atlas, ATL_xerbla,
  123 		[AC_CHECK_LIB(f77blas, $sgemm,
  124 		[AC_CHECK_LIB(cblas, cblas_dgemm,
  125 			[ax_blas_ok=yes
  126 			 BLAS_LIBS="-lcblas -lf77blas -latlas"],
  127 			[], [-lf77blas -latlas])],
  128 			[], [-latlas])])
  129 fi
  130 
  131 # BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
  132 if test $ax_blas_ok = no; then
  133 	AC_CHECK_LIB(blas, $sgemm,
  134 		[AC_CHECK_LIB(dgemm, $dgemm,
  135 		[AC_CHECK_LIB(sgemm, $sgemm,
  136 			[ax_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"],
  137 			[], [-lblas])],
  138 			[], [-lblas])])
  139 fi
  140 
  141 # BLAS in Intel MKL library?
  142 if test $ax_blas_ok = no; then
  143 	# MKL for gfortran
  144 	if test x"$ac_cv_fc_compiler_gnu" = xyes; then
  145 		# 64 bit
  146 		if test $host_cpu = x86_64; then
  147 			AC_CHECK_LIB(mkl_gf_lp64, $sgemm,
  148 			[ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread"],,
  149 			[-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread])
  150 		# 32 bit
  151 		elif test $host_cpu = i686; then
  152 			AC_CHECK_LIB(mkl_gf, $sgemm,
  153 				[ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf -lmkl_sequential -lmkl_core -lpthread"],,
  154 				[-lmkl_gf -lmkl_sequential -lmkl_core -lpthread])
  155 		fi
  156 	# MKL for other compilers (Intel, PGI, ...?)
  157 	else
  158 		# 64-bit
  159 		if test $host_cpu = x86_64; then
  160 			AC_CHECK_LIB(mkl_intel_lp64, $sgemm,
  161 				[ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread"],,
  162 				[-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread])
  163 		# 32-bit
  164 		elif test $host_cpu = i686; then
  165 			AC_CHECK_LIB(mkl_intel, $sgemm,
  166 				[ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_sequential -lmkl_core -lpthread"],,
  167 				[-lmkl_intel -lmkl_sequential -lmkl_core -lpthread])
  168 		fi
  169 	fi
  170 fi
  171 # Old versions of MKL
  172 if test $ax_blas_ok = no; then
  173 	AC_CHECK_LIB(mkl, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lmkl -lguide -lpthread"],,[-lguide -lpthread])
  174 fi
  175 
  176 # BLAS in Apple vecLib library?
  177 if test $ax_blas_ok = no; then
  178 	save_LIBS="$LIBS"; LIBS="-framework vecLib $LIBS"
  179 	AC_MSG_CHECKING([for $sgemm in -framework vecLib])
  180 	AC_LINK_IFELSE([AC_LANG_CALL([], [$sgemm])], [ax_blas_ok=yes;BLAS_LIBS="-framework vecLib"])
  181 	AC_MSG_RESULT($ax_blas_ok)
  182 	LIBS="$save_LIBS"
  183 fi
  184 
  185 # BLAS in Alpha CXML library?
  186 if test $ax_blas_ok = no; then
  187 	AC_CHECK_LIB(cxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lcxml"])
  188 fi
  189 
  190 # BLAS in Alpha DXML library? (now called CXML, see above)
  191 if test $ax_blas_ok = no; then
  192 	AC_CHECK_LIB(dxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-ldxml"])
  193 fi
  194 
  195 # BLAS in Sun Performance library?
  196 if test $ax_blas_ok = no; then
  197 	if test "x$GCC" != xyes; then # only works with Sun CC
  198 		AC_CHECK_LIB(sunmath, acosp,
  199 			[AC_CHECK_LIB(sunperf, $sgemm,
  200 				[BLAS_LIBS="-xlic_lib=sunperf -lsunmath"
  201                                  ax_blas_ok=yes],[],[-lsunmath])])
  202 	fi
  203 fi
  204 
  205 # BLAS in SCSL library?  (SGI/Cray Scientific Library)
  206 if test $ax_blas_ok = no; then
  207 	AC_CHECK_LIB(scs, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lscs"])
  208 fi
  209 
  210 # BLAS in SGIMATH library?
  211 if test $ax_blas_ok = no; then
  212 	AC_CHECK_LIB(complib.sgimath, $sgemm,
  213 		     [ax_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"])
  214 fi
  215 
  216 # BLAS in IBM ESSL library? (requires generic BLAS lib, too)
  217 if test $ax_blas_ok = no; then
  218 	AC_CHECK_LIB(blas, $sgemm,
  219 		[AC_CHECK_LIB(essl, $sgemm,
  220 			[ax_blas_ok=yes; BLAS_LIBS="-lessl -lblas"],
  221 			[], [-lblas $FLIBS])])
  222 fi
  223 
  224 # Generic BLAS library?
  225 if test $ax_blas_ok = no; then
  226 	AC_CHECK_LIB(blas, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lblas"])
  227 fi
  228 
  229 AC_SUBST(BLAS_LIBS)
  230 
  231 LIBS="$ax_blas_save_LIBS"
  232 
  233 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
  234 if test x"$ax_blas_ok" = xyes; then
  235         ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1])
  236         :
  237 else
  238         ax_blas_ok=no
  239         $2
  240 fi
  241 ])dnl AX_BLAS