-AC_MSG_CHECKING([for ftd2xx highspeed device support])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include "confdefs.h"
-#if IS_WIN32
-#include "windows.h"
-#endif
-#include <stdio.h>
-#include <ftd2xx.h>
-
-DWORD x = FT_DEVICE_4232H;
- ]], [])], [
- AC_DEFINE([BUILD_FT2232_HIGHSPEED], [1],
- [Support FT2232H/FT4232HS with FTD2XX or libftdi.])
- build_ft2232_highspeed=yes
- ], [
- build_ft2232_highspeed=no
- ])
- AC_MSG_RESULT([$build_ft2232_highspeed])
-
- if test $build_ft2232_highspeed = no; then
- AC_MSG_WARN([You need a newer FTD2XX driver (version 2.04.16 or later).])
- fi
-
-AC_MSG_CHECKING([for ftd2xx FT232H device support])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include "confdefs.h"
-#if IS_WIN32
-#include "windows.h"
-#endif
-#include <stdio.h>
-#include <ftd2xx.h>
-
-DWORD x = FT_DEVICE_232H;
- ]], [])], [
- AC_DEFINE([HAS_ENUM_FT232H], [1],
- [Support FT232H with FTD2XX or libftdi.])
- has_enum_ft232h=yes
- ], [
- has_enum_ft232h=no
- ])
- AC_MSG_RESULT([$has_enum_ft232h])
-
- if test $has_enum_ft232h = no; then
- AC_MSG_WARN([You need a newer FTD2XX driver (version 2.08.12 or later).])
- fi
-
-LDFLAGS=$LDFLAGS_SAVE
-CFLAGS=$CFLAGS_SAVE
-fi
-
-if test $build_ft2232_libftdi = yes -o $build_usb_blaster_libftdi = yes -o \
- $build_openjtag_ftdi = yes; then
- # We assume: the package is preinstalled in the proper place
- # these present as 2 libraries..
- LIBS="$LIBS -lftdi -lusb"
- #
- # Try to build a small program.
- AC_MSG_CHECKING([Build & Link with libftdi...])
-
- LDFLAGS_SAVE=$LDFLAGS
- CFLAGS_SAVE=$CFLAGS
- _LDFLAGS=`eval echo $LDFLAGS`
- _CFLAGS=`eval echo $CFLAGS`
- LDFLAGS=$_LDFLAGS
- CFLAGS=$_CFLAGS
-
- AC_RUN_IFELSE([AC_LANG_PROGRAM([[
-#include <stdio.h>
-#include <ftdi.h>
- ]], [[
- struct ftdi_context *p;
- p = ftdi_new();
- if( p != NULL ){
- return 0;
- } else {
- fprintf( stderr, "calling ftdi_new() failed\n");
- return 1;
- }
- ]])], [
- AC_MSG_RESULT([Success])
- ], [
- AC_MSG_ERROR([Cannot build & run test program using libftdi])
- ], [
- AC_MSG_RESULT([Skipping as we are cross-compiling, trying build only])
- AC_SEARCH_LIBS([ftdi_new], [], [], [AC_MSG_ERROR([Cannot link with libftdi])])
- ])
-
-AC_MSG_CHECKING([for libftdi highspeed device support])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <stdio.h>
-#include <ftdi.h>
- ]], [[
-enum ftdi_chip_type x = TYPE_2232H;
- ]])], [
- AC_DEFINE([BUILD_FT2232_HIGHSPEED], [1],
- [Support FT2232H/FT4232HS with FTD2XX or libftdi.])
- build_ft2232_highspeed=yes
- ], [
- build_ft2232_highspeed=no
- ])
- AC_MSG_RESULT([$build_ft2232_highspeed])
-
- if test $build_ft2232_highspeed = no; then
- AC_MSG_WARN([You need a newer libftdi version (0.16 or later).])
- fi
-
-AC_MSG_CHECKING([for libftdi FT232H device support])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <stdio.h>
-#include <ftdi.h>
- ]], [[
-enum ftdi_chip_type x = TYPE_232H;
- ]])], [
- AC_DEFINE([HAS_ENUM_FT232H], [1],
- [Support FT232H with FTD2XX or libftdi.])
- has_enum_ft232h=yes
- ], [
- has_enum_ft232h=no
- ])
- AC_MSG_RESULT([$has_enum_ft232h])
-
- if test $has_enum_ft232h = no; then
- AC_MSG_WARN([You need a newer libftdi version (0.20 or later).])
- fi
-
- # Restore the 'unexpanded ldflags'
- LDFLAGS=$LDFLAGS_SAVE
- CFLAGS=$CFLAGS_SAVE
-fi
-
-# check if some driver requires libusb-0.1
-need_usb0=no
-if test $build_vsllink = yes -o $build_usbprog = yes -o \
- $build_rlink = yes -o $build_ulink = yes -o $build_armjtagew = yes; then
- need_usb0=yes
-fi
-
-# check if some driver can work with either libusb version
-need_usb=no
-if test $build_jlink = yes -o $build_osbdm = yes -o $build_opendous = yes -o \
- $build_aice = yes; then
- need_usb=yes
-fi
-
-# check if some driver requires libusb-1.x
-need_usb_ng=no
-if test $build_ftdi = yes -o $build_hladapter_icdi = yes -o \
- $build_hladapter_stlink = yes; then
- need_usb_ng=yes
-fi
-
-# check for libusb library if necessary
-use_libusb1=no
-if test $need_usb = yes -o $need_usb_ng = yes; then
- AC_CHECK_HEADER([libusb-1.0/libusb.h], [
- AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
- use_libusb1=yes
- AC_SEARCH_LIBS([libusb_error_name], [usb-1.0],
- [AC_DEFINE([HAVE_LIBUSB_ERROR_NAME], [1], [Define if your libusb has libusb_error_name()])],
- [AC_MSG_WARN([libusb-1.x older than 1.0.9 detected, consider updating])])
- ], [
- if test $need_usb_ng = yes; then
- AC_MSG_ERROR([libusb-1.x is required for some driver(s) you've selected])
- else
- AC_MSG_WARN([Trying legacy libusb-0.1 as a fallback, consider installing libusb-1 instead])
- need_usb0=yes
- fi
- ])
-fi
-
-use_libusb0=no
-if test $need_usb0 = yes; then
- AC_CHECK_HEADERS([usb.h], [
- use_libusb0=yes
- ], [
- AC_MSG_ERROR([libusb-0.1 is required to build some OpenOCD driver(s)])
- ])