File: lapack.m4

package info (click to toggle)
gretl 2016d-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 48,620 kB
  • ctags: 22,779
  • sloc: ansic: 345,830; sh: 4,648; makefile: 2,712; xml: 570; perl: 364
file content (114 lines) | stat: -rw-r--r-- 3,425 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Configure paths for lapack
# Allin Cottrell <cottrell@wfu.edu>, last updated September 2013

dnl AM_PATH_LAPACK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Test for LAPACK, and define LAPACK_CFLAGS and LAPACK_LIBS.
dnl
AC_DEFUN([AM_PATH_LAPACK],
[dnl 
AC_ARG_WITH(lapack-prefix,[  --with-lapack-prefix=PFX   Prefix where LAPACK is installed (optional)],
            lapack_config_prefix="$withval", lapack_config_prefix="")
AC_ARG_VAR([LAPACK_LIBS],[linker flags for lapack, overriding auto-detection])

  if test x"${LAPACK_LIBS}" = x ; then 
     AC_MSG_CHECKING(for libgfortran, libg2c or libf2c)
     AC_CHECK_LIB(gfortran,_gfortran_abort,FLIB="-lgfortran",FLIB="none")
     if test $FLIB = "none" ; then
        AC_CHECK_LIB(g2c,c_sqrt,FLIB="-lg2c",FLIB="none")
     fi
     if test $FLIB = "none" ; then
        AC_CHECK_LIB(f2c,c_sqrt,FLIB="-lf2c",FLIB="none")
     fi
     if test $FLIB = "none" ; then
        echo "*** Couldn't find libgfortran, libg2c or libf2c"
        FLIB=""
     fi
  fi

  AC_MSG_CHECKING(for LAPACK)
  if test x"${LAPACK_LIBS}" = x ; then
     if test "x$lapack_config_prefix" = x ; then
        LAPACK_LIBS="-llapack -lblas $FLIB"
     else
        LAPACK_LIBS="-L$lapack_config_prefix -llapack -lblas $FLIB"
     fi
  fi

  ac_save_CFLAGS="$CFLAGS"
  ac_save_LIBS="$LIBS"
  CFLAGS="$LAPACK_CFLAGS $CFLAGS"
  LIBS="$LAPACK_LIBS $LIBS"

dnl
dnl Check the installed LAPACK.
dnl
  rm -f conf.lapacktest
  AC_TRY_RUN([
#include <stdlib.h>
#include "gretl_f2c.h"

int main (void)
{
  integer ispec;
  real zero = 0.0;
  real one = 1.0;

  ieeeck_(&ispec, &zero, &one);
  system("touch conf.lapacktest");
  return 0;
}
],, no_lapack=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])

if test "x$no_lapack" = x ; then
     AC_MSG_RESULT(yes)
     ifelse([$2], , :, [$2])
     rm -f conf.blastest
     AC_TRY_RUN([
     #include <stdlib.h>

     int openblas_get_parallel(void);

     int main (void)
     {
       if (openblas_get_parallel() != 1) {
          exit(EXIT_FAILURE);
       }
       system("touch conf.blastest");
       return 0;
     }
     ],blas_pthreads=yes,)
  else
     AC_MSG_RESULT(no)
     if test -f conf.lapacktest ; then
       :
     else
       echo "*** Could not run LAPACK test program, checking why..."
       AC_TRY_LINK([
#include <stdio.h>
],     [ return (1); ],
       [ echo "*** The test program compiled, but did not run. This usually means"
         echo "*** that the run-time linker is not finding LAPACK. If it is not"
         echo "*** finding LAPACK, you'll need to set your LD_LIBRARY_PATH "
         echo "*** environment variable, or edit /etc/ld.so.conf to point"
         echo "*** to the installed location.  Also, make sure you have run"
         echo "*** ldconfig if that is required on your system."
         echo "***" ],
       [ echo "*** The test program failed to compile or link. See config.log for the"
         echo "*** exact error that occured. This may mean LAPACK was incorrectly installed"
         echo "*** or that you have moved LAPACK since it was installed." ])
         CFLAGS="$ac_save_CFLAGS"
         LIBS="$ac_save_LIBS"
     fi
     LAPACK_CFLAGS=""
     LAPACK_LIBS=""
     ifelse([$3], , :, [$3])
  fi
  dnl finalize
  CFLAGS="$ac_save_CFLAGS"
  LIBS="$ac_save_LIBS"
  AC_SUBST(LAPACK_CFLAGS)
  AC_SUBST(LAPACK_LIBS)
  AC_SUBST(FLIB)
  rm -f conf.lapacktest
  rm -f conf.blastest
])