From: Uwe Hermann Date: Wed, 2 Feb 2011 09:25:52 +0000 (+0100) Subject: Fix build when no libusb-LA is compiled. X-Git-Tag: libsigrok-0.1.0~351 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=22b02383442ec55a11cc6dd2b4c467d1de0b5bd2;p=libsigrok.git Fix build when no libusb-LA is compiled. Until now the build would break if the user doesn't enable at least one of the libusb1.0-based LAs. I.e., you could not compile only OLS, or only the demo driver. --- diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index f488cdc5..427d7905 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -23,11 +23,11 @@ * ASIX Sigma Logic Analyzer Driver */ +#include "config.h" #include #include #include #include -#include #include "asix-sigma.h" #define USB_VENDOR 0xa600 diff --git a/hardware/common/misc.c b/hardware/common/misc.c index 03fe2689..43b158ae 100644 --- a/hardware/common/misc.c +++ b/hardware/common/misc.c @@ -17,11 +17,16 @@ * along with this program. If not, see . */ +#include "config.h" #include #include +#ifdef HAVE_LIBUSB_1_0 #include +#endif #include +#ifdef HAVE_LIBUSB_1_0 + int opendev2(int device_index, struct sr_device_instance **sdi, libusb_device *dev, struct libusb_device_descriptor *des, int *skip, uint16_t vid, uint16_t pid, int interface) @@ -90,3 +95,5 @@ int opendev3(struct sr_device_instance **sdi, libusb_device *dev, return 0; } + +#endif diff --git a/hardware/saleae-logic/saleae-logic.c b/hardware/saleae-logic/saleae-logic.c index b66fd30d..a270e0b4 100644 --- a/hardware/saleae-logic/saleae-logic.c +++ b/hardware/saleae-logic/saleae-logic.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include "config.h" #include #include #include @@ -25,7 +26,6 @@ #include #include #include -#include "config.h" #define USB_VENDOR 0x0925 #define USB_PRODUCT 0x3881 diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index 0c3d25bc..ba5fd522 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include "config.h" #include #include #include @@ -24,7 +25,6 @@ #include #include #include -#include "config.h" #include "analyzer.h" #define USB_VENDOR 0x0c12 diff --git a/hwplugin.c b/hwplugin.c index 31fed10c..b1016469 100644 --- a/hwplugin.c +++ b/hwplugin.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include "config.h" #include #include #include @@ -24,7 +25,6 @@ #include #include #include -#include "config.h" /* The list of loaded plugins lives here. */ GSList *plugins; @@ -138,9 +138,11 @@ struct sr_device_instance *sr_get_device_instance(GSList *device_instances, void sr_device_instance_free(struct sr_device_instance *sdi) { switch (sdi->instance_type) { +#ifdef HAVE_LIBUSB_1_0 case SR_USB_INSTANCE: sr_usb_device_instance_free(sdi->usb); break; +#endif case SR_SERIAL_INSTANCE: sr_serial_device_instance_free(sdi->serial); break; @@ -155,6 +157,8 @@ void sr_device_instance_free(struct sr_device_instance *sdi) free(sdi); } +#ifdef HAVE_LIBUSB_1_0 + struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus, uint8_t address, struct libusb_device_handle *hdl) { @@ -178,6 +182,8 @@ void sr_usb_device_instance_free(struct sr_usb_device_instance *usb) /* Nothing to do for this device instance type. */ } +#endif + struct sr_serial_device_instance *sr_serial_device_instance_new( const char *port, int fd) { diff --git a/session.c b/session.c index ed86de3c..77326291 100644 --- a/session.c +++ b/session.c @@ -17,13 +17,13 @@ * along with this program. If not, see . */ +#include "config.h" #include #include #include #include #include #include -#include /* demo.c */ extern GIOChannel channels[2]; diff --git a/session_file.c b/session_file.c index 88dfe4f5..d6480b68 100644 --- a/session_file.c +++ b/session_file.c @@ -17,14 +17,13 @@ * along with this program. If not, see . */ +#include "config.h" #include #include #include #include #include #include -#include - extern struct session *session; extern struct sr_device_plugin session_driver; diff --git a/sigrok-internal.h b/sigrok-internal.h index 3de444e8..b30d417d 100644 --- a/sigrok-internal.h +++ b/sigrok-internal.h @@ -35,18 +35,22 @@ int serial_set_params(int fd, int speed, int bits, int parity, int stopbits, /*--- hardware/common/ezusb.c -----------------------------------------------*/ +#ifdef HAVE_LIBUSB_1_0 int ezusb_reset(struct libusb_device_handle *hdl, int set_clear); int ezusb_install_firmware(libusb_device_handle *hdl, char *filename); int ezusb_upload_firmware(libusb_device *dev, int configuration, const char *filename); +#endif /*--- hardware/common/misc.c ------------------------------------------------*/ +#ifdef HAVE_LIBUSB_1_0 int opendev2(int device_index, struct sr_device_instance **sdi, libusb_device *dev, struct libusb_device_descriptor *des, int *skip, uint16_t vid, uint16_t pid, int interface); int opendev3(struct sr_device_instance **sdi, libusb_device *dev, struct libusb_device_descriptor *des, uint16_t vid, uint16_t pid, int interface); +#endif #endif diff --git a/sigrok-proto.h b/sigrok-proto.h index f6187a91..57b899df 100644 --- a/sigrok-proto.h +++ b/sigrok-proto.h @@ -71,9 +71,11 @@ struct sr_device_instance *sr_get_device_instance(GSList *device_instances, void sr_device_instance_free(struct sr_device_instance *sdi); /* USB-specific instances */ +#ifdef HAVE_LIBUSB_1_0 struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus, uint8_t address, struct libusb_device_handle *hdl); void sr_usb_device_instance_free(struct sr_usb_device_instance *usb); +#endif /* Serial-specific instances */ struct sr_serial_device_instance *sr_serial_device_instance_new( diff --git a/sigrok.h b/sigrok.h index 59ab45b5..983246bb 100644 --- a/sigrok.h +++ b/sigrok.h @@ -25,7 +25,9 @@ #include #include #include +#ifdef HAVE_LIBUSB_1_0 #include +#endif #ifdef __cplusplus extern "C" { @@ -262,11 +264,13 @@ enum { SR_SERIAL_INSTANCE, }; +#ifdef HAVE_LIBUSB_1_0 struct sr_usb_device_instance { uint8_t bus; uint8_t address; struct libusb_device_handle *devhdl; }; +#endif struct sr_serial_device_instance { char *port;