m4/lx_check_coin.m4
author Alpar Juttner <alpar@cs.elte.hu>
Tue, 20 Dec 2011 17:35:45 +0100
changeset 1102 17e36e175725
parent 674 20dac2104519
permissions -rw-r--r--
Merge
ladanyi@615
     1
AC_DEFUN([LX_CHECK_COIN],
ladanyi@615
     2
[
ladanyi@615
     3
  AC_ARG_WITH([coin],
ladanyi@615
     4
AS_HELP_STRING([--with-coin@<:@=PREFIX@:>@], [search for CLP under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
ladanyi@615
     5
AS_HELP_STRING([--without-coin], [disable checking for CLP]),
ladanyi@615
     6
              [], [with_coin=yes])
ladanyi@615
     7
ladanyi@615
     8
  AC_ARG_WITH([coin-includedir],
ladanyi@615
     9
AS_HELP_STRING([--with-coin-includedir=DIR], [search for CLP headers in DIR]),
ladanyi@615
    10
              [], [with_coin_includedir=no])
ladanyi@615
    11
ladanyi@615
    12
  AC_ARG_WITH([coin-libdir],
ladanyi@615
    13
AS_HELP_STRING([--with-coin-libdir=DIR], [search for CLP libraries in DIR]),
ladanyi@615
    14
              [], [with_coin_libdir=no])
ladanyi@615
    15
ladanyi@615
    16
  lx_clp_found=no
ladanyi@615
    17
  if test x"$with_coin" != x"no"; then
ladanyi@615
    18
    AC_MSG_CHECKING([for CLP])
ladanyi@615
    19
ladanyi@615
    20
    if test x"$with_coin_includedir" != x"no"; then
ladanyi@615
    21
      CLP_CXXFLAGS="-I$with_coin_includedir"
ladanyi@615
    22
    elif test x"$with_coin" != x"yes"; then
ladanyi@615
    23
      CLP_CXXFLAGS="-I$with_coin/include"
ladanyi@615
    24
    fi
ladanyi@615
    25
ladanyi@615
    26
    if test x"$with_coin_libdir" != x"no"; then
ladanyi@615
    27
      CLP_LDFLAGS="-L$with_coin_libdir"
ladanyi@615
    28
    elif test x"$with_coin" != x"yes"; then
ladanyi@615
    29
      CLP_LDFLAGS="-L$with_coin/lib"
ladanyi@615
    30
    fi
ladanyi@615
    31
    CLP_LIBS="-lClp -lCoinUtils -lm"
ladanyi@615
    32
ladanyi@615
    33
    lx_save_cxxflags="$CXXFLAGS"
ladanyi@615
    34
    lx_save_ldflags="$LDFLAGS"
ladanyi@615
    35
    lx_save_libs="$LIBS"
ladanyi@615
    36
    CXXFLAGS="$CLP_CXXFLAGS"
ladanyi@615
    37
    LDFLAGS="$CLP_LDFLAGS"
ladanyi@615
    38
    LIBS="$CLP_LIBS"
ladanyi@615
    39
ladanyi@615
    40
    lx_clp_test_prog='
ladanyi@615
    41
      #include <coin/ClpModel.hpp>
ladanyi@615
    42
ladanyi@615
    43
      int main(int argc, char** argv)
ladanyi@615
    44
      {
ladanyi@615
    45
        ClpModel clp;
ladanyi@615
    46
        return 0;
ladanyi@615
    47
      }'
ladanyi@615
    48
ladanyi@615
    49
    AC_LANG_PUSH(C++)
ladanyi@615
    50
    AC_LINK_IFELSE([$lx_clp_test_prog], [lx_clp_found=yes], [lx_clp_found=no])
ladanyi@615
    51
    AC_LANG_POP(C++)
ladanyi@615
    52
ladanyi@615
    53
    CXXFLAGS="$lx_save_cxxflags"
ladanyi@615
    54
    LDFLAGS="$lx_save_ldflags"
ladanyi@615
    55
    LIBS="$lx_save_libs"
ladanyi@615
    56
ladanyi@615
    57
    if test x"$lx_clp_found" = x"yes"; then
ladanyi@674
    58
      AC_DEFINE([LEMON_HAVE_CLP], [1], [Define to 1 if you have CLP.])
ladanyi@615
    59
      lx_lp_found=yes
ladanyi@674
    60
      AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.])
ladanyi@615
    61
      AC_MSG_RESULT([yes])
ladanyi@615
    62
    else
ladanyi@615
    63
      CLP_CXXFLAGS=""
ladanyi@615
    64
      CLP_LDFLAGS=""
ladanyi@615
    65
      CLP_LIBS=""
ladanyi@615
    66
      AC_MSG_RESULT([no])
ladanyi@615
    67
    fi
ladanyi@615
    68
  fi
ladanyi@615
    69
  CLP_LIBS="$CLP_LDFLAGS $CLP_LIBS"
ladanyi@615
    70
  AC_SUBST(CLP_CXXFLAGS)
ladanyi@615
    71
  AC_SUBST(CLP_LIBS)
ladanyi@615
    72
  AM_CONDITIONAL([HAVE_CLP], [test x"$lx_clp_found" = x"yes"])
ladanyi@615
    73
ladanyi@615
    74
ladanyi@615
    75
  lx_cbc_found=no
ladanyi@615
    76
  if test x"$lx_clp_found" = x"yes"; then
ladanyi@615
    77
    if test x"$with_coin" != x"no"; then
ladanyi@615
    78
      AC_MSG_CHECKING([for CBC])
ladanyi@615
    79
ladanyi@615
    80
      if test x"$with_coin_includedir" != x"no"; then
ladanyi@615
    81
        CBC_CXXFLAGS="-I$with_coin_includedir"
ladanyi@615
    82
      elif test x"$with_coin" != x"yes"; then
ladanyi@615
    83
        CBC_CXXFLAGS="-I$with_coin/include"
ladanyi@615
    84
      fi
ladanyi@615
    85
ladanyi@615
    86
      if test x"$with_coin_libdir" != x"no"; then
ladanyi@615
    87
        CBC_LDFLAGS="-L$with_coin_libdir"
ladanyi@615
    88
      elif test x"$with_coin" != x"yes"; then
ladanyi@615
    89
        CBC_LDFLAGS="-L$with_coin/lib"
ladanyi@615
    90
      fi
deba@796
    91
      CBC_LIBS="-lOsi -lCbc -lCbcSolver -lClp -lOsiClp -lCoinUtils -lVol -lOsiVol -lCgl -lm -llapack -lblas"
ladanyi@615
    92
ladanyi@615
    93
      lx_save_cxxflags="$CXXFLAGS"
ladanyi@615
    94
      lx_save_ldflags="$LDFLAGS"
ladanyi@615
    95
      lx_save_libs="$LIBS"
ladanyi@615
    96
      CXXFLAGS="$CBC_CXXFLAGS"
ladanyi@615
    97
      LDFLAGS="$CBC_LDFLAGS"
ladanyi@615
    98
      LIBS="$CBC_LIBS"
ladanyi@615
    99
ladanyi@615
   100
      lx_cbc_test_prog='
ladanyi@615
   101
        #include <coin/CbcModel.hpp>
ladanyi@615
   102
ladanyi@615
   103
        int main(int argc, char** argv)
ladanyi@615
   104
        {
ladanyi@615
   105
          CbcModel cbc;
ladanyi@615
   106
          return 0;
ladanyi@615
   107
        }'
ladanyi@615
   108
ladanyi@615
   109
      AC_LANG_PUSH(C++)
ladanyi@615
   110
      AC_LINK_IFELSE([$lx_cbc_test_prog], [lx_cbc_found=yes], [lx_cbc_found=no])
ladanyi@615
   111
      AC_LANG_POP(C++)
ladanyi@615
   112
ladanyi@615
   113
      CXXFLAGS="$lx_save_cxxflags"
ladanyi@615
   114
      LDFLAGS="$lx_save_ldflags"
ladanyi@615
   115
      LIBS="$lx_save_libs"
ladanyi@615
   116
ladanyi@615
   117
      if test x"$lx_cbc_found" = x"yes"; then
ladanyi@674
   118
        AC_DEFINE([LEMON_HAVE_CBC], [1], [Define to 1 if you have CBC.])
ladanyi@615
   119
        lx_lp_found=yes
ladanyi@674
   120
        AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.])
ladanyi@615
   121
        lx_mip_found=yes
ladanyi@674
   122
        AC_DEFINE([LEMON_HAVE_MIP], [1], [Define to 1 if you have any MIP solver.])
ladanyi@615
   123
        AC_MSG_RESULT([yes])
ladanyi@615
   124
      else
ladanyi@615
   125
        CBC_CXXFLAGS=""
ladanyi@615
   126
        CBC_LDFLAGS=""
ladanyi@615
   127
        CBC_LIBS=""
ladanyi@615
   128
        AC_MSG_RESULT([no])
ladanyi@615
   129
      fi
ladanyi@615
   130
    fi
ladanyi@615
   131
  fi
ladanyi@615
   132
  CBC_LIBS="$CBC_LDFLAGS $CBC_LIBS"
ladanyi@615
   133
  AC_SUBST(CBC_CXXFLAGS)
ladanyi@615
   134
  AC_SUBST(CBC_LIBS)
ladanyi@615
   135
  AM_CONDITIONAL([HAVE_CBC], [test x"$lx_cbc_found" = x"yes"])
ladanyi@615
   136
])