Package: libusb
Version: 0.1.10a-1
Severity: wishlist
Tags: patch

Hi!

This patch fixes FTBFS on kfreebsd-gnu.  It is already in upstream BTS.

Please remember to regenerate configure after appliing.

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: kfreebsd-i386 (i686)
Kernel: GNU/kFreeBSD 5.3-3
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C)
diff -ur libusb-0.1.10a.old/bsd.c libusb-0.1.10a/bsd.c
--- libusb-0.1.10a.old/bsd.c	2004-02-18 07:34:52.000000000 +0100
+++ libusb-0.1.10a/bsd.c	2005-03-02 19:30:05.000000000 +0100
@@ -25,6 +25,10 @@
  * 	for both read and write.
  */
 
+#if defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
+#define __FreeBSD_kernel__ __FreeBSD__
+#endif
+
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
@@ -142,7 +146,7 @@
     USB_ERROR(-ENOMEM);
   dev->impl_info = info;
 
-#if __FreeBSD__
+#ifdef __FreeBSD_kernel__
   snprintf(ctlpath, PATH_MAX, "%s", dev->device->filename);
 #else
   snprintf(ctlpath, PATH_MAX, "%s.00", dev->device->filename);
@@ -255,7 +259,7 @@
   ep = UE_GET_ADDR(ep);
 
   if (info->ep_fd[ep] < 0) {
-#if __FreeBSD__
+#ifdef __FreeBSD_kernel__
     snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->device->filename, ep);
 #else
     snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->device->filename, ep);
@@ -286,7 +290,7 @@
   fd = ensure_ep_open(dev, ep, O_WRONLY);
   if (fd < 0) {
     if (usb_debug >= 2) {
-#if __FreeBSD__
+#ifdef __FreeBSD_kernel__
       fprintf (stderr, "usb_bulk_write: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep));
 #else
       fprintf (stderr, "usb_bulk_write: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep));
@@ -302,7 +306,7 @@
 
   ret = write(fd, bytes, size);
   if (ret < 0)
-#if __FreeBSD__
+#ifdef __FreeBSD_kernel__
     USB_ERROR_STR(-errno, "error writing to bulk endpoint %s.%d: %s",
                   dev->device->filename, UE_GET_ADDR(ep), strerror(errno));
 #else
@@ -324,7 +328,7 @@
   fd = ensure_ep_open(dev, ep, O_RDONLY);
   if (fd < 0) {
     if (usb_debug >= 2) {
-#if __FreeBSD__
+#ifdef __FreeBSD_kernel__
       fprintf (stderr, "usb_bulk_read: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep));
 #else
       fprintf (stderr, "usb_bulk_read: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep));
@@ -343,7 +347,7 @@
 
   ret = read(fd, bytes, size);
   if (ret < 0)
-#if __FreeBSD__
+#ifdef __FreeBSD_kernel__
     USB_ERROR_STR(-errno, "error reading from bulk endpoint %s.%d: %s",
                   dev->device->filename, UE_GET_ADDR(ep), strerror(errno));
 #else
@@ -365,7 +369,7 @@
   fd = ensure_ep_open(dev, ep, O_WRONLY);
   if (fd < 0) {
     if (usb_debug >= 2) {
-#if __FreeBSD__
+#ifdef __FreeBSD_kernel__
       fprintf (stderr, "usb_interrupt_write: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep));
 #else
       fprintf (stderr, "usb_interrupt_write: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep));
@@ -382,7 +386,7 @@
   do {
     ret = write(fd, bytes+sent, size-sent);
     if (ret < 0)
-#if __FreeBSD__
+#ifdef __FreeBSD_kernel__
       USB_ERROR_STR(-errno, "error writing to interrupt endpoint %s.%d: %s",
                     dev->device->filename, UE_GET_ADDR(ep), strerror(errno));
 #else
@@ -407,7 +411,7 @@
   fd = ensure_ep_open(dev, ep, O_RDONLY);
   if (fd < 0) {
     if (usb_debug >= 2) {
-#if __FreeBSD__
+#ifdef __FreeBSD_kernel__
       fprintf (stderr, "usb_interrupt_read: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep));
 #else
       fprintf (stderr, "usb_interrupt_read: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep));
@@ -427,7 +431,7 @@
   do {
     ret = read(fd, bytes+retrieved, size-retrieved);
     if (ret < 0)
-#if __FreeBSD__
+#ifdef __FreeBSD_kernel__
       USB_ERROR_STR(-errno, "error reading from interrupt endpoint %s.%d: %s",
                     dev->device->filename, UE_GET_ADDR(ep), strerror(errno));
 #else
@@ -543,7 +547,7 @@
       /* best not to play with things we don't understand */
       continue;
 
-#if __FreeBSD__
+#ifdef __FreeBSD_kernel__
     snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.udi_devnames[0]);
 #else
     snprintf(buf, sizeof(buf) - 1, "/dev/%s.00", di.udi_devnames[0]);
diff -ur libusb-0.1.10a.old/configure.in libusb-0.1.10a/configure.in
--- libusb-0.1.10a.old/configure.in	2005-03-02 18:48:14.000000000 +0100
+++ libusb-0.1.10a/configure.in	2005-03-03 12:17:08.000000000 +0100
@@ -91,8 +91,8 @@
 BSD_API=0
 
 AC_MSG_CHECKING(for what USB OS support)
-case $host in
-  *-linux*)
+case $host_os in
+  linux*)
     AC_DEFINE(LINUX_API, 1)
     AC_DEFINE(BSD_API, 0)
     AC_DEFINE(DARWIN_API, 0)
@@ -101,7 +101,7 @@
     AC_MSG_RESULT(Linux)
     OSLIBS=""
     ;;
-  *-freebsd*|*-openbsd*|*-netbsd*)
+  freebsd*|kfreebsd*-gnu|openbsd*|netbsd*|knetbsd*-gnu)
     AC_DEFINE(BSD_API, 1)
     AC_DEFINE(LINUX_API, 0)
     AC_DEFINE(DARWIN_API, 0)
@@ -110,7 +110,7 @@
     AC_MSG_RESULT(FreeBSD, OpenBSD and/or NetBSD)
     OSLIBS=""
     ;;
-  *-darwin*)
+  darwin*)
     AC_DEFINE(DARWIN_API, 1) 
     AC_DEFINE(LINUX_API, 0)
     AC_DEFINE(BSD_API, 0)
@@ -191,11 +191,9 @@
 
 if test "$os_support" = "bsd"; then
   AC_MSG_CHECKING(if dev/usb/usb.h uses new naming convention)
-  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <dev/usb/usb.h>]], [[int main(void)
-     {
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <dev/usb/usb.h>]], [[
        int a = ((struct usb_ctl_request *)0L)->ucr_addr;
-       return 0;
-     }]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)
+       return 0;]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)
     AC_DEFINE_UNQUOTED(HAVE_OLD_DEV_USB_USB_H)])
 fi
 

Reply via email to