m4/lx_check_glpk.m4
author Peter Kovacs <kpeter@inf.elte.hu>
Tue, 24 Mar 2009 00:18:25 +0100
changeset 604 8c3112a66878
parent 457 69928a704ffb
child 627 20dac2104519
permissions -rw-r--r--
Use XTI implementation instead of ATI in NetworkSimplex (#234)

XTI (eXtended Threaded Index) is an imporved version of the widely
known ATI (Augmented Threaded Index) method for storing and updating
the spanning tree structure in Network Simplex algorithms.

In the ATI data structure three indices are stored for each node:
predecessor, thread and depth. In the XTI data structure depth is
replaced by the number of successors and the last successor
(according to the thread index).
ladanyi@1
     1
AC_DEFUN([LX_CHECK_GLPK],
ladanyi@1
     2
[
ladanyi@1
     3
  AC_ARG_WITH([glpk],
ladanyi@1
     4
AS_HELP_STRING([--with-glpk@<:@=PREFIX@:>@], [search for GLPK under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
ladanyi@1
     5
AS_HELP_STRING([--without-glpk], [disable checking for GLPK]),
ladanyi@1
     6
              [], [with_glpk=yes])
ladanyi@1
     7
ladanyi@1
     8
  AC_ARG_WITH([glpk-includedir],
ladanyi@1
     9
AS_HELP_STRING([--with-glpk-includedir=DIR], [search for GLPK headers in DIR]),
ladanyi@1
    10
              [], [with_glpk_includedir=no])
ladanyi@1
    11
ladanyi@1
    12
  AC_ARG_WITH([glpk-libdir],
ladanyi@1
    13
AS_HELP_STRING([--with-glpk-libdir=DIR], [search for GLPK libraries in DIR]),
ladanyi@1
    14
              [], [with_glpk_libdir=no])
ladanyi@1
    15
ladanyi@1
    16
  lx_glpk_found=no
ladanyi@1
    17
  if test x"$with_glpk" != x"no"; then
ladanyi@1
    18
    AC_MSG_CHECKING([for GLPK])
ladanyi@1
    19
ladanyi@1
    20
    if test x"$with_glpk_includedir" != x"no"; then
ladanyi@1
    21
      GLPK_CFLAGS="-I$with_glpk_includedir"
ladanyi@1
    22
    elif test x"$with_glpk" != x"yes"; then
ladanyi@1
    23
      GLPK_CFLAGS="-I$with_glpk/include"
ladanyi@1
    24
    fi
ladanyi@1
    25
ladanyi@1
    26
    if test x"$with_glpk_libdir" != x"no"; then
ladanyi@1
    27
      GLPK_LDFLAGS="-L$with_glpk_libdir"
ladanyi@1
    28
    elif test x"$with_glpk" != x"yes"; then
ladanyi@1
    29
      GLPK_LDFLAGS="-L$with_glpk/lib"
ladanyi@1
    30
    fi
ladanyi@1
    31
    GLPK_LIBS="-lglpk"
ladanyi@1
    32
ladanyi@1
    33
    lx_save_cxxflags="$CXXFLAGS"
ladanyi@1
    34
    lx_save_ldflags="$LDFLAGS"
ladanyi@1
    35
    lx_save_libs="$LIBS"
ladanyi@1
    36
    CXXFLAGS="$GLPK_CFLAGS"
ladanyi@1
    37
    LDFLAGS="$GLPK_LDFLAGS"
ladanyi@1
    38
    LIBS="$GLPK_LIBS"
ladanyi@1
    39
ladanyi@1
    40
    lx_glpk_test_prog='
ladanyi@1
    41
      extern "C" {
ladanyi@1
    42
      #include <glpk.h>
ladanyi@1
    43
      }
ladanyi@1
    44
deba@459
    45
      #if (GLP_MAJOR_VERSION < 4) \
deba@459
    46
         || (GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION < 33)
deba@459
    47
      #error Supported GLPK versions: 4.33 or above
deba@459
    48
      #endif
deba@459
    49
ladanyi@187
    50
      int main(int argc, char** argv)
ladanyi@1
    51
      {
ladanyi@1
    52
        LPX *lp;
ladanyi@1
    53
        lp = lpx_create_prob();
ladanyi@1
    54
        lpx_delete_prob(lp);
ladanyi@1
    55
        return 0;
ladanyi@1
    56
      }'
ladanyi@1
    57
ladanyi@1
    58
    AC_LANG_PUSH(C++)
ladanyi@1
    59
    AC_LINK_IFELSE([$lx_glpk_test_prog], [lx_glpk_found=yes], [lx_glpk_found=no])
ladanyi@1
    60
    AC_LANG_POP(C++)
ladanyi@1
    61
ladanyi@1
    62
    CXXFLAGS="$lx_save_cxxflags"
ladanyi@1
    63
    LDFLAGS="$lx_save_ldflags"
ladanyi@1
    64
    LIBS="$lx_save_libs"
ladanyi@1
    65
ladanyi@1
    66
    if test x"$lx_glpk_found" = x"yes"; then
ladanyi@1
    67
      AC_DEFINE([HAVE_GLPK], [1], [Define to 1 if you have GLPK.])
alpar@457
    68
      lx_lp_found=yes
alpar@457
    69
      AC_DEFINE([HAVE_LP], [1], [Define to 1 if you have any LP solver.])
alpar@457
    70
      lx_mip_found=yes
alpar@457
    71
      AC_DEFINE([HAVE_MIP], [1], [Define to 1 if you have any MIP solver.])
ladanyi@1
    72
      AC_MSG_RESULT([yes])
ladanyi@1
    73
    else
ladanyi@1
    74
      GLPK_CFLAGS=""
ladanyi@1
    75
      GLPK_LDFLAGS=""
ladanyi@1
    76
      GLPK_LIBS=""
ladanyi@1
    77
      AC_MSG_RESULT([no])
ladanyi@1
    78
    fi
ladanyi@1
    79
  fi
ladanyi@1
    80
  GLPK_LIBS="$GLPK_LDFLAGS $GLPK_LIBS"
ladanyi@1
    81
  AC_SUBST(GLPK_CFLAGS)
ladanyi@1
    82
  AC_SUBST(GLPK_LIBS)
ladanyi@1
    83
  AM_CONDITIONAL([HAVE_GLPK], [test x"$lx_glpk_found" = x"yes"])
ladanyi@1
    84
])