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_CHECK_BINDINGS(DEFAULT_BINDINGS_LIST)
14 # ------------------------------------------
15 # Check for user language binding preferences, and what is possible
16 # to build on the build host.
17 AC_DEFUN([CVC4_CHECK_BINDINGS], [
18 dnl Check for SWIG (for building language bindings)
21 m4_foreach(lang,[CVC4_ALL_BINDINGS],
22 [[cvc4_build_]]lang[[_bindings=no
25 AC_ARG_VAR(SWIG, [SWIG binary (used to generate language bindings)])
27 [AS_HELP_STRING([--with-swig=BINARY], [path to swig binary])],
28 [if test "$withval" = no; then noswig=yes; else SWIG="$withval"; fi])
29 AC_ARG_ENABLE([language-bindings],
30 [AS_HELP_STRING([--enable-language-bindings=][CVC4_SUPPORTED_BINDINGS][ | all], [specify language bindings to build])],
31 [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],
32 [cvc4_check_for_bindings=no; try_bindings=])
33 CVC4_LANGUAGE_BINDINGS=
34 if test "$noswig" = yes; then
35 AC_MSG_WARN([use of swig disabled by user, native API bindings disabled.])
38 if test -z "$SWIG"; then
39 AC_CHECK_PROGS(SWIG, [swig swig2.0], [], [])
41 AC_CHECK_PROG(SWIG, "$SWIG", "$SWIG", [])
43 if test -z "$SWIG"; then
44 AC_MSG_WARN([language bindings for native API disabled, swig not found.])
48 AC_MSG_CHECKING([for requested user language bindings])
49 if test "$try_bindings" = all; then
50 try_bindings='CVC4_SUPPORTED_BINDINGS'
52 try_bindings=$(echo "$try_bindings" | sed 's/,/ /g')
53 if test -z "$try_bindings"; then
56 AC_MSG_RESULT([$try_bindings])
58 CVC4_UNSUPPORTED_LANGUAGE_BINDINGS=
59 cvc4_save_CPPFLAGS="$CPPFLAGS"
60 cvc4_save_CXXFLAGS="$CXXFLAGS"
62 for binding in $try_bindings; do
63 __cvc4_lang_supported=no
64 m4_foreach([__cvc4_supported_binding], [CVC4_SUPPORTED_BINDINGS],
65 [if test "$binding" = "__cvc4_supported_binding"; then __cvc4_lang_supported=yes; fi
67 if test $__cvc4_lang_supported = no; then
68 CVC4_UNSUPPORTED_LANGUAGE_BINDINGS="${CVC4_UNSUPPORTED_LANGUAGE_BINDINGS:+$CVC4_UNSUPPORTED_LANGUAGE_BINDINGS }$binding"
72 AC_MSG_CHECKING([for availability of $binding binding])
75 AC_MSG_RESULT([C++ is built by default]);;
77 cvc4_build_c_bindings=yes
78 AC_MSG_RESULT([C support will be built]);;
80 AC_MSG_RESULT([Java support will be built])
81 AC_ARG_VAR(JAVA_CPPFLAGS, [flags to pass to compiler when building Java bindings])
82 CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
83 AC_CHECK_HEADER([jni.h], [cvc4_build_java_bindings=yes], [binding_error=yes])
86 AC_MSG_RESULT([[C# support will be built]])
87 AC_ARG_VAR(CSHARP_CPPFLAGS, [flags to pass to compiler when building C# bindings])
88 CPPFLAGS="$CPPFLAGS $CSHARP_CPPFLAGS"
89 cvc4_build_csharp_bindings=yes
92 AC_MSG_RESULT([perl support will be built])
93 AC_ARG_VAR(PERL_CPPFLAGS, [flags to pass to compiler when building perl bindings])
94 CPPFLAGS="$CPPFLAGS $PERL_CPPFLAGS"
95 AC_CHECK_HEADER([EXTERN.h], [cvc4_build_perl_bindings=yes], [binding_error=yes])
98 AC_MSG_RESULT([php support will be built])
99 AC_ARG_VAR(PHP_CPPFLAGS, [flags to pass to compiler when building PHP bindings])
100 CPPFLAGS="$CPPFLAGS $PHP_CPPFLAGS"
101 AC_CHECK_HEADER([zend.h], [cvc4_build_php_bindings=yes], [binding_error=yes])
104 AC_MSG_RESULT([python support will be built])
105 AM_PATH_PYTHON([2.5], [cvc4_build_python_bindings=yes], [binding_error=yes])
106 AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for python, bypassing python-config])
107 AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])
108 AS_IF([test -z "$PYTHON_INCLUDE"], [
109 AS_IF([test -z "$PYTHON_CONFIG"], [
110 AC_PATH_PROGS([PYTHON_CONFIG],
111 [python$PYTHON_VERSION-config python-config],
114 AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON.])])
116 AC_MSG_CHECKING([python include flags])
117 AC_SUBST(PYTHON_CXXFLAGS, `$PYTHON_CONFIG --includes`)
118 AC_MSG_RESULT([$PYTHON_CXXFLAGS])
120 CPPFLAGS="$CPPFLAGS $PYTHON_CXXFLAGS"
121 AC_CHECK_HEADER([Python.h], [cvc4_build_python_bindings=yes], [binding_error=yes])
124 AC_MSG_RESULT([ruby support will be built])
125 AC_ARG_VAR(RUBY_CPPFLAGS, [flags to pass to compiler when building ruby bindings])
126 CPPFLAGS="$CPPFLAGS $RUBY_CPPFLAGS"
127 AC_CHECK_HEADER([ruby.h], [cvc4_build_ruby_bindings=yes], [binding_error=yes])
130 AC_MSG_RESULT([tcl support will be built])
131 AC_ARG_VAR(TCL_CPPFLAGS, [flags to pass to compiler when building tcl bindings])
132 CPPFLAGS="$CPPFLAGS $TCL_CPPFLAGS"
133 AC_CHECK_HEADER([tcl.h], [cvc4_build_tcl_bindings=yes], [binding_error=yes])
136 AC_MSG_RESULT([OCaml support will be built])
137 AC_ARG_VAR(TCL_CPPFLAGS, [flags to pass to compiler when building OCaml bindings])
138 CPPFLAGS="$CPPFLAGS $OCAML_CPPFLAGS"
139 AC_CHECK_HEADER([caml/misc.h], [cvc4_build_ocaml_bindings=yes], [binding_error=yes])
140 if test "$binding_error" = no; then
141 AC_ARG_VAR(OCAMLC, [OCaml compiler])
142 if test -z "$OCAMLC"; then
143 AC_CHECK_PROGS(OCAMLC, ocamlc, ocamlc, [])
145 AC_CHECK_PROG(OCAMLC, "$OCAMLC", "$OCAMLC", [])
147 AC_ARG_VAR(OCAMLMKTOP, [OCaml runtime-maker])
148 if test -z "$OCAMLMKTOP"; then
149 AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop, ocamlmktop, [])
151 AC_CHECK_PROG(OCAMLMKTOP, "$OCAMLMKTOP", "$OCAMLMKTOP", [])
153 AC_ARG_VAR(OCAMLFIND, [OCaml-find binary])
154 if test -z "$OCAMLFIND"; then
155 AC_CHECK_PROGS(OCAMLFIND, ocamlfind, ocamlfind, [])
157 AC_CHECK_PROG(OCAMLFIND, "$OCAMLFIND", "$OCAMLFIND", [])
159 AC_ARG_VAR(CAMLP4O, [camlp4o binary])
160 if test -z "$CAMLP4O"; then
161 AC_CHECK_PROGS(CAMLP4O, camlp4o, camlp4o, [])
163 AC_CHECK_PROG(CAMLP4O, "$CAMLP4O", "$CAMLP4O", [])
167 *) AC_MSG_RESULT([unknown binding]); binding_error=yes;;
169 if test "$binding_error" = yes; then
170 if test "$cvc4_check_for_bindings" = no; then
171 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).])
173 AC_MSG_WARN([Language binding \`$binding' cannot be built (the preceding few lines should give an indication why this is).])
176 CVC4_LANGUAGE_BINDINGS="${CVC4_LANGUAGE_BINDINGS:+$CVC4_LANGUAGE_BINDINGS }$binding"
179 CXXFLAGS="$cvc4_save_CXXFLAGS"
180 CPPFLAGS="$cvc4_save_CPPFLAGS"
183 AM_CONDITIONAL([CVC4_HAS_SWIG], [test "$SWIG"])
185 m4_foreach([lang], [CVC4_ALL_BINDINGS],
186 [AM_CONDITIONAL([CVC4_LANGUAGE_BINDING_]m4_toupper(lang), [test "$cvc4_build_]lang[_bindings" = yes])
190 AC_SUBST(CVC4_LANGUAGE_BINDINGS)
192 ])# CVC4_CHECK_BINDINGS