* Relicensed C++ wrapper under GPLv2 + linking exception (Marek VavruĊĦa and Intra2net)
* Support for FT2232H and FT4232H (David Challis and Intra2net)
* Support for mingw cross compile (Uwe Bonnes)
-* Minor autoconf cleanup (Tarek Heiland)
+* Python bindings and minor autoconf cleanup (Tarek Heiland)
* Code cleanup in various places (Intra2net)
* Fixed ftdi_read_chipid in some cases (Matthias Richter)
* eeprom decode function and small cleanups (Marius Kintel)
# have all needed files, that a GNU package needs
AUTOMAKE_OPTIONS = foreign 1.4
-SUBDIRS = src $(LIBFTDI_MODULES) examples doc
+SUBDIRS = src bindings $(LIBFTDI_MODULES) examples doc
EXTRA_DIST = libftdi.spec libftdi.spec.in COPYING.LIB COPYING.GPL LICENSE README AUTHORS ChangeLog libftdi-config.in CMakeLists.txt packages
--- /dev/null
+SUBDIRS = python
+
+EXTRA_DIST = ftdi.i
+
--- /dev/null
+/* File: example.i */
+%module ftdi
+%include "typemaps.i"
+%include "cpointer.i"
+%typemap(in) unsigned char* = char*;
+%ignore ftdi_write_data_async;
+%ignore ftdi_async_complete;
+
+%include ftdi.h
+%{
+#include <ftdi.h>
+%}
+
+extern "C" {
+
+%apply char *OUTPUT { unsigned char *buf };
+ int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size);
+%clear unsigned char *buf;
+%apply int *OUTPUT { unsigned int *chunksize };
+ int ftdi_read_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize);
+ int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize);
+%clear unsigned int *chunksize;
+ //int ftdi_write_data_async(struct ftdi_context *ftdi, unsigned char *buf, int size);
+ //void ftdi_async_complete(struct ftdi_context *ftdi, int wait_for_more);
+%apply char *OUTPUT { unsigned char *pins };
+ int ftdi_read_pins(struct ftdi_context *ftdi, unsigned char *pins);
+%clear unsigned char *pins;
+%apply char *OUTPUT { unsigned char *latency };
+ int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char *latency);
+%clear unsigned char *status;
+%apply char *OUTPUT { unsigned char *latency };
+ int ftdi_poll_modem_status(struct ftdi_context *ftdi, unsigned short *status);
+%clear unsigned char *status;
+%apply char *OUTPUT { unsigned char *output };
+ int ftdi_eeprom_build(struct ftdi_eeprom *eeprom, unsigned char *output);
+%clear unsigned char *output;
+%apply char *OUTPUT { unsigned char *eeprom };
+ int ftdi_read_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
+ int ftdi_write_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
+%clear unsigned char *eeprom;
+%apply int *OUTPUT { unsigned int *chipid };
+ int ftdi_read_chipid(struct ftdi_context *ftdi, unsigned int *chipid);
+%clear unsigned int *chipid;
+
+}
+
+
--- /dev/null
+
+## Process this file with automake to produce Makefile.in
+
+if HAVE_SWIG
+if HAVE_PYTHON
+if ENABLE_PYTHON_BINDING
+
+LIBFTDI_INTERFACE = $(top_srcdir)/src/ftdi.h
+SWIG_INTERFACE = ../ftdi.i
+
+BUILT_SOURCES = ftdi_wrap.c ftdi.py
+CLEANFILES = ftdi_wrap.c ftdi.py
+
+all-local: ftdi_wrap.c ftdi.py
+ @case "`uname`" in \
+ MINGW*) \
+ $(PYTHON) setup.py build --compiler=mingw32 \
+ ;; \
+ *) \
+ $(PYTHON) setup.py build \
+ ;; \
+ esac;
+
+# python on MinGW/MSYS requires pure Windows style paths
+# Using following (cd $dir && pwd -W) hack to get a nearly
+# native Windows path, then translating the forward slash
+# to a backward slash to make python distutils jolly.
+# P.S. the backslash has to be escaped thrice, hence a single
+# backslash turns into a sequence of eight (neat, huh?)
+#
+install-exec-local:
+ @case "`uname`" in \
+ MINGW*) \
+ NATIVE_WINDOWS_PREFIX="`cd $(DESTDIR)$(prefix) && pwd -W`"; \
+ NATIVE_WINDOWS_PREFIX="`echo $$NATIVE_WINDOWS_PREFIX | sed -e 's|/|\\\\\\\\|g'`"; \
+ $(PYTHON) setup.py install --prefix="$$NATIVE_WINDOWS_PREFIX" \
+ ;; \
+ *) \
+ $(PYTHON) setup.py install --prefix=$(DESTDIR)$(prefix) \
+ ;; \
+ esac;
+
+# This rule cleans up stuff installed by Python's setup.py
+# Unfortunately, Python's distutils do not provide an uninstall
+# command, so we have to make up for it here in uninstall-local
+# hook. This might break if distutils' behaviour changes as automake
+# has no control over what distutils install command does.
+#
+uninstall-local:
+ rm -rf $(DESTDIR)$(libdir)/python*/site-packages/*ftdi*
+
+clean-local:
+ $(PYTHON) setup.py clean --all
+
+ftdi_wrap.c ftdi.py: $(SWIG_INTERFACE) $(LIBFTDI_INTERFACE)
+ $(SWIG) -python -I$(top_srcdir)/src -o ftdi_wrap.c -outdir . $(srcdir)/$(SWIG_INTERFACE)
+
+
+endif # ENABLE_PYTHON_BINDING
+endif # HAVE_PYTHON
+endif # HAVE_SWIG
--- /dev/null
+# Process this file with configure to produce setup.py
+
+from distutils.core import setup, Extension
+setup(name='@PACKAGE_NAME@',
+ version='@PACKAGE_VERSION@',
+ description='libftdi Python binding',
+ author='Tarek Heiland',
+ author_email='@PACKAGE_BUGREPORT@',
+ maintainer='',
+ maintainer_email='@PACKAGE_BUGREPORT@',
+ url='',
+ py_modules=['ftdi'],
+ ext_modules=[Extension('_ftdi', ['ftdi_wrap.c'],
+ include_dirs=['@top_srcdir@/src'],
+ library_dirs=['@top_srcdir@/src/.libs','lib','/usr/lib'],
+ libraries=['ftdi'])],
+ )
AC_PATH_PROG(DOXYGEN, doxygen)
AM_CONDITIONAL(HAVE_DOXYGEN, test -n $DOXYGEN)
+dnl ============================
+dnl Bindings for other languages
+dnl ==
+
+dnl ===============
+dnl Checks for SWIG
+dnl ===============
+AC_PATH_PROG([SWIG], [swig])
+AM_CONDITIONAL(HAVE_SWIG, test "$SWIG")
+
+dnl =================
+dnl Checks for Python
+dnl =================
+AM_PATH_PYTHON([2.0],
+ [],
+ [AC_MSG_WARN([Python not found. Python is required to build presage python binding. Python can be obtained from http://www.pyth
+on.org])])
+if test "$PYTHON"
+then
+ python_include_path=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_python_inc();"`
+ AC_CHECK_HEADERS([${python_include_path}/Python.h],
+ [have_python_header=true],
+ [AC_MSG_WARN([Python.h header file not found. Python development files are required to build presage python binding. Pyt
+hon can be obtained from http://www.python.org])],
+ [])
+fi
+AM_CONDITIONAL(HAVE_PYTHON, test "$PYTHON" -a "x$have_python_header" = "xtrue")
+
+AC_ARG_ENABLE([python-binding],
+ AS_HELP_STRING([--enable-python-binding],
+ [build python binding (default=no)]),
+ [ac_enable_python_binding=$enableval],
+ [ac_enable_python_binding=no])
+if test "x$ac_enable_python_binding" = "xyes"
+then
+ if test ! "$SWIG" -o ! "$PYTHON" -o ! "x$have_python_header" = "xtrue"
+ then
+ AC_MSG_WARN([Python binding for libftdi cannot be built. Ensure that SWIG and Python packages are available.])
+ fi
+else
+ AC_MSG_NOTICE([Python binding for libftdi will not be built.])
+ AC_MSG_NOTICE([Enable Python binding module building with --enable-python-binding])
+fi
+AM_CONDITIONAL(ENABLE_PYTHON_BINDING, test "x$ac_enable_python_binding" = "xyes")
+
+if test "$SWIG" -a "$PYTHON" -a "x$have_python_header" = "xtrue" -a "x$ac_enable_python_binding" = "xyes"
+then
+ AC_MSG_NOTICE([Python binding for libftdi will be built.])
+ build_python_binding="yes"
+else
+ build_python_binding="no"
+fi
+
AC_SUBST(LIBFTDI_MODULES)
AC_SUBST(LIBFTDI_MODULES_PKGCONFIG)
AC_OUTPUT([libftdi-config],[chmod a+x libftdi-config])
-AC_OUTPUT(Makefile src/Makefile examples/Makefile doc/Doxyfile doc/Makefile libftdi.pc libftdi.spec)
+AC_OUTPUT(Makefile src/Makefile bindings/Makefile bindings/python/Makefile bindings/python/setup.py examples/Makefile doc/Doxyfile doc/Makefile libftdi.pc libftdi.spec)
if test "x$ENABLE_LIBFTDIPP" = "x1"; then
AC_OUTPUT(ftdipp/Makefile libftdipp.pc)