COIN-OR::LEMON - Graph Library

source: lemon-0.x/config/lp.m4 @ 1382:2c925c18d130

Last change on this file since 1382:2c925c18d130 was 1382:2c925c18d130, checked in by Alpar Juttner, 19 years ago

Set $lp_{glpk|cplex}_found even if --without-{glpk|cplex} option was given.

File size: 4.0 KB
Line 
1AC_DEFUN([LX_CHECK_GLPK],
2[
3  AC_ARG_WITH([glpk],
4AS_HELP_STRING([--with-glpk@<:@=PREFIX@:>@], [search for GLPK under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
5AS_HELP_STRING([--without-glpk], [disable checking for GLPK]),
6              [], [with_glpk=yes])
7
8  AC_ARG_WITH([glpk-includedir],
9AS_HELP_STRING([--with-glpk-includedir=DIR], [search for GLPK headers in DIR]),
10              [], [with_glpk_includedir=no])
11
12  AC_ARG_WITH([glpk-libdir],
13AS_HELP_STRING([--with-glpk-libdir=DIR], [search for GLPK libraries in DIR]),
14              [], [with_glpk_libdir=no])
15
16  lx_glpk_found=no
17  if test x"$with_glpk" != x"no"; then
18    AC_MSG_CHECKING([for GLPK])
19
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"
24    fi
25
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"
30    fi
31    GLPK_LIBS="-lglpk"
32
33    lx_save_cxxflags="$CXXFLAGS";
34    lx_save_ldflags="$LDFLAGS";
35    lx_save_libs="$LIBS";
36    CXXFLAGS="$GLPK_CFLAGS"
37    LDFLAGS="$GLPK_LDFLAGS"
38    LIBS="$GLPK_LIBS"
39
40    lx_glpk_test_prog='
41      extern "C" {
42      #include <glpk.h>
43      }
44
45      int main(int argc, char* argv[])
46      {
47        LPX *lp;
48        lp = lpx_create_prob();
49        lpx_delete_prob(lp);
50        return 0;
51      }'
52
53    AC_LANG_PUSH(C++)
54    AC_LINK_IFELSE([$lx_glpk_test_prog], [lx_glpk_found=yes], [lx_glpk_found=no])
55    AC_LANG_POP(C++)
56
57    CXXFLAGS="$lx_save_cxxflags"
58    LDFLAGS="$lx_save_ldflags"
59    LIBS="$lx_save_libs"
60
61    if test x"$lx_glpk_found" = x"yes"; then
62      AC_DEFINE([HAVE_GLPK], [1], [Define to 1 if you have GLPK.])
63      AC_MSG_RESULT([yes])
64    else
65      AC_MSG_RESULT([no])
66    fi
67  fi
68  GLPK_LIBS="$GLPK_LDFLAGS $GLPK_LIBS"
69  AC_SUBST(GLPK_CFLAGS)
70  AC_SUBST(GLPK_LIBS)
71  AM_CONDITIONAL([HAVE_GLPK], [test x"$lx_glpk_found" = x"yes"])
72])
73
74
75AC_DEFUN([LX_CHECK_CPLEX],
76[
77  AC_ARG_WITH([cplex],
78AS_HELP_STRING([--with-cplex@<:@=PREFIX@:>@], [search for CPLEX under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
79AS_HELP_STRING([--without-cplex], [disable checking for CPLEX]),
80              [], [with_cplex=yes])
81
82  AC_ARG_WITH([cplex-includedir],
83AS_HELP_STRING([--with-cplex-includedir=DIR], [search for CPLEX headers in DIR]),
84              [], [with_cplex_includedir=no])
85
86  AC_ARG_WITH([cplex-libdir],
87AS_HELP_STRING([--with-cplex-libdir=DIR], [search for CPLEX libraries in DIR]),
88              [], [with_cplex_libdir=no])
89
90  lx_cplex_found=no
91  if test x"$with_cplex" != x"no"; then
92    AC_MSG_CHECKING([for CPLEX])
93
94    if test x"$with_cplex_includedir" != x"no"; then
95      CPLEX_CFLAGS="-I$with_cplex_includedir"
96    elif test x"$with_cplex" != x"yes"; then
97      CPLEX_CFLAGS="-I$with_cplex/include"
98    fi
99
100    if test x"$with_cplex_libdir" != x"no"; then
101      CPLEX_LDFLAGS="-L$with_cplex_libdir"
102    elif test x"$with_cplex" != x"yes"; then
103      CPLEX_LDFLAGS="-L$with_cplex/lib"
104    fi
105    CPLEX_LIBS="-lcplex -lm -lpthread"
106
107    lx_save_cxxflags="$CXXFLAGS";
108    lx_save_ldflags="$LDFLAGS";
109    lx_save_libs="$LIBS";
110    CXXFLAGS="$CPLEX_CFLAGS"
111    LDFLAGS="$CPLEX_LDFLAGS"
112    LIBS="$CPLEX_LIBS"
113
114    lx_cplex_test_prog='
115      extern "C" {
116      #include <ilcplex/cplex.h>
117      }
118
119      int main(int argc, char* argv[])
120      {
121        CPXENVptr env = NULL;
122        return 0;
123      }'
124
125    AC_LANG_PUSH(C++)
126    AC_LINK_IFELSE([$lx_cplex_test_prog], [lx_cplex_found=yes], [lx_cplex_found=no])
127    AC_LANG_POP(C++)
128
129    CXXFLAGS="$lx_save_cxxflags"
130    LDFLAGS="$lx_save_ldflags"
131    LIBS="$lx_save_libs"
132
133    if test x"$lx_cplex_found" = x"yes"; then
134      AC_DEFINE([HAVE_CPLEX], [1], [Define to 1 if you have CPLEX.])
135      AC_MSG_RESULT([yes])
136    else
137      AC_MSG_RESULT([no])
138    fi
139  fi
140  CPLEX_LIBS="$CPLEX_LDFLAGS $CPLEX_LIBS"
141  AC_SUBST(CPLEX_CFLAGS)
142  AC_SUBST(CPLEX_LIBS)
143  AM_CONDITIONAL([HAVE_CPLEX], [test x"$lx_cplex_found" = x"yes"])
144])
Note: See TracBrowser for help on using the repository browser.