3 # Look for glpk and link it in, but only if user requested.
4 AC_DEFUN([CVC4_CHECK_FOR_GLPK], [
5 AC_MSG_CHECKING([whether user requested glpk support])
9 if test "$with_glpk" = no; then
10 AC_MSG_RESULT([no, glpk disabled by user])
11 elif test "$with_glpk" = yes; then
12 AC_MSG_RESULT([yes, glpk requested by user])
14 dnl Try a bunch of combinations until something works :-/
16 AC_CHECK_HEADERS([glpk/glpk.h glpk.h], [break])
17 if test x$ac_cv_header_glpk_glpk_h = xno && test x$ac_cv_header_glpk_h = xno; then
18 AC_MSG_FAILURE([cannot find glpk.h, the GLPK header!])
20 AC_MSG_CHECKING([how to link glpk])
21 CVC4_TRY_GLPK_WITH([])
22 CVC4_TRY_GLPK_WITH([-lgmp])
23 CVC4_TRY_GLPK_WITH([-lz])
24 CVC4_TRY_GLPK_WITH([-ldl])
25 CVC4_TRY_GLPK_WITH([-lltdl])
26 CVC4_TRY_GLPK_WITH([-lltdl -ldl])
27 CVC4_TRY_GLPK_WITH([-lz -ldl])
28 CVC4_TRY_GLPK_WITH([-lz -lltdl])
29 CVC4_TRY_GLPK_WITH([-lz -lltdl -ldl])
30 CVC4_TRY_GLPK_WITH([-lgmp -lz])
31 CVC4_TRY_GLPK_WITH([-lgmp -ldl])
32 CVC4_TRY_GLPK_WITH([-lgmp -lltdl])
33 CVC4_TRY_GLPK_WITH([-lgmp -lltdl -ldl])
34 CVC4_TRY_GLPK_WITH([-lgmp -lz -ldl])
35 CVC4_TRY_GLPK_WITH([-lgmp -lz -lltdl])
36 CVC4_TRY_GLPK_WITH([-lgmp -lz -lltdl -ldl])
37 if test -z "$GLPK_LIBS"; then
38 AC_MSG_FAILURE([cannot link against libglpk! (perhaps you have not switched to glpk-cut-log? see /README)])
40 AC_MSG_RESULT([$GLPK_LIBS])
41 # make sure it works in static builds, too
42 if test "$enable_static_binary" = yes; then
44 AC_MSG_CHECKING([whether statically-linked glpk is functional])
45 CVC4_TRY_STATIC_GLPK_WITH([])
46 CVC4_TRY_STATIC_GLPK_WITH([-lgmp])
47 CVC4_TRY_STATIC_GLPK_WITH([-lz])
48 CVC4_TRY_STATIC_GLPK_WITH([-ldl])
49 CVC4_TRY_STATIC_GLPK_WITH([-lltdl])
50 CVC4_TRY_STATIC_GLPK_WITH([-lltdl -ldl])
51 CVC4_TRY_STATIC_GLPK_WITH([-lz -ldl])
52 CVC4_TRY_STATIC_GLPK_WITH([-lz -lltdl])
53 CVC4_TRY_STATIC_GLPK_WITH([-lz -lltdl -ldl])
54 CVC4_TRY_STATIC_GLPK_WITH([-lgmp -lz])
55 CVC4_TRY_STATIC_GLPK_WITH([-lgmp -ldl])
56 CVC4_TRY_STATIC_GLPK_WITH([-lgmp -lltdl])
57 CVC4_TRY_STATIC_GLPK_WITH([-lgmp -lltdl -ldl])
58 CVC4_TRY_STATIC_GLPK_WITH([-lgmp -lz -ldl])
59 CVC4_TRY_STATIC_GLPK_WITH([-lgmp -lz -lltdl])
60 CVC4_TRY_STATIC_GLPK_WITH([-lgmp -lz -lltdl -ldl])
61 if test -n "$GLPK_LIBS"; then
62 AC_MSG_RESULT([yes, it works])
66 AC_MSG_FAILURE([glpk installation appears incompatible with static-binary])
72 if test "$with_glpk" = yes; then
80 AC_MSG_RESULT([no, user didn't request glpk])
83 ])# CVC4_CHECK_FOR_GLPK
85 # CVC4_TRY_GLPK_WITH(LIBS)
86 # ------------------------
87 # Try AC_CHECK_LIB(glpk) with the given linking libraries
88 AC_DEFUN([CVC4_TRY_GLPK_WITH], [
89 if test -z "$GLPK_LIBS"; then
91 cvc4_save_LIBS="$LIBS"
93 AC_LINK_IFELSE([AC_LANG_PROGRAM([#ifdef HAVE_GLPK_GLPK_H]
94 [#include <glpk/glpk.h>]
98 [int i = glp_ios_get_cut(NULL, 0, NULL, NULL, NULL, NULL, NULL)])],
99 [GLPK_LIBS="-lglpk $1"],
101 LIBS="$cvc4_save_LIBS"
104 ])# CVC4_TRY_GLPK_WITH
106 # CVC4_TRY_STATIC_GLPK_WITH(LIBS)
107 # -------------------------------
108 # Try AC_CHECK_LIB(glpk) with the given linking libraries
109 AC_DEFUN([CVC4_TRY_STATIC_GLPK_WITH], [
110 if test -z "$GLPK_LIBS"; then
112 cvc4_save_LIBS="$LIBS"
113 cvc4_save_LDFLAGS="$LDFLAGS"
114 LDFLAGS="-static $LDFLAGS"
116 AC_LINK_IFELSE([AC_LANG_PROGRAM([#ifdef HAVE_GLPK_GLPK_H]
117 [#include <glpk/glpk.h>]
121 [int i = glp_ios_get_cut(NULL, 0, NULL, NULL, NULL, NULL, NULL)])],
122 [GLPK_LIBS="-lglpk $1"],
124 LIBS="$cvc4_save_LIBS"
125 LDFLAGS="$cvc4_save_LDFLAGS"
128 ])# CVC4_TRY_STATIC_GLPK_WITH