From 084a0943a177201be36ab982a59ea3b4e0c350ee Mon Sep 17 00:00:00 2001 From: Kolja Waschk Date: Fri, 14 Dec 2007 15:31:01 +0000 Subject: [PATCH] Initial suppor for --with-libftdi/etc. options to configure, and linking with FTDI FTD2XX library in Cygwin git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@839 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 7 ++ jtag/configure.ac | 124 +++++++++++++++++++++++++--------- jtag/src/Makefile.am | 1 + jtag/src/tap/parport/ftd2xx.c | 8 ++- 4 files changed, 107 insertions(+), 33 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 4ffbc364..9e548a5d 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,10 @@ +2007-12-14 Kolja Waschk + + * README, doc/UrJTAG.txt: pointer to http://www.urjtag.org + * configure.ac, src/Makefile.am, src/tap/parport/ftd2xx.c: + Changes to allow linking against FTDI FTD2XX in Cygwin, initial + support for --with-(libftdi|libusb|ftd2xx) configure options + 2007-12-13 Kolja Waschk * configure.ac: Run "svn info" with "-R" to get latest revision diff --git a/jtag/configure.ac b/jtag/configure.ac index 6f42de2a..583b429c 100644 --- a/jtag/configure.ac +++ b/jtag/configure.ac @@ -174,43 +174,103 @@ AC_CHECK_HEADERS(linux/ppdev.h) VL_LIB_READLINE -dnl check for libftdi-config -AC_PATH_PROG(HAVELIBFTDI, libftdi-config, no) -if test "$HAVELIBFTDI" != "no" ; then -dnl LIBFTDI_CFLAGS=`$HAVELIBFTDI --cflags` - AM_CONDITIONAL(HAVE_LIBFTDI, true) - LIBFTDI_LIBS=`$HAVELIBFTDI --libs` - CFLAGS="$CFLAGS $LIBFTDI_CFLAGS" - LIBS="$LIBS $LIBFTDI_LIBS" - AC_DEFINE(HAVE_LIBFTDI, 1, [Define if you have libftdi]) -else - AM_CONDITIONAL(HAVE_LIBFTDI, false) - AC_MSG_WARN([*** libftdi-config not found. No support for FTDI-based USB JTAG cables via libftdi.]) -fi +AC_ARG_WITH([libftdi], + [AS_HELP_STRING([--with-libftdi], + [use libftdi for FTDI-based cables])], + [], [with_libftdi=check]) + +AS_IF([test "x$with_libftdi" == xyes -o "x$with_libftdi" = xcheck], [ + AC_PATH_PROG(HAVELIBFTDI, libftdi-config, no) + AS_IF([test "$HAVELIBFTDI" != "no" ],[ + dnl LIBFTDI_CFLAGS=`$HAVELIBFTDI --cflags` + AM_CONDITIONAL(HAVE_LIBFTDI, true) + LIBFTDI_LIBS=`$HAVELIBFTDI --libs` + CFLAGS="$CFLAGS $LIBFTDI_CFLAGS" + LIBS="$LIBS $LIBFTDI_LIBS" + AC_DEFINE(HAVE_LIBFTDI, 1, [Define if you have libftdi]) + ],[ + AM_CONDITIONAL(HAVE_LIBFTDI, false) + AC_MSG_WARN([*** libftdi-config not found. No support for FTDI-based USB JTAG cables via libftdi.]) + ]) +],[ + AS_IF([test "x$with_libftdi" != xno], [ + AM_CONDITIONAL(HAVE_LIBFTDI, true) + CFLAGS="$CFLAGS -I$with_libftdi -L$with_libftdi" + LIBS="$LIBS -lftdi" + AC_DEFINE(HAVE_LIBFTDI, 1, [Define if you have libftdi]) + ],[ + AM_CONDITIONAL(HAVE_LIBFTDI, false) + ]) +]) dnl check for libusb-config -AC_PATH_PROG(HAVELIBUSB, libusb-config, no) -if test "$HAVELIBUSB" != "no" ; then -dnl LIBUSB_CFLAGS=`$HAVELIBUSB --cflags` - AM_CONDITIONAL(HAVE_LIBUSB, true) - LIBUSB_LIBS=`$HAVELIBUSB --libs` - CFLAGS="$CFLAGS $LIBUSB_CFLAGS" - LIBS="$LIBS $LIBUSB_LIBS" - AC_DEFINE(HAVE_LIBUSB, 1, [Define if you have libusb]) -else - AM_CONDITIONAL(HAVE_LIBUSB, false) - AC_MSG_WARN([*** libusb-config not found. Omitting support for some USB JTAG cables.]) -fi -dnl check for availability of libftd2xx -AC_CHECK_LIB([ftd2xx], [FT_Open], [ - AM_CONDITIONAL(HAVE_LIBFTD2XX, true) - AC_DEFINE(HAVE_LIBFTD2XX, 1, [define if you have libftd2xx]) - LIBS="-lftd2xx $LIBS" +AC_ARG_WITH([libusb], + [AS_HELP_STRING([--with-libusb], + [use libusb for some USB JTAG cables])], + [], [with_libusb=check]) + +AS_IF([test "x$with_libusb" == xyes -o "x$with_libusb" == xcheck], [ + AC_PATH_PROG(HAVELIBUSB, libusb-config, no) + AS_IF([test "$HAVELIBUSB" != "no"],[ + dnl LIBUSB_CFLAGS=`$HAVELIBUSB --cflags` + AM_CONDITIONAL(HAVE_LIBUSB, true) + LIBUSB_LIBS=`$HAVELIBUSB --libs` + CFLAGS="$CFLAGS $LIBUSB_CFLAGS" + LIBS="$LIBS $LIBUSB_LIBS" + AC_DEFINE(HAVE_LIBUSB, 1, [Define if you have libusb]) + ],[ + AM_CONDITIONAL(HAVE_LIBUSB, false) + AC_MSG_WARN([*** libusb-config not found. Omitting support for some USB JTAG cables.]) + ]) +],[ + AS_IF([test "x$with_libusb" != xno], [ + AM_CONDITIONAL(HAVE_LIBUSB, true) + CFLAGS="$CFLAGS -I$with_libusb -L$with_libusb" + LIBS="$LIBS -lusb" + AC_DEFINE(HAVE_LIBUSB, 1, [Define if you have libusb]) + ],[ + AM_CONDITIONAL(HAVE_LIBUSB, false) + ]) +]) + + +dnl Use FTDI ftd2xx library? + +AC_ARG_WITH([ftd2xx], + [AS_HELP_STRING([--with-ftd2xx], + [use ftd2xx library for FTDI-based cables])], + [], [with_ftd2xx=check]) + +FTD2XXLIB= +AS_IF([test "x$with_ftd2xx" == xyes -o "x$with_ftd2xx" = xcheck], [ + AC_CHECK_LIB([ftd2xx], [FT_Open], [ + AM_CONDITIONAL(HAVE_LIBFTD2XX, true) + AC_DEFINE(HAVE_LIBFTD2XX, 1, [define if you have libftd2xx]) + LIBS="-lftd2xx $LIBS" + ],[ + AM_CONDITIONAL(HAVE_LIBFTD2XX, false) + AC_MSG_WARN([*** libftd2xx not found. No support for FTDI-based USB JTAG cables via libftd2xx.]) + ]) ],[ - AM_CONDITIONAL(HAVE_LIBFTD2XX, false) - AC_MSG_WARN([*** libftd2xx not found. No support for FTDI-based USB JTAG cables via libftd2xx.]) + AS_IF([test "x$with_ftd2xx" != xno], [ + AM_CONDITIONAL(HAVE_LIBFTD2XX, true) + AC_DEFINE(HAVE_LIBFTD2XX, 1, [define if you have libftd2xx]) + case $host in + *cygwin*) + CFLAGS="$CFLAGS -I$with_ftd2xx" + FTD2XXLIB="$with_ftd2xx/ftd2xx.lib" + ;; + *) + CFLAGS="$CFLAGS -I$with_ftd2xx -L$with_ftd2xx" + LIBS="-lftd2xx $LIBS" + ;; + esac + ],[ + AM_CONDITIONAL(HAVE_LIBFTD2XX, false) + ]) ]) +AC_SUBST(FTD2XXLIB) CFLAGS="$CFLAGS -Wall" CPPFLAGS="$CPPFLAGS -I\$(top_srcdir) -I\$(top_srcdir)/include" diff --git a/jtag/src/Makefile.am b/jtag/src/Makefile.am index e38670f7..3edb0a22 100644 --- a/jtag/src/Makefile.am +++ b/jtag/src/Makefile.am @@ -65,6 +65,7 @@ jtag_LDADD = \ -Lbus -lbus \ -Lsvf -lsvf \ -lm \ + @FTD2XXLIB@ \ @LIBINTL@ localedir = $(datadir)/locale diff --git a/jtag/src/tap/parport/ftd2xx.c b/jtag/src/tap/parport/ftd2xx.c index 6d3fad55..87afaccb 100644 --- a/jtag/src/tap/parport/ftd2xx.c +++ b/jtag/src/tap/parport/ftd2xx.c @@ -30,9 +30,13 @@ #include "sysdep.h" #include -#include #include +#if __CYGWIN__ +#include +#else +#include #include +#endif #include #include @@ -207,9 +211,11 @@ ftd2xx_generic_open( parport_t *parport ) ftd2xx_params_t *p = parport->params; FT_STATUS status; +#if !__CYGWIN__ /* Add non-standard Vid/Pid to the linux driver */ if ((status = FT_SetVIDPID(p->vendor_id, p->product_id)) != FT_OK) fprintf( stderr, "Warning: couldn't add %4.4x:%4.4x", p->vendor_id, p->product_id ); +#endif if ((status = FT_Open(0, &(p->fc))) != FT_OK) { fprintf( stderr, "Error: unable to open FTDI device: %li\n", status);