[sane-devel] How to find out if USB is available for compilation

Henning Meier-Geinitz henning@meier-geinitz.de
Thu, 7 Mar 2002 18:41:56 +0100


Hi,

On Wed, Mar 06, 2002 at 10:29:26PM +0100, Oliver Rauch wrote:
> I am integrating the umax-usb code from Frank Zago that adds support for the
> Astra 2200 via USB connection into the umax scsi backend (umax.c).
> 
> I want to disable the USB code when USB is not supported on the platform.

Why? Smaller code? I think that's against the philosophy of SANE.
If someone updates the kernel later to a version that supports
USB he will get in trouble.

If you use libusb for this backend, see below.

> Is there a planned way to identify if USB is available?

From the view of sanei_usb USB on Linux and the BSDs is just a file:
Status: O

wite and read data to /dev/usb/scanner (or whatever). No headers or
libraries are involved. So there is no easy way to detect if USB is
available. You could try to open the varoius USB scanner device files
as sane-find-scanner does but I don't think we should do this during
compile time.

> config.h:HAVE_USB_H seems to be the only available way to do this but
> it is defined only for linux when the comment in config.h is correct.

No, that's a documentation bug. usb.h is part of libusb so if
HAVE_USB_H is defined, that means this library is available. There is
a test in configure.in that enables the sm3600 backend if the library
is found. That's the onl backend that uses this library. All the other
backends use sanei_usb or direct access to USB device files.

> How is USB identified for openBSD and other systems?

It isn't really identified. Just open the device file and send data to
it.

Bye,
  Henning