+# Language binding '--enable' options
+
+AC_ARG_ENABLE(bindings,
+ AC_HELP_STRING([--enable-bindings],
+ [build language bindings [default=yes]]),
+ [BINDINGS_ALL="$enableval"], [BINDINGS_ALL="yes"])
+
+AC_ARG_ENABLE(cxx,
+ AC_HELP_STRING([--enable-cxx],
+ [build C++ bindings [default=yes]]),
+ [BINDINGS_CXX="$enableval"], [BINDINGS_CXX=$BINDINGS_ALL])
+
+AC_ARG_ENABLE(python,
+ AC_HELP_STRING([--enable-python],
+ [build Python bindings [default=yes]]),
+ [BINDINGS_PYTHON="$enableval"], [BINDINGS_PYTHON=$BINDINGS_ALL])
+
+AC_ARG_ENABLE(java,
+ AC_HELP_STRING([--enable-java],
+ [build Java bindings [default=yes]]),
+ [BINDINGS_JAVA="$enableval"], [BINDINGS_JAVA=$BINDINGS_ALL])
+
+# Check if the C++ compiler supports the C++11 standard.
+
+m4_ifdef([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX_11(,[optional])],
+ [AC_MSG_NOTICE([Missing macro m4_toupper(aX_CXX_COMPILE_STDCXX_11), no C++11 check])])
+
+if test "x$HAVE_CXX11" != "x1"; then
+ BINDINGS_CXX="no"; cxx_msg="C++11 compiler required"
+fi
+
+# The C++ bindings use gccxml to parse libsigrok symbols.
+AC_CHECK_PROG([HAVE_GCCXML], [gccxml], [yes])
+if test "x$HAVE_GCCXML" != "xyes"; then
+ BINDINGS_CXX="no"; cxx_msg="gccxml required"
+fi
+
+# Python is needed for the C++ bindings.
+AC_CHECK_PROG([HAVE_PYTHON], [python], [yes])
+if test "x$HAVE_PYTHON" != "xyes"; then
+ BINDINGS_CXX="no"; cxx_msg="Python required"
+fi
+
+# The Python bindings need Python development files
+PKG_CHECK_MODULES([python], [python >= 2.7],
+ [CXXFLAGS="$CXXFLAGS $python_CFLAGS";
+ CXXLIBS="$CXXLIBS $python_LIBS"],
+ [BINDINGS_PYTHON="no"; python_msg="Python headers required"])
+
+# The C++ bindings need the pygccxml Python module.
+m4_ifdef([AX_PYTHON_MODULE], [AX_PYTHON_MODULE([pygccxml])],
+ # We'll let it go through even if the macro wasn't found, the python
+ # module may still be there.
+ [HAVE_PYTHON_PYGCCXML="yes";
+ AC_MSG_NOTICE([Missing macro m4_toupper(aX_PYTHON_MODULE), no pygccxml check])]
+)
+if test "x$HAVE_PYMOD_PYGCCXML" != "xyes"; then
+ BINDINGS_CXX="no"; cxx_msg="Python pygccxml module required"
+fi
+
+# The Python bindings need the setuptools Python module.
+m4_ifdef([AX_PYTHON_MODULE], [AX_PYTHON_MODULE([setuptools])],
+ # We'll let it go through even if the macro wasn't found, the python
+ # module may still be there.
+ [HAVE_PYTHON_SETUPTOOLS="yes";
+ AC_MSG_NOTICE([Missing macro m4_toupper(aX_PYTHON_MODULE), no setuptools check])]
+)
+if test "x$HAVE_PYMOD_SETUPTOOLS" != "xyes"; then
+ BINDINGS_PYTHON="no"; python_msg="Python setuptools module required"
+fi
+
+# The Python and Java bindings use swig to generate code.
+AC_CHECK_PROG([HAVE_SWIG], [swig], [yes])
+if test "x$HAVE_SWIG" != "xyes"; then
+ BINDINGS_PYTHON="no"; python_msg="swig required"
+ BINDINGS_JAVA="no"; java_msg="swig required"
+fi
+