config/lp.m4
author ladanyi
Thu, 14 Apr 2005 12:02:14 +0000
changeset 1349 83388a4aa3af
child 1355 57936f15055b
permissions -rw-r--r--
- GLPK is autodetected now
ladanyi@1349
     1
AC_DEFUN([LX_CHECK_GLPK],
ladanyi@1349
     2
[
ladanyi@1349
     3
  AC_ARG_WITH([glpk],
ladanyi@1349
     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@1349
     5
AS_HELP_STRING([--without-glpk], [Disable checking for GLPK]),
ladanyi@1349
     6
              [], [with_glpk=yes])
ladanyi@1349
     7
ladanyi@1349
     8
  AC_ARG_WITH([glpk-includedir],
ladanyi@1349
     9
AS_HELP_STRING([--with-glpk-includedir=DIR], [Search for GLPK headers in DIR]),
ladanyi@1349
    10
              [], [with_glpk_includedir=no])
ladanyi@1349
    11
ladanyi@1349
    12
  AC_ARG_WITH([glpk-libdir],
ladanyi@1349
    13
AS_HELP_STRING([--with-glpk-libdir=DIR], [Search for GLPK libraries in DIR]),
ladanyi@1349
    14
              [], [with_glpk_libdir=no])
ladanyi@1349
    15
ladanyi@1349
    16
  if test x"$with_glpk" != x"no"; then
ladanyi@1349
    17
    AC_MSG_CHECKING([for GLPK])
ladanyi@1349
    18
ladanyi@1349
    19
    if test x"$with_glpk_includedir" != x"no"; then
ladanyi@1349
    20
      GLPK_CFLAGS="-I$with_glpk_includedir"
ladanyi@1349
    21
    elif test x"$with_glpk" != x"yes"; then
ladanyi@1349
    22
      GLPK_CFLAGS="-I$with_glpk/include"
ladanyi@1349
    23
    fi
ladanyi@1349
    24
ladanyi@1349
    25
    if test x"$with_glpk_libdir" != x"no"; then
ladanyi@1349
    26
      GLPK_LDFLAGS="-L$with_glpk_libdir"
ladanyi@1349
    27
    elif test x"$with_glpk" != x"yes"; then
ladanyi@1349
    28
      GLPK_LDFLAGS="-L$with_glpk/lib"
ladanyi@1349
    29
    fi
ladanyi@1349
    30
    GLPK_LIBS="-lglpk"
ladanyi@1349
    31
ladanyi@1349
    32
    lx_save_cxxflags="$CXXFLAGS";
ladanyi@1349
    33
    lx_save_ldflags="$LDFLAGS";
ladanyi@1349
    34
    lx_save_libs="$LIBS";
ladanyi@1349
    35
    CXXFLAGS="$GLPK_CFLAGS"
ladanyi@1349
    36
    LDFLAGS="$GLPK_LDFLAGS"
ladanyi@1349
    37
    LIBS="$GLPK_LIBS"
ladanyi@1349
    38
ladanyi@1349
    39
    lx_glpk_test_prog='
ladanyi@1349
    40
      extern "C" {
ladanyi@1349
    41
      #include <glpk.h>
ladanyi@1349
    42
      }
ladanyi@1349
    43
ladanyi@1349
    44
      int main(int argc, char* argv[])
ladanyi@1349
    45
      {
ladanyi@1349
    46
        LPX *lp;
ladanyi@1349
    47
        lp = lpx_create_prob();
ladanyi@1349
    48
        lpx_delete_prob(lp);
ladanyi@1349
    49
        return 0;
ladanyi@1349
    50
      }'
ladanyi@1349
    51
ladanyi@1349
    52
    AC_LANG_PUSH(C++)
ladanyi@1349
    53
    AC_LINK_IFELSE([$lx_glpk_test_prog], [lx_glpk_found=yes], [])
ladanyi@1349
    54
    AC_LANG_POP(C++)
ladanyi@1349
    55
ladanyi@1349
    56
    CXXFLAGS="$lx_save_cxxflags"
ladanyi@1349
    57
    LDFLAGS="$lx_save_ldflags"
ladanyi@1349
    58
    LIBS="$lx_save_libs"
ladanyi@1349
    59
ladanyi@1349
    60
    if test x"$lx_glpk_found" = x"yes"; then
ladanyi@1349
    61
      AC_DEFINE([HAVE_GLPK], [1], [Define if GLPK was found])
ladanyi@1349
    62
      AC_MSG_RESULT([found])
ladanyi@1349
    63
    else
ladanyi@1349
    64
      AC_MSG_RESULT([not found])
ladanyi@1349
    65
    fi
ladanyi@1349
    66
  fi
ladanyi@1349
    67
  GLPK_LIBS="$GLPK_LDFLAGS $GLPK_LIBS"
ladanyi@1349
    68
  AC_SUBST(GLPK_CFLAGS)
ladanyi@1349
    69
  AC_SUBST(GLPK_LIBS)
ladanyi@1349
    70
  AM_CONDITIONAL([HAVE_GLPK], [test x"$lx_glpk_found" = x"yes"])
ladanyi@1349
    71
])