m4/lx_check_glpk.m4
author Balazs Dezso <deba@inf.elte.hu>
Mon, 16 Jun 2008 18:19:07 +0200
changeset 172 c94a80f38d7f
child 187 84c2a2e5cfee
permissions -rw-r--r--
Clarifying the usage of skipSection
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
ladanyi@1
    45
      int main(int argc, char* argv[])
ladanyi@1
    46
      {
ladanyi@1
    47
        LPX *lp;
ladanyi@1
    48
        lp = lpx_create_prob();
ladanyi@1
    49
        lpx_delete_prob(lp);
ladanyi@1
    50
        return 0;
ladanyi@1
    51
      }'
ladanyi@1
    52
ladanyi@1
    53
    AC_LANG_PUSH(C++)
ladanyi@1
    54
    AC_LINK_IFELSE([$lx_glpk_test_prog], [lx_glpk_found=yes], [lx_glpk_found=no])
ladanyi@1
    55
    AC_LANG_POP(C++)
ladanyi@1
    56
ladanyi@1
    57
    CXXFLAGS="$lx_save_cxxflags"
ladanyi@1
    58
    LDFLAGS="$lx_save_ldflags"
ladanyi@1
    59
    LIBS="$lx_save_libs"
ladanyi@1
    60
ladanyi@1
    61
    if test x"$lx_glpk_found" = x"yes"; then
ladanyi@1
    62
      AC_DEFINE([HAVE_GLPK], [1], [Define to 1 if you have GLPK.])
ladanyi@1
    63
      AC_MSG_RESULT([yes])
ladanyi@1
    64
    else
ladanyi@1
    65
      GLPK_CFLAGS=""
ladanyi@1
    66
      GLPK_LDFLAGS=""
ladanyi@1
    67
      GLPK_LIBS=""
ladanyi@1
    68
      AC_MSG_RESULT([no])
ladanyi@1
    69
    fi
ladanyi@1
    70
  fi
ladanyi@1
    71
  GLPK_LIBS="$GLPK_LDFLAGS $GLPK_LIBS"
ladanyi@1
    72
  AC_SUBST(GLPK_CFLAGS)
ladanyi@1
    73
  AC_SUBST(GLPK_LIBS)
ladanyi@1
    74
  AM_CONDITIONAL([HAVE_GLPK], [test x"$lx_glpk_found" = x"yes"])
ladanyi@1
    75
])