config/lp.m4
author ladanyi
Sun, 24 Apr 2005 22:26:37 +0000
changeset 1385 49d1ca28ebd8
parent 1382 2c925c18d130
child 1388 50fc3487af8b
permissions -rw-r--r--
Don't set {GLPK,CPLEX}_{CFLAGS,LIBS} if the check fails.
ladanyi@1349
     1
AC_DEFUN([LX_CHECK_GLPK],
ladanyi@1349
     2
[
ladanyi@1349
     3
  AC_ARG_WITH([glpk],
ladanyi@1369
     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@1369
     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@1369
     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@1369
    13
AS_HELP_STRING([--with-glpk-libdir=DIR], [search for GLPK libraries in DIR]),
ladanyi@1349
    14
              [], [with_glpk_libdir=no])
ladanyi@1349
    15
alpar@1382
    16
  lx_glpk_found=no
ladanyi@1349
    17
  if test x"$with_glpk" != x"no"; then
ladanyi@1349
    18
    AC_MSG_CHECKING([for GLPK])
ladanyi@1349
    19
ladanyi@1349
    20
    if test x"$with_glpk_includedir" != x"no"; then
ladanyi@1349
    21
      GLPK_CFLAGS="-I$with_glpk_includedir"
ladanyi@1349
    22
    elif test x"$with_glpk" != x"yes"; then
ladanyi@1349
    23
      GLPK_CFLAGS="-I$with_glpk/include"
ladanyi@1349
    24
    fi
ladanyi@1349
    25
ladanyi@1349
    26
    if test x"$with_glpk_libdir" != x"no"; then
ladanyi@1349
    27
      GLPK_LDFLAGS="-L$with_glpk_libdir"
ladanyi@1349
    28
    elif test x"$with_glpk" != x"yes"; then
ladanyi@1349
    29
      GLPK_LDFLAGS="-L$with_glpk/lib"
ladanyi@1349
    30
    fi
ladanyi@1349
    31
    GLPK_LIBS="-lglpk"
ladanyi@1349
    32
ladanyi@1385
    33
    lx_save_cxxflags="$CXXFLAGS"
ladanyi@1385
    34
    lx_save_ldflags="$LDFLAGS"
ladanyi@1385
    35
    lx_save_libs="$LIBS"
ladanyi@1349
    36
    CXXFLAGS="$GLPK_CFLAGS"
ladanyi@1349
    37
    LDFLAGS="$GLPK_LDFLAGS"
ladanyi@1349
    38
    LIBS="$GLPK_LIBS"
ladanyi@1349
    39
ladanyi@1349
    40
    lx_glpk_test_prog='
ladanyi@1349
    41
      extern "C" {
ladanyi@1349
    42
      #include <glpk.h>
ladanyi@1349
    43
      }
ladanyi@1349
    44
ladanyi@1349
    45
      int main(int argc, char* argv[])
ladanyi@1349
    46
      {
ladanyi@1349
    47
        LPX *lp;
ladanyi@1349
    48
        lp = lpx_create_prob();
ladanyi@1349
    49
        lpx_delete_prob(lp);
ladanyi@1349
    50
        return 0;
ladanyi@1349
    51
      }'
ladanyi@1349
    52
ladanyi@1349
    53
    AC_LANG_PUSH(C++)
alpar@1373
    54
    AC_LINK_IFELSE([$lx_glpk_test_prog], [lx_glpk_found=yes], [lx_glpk_found=no])
ladanyi@1349
    55
    AC_LANG_POP(C++)
ladanyi@1349
    56
ladanyi@1349
    57
    CXXFLAGS="$lx_save_cxxflags"
ladanyi@1349
    58
    LDFLAGS="$lx_save_ldflags"
ladanyi@1349
    59
    LIBS="$lx_save_libs"
ladanyi@1349
    60
ladanyi@1349
    61
    if test x"$lx_glpk_found" = x"yes"; then
ladanyi@1355
    62
      AC_DEFINE([HAVE_GLPK], [1], [Define to 1 if you have GLPK.])
ladanyi@1355
    63
      AC_MSG_RESULT([yes])
ladanyi@1349
    64
    else
ladanyi@1385
    65
      $GLPK_CFLAGS=""
ladanyi@1385
    66
      $GLPK_LDFLAGS=""
ladanyi@1385
    67
      $GLPK_LIBS=""
ladanyi@1355
    68
      AC_MSG_RESULT([no])
ladanyi@1349
    69
    fi
ladanyi@1349
    70
  fi
ladanyi@1349
    71
  GLPK_LIBS="$GLPK_LDFLAGS $GLPK_LIBS"
ladanyi@1349
    72
  AC_SUBST(GLPK_CFLAGS)
ladanyi@1349
    73
  AC_SUBST(GLPK_LIBS)
ladanyi@1349
    74
  AM_CONDITIONAL([HAVE_GLPK], [test x"$lx_glpk_found" = x"yes"])
ladanyi@1349
    75
])
ladanyi@1380
    76
ladanyi@1380
    77
ladanyi@1380
    78
AC_DEFUN([LX_CHECK_CPLEX],
ladanyi@1380
    79
[
ladanyi@1380
    80
  AC_ARG_WITH([cplex],
ladanyi@1380
    81
AS_HELP_STRING([--with-cplex@<:@=PREFIX@:>@], [search for CPLEX under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
ladanyi@1380
    82
AS_HELP_STRING([--without-cplex], [disable checking for CPLEX]),
ladanyi@1380
    83
              [], [with_cplex=yes])
ladanyi@1380
    84
ladanyi@1380
    85
  AC_ARG_WITH([cplex-includedir],
ladanyi@1380
    86
AS_HELP_STRING([--with-cplex-includedir=DIR], [search for CPLEX headers in DIR]),
ladanyi@1380
    87
              [], [with_cplex_includedir=no])
ladanyi@1380
    88
ladanyi@1380
    89
  AC_ARG_WITH([cplex-libdir],
ladanyi@1380
    90
AS_HELP_STRING([--with-cplex-libdir=DIR], [search for CPLEX libraries in DIR]),
ladanyi@1380
    91
              [], [with_cplex_libdir=no])
ladanyi@1380
    92
alpar@1382
    93
  lx_cplex_found=no
ladanyi@1380
    94
  if test x"$with_cplex" != x"no"; then
ladanyi@1380
    95
    AC_MSG_CHECKING([for CPLEX])
ladanyi@1380
    96
ladanyi@1380
    97
    if test x"$with_cplex_includedir" != x"no"; then
ladanyi@1380
    98
      CPLEX_CFLAGS="-I$with_cplex_includedir"
ladanyi@1380
    99
    elif test x"$with_cplex" != x"yes"; then
ladanyi@1380
   100
      CPLEX_CFLAGS="-I$with_cplex/include"
ladanyi@1380
   101
    fi
ladanyi@1380
   102
ladanyi@1380
   103
    if test x"$with_cplex_libdir" != x"no"; then
ladanyi@1380
   104
      CPLEX_LDFLAGS="-L$with_cplex_libdir"
ladanyi@1380
   105
    elif test x"$with_cplex" != x"yes"; then
ladanyi@1380
   106
      CPLEX_LDFLAGS="-L$with_cplex/lib"
ladanyi@1380
   107
    fi
ladanyi@1380
   108
    CPLEX_LIBS="-lcplex -lm -lpthread"
ladanyi@1380
   109
ladanyi@1385
   110
    lx_save_cxxflags="$CXXFLAGS"
ladanyi@1385
   111
    lx_save_ldflags="$LDFLAGS"
ladanyi@1385
   112
    lx_save_libs="$LIBS"
ladanyi@1380
   113
    CXXFLAGS="$CPLEX_CFLAGS"
ladanyi@1380
   114
    LDFLAGS="$CPLEX_LDFLAGS"
ladanyi@1380
   115
    LIBS="$CPLEX_LIBS"
ladanyi@1380
   116
ladanyi@1380
   117
    lx_cplex_test_prog='
ladanyi@1380
   118
      extern "C" {
ladanyi@1380
   119
      #include <ilcplex/cplex.h>
ladanyi@1380
   120
      }
ladanyi@1380
   121
ladanyi@1380
   122
      int main(int argc, char* argv[])
ladanyi@1380
   123
      {
ladanyi@1385
   124
        CPXENVptr env = NULL;
ladanyi@1380
   125
        return 0;
ladanyi@1380
   126
      }'
ladanyi@1380
   127
ladanyi@1380
   128
    AC_LANG_PUSH(C++)
ladanyi@1380
   129
    AC_LINK_IFELSE([$lx_cplex_test_prog], [lx_cplex_found=yes], [lx_cplex_found=no])
ladanyi@1380
   130
    AC_LANG_POP(C++)
ladanyi@1380
   131
ladanyi@1380
   132
    CXXFLAGS="$lx_save_cxxflags"
ladanyi@1380
   133
    LDFLAGS="$lx_save_ldflags"
ladanyi@1380
   134
    LIBS="$lx_save_libs"
ladanyi@1380
   135
ladanyi@1380
   136
    if test x"$lx_cplex_found" = x"yes"; then
ladanyi@1380
   137
      AC_DEFINE([HAVE_CPLEX], [1], [Define to 1 if you have CPLEX.])
ladanyi@1380
   138
      AC_MSG_RESULT([yes])
ladanyi@1380
   139
    else
ladanyi@1385
   140
      $CPLEX_CFLAGS=""
ladanyi@1385
   141
      $CPLEX_LDFLAGS=""
ladanyi@1385
   142
      $CPLEX_LIBS=""
ladanyi@1380
   143
      AC_MSG_RESULT([no])
ladanyi@1380
   144
    fi
ladanyi@1380
   145
  fi
ladanyi@1380
   146
  CPLEX_LIBS="$CPLEX_LDFLAGS $CPLEX_LIBS"
ladanyi@1380
   147
  AC_SUBST(CPLEX_CFLAGS)
ladanyi@1380
   148
  AC_SUBST(CPLEX_LIBS)
ladanyi@1380
   149
  AM_CONDITIONAL([HAVE_CPLEX], [test x"$lx_cplex_found" = x"yes"])
ladanyi@1380
   150
])