Changeset 3244


Ignore:
Timestamp:
Jun 29, 2014 5:04:29 PM (5 years ago)
Author:
stefan
Message:

put back blas and lapack checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/coin.m4

    r3243 r3244  
    710710m4_foreach_w([myvar],[$1],[
    711711  if test -n "${m4_toupper(myvar)_PCREQUIRES}" ; then
    712     m4_toupper(myvar)_CFLAGS=`$PKG_CONFIG --define-variable prefix=${COIN_DESTDIR}${prefix} --cflags ${m4_toupper(myvar)_PCREQUIRES}` ${m4_toupper(myvar)_CFLAGS}
    713     m4_toupper(myvar)_LIBS=`$PKG_CONFIG --define-variable prefix=${COIN_DESTDIR}${prefix} --libs ${m4_toupper(myvar)_PCREQUIRES}` ${m4_toupper(myvar)_LIBS}
     712    m4_toupper(myvar)_CFLAGS="`$PKG_CONFIG --define-variable prefix=${COIN_DESTDIR}${prefix} --cflags ${m4_toupper(myvar)_PCREQUIRES}` ${m4_toupper(myvar)_CFLAGS}"
     713    m4_toupper(myvar)_LIBS="`$PKG_CONFIG --define-variable prefix=${COIN_DESTDIR}${prefix} --libs ${m4_toupper(myvar)_PCREQUIRES}` ${m4_toupper(myvar)_LIBS}"
    714714  fi
    715715
     
    726726# reset PKG_CONFIG_PATH variable
    727727PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
    728 
    729 ])
     728])
     729
     730
     731###########################################################################
     732#                            COIN_TRY_FLINK                               #
     733###########################################################################
     734
     735# Auxilliary macro to test if a Fortran function name can be linked,
     736# given the current settings of LIBS.  We determine from the context, what
     737# the currently active programming language is, and cast the name accordingly.
     738# The first argument is the name of the function/subroutine, in small letters,
     739# the second argument are the actions taken when the test works, and the
     740# third argument are the actions taken if the test fails.
     741
     742AC_DEFUN([AC_COIN_TRY_FLINK],[
     743case $ac_ext in
     744  f)
     745    AC_TRY_LINK(,[      call $1],[flink_try=yes],[flink_try=no])
     746    ;;
     747  c)
     748    coin_need_flibs=no
     749    flink_try=no
     750    AC_F77_FUNC($1,cfunc$1)
     751    AC_LINK_IFELSE(
     752      [AC_LANG_PROGRAM([void $cfunc$1();],[$cfunc$1()])],
     753      [flink_try=yes],
     754      [if test x"$FLIBS" != x; then
     755         flink_save_libs="$LIBS"
     756         LIBS="$LIBS $FLIBS"
     757         AC_LINK_IFELSE(
     758           [AC_LANG_PROGRAM([void $cfunc$1();],[$cfunc$1()])],
     759           [coin_need_flibs=yes
     760            flint_try=yes]
     761         )
     762         LIBS="$flink_save_libs"
     763       fi
     764      ]
     765    )
     766    ;;
     767  cc|cpp)
     768    coin_need_flibs=no
     769    flink_try=no
     770    AC_F77_FUNC($1,cfunc$1)
     771    AC_LINK_IFELSE(
     772      [AC_LANG_PROGRAM([extern "C" {void $cfunc$1();}],[$cfunc$1()])],
     773      [flink_try=yes],
     774      [if test x"$FLIBS" != x; then
     775         flink_save_libs="$LIBS"
     776         LIBS="$LIBS $FLIBS"
     777         AC_LINK_IFELSE(
     778           [AC_LANG_PROGRAM([extern "C" {void $cfunc$1();}],[$cfunc$1()])],
     779           [coin_need_flibs=yes
     780            flink_try=yes]
     781         )
     782         LIBS="$flink_save_libs"
     783       fi
     784      ]
     785    )
     786    ;;
     787esac
     788if test $flink_try = yes; then
     789  $2
     790else
     791  $3
     792fi
     793]) # AC_COIN_TRY_FLINK
     794
     795###########################################################################
     796#                         COIN_CHECK_PACKAGE_BLAS                         #
     797###########################################################################
     798
     799# This macro checks for a library containing the BLAS library.  It
     800# 1. checks the --with-blas argument
     801# 2. if --with-blas=BUILD has been specified goes to point 5
     802# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS
     803#    to its value
     804# 4. tries standard libraries
     805# 5. calls COIN_CHECK_PACKAGE(Blas, [coinblas], [$1]) to check for
     806#    ThirdParty/Blas
     807# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
     808# BLAS_LIBS is set to the flags required to link with a Blas library.
     809# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
     810# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
     811# In case 5, Blas is added to X_PCREQUIRES.
     812
     813AC_DEFUN([AC_COIN_CHECK_PACKAGE_BLAS],
     814[
     815AC_ARG_WITH([blas],
     816            AC_HELP_STRING([--with-blas],
     817                           [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
     818            [use_blas="$withval"], [use_blas=])
     819
     820# if user specified --with-blas-lib, then we should give COIN_CHECK_PACKAGE
     821# preference
     822AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
     823
     824# Check if user supplied option makes sense
     825if test x"$use_blas" != x; then
     826  if test "$use_blas" = "BUILD"; then
     827    # we come to this later
     828    :
     829  elif test "$use_blas" != "no"; then
     830    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
     831    coin_save_LIBS="$LIBS"
     832    LIBS="$use_blas $LIBS"
     833    AC_COIN_TRY_FLINK([daxpy],
     834                      [test $coin_need_flibs = yes && use_blas="$use_blas $FLIBS"
     835                       AC_MSG_RESULT([yes: $use_blas])],
     836                      [AC_MSG_RESULT([no])
     837                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
     838    LIBS="$coin_save_LIBS"
     839  fi
     840else
     841  # Try to autodetect the library for blas based on build system
     842  case $build in
     843    *-sgi-*)
     844      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
     845      coin_save_LIBS="$LIBS"
     846      LIBS="-lcomplib.sgimath $LIBS"
     847      AC_COIN_TRY_FLINK([daxpy],
     848                        [use_blas="-lcomplib.sgimath"
     849                         test $coin_need_flibs = yes && use_blas="$use_blas $FLIBS"
     850                         AC_MSG_RESULT([yes: $use_blas])
     851                        ],
     852                        [AC_MSG_RESULT([no])])
     853      LIBS="$coin_save_LIBS"
     854      ;;
     855
     856    *-*-solaris*)
     857      AC_MSG_CHECKING([for BLAS in libsunperf])
     858      # Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
     859      # cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
     860      # recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
     861      # that CC and cc will understand -library in Studio 13. The main extra
     862      # function of -xlic_lib and -library is to arrange for the Fortran run-time
     863      # libraries to be linked for C++ and C. We can arrange that explicitly.
     864      coin_save_LIBS="$LIBS"
     865      LIBS="-lsunperf $FLIBS $LIBS"
     866      AC_COIN_TRY_FLINK([daxpy],
     867                        [use_blas='-lsunperf'
     868                         test $coin_need_flibs = yes && use_blas="$use_blas $FLIBS"
     869                         AC_MSG_RESULT([yes: $use_blas])
     870                        ],
     871                        [AC_MSG_RESULT([no])])
     872      LIBS="$coin_save_LIBS"
     873      ;;
     874     
     875    *-cygwin* | *-mingw*)
     876      case "$CC" in
     877        clang* ) ;;
     878        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
     879          coin_save_LIBS="$LIBS"
     880          AC_MSG_CHECKING([for BLAS in MKL (32bit)])
     881          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
     882          AC_COIN_TRY_FLINK([daxpy],
     883                            [use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
     884                             AC_MSG_RESULT([yes: $use_blas])
     885                            ],
     886                            [AC_MSG_RESULT([no])])
     887          LIBS="$coin_save_LIBS"
     888         
     889          if test "x$use_blas" = x ; then
     890            AC_MSG_CHECKING([for BLAS in MKL (64bit)])
     891            LIBS="mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib $LIBS"
     892            AC_COIN_TRY_FLINK([daxpy],
     893                              [use_blas='mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib'
     894                               AC_MSG_RESULT([yes: $use_blas])
     895                              ],
     896                              [AC_MSG_RESULT([no])])
     897            LIBS="$coin_save_LIBS"
     898          fi
     899          ;;
     900      esac
     901      ;;
     902     
     903     *-darwin*)
     904      AC_MSG_CHECKING([for BLAS in Veclib])
     905      coin_save_LIBS="$LIBS"
     906      LIBS="-framework vecLib $LIBS"
     907      AC_COIN_TRY_FLINK([daxpy],
     908                        [use_blas='-framework vecLib'
     909                         test $coin_need_flibs = yes && use_blas="$use_blas $FLIBS"
     910                         AC_MSG_RESULT([yes: $use_blas])
     911                        ],
     912                        [AC_MSG_RESULT([no])])
     913      LIBS="$coin_save_LIBS"
     914      ;;
     915  esac
     916
     917  if test -z "$use_blas" ; then
     918    AC_MSG_CHECKING([whether -lblas has BLAS])
     919    coin_save_LIBS="$LIBS"
     920    LIBS="-lblas $LIBS"
     921    AC_COIN_TRY_FLINK([daxpy],
     922                      [use_blas='-lblas'
     923                       test $coin_need_flibs = yes && use_blas="$use_blas $FLIBS"
     924                       AC_MSG_RESULT([yes: $use_blas])
     925                      ],
     926                      [AC_MSG_RESULT([no])])
     927    LIBS="$coin_save_LIBS"
     928  fi
     929
     930  # If we have no other ideas, consider building BLAS.
     931  if test -z "$use_blas" ; then
     932    use_blas=BUILD
     933  fi
     934fi
     935
     936if test "x$use_blas" = xBUILD ; then
     937  AC_COIN_CHECK_PACKAGE(Blas, [coinblas], [$1])
     938 
     939elif test "x$use_blas" != x && test "$use_blas" != no; then
     940  coin_has_blas=yes
     941  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
     942  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
     943  BLAS_LIBS="$use_blas"
     944  BLAS_CFLAGS=
     945  BLAS_DATA=
     946  AC_SUBST(BLAS_LIBS)
     947  AC_SUBST(BLAS_CFLAGS)
     948  AC_SUBST(BLAS_DATA)
     949  m4_foreach_w([myvar], [$1], [
     950    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
     951  ])
     952 
     953else
     954  coin_has_blas=no
     955  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
     956fi
     957
     958m4_foreach_w([myvar], [$1], [
     959  AC_SUBST(m4_toupper(myvar)_LIBS)
     960])
     961
     962]) # AC_COIN_CHECK_PACKAGE_BLAS
     963
     964###########################################################################
     965#                       COIN_CHECK_PACKAGE_LAPACK                         #
     966###########################################################################
     967
     968# This macro checks for a library containing the LAPACK library.  It
     969# 1. checks the --with-lapack argument
     970# 2. if --with-lapack=BUILD has been specified goes to point 5
     971# 3. if --with-lapack has been specified to a working library, sets
     972#    LAPACK_LIBS to its value
     973# 4. tries standard libraries
     974# 5. calls COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]) to check for
     975#    ThirdParty/Lapack
     976# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
     977# LAPACK_LIBS is set to the flags required to link with a Lapack library.
     978# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
     979# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
     980# In case 5, Lapack is added to X_PCREQUIRES.
     981#
     982# TODO: Lapack usually depends on Blas, so if we check for a system lapack library,
     983#   shouldn't we include AC_COIN_CHECK_PACKAGE_BLAS first?
     984#   However, if we look for coinlapack via AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]),
     985#   then we will get Blas as dependency of coinlapack.
     986
     987AC_DEFUN([AC_COIN_CHECK_PACKAGE_LAPACK],
     988[
     989AC_ARG_WITH([lapack],
     990            AC_HELP_STRING([--with-lapack],
     991                           [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
     992            [use_lapack=$withval], [use_lapack=])
     993
     994#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
     995AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
     996
     997# Check if user supplied option makes sense
     998if test x"$use_lapack" != x; then
     999  if test "$use_lapack" = "BUILD"; then
     1000    # we come to this later
     1001    :
     1002  elif test "$use_lapack" != no; then
     1003    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
     1004    coin_need_flibs=no
     1005    use_lapack="$use_lapack $BLAS_LIBS"
     1006    coin_save_LIBS="$LIBS"
     1007    LIBS="$use_lapack $LIBS"
     1008    AC_COIN_TRY_FLINK([dsyev],
     1009                      [if test $coin_need_flibs = yes ; then
     1010                         use_lapack="$use_lapack $FLIBS"
     1011                       fi
     1012                       AC_MSG_RESULT([yes: $use_lapack])
     1013                      ],
     1014                      [AC_MSG_RESULT([no])
     1015                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
     1016    LIBS="$coin_save_LIBS"
     1017  fi
     1018else
     1019  if test x$coin_has_blas = xyes; then
     1020    # First try to see if LAPACK is already available with BLAS library
     1021    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
     1022    coin_save_LIBS="$LIBS"
     1023    coin_need_flibs=no
     1024    LIBS="$BLAS_LIBS $LIBS"
     1025    AC_COIN_TRY_FLINK([dsyev],
     1026                      [use_lapack="$BLAS_LIBS"
     1027                       if test $coin_need_flibs = yes ; then
     1028                         use_lapack="$use_lapack $FLIBS"
     1029                       fi
     1030                       AC_MSG_RESULT([yes: $use_lapack])
     1031                      ],
     1032                      [AC_MSG_RESULT([no])])
     1033    LIBS="$coin_save_LIBS"
     1034  fi
     1035
     1036  if test -z "$use_lapack" ; then
     1037    AC_MSG_CHECKING([whether -llapack has LAPACK])
     1038    coin_need_flibs=no
     1039    coin_save_LIBS="$LIBS"
     1040    LIBS="-llapack $BLAS_LIBS $LIBS"
     1041    AC_COIN_TRY_FLINK([dsyev],
     1042                      [use_lapack='-llapack'
     1043                       if test $coin_need_flibs = yes ; then
     1044                         use_lapack="$use_lapack $FLIBS"
     1045                       fi
     1046                       AC_MSG_RESULT([yes: $use_lapack])
     1047                      ],
     1048                      [AC_MSG_RESULT([no])])
     1049    LIBS="$coin_save_LIBS"
     1050  fi
     1051
     1052  # If we have no other ideas, consider building LAPACK.
     1053  if test -z "$use_lapack" ; then
     1054    use_lapack=BUILD
     1055  fi
     1056fi
     1057
     1058if test "x$use_lapack" = xBUILD ; then
     1059  AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1])
     1060
     1061elif test "x$use_lapack" != x && test "$use_lapack" != no; then
     1062  coin_has_lapack=yes
     1063  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
     1064  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
     1065  LAPACK_LIBS="$use_lapack"
     1066  LAPACK_CFLAGS=
     1067  LAPACK_DATA=
     1068  AC_SUBST(LAPACK_LIBS)
     1069  AC_SUBST(LAPACK_CFLAGS)
     1070  AC_SUBST(LAPACK_DATA)
     1071  m4_foreach_w([myvar], [$1], [
     1072    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
     1073  ])
     1074 
     1075else
     1076  coin_has_lapack=no
     1077  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
     1078fi
     1079
     1080m4_foreach_w([myvar], [$1], [
     1081  AC_SUBST(m4_toupper(myvar)_LIBS)
     1082])
     1083
     1084]) # AC_COIN_CHECK_PACKAGE_LAPACK
     1085
    7301086
    7311087###########################################################################
     
    8111167fi
    8121168
     1169m4_if(m4_tolower($1), blas, [
     1170  if test $m4_tolower(coin_has_$1) != no; then
     1171    #--with-blas can overwrite --with-blas-lib, and can be set to BUILD to enforce building blas
     1172    AC_ARG_WITH([blas],
     1173      AC_HELP_STRING([--with-blas], [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
     1174        [if test x"$withval" = "xno" ; then
     1175           coin_has_blas="no"
     1176           coin_reason="--without-blas has been specified"
     1177         elif test x"$withval" != "xBUILD" ; then
     1178           coin_has_blas="no"
     1179           coin_reason="--with-blas has been specified"
     1180         fi],
     1181        [])
     1182  fi
     1183])
     1184
     1185m4_if(m4_tolower($1), lapack, [
     1186  if test $m4_tolower(coin_has_$1) != no; then
     1187    #--with-lapack can overwrite --with-lapack-lib, and can be set to BUILD to enforce building lapack
     1188    AC_ARG_WITH([lapack],
     1189      AC_HELP_STRING([--with-lapack], [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
     1190        [if test x"$withval" = "xno" ; then
     1191           coin_has_lapack="no"
     1192           coin_reason="--without-lapack has been specified"
     1193         elif test x"$withval" != "xBUILD" ; then
     1194           coin_has_lapack="no"
     1195           coin_reason="--with-lapack has been specified"
     1196         fi],
     1197        [])
     1198  fi
     1199])
    8131200
    8141201# check if project is available in present directory
Note: See TracChangeset for help on using the changeset viewer.