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