Disable drivers that need serial port support if libserialport is not found.
Also, disable building various other serial port related code in that case.
[CFLAGS="$CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
SR_PKGLIBS="$SR_PKGLIBS libzip"])
-# libserialport is always needed. Abort if it's not found.
+# libserialport is only needed for some hardware drivers. Disable the
+# respective drivers if it is not found.
PKG_CHECK_MODULES([libserialport], [libserialport >= 0.1],
- [CFLAGS="$CFLAGS $libserialport_CFLAGS"; LIBS="$LIBS $libserialport_LIBS";
- SR_PKGLIBS="$SR_PKGLIBS libserialport"])
+ [have_libserialport="yes"; CFLAGS="$CFLAGS $libserialport_CFLAGS";
+ LIBS="$LIBS $libserialport_LIBS";
+ SR_PKGLIBS="$SR_PKGLIBS libserialport"],
+ [have_libserialport="no"; HW_AGILENT_DMM="no"; HW_BRYMEN_DMM="no";
+ HW_CEM_DT_885X="no"; HW_CENTER_3XX="no"; HW_COLEAD_SLM="no";
+ HW_FLUKE_DMM="no"; HW_LINK_MSO19="no"; HW_MIC_985XX="no";
+ HW_NORMA_DMM="no"; HW_OLS="no"; HW_RIGOL_DS1XX2="no";
+ HW_SERIAL_DMM="no"; HW_TELEINFO="no"; HW_TONDAJ_SL_814="no"])
+
+# Define HAVE_LIBSERIALPORT in config.h if we found libserialport.
+if test "x$have_libserialport" != "xno"; then
+ AC_DEFINE_UNQUOTED(HAVE_LIBSERIALPORT, [1],
+ [Specifies whether we have libserialport.])
+fi
+
+# Serial port helper code is only compiled in if libserialport was found.
+AM_CONDITIONAL(NEED_SERIAL, test "x$have_libserialport" != xno)
# libusb-1.0 is only needed for some hardware drivers. Disable the respective
# drivers if it is not found.
echo
# Note: This only works for libs with pkg-config integration.
-for lib in "glib-2.0 >= 2.32.0" "libzip >= 0.10" "libusb-1.0 >= 1.0.9" "libftdi >= 0.16" "libudev >= 151" "alsa >= 1.0" "check >= 0.9.4"; do
+for lib in "glib-2.0 >= 2.32.0" "libzip >= 0.10" "libserialport >= 0.1" "libusb-1.0 >= 1.0.9" "libftdi >= 0.16" "libudev >= 151" "alsa >= 1.0" "check >= 0.9.4"; do
if `$PKG_CONFIG --exists $lib`; then
ver=`$PKG_CONFIG --modversion $lib`
answer="yes ($ver)"
#endif
+#ifdef HAVE_LIBSERIALPORT
+
/**
* @private
*
g_free(serial);
}
+#endif
+
/**
* Get the list of devices/instances of the specified driver.
*
# Local lib, this is NOT meant to be installed!
noinst_LTLIBRARIES = libsigrok_hw_common.la
-libsigrok_hw_common_la_SOURCES = serial.c
+libsigrok_hw_common_la_SOURCES =
+
+if NEED_SERIAL
+libsigrok_hw_common_la_SOURCES += serial.c
+endif
if NEED_USB
libsigrok_hw_common_la_SOURCES += ezusb.c usb.c
return TRUE;
}
+#ifdef HAVE_LIBSERIALPORT
SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial)
{
const uint8_t wbuf = 'D';
return (serial_write(serial, &wbuf, 1) == 1) ? SR_OK : SR_ERR;
}
+#endif
SR_PRIV gboolean sr_metex14_packet_valid(const uint8_t *buf)
{
#ifdef HAVE_LIBUSB_1_0
#include <libusb.h>
#endif
+#ifdef HAVE_LIBSERIALPORT
#include <serialport.h>
+#endif
/**
* @file
};
#endif
+#ifdef HAVE_LIBSERIALPORT
#define SERIAL_PARITY_NONE SP_PARITY_NONE
#define SERIAL_PARITY_EVEN SP_PARITY_EVEN
#define SERIAL_PARITY_ODD SP_PARITY_ODD
int fd;
struct sp_port *data;
};
+#endif
/* Private driver context. */
struct drv_context {
SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_dev_inst *usb);
#endif
+#ifdef HAVE_LIBSERIALPORT
/* Serial-specific instances */
SR_PRIV struct sr_serial_dev_inst *sr_serial_dev_inst_new(const char *port,
const char *serialcomm);
SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial);
+#endif
/*--- hwdriver.c ------------------------------------------------------------*/
SR_PRIV int std_init(struct sr_context *sr_ctx, struct sr_dev_driver *di,
const char *prefix);
+#ifdef HAVE_LIBSERIALPORT
SR_PRIV int std_dev_acquisition_stop_serial(struct sr_dev_inst *sdi,
void *cb_data, dev_close_t dev_close_fn,
struct sr_serial_dev_inst *serial, const char *prefix);
+#endif
SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi,
const char *prefix);
SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
/*--- hardware/common/serial.c ----------------------------------------------*/
+#ifdef HAVE_LIBSERIALPORT
enum {
SERIAL_RDWR = 1,
SERIAL_RDONLY = 2,
uint8_t *buf, size_t *buflen,
size_t packet_size, packet_valid_t is_valid,
uint64_t timeout_ms, int baudrate);
+#endif
/*--- hardware/common/ezusb.c -----------------------------------------------*/
gboolean is_unitless;
};
+#ifdef HAVE_LIBSERIALPORT
SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial);
+#endif
SR_PRIV gboolean sr_metex14_packet_valid(const uint8_t *buf);
SR_PRIV int sr_metex14_parse(const uint8_t *buf, float *floatval,
struct sr_datafeed_analog *analog, void *info);
return SR_OK;
}
+#ifdef HAVE_LIBSERIALPORT
+
/*
* Standard sr_session_stop() API helper.
*
return SR_OK;
}
+#endif
+
/*
* Standard driver dev_clear() helper.
*
driver->dev_close(sdi);
if (sdi->conn) {
- if (sdi->inst_type == SR_INST_SERIAL)
+#if HAVE_LIBSERIALPORT
+ if (sdi->inst_type == SR_INST_SERIAL)
sr_serial_dev_inst_free(sdi->conn);
+#endif
#if HAVE_LIBUSB_1_0
- else if (sdi->inst_type == SR_INST_USB)
+ if (sdi->inst_type == SR_INST_USB)
sr_usb_dev_inst_free(sdi->conn);
#endif
}