ladanyi@1: AC_DEFUN([LX_CHECK_CPLEX],
ladanyi@1: [
ladanyi@1:   AC_ARG_WITH([cplex],
ladanyi@1: AS_HELP_STRING([--with-cplex@<:@=PREFIX@:>@], [search for CPLEX under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
ladanyi@1: AS_HELP_STRING([--without-cplex], [disable checking for CPLEX]),
ladanyi@1:               [], [with_cplex=yes])
ladanyi@1: 
ladanyi@1:   AC_ARG_WITH([cplex-includedir],
ladanyi@1: AS_HELP_STRING([--with-cplex-includedir=DIR], [search for CPLEX headers in DIR]),
ladanyi@1:               [], [with_cplex_includedir=no])
ladanyi@1: 
ladanyi@1:   AC_ARG_WITH([cplex-libdir],
ladanyi@1: AS_HELP_STRING([--with-cplex-libdir=DIR], [search for CPLEX libraries in DIR]),
ladanyi@1:               [], [with_cplex_libdir=no])
ladanyi@1: 
ladanyi@1:   lx_cplex_found=no
ladanyi@1:   if test x"$with_cplex" != x"no"; then
ladanyi@1:     AC_MSG_CHECKING([for CPLEX])
ladanyi@1: 
ladanyi@1:     if test x"$with_cplex_includedir" != x"no"; then
ladanyi@1:       CPLEX_CFLAGS="-I$with_cplex_includedir"
ladanyi@1:     elif test x"$with_cplex" != x"yes"; then
ladanyi@1:       CPLEX_CFLAGS="-I$with_cplex/include"
ladanyi@1:     elif test x"$CPLEX_INCLUDEDIR" != x; then
ladanyi@1:       CPLEX_CFLAGS="-I$CPLEX_INCLUDEDIR"
ladanyi@1:     fi
ladanyi@1: 
ladanyi@1:     if test x"$with_cplex_libdir" != x"no"; then
ladanyi@1:       CPLEX_LDFLAGS="-L$with_cplex_libdir"
ladanyi@1:     elif test x"$with_cplex" != x"yes"; then
ladanyi@1:       CPLEX_LDFLAGS="-L$with_cplex/lib"
ladanyi@1:     elif test x"$CPLEX_LIBDIR" != x; then
ladanyi@1:       CPLEX_LDFLAGS="-L$CPLEX_LIBDIR"
ladanyi@1:     fi
ladanyi@1:     CPLEX_LIBS="-lcplex -lm -lpthread"
ladanyi@1: 
ladanyi@1:     lx_save_cxxflags="$CXXFLAGS"
ladanyi@1:     lx_save_ldflags="$LDFLAGS"
ladanyi@1:     lx_save_libs="$LIBS"
ladanyi@1:     CXXFLAGS="$CPLEX_CFLAGS"
ladanyi@1:     LDFLAGS="$CPLEX_LDFLAGS"
ladanyi@1:     LIBS="$CPLEX_LIBS"
ladanyi@1: 
ladanyi@1:     lx_cplex_test_prog='
ladanyi@1:       extern "C" {
ladanyi@1:       #include <ilcplex/cplex.h>
ladanyi@1:       }
ladanyi@1: 
ladanyi@187:       int main(int argc, char** argv)
ladanyi@1:       {
ladanyi@1:         CPXENVptr env = NULL;
ladanyi@1:         return 0;
ladanyi@1:       }'
ladanyi@1: 
ladanyi@1:     AC_LANG_PUSH(C++)
ladanyi@1:     AC_LINK_IFELSE([$lx_cplex_test_prog], [lx_cplex_found=yes], [lx_cplex_found=no])
ladanyi@1:     AC_LANG_POP(C++)
ladanyi@1: 
ladanyi@1:     CXXFLAGS="$lx_save_cxxflags"
ladanyi@1:     LDFLAGS="$lx_save_ldflags"
ladanyi@1:     LIBS="$lx_save_libs"
ladanyi@1: 
ladanyi@1:     if test x"$lx_cplex_found" = x"yes"; then
ladanyi@1:       AC_DEFINE([HAVE_CPLEX], [1], [Define to 1 if you have CPLEX.])
alpar@457:       lx_lp_found=yes
alpar@457:       AC_DEFINE([HAVE_LP], [1], [Define to 1 if you have any LP solver.])
alpar@457:       lx_mip_found=yes
alpar@457:       AC_DEFINE([HAVE_MIP], [1], [Define to 1 if you have any MIP solver.])
ladanyi@1:       AC_MSG_RESULT([yes])
ladanyi@1:     else
ladanyi@1:       CPLEX_CFLAGS=""
ladanyi@1:       CPLEX_LDFLAGS=""
ladanyi@1:       CPLEX_LIBS=""
ladanyi@1:       AC_MSG_RESULT([no])
ladanyi@1:     fi
ladanyi@1:   fi
ladanyi@1:   CPLEX_LIBS="$CPLEX_LDFLAGS $CPLEX_LIBS"
ladanyi@1:   AC_SUBST(CPLEX_CFLAGS)
ladanyi@1:   AC_SUBST(CPLEX_LIBS)
ladanyi@1:   AM_CONDITIONAL([HAVE_CPLEX], [test x"$lx_cplex_found" = x"yes"])
ladanyi@1: ])