Changeset 1656


Ignore:
Timestamp:
Jul 25, 2010 3:54:51 PM (11 years ago)
Author:
stefan
Message:

revise fallback: check also dependencies and augment libs and cflags; search for .pc files in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/coin.m4

    r1655 r1656  
    37573757# and upper case).
    37583758# The second argument should be a (space separated) list of projects which this
    3759 # module consists of. Optionally, required version numbers could be added.
     3759# module consists of. Optionally, required version numbers can be added.
    37603760# The optional third argument can be used to overwrite default values for flags like 'required'.
    3761 # The optional fourth argument can be used to define a fallback for the case where pkg-config is not available.
    3762 # It should contain the path under which a $2-uninstalled.pc file can be found.
    3763 # If provided, then COIN_HAS_MODULE_FALLBACK($1, $2, $4, $3) is called.
    37643761#
    37653762# It is also possible to specify a preinstalled version of this module
     
    37673764# If the flag 'required' (which is on by default) is set, then user-given linker flags are added to
    37683765# the PCADDLIBS variable, which can be used to setup a .pc file.
     3766#
     3767# If the user did not specify --with-$1-... flags and pkg-config is not available,
     3768# COIN_HAS_MODULE_FALLBACK($1, $2, $3) is called.
    37693769
    37703770AC_DEFUN([AC_COIN_HAS_MODULE],
     
    38403840    export PKG_CONFIG_PATH
    38413841  else
    3842     #if 4th argument is given, try fallback - whereby we take the first word from $2 as basename for the .pc file
    3843     m4_ifvaln([$4],
    3844       [AC_COIN_HAS_MODULE_FALLBACK([$1], [m4_bpatsubst($2, [ .*], [])], [$4], [$3 printmsgchecking=0])],
    3845       [AC_MSG_RESULT([skipped check via pkg-config])])
     3842    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
     3843    AC_COIN_HAS_MODULE_FALLBACK([$1], [$2], [$3])
    38463844  fi
    38473845
     
    38773875###########################################################################
    38783876
    3879 # This macro can be used if COIN_HAS_MODULE fails to find a module because pkg-config
    3880 # was disabled or not available.
    3881 # Here, the module can consist of only one package.
     3877# This macro is used if COIN_HAS_MODULE fails to find a module because pkg-config was disabled or is not available.
    38823878#
    3883 # It reads a project-uninstalled.pc file and defines the variables MODULE_CFLAGS, MODULE_LIBS, and MODULE_DATA,
     3879# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc file in the directories specified in
     3880# $COIN_PKG_CONFIG_PATH_UNINSTALLED. The latter variable is setup by COIN_HAS_PKGCONFIG and
     3881# consists of the content of the coin_subdirs.txt file which has been created by configure in the base directory.
     3882# The content of xxx-uninstalled.pc is parsed in order to defines the variables MODULE_CFLAGS, MODULE_LIBS, and MODULE_DATA,
    38843883# referring to the compiler and linker flags to use when linking against this module
    38853884# and the directory where the module data resists.
    3886 # Further, tolower(coin_has_$1) is set to "yes" and a COIN_HAS_MODULE preprocessor macro and
    3887 # makefile conditional are defined.
     3885# Further, the Required field of each .pc file is parsed and -uninstalled.pc files for these projects are searched for.
     3886# The MODULE_CFLAGS and MODULE_LIBS variables are augmented with the information from these .pc files.
     3887# Thus, the macros checks also dependencies of $2.
     3888# Note that the MODULE_DATA variable is set to the content of datadir of the first .pc file that is parsed.
     3889#
     3890# If .pc files for all projects in $2 and their dependencies is found, tolower(coin_has_$1) is set to "yes".
     3891# Otherwise, if some dependency is not found, tolower(coin_has_$1) is set to no.
     3892# Further, a COIN_HAS_MODULE preprocessor macro and a makefile conditional are defined.
    38883893# If the flag 'required' is set (which is on by default), then the module package is added to
    38893894# the REQUIREDPACKAGES variable, which can be used to setup a .pc file.
    3890 # If the flag 'dodefine' is set (which is on by default), then the compiler define COIN_HAS_MODULE is set.
    3891 # If the flag 'doconditional' is set (which is on by default), then the makefile conditional COIN_HAS_MODULE is set.
    38923895#
    38933896# The first argument should be the name (MODULE) of the module (in correct lower and upper case).
    3894 # The second argument should be the base name of the projects .pc file which defines this module.
    3895 # The third argument should be the (relative) path under which the .pc file may be located.
    3896 # The optional fourth argument can be used to overwrite default values for the flags 'required', 'dodefine', 'doconditional'.
     3897# The second argument should be the base names of the projects .pc file which define this module.
     3898# The optional third argument can be used to overwrite default values for flags like 'required'.
     3899
     3900# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into $COIN_PKG_CONFIG_PATH_UNINSTALLED.
     3901# When the content of this variable was setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
    38973902
    38983903AC_DEFUN([AC_COIN_HAS_MODULE_FALLBACK],
    3899 [
    3900 if test x$m4_tolower(coin_has_$1) != "xyes" ; then
    3901 
    3902 m4_bmatch($4, [printmsgchecking=0], [], AC_MSG_CHECKING([for COIN-OR module $1 (fallback)]))
     3904[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3905AC_MSG_CHECKING([for COIN-OR module $1 (fallback)])
    39033906
    39043907m4_tolower(coin_has_$1)=notGiven
    3905 
    3906 # check if user wants to skip module in any case
    3907 if test x"$COIN_SKIP_PROJECTS" != x; then
    3908   for dir in $COIN_SKIP_PROJECTS; do
    3909     if test $dir = "$1"; then
    3910       m4_tolower(coin_has_$1)=skipping
    3911     fi
    3912   done
    3913 fi
    3914 
    39153908m4_toupper($1_LIBS)=
    39163909m4_toupper($1_CFLAGS)=
     
    39183911AC_SUBST(REQUIREDPACKAGES)
    39193912
    3920 if test $m4_tolower(coin_has_$1) != "skipping" ; then
    3921   # if the project is available and configured, then a project-uninstalled.pc file should have been created
    3922   if test -r $3/$2-uninstalled.pc ; then
    3923     # read CFLAGS and LIBS from $2-uninstalled.pc file
    3924     # add CYGPATH_W cludge into include flags
    3925     # replace -L${libdir} by absolute path to build directory in linker flags
    3926     # we assume that the build directory is $3/src if this directory exists, otherwise we assume that it is $3
    3927     m4_toupper($1_CFLAGS)=[`sed -n -e 's/Cflags://' -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/gp'] $3/$2-uninstalled.pc`
    3928     projectlibs=`sed -n -e 's/Libs://' -e 's/-L\${libdir}//p' $3/$2-uninstalled.pc`
    3929     if test "x$projectlibs" != x ; then
    3930       if test -d $3/src ; then
    3931         m4_toupper($1_LIBS)="-L`cd $3/src; pwd` $projectlibs"
     3913# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x)
     3914projtoprocess="m4_bpatsubsts([$2], [<?>?=[      ]*[^    ]+])"
     3915projprocessed=""
     3916
     3917while test $m4_tolower(coin_has_$1) = notGiven ; do
     3918  # setup list of projects that need to be processed in the next round
     3919  nextprojtoprocess=""
     3920
     3921  for proj in $projtoprocess ; do
     3922    # if $proj has been processed already, skip this round
     3923    if test "x$projprocessed" != x ; then
     3924      for projdone in $projprocessed ; do
     3925        if test $projdone = $proj ; then
     3926          continue 2
     3927        fi
     3928      done
     3929    fi
     3930
     3931    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
     3932    pcfile=""
     3933    save_IFS="$IFS"
     3934    IFS=":"
     3935    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
     3936      # the base directory configure should have setup coin_subdirs.txt in a way that it does not contain projects that should be skipped, so we do not need to test this here again
     3937      if test -r "$dir/$proj-uninstalled.pc" ; then
     3938        pcfile="$dir/$proj-uninstalled.pc"
     3939        pcfiledir="$dir"
     3940        break
     3941      fi
     3942    done
     3943    IFS="$save_IFS"
     3944
     3945    if test "x$pcfile" != x ; then
     3946      # read CFLAGS from $pcfile and add CYGPATH_W cludge into include flags
     3947      projcflags=[`sed -n -e 's/Cflags://' -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/gp' "$pcfile"`]
     3948      m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
     3949     
     3950      # read LIBS from $pcfile and replace -L${libdir} by absolute path to build directory in linker flags
     3951      # we assume that the build directory is $pcfiledir/src if this directory exists, otherwise we assume that it is $pcfiledir
     3952      projlibs=`sed -n -e 's/Libs://' -e 's/-L\${libdir}//p' "$pcfile"`
     3953      if test "x$projlibs" != x ; then
     3954        if test -d "${pcfiledir}/src" ; then
     3955          projlibs="-L`cd "${pcfiledir}/src"; pwd` $projlibs"
     3956        else
     3957          projlibs="-L`cd "$pcfiledir"; pwd` $projlibs"
     3958        fi
    39323959      else
    3933         m4_toupper($1_LIBS)="-L`cd $3; pwd` $projectlibs"
     3960        projlibs=`sed -n -e 's/Libs://p' "$pcfile"`
    39343961      fi
     3962      m4_toupper($1_LIBS)="$projlibs $m4_toupper($1_LIBS)"
     3963     
     3964      # read DATA from $pcfile, if this is the first .pc file we are processing (so assume that its the main one)
     3965      if test "x$projprocessed" = x ; then
     3966        m4_toupper($1_DATA)=`sed -n -e 's/datadir=//gp' "$pcfile"`
     3967      fi
     3968     
     3969      # read dependencies from $pcfile, filter it, and add to list of projects that need to be processed next
     3970      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\?>\?=[         ]*[^    ]\+//g'`]
     3971      nextprojtoprocess="$nextprojtoprocess $projrequires"
     3972     
     3973      # remember that we have processed $proj
     3974      projprocessed="$projprocessed $proj"
     3975     
    39353976    else
    3936       m4_toupper($1_LIBS)=`sed -n -e 's/Libs://p' $3/$2-uninstalled.pc`
    3937     fi
    3938     m4_toupper($1_DATA)=`sed -n -e 's/datadir=//gp' $3/$2-uninstalled.pc`
    3939 
    3940     m4_bmatch($4, [required=0], [],
    3941       [REQUIREDPACKAGES="$2 $REQUIREDPACKAGES"
    3942       ])
    3943 
    3944     m4_bmatch($4, [dodefine=0], [],
    3945       [AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 module is available])
    3946       ])
    3947 
     3977      AC_MSG_RESULT([no, dependency $proj not available])
     3978      break 2
     3979    fi
     3980
     3981  done
     3982 
     3983  projtoprocess="$nextprojtoprocess"
     3984 
     3985  if test "x$projtoprocess" = x ; then
    39483986    m4_tolower(coin_has_$1)=yes
    3949     AC_MSG_RESULT([$3])
    3950   else
    3951     AC_MSG_RESULT($m4_tolower(coin_has_$1))
    3952   fi
    3953 else
    3954   AC_MSG_RESULT([skipping])
    3955 fi
    3956 
    3957 #if user did not disable setting of makefile conditional, do it
    3958 m4_bmatch($4, [doconditional=0], [],
    3959   [AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
     3987    AC_MSG_RESULT([yes, dependencies are$projprocessed])
     3988   
     3989    m4_bmatch($3, [required=0], [], [REQUIREDPACKAGES="$2 $REQUIREDPACKAGES"])
     3990    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 module is available])
     3991   
     3992    if test 1 = 0 ; then  #change this test to enable a bit of debugging output
     3993    if test -n "$m4_toupper($1)_CFLAGS" ; then
     3994      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     3995    fi
     3996    if test -n "$m4_toupper($1)_LIBS" ; then
     3997      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
     3998    fi
     3999    if test -n "$m4_toupper($1)_DATA" ; then
     4000      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
     4001    fi
     4002    fi
     4003  fi
     4004done
     4005
     4006AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
    39604007               [test $m4_tolower(coin_has_$1) != notGiven &&
    39614008                test $m4_tolower(coin_has_$1) != skipping])
    3962   ])
    3963 fi
     4009
    39644010]) # AC_COIN_HAS_MODULE_FALLBACK
    39654011
     
    40784124
    40794125if test "x$use_blas" = xBUILD ; then
    4080   if test -d ../ThirdParty/Blas ; then
    4081     blasdir=../ThirdParty/Blas
    4082   else
    4083     blasdir=../Blas
    4084   fi
    4085   AC_COIN_HAS_MODULE(Blas, [coinblas], [], [$blasdir])
     4126  AC_COIN_HAS_MODULE(Blas, [coinblas])
    40864127 
    40874128elif test "x$use_blas" != x && test "$use_blas" != no; then
     
    42134254
    42144255if test "x$use_lapack" = xBUILD ; then
    4215   if test -d ../ThirdParty/Lapack ; then
    4216     lapackdir=../ThirdParty/Lapack
    4217   else
    4218     lapackdir=../Lapack
    4219   fi
    4220   AC_COIN_HAS_MODULE(Lapack, [coinlapack], [], [$lapackdir])
     4256  AC_COIN_HAS_MODULE(Lapack, [coinlapack])
    42214257 
    42224258elif test "x$use_lapack" != x && test "$use_lapack" != no; then
Note: See TracChangeset for help on using the changeset viewer.