3 # Look for abc and link it in, but only if user requested.
4 AC_DEFUN([CVC4_CHECK_FOR_ABC], [
5 AC_MSG_CHECKING([whether user requested abc support])
10 if test "$with_abc" = no; then
11 AC_MSG_RESULT([no, abc disabled by user])
12 elif test -n "$with_abc"; then
13 AC_MSG_RESULT([yes, abc requested by user])
15 # Get the location of all the ABC stuff
16 AC_ARG_VAR(ABC_HOME, [path to top level of abc source tree])
20 [--with-abc-dir=PATH],
21 [path to top level of abc source tree]
23 [ABC_HOME="$withval"],
24 [ if test -z "$ABC_HOME"; then
25 AC_MSG_FAILURE([must give --with-abc-dir=PATH or define environment variable ABC_HOME!])
29 if ! test -d "$ABC_HOME" || ! test -x "$ABC_HOME/arch_flags"; then
30 AC_MSG_FAILURE([either $ABC_HOME is not an abc source tree or it's not yet built])
33 AC_MSG_CHECKING([for arch_flags to use with libabc])
34 libabc_arch_flags="$("$ABC_HOME/arch_flags")"
35 AC_MSG_RESULT([$libabc_arch_flags])
36 CVC4CPPFLAGS="${CVC4CPPFLAGS:+$CVC4CPPFLAGS }-I$ABC_HOME/src $libabc_arch_flags"
37 ABC_LDFLAGS="-L$ABC_HOME"
39 dnl Try a bunch of combinations until something works :-/
40 cvc4_save_LDFLAGS="$LDFLAGS"
42 CPPFLAGS="$CPPFLAGS -I$ABC_HOME/src $libabc_arch_flags"
43 LDFLAGS="$LDFLAGS $ABC_LDFLAGS"
44 AC_CHECK_HEADER([base/abc/abc.h], [], [AC_MSG_FAILURE([cannot find abc.h, the ABC header!])])
45 AC_MSG_CHECKING([how to link abc])
47 CVC4_TRY_ABC_WITH([-lm])
48 CVC4_TRY_ABC_WITH([-lm -lrt])
49 CVC4_TRY_ABC_WITH([-lm -lrt -ldl])
50 CVC4_TRY_ABC_WITH([-lm -lrt -lreadline -ldl])
51 CVC4_TRY_ABC_WITH([-lm -lpthread])
52 CVC4_TRY_ABC_WITH([-lm -lpthread -lrt])
53 CVC4_TRY_ABC_WITH([-lm -lpthread -lrt -ldl])
54 CVC4_TRY_ABC_WITH([-lm -lpthread -lrt -lreadline -ldl])
55 dnl CVC4_TRY_ABC_WITH([-lm -rdynamic -lreadline -lpthread -lrt -ldl])
56 if test -z "$ABC_LIBS"; then
57 AC_MSG_FAILURE([cannot link against libabc!])
59 AC_MSG_RESULT([$ABC_LIBS])
60 # make sure it works in static builds, too
61 if test "$enable_static_binary" = yes; then
63 AC_MSG_CHECKING([whether statically-linked abc is functional])
64 CVC4_TRY_STATIC_ABC_WITH([])
65 CVC4_TRY_STATIC_ABC_WITH([-lm])
66 CVC4_TRY_STATIC_ABC_WITH([-lm -lrt])
67 CVC4_TRY_STATIC_ABC_WITH([-lm -lrt -ldl])
68 CVC4_TRY_STATIC_ABC_WITH([-lm -lrt -lreadline -ldl])
69 CVC4_TRY_STATIC_ABC_WITH([-lm -lpthread])
70 CVC4_TRY_STATIC_ABC_WITH([-lm -lpthread -lrt])
71 CVC4_TRY_STATIC_ABC_WITH([-lm -lpthread -lrt -ldl])
72 CVC4_TRY_STATIC_ABC_WITH([-lm -lpthread -lrt -lreadline -ldl])
73 if test -n "$ABC_LIBS"; then
74 AC_MSG_RESULT([yes, it works])
78 AC_MSG_FAILURE([abc installation appears incompatible with static-binary])
84 if test "$with_abc" = yes; then
91 LDFLAGS="$cvc4_save_LDFLAGS"
93 AC_MSG_RESULT([no, user didn't request abc])
96 ])# CVC4_CHECK_FOR_ABC
98 # CVC4_TRY_ABC_WITH(LIBS)
99 # -----------------------
100 # Try AC_CHECK_LIB(abc) with the given linking libraries
101 AC_DEFUN([CVC4_TRY_ABC_WITH], [
102 if test -z "$ABC_LIBS"; then
104 cvc4_save_LIBS="$LIBS"
106 AC_LINK_IFELSE([AC_LANG_PROGRAM([extern "C" { void Abc_Start(); }],
108 [ABC_LIBS="-labc $1"],
110 LIBS="$cvc4_save_LIBS"
113 ])# CVC4_TRY_ABC_WITH
115 # CVC4_TRY_STATIC_ABC_WITH(LIBS)
116 # ------------------------------
117 # Try AC_CHECK_LIB(abc) with the given linking libraries
118 AC_DEFUN([CVC4_TRY_STATIC_ABC_WITH], [
119 if test -z "$ABC_LIBS"; then
121 cvc4_save_LIBS="$LIBS"
122 cvc4_save_LDFLAGS="$LDFLAGS"
123 LDFLAGS="-static $LDFLAGS"
124 LIBS="-labc-static $1"
125 AC_LINK_IFELSE([AC_LANG_PROGRAM([extern "C" { void Abc_Start(); }],
127 [ABC_LIBS="-labc-static $1"],
129 AC_LINK_IFELSE([AC_LANG_PROGRAM([extern "C" { void Abc_Start(); }],
131 [ABC_LIBS="-labc $1"]) ])
132 LIBS="$cvc4_save_LIBS"
133 LDFLAGS="$cvc4_save_LDFLAGS"
136 ])# CVC4_TRY_STATIC_ABC_WITH