Backport relevant parts of bugfixes [ad22262328b3], [61fdd06833a6] and [4add05447ca0] to branch 1.2 (#623)
1 AC_DEFUN([LX_CHECK_GLPK],
4 AS_HELP_STRING([--with-glpk@<:@=PREFIX@:>@], [search for GLPK under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
5 AS_HELP_STRING([--without-glpk], [disable checking for GLPK]),
8 AC_ARG_WITH([glpk-includedir],
9 AS_HELP_STRING([--with-glpk-includedir=DIR], [search for GLPK headers in DIR]),
10 [], [with_glpk_includedir=no])
12 AC_ARG_WITH([glpk-libdir],
13 AS_HELP_STRING([--with-glpk-libdir=DIR], [search for GLPK libraries in DIR]),
14 [], [with_glpk_libdir=no])
17 if test x"$with_glpk" != x"no"; then
18 AC_MSG_CHECKING([for GLPK])
20 if test x"$with_glpk_includedir" != x"no"; then
21 GLPK_CFLAGS="-I$with_glpk_includedir"
22 elif test x"$with_glpk" != x"yes"; then
23 GLPK_CFLAGS="-I$with_glpk/include"
26 if test x"$with_glpk_libdir" != x"no"; then
27 GLPK_LDFLAGS="-L$with_glpk_libdir"
28 elif test x"$with_glpk" != x"yes"; then
29 GLPK_LDFLAGS="-L$with_glpk/lib"
33 lx_save_cxxflags="$CXXFLAGS"
34 lx_save_ldflags="$LDFLAGS"
36 CXXFLAGS="$GLPK_CFLAGS"
37 LDFLAGS="$GLPK_LDFLAGS"
45 #if (GLP_MAJOR_VERSION < 4) \
46 || (GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION < 33)
47 #error Supported GLPK versions: 4.33 or above
50 int main(int argc, char** argv)
53 lp = lpx_create_prob();
59 AC_LINK_IFELSE([$lx_glpk_test_prog], [lx_glpk_found=yes], [lx_glpk_found=no])
62 CXXFLAGS="$lx_save_cxxflags"
63 LDFLAGS="$lx_save_ldflags"
66 if test x"$lx_glpk_found" = x"yes"; then
67 AC_DEFINE([LEMON_HAVE_GLPK], [1], [Define to 1 if you have GLPK.])
69 AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.])
71 AC_DEFINE([LEMON_HAVE_MIP], [1], [Define to 1 if you have any MIP solver.])
80 GLPK_LIBS="$GLPK_LDFLAGS $GLPK_LIBS"
83 AM_CONDITIONAL([HAVE_GLPK], [test x"$lx_glpk_found" = x"yes"])