COIN-OR::LEMON - Graph Library

source: lemon-0.x/config/lp.m4 @ 1380:cb2891afe526

Last change on this file since 1380:cb2891afe526 was 1380:cb2891afe526, checked in by Akos Ladanyi, 16 years ago

added check for CLPEX

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