1 # CVC4_SUPPORTED_BINDINGS
2 # -----------------------
3 # Supported language bindings for CVC4.
4 AC_DEFUN([CVC4_SUPPORTED_BINDINGS],
9 # All language bindings for CVC4 (may include unofficial bindings).
10 AC_DEFUN([CVC4_ALL_BINDINGS],
11 [c,java,csharp,perl,php,python,ruby,tcl,ocaml])
13 # CVC4_NEED_SWIG_FOR_BINDING
14 # --------------------------
15 # Used by CVC4_CHECK_BINDINGS to ensure swig is available (and correct
16 # version) when a binding needs it
17 AC_DEFUN([CVC4_NEED_SWIG_FOR_BINDING], [
18 if test -z "$SWIG"; then
19 AC_MSG_WARN([swig not available or incompatible version; $binding bindings require swig 2.0.0 or later])
24 # CVC4_CHECK_BINDINGS(DEFAULT_BINDINGS_LIST)
25 # ------------------------------------------
26 # Check for user language binding preferences, and what is possible
27 # to build on the build host.
28 AC_DEFUN([CVC4_CHECK_BINDINGS], [
29 dnl Check for SWIG (for building language bindings)
32 m4_foreach(lang,[CVC4_ALL_BINDINGS],
33 [[cvc4_build_]]lang[[_bindings=no
36 AC_ARG_VAR(SWIG, [SWIG binary (used to generate language bindings)])
38 [AS_HELP_STRING([--with-swig=BINARY], [path to swig binary])],
39 [if test "$withval" = no; then noswig=yes; else SWIG="$withval"; fi])
40 AC_ARG_ENABLE([language-bindings],
41 [AS_HELP_STRING([--enable-language-bindings=][CVC4_SUPPORTED_BINDINGS][ | all], [specify language bindings to build])],
42 [if test "$enableval" = yes; then cvc4_check_for_bindings=yes; try_bindings='$1'; else cvc4_check_for_bindings=no; if test "$enableval" = no; then try_bindings=; else try_bindings="$enableval"; fi; fi],
43 [cvc4_check_for_bindings=no; try_bindings=])
44 CVC4_LANGUAGE_BINDINGS=
45 if test "$noswig" = yes; then
46 AC_MSG_WARN([use of swig disabled by user, native API bindings disabled.])
49 if test -z "$SWIG"; then
50 AC_CHECK_PROGS(SWIG, [swig swig2.0], [], [])
52 AC_CHECK_PROG(SWIG, "$SWIG", "$SWIG", [])
54 if test -z "$SWIG"; then
55 AC_MSG_RESULT([not found])
56 AC_MSG_WARN([language bindings for native API disabled, swig not found.])
58 AC_MSG_CHECKING([compatibility with version of swig])
59 cat > conftest.c << _CVC4EOF
61 #if !defined(SWIG_VERSION) || SWIG_VERSION < 0x020000
65 if $SWIG conftest.c >&AS_MESSAGE_LOG_FD 2>&1; then
66 AC_MSG_RESULT([compatible version])
68 AC_MSG_RESULT([incompatible version])
69 AC_MSG_WARN([swig version 2.0.0 or later is required to build native API bindings])
71 echo '===Failed swig input was:' >&AS_MESSAGE_LOG_FD
72 cat conftest.c >&AS_MESSAGE_LOG_FD
73 echo '===End failed swig input' >&AS_MESSAGE_LOG_FD
79 AC_MSG_CHECKING([for requested user language bindings])
80 if test "$try_bindings" = all; then
81 try_bindings='CVC4_SUPPORTED_BINDINGS'
83 try_bindings=$(echo "$try_bindings" | sed 's/,/ /g')
84 if test -z "$try_bindings"; then
87 AC_MSG_RESULT([$try_bindings])
89 CVC4_UNSUPPORTED_LANGUAGE_BINDINGS=
90 cvc4_save_CPPFLAGS="$CPPFLAGS"
91 cvc4_save_CXXFLAGS="$CXXFLAGS"
93 for binding in $try_bindings; do
94 __cvc4_lang_supported=no
95 m4_foreach([__cvc4_supported_binding], [CVC4_SUPPORTED_BINDINGS],
96 [if test "$binding" = "__cvc4_supported_binding"; then __cvc4_lang_supported=yes; fi
98 if test $__cvc4_lang_supported = no; then
99 CVC4_UNSUPPORTED_LANGUAGE_BINDINGS="${CVC4_UNSUPPORTED_LANGUAGE_BINDINGS:+$CVC4_UNSUPPORTED_LANGUAGE_BINDINGS }$binding"
103 AC_MSG_CHECKING([for availability of $binding binding])
106 AC_MSG_RESULT([C++ is built by default]);;
108 cvc4_build_c_bindings=yes
109 AC_MSG_RESULT([C support will be built]);;
111 AC_MSG_RESULT([Java support will be built])
112 CVC4_NEED_SWIG_FOR_BINDING
113 AC_ARG_VAR(JAVA_CPPFLAGS, [flags to pass to compiler when building Java bindings])
114 CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
115 AC_CHECK_HEADER([jni.h], [cvc4_build_java_bindings=yes], [binding_error=yes])
118 AC_MSG_RESULT([[C# support will be built]])
119 CVC4_NEED_SWIG_FOR_BINDING
120 AC_ARG_VAR(CSHARP_CPPFLAGS, [flags to pass to compiler when building C# bindings])
121 CPPFLAGS="$CPPFLAGS $CSHARP_CPPFLAGS"
122 cvc4_build_csharp_bindings=yes
125 AC_MSG_RESULT([perl support will be built])
126 CVC4_NEED_SWIG_FOR_BINDING
127 AC_ARG_VAR(PERL_CPPFLAGS, [flags to pass to compiler when building perl bindings])
128 CPPFLAGS="$CPPFLAGS $PERL_CPPFLAGS"
129 AC_CHECK_HEADER([EXTERN.h], [cvc4_build_perl_bindings=yes], [binding_error=yes])
132 AC_MSG_RESULT([php support will be built])
133 CVC4_NEED_SWIG_FOR_BINDING
134 AC_ARG_VAR(PHP_CPPFLAGS, [flags to pass to compiler when building PHP bindings])
135 CPPFLAGS="$CPPFLAGS $PHP_CPPFLAGS"
136 AC_CHECK_HEADER([zend.h], [cvc4_build_php_bindings=yes], [binding_error=yes])
139 AC_MSG_RESULT([python support will be built])
140 CVC4_NEED_SWIG_FOR_BINDING
141 AM_PATH_PYTHON([2.5], [cvc4_build_python_bindings=yes], [binding_error=yes])
142 AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for python, bypassing python-config])
143 AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])
144 AS_IF([test -z "$PYTHON_INCLUDE"], [
145 AS_IF([test -z "$PYTHON_CONFIG"], [
146 AC_PATH_PROGS([PYTHON_CONFIG],
147 [python$PYTHON_VERSION-config python-config],
150 AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON.])])
152 AC_MSG_CHECKING([python include flags])
153 AC_SUBST(PYTHON_CXXFLAGS, `$PYTHON_CONFIG --includes`)
154 AC_MSG_RESULT([$PYTHON_CXXFLAGS])
156 CPPFLAGS="$CPPFLAGS $PYTHON_CXXFLAGS"
157 AC_CHECK_HEADER([Python.h], [cvc4_build_python_bindings=yes], [binding_error=yes])
160 AC_MSG_RESULT([ruby support will be built])
161 CVC4_NEED_SWIG_FOR_BINDING
162 AC_ARG_VAR(RUBY_CPPFLAGS, [flags to pass to compiler when building ruby bindings])
163 CPPFLAGS="$CPPFLAGS $RUBY_CPPFLAGS"
164 AC_CHECK_HEADER([ruby.h], [cvc4_build_ruby_bindings=yes], [binding_error=yes])
167 AC_MSG_RESULT([tcl support will be built])
168 CVC4_NEED_SWIG_FOR_BINDING
169 AC_ARG_VAR(TCL_CPPFLAGS, [flags to pass to compiler when building tcl bindings])
170 CPPFLAGS="$CPPFLAGS $TCL_CPPFLAGS"
171 AC_CHECK_HEADER([tcl.h], [cvc4_build_tcl_bindings=yes], [binding_error=yes])
174 AC_MSG_RESULT([OCaml support will be built])
175 CVC4_NEED_SWIG_FOR_BINDING
176 AC_ARG_VAR(TCL_CPPFLAGS, [flags to pass to compiler when building OCaml bindings])
177 CPPFLAGS="$CPPFLAGS $OCAML_CPPFLAGS"
178 AC_CHECK_HEADER([caml/misc.h], [cvc4_build_ocaml_bindings=yes], [binding_error=yes])
179 if test "$binding_error" = no; then
180 AC_ARG_VAR(OCAMLC, [OCaml compiler])
181 if test -z "$OCAMLC"; then
182 AC_CHECK_PROGS(OCAMLC, ocamlc, ocamlc, [])
184 AC_CHECK_PROG(OCAMLC, "$OCAMLC", "$OCAMLC", [])
186 AC_ARG_VAR(OCAMLMKTOP, [OCaml runtime-maker])
187 if test -z "$OCAMLMKTOP"; then
188 AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop, ocamlmktop, [])
190 AC_CHECK_PROG(OCAMLMKTOP, "$OCAMLMKTOP", "$OCAMLMKTOP", [])
192 AC_ARG_VAR(OCAMLFIND, [OCaml-find binary])
193 if test -z "$OCAMLFIND"; then
194 AC_CHECK_PROGS(OCAMLFIND, ocamlfind, ocamlfind, [])
196 AC_CHECK_PROG(OCAMLFIND, "$OCAMLFIND", "$OCAMLFIND", [])
198 AC_ARG_VAR(CAMLP4O, [camlp4o binary])
199 if test -z "$CAMLP4O"; then
200 AC_CHECK_PROGS(CAMLP4O, camlp4o, camlp4o, [])
202 AC_CHECK_PROG(CAMLP4O, "$CAMLP4O", "$CAMLP4O", [])
206 *) AC_MSG_RESULT([unknown binding]); binding_error=yes;;
208 if test "$binding_error" = yes; then
209 if test "$cvc4_check_for_bindings" = no; then
210 AC_MSG_ERROR([Language binding \`$binding' requested by user, but it cannot be built (the preceding few lines should give an indication why this is).])
212 AC_MSG_WARN([Language binding \`$binding' cannot be built (the preceding few lines should give an indication why this is).])
215 CVC4_LANGUAGE_BINDINGS="${CVC4_LANGUAGE_BINDINGS:+$CVC4_LANGUAGE_BINDINGS }$binding"
218 CXXFLAGS="$cvc4_save_CXXFLAGS"
219 CPPFLAGS="$cvc4_save_CPPFLAGS"
222 AM_CONDITIONAL([CVC4_HAS_SWIG], [test "$SWIG"])
224 m4_foreach([lang], [CVC4_ALL_BINDINGS],
225 [AM_CONDITIONAL([CVC4_LANGUAGE_BINDING_]m4_toupper(lang), [test "$cvc4_build_]lang[_bindings" = yes])
229 AC_SUBST(CVC4_LANGUAGE_BINDINGS)
231 ])# CVC4_CHECK_BINDINGS