AC_DEFUN([LX_CHECK_GLPK],
AS_HELP_STRING([--with-glpk@<:@=PREFIX@:>@], [search for GLPK under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
AS_HELP_STRING([--without-glpk], [disable checking for GLPK]),
AC_ARG_WITH([glpk-includedir],
AS_HELP_STRING([--with-glpk-includedir=DIR], [search for GLPK headers in DIR]),
[], [with_glpk_includedir=no])
AC_ARG_WITH([glpk-libdir],
AS_HELP_STRING([--with-glpk-libdir=DIR], [search for GLPK libraries in DIR]),
[], [with_glpk_libdir=no])
if test x"$with_glpk" != x"no"; then
AC_MSG_CHECKING([for GLPK])
if test x"$with_glpk_includedir" != x"no"; then
GLPK_CFLAGS="-I$with_glpk_includedir"
elif test x"$with_glpk" != x"yes"; then
GLPK_CFLAGS="-I$with_glpk/include"
if test x"$with_glpk_libdir" != x"no"; then
GLPK_LDFLAGS="-L$with_glpk_libdir"
elif test x"$with_glpk" != x"yes"; then
GLPK_LDFLAGS="-L$with_glpk/lib"
lx_save_cxxflags="$CXXFLAGS"
lx_save_ldflags="$LDFLAGS"
int main(int argc, char** argv)
AC_LINK_IFELSE([$lx_glpk_test_prog], [lx_glpk_found=yes], [lx_glpk_found=no])
CXXFLAGS="$lx_save_cxxflags"
LDFLAGS="$lx_save_ldflags"
if test x"$lx_glpk_found" = x"yes"; then
AC_DEFINE([HAVE_GLPK], [1], [Define to 1 if you have GLPK.])
GLPK_LIBS="$GLPK_LDFLAGS $GLPK_LIBS"
AM_CONDITIONAL([HAVE_GLPK], [test x"$lx_glpk_found" = x"yes"])