Changeset 1544


Ignore:
Timestamp:
May 1, 2010 8:56:59 AM (11 years ago)
Author:
stefan
Message:

merge split branch rev. 1543 into trunk

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Makemain.inc

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

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

    • Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset for help on using the changeset viewer.