Changeset 1474


Ignore:
Timestamp:
Feb 21, 2010 10:23:00 AM (10 years ago)
Author:
stefan
Message:

copy over pkg-config setup macros from BSPsplit branch

Location:
branches/split
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/split/Makemain.inc

    r1376 r1474  
    1212
    1313DocFiles =  README AUTHORS LICENSE
    14 DocInstallDir = $(prefix)/share/doc/coin/$(PACKAGE_NAME)
     14DocInstallDir = $(datadir)/coin/doc/$(PACKAGE_NAME)
    1515
    1616install-doc: $(DocFiles)
  • branches/split/coin.m4

    r1372 r1474  
    33513351
    33523352]) # AC_COIN_HAS_GLPK
     3353
     3354###########################################################################
     3355#                           COIN_HAS_PKGCONFIG                            #
     3356###########################################################################
     3357
     3358# This macro checks whether a pkg-config tool with a minimal version number is available.
     3359# If so, then the variable PKGCONFIG is set to its path.
     3360# If not, PKGCONFIG is set to "".
     3361# The minimal version number can be given as first parameter, by default it is 0.9.0.
     3362# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4
     3363AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
     3364[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
     3365
     3366AC_ARG_ENABLE([pkg-config],
     3367  [AC_HELP_STRING([--enable-pkg-config],[use pkg-config if available (default is yes)])],
     3368  [use_pkgconfig="$enableval"],
     3369  [use_pkgconfig=yes])
     3370
     3371if test $use_pkgconfig = yes ; then
     3372  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
     3373    AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
     3374  fi
     3375  if test -n "$PKG_CONFIG"; then
     3376    _pkg_min_version=m4_default([$1], [0.9.0])
     3377    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
     3378    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
     3379      AC_MSG_RESULT([yes])
     3380    else
     3381      AC_MSG_RESULT([no])
     3382      PKG_CONFIG=""
     3383    fi
     3384  fi
     3385
     3386  # check if pkg-config supports the short-errors flag
     3387  if test -n "$PKG_CONFIG" && \
     3388    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
     3389    pkg_short_errors=" --short-errors "
     3390  else
     3391    pkg_short_errors=""
     3392  fi
     3393fi
     3394])
     3395
     3396###########################################################################
     3397#                           COIN_PKG_CHECK_PROJECT_EXISTS                 #
     3398###########################################################################
     3399
     3400# COIN_PKG_CHECK_PROJECT_EXISTS(PROJECT, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     3401#
     3402# Check to see whether a particular project exists.  Similar
     3403# to PKG_CHECK_MODULES(), but set only the variables $1_VERSION and $1_PKG_ERRORS variables
     3404#
     3405AC_DEFUN([AC_COIN_PKG_CHECK_PROJECT_EXISTS],
     3406[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3407if test -n "$PKG_CONFIG" ; then
     3408  if $PKG_CONFIG --exists "m4_tolower($1)"; then
     3409    m4_toupper($1)[]_VERSION=`$PKG_CONFIG --modversion "m4_tolower($1)" 2>/dev/null`
     3410    m4_ifval([$2], [$2], [:])
     3411  else
     3412    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "m4_tolower($1)"`
     3413    $3
     3414  fi
     3415else
     3416  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
     3417fi
     3418])
     3419
     3420###########################################################################
     3421#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
     3422###########################################################################
     3423
     3424# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     3425#
     3426# Check to see whether a particular set of packages exists.
     3427# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
     3428#
     3429AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
     3430[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3431if test -n "$PKG_CONFIG" ; then
     3432  if $PKG_CONFIG --exists "$2"; then
     3433    m4_toupper($1)[]_VERSIONS="`$PKG_CONFIG --modversion $2 2>/dev/null`"
     3434    m4_ifval([$3], [$3], [:])
     3435  else
     3436    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors $2`
     3437    $4
     3438  fi
     3439else
     3440  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
     3441fi
     3442])
     3443
     3444###########################################################################
     3445#                           COIN_PKG_HAS_MODULE                           #
     3446###########################################################################
     3447
     3448# COIN_PKG_HAS_MODULE(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     3449#
     3450# Checks whether pkg-config files for a given set of packages is available.
     3451# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
     3452# If not, then ACTION-IF-NOT-FOUND is executed.
     3453# A reason for not finding a package is stored in MODULE_PKG_ERRORS
     3454#
     3455# --------------------------------------------------------------
     3456AC_DEFUN([AC_COIN_PKG_HAS_MODULE],
     3457[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3458
     3459AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
     3460  [ cflags=`$PKG_CONFIG --cflags "$2" 2>/dev/null`
     3461    # pkg-config cannot handle spaces, so CYGPATH_W cannot be put into .pc files
     3462        # thus, we modify the cflags extracted from pkg-config by putting CYGPATH_W behind -I's
     3463        # but only do this if is not trivial
     3464    if test "$CYGPATH_W" != "echo" ; then
     3465      # need to put into brackets since otherwise autoconf replaces the brackets in the sed command
     3466          [cflags=`echo $cflags | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
     3467        fi
     3468    m4_toupper($1)[]_CFLAGS="$cflags"
     3469    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "$2" 2>/dev/null`
     3470    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "$2" 2>/dev/null`
     3471    $3
     3472  ],
     3473  [ $4 ])
     3474
     3475])# PKG_CHECK_MODULES
     3476
     3477###########################################################################
     3478#                           COIN_MAIN_PACKAGEDIR                          #
     3479###########################################################################
     3480
     3481# This macro substitutes COIN_MAIN_SUBDIR.
     3482# If $2/$1 or $1 is in COIN_SKIP_PROJECTS, do nothing.
     3483# If --with-$1-lib, --with-$1-incdir, or --with-$1-datadir is given, then assume that the package is installed.
     3484# Otherwise, if pkg-config is available, use it to check whether the package is available.
     3485#   If $4 is given, then pkg-config is asked for the existance of $4, otherwise tolower($1) is used.
     3486# Otherwise, if the directory $2/$1 and the file $2/$1/$3 exist, check whether $2/$1/configure exists.
     3487#   If so, include this directory into the list of directories where configure and make recourse into.
     3488# tolower(coin_has_$1) is set to notGiven, skipping, installed, the version of an installed project, or the projects main directory (if uninstalled).
     3489
     3490AC_DEFUN([AC_COIN_MAIN_PACKAGEDIR],
     3491[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3492AC_MSG_CHECKING([whether project $1 is available])
     3493
     3494m4_tolower(coin_has_$1)=notGiven
     3495coin_have_project_dir=no
     3496
     3497# check if user wants to skip project in any case
     3498AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
     3499if test x"$COIN_SKIP_PROJECTS" != x; then
     3500  for dir in $COIN_SKIP_PROJECTS; do
     3501    if test $dir = "$1"; then
     3502      m4_tolower(coin_has_$1)=skipping
     3503    fi
     3504    if test $dir = "$2/$1"; then
     3505      m4_tolower(coin_has_$1)=skipping
     3506    fi
     3507  done
     3508fi
     3509
     3510if test $m4_tolower(coin_has_$1) != skipping; then
     3511  if test $PACKAGE_TARNAME = m4_tolower($1); then
     3512    m4_tolower(coin_has_$1)=.
     3513    coin_have_project_dir=yes
     3514  fi
     3515
     3516  AC_ARG_WITH([m4_tolower($1)-lib],
     3517    AC_HELP_STRING([--with-m4_tolower($1)-lib],
     3518                   [linker flags for using project $1]),
     3519      [m4_tolower(coin_has_$1)=installed],
     3520      [])
     3521
     3522  AC_ARG_WITH([m4_tolower($1)-incdir],
     3523    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
     3524                   [directory with header files for using project $1]),
     3525    [m4_tolower(coin_has_$1)=installed],
     3526    [])
     3527
     3528  AC_ARG_WITH([m4_tolower($1)-datadir],
     3529    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
     3530                   [directory with data files for using project $1]),
     3531    [m4_tolower(coin_has_$1)=installed],
     3532    [])
     3533fi
     3534
     3535if test $m4_tolower(coin_has_$1) = notGiven; then
     3536  #only if pkg-config is available:
     3537  #see if user gives directory where project might be installed: assemble search path for pkg-config
     3538  if test -n "$PKG_CONFIG" ; then
     3539    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
     3540   
     3541    # let's assume that when installing into $prefix, then the user may have installed some other coin projects there before, so it's worth to have a look into there
     3542    if test -d "$prefix"; then
     3543      PKG_CONFIG_PATH="$prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
     3544    fi
     3545   
     3546    AC_ARG_WITH([coin-instdir],
     3547      AC_HELP_STRING([--with-coin-instdir],
     3548                     [prefix of installation directory for precompiled COIN packages]),
     3549      [if test -d "$withval"; then : ; else
     3550         AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
     3551       fi
     3552       PKG_CONFIG_PATH="$withval/lib/pkgconfig:$PKG_CONFIG_PATH"
     3553      ],[])
     3554
     3555    # let pkgconfig check if the project is already installed somewhere
     3556    # need to export variable to be sure that the following pkg-config call gets these values
     3557    export PKG_CONFIG_PATH
     3558    AC_COIN_PKG_CHECK_PROJECT_EXISTS(m4_ifval([$4],[$4],[$1]), [m4_tolower(coin_has_$1)="$m4_toupper(m4_ifval([$4],[$4],[$1]))_VERSION"])
     3559
     3560    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
     3561  fi
     3562fi
     3563
     3564# if not found yet, check if project is available in present directory
     3565if test "$m4_tolower(coin_has_$1)" = notGiven; then
     3566  if test -d $srcdir/$2/$1; then
     3567    m4_ifvaln([$3],
     3568      [for i in $srcdir/$2/$1/$3; do
     3569         if test -r $i; then
     3570           coin_have_project_dir=yes
     3571         fi
     3572       done],
     3573      [ coin_have_project_dir=yes ])
     3574    if test $coin_have_project_dir = yes; then
     3575      m4_tolower(coin_has_$1)=$2/$1
     3576    fi
     3577  fi
     3578fi
     3579
     3580AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
     3581
     3582AC_MSG_CHECKING(whether project $1 need to be configured)
     3583if test "$coin_have_project_dir" = yes ; then
     3584
     3585  if test -r $srcdir/$2/$1/configure; then
     3586    coin_subdirs="$coin_subdirs m4_ifval($2,[$2/],)$1"
     3587    AC_MSG_RESULT(yes)
     3588    AC_CONFIG_SUBDIRS(m4_ifval($2,[$2/],)$1)
     3589  else
     3590    AC_MSG_RESULT(no)
     3591  fi
     3592else
     3593  AC_MSG_RESULT(no)
     3594fi
     3595])
     3596
     3597###########################################################################
     3598#                            COIN_HAS_MODULE                              #
     3599###########################################################################
     3600
     3601# This macro sets up a COIN-OR module.
     3602# A module consists of one or more COIN-OR packages.
     3603# It defines the MODULE_CFLAGS, MODULE_LIBS, and MODULE_DATA variables, refering to the compiler and linker
     3604# flags to use when linking against this module and the directories where the module data resists.
     3605# It also defines a COIN_HAS_MODULE preprocessor macro and makefile conditional.
     3606# Further, tolower(coin_has_$1) is set to "yes".
     3607# If the flag 'required' is set (which is on by default), then the packages of the module are added to
     3608# the REQUIREDPACKAGES variable, which can be used to setup a .pc file.
     3609# The first argument should be the name (MODULE) of the module (in correct lower
     3610# and upper case).
     3611# The second argument should be a (space separated) list of projects which this
     3612# module consists of. Optionally, required version numbers could be added.
     3613# The optional third argument can be used to overwrite default values for flags like 'required'.
     3614#
     3615# It is also possible to specify a preinstalled version of this module
     3616# or to specify only the linker and compiler flags and data directory.
     3617# If the flag 'required' (which is on by default), then the user-given linker flags are added to
     3618# the ADDLIBS variable, which can be used to setup a .pc file.
     3619
     3620AC_DEFUN([AC_COIN_HAS_MODULE],
     3621[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3622AC_MSG_CHECKING([for COIN module $1])
     3623
     3624m4_tolower(coin_has_$1)=notGiven
     3625
     3626# check if user wants to skip module in any case
     3627if test x"$COIN_SKIP_PROJECTS" != x; then
     3628  for dir in $COIN_SKIP_PROJECTS; do
     3629    if test $dir = "$1"; then
     3630      m4_tolower(coin_has_$1)=skipping
     3631    fi
     3632  done
     3633fi
     3634
     3635m4_toupper($1_LIBS)=
     3636m4_toupper($1_CFLAGS)=
     3637m4_toupper($1_DATA)=
     3638AC_SUBST(m4_toupper($1_LIBS))
     3639AC_SUBST(m4_toupper($1_CFLAGS))
     3640AC_SUBST(m4_toupper($1_DATA))
     3641AC_SUBST(REQUIREDPACKAGES)
     3642
     3643required=1
     3644
     3645# execute third argument that can be used to overwrite flags like 'required'
     3646$3
     3647
     3648#check if user provided LIBS, CFLAGS, and DATA for module
     3649if test $m4_tolower(coin_has_$1) != skipping; then
     3650
     3651  AC_ARG_WITH([m4_tolower($1)-lib],
     3652    AC_HELP_STRING([--with-m4_tolower($1)-lib],
     3653                   [linker flags for using module $1]),
     3654      [m4_tolower(coin_has_$1)=yes
     3655       m4_toupper($1_LIBS)="$withval"
     3656       if test $required = 1; then
     3657         ADDLIBS="$ADDLIBS $withval"
     3658       fi
     3659      ],
     3660      [])
     3661
     3662  AC_ARG_WITH([m4_tolower($1)-incdir],
     3663    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
     3664                   [directory with header files for using module $1]),
     3665    [m4_tolower(coin_has_$1)=yes
     3666     m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"],
     3667    [])
     3668
     3669  AC_ARG_WITH([m4_tolower($1)-datadir],
     3670    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
     3671                   [directory with data files for using module $1]),
     3672    [m4_tolower(coin_has_$1)=yes
     3673     m4_toupper($1_DATA)="$withval"],
     3674    [])
     3675fi
     3676
     3677if test $m4_tolower(coin_has_$1) = notGiven; then
     3678  if test -n "$PKG_CONFIG" ; then
     3679    # assemble search path for pkg-config
     3680    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
     3681
     3682    # let's assume that when installing into $prefix, then the user may have installed some other coin projects there before, so it's worth to have a look into there
     3683    # best would actually to use ${libdir}, since .pc files get installed into ${libdir}/pkgconfig,
     3684    # unfortunately, ${libdir} expands to ${exec_prefix}/lib and ${exec_prefix} to ${prefix}...
     3685    if test -d "${prefix}"; then
     3686      PKG_CONFIG_PATH="${prefix}/lib/pkgconfig:$PKG_CONFIG_PATH"
     3687    fi
     3688
     3689    AC_ARG_WITH([coin-instdir],
     3690      AC_HELP_STRING([--with-coin-instdir],
     3691                     [prefix of installation directory for precompiled COIN packages]),
     3692      [if test -d "$withval"; then : ; else
     3693         AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
     3694       fi
     3695       PKG_CONFIG_PATH="$withval/lib/pkgconfig:$PKG_CONFIG_PATH"
     3696      ],[])
     3697
     3698    # in a classic setup, we want to find uninstalled projects
     3699    # their (relative) location is written to coin_subdirs.txt by the configure in the project base directory
     3700    # unfortunately, if the user set prefix, then we do not know where the project base directory is located
     3701    # but it is likely to be either .. (if we are a usual coin project) or ../.. (if we are a unusual coin project like ThirdParty or Data)
     3702    if test -e ../coin_subdirs.txt ; then
     3703      for i in `cat ../coin_subdirs.txt` ; do
     3704        PKG_CONFIG_PATH="../$i:$PKG_CONFIG_PATH"
     3705      done
     3706    fi
     3707   
     3708    if test -e ../../coin_subdirs.txt ; then
     3709      for i in `cat ../../coin_subdirs.txt` ; do
     3710        PKG_CONFIG_PATH="../../$i:$PKG_CONFIG_PATH"
     3711      done
     3712    fi
     3713   
     3714    # let pkg-config do it's magic
     3715    # need to export variable to be sure that the following pkg-config gets these values
     3716    export PKG_CONFIG_PATH
     3717    AC_COIN_PKG_HAS_MODULE([$1],[$2],
     3718      [ m4_tolower(coin_has_$1)=yes
     3719        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
     3720        if test $required = 1; then
     3721          REQUIREDPACKAGES="$REQUIREDPACKAGES $2"
     3722        fi
     3723      ],
     3724      [ m4_tolower(coin_has_$1)=notGiven
     3725        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
     3726      ])
     3727
     3728    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
     3729  else
     3730    AC_MSG_RESULT([skipped check via pkg-config])
     3731  fi
     3732
     3733else
     3734  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
     3735fi
     3736
     3737if test $m4_tolower(coin_has_$1) != skipping &&
     3738   test $m4_tolower(coin_has_$1) != notGiven ; then
     3739  if test -n "$m4_toupper($1)_CFLAGS" ; then
     3740    AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     3741  fi
     3742  if test -n "$m4_toupper($1)_LIBS" ; then
     3743    AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
     3744  fi
     3745  if test -n "$m4_toupper($1)_DATA" ; then
     3746    AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
     3747  fi
     3748  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 module is available])
     3749fi
     3750
     3751# Define the Makefile conditional
     3752AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
     3753               [test $m4_tolower(coin_has_$1) != notGiven &&
     3754                test $m4_tolower(coin_has_$1) != skipping])
     3755
     3756]) # AC_COIN_HAS_MODULE
     3757
     3758
     3759###########################################################################
     3760#                         COIN_HAS_MODULE_BLAS                            #
     3761###########################################################################
     3762
     3763# This macro checks for a library containing the BLAS library.  It
     3764# 1. checks the --with-blas argument
     3765# 2. if --with-blas=BUILD has been specified goes to point 5
     3766# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS to its value
     3767# 4. tries standard libraries
     3768# 5. calls COIN_HAS_MODULE(Blas, [blas]) to check for ThirdParty/Blas
     3769# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
     3770# BLAS_LIBS is set to the flags required to link with a Blas library.
     3771# In case 3 and 4, the flags to link to Blas are added to ADDLIBS.
     3772# In case 5, Blas is added to REQUIREDPACKAGES
     3773
     3774AC_DEFUN([AC_COIN_HAS_MODULE_BLAS],
     3775[
     3776AC_ARG_WITH([blas],
     3777            AC_HELP_STRING([--with-blas],
     3778                           [specify BLAS library (or BUILD for compilation)]),
     3779            [use_blas="$withval"], [use_blas=])
     3780
     3781#if user specified --with-blas-lib, then we should give COIN_HAS_MODULE preference
     3782AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
     3783
     3784# Check if user supplied option makes sense
     3785if test x"$use_blas" != x; then
     3786  if test "$use_blas" = "BUILD"; then
     3787    # we come to this later
     3788    :
     3789  elif test "$use_blas" != "no"; then
     3790    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
     3791    coin_save_LIBS="$LIBS"
     3792    LIBS="$use_blas $LIBS"
     3793    AC_COIN_TRY_FLINK([daxpy],
     3794                      [AC_MSG_RESULT([yes])
     3795                       ADDLIBS="$use_blas $ADDLIBS"],
     3796                      [AC_MSG_RESULT([no])
     3797                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
     3798    LIBS="$coin_save_LIBS"
     3799  fi
     3800else
     3801# Try to autodetect the library for blas based on build system
     3802  #AC_MSG_CHECKING([default locations for BLAS])
     3803  skip_lblas_check=no
     3804  case $build in
     3805    *-sgi-*)
     3806      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
     3807      SAVE_LIBS="$LIBS"
     3808      LIBS="-lcomplib.sgimath $LIBS"
     3809      AC_COIN_TRY_FLINK([daxpy],
     3810                        [AC_MSG_RESULT([yes])
     3811                         use_blas=-lcomplib.sgimath;
     3812                         ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
     3813                        [AC_MSG_RESULT([no])
     3814                         SAVE_LIBS="$LIBS"])
     3815      ;;
     3816
     3817# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
     3818# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
     3819# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
     3820# that CC and cc will understand -library in Studio 13. The main extra
     3821# function of -xlic_lib and -library is to arrange for the Fortran run-time
     3822# libraries to be linked for C++ and C. We can arrange that explicitly.
     3823    *-*-solaris*)
     3824      SAVE_LIBS="$LIBS"
     3825      AC_MSG_CHECKING([for BLAS in libsunperf])
     3826      LIBS="-lsunperf $FLIBS $LIBS"
     3827      AC_COIN_TRY_FLINK([daxpy],
     3828                        [AC_MSG_RESULT([yes])
     3829                         use_blas='-lsunperf'
     3830                         ADDLIBS="-lsunperf $ADDLIBS"
     3831                         coin_need_flibs=yes],
     3832                        [AC_MSG_RESULT([no])
     3833                         LIBS="$SAVE_LIBS"])
     3834      ;;
     3835    *-cygwin* | *-mingw*)
     3836# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
     3837# library will want to link with cygwin, hence won't run standalone in DOS.
     3838      if test "$enable_doscompile" = mingw; then
     3839        skip_lblas_check=yes
     3840      fi
     3841      case "$CC" in
     3842        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
     3843          SAVE_LIBS="$LIBS"
     3844          AC_MSG_CHECKING([for BLAS in MKL])
     3845          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
     3846          AC_COIN_TRY_FLINK([daxpy],
     3847                            [AC_MSG_RESULT([yes])
     3848                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
     3849                             ADDLIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $ADDLIBS"],
     3850                            [AC_MSG_RESULT([no])
     3851                             LIBS="$SAVE_LIBS"])
     3852          ;;
     3853      esac
     3854      ;;
     3855  esac
     3856
     3857  if test -z "$use_blas" && test $skip_lblas_check = no; then
     3858    SAVE_LIBS="$LIBS"
     3859    AC_MSG_CHECKING([whether -lblas has BLAS])
     3860    LIBS="-lblas $LIBS"
     3861    AC_COIN_TRY_FLINK([daxpy],
     3862                      [AC_MSG_RESULT([yes])
     3863                       ADDLIBS="-lblas $ADDLIBS"
     3864                       use_blas='-lblas'],
     3865                      [AC_MSG_RESULT([no])
     3866                       LIBS="$SAVE_LIBS"])
     3867  fi
     3868  LIBS="$SAVE_LIBS"
     3869 
     3870  # If we have no other ideas, consider building BLAS.
     3871  if test -z "$use_blas" ; then
     3872    use_blas=BUILD
     3873  fi
     3874fi
     3875
     3876if test "x$use_blas" = xBUILD ; then
     3877  AC_COIN_HAS_MODULE(Blas, [coinblas])
     3878 
     3879elif test "x$use_blas" != x && test "$use_blas" != no; then
     3880  coin_has_blas=yes
     3881  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
     3882  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
     3883  BLAS_LIBS="$use_blas"
     3884  BLAS_CFLAGS=
     3885  BLAS_DATA=
     3886  AC_SUBST(BLAS_LIBS)
     3887  AC_SUBST(BLAS_CFLAGS)
     3888  AC_SUBST(BLAS_DATA)
     3889 
     3890else
     3891  coin_has_blas=no
     3892  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
     3893fi
     3894
     3895]) # AC_COIN_HAS_MODULE_BLAS
     3896
     3897###########################################################################
     3898#                       COIN_HAS_MODULE_LAPACK                            #
     3899###########################################################################
     3900
     3901# This macro checks for a library containing the LAPACK library.  It
     3902# 1. checks the --with-lapack argument
     3903# 2. if --with-lapack=BUILD has been specified goes to point 5
     3904# 3. if --with-lapack has been specified to a working library, sets LAPACK_LIBS to its value
     3905# 4. tries standard libraries
     3906# 5. calls COIN_HAS_MODULE(Lapack, [lapack]) to check for ThirdParty/Lapack
     3907# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
     3908# LAPACK_LIBS is set to the flags required to link with a Lapack library.
     3909# In case 3 and 4, the flags to link to Lapack are added to ADDLIBS.
     3910# In case 5, Lapack is added to REQUIREDPACKAGES
     3911
     3912AC_DEFUN([AC_COIN_HAS_MODULE_LAPACK],
     3913[
     3914AC_ARG_WITH([lapack],
     3915            AC_HELP_STRING([--with-lapack],
     3916                           [specify LAPACK library (or BUILD for compilation)]),
     3917            [use_lapack=$withval], [use_lapack=])
     3918           
     3919#if user specified --with-lapack-lib, then we should give COIN_HAS_MODULE preference
     3920AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
     3921
     3922# Check if user supplied option makes sense
     3923if test x"$use_lapack" != x; then
     3924  if test "$use_lapack" = "BUILD"; then
     3925    # we come to this later
     3926    :
     3927  elif test "$use_lapack" != no; then
     3928    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
     3929    coin_save_LIBS="$LIBS"
     3930    LIBS="$use_lapack $LIBS"
     3931    AC_COIN_TRY_FLINK([dsyev],
     3932                      [AC_MSG_RESULT([yes])
     3933                       ADDLIBS="$use_lapack $ADDLIBS"],
     3934                      [AC_MSG_RESULT([no])
     3935                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
     3936    LIBS="$coin_save_LIBS"
     3937  fi
     3938else
     3939  if test x$coin_has_blas = xyes; then
     3940    # First try to see if LAPACK is already available with BLAS library
     3941    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
     3942    coin_save_LIBS="$LIBS"
     3943    LIBS="$ADDLIBS $LIBS"
     3944    AC_COIN_TRY_FLINK([dsyev],
     3945                      [AC_MSG_RESULT([yes]); use_lapack=ok],
     3946                      [AC_MSG_RESULT([no])])
     3947    LIBS="$coin_save_LIBS"
     3948  fi
     3949  skip_llapack_check=no
     3950  if test -z "$use_lapack"; then
     3951    # Try to autodetect the library for lapack based on build system
     3952    case $build in
     3953      *-sgi-*)
     3954        SAVE_LIBS="$LIBS"
     3955        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
     3956        LIBS="-lcomplib.sgimath $LIBS"
     3957        AC_COIN_TRY_FLINK([dsyev],
     3958                          [AC_MSG_RESULT([yes])
     3959                           use_lapack=-lcomplib.sgimath;
     3960                           ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
     3961                          [AC_MSG_RESULT([no])
     3962                           SAVE_LIBS="$LIBS"])
     3963        ;;
     3964
     3965# See comments in COIN_HAS_BLAS.
     3966      *-*-solaris*)
     3967      SAVE_LIBS="$LIBS"
     3968      AC_MSG_CHECKING([for LAPACK in libsunperf])
     3969      LIBS="-lsunperf $FLIBS $LIBS"
     3970      AC_COIN_TRY_FLINK([dsyev],
     3971                        [AC_MSG_RESULT([yes])
     3972                         use_blas='-lsunperf'
     3973                         ADDLIBS="-lsunperf $ADDLIBS"
     3974                         coin_need_flibs=yes],
     3975                        [AC_MSG_RESULT([no])
     3976                         LIBS="$SAVE_LIBS"])
     3977        ;;
     3978# On cygwin, do this check only if doscompile is disabled. The prebuilt library
     3979# will want to link with cygwin, hence won't run standalone in DOS.
     3980      *-cygwin*)
     3981        if test "$enable_doscompile" = mingw; then
     3982          skip_llapack_check=yes
     3983        fi
     3984        ;;
     3985    esac
     3986  fi
     3987
     3988  if test -z "$use_lapack" && test $skip_llapack_check = no; then
     3989    SAVE_LIBS="$LIBS"
     3990    AC_MSG_CHECKING([whether -llapack has LAPACK])
     3991    LIBS="-llapack $LIBS"
     3992    AC_COIN_TRY_FLINK([dsyev],
     3993                      [AC_MSG_RESULT([yes])
     3994                       ADDLIBS="-llapack $ADDLIBS"
     3995                       use_lapack='-llapack'],
     3996                      [AC_MSG_RESULT([no])
     3997                       LIBS="$SAVE_LIBS"])
     3998  fi
     3999 
     4000  LIBS="$SAVE_LIBS"
     4001
     4002  # If we have no other ideas, consider building LAPACK.
     4003  if test -z "$use_lapack" ; then
     4004    use_lapack=BUILD
     4005  fi
     4006fi
     4007
     4008if test "x$use_lapack" = xBUILD ; then
     4009  AC_COIN_HAS_MODULE(Lapack, [coinlapack])
     4010 
     4011elif test "x$use_lapack" != x && test "$use_lapack" != no; then
     4012  coin_has_lapack=yes
     4013  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
     4014  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
     4015  LAPACK_LIBS="$use_blas"
     4016  LAPACK_CFLAGS=
     4017  LAPACK_DATA=
     4018  AC_SUBST(LAPACK_LIBS)
     4019  AC_SUBST(LAPACK_CFLAGS)
     4020  AC_SUBST(LAPACK_DATA)
     4021 
     4022else
     4023  coin_has_lapack=no
     4024  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
     4025fi
     4026
     4027]) # AC_COIN_HAS_MODULE_LAPACK
Note: See TracChangeset for help on using the changeset viewer.