hypre/config/hypre_blas_macros.m4
falgout 73a0867c82 Added configure-line options to change name mangling for Fortran.
Cleaned up a lot of things in configure itself (still more to do though).
2010-01-25 22:51:05 +00:00

139 lines
4.9 KiB
Plaintext

dnl #*BHEADER********************************************************************
dnl # Copyright (c) 2008, Lawrence Livermore National Security, LLC.
dnl # Produced at the Lawrence Livermore National Laboratory.
dnl # This file is part of HYPRE. See file COPYRIGHT for details.
dnl #
dnl # HYPRE is free software; you can redistribute it and/or modify it under the
dnl # terms of the GNU Lesser General Public License (as published by the Free
dnl # Software Foundation) version 2.1 dated February 1999.
dnl #
dnl # $Revision$
dnl #EHEADER*********************************************************************
dnl @synopsis AC_HYPRE_FIND_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
dnl
dnl This macro looks for a library that implements the BLAS
dnl linear-algebra interface (see http://www.netlib.org/blas/).
dnl On success, it sets the BLASLIBS output variable to
dnl hold the requisite library linkages.
dnl
dnl To link with BLAS, you should link with:
dnl
dnl $BLASLIBS $LIBS $FLIBS
dnl
dnl in that order. FLIBS is the output variable of the
dnl AC_F77_LIBRARY_LDFLAGS macro, and is sometimes necessary in order to link
dnl with F77 libraries.
dnl
dnl Many libraries are searched for, from ATLAS to CXML to ESSL.
dnl The user may specify a BLAS library by using the --with-blas-libs=<lib>
dnl and --with-blas-lib-dirs=<dir> options. In order to link successfully,
dnl however, be aware that you will probably need to use the same Fortran
dnl compiler (which can be set via the F77 env. var.) as was used to compile
dnl the BLAS library.
dnl
dnl ACTION-IF-FOUND is a list of shell commands to run if a BLAS
dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands
dnl to run it if it is not found.
dnl
dnl This macro requires autoconf 2.50 or later.
dnl
dnl @version $Id$
dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
AC_DEFUN([AC_HYPRE_FIND_BLAS],
[
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
#***************************************************************
# Initialize return variables
#***************************************************************
BLASLIBS="null"
BLASLIBDIRS="null"
AC_ARG_WITH(blas,
[AS_HELP_STRING([--with-blas], [Find a system-provided BLAS library])])
case $with_blas in
yes) ;;
*) BLASLIBS="internal" ;;
esac
#***************************************************************
# Save incoming LIBS and LDFLAGS values to be restored
#***************************************************************
hypre_save_LIBS="$LIBS"
hypre_save_LDFLGS="$LDFLAGS"
LIBS="$LIBS $FLIBS"
#***************************************************************
# Set possible BLAS library names
#***************************************************************
BLAS_LIB_NAMES="blas essl dxml cxml mkl scs atlas complib.sgimath sunmath"
#***************************************************************
# Set search paths for BLAS library
#***************************************************************
temp_FLAGS="-L/usr/lib -L/usr/local/lib -L/lib -L/opt/intel/mkl70/lib/32"
LDFLAGS="$temp_FLAGS $LDFLAGS"
#***************************************************************
# Check for function dgemm in BLAS_LIB_NAMES
#***************************************************************
if test "$BLASLIBS" = "null"; then
AC_F77_FUNC(dgemm)
for lib in $BLAS_LIB_NAMES; do
AC_CHECK_LIB($lib, $dgemm, [BLASLIBS=$lib])
done
fi
#***************************************************************
# Set path to selected BLAS library
#***************************************************************
BLAS_SEARCH_DIRS="/usr/lib /usr/local/lib /lib"
if test "$BLASLIBS" != "null"; then
for dir in $BLAS_SEARCH_DIRS; do
if test "$BLASLIBDIRS" = "null" -a -f $dir/lib$BLASLIBS.a; then
BLASLIBDIRS=$dir
fi
if test "$BLASLIBDIRS" = "null" -a -f $dir/lib$BLASLIBS.so; then
BLASLIBDIRS=$dir
fi
done
fi
#***************************************************************
# Set variables if ATLAS or DXML libraries are used
#***************************************************************
if test "$BLASLIBS" = "dxml"; then
AC_DEFINE(HYPRE_USING_DXML, 1, [Using dxml for Blas])
fi
if test "$BLASLIBS" = "essl"; then
AC_DEFINE(HYPRE_USING_ESSL, 1, [Using essl for Blas])
fi
#***************************************************************
# Add -L and -l prefixes if values found
#***************************************************************
if test "$BLASLIBS" != "null" -a "$BLASLIBS" != "internal"; then
BLASLIBS="-l$BLASLIBS"
fi
if test "$BLASLIBDIRS" != "null"; then
BLASLIBDIRS="-L$BLASLIBDIRS"
fi
#***************************************************************
# Restore incoming LIBS and LDFLAGS values
#***************************************************************
LIBS="$hypre_save_LIBS"
LDFLAGS="$hypre_save_LDFLGS"
])dnl AC_HYPRE_FIND_BLAS