Changeset 1507


Ignore:
Timestamp:
Apr 24, 2010 11:22:46 AM (10 years ago)
Author:
stefan
Message:

new macro AC_COIN_HAS_MODULE_FALLBACK to find packages in a non-pkg-config build by reading a ...-uninstalled.pc file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/split/coin.m4

    r1475 r1507  
    24942494
    24952495###########################################################################
    2496 #                            COIN_HAS_PROJECT                             #
     2496#                            COIN_HAS_PROJECT (deprecated)                #
    24972497###########################################################################
    24982498
     
    36253625# It is also possible to specify a preinstalled version of this module
    36263626# or to specify only the linker and compiler flags and data directory.
    3627 # If the flag 'required' (which is on by default), then the user-given linker flags are added to
     3627# If the flag 'required' (which is on by default) is set, then the user-given linker flags are added to
    36283628# the ADDLIBS variable, which can be used to setup a .pc file.
    36293629
    36303630AC_DEFUN([AC_COIN_HAS_MODULE],
    36313631[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
    3632 AC_MSG_CHECKING([for COIN module $1])
     3632AC_MSG_CHECKING([for COIN-OR module $1])
    36333633
    36343634m4_tolower(coin_has_$1)=notGiven
     
    36513651AC_SUBST(REQUIREDPACKAGES)
    36523652
    3653 required=1
    3654 
    3655 # execute third argument that can be used to overwrite flags like 'required'
    3656 $3
    3657 
    36583653#check if user provided LIBS, CFLAGS, and DATA for module
    36593654if test $m4_tolower(coin_has_$1) != skipping; then
     
    36643659      [m4_tolower(coin_has_$1)=yes
    36653660       m4_toupper($1_LIBS)="$withval"
    3666        if test $required = 1; then
    3667          ADDLIBS="$ADDLIBS $withval"
    3668        fi
     3661       m4_bmatch($3, [required=0], [], [ADDLIBS="$ADDLIBS $withval"])
    36693662      ],
    36703663      [])
     
    37283721      [ m4_tolower(coin_has_$1)=yes
    37293722        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
    3730         if test $required = 1; then
    3731           REQUIREDPACKAGES="$REQUIREDPACKAGES $2"
    3732         fi
     3723        m4_bmatch($3, [required=0], [], [REQUIREDPACKAGES="$REQUIREDPACKAGES $2"])
    37333724      ],
    37343725      [ m4_tolower(coin_has_$1)=notGiven
     
    37473738if test $m4_tolower(coin_has_$1) != skipping &&
    37483739   test $m4_tolower(coin_has_$1) != notGiven ; then
     3740  if test 0 = 1 ; then  #change this test to enable a bit of debugging output
    37493741  if test -n "$m4_toupper($1)_CFLAGS" ; then
    37503742    AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     
    37553747  if test -n "$m4_toupper($1)_DATA" ; then
    37563748    AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
     3749  fi
    37573750  fi
    37583751  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 module is available])
     
    37663759]) # AC_COIN_HAS_MODULE
    37673760
     3761###########################################################################
     3762#                       COIN_HAS_MODULE_FALLBACK                          #
     3763###########################################################################
     3764
     3765# This macro can be used if COIN_HAS_MODULE fails to find a module because pkg-config
     3766# was disabled or not available.
     3767# Here, the module can consist of only one package.
     3768#
     3769# It reads a project-uninstalled.pc file and defines the variables MODULE_CFLAGS, MODULE_LIBS, and MODULE_DATA,
     3770# refering to the compiler and linker flags to use when linking against this module
     3771# and the directory where the module data resists.
     3772# Further, tolower(coin_has_$1) is set to "yes" and a COIN_HAS_MODULE preprocessor macro and
     3773# makefile conditional are defined. Further, the linker flags are added to the ADDLIBS variable.
     3774# If the flag 'required' is set (which is on by default), then the module package is added to
     3775# the REQUIREDPACKAGES variable, which can be used to setup a .pc file.
     3776# If the flag 'dodefine' is set (which is on by default), then the compiler define COIN_HAS_MODULE is set.
     3777# If the flag 'doconditional' is set (which is on by default), then the makefile conditional COIN_HAS_MODULE is set.
     3778#
     3779# The first argument should be the name (MODULE) of the module (in correct lower and upper case).
     3780# The second argument should be the base name of the projects .pc file which defines this module.
     3781# The third argument should be the (relative) path under which the .pc file may be located.
     3782# The optional fourth argument can be used to overwrite default values for the flags 'required', 'dodefine', 'doconditional'.
     3783
     3784AC_DEFUN([AC_COIN_HAS_MODULE_FALLBACK],
     3785[
     3786if test $m4_tolower(coin_has_$1) != "yes" ; then
     3787AC_MSG_CHECKING([for COIN-OR module $1 (fallback)])
     3788
     3789m4_tolower(coin_has_$1)=notGiven
     3790
     3791# check if user wants to skip module in any case
     3792if test x"$COIN_SKIP_PROJECTS" != x; then
     3793  for dir in $COIN_SKIP_PROJECTS; do
     3794    if test $dir = "$1"; then
     3795      m4_tolower(coin_has_$1)=skipping
     3796    fi
     3797  done
     3798fi
     3799
     3800m4_toupper($1_LIBS)=
     3801m4_toupper($1_CFLAGS)=
     3802m4_toupper($1_DATA)=
     3803AC_SUBST(REQUIREDPACKAGES)
     3804
     3805if test $m4_tolower(coin_has_$1) != "skipping" ; then
     3806  # if the project is available and configured, then a project-uninstalled.pc file should have been created
     3807  if test -r $3/$2-uninstalled.pc ; then
     3808    # read CFLAGS and LIBS from $2-uninstalled.pc file
     3809    # add CYGPATH_W cludge into include flags
     3810    # replace -L${libdir} by absolute path to build directory in linker flags
     3811    m4_toupper($1_CFLAGS)=[`sed -n -e 's/Cflags://' -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/gp'] $3/$2-uninstalled.pc`
     3812    projectlibs=`sed -n -e 's/Libs://' -e 's/-L\${libdir}//p' $3/$2-uninstalled.pc`
     3813    if test "x$projectlibs" != x ; then
     3814      m4_toupper($1_LIBS)="-L`cd $3; pwd` $projectlibs"
     3815    fi
     3816    m4_toupper($1_DATA)=`sed -n -e 's/datadir=//gp' $3/$2-uninstalled.pc`
     3817
     3818    ADDLIBS="$ADDLIBS $m4_toupper($1_LIBS)"
     3819 
     3820    m4_bmatch($4, [required=0], [], [REQUIREDPACKAGES="$REQUIREDPACKAGES $2"])
     3821
     3822    m4_bmatch($4, [dodefine=0], [],
     3823      [AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 module is available])
     3824      ])
     3825
     3826    m4_tolower(coin_has_$1)=yes
     3827  fi
     3828fi
     3829
     3830#if user did not disable setting of makefile conditional, do it
     3831m4_bmatch($4, [doconditional=0], [],
     3832  [AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
     3833               [test $m4_tolower(coin_has_$1) != notGiven &&
     3834                test $m4_tolower(coin_has_$1) != skipping])
     3835  ])
     3836
     3837AC_MSG_RESULT($m4_tolower(coin_has_$1))
     3838fi
     3839]) # AC_COIN_HAS_MODULE_FALLBACK
    37683840
    37693841###########################################################################
     
    37763848# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS to its value
    37773849# 4. tries standard libraries
    3778 # 5. calls COIN_HAS_MODULE(Blas, [blas]) to check for ThirdParty/Blas
     3850# 5. calls COIN_HAS_MODULE(Blas, [coinblas]) to check for ThirdParty/Blas
     3851# 6. calls COIN_HAS_MODULE_FALLBACK(Blas, [coinblas], [../ThirdParty/Blas])
    37793852# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
    37803853# BLAS_LIBS is set to the flags required to link with a Blas library.
     
    39033976fi
    39043977
     3978#call fallback in case the previous failed, maybe because pkg-config was not available
     3979AC_COIN_HAS_MODULE_FALLBACK([Blas], [coinblas], [../ThirdParty/Blas])
     3980
    39053981]) # AC_COIN_HAS_MODULE_BLAS
    39063982
     
    39153991# 4. tries standard libraries
    39163992# 5. calls COIN_HAS_MODULE(Lapack, [lapack]) to check for ThirdParty/Lapack
     3993# 6. calls COIN_HAS_MODULE_FALLBACK(Lapack, [coinlapack], [../ThirdParty/Lapack])
    39173994# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
    39183995# LAPACK_LIBS is set to the flags required to link with a Lapack library.
     
    40354112fi
    40364113
     4114#call fallback in case the previous failed, maybe because pkg-config was not available
     4115AC_COIN_HAS_MODULE_FALLBACK([Lapack], [coinlapack], [../ThirdParty/Lapack])
     4116
    40374117]) # AC_COIN_HAS_MODULE_LAPACK
Note: See TracChangeset for help on using the changeset viewer.