Rev Author Line No. Line
178 kaklik 1 dnl @synopsis ACX_LAPACK([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
2 dnl
3 dnl This macro looks for a library that implements the LAPACK
4 dnl linear-algebra interface (see http://www.netlib.org/lapack/). On
5 dnl success, it sets the LAPACK_LIBS output variable to hold the
6 dnl requisite library linkages.
7 dnl
8 dnl To link with LAPACK, you should link with:
9 dnl
10 dnl $LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS
11 dnl
12 dnl in that order. BLAS_LIBS is the output variable of the ACX_BLAS
13 dnl macro, called automatically. FLIBS is the output variable of the
14 dnl AC_F77_LIBRARY_LDFLAGS macro (called if necessary by ACX_BLAS), and
15 dnl is sometimes necessary in order to link with F77 libraries. Users
16 dnl will also need to use AC_F77_DUMMY_MAIN (see the autoconf manual),
17 dnl for the same reason.
18 dnl
19 dnl The user may also use --with-lapack=<lib> in order to use some
20 dnl specific LAPACK library <lib>. In order to link successfully,
21 dnl however, be aware that you will probably need to use the same
22 dnl Fortran compiler (which can be set via the F77 env. var.) as was
23 dnl used to compile the LAPACK and BLAS libraries.
24 dnl
25 dnl ACTION-IF-FOUND is a list of shell commands to run if a LAPACK
26 dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
27 dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
28 dnl default action will define HAVE_LAPACK.
29 dnl
30 dnl @category InstalledPackages
31 dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
32 dnl @version 2002-03-12
33 dnl @license GPLWithACException
34  
35 AC_DEFUN([ACX_LAPACK], [
36 AC_REQUIRE([ACX_BLAS])
37 acx_lapack_ok=no
38  
39 AC_ARG_WITH(lapack,
40 [AC_HELP_STRING([--with-lapack=<lib>], [use LAPACK library <lib>])])
41 case $with_lapack in
42 yes | "") ;;
43 no) acx_lapack_ok=disable ;;
44 -* | */* | *.a | *.so | *.so.* | *.o) LAPACK_LIBS="$with_lapack" ;;
45 *) LAPACK_LIBS="-l$with_lapack" ;;
46 esac
47  
48 # Get fortran linker name of LAPACK function to check for.
49 AC_F77_FUNC(cheev)
50  
51 # We cannot use LAPACK if BLAS is not found
52 if test "x$acx_blas_ok" != xyes; then
53 acx_lapack_ok=noblas
54 fi
55  
56 # First, check LAPACK_LIBS environment variable
57 if test "x$LAPACK_LIBS" != x; then
58 save_LIBS="$LIBS"; LIBS="$LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
59 AC_MSG_CHECKING([for $cheev in $LAPACK_LIBS])
60 AC_TRY_LINK_FUNC($cheev, [acx_lapack_ok=yes], [LAPACK_LIBS=""])
61 AC_MSG_RESULT($acx_lapack_ok)
62 LIBS="$save_LIBS"
63 if test acx_lapack_ok = no; then
64 LAPACK_LIBS=""
65 fi
66 fi
67  
68 # LAPACK linked to by default? (is sometimes included in BLAS lib)
69 if test $acx_lapack_ok = no; then
70 save_LIBS="$LIBS"; LIBS="$LIBS $BLAS_LIBS $FLIBS"
71 AC_CHECK_FUNC($cheev, [acx_lapack_ok=yes])
72 LIBS="$save_LIBS"
73 fi
74  
75 # Generic LAPACK library?
76 for lapack in lapack lapack_rs6k; do
77 if test $acx_lapack_ok = no; then
78 save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
79 AC_CHECK_LIB($lapack, $cheev,
80 [acx_lapack_ok=yes; LAPACK_LIBS="-l$lapack"], [], [$FLIBS])
81 LIBS="$save_LIBS"
82 fi
83 done
84  
85 AC_SUBST(LAPACK_LIBS)
86  
87 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
88 if test x"$acx_lapack_ok" = xyes; then
89 ifelse([$1],,AC_DEFINE(HAVE_LAPACK,1,[Define if you have LAPACK library.]),[$1])
90 :
91 else
92 acx_lapack_ok=no
93 $2
94 fi
95 ])dnl ACX_LAPACK