libusb-1.0 support
[openocd.git] / configure.ac
index d0386bc..f061170 100644 (file)
@@ -486,6 +486,10 @@ AC_ARG_ENABLE(internal-jimtcl,
   AS_HELP_STRING([--disable-internal-jimtcl], [Disable building internal jimtcl]),
   [use_internal_jimtcl=$enableval], [use_internal_jimtcl=yes])
 
+AC_ARG_ENABLE(libusb0,
+  AS_HELP_STRING([--enable-libusb0], [Use libusb-0.1 library for USB JTAG devices]),
+  [check_libusb0=$enableval], [check_libusb0=no])
+
 build_minidriver=no
 AC_MSG_CHECKING([whether to enable ZY1000 minidriver])
 if test $build_zy1000 = yes; then
@@ -1055,11 +1059,28 @@ build_usb=no
 if test $build_jlink = yes -o $build_vsllink = yes -o $build_usbprog = yes -o \
   $build_rlink = yes -o $build_ulink = yes -o $build_armjtagew = yes
 then
-  AC_CHECK_HEADERS([usb.h],[],
-  [AC_MSG_ERROR([usb.h is required to build some OpenOCD driver(s)])])
   build_usb=yes
 fi
 
+# Check for libusb1 ported drivers.
+build_usb_ng=no
+
+# check for libusb library if necessary
+use_libusb0=no
+use_libusb1=no
+if test $build_usb = yes -o $build_usb_ng = yes; then
+  if test $check_libusb0 = no -a $build_usb_ng = yes; then
+       AC_CHECK_HEADERS(libusb-1.0/libusb.h,
+                       [AC_DEFINE(HAVE_LIBUSB1, 1, [Define if you have libusb-1.0]) check_libusb0=no use_libusb1=yes ],
+                       [ check_libusb0=yes use_libusb1=no ])
+  fi
+
+  if test $check_libusb0 = yes -o $build_usb = yes; then
+       AC_CHECK_HEADERS(usb.h, [use_libusb0=yes],
+                       [AC_MSG_ERROR([libusb or libusb-1.0 are required to build some OpenOCD driver(s)])])
+  fi
+fi
+
 AM_CONDITIONAL(RELEASE, test $build_release = yes)
 AM_CONDITIONAL(PARPORT, test $build_parport = yes)
 AM_CONDITIONAL(DUMMY, test $build_dummy = yes)
@@ -1089,6 +1110,9 @@ AM_CONDITIONAL(ARMJTAGEW, test $build_armjtagew = yes)
 AM_CONDITIONAL(REMOTE_BITBANG, test $build_remote_bitbang = yes)
 AM_CONDITIONAL(BUSPIRATE, test $build_buspirate = yes)
 AM_CONDITIONAL(USB, test $build_usb = yes)
+AM_CONDITIONAL(USB_NG, test $build_usb_ng = yes)
+AM_CONDITIONAL(USE_LIBUSB0, test $use_libusb0 = yes)
+AM_CONDITIONAL(USE_LIBUSB1, test $use_libusb1 = yes)
 AM_CONDITIONAL(IS_CYGWIN, test $is_cygwin = yes)
 AM_CONDITIONAL(IS_MINGW, test $is_mingw = yes)
 AM_CONDITIONAL(IS_WIN32, test $is_win32 = yes)