m4/lx_check_coin.m4
changeset 784 1a7fe3bef514
parent 627 20dac2104519
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/m4/lx_check_coin.m4	Thu Nov 05 15:50:01 2009 +0100
     1.3 @@ -0,0 +1,136 @@
     1.4 +AC_DEFUN([LX_CHECK_COIN],
     1.5 +[
     1.6 +  AC_ARG_WITH([coin],
     1.7 +AS_HELP_STRING([--with-coin@<:@=PREFIX@:>@], [search for CLP under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
     1.8 +AS_HELP_STRING([--without-coin], [disable checking for CLP]),
     1.9 +              [], [with_coin=yes])
    1.10 +
    1.11 +  AC_ARG_WITH([coin-includedir],
    1.12 +AS_HELP_STRING([--with-coin-includedir=DIR], [search for CLP headers in DIR]),
    1.13 +              [], [with_coin_includedir=no])
    1.14 +
    1.15 +  AC_ARG_WITH([coin-libdir],
    1.16 +AS_HELP_STRING([--with-coin-libdir=DIR], [search for CLP libraries in DIR]),
    1.17 +              [], [with_coin_libdir=no])
    1.18 +
    1.19 +  lx_clp_found=no
    1.20 +  if test x"$with_coin" != x"no"; then
    1.21 +    AC_MSG_CHECKING([for CLP])
    1.22 +
    1.23 +    if test x"$with_coin_includedir" != x"no"; then
    1.24 +      CLP_CXXFLAGS="-I$with_coin_includedir"
    1.25 +    elif test x"$with_coin" != x"yes"; then
    1.26 +      CLP_CXXFLAGS="-I$with_coin/include"
    1.27 +    fi
    1.28 +
    1.29 +    if test x"$with_coin_libdir" != x"no"; then
    1.30 +      CLP_LDFLAGS="-L$with_coin_libdir"
    1.31 +    elif test x"$with_coin" != x"yes"; then
    1.32 +      CLP_LDFLAGS="-L$with_coin/lib"
    1.33 +    fi
    1.34 +    CLP_LIBS="-lClp -lCoinUtils -lm"
    1.35 +
    1.36 +    lx_save_cxxflags="$CXXFLAGS"
    1.37 +    lx_save_ldflags="$LDFLAGS"
    1.38 +    lx_save_libs="$LIBS"
    1.39 +    CXXFLAGS="$CLP_CXXFLAGS"
    1.40 +    LDFLAGS="$CLP_LDFLAGS"
    1.41 +    LIBS="$CLP_LIBS"
    1.42 +
    1.43 +    lx_clp_test_prog='
    1.44 +      #include <coin/ClpModel.hpp>
    1.45 +
    1.46 +      int main(int argc, char** argv)
    1.47 +      {
    1.48 +        ClpModel clp;
    1.49 +        return 0;
    1.50 +      }'
    1.51 +
    1.52 +    AC_LANG_PUSH(C++)
    1.53 +    AC_LINK_IFELSE([$lx_clp_test_prog], [lx_clp_found=yes], [lx_clp_found=no])
    1.54 +    AC_LANG_POP(C++)
    1.55 +
    1.56 +    CXXFLAGS="$lx_save_cxxflags"
    1.57 +    LDFLAGS="$lx_save_ldflags"
    1.58 +    LIBS="$lx_save_libs"
    1.59 +
    1.60 +    if test x"$lx_clp_found" = x"yes"; then
    1.61 +      AC_DEFINE([LEMON_HAVE_CLP], [1], [Define to 1 if you have CLP.])
    1.62 +      lx_lp_found=yes
    1.63 +      AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.])
    1.64 +      AC_MSG_RESULT([yes])
    1.65 +    else
    1.66 +      CLP_CXXFLAGS=""
    1.67 +      CLP_LDFLAGS=""
    1.68 +      CLP_LIBS=""
    1.69 +      AC_MSG_RESULT([no])
    1.70 +    fi
    1.71 +  fi
    1.72 +  CLP_LIBS="$CLP_LDFLAGS $CLP_LIBS"
    1.73 +  AC_SUBST(CLP_CXXFLAGS)
    1.74 +  AC_SUBST(CLP_LIBS)
    1.75 +  AM_CONDITIONAL([HAVE_CLP], [test x"$lx_clp_found" = x"yes"])
    1.76 +
    1.77 +
    1.78 +  lx_cbc_found=no
    1.79 +  if test x"$lx_clp_found" = x"yes"; then
    1.80 +    if test x"$with_coin" != x"no"; then
    1.81 +      AC_MSG_CHECKING([for CBC])
    1.82 +
    1.83 +      if test x"$with_coin_includedir" != x"no"; then
    1.84 +        CBC_CXXFLAGS="-I$with_coin_includedir"
    1.85 +      elif test x"$with_coin" != x"yes"; then
    1.86 +        CBC_CXXFLAGS="-I$with_coin/include"
    1.87 +      fi
    1.88 +
    1.89 +      if test x"$with_coin_libdir" != x"no"; then
    1.90 +        CBC_LDFLAGS="-L$with_coin_libdir"
    1.91 +      elif test x"$with_coin" != x"yes"; then
    1.92 +        CBC_LDFLAGS="-L$with_coin/lib"
    1.93 +      fi
    1.94 +      CBC_LIBS="-lOsi -lCbc -lCbcSolver -lClp -lOsiClp -lCoinUtils -lVol -lOsiVol -lCgl -lm -llapack -lblas"
    1.95 +
    1.96 +      lx_save_cxxflags="$CXXFLAGS"
    1.97 +      lx_save_ldflags="$LDFLAGS"
    1.98 +      lx_save_libs="$LIBS"
    1.99 +      CXXFLAGS="$CBC_CXXFLAGS"
   1.100 +      LDFLAGS="$CBC_LDFLAGS"
   1.101 +      LIBS="$CBC_LIBS"
   1.102 +
   1.103 +      lx_cbc_test_prog='
   1.104 +        #include <coin/CbcModel.hpp>
   1.105 +
   1.106 +        int main(int argc, char** argv)
   1.107 +        {
   1.108 +          CbcModel cbc;
   1.109 +          return 0;
   1.110 +        }'
   1.111 +
   1.112 +      AC_LANG_PUSH(C++)
   1.113 +      AC_LINK_IFELSE([$lx_cbc_test_prog], [lx_cbc_found=yes], [lx_cbc_found=no])
   1.114 +      AC_LANG_POP(C++)
   1.115 +
   1.116 +      CXXFLAGS="$lx_save_cxxflags"
   1.117 +      LDFLAGS="$lx_save_ldflags"
   1.118 +      LIBS="$lx_save_libs"
   1.119 +
   1.120 +      if test x"$lx_cbc_found" = x"yes"; then
   1.121 +        AC_DEFINE([LEMON_HAVE_CBC], [1], [Define to 1 if you have CBC.])
   1.122 +        lx_lp_found=yes
   1.123 +        AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.])
   1.124 +        lx_mip_found=yes
   1.125 +        AC_DEFINE([LEMON_HAVE_MIP], [1], [Define to 1 if you have any MIP solver.])
   1.126 +        AC_MSG_RESULT([yes])
   1.127 +      else
   1.128 +        CBC_CXXFLAGS=""
   1.129 +        CBC_LDFLAGS=""
   1.130 +        CBC_LIBS=""
   1.131 +        AC_MSG_RESULT([no])
   1.132 +      fi
   1.133 +    fi
   1.134 +  fi
   1.135 +  CBC_LIBS="$CBC_LDFLAGS $CBC_LIBS"
   1.136 +  AC_SUBST(CBC_CXXFLAGS)
   1.137 +  AC_SUBST(CBC_LIBS)
   1.138 +  AM_CONDITIONAL([HAVE_CBC], [test x"$lx_cbc_found" = x"yes"])
   1.139 +])