Changeset 1431 for stable


Ignore:
Timestamp:
Nov 1, 2009 10:03:40 AM (11 years ago)
Author:
stefan
Message:

add COIN_HAS_MODULE macro to check for a set of packages via pkg-config

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stable/BSPsplit/coin.m4

    r1398 r1431  
    33803380
    33813381###########################################################################
    3382 #                           COIN_PKG_CHECK_EXISTS                         #
     3382#                           COIN_PKG_CHECK_EXISTS (deprecated)            #
    33833383###########################################################################
    33843384
     
    34053405
    34063406###########################################################################
    3407 #                           COIN_PKG_CHECK_MODULE                         #
     3407#                           COIN_PKG_CHECK_MODULE   (deprecated)          #
    34083408###########################################################################
    34093409
     
    34263426  ],
    34273427  [ $3 ])
     3428
     3429])# PKG_CHECK_MODULES
     3430
     3431###########################################################################
     3432#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
     3433###########################################################################
     3434
     3435# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     3436#
     3437# Check to see whether a particular set of packages exists.
     3438# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
     3439#
     3440AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
     3441[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3442if test -n "$PKG_CONFIG" ; then
     3443  if $PKG_CONFIG --exists "$2"; then
     3444    m4_toupper($1)[]_VERSIONS="`$PKG_CONFIG --modversion $2 2>/dev/null`"
     3445    m4_ifval([$3], [$3], [:])
     3446  else
     3447    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors $2`
     3448    $4
     3449  fi
     3450else
     3451  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
     3452fi
     3453])
     3454
     3455###########################################################################
     3456#                           COIN_PKG_HAS_MODULE                           #
     3457###########################################################################
     3458
     3459# COIN_PKG_CHECK_MODULE(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     3460#
     3461# Checks whether pkg-config files for a given set of packages is available.
     3462# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
     3463# If not, then ACTION-IF-NOT-FOUND is executed.
     3464# A reason for not finding a package is stored in MODULE_PKG_ERRORS
     3465#
     3466# --------------------------------------------------------------
     3467AC_DEFUN([AC_COIN_PKG_HAS_MODULE],
     3468[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3469
     3470AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
     3471  [ m4_toupper($1)[]_CFLAGS=`$PKG_CONFIG --cflags "m4_tolower($1)" 2>/dev/null`
     3472    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "m4_tolower($1)" 2>/dev/null`
     3473    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "m4_tolower($1)" 2>/dev/null`
     3474    $3
     3475  ],
     3476  [ $4 ])
    34283477
    34293478])# PKG_CHECK_MODULES
     
    34943543    ],[])
    34953544
    3496   AC_ARG_WITH([m4_tolower($1)],
    3497     AC_HELP_STRING([--with-m4_tolower($1)],
    3498                    [prefix of installation directory for precompiled $1 package]),
    3499     [if test -d "$withval"; then : ; else
    3500        AC_MSG_ERROR([argument for --with-m4_tolower($1) not a directory])
    3501      fi
    3502      # maybe the user points directly to the directory with the .pc file
    3503      PKG_CONFIG_PATH="$withval:$PKG_CONFIG_PATH"
    3504      # maybe the user points to a project main directory
    3505      if test -d "$withval/lib/$2/pkgconfig"; then
    3506        PKG_CONFIG_PATH="$withval/lib/$2/pkgconfig:$PKG_CONFIG_PATH"
    3507      fi
    3508     ],[])
     3545#   AC_ARG_WITH([m4_tolower($1)],
     3546#     AC_HELP_STRING([--with-m4_tolower($1)],
     3547#                    [prefix of installation directory for precompiled $1 package]),
     3548#     [if test -d "$withval"; then : ; else
     3549#        AC_MSG_ERROR([argument for --with-m4_tolower($1) not a directory])
     3550#      fi
     3551#      # maybe the user points directly to the directory with the .pc file
     3552#      PKG_CONFIG_PATH="$withval:$PKG_CONFIG_PATH"
     3553#      # maybe the user points to a project main directory
     3554#      if test -d "$withval/lib/$2/pkgconfig"; then
     3555#        PKG_CONFIG_PATH="$withval/lib/$2/pkgconfig:$PKG_CONFIG_PATH"
     3556#      fi
     3557#     ],[])
    35093558
    35103559  # let pkgconfig check if the project is already installed somewhere
     
    35693618AC_DEFUN([AC_COIN_HAS_PROJECT2],
    35703619[AC_MSG_CHECKING([for COIN project $1])
    3571 # First check, if the sub-project is actually available
    35723620
    35733621m4_tolower(coin_has_$1)=notGiven
     
    36323680    ],[])
    36333681
    3634   AC_ARG_WITH([m4_tolower($1)],
    3635     AC_HELP_STRING([--with-m4_tolower($1)],
    3636                    [prefix of installation directory for precompiled $1 package]),
    3637     [if test -d "$withval"; then : ; else
    3638        AC_MSG_ERROR([argument for --with-m4_tolower($1) not a directory])
    3639      fi
    3640      #if the user points directly to the directory with the .pc file
    3641      PKG_CONFIG_PATH="$withval:$PKG_CONFIG_PATH"
    3642      #if the user points to a project main directory
    3643      if test -d "$withval/lib/$2/pkgconfig"; then
    3644        PKG_CONFIG_PATH="$withval/lib/$2/pkgconfig:$PKG_CONFIG_PATH"
    3645      fi
    3646     ],[])
     3682#   AC_ARG_WITH([m4_tolower($1)],
     3683#     AC_HELP_STRING([--with-m4_tolower($1)],
     3684#                    [prefix of installation directory for precompiled $1 package]),
     3685#     [if test -d "$withval"; then : ; else
     3686#        AC_MSG_ERROR([argument for --with-m4_tolower($1) not a directory])
     3687#      fi
     3688#      #if the user points directly to the directory with the .pc file
     3689#      PKG_CONFIG_PATH="$withval:$PKG_CONFIG_PATH"
     3690#      #if the user points to a project main directory
     3691#      if test -d "$withval/lib/$2/pkgconfig"; then
     3692#        PKG_CONFIG_PATH="$withval/lib/$2/pkgconfig:$PKG_CONFIG_PATH"
     3693#      fi
     3694#     ],[])
    36473695
    36483696  # check if uninstalled project can be found in ../$2/$1
     
    37003748
    37013749]) # AC_COIN_HAS_PROJECT2
     3750
     3751AC_DEFUN([AC_COIN_HAS_MODULE_HELPER],
     3752[
     3753module_content="$module_content m4_tolower($1)"
     3754for i in $1 ; do
     3755  # check if directory $srcdir/../$1 exists and add ../$1 to the PKG_CONFIG_PATH
     3756  # this is for the classic setup where an uninstalled project can be found in ../$1
     3757  if test -d $srcdir/../$1; then
     3758#    coin_pkg_is_here=no
     3759#    m4_ifvaln([$3],
     3760#      [for i in $srcdir/../$2/$1/$3; do
     3761#         if test -r $i; then
     3762#           coin_pkg_is_here=yes
     3763#         fi
     3764#       done],
     3765#      [ coin_pkg_is_here=yes ])
     3766#    if test $coin_pkg_is_here = yes; then
     3767      PKG_CONFIG_PATH="../$1:$PKG_CONFIG_PATH"
     3768#    fi
     3769  break;
     3770  fi
     3771done
     3772]) # AC_COIN_HAS_MODULE_HELPER
     3773
     3774###########################################################################
     3775#                            COIN_HAS_MODULE                              #
     3776###########################################################################
     3777
     3778# This macro sets up a COIN-OR module.
     3779# A module consists of one or more COIN-OR packages.
     3780# It defines the MODULE_CFLAGS, MODULE_LIBS, and MODULE_DATA variables, refering to the compiler and linker
     3781# flags to use when linking against this module and the directories where the module data resists.
     3782# It also defines a COIN_HAS_MODULE preprocessor macro and makefile conditional.
     3783# The argument should be the name (MODULE) of the module (in correct lower
     3784# and upper case), and a list of projects that belong to this module.
     3785#, optionally a directory where to look at it, and
     3786# optionally a file that need to be present in the package directory.
     3787#
     3788# It is also possible to specify a preinstalled version of this module
     3789# or to specify only the linker and compiler flags and data directory.
     3790
     3791AC_DEFUN([AC_COIN_HAS_MODULE],
     3792[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3793AC_MSG_CHECKING([for COIN module $1])
     3794
     3795m4_tolower(coin_has_$1)=notGiven
     3796
     3797# check if user wants to skip module in any case
     3798if test x"$COIN_SKIP_PROJECTS" != x; then
     3799  for dir in $COIN_SKIP_PROJECTS; do
     3800    if test $dir = "$1"; then
     3801      m4_tolower(coin_has_$1)=skipping
     3802    fi
     3803  done
     3804fi
     3805
     3806m4_toupper($1_LIBS)=
     3807m4_toupper($1_CFLAGS)=
     3808m4_toupper($1_DATA)=
     3809AC_SUBST(m4_toupper($1_LIBS))
     3810AC_SUBST(m4_toupper($1_CFLAGS))
     3811AC_SUBST(m4_toupper($1_DATA))
     3812
     3813#check if user provided LIBS, CFLAGS, and DATA for module
     3814if test $m4_tolower(coin_has_$1) != skipping; then
     3815
     3816  AC_ARG_WITH([m4_tolower($1)-lib],
     3817    AC_HELP_STRING([--with-m4_tolower($1)-lib],
     3818                   [linker flags for using module $1]),
     3819      [m4_tolower(coin_has_$1)=yes
     3820       m4_toupper($1_LIBS)="$withval"],
     3821      [])
     3822
     3823  AC_ARG_WITH([m4_tolower($1)-incdir],
     3824    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
     3825                   [directory with header files for using module $1]),
     3826    [m4_tolower(coin_has_$1)=yes
     3827     m4_toupper($1_CFLAGS)="-I$withval"],
     3828    [])
     3829
     3830  AC_ARG_WITH([m4_tolower($1)-datadir],
     3831    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
     3832                   [directory with data files for using module $1]),
     3833    [m4_tolower(coin_has_$1)=yes
     3834     m4_toupper($1_DATA)="$withval"],
     3835    [])
     3836fi
     3837
     3838if test $m4_tolower(coin_has_$1) = notGiven; then
     3839  #assemble search path for pkg-config
     3840  if test -n "$PKG_CONFIG" ; then
     3841    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
     3842
     3843    AC_ARG_WITH([coin-instdir],
     3844      AC_HELP_STRING([--with-coin-instdir],
     3845                     [prefix of installation directory for precompiled COIN packages]),
     3846      [if test -d "$withval"; then : ; else
     3847         AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
     3848       fi
     3849       PKG_CONFIG_PATH="$withval/lib/pkgconfig:$PKG_CONFIG_PATH",
     3850      ],[])
     3851
     3852    # go through $2 to ... and assemble PKG_CONFIG_PATH with ../$2 and module search string
     3853    module_content=""
     3854    m4_ifvaln([$2], AC_COIN_HAS_MODULE_HELPER([$2]))
     3855    m4_ifvaln([$3], AC_COIN_HAS_MODULE_HELPER([$3]))
     3856    m4_ifvaln([$4], AC_COIN_HAS_MODULE_HELPER([$4]))
     3857    m4_ifvaln([$5], AC_COIN_HAS_MODULE_HELPER([$5]))
     3858    m4_ifvaln([$6], AC_COIN_HAS_MODULE_HELPER([$6]))
     3859    m4_ifvaln([$7], AC_COIN_HAS_MODULE_HELPER([$7]))
     3860    m4_ifvaln([$8], AC_COIN_HAS_MODULE_HELPER([$8]))
     3861    m4_ifvaln([$9], AC_COIN_HAS_MODULE_HELPER([$9]))
     3862
     3863    # let pkg-config do it's magic
     3864    # need to export variable to be sure that the following pkg-config gets these values
     3865    export PKG_CONFIG_PATH
     3866    AC_COIN_PKG_HAS_MODULE([$1],[$module_content],
     3867      [ m4_tolower(coin_has_$1)=yes
     3868        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
     3869      ],
     3870      [ m4_tolower(coin_has_$1)=notGiven
     3871        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
     3872      ])
     3873
     3874    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
     3875  else
     3876    AC_MSG_RESULT([skipped check via pkg-config])
     3877  fi
     3878
     3879else
     3880  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
     3881fi
     3882
     3883if test $m4_tolower(coin_has_$1) != skipping &&
     3884   test $m4_tolower(coin_has_$1) != notGiven ; then
     3885  if test "x$m4_toupper($1)_CFLAGS" != x ; then
     3886    AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     3887  fi
     3888  if test "x$m4_toupper($1)_LIBS" != x ; then
     3889    AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
     3890    ADDLIBS="$m4_toupper($1)_LIBS $ADDLIBS"
     3891  fi
     3892  if test "x$m4_toupper($1)_DATA" != x ; then
     3893    AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
     3894  fi
     3895  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 module is available])
     3896fi
     3897
     3898# Define the Makefile conditional
     3899AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
     3900               [test $m4_tolower(coin_has_$1) != notGiven &&
     3901                test $m4_tolower(coin_has_$1) != skipping])
     3902
     3903]) # AC_COIN_HAS_MODULE
     3904
Note: See TracChangeset for help on using the changeset viewer.