From a37a65882a40470b4de9b4cb85da63515d7f77c5 Mon Sep 17 00:00:00 2001
From: debrouxl <lionel_debroux@yahoo.fr>
Date: Tue, 8 Feb 2011 12:16:07 +0100
Subject: libticables: add autotools infrastructure for building against libusb 1.0.

---
 libticables/trunk/Makefile.in               |    2 +
 libticables/trunk/build/mingw/Makefile.in   |    2 +
 libticables/trunk/config.h.in               |    5 +-
 libticables/trunk/configure                 |  231 ++++++++++++++++++++-------
 libticables/trunk/configure.ac              |   55 ++++++-
 libticables/trunk/docs/Makefile.in          |    2 +
 libticables/trunk/src/Makefile.in           |    2 +
 libticables/trunk/src/win32/dha/Makefile.in |    2 +
 libticables/trunk/src/win64/rwp/Makefile.in |    2 +
 libticables/trunk/tests/Makefile.in         |    2 +
 10 files changed, 235 insertions(+), 70 deletions(-)

diff --git a/libticables/trunk/Makefile.in b/libticables/trunk/Makefile.in
index 8c67326..f14ad16 100644
--- a/libticables/trunk/Makefile.in
+++ b/libticables/trunk/Makefile.in
@@ -180,6 +180,8 @@ LIBINTL = @LIBINTL@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBUSB10_CFLAGS = @LIBUSB10_CFLAGS@
+LIBUSB10_LIBS = @LIBUSB10_LIBS@
 LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
 LIBUSB_LIBS = @LIBUSB_LIBS@
 LN_S = @LN_S@
diff --git a/libticables/trunk/build/mingw/Makefile.in b/libticables/trunk/build/mingw/Makefile.in
index 289441a..28ff3f5 100644
--- a/libticables/trunk/build/mingw/Makefile.in
+++ b/libticables/trunk/build/mingw/Makefile.in
@@ -100,6 +100,8 @@ LIBINTL = @LIBINTL@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBUSB10_CFLAGS = @LIBUSB10_CFLAGS@
+LIBUSB10_LIBS = @LIBUSB10_LIBS@
 LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
 LIBUSB_LIBS = @LIBUSB_LIBS@
 LN_S = @LN_S@
diff --git a/libticables/trunk/config.h.in b/libticables/trunk/config.h.in
index 9a5bef8..1c1554b 100644
--- a/libticables/trunk/config.h.in
+++ b/libticables/trunk/config.h.in
@@ -41,9 +41,12 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 to enable libusb support. */
+/* Define to 1 to enable libusb 0.1.x support. */
 #undef HAVE_LIBUSB
 
+/* Define to 1 to enable libusb 1.0.x support. */
+#undef HAVE_LIBUSB_1_0
+
 /* Define to 1 if you have the <linux/parport.h> header file. */
 #undef HAVE_LINUX_PARPORT_H
 
diff --git a/libticables/trunk/configure b/libticables/trunk/configure
index f5fd22e..6aa1cfe 100755
--- a/libticables/trunk/configure
+++ b/libticables/trunk/configure
@@ -756,6 +756,8 @@ LTLIBOBJS
 OS_WIN32_FALSE
 OS_WIN32_TRUE
 LIBOBJS
+LIBUSB10_LIBS
+LIBUSB10_CFLAGS
 LIBUSB_LIBS
 LIBUSB_CFLAGS
 GLIB_LIBS
@@ -912,6 +914,7 @@ enable_rpath
 with_libiconv_prefix
 with_libintl_prefix
 enable_libusb
+enable_libusb10
 enable_logging
 '
       ac_precious_vars='build_alias
@@ -935,7 +938,9 @@ PKG_CONFIG_LIBDIR
 GLIB_CFLAGS
 GLIB_LIBS
 LIBUSB_CFLAGS
-LIBUSB_LIBS'
+LIBUSB_LIBS
+LIBUSB10_CFLAGS
+LIBUSB10_LIBS'
 
 
 # Initialize some variables set by options.
@@ -1567,7 +1572,8 @@ Optional Features:
   --disable-libtool-lock  avoid locking (might break parallel builds)
   --disable-nls           do not use Native Language Support
   --disable-rpath         do not hardcode runtime library paths
-  --disable-libusb        disable USB support
+  --disable-libusb        disable USB support through libusb 0.1.x
+  --disable-libusb10      disable USB support through libusb 1.0.x
   --enable-logging        enable logging
 
 Optional Packages:
@@ -1607,6 +1613,10 @@ Some influential environment variables:
   LIBUSB_CFLAGS
               C compiler flags for LIBUSB, overriding pkg-config
   LIBUSB_LIBS linker flags for LIBUSB, overriding pkg-config
+  LIBUSB10_CFLAGS
+              C compiler flags for LIBUSB10, overriding pkg-config
+  LIBUSB10_LIBS
+              linker flags for LIBUSB10, overriding pkg-config
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -4946,7 +4956,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 4949 "configure"' > conftest.$ac_ext
+  echo '#line 4959 "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7641,11 +7651,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7644: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7654: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7648: \$? = $ac_status" >&5
+   echo "$as_me:7658: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -7931,11 +7941,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7934: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7944: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7938: \$? = $ac_status" >&5
+   echo "$as_me:7948: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8035,11 +8045,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8038: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8048: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8042: \$? = $ac_status" >&5
+   echo "$as_me:8052: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -10073,7 +10083,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 10076 "configure"
+#line 10086 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10173,7 +10183,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 10176 "configure"
+#line 10186 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12514,11 +12524,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:12517: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:12527: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:12521: \$? = $ac_status" >&5
+   echo "$as_me:12531: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -12618,11 +12628,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:12621: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:12631: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:12625: \$? = $ac_status" >&5
+   echo "$as_me:12635: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -14216,11 +14226,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14219: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14229: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:14223: \$? = $ac_status" >&5
+   echo "$as_me:14233: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -14320,11 +14330,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14323: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14333: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:14327: \$? = $ac_status" >&5
+   echo "$as_me:14337: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -16494,11 +16504,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16497: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16507: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16501: \$? = $ac_status" >&5
+   echo "$as_me:16511: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -16784,11 +16794,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16787: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16797: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16791: \$? = $ac_status" >&5
+   echo "$as_me:16801: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -16888,11 +16898,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16891: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16901: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:16895: \$? = $ac_status" >&5
+   echo "$as_me:16905: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -22185,6 +22195,7 @@ $as_echo "#define HAVE_DCGETTEXT 1" >>confdefs.h
 
 
 
+# Call explicitely before using PKG_*
 
 
 
@@ -22305,6 +22316,7 @@ $as_echo "no" >&6; }
 	fi
 fi
 
+
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLIB" >&5
 $as_echo_n "checking for GLIB... " >&6; }
@@ -22404,8 +22416,8 @@ else
   cab_cv_use_libusb=yes
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to disable USB" >&5
-$as_echo_n "checking whether to disable USB... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable USB through libusb 0.1.x" >&5
+$as_echo_n "checking whether to enable USB through libusb 0.1.x... " >&6; }
 if test "${cab_cv_use_libusb+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
@@ -22413,7 +22425,33 @@ else
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cab_cv_use_libusb" >&5
 $as_echo "$cab_cv_use_libusb" >&6; }
-if test x$cab_cv_use_libusb = xyes; then
+
+# Check whether --enable-libusb10 was given.
+if test "${enable_libusb10+set}" = set; then :
+  enableval=$enable_libusb10; cab_cv_use_libusb10=$enableval
+else
+  cab_cv_use_libusb10=yes
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable USB through libusb 1.0.x" >&5
+$as_echo_n "checking whether to enable USB through libusb 1.0.x... " >&6; }
+if test "${cab_cv_use_libusb10+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cab_cv_use_libusb10=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cab_cv_use_libusb10" >&5
+$as_echo "$cab_cv_use_libusb10" >&6; }
+
+if test "x$cab_cv_use_libusb" = xyes; then :
+  if test "x$cab_cv_use_libusb10" = xyes; then :
+  as_fn_error $? "cannot enable both libusb 0.1.x support and libusb 1.0.x support !" "$LINENO" 5
+
+fi
+
+fi
+
+if test "x$cab_cv_use_libusb" = xyes; then
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBUSB" >&5
@@ -22423,12 +22461,12 @@ if test -n "$LIBUSB_CFLAGS"; then
     pkg_cv_LIBUSB_CFLAGS="$LIBUSB_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb >= 0.1.10\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "libusb >= 0.1.10") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libusb >= 0.1.12 \""; } >&5
+  ($PKG_CONFIG --exists --print-errors " libusb >= 0.1.12 ") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_LIBUSB_CFLAGS=`$PKG_CONFIG --cflags "libusb >= 0.1.10" 2>/dev/null`
+  pkg_cv_LIBUSB_CFLAGS=`$PKG_CONFIG --cflags " libusb >= 0.1.12 " 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -22439,12 +22477,12 @@ if test -n "$LIBUSB_LIBS"; then
     pkg_cv_LIBUSB_LIBS="$LIBUSB_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb >= 0.1.10\""; } >&5
-  ($PKG_CONFIG --exists --print-errors "libusb >= 0.1.10") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libusb >= 0.1.12 \""; } >&5
+  ($PKG_CONFIG --exists --print-errors " libusb >= 0.1.12 ") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_LIBUSB_LIBS=`$PKG_CONFIG --libs "libusb >= 0.1.10" 2>/dev/null`
+  pkg_cv_LIBUSB_LIBS=`$PKG_CONFIG --libs " libusb >= 0.1.12 " 2>/dev/null`
 else
   pkg_failed=yes
 fi
@@ -22464,52 +22502,123 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libusb >= 0.1.10" 2>&1`
+	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors " libusb >= 0.1.12 " 2>&1`
         else
-	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --print-errors "libusb >= 0.1.10" 2>&1`
+	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --print-errors " libusb >= 0.1.12 " 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$LIBUSB_PKG_ERRORS" >&5
 
-	as_fn_error $? "Package requirements (libusb >= 0.1.10) were not met:
-
-$LIBUSB_PKG_ERRORS
-
-Consider adjusting the PKG_CONFIG_PATH environment variable if you
-installed software in a non-standard prefix.
-
-Alternatively, you may set the environment variables LIBUSB_CFLAGS
-and LIBUSB_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details." "$LINENO" 5
+	have_libusb=no
 elif test $pkg_failed = untried; then
      	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "The pkg-config script could not be found or is too old.  Make sure it
-is in your PATH or set the PKG_CONFIG environment variable to the full
-path to pkg-config.
-
-Alternatively, you may set the environment variables LIBUSB_CFLAGS
-and LIBUSB_LIBS to avoid the need to call pkg-config.
-See the pkg-config man page for more details.
-
-To get pkg-config, see <http://pkg-config.freedesktop.org/>.
-See \`config.log' for more details" "$LINENO" 5 ; }
+	have_libusb=no
 else
 	LIBUSB_CFLAGS=$pkg_cv_LIBUSB_CFLAGS
 	LIBUSB_LIBS=$pkg_cv_LIBUSB_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-
+	have_libusb=yes
 fi
+  if test "$have_libusb" = "yes"; then
+    CFLAGS="$CFLAGS $LIBUSB_CFLAGS"
+    USB_LIBS="$USB_LIBS $LIBUSB_LIBS"
+    HAVE_USB=yes
 
 $as_echo "#define HAVE_LIBUSB 1" >>confdefs.h
 
+  else
+    LIBUSB_CFLAGS=
+    LIBUSB_LIBS=
+  fi
+fi
+
+if test "x$cab_cv_use_libusb10" = xyes; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBUSB10" >&5
+$as_echo_n "checking for LIBUSB10... " >&6; }
+
+if test -n "$LIBUSB10_CFLAGS"; then
+    pkg_cv_LIBUSB10_CFLAGS="$LIBUSB10_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libusb-1.0 >= 1.0.0 \""; } >&5
+  ($PKG_CONFIG --exists --print-errors " libusb-1.0 >= 1.0.0 ") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_LIBUSB10_CFLAGS=`$PKG_CONFIG --cflags " libusb-1.0 >= 1.0.0 " 2>/dev/null`
 else
-  LIBUSB_CFLAGS=
-  LIBUSB_LIBS=
+  pkg_failed=yes
 fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$LIBUSB10_LIBS"; then
+    pkg_cv_LIBUSB10_LIBS="$LIBUSB10_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libusb-1.0 >= 1.0.0 \""; } >&5
+  ($PKG_CONFIG --exists --print-errors " libusb-1.0 >= 1.0.0 ") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_LIBUSB10_LIBS=`$PKG_CONFIG --libs " libusb-1.0 >= 1.0.0 " 2>/dev/null`
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        LIBUSB10_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors " libusb-1.0 >= 1.0.0 " 2>&1`
+        else
+	        LIBUSB10_PKG_ERRORS=`$PKG_CONFIG --print-errors " libusb-1.0 >= 1.0.0 " 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$LIBUSB10_PKG_ERRORS" >&5
+
+	have_libusb10=no
+elif test $pkg_failed = untried; then
+     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+	have_libusb10=no
+else
+	LIBUSB10_CFLAGS=$pkg_cv_LIBUSB10_CFLAGS
+	LIBUSB10_LIBS=$pkg_cv_LIBUSB10_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	have_libusb10=yes
+fi
+  if test "$have_libusb10" = "yes"; then
+    CFLAGS="$CFLAGS $LIBUSB10_CFLAGS"
+    USB_LIBS="$USB_LIBS $LIBUSB10_LIBS"
+    HAVE_USB=yes
+
+$as_echo "#define HAVE_LIBUSB_1_0 1" >>confdefs.h
+
+  else
+    LIBUSB10_CFLAGS=
+    LIBUSB10_LIBS=
+  fi
+fi
+
+
+
 
 
 
diff --git a/libticables/trunk/configure.ac b/libticables/trunk/configure.ac
index 01f6c15..ada750c 100644
--- a/libticables/trunk/configure.ac
+++ b/libticables/trunk/configure.ac
@@ -63,25 +63,64 @@ AC_CHECK_TOOL(RC, windres, windres)
 AM_GNU_GETTEXT(external)
 AM_GNU_GETTEXT_VERSION([0.16])
 
+# Call explicitely before using PKG_*
+PKG_PROG_PKG_CONFIG
+
 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.4.0)
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 
 # USB cable support
 AC_ARG_ENABLE(libusb,
-  AC_HELP_STRING([--disable-libusb], [disable USB support]),
+  AC_HELP_STRING([--disable-libusb], [disable USB support through libusb 0.1.x]),
   [cab_cv_use_libusb=$enableval], [cab_cv_use_libusb=yes])
-AC_CACHE_CHECK([whether to disable USB],
+AC_CACHE_CHECK([whether to enable USB through libusb 0.1.x],
   [cab_cv_use_libusb], [cab_cv_use_libusb=no])
-if test x$cab_cv_use_libusb = xyes; then
-  PKG_CHECK_MODULES(LIBUSB, libusb >= 0.1.10)
-  AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 to enable libusb support.])
-else
-  LIBUSB_CFLAGS=
-  LIBUSB_LIBS=
+
+AC_ARG_ENABLE(libusb10,
+  AC_HELP_STRING([--disable-libusb10], [disable USB support through libusb 1.0.x]),
+  [cab_cv_use_libusb10=$enableval], [cab_cv_use_libusb10=yes])
+AC_CACHE_CHECK([whether to enable USB through libusb 1.0.x],
+  [cab_cv_use_libusb10], [cab_cv_use_libusb10=no])
+
+AS_IF([test "x$cab_cv_use_libusb" = xyes],
+  AS_IF([test "x$cab_cv_use_libusb10" = xyes],
+    AC_MSG_ERROR([cannot enable both libusb 0.1.x support and libusb 1.0.x support !])
+  )
+)
+
+if test "x$cab_cv_use_libusb" = xyes; then
+  dnl Try libusb-0.1
+  PKG_CHECK_MODULES(LIBUSB, [ libusb >= 0.1.12 ], have_libusb=yes, have_libusb=no)
+  if test "$have_libusb" = "yes"; then
+    CFLAGS="$CFLAGS $LIBUSB_CFLAGS"
+    USB_LIBS="$USB_LIBS $LIBUSB_LIBS"
+    HAVE_USB=yes
+    AC_DEFINE(HAVE_LIBUSB, 1, [Define to 1 to enable libusb 0.1.x support.])
+  else
+    LIBUSB_CFLAGS=
+    LIBUSB_LIBS=
+  fi
 fi
+
+if test "x$cab_cv_use_libusb10" = xyes; then
+  dnl Try libusb-1.0
+  PKG_CHECK_MODULES(LIBUSB10, [ libusb-1.0 >= 1.0.0 ], have_libusb10=yes, have_libusb10=no)
+  if test "$have_libusb10" = "yes"; then
+    CFLAGS="$CFLAGS $LIBUSB10_CFLAGS"
+    USB_LIBS="$USB_LIBS $LIBUSB10_LIBS"
+    HAVE_USB=yes
+    AC_DEFINE(HAVE_LIBUSB_1_0, 1, [Define to 1 to enable libusb 1.0.x support.])
+  else
+    LIBUSB10_CFLAGS=
+    LIBUSB10_LIBS=
+  fi
+fi
+
 AC_SUBST(LIBUSB_CFLAGS)
 AC_SUBST(LIBUSB_LIBS)
+AC_SUBST(LIBUSB10_CFLAGS)
+AC_SUBST(LIBUSB10_LIBS)
 
 # Checks for header files.
 AC_HEADER_DIRENT
diff --git a/libticables/trunk/docs/Makefile.in b/libticables/trunk/docs/Makefile.in
index 9d88580..24f287e 100644
--- a/libticables/trunk/docs/Makefile.in
+++ b/libticables/trunk/docs/Makefile.in
@@ -98,6 +98,8 @@ LIBINTL = @LIBINTL@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBUSB10_CFLAGS = @LIBUSB10_CFLAGS@
+LIBUSB10_LIBS = @LIBUSB10_LIBS@
 LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
 LIBUSB_LIBS = @LIBUSB_LIBS@
 LN_S = @LN_S@
diff --git a/libticables/trunk/src/Makefile.in b/libticables/trunk/src/Makefile.in
index a00bcbf..28a4984 100644
--- a/libticables/trunk/src/Makefile.in
+++ b/libticables/trunk/src/Makefile.in
@@ -203,6 +203,8 @@ LIBINTL = @LIBINTL@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBUSB10_CFLAGS = @LIBUSB10_CFLAGS@
+LIBUSB10_LIBS = @LIBUSB10_LIBS@
 LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
 LIBUSB_LIBS = @LIBUSB_LIBS@
 LN_S = @LN_S@
diff --git a/libticables/trunk/src/win32/dha/Makefile.in b/libticables/trunk/src/win32/dha/Makefile.in
index 6a7937e..414e175 100644
--- a/libticables/trunk/src/win32/dha/Makefile.in
+++ b/libticables/trunk/src/win32/dha/Makefile.in
@@ -169,6 +169,8 @@ LIBINTL = @LIBINTL@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBUSB10_CFLAGS = @LIBUSB10_CFLAGS@
+LIBUSB10_LIBS = @LIBUSB10_LIBS@
 LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
 LIBUSB_LIBS = @LIBUSB_LIBS@
 LN_S = @LN_S@
diff --git a/libticables/trunk/src/win64/rwp/Makefile.in b/libticables/trunk/src/win64/rwp/Makefile.in
index 4a4f240..8123b75 100644
--- a/libticables/trunk/src/win64/rwp/Makefile.in
+++ b/libticables/trunk/src/win64/rwp/Makefile.in
@@ -169,6 +169,8 @@ LIBINTL = @LIBINTL@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBUSB10_CFLAGS = @LIBUSB10_CFLAGS@
+LIBUSB10_LIBS = @LIBUSB10_LIBS@
 LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
 LIBUSB_LIBS = @LIBUSB_LIBS@
 LN_S = @LN_S@
diff --git a/libticables/trunk/tests/Makefile.in b/libticables/trunk/tests/Makefile.in
index fa076bb..587e799 100644
--- a/libticables/trunk/tests/Makefile.in
+++ b/libticables/trunk/tests/Makefile.in
@@ -119,6 +119,8 @@ LIBINTL = @LIBINTL@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBUSB10_CFLAGS = @LIBUSB10_CFLAGS@
+LIBUSB10_LIBS = @LIBUSB10_LIBS@
 LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
 LIBUSB_LIBS = @LIBUSB_LIBS@
 LN_S = @LN_S@
-- 
1.7.4.2.g597a6

