configure.ac: libserialport is optional.
Disable drivers that need serial port support if libserialport is not found. Also, disable building various other serial port related code in that case.
This commit is contained in:
parent
0dcb0c981e
commit
c4f2dfd0f0
24
configure.ac
24
configure.ac
|
@ -251,10 +251,26 @@ PKG_CHECK_MODULES([libzip], [libzip >= 0.10],
|
|||
[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.
|
||||
|
@ -566,7 +582,7 @@ echo "Detected libraries:"
|
|||
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)"
|
||||
|
|
4
device.c
4
device.c
|
@ -299,6 +299,8 @@ SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_dev_inst *usb)
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBSERIALPORT
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
|
@ -346,6 +348,8 @@ SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial)
|
|||
g_free(serial);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the list of devices/instances of the specified driver.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,11 @@ SUBDIRS = dmm
|
|||
# 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
|
||||
|
|
|
@ -254,6 +254,7 @@ static gboolean flags_valid(const struct metex14_info *info)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBSERIALPORT
|
||||
SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial)
|
||||
{
|
||||
const uint8_t wbuf = 'D';
|
||||
|
@ -262,6 +263,7 @@ SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial)
|
|||
|
||||
return (serial_write(serial, &wbuf, 1) == 1) ? SR_OK : SR_ERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
SR_PRIV gboolean sr_metex14_packet_valid(const uint8_t *buf)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,9 @@
|
|||
#ifdef HAVE_LIBUSB_1_0
|
||||
#include <libusb.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIBSERIALPORT
|
||||
#include <serialport.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file
|
||||
|
@ -65,6 +67,7 @@ struct sr_usb_dev_inst {
|
|||
};
|
||||
#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
|
||||
|
@ -74,6 +77,7 @@ struct sr_serial_dev_inst {
|
|||
int fd;
|
||||
struct sp_port *data;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Private driver context. */
|
||||
struct drv_context {
|
||||
|
@ -108,10 +112,12 @@ SR_PRIV GSList *sr_usb_find_usbtmc(libusb_context *usb_ctx);
|
|||
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 ------------------------------------------------------------*/
|
||||
|
@ -137,9 +143,11 @@ typedef void (*std_dev_clear_t)(void *priv);
|
|||
|
||||
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,
|
||||
|
@ -147,6 +155,7 @@ 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,
|
||||
|
@ -172,6 +181,7 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
|
|||
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 -----------------------------------------------*/
|
||||
|
||||
|
@ -298,7 +308,9 @@ struct metex14_info {
|
|||
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);
|
||||
|
|
10
std.c
10
std.c
|
@ -101,6 +101,8 @@ SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi,
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBSERIALPORT
|
||||
|
||||
/*
|
||||
* Standard sr_session_stop() API helper.
|
||||
*
|
||||
|
@ -163,6 +165,8 @@ SR_PRIV int std_dev_acquisition_stop_serial(struct sr_dev_inst *sdi,
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Standard driver dev_clear() helper.
|
||||
*
|
||||
|
@ -203,10 +207,12 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
|
|||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue