Changeset 1443


Ignore:
Timestamp:
Nov 22, 2009 12:28:14 PM (11 years ago)
Author:
stefan
Message:

allow to disable pkg-config; add AC_COIN_HAS_MODULE_BLAS and AC_COIN_HAS_MODULE_LAPACK

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stable/BSPsplit/coin.m4

    r1440 r1443  
    33553355[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
    33563356
    3357 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
    3358   AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
    3359 fi
    3360 if test -n "$PKG_CONFIG"; then
    3361   _pkg_min_version=m4_default([$1], [0.9.0])
    3362   AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
    3363   if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
    3364     AC_MSG_RESULT([yes])
     3357AC_ARG_ENABLE([pkg-config],
     3358  [AC_HELP_STRING([--enable-pkg-config],[use pkg-config if available (default is yes)])],
     3359  [use_pkgconfig="$enableval"],
     3360  [use_pkgconfig=yes])
     3361
     3362if test $use_pkgconfig = yes ; then
     3363  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
     3364    AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
     3365  fi
     3366  if test -n "$PKG_CONFIG"; then
     3367    _pkg_min_version=m4_default([$1], [0.9.0])
     3368    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
     3369    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
     3370      AC_MSG_RESULT([yes])
     3371    else
     3372      AC_MSG_RESULT([no])
     3373      PKG_CONFIG=""
     3374    fi
     3375  fi
     3376
     3377  # check if pkg-config supports the short-errors flag
     3378  if test -n "$PKG_CONFIG" && \
     3379    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
     3380    pkg_short_errors=" --short-errors "
    33653381  else
    3366     AC_MSG_RESULT([no])
    3367     PKG_CONFIG=""
    3368   fi
    3369 fi
    3370 
    3371 # check if pkg-config supports the short-errors flag
    3372 if test -n "$PKG_CONFIG" && \
    3373   $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
    3374   pkg_short_errors=" --short-errors "
    3375 else
    3376   pkg_short_errors=""
    3377 fi
    3378 
     3382    pkg_short_errors=""
     3383  fi
     3384fi
    33793385])
    33803386
     
    40144020
    40154021]) # AC_COIN_HAS_MODULE
     4022
     4023
     4024###########################################################################
     4025#                         COIN_HAS_MODULE_BLAS                            #
     4026###########################################################################
     4027
     4028# This macro checks for a library containing the BLAS library.  It
     4029# 1. checks the --with-blas argument
     4030# 2. if --with-blas=BUILD has been specified goes to point 5
     4031# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS to its value
     4032# 4. tries standard libraries
     4033# 5. calls COIN_HAS_MODULE(Blas, [blas]) to check for ThirdParty/Blas
     4034# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
     4035# BLAS_LIBS is set to the flags required to link with a Blas library.
     4036# In case 3 and 4, the flags to link to Blas are added to ADDLIBS.
     4037# In case 5, Blas is added to REQUIREDPACKAGES
     4038
     4039AC_DEFUN([AC_COIN_HAS_MODULE_BLAS],
     4040[
     4041AC_ARG_WITH([blas],
     4042            AC_HELP_STRING([--with-blas],
     4043                           [specify BLAS library (or BUILD for compilation)]),
     4044            [use_blas="$withval"], [use_blas=])
     4045
     4046#if user specified --with-blas-lib, then we should give COIN_HAS_MODULE preference
     4047AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
     4048
     4049# Check if user supplied option makes sense
     4050if test x"$use_blas" != x; then
     4051  if test "$use_blas" = "BUILD"; then
     4052    # we come to this later
     4053    :
     4054  elif test "$use_blas" != "no"; then
     4055    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
     4056    coin_save_LIBS="$LIBS"
     4057    LIBS="$use_blas $LIBS"
     4058    AC_COIN_TRY_FLINK([daxpy],
     4059                      [AC_MSG_RESULT([yes])
     4060                       ADDLIBS="$use_blas $ADDLIBS"],
     4061                      [AC_MSG_RESULT([no])
     4062                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
     4063    LIBS="$coin_save_LIBS"
     4064  fi
     4065else
     4066# Try to autodetect the library for blas based on build system
     4067  #AC_MSG_CHECKING([default locations for BLAS])
     4068  skip_lblas_check=no
     4069  case $build in
     4070    *-sgi-*)
     4071      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
     4072      SAVE_LIBS="$LIBS"
     4073      LIBS="-lcomplib.sgimath $LIBS"
     4074      AC_COIN_TRY_FLINK([daxpy],
     4075                        [AC_MSG_RESULT([yes])
     4076                         use_blas=-lcomplib.sgimath;
     4077                         ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
     4078                        [AC_MSG_RESULT([no])
     4079                         SAVE_LIBS="$LIBS"])
     4080      ;;
     4081
     4082# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
     4083# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
     4084# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
     4085# that CC and cc will understand -library in Studio 13. The main extra
     4086# function of -xlic_lib and -library is to arrange for the Fortran run-time
     4087# libraries to be linked for C++ and C. We can arrange that explicitly.
     4088    *-*-solaris*)
     4089      SAVE_LIBS="$LIBS"
     4090      AC_MSG_CHECKING([for BLAS in libsunperf])
     4091      LIBS="-lsunperf $FLIBS $LIBS"
     4092      AC_COIN_TRY_FLINK([daxpy],
     4093                        [AC_MSG_RESULT([yes])
     4094                         use_blas='-lsunperf'
     4095                         ADDLIBS="-lsunperf $ADDLIBS"
     4096                         coin_need_flibs=yes],
     4097                        [AC_MSG_RESULT([no])
     4098                         LIBS="$SAVE_LIBS"])
     4099      ;;
     4100    *-cygwin* | *-mingw*)
     4101# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
     4102# library will want to link with cygwin, hence won't run standalone in DOS.
     4103      if test "$enable_doscompile" = mingw; then
     4104        skip_lblas_check=yes
     4105      fi
     4106      case "$CC" in
     4107        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
     4108          SAVE_LIBS="$LIBS"
     4109          AC_MSG_CHECKING([for BLAS in MKL])
     4110          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
     4111          AC_COIN_TRY_FLINK([daxpy],
     4112                            [AC_MSG_RESULT([yes])
     4113                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
     4114                             ADDLIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $ADDLIBS"],
     4115                            [AC_MSG_RESULT([no])
     4116                             LIBS="$SAVE_LIBS"])
     4117          ;;
     4118      esac
     4119      ;;
     4120  esac
     4121
     4122  if test -z "$use_blas" && test $skip_lblas_check = no; then
     4123    SAVE_LIBS="$LIBS"
     4124    AC_MSG_CHECKING([whether -lblas has BLAS])
     4125    LIBS="-lblas $LIBS"
     4126    AC_COIN_TRY_FLINK([daxpy],
     4127                      [AC_MSG_RESULT([yes])
     4128                       ADDLIBS="-lblas $ADDLIBS"
     4129                       use_blas='-lblas'],
     4130                      [AC_MSG_RESULT([no])
     4131                       LIBS="$SAVE_LIBS"])
     4132  fi
     4133  LIBS="$SAVE_LIBS"
     4134 
     4135  # If we have no other ideas, consider building BLAS.
     4136  use_blas=BUILD
     4137fi
     4138
     4139if test "x$use_blas" = xBUILD ; then
     4140  AC_COIN_HAS_MODULE(Blas, [blas])
     4141 
     4142elif test "x$use_blas" != x && test "$use_blas" != no; then
     4143  coin_has_blas=yes
     4144  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
     4145  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
     4146  BLAS_LIBS="$use_blas"
     4147  BLAS_CFLAGS=
     4148  BLAS_DATA=
     4149  AC_SUBST(BLAS_LIBS)
     4150  AC_SUBST(BLAS_CFLAGS)
     4151  AC_SUBST(BLAS_DATA)
     4152 
     4153else
     4154  coin_has_blas=no
     4155  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
     4156fi
     4157
     4158#if test "$use_blas" = BUILD; then
     4159#  coin_need_flibs=yes
     4160#fi
     4161
     4162#to make configure happy if fallback is used
     4163#AM_CONDITIONAL([COIN_BUILD_BLAS],[test "$use_blas" = BUILD])
     4164
     4165]) # AC_COIN_HAS_MODULE_BLAS
     4166
     4167###########################################################################
     4168#                       COIN_HAS_MODULE_LAPACK                            #
     4169###########################################################################
     4170
     4171# This macro checks for a library containing the LAPACK library.  It
     4172# 1. checks the --with-lapack argument
     4173# 2. if --with-lapack=BUILD has been specified goes to point 5
     4174# 3. if --with-lapack has been specified to a working library, sets LAPACK_LIBS to its value
     4175# 4. tries standard libraries
     4176# 5. calls COIN_HAS_MODULE(Lapack, [lapack]) to check for ThirdParty/Lapack
     4177# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
     4178# LAPACK_LIBS is set to the flags required to link with a Lapack library.
     4179# In case 3 and 4, the flags to link to Lapack are added to ADDLIBS.
     4180# In case 5, Lapack is added to REQUIREDPACKAGES
     4181
     4182AC_DEFUN([AC_COIN_HAS_MODULE_LAPACK],
     4183[
     4184AC_ARG_WITH([lapack],
     4185            AC_HELP_STRING([--with-lapack],
     4186                           [specify LAPACK library (or BUILD for compilation)]),
     4187            [use_lapack=$withval], [use_lapack=])
     4188           
     4189#if user specified --with-lapack-lib, then we should give COIN_HAS_MODULE preference
     4190AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
     4191
     4192# Check if user supplied option makes sense
     4193if test x"$use_lapack" != x; then
     4194  if test "$use_lapack" = "BUILD"; then
     4195    # we come to this later
     4196    :
     4197  elif test "$use_lapack" != no; then
     4198    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
     4199    coin_save_LIBS="$LIBS"
     4200    LIBS="$use_lapack $LIBS"
     4201    AC_COIN_TRY_FLINK([dsyev],
     4202                      [AC_MSG_RESULT([yes])
     4203                       ADDLIBS="$use_lapack $ADDLIBS"],
     4204                      [AC_MSG_RESULT([no])
     4205                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
     4206    LIBS="$coin_save_LIBS"
     4207  fi
     4208else
     4209  if test x$coin_has_blas = xyes; then
     4210    # First try to see if LAPACK is already available with BLAS library
     4211    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
     4212    coin_save_LIBS="$LIBS"
     4213    LIBS="$ADDLIBS $LIBS"
     4214    AC_COIN_TRY_FLINK([dsyev],
     4215                      [AC_MSG_RESULT([yes]); use_lapack=ok],
     4216                      [AC_MSG_RESULT([no])])
     4217    LIBS="$coin_save_LIBS"
     4218  fi
     4219  skip_llapack_check=no
     4220  if test -z "$use_lapack"; then
     4221    # Try to autodetect the library for lapack based on build system
     4222    case $build in
     4223      *-sgi-*)
     4224        SAVE_LIBS="$LIBS"
     4225        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
     4226        LIBS="-lcomplib.sgimath $LIBS"
     4227        AC_COIN_TRY_FLINK([dsyev],
     4228                          [AC_MSG_RESULT([yes])
     4229                           use_lapack=-lcomplib.sgimath;
     4230                           ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
     4231                          [AC_MSG_RESULT([no])
     4232                           SAVE_LIBS="$LIBS"])
     4233        ;;
     4234
     4235# See comments in COIN_HAS_BLAS.
     4236      *-*-solaris*)
     4237      SAVE_LIBS="$LIBS"
     4238      AC_MSG_CHECKING([for LAPACK in libsunperf])
     4239      LIBS="-lsunperf $FLIBS $LIBS"
     4240      AC_COIN_TRY_FLINK([dsyev],
     4241                        [AC_MSG_RESULT([yes])
     4242                         use_blas='-lsunperf'
     4243                         ADDLIBS="-lsunperf $ADDLIBS"
     4244                         coin_need_flibs=yes],
     4245                        [AC_MSG_RESULT([no])
     4246                         LIBS="$SAVE_LIBS"])
     4247        ;;
     4248# On cygwin, do this check only if doscompile is disabled. The prebuilt library
     4249# will want to link with cygwin, hence won't run standalone in DOS.
     4250      *-cygwin*)
     4251        if test "$enable_doscompile" = mingw; then
     4252          skip_llapack_check=yes
     4253        fi
     4254        ;;
     4255    esac
     4256  fi
     4257
     4258  if test -z "$use_lapack" && test $skip_llapack_check = no; then
     4259    SAVE_LIBS="$LIBS"
     4260    AC_MSG_CHECKING([whether -llapack has LAPACK])
     4261    LIBS="-llapack $LIBS"
     4262    AC_COIN_TRY_FLINK([dsyev],
     4263                      [AC_MSG_RESULT([yes])
     4264                       ADDLIBS="-llapack $ADDLIBS"
     4265                       use_lapack='-llapack'],
     4266                      [AC_MSG_RESULT([no])
     4267                       LIBS="$SAVE_LIBS"])
     4268  fi
     4269 
     4270  LIBS="$SAVE_LIBS"
     4271
     4272  # If we have no other ideas, consider building LAPACK.
     4273  use_lapack=BUILD
     4274fi
     4275
     4276if test "x$use_lapack" = xBUILD ; then
     4277  AC_COIN_HAS_MODULE(Lapack, [lapack])
     4278 
     4279elif test "x$use_lapack" != x && test "$use_lapack" != no; then
     4280  coin_has_lapack=yes
     4281  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
     4282  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
     4283  LAPACK_LIBS="$use_blas"
     4284  LAPACK_CFLAGS=
     4285  LAPACK_DATA=
     4286  AC_SUBST(LAPACK_LIBS)
     4287  AC_SUBST(LAPACK_CFLAGS)
     4288  AC_SUBST(LAPACK_DATA)
     4289 
     4290else
     4291  coin_has_lapack=no
     4292  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
     4293fi
     4294
     4295#if test "$use_lapack" = BUILD; then
     4296#  coin_need_flibs=yes
     4297#fi
     4298
     4299#AM_CONDITIONAL([COIN_BUILD_LAPACK],[test "$use_lapack" = BUILD])
     4300
     4301]) # AC_COIN_HAS_MODULE_LAPACK
Note: See TracChangeset for help on using the changeset viewer.