ladanyi@1: AC_DEFUN([LX_CHECK_GLPK],
ladanyi@1: [
ladanyi@1:   AC_ARG_WITH([glpk],
ladanyi@1: 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: AS_HELP_STRING([--without-glpk], [disable checking for GLPK]),
ladanyi@1:               [], [with_glpk=yes])
ladanyi@1: 
ladanyi@1:   AC_ARG_WITH([glpk-includedir],
ladanyi@1: AS_HELP_STRING([--with-glpk-includedir=DIR], [search for GLPK headers in DIR]),
ladanyi@1:               [], [with_glpk_includedir=no])
ladanyi@1: 
ladanyi@1:   AC_ARG_WITH([glpk-libdir],
ladanyi@1: AS_HELP_STRING([--with-glpk-libdir=DIR], [search for GLPK libraries in DIR]),
ladanyi@1:               [], [with_glpk_libdir=no])
ladanyi@1: 
ladanyi@1:   lx_glpk_found=no
ladanyi@1:   if test x"$with_glpk" != x"no"; then
ladanyi@1:     AC_MSG_CHECKING([for GLPK])
ladanyi@1: 
ladanyi@1:     if test x"$with_glpk_includedir" != x"no"; then
ladanyi@1:       GLPK_CFLAGS="-I$with_glpk_includedir"
ladanyi@1:     elif test x"$with_glpk" != x"yes"; then
ladanyi@1:       GLPK_CFLAGS="-I$with_glpk/include"
ladanyi@1:     fi
ladanyi@1: 
ladanyi@1:     if test x"$with_glpk_libdir" != x"no"; then
ladanyi@1:       GLPK_LDFLAGS="-L$with_glpk_libdir"
ladanyi@1:     elif test x"$with_glpk" != x"yes"; then
ladanyi@1:       GLPK_LDFLAGS="-L$with_glpk/lib"
ladanyi@1:     fi
ladanyi@1:     GLPK_LIBS="-lglpk"
ladanyi@1: 
ladanyi@1:     lx_save_cxxflags="$CXXFLAGS"
ladanyi@1:     lx_save_ldflags="$LDFLAGS"
ladanyi@1:     lx_save_libs="$LIBS"
ladanyi@1:     CXXFLAGS="$GLPK_CFLAGS"
ladanyi@1:     LDFLAGS="$GLPK_LDFLAGS"
ladanyi@1:     LIBS="$GLPK_LIBS"
ladanyi@1: 
ladanyi@1:     lx_glpk_test_prog='
ladanyi@1:       extern "C" {
ladanyi@1:       #include <glpk.h>
ladanyi@1:       }
ladanyi@1: 
deba@459:       #if (GLP_MAJOR_VERSION < 4) \
deba@459:          || (GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION < 33)
deba@459:       #error Supported GLPK versions: 4.33 or above
deba@459:       #endif
deba@459: 
ladanyi@187:       int main(int argc, char** argv)
ladanyi@1:       {
ladanyi@1:         LPX *lp;
ladanyi@1:         lp = lpx_create_prob();
ladanyi@1:         lpx_delete_prob(lp);
ladanyi@1:         return 0;
ladanyi@1:       }'
ladanyi@1: 
ladanyi@1:     AC_LANG_PUSH(C++)
ladanyi@1:     AC_LINK_IFELSE([$lx_glpk_test_prog], [lx_glpk_found=yes], [lx_glpk_found=no])
ladanyi@1:     AC_LANG_POP(C++)
ladanyi@1: 
ladanyi@1:     CXXFLAGS="$lx_save_cxxflags"
ladanyi@1:     LDFLAGS="$lx_save_ldflags"
ladanyi@1:     LIBS="$lx_save_libs"
ladanyi@1: 
ladanyi@1:     if test x"$lx_glpk_found" = x"yes"; then
ladanyi@621:       AC_DEFINE([LEMON_HAVE_GLPK], [1], [Define to 1 if you have GLPK.])
alpar@457:       lx_lp_found=yes
ladanyi@622:       AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.])
alpar@457:       lx_mip_found=yes
ladanyi@622:       AC_DEFINE([LEMON_HAVE_MIP], [1], [Define to 1 if you have any MIP solver.])
ladanyi@1:       AC_MSG_RESULT([yes])
ladanyi@1:     else
ladanyi@1:       GLPK_CFLAGS=""
ladanyi@1:       GLPK_LDFLAGS=""
ladanyi@1:       GLPK_LIBS=""
ladanyi@1:       AC_MSG_RESULT([no])
ladanyi@1:     fi
ladanyi@1:   fi
ladanyi@1:   GLPK_LIBS="$GLPK_LDFLAGS $GLPK_LIBS"
ladanyi@1:   AC_SUBST(GLPK_CFLAGS)
ladanyi@1:   AC_SUBST(GLPK_LIBS)
ladanyi@1:   AM_CONDITIONAL([HAVE_GLPK], [test x"$lx_glpk_found" = x"yes"])
ladanyi@1: ])