Changeset 1676


Ignore:
Timestamp:
Sep 12, 2010 3:11:27 PM (11 years ago)
Author:
stefan
Message:

add new COIN_HAS_PACKAGE macros to setup target specific linking flags; should replace COIN_HAS_MODULE soon; other changes to get rid of ADDLIBS soon

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/coin.m4

    r1675 r1676  
    1212# Check requirements
    1313AC_PREREQ(2.59)
     14
     15###########################################################################
     16#                           coin_foreach_w                                #
     17###########################################################################
     18
     19# the autoconf version used by COIN-OR is so old that it does not have the M4 macro foreach_w.
     20# thus, we define our own one which applies the foreach macro to the same arguments but with
     21# all spaces replaced by ',' in the second argument.
     22# further, we run the loop only if the second argument is not empty
     23AC_DEFUN([coin_foreach_w], [m4_ifval([$2], [m4_foreach([$1], [m4_bpatsubsts([$2],[[     ]+],[, ])], [$3])])])
    1424
    1525###########################################################################
     
    22702280]) # AC_COIN_ENABLE_GNU_PACKAGES
    22712281
     2282#######################################################################
     2283#                           COIN_CHECK_LIBM                           #
     2284#######################################################################
     2285
     2286# For a (space separated) list of arguments X, this macro adds the flags
     2287# for linking against the math library to a X_LIBS and X_PCLIBS.
     2288
     2289AC_DEFUN([AC_COIN_CHECK_LIBM],
     2290[AC_BEFORE([AC_COIN_PROG_CC],[$0])
     2291
     2292case "$CC" in
     2293  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
     2294    ;;
     2295  *)
     2296    coin_foreach_w([myvar], [$1], [
     2297      m4_toupper(myvar)_LIBS="-lm $m4_toupper(myvar)_LIBS"
     2298      m4_toupper(myvar)_PCLIBS="-lm $m4_toupper(myvar)_PCLIBS"
     2299    ])
     2300  ;;
     2301esac
     2302
     2303]) # AC_COIN_CHECK_LIBM
     2304
    22722305###########################################################################
    22732306#                           COIN_CHECK_GNU_ZLIB                           #
     
    22752308
    22762309# This macro checks for the libz library.
     2310# If found, it sets the automake conditional COIN_HAS_ZLIB and defines the C preprocessor variable COIN_HAS_ZLIB.
     2311# Further, for a (space separated) list of arguments X, it adds the linker flag to the variables X_LIBS and X_PCLIBS.
    22772312
    22782313AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
     
    22892324  if test $coin_has_zlib = yes; then
    22902325    AC_CHECK_LIB([z],[gzopen],
    2291                  [ADDLIBS="-lz $ADDLIBS"],
     2326                 [ADDLIBS="-lz $ADDLIBS"
     2327                  coin_foreach_w([myvar], [$1], [
     2328                    m4_toupper(myvar)_LIBS="-lz $m4_toupper(myvar)_LIBS"
     2329                    m4_toupper(myvar)_PCLIBS="-lz $m4_toupper(myvar)_PCLIBS"
     2330                  ])
     2331                 ],
    22922332                 [coin_has_zlib=no])
    22932333  fi
     
    23072347
    23082348# This macro checks for the libbz2 library.
     2349# If found, it defines the C preprocessor variable COIN_HAS_BZLIB.
     2350# Further, for a (space separated) list of arguments X, it adds the linker flag to the variables X_LIBS and X_PCLIBS.
    23092351
    23102352AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
     
    23212363  if test $coin_has_bzlib = yes; then
    23222364    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
    2323                  [ADDLIBS="-lbz2 $ADDLIBS"],
     2365                 [ADDLIBS="-lbz2 $ADDLIBS"
     2366                  coin_foreach_w([myvar], [$1], [
     2367                    m4_toupper(myvar)_LIBS="-lbz2 $m4_toupper(myvar)_LIBS"
     2368                    m4_toupper(myvar)_PCLIBS="-lbz2 $m4_toupper(myvar)_PCLIBS"
     2369                  ])
     2370                 ],
    23242371                 [coin_has_bzlib=no])
    23252372  fi
     
    23402387# contains "readline".  It is assumed that #include <stdio.h> is included
    23412388# in the source file before the #include<readline/readline.h>
     2389# If found, it defines the C preprocessor variable COIN_HAS_READLINE.
     2390# Further, for a (space separated) list of arguments X, it adds the linker flag to the variable X_LIBS and X_PCLIBS.
    23422391
    23432392AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
     
    23652414  if test $coin_has_readline = yes; then
    23662415    AC_CHECK_LIB([readline],[readline],
    2367                  [ADDLIBS="-lreadline $LIBS $ADDLIBS"],
     2416                 [ADDLIBS="-lreadline $LIBS $ADDLIBS"
     2417                  coin_foreach_w([myvar], [$1], [
     2418                    m4_toupper(myvar)_LIBS="-lreadline $LIBS $m4_toupper(myvar)_LIBS"
     2419                    m4_toupper(myvar)_PCLIBS="-lreadline $LIBS $m4_toupper(myvar)_PCLIBS"
     2420                  ])
     2421                 ],
    23682422                 [coin_has_readline=no])
    23692423  fi
     
    26292683# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
    26302684# name.
     2685# A fifth argument can be specified to include linker flags that may be required
     2686# to sucessfully perform the linking check.
     2687#
     2688# An optional sixth argument can be given to specify a list of targets.
     2689# For each target X, the variables X_LIBS and X_PCLIBS will be extended by $LBRYLIB,
     2690# if the library has been found and seems to work.
    26312691
    26322692AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
     
    26922752        [if test x"$m4_tolower($1)_libcheck" != xno; then
    26932753           coin_save_LIBS="$LIBS"
    2694            LIBS="$$2LIB $ADDLIBS"
     2754           LIBS="$$2LIB $ADDLIBS $5"
    26952755           coin_$2_link=no
    26962756           AC_LANG_PUSH(C)
     
    27042764           done
    27052765           AC_LANG_POP(C)
    2706            if test x"$coin_$2_link" = xyes ; then
    2707              LIBS="$coin_save_LIBS"
    2708            else
     2766           LIBS="$coin_save_LIBS"
     2767           if test x"$coin_$2_link" != xyes ; then
    27092768             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
    27102769           fi
     
    27122771
    27132772# If we make it this far, we've verified the file and linked the function. Add
    2714 # the necessary link flags to ADDLIBS and define the preprocessor symbol
     2773# the necessary link flags to ADDLIBS and $6_{PC}LIBS and define the preprocessor symbol
    27152774# COIN_HAS_LBRY.
    27162775
    27172776    ADDLIBS="$$2LIB $ADDLIBS"
     2777    coin_foreach_w([myvar], [$6], [
     2778      m4_toupper(myvar)_LIBS="$$2LIB $m4_toupper(myvar)_LIBS"
     2779      m4_toupper(myvar)_PCLIBS="$$2LIB $m4_toupper(myvar)_PCLIBS"
     2780    ])
     2781   
    27182782    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
    27192783  fi
     
    43544418
    43554419]) # AC_COIN_HAS_MODULE_LAPACK
     4420
     4421###########################################################################
     4422#                            COIN_HAS_PACKAGE                             #
     4423###########################################################################
     4424
     4425# This macro checks for the existance of a COIN-OR package and provides compiler and linker flags to compile against this package.
     4426# A package can consists of one or more COIN-OR or other projects.
     4427# It defines the PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA variables, referring to the compiler and linker
     4428# flags to use when linking against this module and the directories where the module data resists.
     4429# It also defines a COIN_HAS_PACKAGE preprocessor macro and makefile conditional.
     4430# Further, tolower(coin_has_$1) is set to "yes".
     4431# If a list of build targets using this projects is given in the third argument,
     4432# then the compiler and linker variables and .pc file setup variable corresponding to this build target
     4433# are extended with the values for this package.
     4434# That is, for each build target X, the variables X_CFLAGS, X_LIBS, X_PCLIBS, X_PCREQUIRES are setup,
     4435# whereas the last two specify the values to put into the "Libs:" and "Requires:" fields of the .pc file, resp.
     4436#
     4437# The first argument should be the name (PACKAGE) of the package (in correct lower
     4438# and upper case).
     4439# The second argument should be a (space separated) list of projects which this
     4440# package consists of. Optionally, required version numbers can be added.
     4441# The optional third argument should be a (space separated) list of build targets
     4442# which use this package, if available.
     4443#
     4444# It is also possible to specify a preinstalled version of this package
     4445# or to specify only the linker and compiler flags and data directory.
     4446#
     4447# If the user did not specify --with-$1-... flags and pkg-config is not available,
     4448# COIN_HAS_PACKAGE_FALLBACK($1, $2, $3) is called.
     4449
     4450AC_DEFUN([AC_COIN_HAS_PACKAGE],
     4451[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     4452AC_MSG_CHECKING([for COIN-OR package $1])
     4453
     4454m4_tolower(coin_has_$1)=notGiven
     4455
     4456# check if user wants to skip package in any case
     4457if test x"$COIN_SKIP_PROJECTS" != x; then
     4458  for dir in $COIN_SKIP_PROJECTS; do
     4459    if test $dir = "$1"; then
     4460      m4_tolower(coin_has_$1)=skipping
     4461    fi
     4462  done
     4463fi
     4464
     4465m4_toupper($1_LIBS)=
     4466m4_toupper($1_CFLAGS)=
     4467m4_toupper($1_DATA)=
     4468AC_SUBST(m4_toupper($1_LIBS))
     4469AC_SUBST(m4_toupper($1_CFLAGS))
     4470AC_SUBST(m4_toupper($1_DATA))
     4471coin_foreach_w([myvar], [$3], [
     4472  AC_SUBST(m4_toupper(myvar)_LIBS)
     4473  AC_SUBST(m4_toupper(myvar)_PCLIBS)
     4474  AC_SUBST(m4_toupper(myvar)_PCREQUIRES)
     4475])
     4476
     4477#check if user provided LIBS, CFLAGS, or DATA for module
     4478if test $m4_tolower(coin_has_$1) != skipping; then
     4479
     4480  AC_ARG_WITH([m4_tolower($1)-lib],
     4481    AC_HELP_STRING([--with-m4_tolower($1)-lib],
     4482                   [linker flags for using package $1]),
     4483      [m4_tolower(coin_has_$1)=yes
     4484       m4_toupper($1_LIBS)="$withval"
     4485       coin_foreach_w([myvar], [$3], [
     4486         m4_toupper(myvar)_PCLIBS="$withval $m4_toupper(myvar)_PCLIBS"
     4487         m4_toupper(myvar)_LIBS="$withval $m4_toupper(myvar)_LIBS"
     4488       ])
     4489      ],
     4490      [])
     4491
     4492  AC_ARG_WITH([m4_tolower($1)-incdir],
     4493    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
     4494                   [directory with header files for using package $1]),
     4495    [m4_tolower(coin_has_$1)=yes
     4496     m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"
     4497     coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS="$withval $m4_toupper(myvar)_CFLAGS"
     4498     ])
     4499    ],
     4500    [])
     4501
     4502  AC_ARG_WITH([m4_tolower($1)-datadir],
     4503    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
     4504                   [directory with data files for using package $1]),
     4505    [m4_tolower(coin_has_$1)=yes
     4506     m4_toupper($1_DATA)="$withval"],
     4507    [])
     4508fi
     4509
     4510if test $m4_tolower(coin_has_$1) = notGiven; then
     4511  if test -n "$PKG_CONFIG" ; then
     4512    # set search path for pkg-config
     4513    # need to export variable to be sure that the following pkg-config gets these values
     4514    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
     4515    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$COIN_PKG_CONFIG_PATH_UNINSTALLED"
     4516    export PKG_CONFIG_PATH
     4517   
     4518    # let pkg-config do it's magic
     4519    AC_COIN_PKG_HAS_MODULE([$1],[$2],
     4520      [ m4_tolower(coin_has_$1)=yes
     4521        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
     4522        coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
     4523        ])
     4524      ],
     4525      [ m4_tolower(coin_has_$1)=notGiven
     4526        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
     4527      ])
     4528
     4529    # reset PKG_CONFIG_PATH variable
     4530    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
     4531    export PKG_CONFIG_PATH
     4532   
     4533    # augment X_CFLAGS and X_LIBS for each build target X in $3
     4534    coin_foreach_w([myvar], [$3], [
     4535      m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
     4536      m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
     4537    ])
     4538  else
     4539    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
     4540    AC_COIN_HAS_PACKAGE_FALLBACK([$1], [$2], [$3])
     4541  fi
     4542
     4543else
     4544  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
     4545fi
     4546
     4547if test $m4_tolower(coin_has_$1) != skipping &&
     4548   test $m4_tolower(coin_has_$1) != notGiven ; then
     4549  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
     4550   
     4551  if test 1 = 1 ; then  #change this test to enable a bit of debugging output
     4552    if test -n "$m4_toupper($1)_CFLAGS" ; then
     4553      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     4554    fi
     4555    if test -n "$m4_toupper($1)_LIBS" ; then
     4556      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
     4557    fi
     4558    if test -n "$m4_toupper($1)_DATA" ; then
     4559      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
     4560    fi
     4561    if test -n "$m4_toupper($1)_CFLAGS" ; then
     4562      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     4563    fi
     4564    coin_foreach_w([myvar], [$3], [
     4565      AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
     4566      AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
     4567    ])
     4568  fi
     4569fi
     4570
     4571# Define the Makefile conditional
     4572AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
     4573               [test $m4_tolower(coin_has_$1) != notGiven &&
     4574                test $m4_tolower(coin_has_$1) != skipping])
     4575
     4576]) # AC_COIN_HAS_MODULE
     4577
     4578###########################################################################
     4579#                       COIN_HAS_PACKAGE_FALLBACK                         #
     4580###########################################################################
     4581
     4582# This macro is used if COIN_HAS_PACKAGE fails to find a module because pkg-config was disabled or is not available.
     4583#
     4584# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc file in the directories specified in
     4585# $COIN_PKG_CONFIG_PATH_UNINSTALLED. The latter variable is setup by COIN_HAS_PKGCONFIG and
     4586# consists of the content of the coin_subdirs.txt file which has been created by configure in the base directory.
     4587# The content of xxx-uninstalled.pc is parsed in order to defines the variables PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA,
     4588# referring to the compiler and linker flags to use when linking against this package
     4589# and the directory where the package data resists.
     4590# Further, for each build target X specified in the third argument, the variables X_CFLAGS and X_LIBS are
     4591# extended with the compiler and linker flags of this package and the variables X_PCLIBS and X_PCREQUIRES are extended by the list
     4592# of linker flags and dependent projects as needed to setup a .pc file.
     4593# The macros checks also dependencies of $2.
     4594# Note that the PACKAGE_DATA variable is set to the content of datadir of the first .pc file that is parsed.
     4595#
     4596# If .pc files for all projects in $2 and their dependencies is found, tolower(coin_has_$1) is set to "yes".
     4597# Otherwise, if some dependency is not found, tolower(coin_has_$1) is set to "notGiven".
     4598# Further, a COIN_HAS_PACKAGE preprocessor macro and a makefile conditional are defined.
     4599#
     4600# The first argument should be the name (PACKAGE) of the package (in correct lower and upper case).
     4601# The second argument should be the base names of the projects .pc file which define this package.
     4602# The optional third argument should be a (space separated) list of build targets
     4603# which use this package, if available.
     4604
     4605# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into $COIN_PKG_CONFIG_PATH_UNINSTALLED.
     4606# When the content of this variable was setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
     4607
     4608AC_DEFUN([AC_COIN_HAS_PACKAGE_FALLBACK],
     4609[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     4610AC_MSG_CHECKING([for COIN-OR package $1 (fallback)])
     4611
     4612m4_tolower(coin_has_$1)=notGiven
     4613m4_toupper($1_LIBS)=
     4614m4_toupper($1_CFLAGS)=
     4615m4_toupper($1_DATA)=
     4616
     4617# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x)
     4618projtoprocess="m4_bpatsubsts([$2], [<?>?=[      ]*[^    ]+])"
     4619projprocessed=""
     4620
     4621while test $m4_tolower(coin_has_$1) = notGiven ; do
     4622  # setup list of projects that need to be processed in the next round
     4623  nextprojtoprocess=""
     4624
     4625  for proj in $projtoprocess ; do
     4626    # if $proj has been processed already, skip this round
     4627    if test "x$projprocessed" != x ; then
     4628      for projdone in $projprocessed ; do
     4629        if test $projdone = $proj ; then
     4630          continue 2
     4631        fi
     4632      done
     4633    fi
     4634
     4635    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
     4636    pcfile=""
     4637    save_IFS="$IFS"
     4638    IFS=":"
     4639    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
     4640      # 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
     4641      if test -r "$dir/$proj-uninstalled.pc" ; then
     4642        pcfile="$dir/$proj-uninstalled.pc"
     4643        pcfiledir="$dir"
     4644        break
     4645      fi
     4646    done
     4647    IFS="$save_IFS"
     4648
     4649    if test "x$pcfile" != x ; then
     4650      # read CFLAGS from $pcfile and add CYGPATH_W cludge into include flags
     4651      projcflags=`sed -n -e 's/Cflags://p' "$pcfile"`
     4652      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
     4653      m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
     4654     
     4655      # read LIBS from $pcfile and replace -L${libdir} by absolute path to build directory in linker flags
     4656      # we assume that the build directory is $pcfiledir/src if this directory exists, otherwise we assume that it is $pcfiledir
     4657      projlibs=`sed -n -e 's/Libs://' -e 's/-L\${libdir}//p' "$pcfile"`
     4658      if test "x$projlibs" != x ; then
     4659        if test -d "${pcfiledir}/src" ; then
     4660          projlibs="-L`cd "${pcfiledir}/src"; pwd` $projlibs"
     4661        else
     4662          projlibs="-L`cd "$pcfiledir"; pwd` $projlibs"
     4663        fi
     4664      else
     4665        projlibs=`sed -n -e 's/Libs://p' "$pcfile"`
     4666      fi
     4667      m4_toupper($1_LIBS)="$m4_toupper($1_LIBS) $projlibs"
     4668     
     4669      # read DATA from $pcfile, if this is the first .pc file we are processing (so assume that its the main one)
     4670      if test "x$projprocessed" = x ; then
     4671        m4_toupper($1_DATA)=`sed -n -e 's/datadir=//gp' "$pcfile"`
     4672      fi
     4673     
     4674      # read dependencies from $pcfile, filter it, and add to list of projects that need to be processed next
     4675      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\?>\?=[         ]*[^    ]\+//g'`]
     4676      nextprojtoprocess="$nextprojtoprocess $projrequires"
     4677     
     4678      # remember that we have processed $proj
     4679      projprocessed="$projprocessed $proj"
     4680     
     4681    else
     4682      AC_MSG_RESULT([no, dependency $proj not available])
     4683      break 2
     4684    fi
     4685
     4686  done
     4687 
     4688  projtoprocess="$nextprojtoprocess"
     4689 
     4690  # if there are no more projects to search for, finish up
     4691  if test "x$projtoprocess" = x ; then
     4692    m4_tolower(coin_has_$1)=yes
     4693    AC_MSG_RESULT([yes, dependencies are$projprocessed])
     4694    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
     4695   
     4696    coin_foreach_w([myvar], [$3], [
     4697      m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
     4698      m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
     4699      m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
     4700    ])
     4701   
     4702    if test 1 = 1 ; then  #change this test to enable a bit of debugging output
     4703      if test -n "$m4_toupper($1)_CFLAGS" ; then
     4704        AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     4705      fi
     4706      if test -n "$m4_toupper($1)_LIBS" ; then
     4707        AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
     4708      fi
     4709      if test -n "$m4_toupper($1)_DATA" ; then
     4710        AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
     4711      fi
     4712      coin_foreach_w([myvar], [$3], [
     4713        AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
     4714        AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
     4715      ])
     4716    fi
     4717  fi
     4718done
     4719
     4720AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
     4721               [test $m4_tolower(coin_has_$1) != notGiven &&
     4722                test $m4_tolower(coin_has_$1) != skipping])
     4723
     4724]) # AC_COIN_HAS_PACKAGE_FALLBACK
     4725
     4726###########################################################################
     4727#                         COIN_HAS_PACKAGE_BLAS                           #
     4728###########################################################################
     4729
     4730# This macro checks for a library containing the BLAS library.  It
     4731# 1. checks the --with-blas argument
     4732# 2. if --with-blas=BUILD has been specified goes to point 5
     4733# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS to its value
     4734# 4. tries standard libraries
     4735# 5. calls COIN_HAS_PACKAGE(Blas, [coinblas], [$1]) to check for ThirdParty/Blas
     4736# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
     4737# BLAS_LIBS is set to the flags required to link with a Blas library.
     4738# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
     4739# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
     4740# In case 5, Blas is added to X_PCREQUIRES.
     4741
     4742AC_DEFUN([AC_COIN_HAS_PACKAGE_BLAS],
     4743[
     4744AC_ARG_WITH([blas],
     4745            AC_HELP_STRING([--with-blas],
     4746                           [specify BLAS library (or BUILD for compilation)]),
     4747            [use_blas="$withval"], [use_blas=])
     4748
     4749#if user specified --with-blas-lib, then we should give COIN_HAS_PACKAGE preference
     4750AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
     4751
     4752# Check if user supplied option makes sense
     4753if test x"$use_blas" != x; then
     4754  if test "$use_blas" = "BUILD"; then
     4755    # we come to this later
     4756    :
     4757  elif test "$use_blas" != "no"; then
     4758    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
     4759    coin_save_LIBS="$LIBS"
     4760    LIBS="$use_blas $LIBS"
     4761    AC_COIN_TRY_FLINK([daxpy],
     4762                      [AC_MSG_RESULT([yes])],
     4763                      [AC_MSG_RESULT([no])
     4764                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
     4765    LIBS="$coin_save_LIBS"
     4766  fi
     4767else
     4768# Try to autodetect the library for blas based on build system
     4769  #AC_MSG_CHECKING([default locations for BLAS])
     4770  skip_lblas_check=no
     4771  case $build in
     4772    *-sgi-*)
     4773      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
     4774      coin_save_LIBS="$LIBS"
     4775      LIBS="-lcomplib.sgimath $LIBS"
     4776      AC_COIN_TRY_FLINK([daxpy],
     4777                        [AC_MSG_RESULT([yes])
     4778                         use_blas="-lcomplib.sgimath"],
     4779                        [AC_MSG_RESULT([no])])
     4780      LIBS="$coin_save_LIBS"
     4781      ;;
     4782
     4783# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
     4784# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
     4785# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
     4786# that CC and cc will understand -library in Studio 13. The main extra
     4787# function of -xlic_lib and -library is to arrange for the Fortran run-time
     4788# libraries to be linked for C++ and C. We can arrange that explicitly.
     4789    *-*-solaris*)
     4790      AC_MSG_CHECKING([for BLAS in libsunperf])
     4791      coin_save_LIBS="$LIBS"
     4792      LIBS="-lsunperf $FLIBS $LIBS"
     4793      AC_COIN_TRY_FLINK([daxpy],
     4794                        [AC_MSG_RESULT([yes])
     4795                         use_blas='-lsunperf'
     4796                         coin_need_flibs=yes],
     4797                        [AC_MSG_RESULT([no])])
     4798      LIBS="$coin_save_LIBS"
     4799      ;;
     4800    *-cygwin* | *-mingw*)
     4801# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
     4802# library will want to link with cygwin, hence won't run standalone in DOS.
     4803      if test "$enable_doscompile" = mingw; then
     4804        skip_lblas_check=yes
     4805      fi
     4806      case "$CC" in
     4807        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
     4808          AC_MSG_CHECKING([for BLAS in MKL])
     4809          coin_save_LIBS="$LIBS"
     4810          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
     4811          AC_COIN_TRY_FLINK([daxpy],
     4812                            [AC_MSG_RESULT([yes])
     4813                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'],
     4814                            [AC_MSG_RESULT([no])])
     4815          LIBS="$coin_save_LIBS"
     4816          ;;
     4817      esac
     4818      ;;
     4819  esac
     4820
     4821  if test -z "$use_blas" && test $skip_lblas_check = no; then
     4822    AC_MSG_CHECKING([whether -lblas has BLAS])
     4823    coin_save_LIBS="$LIBS"
     4824    LIBS="-lblas $LIBS"
     4825    AC_COIN_TRY_FLINK([daxpy],
     4826                      [AC_MSG_RESULT([yes])
     4827                       use_blas='-lblas'],
     4828                      [AC_MSG_RESULT([no])])
     4829    LIBS="$coin_save_LIBS"
     4830  fi
     4831 
     4832  # If we have no other ideas, consider building BLAS.
     4833  if test -z "$use_blas" ; then
     4834    use_blas=BUILD
     4835  fi
     4836fi
     4837
     4838if test "x$use_blas" = xBUILD ; then
     4839  AC_COIN_HAS_PACKAGE(Blas, [coinblas], [$1])
     4840 
     4841elif test "x$use_blas" != x && test "$use_blas" != no; then
     4842  coin_has_blas=yes
     4843  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
     4844  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
     4845  BLAS_LIBS="$use_blas"
     4846  BLAS_CFLAGS=
     4847  BLAS_DATA=
     4848  AC_SUBST(BLAS_LIBS)
     4849  AC_SUBST(BLAS_CFLAGS)
     4850  AC_SUBST(BLAS_DATA)
     4851  coin_foreach_w([myvar], [$1], [
     4852    m4_toupper(myvar)_PCLIBS="$BLAS_LIBS $m4_toupper(myvar)_PCLIBS"
     4853    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
     4854  ])
     4855 
     4856else
     4857  coin_has_blas=no
     4858  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
     4859fi
     4860
     4861coin_foreach_w([myvar], [$1], [
     4862  AC_SUBST(m4_toupper(myvar)_PCLIBS)
     4863  AC_SUBST(m4_toupper(myvar)_LIBS)
     4864])
     4865
     4866]) # AC_COIN_HAS_PACKAGE_BLAS
     4867
     4868###########################################################################
     4869#                       COIN_HAS_PACKAGE_LAPACK                           #
     4870###########################################################################
     4871
     4872# This macro checks for a library containing the LAPACK library.  It
     4873# 1. checks the --with-lapack argument
     4874# 2. if --with-lapack=BUILD has been specified goes to point 5
     4875# 3. if --with-lapack has been specified to a working library, sets LAPACK_LIBS to its value
     4876# 4. tries standard libraries
     4877# 5. calls COIN_HAS_PACKAGE(Lapack, [lapack], [$1]) to check for ThirdParty/Lapack
     4878# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
     4879# LAPACK_LIBS is set to the flags required to link with a Lapack library.
     4880# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
     4881# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
     4882# In case 5, Lapack is added to X_PCREQUIRES.
     4883
     4884AC_DEFUN([AC_COIN_HAS_PACKAGE_LAPACK],
     4885[
     4886AC_ARG_WITH([lapack],
     4887            AC_HELP_STRING([--with-lapack],
     4888                           [specify LAPACK library (or BUILD for compilation)]),
     4889            [use_lapack=$withval], [use_lapack=])
     4890           
     4891#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
     4892AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
     4893
     4894# Check if user supplied option makes sense
     4895if test x"$use_lapack" != x; then
     4896  if test "$use_lapack" = "BUILD"; then
     4897    # we come to this later
     4898    :
     4899  elif test "$use_lapack" != no; then
     4900    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
     4901    coin_save_LIBS="$LIBS"
     4902    LIBS="$use_lapack $LIBS"
     4903    AC_COIN_TRY_FLINK([dsyev],
     4904                      [AC_MSG_RESULT([yes])],
     4905                      [AC_MSG_RESULT([no])
     4906                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
     4907    LIBS="$coin_save_LIBS"
     4908  fi
     4909else
     4910  if test x$coin_has_blas = xyes; then
     4911    # First try to see if LAPACK is already available with BLAS library
     4912    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
     4913    coin_save_LIBS="$LIBS"
     4914    LIBS="$BLAS_LIBS $LIBS"
     4915    AC_COIN_TRY_FLINK([dsyev],
     4916                      [AC_MSG_RESULT([yes]); use_lapack="$BLAS_LIBS"],
     4917                      [AC_MSG_RESULT([no])])
     4918    LIBS="$coin_save_LIBS"
     4919  fi
     4920  skip_llapack_check=no
     4921  if test -z "$use_lapack"; then
     4922    # Try to autodetect the library for lapack based on build system
     4923    case $build in
     4924      *-sgi-*)
     4925        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
     4926        coin_save_LIBS="$LIBS"
     4927        LIBS="-lcomplib.sgimath $LIBS"
     4928        AC_COIN_TRY_FLINK([dsyev],
     4929                          [AC_MSG_RESULT([yes])
     4930                           use_lapack="-lcomplib.sgimath;"],
     4931                          [AC_MSG_RESULT([no])])
     4932        LIBS="$coin_save_LIBS"
     4933        ;;
     4934
     4935      # See comments in COIN_HAS_BLAS.
     4936      *-*-solaris*)
     4937        AC_MSG_CHECKING([for LAPACK in libsunperf])
     4938        coin_save_LIBS="$LIBS"
     4939        LIBS="-lsunperf $FLIBS $LIBS"
     4940        AC_COIN_TRY_FLINK([dsyev],
     4941                          [AC_MSG_RESULT([yes])
     4942                           use_lapack='-lsunperf'
     4943                           coin_need_flibs=yes],
     4944                          [AC_MSG_RESULT([no])])
     4945        LIBS="$coin_save_LIBS"
     4946        ;;
     4947        # On cygwin, do this check only if doscompile is disabled. The prebuilt library
     4948        # will want to link with cygwin, hence won't run standalone in DOS.
     4949      *-cygwin*)
     4950        if test "$enable_doscompile" = mingw; then
     4951          skip_llapack_check=yes
     4952        fi
     4953        ;;
     4954    esac
     4955  fi
     4956
     4957  if test -z "$use_lapack" && test $skip_llapack_check = no; then
     4958    AC_MSG_CHECKING([whether -llapack has LAPACK])
     4959    coin_save_LIBS="$LIBS"
     4960    LIBS="-llapack $LIBS"
     4961    AC_COIN_TRY_FLINK([dsyev],
     4962                      [AC_MSG_RESULT([yes])
     4963                       use_lapack='-llapack'],
     4964                      [AC_MSG_RESULT([no])])
     4965    LIBS="$coin_save_LIBS"
     4966  fi
     4967
     4968  # If we have no other ideas, consider building LAPACK.
     4969  if test -z "$use_lapack" ; then
     4970    use_lapack=BUILD
     4971  fi
     4972fi
     4973
     4974if test "x$use_lapack" = xBUILD ; then
     4975  AC_COIN_HAS_PACKAGE(Lapack, [coinlapack], [$1])
     4976 
     4977elif test "x$use_lapack" != x && test "$use_lapack" != no; then
     4978  coin_has_lapack=yes
     4979  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
     4980  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
     4981  LAPACK_LIBS="$use_lapack"
     4982  LAPACK_CFLAGS=
     4983  LAPACK_DATA=
     4984  AC_SUBST(LAPACK_LIBS)
     4985  AC_SUBST(LAPACK_CFLAGS)
     4986  AC_SUBST(LAPACK_DATA)
     4987  coin_foreach_w([myvar], [$1], [
     4988    m4_toupper(myvar)_PCLIBS="$LAPACK_LIBS $m4_toupper(myvar)_PCLIBS"
     4989    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
     4990  ])
     4991 
     4992else
     4993  coin_has_lapack=no
     4994  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
     4995fi
     4996
     4997coin_foreach_w([myvar], [$1], [
     4998  AC_SUBST(m4_toupper(myvar)_PCLIBS)
     4999  AC_SUBST(m4_toupper(myvar)_LIBS)
     5000])
     5001
     5002]) # AC_COIN_HAS_PACKAGE_LAPACK
Note: See TracChangeset for help on using the changeset viewer.