2011-12-30 09:42:39 +00:00
##
2013-04-23 20:24:30 +00:00
## This file is part of the libsigrok project.
2011-12-30 09:42:39 +00:00
##
2012-02-13 13:31:51 +00:00
## Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
2012-10-15 06:17:32 +00:00
## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
2011-12-30 09:42:39 +00:00
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
2012-01-28 20:26:56 +00:00
# We require at least autoconf 2.63 (AC_INIT format changed there).
AC_PREREQ([2.63])
2011-12-30 09:42:39 +00:00
2017-06-15 14:15:24 +00:00
AC_INIT([libsigrok], [0.6.0],
2015-08-14 19:01:59 +00:00
[sigrok-devel@lists.sourceforge.net],
2011-12-30 09:50:00 +00:00
[libsigrok], [http://www.sigrok.org])
2015-08-22 18:58:11 +00:00
AC_CONFIG_MACRO_DIR([m4])
2012-01-03 20:55:48 +00:00
AC_CONFIG_AUX_DIR([autostuff])
2015-08-23 12:52:00 +00:00
AC_CONFIG_HEADERS([config.h include/libsigrok/version.h])
2011-12-30 09:42:39 +00:00
2012-01-28 20:26:56 +00:00
# We require at least automake 1.11 (needed for 'silent rules').
2015-08-15 16:10:50 +00:00
AM_INIT_AUTOMAKE([1.11 -Wall -Werror no-define nostdinc subdir-objects check-news color-tests])
2015-08-26 21:09:03 +00:00
AM_SILENT_RULES([yes])
2012-05-11 16:23:21 +00:00
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
2011-12-30 09:42:39 +00:00
2015-09-10 17:35:17 +00:00
AC_CANONICAL_HOST
2011-12-30 09:42:39 +00:00
# Checks for programs.
AC_PROG_CC
2014-07-17 17:39:49 +00:00
AC_PROG_CXX
2011-12-30 09:42:39 +00:00
AC_PROG_INSTALL
AC_PROG_LN_S
2013-03-12 22:00:58 +00:00
# Required for per-target flags or subdir-objects with C sources.
AM_PROG_CC_C_O
2015-09-13 16:35:28 +00:00
# Set the standard the C library headers should conform to.
AH_VERBATIM([_POSIX_C_SOURCE], [/* The targeted POSIX standard. */
#ifndef _POSIX_C_SOURCE
# define _POSIX_C_SOURCE 200112L
#endif])
2015-09-08 02:47:46 +00:00
# Get compiler versions.
SR_PROG_VERSION([$CC], [sr_cc_version])
SR_PROG_VERSION([$CXX], [sr_cxx_version])
2015-09-07 21:38:52 +00:00
# Check for optional make features.
2015-09-07 20:28:14 +00:00
SR_PROG_MAKE_ORDER_ONLY
2011-12-30 09:42:39 +00:00
# Initialize libtool.
LT_INIT
2015-08-23 12:52:00 +00:00
# Set up the libsigrok version defines.
SR_PKG_VERSION_SET([SR_PACKAGE_VERSION], [AC_PACKAGE_VERSION])
2015-08-14 15:53:06 +00:00
2012-01-03 23:05:43 +00:00
# Library version for libsigrok (NOT the same as the package version).
2011-12-30 09:42:39 +00:00
# Carefully read the libtool docs before updating these numbers!
# The algorithm for determining which number to change (and how) is nontrivial!
# http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
2016-01-29 21:57:48 +00:00
# Format: current:revision:age.
2017-06-12 01:03:21 +00:00
SR_LIB_VERSION_SET([SR_LIB_VERSION], [4:0:0])
2011-12-30 09:42:39 +00:00
2015-10-03 12:08:32 +00:00
AM_CONDITIONAL([WIN32], [test -z "${host_os##mingw*}" || test -z "${host_os##cygwin*}"])
2015-08-15 13:59:52 +00:00
#############################
## Optional dependencies ##
#############################
2014-07-23 14:33:42 +00:00
2015-09-07 19:49:17 +00:00
AC_LANG([C])
2015-08-15 13:59:52 +00:00
# Initialize pkg-config.
# We require at least 0.22, as "Requires.private" behaviour changed there.
PKG_PROG_PKG_CONFIG([0.22])
2014-07-18 19:12:31 +00:00
2015-08-23 18:07:38 +00:00
# Keep track of all checked modules so we can list them at the end.
SR_PKG_CHECK_SUMMARY([sr_pkglibs_summary])
# Collect the pkg-config module names of all dependencies in SR_PKGLIBS.
2015-08-15 13:59:52 +00:00
# These are used to derive the compiler flags and for the "Requires.private"
# field in the generated libsigrok.pc file.
2015-08-23 18:07:38 +00:00
SR_VAR_OPT_PKG([SR_PKGLIBS], [sr_deps_avail])
2015-08-26 11:13:39 +00:00
SR_PKGLIBS_TESTS=
2015-08-15 13:59:52 +00:00
SR_PKGLIBS_CXX=
SR_PKGLIBS_PYTHON=
2016-01-11 13:31:47 +00:00
SR_PKGLIBS_RUBY=
2015-09-07 19:49:17 +00:00
SR_EXTRA_LIBS=
2016-12-06 20:01:23 +00:00
SR_EXTRA_CXX_LIBS=
2015-08-15 13:59:52 +00:00
2018-06-03 04:34:27 +00:00
SR_ARG_OPT_PKG([libserialport], [LIBSERIALPORT], ,
2015-08-15 13:59:52 +00:00
[libserialport >= 0.1.1])
2017-09-17 14:55:50 +00:00
SR_ARG_OPT_PKG([libftdi], [LIBFTDI], , [libftdi1 >= 1.0])
2015-08-15 13:59:52 +00:00
2019-06-15 13:52:22 +00:00
# pkg-config file names: MinGW/MacOSX: hidapi; Linux: hidapi-hidraw/-libusb
2017-03-26 14:48:36 +00:00
SR_ARG_OPT_PKG([libhidapi], [LIBHIDAPI], ,
[hidapi >= 0.8.0], [hidapi-hidraw >= 0.8.0], [hidapi-libusb >= 0.8.0])
2019-06-15 13:52:22 +00:00
SR_ARG_OPT_PKG([libbluez], [LIBBLUEZ], , [bluez >= 4.0])
2018-12-27 13:22:34 +00:00
2020-03-06 14:44:41 +00:00
SR_ARG_OPT_PKG([libnettle], [LIBNETTLE], , [nettle])
2015-08-15 13:59:52 +00:00
# FreeBSD comes with an "integrated" libusb-1.0-style USB API.
# This means libusb-1.0 is always available; no need to check for it.
2015-09-07 13:01:52 +00:00
# On Windows, require the latest version we can get our hands on,
# until the new generic event handling has seen an official release.
AS_CASE([$host_os],
[freebsd*], [sr_libusb_req='libusb-1.0' sr_have_libusb=yes],
[mingw*], [sr_libusb_req='libusb-1.0 >= 1.0.20'],
[sr_libusb_req='libusb-1.0 >= 1.0.16'])
2015-08-15 13:59:52 +00:00
2015-08-16 16:53:32 +00:00
SR_ARG_OPT_PKG([libusb], [LIBUSB_1_0], [NEED_USB],
2015-09-07 13:01:52 +00:00
[$sr_libusb_req])
2014-07-17 17:39:49 +00:00
2015-08-16 16:53:32 +00:00
SR_ARG_OPT_PKG([librevisa], [LIBREVISA], [NEED_VISA],
2015-08-15 13:59:52 +00:00
[librevisa >= 0.0.20130412])
2014-08-31 08:56:00 +00:00
2015-08-16 16:53:32 +00:00
SR_ARG_OPT_PKG([libgpib], [LIBGPIB], [NEED_GPIB],
2015-08-15 13:59:52 +00:00
[libgpib])
2015-09-07 19:49:17 +00:00
SR_ARG_OPT_CHECK([libieee1284], [LIBIEEE1284],, [
sr_save_LIBS=$LIBS
LIBS="-lieee1284 $LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ieee1284.h>]],
[[(void) ieee1284_open(0, 0, 0);]])],
[sr_have_libieee1284=yes], [sr_have_libieee1284=no])
2015-09-08 02:02:04 +00:00
LIBS=$sr_save_LIBS
2015-09-07 19:49:17 +00:00
])
AS_IF([test "x$sr_have_libieee1284" = xyes],
[SR_PREPEND([SR_EXTRA_LIBS], [-lieee1284])])
2019-02-19 23:26:27 +00:00
SR_ARG_OPT_PKG([libgio], [LIBGIO], , [gio-2.0 >= 2.24.0])
2018-12-27 13:22:34 +00:00
# See if any of the (potentially platform specific) libs are available
# which provide some means of Bluetooth communication.
AS_IF([test "x$sr_have_libbluez" = xyes],
sr_have_bluetooth=yes, sr_have_bluetooth=no)
AS_IF([test "x$sr_have_bluetooth" = xyes],
[AC_DEFINE([HAVE_BLUETOOTH], [1], [Specifies whether Bluetooth communication is supported.])])
2019-02-19 23:26:27 +00:00
AS_IF([test "x$sr_have_bluetooth" = xyes],
[SR_APPEND([sr_deps_avail], [bluetooth_comm])])
2018-12-27 13:22:34 +00:00
AS_IF([test "x$sr_have_libserialport" = xyes -o "x$sr_have_libhidapi" = xyes -o "x$sr_have_bluetooth" = xyes],
2018-06-03 04:34:27 +00:00
sr_have_serial_comm=yes, sr_have_serial_comm=no)
AS_IF([test "x$sr_have_serial_comm" = xyes],
[AC_DEFINE([HAVE_SERIAL_COMM], [1], [Specifies whether serial communication is supported.])])
AS_IF([test "x$sr_have_serial_comm" = xyes],
[SR_APPEND([sr_deps_avail], [serial_comm])])
AM_CONDITIONAL([NEED_SERIAL], [test "x$sr_have_serial_comm" = xyes])
2015-08-15 13:59:52 +00:00
######################
## Feature checks ##
######################
2014-07-17 17:45:29 +00:00
2013-04-08 12:46:13 +00:00
# The Check unit testing framework is optional. Disable if not found.
2015-08-26 11:13:39 +00:00
SR_PKG_CHECK([check], [SR_PKGLIBS_TESTS], [check >= 0.9.4])
2015-08-15 13:59:52 +00:00
AM_CONDITIONAL([HAVE_CHECK], [test "x$sr_have_check" = xyes])
2015-08-25 10:50:35 +00:00
# Enable the C99 standard if possible, and enforce the use
2015-08-23 19:08:54 +00:00
# of SR_API to explicitly mark all public API functions.
SR_EXTRA_CFLAGS=
2015-08-25 10:50:35 +00:00
SR_CHECK_COMPILE_FLAGS([SR_EXTRA_CFLAGS], [C99], [-std=c99 -c99 -AC99 -qlanglvl=extc99])
2015-08-23 19:08:54 +00:00
SR_CHECK_COMPILE_FLAGS([SR_EXTRA_CFLAGS], [visibility], [-fvisibility=hidden])
2015-08-23 13:02:30 +00:00
SR_ARG_ENABLE_WARNINGS([SR_WFLAGS], [-Wall], [-Wall -Wextra -Wmissing-prototypes])
2015-08-15 13:59:52 +00:00
# Check host characteristics.
2015-08-26 21:09:03 +00:00
AC_SYS_LARGEFILE
2015-08-15 13:59:52 +00:00
AC_C_BIGENDIAN
2013-03-07 08:37:42 +00:00
2015-08-23 18:07:38 +00:00
AC_CHECK_HEADERS([sys/mman.h], [SR_APPEND([sr_deps_avail], [sys_mman_h])])
AC_CHECK_HEADERS([sys/ioctl.h], [SR_APPEND([sr_deps_avail], [sys_ioctl_h])])
AC_CHECK_HEADERS([sys/timerfd.h], [SR_APPEND([sr_deps_avail], [sys_timerfd_h])])
2015-08-15 13:59:52 +00:00
2015-08-24 20:06:27 +00:00
# We need to link against the Winsock2 library for SCPI over TCP.
2015-09-07 19:49:17 +00:00
AS_CASE([$host_os], [mingw*], [SR_PREPEND([SR_EXTRA_LIBS], [-lws2_32])])
2015-08-24 20:06:27 +00:00
# libm (the standard math library) is always needed.
SR_SEARCH_LIBS([SR_EXTRA_LIBS], [pow], [m])
2015-08-15 13:59:52 +00:00
# RPC is only needed for VXI support.
AC_CACHE_CHECK([for RPC support], [sr_cv_have_rpc],
[AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <rpc/rpc.h>]m4_newline[CLIENT *rpc_test(void);]],
[[(void) clnt_create("", 0, 0, "");]])],
[sr_cv_have_rpc=yes], [sr_cv_have_rpc=no])])
AS_IF([test "x$sr_cv_have_rpc" = xyes],
[AC_DEFINE([HAVE_RPC], [1], [Specifies whether we have RPC support.])])
# VXI support is only compiled if RPC support was found.
AM_CONDITIONAL([NEED_RPC], [test "x$sr_cv_have_rpc" = xyes])
2016-04-29 22:28:09 +00:00
# Check for compiler support of 128 bit integers
AC_CHECK_TYPES([__int128_t, __uint128_t], [], [], [])
2015-08-17 03:08:48 +00:00
########################
## Hardware drivers ##
########################
# Keep track of all drivers so we can list them at the end.
2015-08-23 18:07:38 +00:00
SR_VAR_SUMMARY([sr_driver_summary])
2015-08-17 03:08:48 +00:00
# Check whether the sr_deps_avail list contains all of the arguments.
# Unavailable dependencies are collected in sr_deps_missing.
sr_check_driver_deps() {
sr_deps_missing=
for sr_dep
do
AS_CASE([" $sr_deps_avail "], [*" $sr_dep "*],,
2015-08-23 21:53:01 +00:00
[SR_APPEND([sr_deps_missing], [', '], [$sr_dep])])
2015-08-17 03:08:48 +00:00
done
2015-08-24 09:18:09 +00:00
test -z "$sr_deps_missing" || return 1
2015-08-17 03:08:48 +00:00
}
AC_ARG_ENABLE([all-drivers],
[AS_HELP_STRING([--enable-all-drivers],
[enable all drivers by default [default=yes]])],
[], [enable_all_drivers=yes])
## _SR_DRIVER(Device name, driver-name, var-name, [dependencies...])
m4_define([_SR_DRIVER], [
2015-08-18 13:02:01 +00:00
AC_ARG_ENABLE([$2],
2015-08-17 03:08:48 +00:00
[AS_HELP_STRING([--enable-$2], [enable $1 support])],
[$3=$enableval], [$3=$enable_all_drivers])
AS_IF([test "x[$]$3" = xyes], [sr_hw_info=yes[]m4_ifval([$4], [
2015-08-24 09:18:09 +00:00
sr_check_driver_deps $4 \
|| $3=no sr_hw_info="no (missing: $sr_deps_missing)"
2015-08-17 03:08:48 +00:00
])], [sr_hw_info='no (disabled)'])
2015-08-23 18:07:38 +00:00
sr_driver_summary_append "$2" "$sr_hw_info"
2015-08-17 03:08:48 +00:00
AM_CONDITIONAL([$3], [test "x[$]$3" = xyes])
2016-08-14 23:28:55 +00:00
AM_COND_IF([$3], [AC_DEFINE([HAVE_$3], [1], [Whether to support $1 device.]) AC_DEFINE([HAVE_DRIVERS], [1], [Whether at least one driver is enabled.])])
2015-08-17 03:08:48 +00:00
])
## SR_DRIVER(Device name, driver-name, [dependencies...])
m4_define([SR_DRIVER],
[_SR_DRIVER([$1], [$2], m4_expand([AS_TR_CPP([HW_$2])]), [$3])])
2019-04-29 16:57:04 +00:00
SR_DRIVER([Agilent DMM], [agilent-dmm], [serial_comm])
SR_DRIVER([Appa 55II], [appa-55ii], [serial_comm])
SR_DRIVER([Arachnid Labs Re:load Pro], [arachnid-labs-re-load-pro], [serial_comm])
2015-08-17 03:08:48 +00:00
SR_DRIVER([ASIX SIGMA/SIGMA2], [asix-sigma], [libftdi])
2019-04-29 16:57:04 +00:00
SR_DRIVER([Atten PPS3xxx], [atten-pps3xxx], [serial_comm])
2015-08-17 03:08:48 +00:00
SR_DRIVER([BayLibre ACME], [baylibre-acme], [sys_timerfd_h])
SR_DRIVER([BeagleLogic], [beaglelogic], [sys_mman_h sys_ioctl_h])
2019-04-29 16:57:04 +00:00
SR_DRIVER([Brymen DMM], [brymen-dmm], [serial_comm])
SR_DRIVER([CEM DT-885x], [cem-dt-885x], [serial_comm])
SR_DRIVER([Center 3xx], [center-3xx], [serial_comm])
2015-11-15 15:12:35 +00:00
SR_DRIVER([ChronoVu LA], [chronovu-la], [libusb libftdi])
2019-04-29 16:57:04 +00:00
SR_DRIVER([Colead SLM], [colead-slm], [serial_comm])
SR_DRIVER([Conrad DIGI 35 CPU], [conrad-digi-35-cpu], [serial_comm])
2015-08-17 03:08:48 +00:00
SR_DRIVER([demo], [demo])
2017-06-20 21:07:27 +00:00
SR_DRIVER([DreamSourceLab DSLogic], [dreamsourcelab-dslogic], [libusb])
2017-09-09 16:31:15 +00:00
SR_DRIVER([Fluke 45], [fluke-45])
2019-04-29 16:57:04 +00:00
SR_DRIVER([Fluke DMM], [fluke-dmm], [serial_comm])
2016-04-02 16:36:52 +00:00
SR_DRIVER([FTDI LA], [ftdi-la], [libusb libftdi])
2015-08-17 03:08:48 +00:00
SR_DRIVER([fx2lafw], [fx2lafw], [libusb])
2019-04-29 16:57:04 +00:00
SR_DRIVER([GMC MH 1x/2x], [gmc-mh-1x-2x], [serial_comm])
SR_DRIVER([GW Instek GDS-800], [gwinstek-gds-800], [serial_comm])
SR_DRIVER([GW Instek GPD], [gwinstek-gpd], [serial_comm])
SR_DRIVER([Hameg HMO], [hameg-hmo], [serial_comm])
2016-03-05 20:55:02 +00:00
SR_DRIVER([Hantek 4032L], [hantek-4032l], [libusb])
2015-09-16 19:18:07 +00:00
SR_DRIVER([Hantek 6xxx], [hantek-6xxx], [libusb])
2015-08-17 03:08:48 +00:00
SR_DRIVER([Hantek DSO], [hantek-dso], [libusb])
2016-02-28 06:05:27 +00:00
SR_DRIVER([HP 3457A], [hp-3457a])
2017-10-02 10:50:04 +00:00
SR_DRIVER([HP 3478A], [hp-3478a], [libgpib])
2015-09-10 16:36:30 +00:00
SR_DRIVER([Hung-Chang DSO-2100], [hung-chang-dso-2100], [libieee1284])
2015-08-17 03:08:48 +00:00
SR_DRIVER([Ikalogic Scanalogic-2], [ikalogic-scanalogic2], [libusb])
SR_DRIVER([Ikalogic Scanaplus], [ikalogic-scanaplus], [libftdi])
2018-08-29 22:02:16 +00:00
SR_DRIVER([IPDBG LA], [ipdbg-la])
2015-08-17 03:08:48 +00:00
SR_DRIVER([Kecheng KC-330B], [kecheng-kc-330b], [libusb])
2019-04-29 16:57:04 +00:00
SR_DRIVER([KERN scale], [kern-scale], [serial_comm])
2020-03-21 11:08:10 +00:00
SR_DRIVER([Kingst LA2016], [kingst-la2016], [libusb])
2019-04-29 16:57:04 +00:00
SR_DRIVER([Korad KAxxxxP], [korad-kaxxxxp], [serial_comm])
2015-08-17 03:08:48 +00:00
SR_DRIVER([Lascar EL-USB], [lascar-el-usb], [libusb])
2015-10-08 18:13:53 +00:00
SR_DRIVER([LeCroy LogicStudio], [lecroy-logicstudio], [libusb])
2017-02-27 09:44:33 +00:00
SR_DRIVER([LeCroy X-Stream], [lecroy-xstream])
2019-04-29 16:57:04 +00:00
SR_DRIVER([Manson HCS-3xxx], [manson-hcs-3xxx], [serial_comm])
2019-12-22 14:33:45 +00:00
SR_DRIVER([Mastech MS6514], [mastech-ms6514], [serial_comm])
2015-08-17 03:08:48 +00:00
SR_DRIVER([maynuo-m97], [maynuo-m97])
2019-04-29 16:57:04 +00:00
SR_DRIVER([MIC 985xx], [mic-985xx], [serial_comm])
2018-12-11 11:18:07 +00:00
SR_DRIVER([Microchip PICkit2], [microchip-pickit2], [libusb])
2019-02-19 23:26:27 +00:00
SR_DRIVER([Mooshimeter DMM], [mooshimeter-dmm], [bluetooth_comm libgio])
2019-04-29 16:57:04 +00:00
SR_DRIVER([Motech LPS 30x], [motech-lps-30x], [serial_comm])
SR_DRIVER([Norma DMM], [norma-dmm], [serial_comm])
SR_DRIVER([OpenBench Logic Sniffer], [openbench-logic-sniffer], [serial_comm])
SR_DRIVER([PCE PCE-322A], [pce-322a], [serial_comm])
2015-08-17 03:08:48 +00:00
SR_DRIVER([Pipistrello-OLS], [pipistrello-ols], [libftdi])
2019-04-29 16:57:04 +00:00
SR_DRIVER([RDTech DPSxxxx/DPHxxxx], [rdtech-dps], [serial_comm])
2018-10-28 22:45:57 +00:00
SR_DRIVER([RDTech UMXX], [rdtech-um], [serial_comm])
2020-03-06 14:44:41 +00:00
SR_DRIVER([RDTech TCXX], [rdtech-tc], [serial_comm libnettle])
2015-08-17 03:08:48 +00:00
SR_DRIVER([Rigol DS], [rigol-ds])
2019-04-29 16:57:04 +00:00
SR_DRIVER([Rohde&Schwarz SME-0x], [rohde-schwarz-sme-0x], [serial_comm])
2015-08-17 03:08:48 +00:00
SR_DRIVER([Saleae Logic16], [saleae-logic16], [libusb])
2017-06-28 06:15:24 +00:00
SR_DRIVER([Saleae Logic Pro], [saleae-logic-pro], [libusb])
2018-11-02 17:32:33 +00:00
SR_DRIVER([SCPI DMM], [scpi-dmm])
2015-08-17 03:08:48 +00:00
SR_DRIVER([SCPI PPS], [scpi-pps])
2019-04-29 16:57:04 +00:00
SR_DRIVER([serial DMM], [serial-dmm], [serial_comm])
SR_DRIVER([serial LCR], [serial-lcr], [serial_comm])
2018-02-11 14:18:57 +00:00
SR_DRIVER([Siglent SDS], [siglent-sds])
2015-08-17 03:08:48 +00:00
SR_DRIVER([Sysclk LWLA], [sysclk-lwla], [libusb])
2019-04-22 10:24:47 +00:00
SR_DRIVER([Sysclk SLA5032], [sysclk-sla5032], [libusb])
2019-04-29 16:57:04 +00:00
SR_DRIVER([Teleinfo], [teleinfo], [serial_comm])
2015-08-17 03:08:48 +00:00
SR_DRIVER([Testo], [testo], [libusb])
2019-04-29 16:57:04 +00:00
SR_DRIVER([Tondaj SL-814], [tondaj-sl-814], [serial_comm])
2015-08-17 03:08:48 +00:00
SR_DRIVER([UNI-T DMM], [uni-t-dmm], [libusb])
uni-t-ut181a: implement device driver for the UNI-T UT181A multimeter
Extend the previously introduced skeleton driver for UNI-T UT181A. Introduce
support for the full multimeter's protocol as it was documented by the ut181a
project. Which covers the retrieval of live readings, saved measurements, and
recordings, in all of the meter's modes and including relative, min/max, and
peak submodes. This implementation also parses compare mode (limits check)
responses, although it cannot express the result in terms of the session feed.
Announce the device as a multimeter as well as a thermometer, it supports
up to two probes including difference mode. When in doubt, prefer usability
over feature coverage (the driver side reflects all properties of the meter,
but not all features can get controlled by the driver). The probe routine
requires that users specify the serial port, and enable serial communication
on the meter.
Several TODO items remain. Comments in the driver code discuss limitations
of the current implementation, as well as cases where the meter's features
don't map well to sigrok's internal presentation. This implementation also
contains (optional, off by default) diagnostics for research on the serial
protocol.
2019-12-14 14:14:46 +00:00
SR_DRIVER([UNI-T UT181A], [uni-t-ut181a], [serial_comm])
2017-10-06 00:52:29 +00:00
SR_DRIVER([UNI-T UT32x], [uni-t-ut32x], [serial_comm])
2015-08-17 03:08:48 +00:00
SR_DRIVER([Yokogawa DL/DLM], [yokogawa-dlm])
SR_DRIVER([ZEROPLUS Logic Cube], [zeroplus-logic-cube], [libusb])
2019-04-29 16:57:04 +00:00
SR_DRIVER([ZKETECH EBD-USB], [zketech-ebd-usb], [serial_comm])
2015-08-15 13:59:52 +00:00
###############################
## Language bindings setup ##
###############################
2015-08-17 03:08:48 +00:00
AC_LANG([C++])
2015-08-23 13:02:30 +00:00
SR_ARG_ENABLE_WARNINGS([SR_WXXFLAGS], [-Wall], [-Wall -Wextra])
2015-08-17 03:08:48 +00:00
2015-08-15 13:59:52 +00:00
AC_ARG_ENABLE([bindings],
[AS_HELP_STRING([--enable-bindings], [build language bindings [default=yes]])],
[], [enable_bindings=yes])
2015-07-25 17:50:36 +00:00
2015-08-15 13:59:52 +00:00
AC_ARG_ENABLE([cxx],
[AS_HELP_STRING([--enable-cxx], [build C++ bindings [default=yes]])],
[], [enable_cxx=$enable_bindings])
2015-02-12 13:53:51 +00:00
2015-08-15 13:59:52 +00:00
AC_ARG_ENABLE([python],
[AS_HELP_STRING([--enable-python], [build Python bindings [default=yes]])],
[], [enable_python=$enable_bindings])
2011-12-30 09:42:39 +00:00
2016-01-11 13:31:47 +00:00
AC_ARG_ENABLE([ruby],
2020-06-20 16:06:00 +00:00
[AS_HELP_STRING([--enable-ruby], [build Ruby bindings [default=yes]])],
[], [enable_ruby=$enable_bindings])
2016-01-11 13:31:47 +00:00
2015-08-15 13:59:52 +00:00
AC_ARG_ENABLE([java],
[AS_HELP_STRING([--enable-java], [build Java bindings [default=yes]])],
[], [enable_java=$enable_bindings])
####################
## C++ bindings ##
####################
sr_cxx_missing=
# Check if the C++ compiler supports the C++11 standard.
2016-05-13 10:27:14 +00:00
AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
2015-08-23 21:53:01 +00:00
AS_IF([test "x$HAVE_CXX11" != x1],
[SR_APPEND([sr_cxx_missing], [', '], ['C++11'])])
2015-08-15 13:59:52 +00:00
# The C++ bindings need glibmm.
SR_PKG_CHECK([glibmm], [SR_PKGLIBS_CXX], [glibmm-2.4 >= 2.32.0])
2015-08-23 21:53:01 +00:00
AS_IF([test "x$sr_have_glibmm" != xyes],
[SR_APPEND([sr_cxx_missing], [', '], [glibmm])])
2015-08-15 13:59:52 +00:00
# The C++ bindings use Doxygen to parse libsigrok symbols.
AC_CHECK_PROG([HAVE_DOXYGEN], [doxygen], [yes], [no])
2015-08-23 21:53:01 +00:00
AS_IF([test "x$HAVE_DOXYGEN" != xyes],
[SR_APPEND([sr_cxx_missing], [', '], [Doxygen])])
2015-08-15 13:59:52 +00:00
2016-12-06 20:01:23 +00:00
# Link C++ code with gnustl_shared if it exists (Android)
SR_SEARCH_LIBS([SR_EXTRA_CXX_LIBS], [__cxa_throw], [gnustl_shared])
2015-08-15 13:59:52 +00:00
# Python is needed for the C++ bindings.
AM_PATH_PYTHON([2.7],
[HAVE_PYTHON=yes],
2015-08-23 21:53:01 +00:00
[HAVE_PYTHON=no
SR_APPEND([sr_cxx_missing], [', '], [Python])])
2015-08-15 13:59:52 +00:00
AS_IF([test -z "$sr_cxx_missing"],
[BINDINGS_CXX=$enable_cxx], [BINDINGS_CXX=no])
AM_CONDITIONAL([BINDINGS_CXX], [test "x$BINDINGS_CXX" = xyes])
# C++ bindings want stoi and stod.
AM_COND_IF([BINDINGS_CXX], [
AC_CACHE_CHECK([for stoi and stod], [sr_cv_have_stoi_stod],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string>]],
[[(void) std::stoi("1"); (void) std::stod("1.0");]])],
[sr_cv_have_stoi_stod=yes], [sr_cv_have_stoi_stod=no])])
AS_IF([test "x$sr_cv_have_stoi_stod" = xyes],
[AC_DEFINE([HAVE_STOI_STOD], [1],
[Specifies whether we have the stoi and stod functions.])])
])
#######################
## Python bindings ##
#######################
2015-08-23 21:53:01 +00:00
AS_IF([test "x$BINDINGS_CXX" = xyes],
[sr_python_missing=],
[sr_python_missing='C++ bindings'])
2015-08-15 13:59:52 +00:00
2015-11-01 20:40:28 +00:00
# Extract major and minor version number of the Python interpreter.
sr_pymajor=${PYTHON_VERSION%%.*}
sr_pyminor=${PYTHON_VERSION#*.}
# The Python bindings need Python development files. Check for either
# Python 3 or Python 2 headers depending on the interpreter version.
2015-08-15 13:59:52 +00:00
SR_PKG_CHECK([python_dev], [SR_PKGLIBS_PYTHON],
2015-11-01 20:40:28 +00:00
[python = $PYTHON_VERSION],
[python$sr_pymajor = $PYTHON_VERSION],
[python$sr_pymajor$sr_pyminor = $PYTHON_VERSION],
[python-$PYTHON_VERSION = $PYTHON_VERSION])
2015-08-23 21:53:01 +00:00
AS_IF([test "x$sr_have_python_dev" != xyes],
[SR_APPEND([sr_python_missing], [', '], [Headers])])
2015-08-15 13:59:52 +00:00
# PyGObject is needed for the Python bindings.
SR_PKG_CHECK([pygobject], [SR_PKGLIBS_PYTHON], [pygobject-3.0 >= 3.0.0])
2015-08-23 21:53:01 +00:00
AS_IF([test "x$sr_have_pygobject" != xyes],
[SR_APPEND([sr_python_missing], [', '], [PyGObject])])
2015-08-15 13:59:52 +00:00
PKG_CHECK_EXISTS([pygobject-3.0 < 3.7.91],
[AC_DEFINE([PYGOBJECT_FLAGS_SIGNED], [1],
[Whether last argument to pyg_flags_get_value() is signed.])])
2015-09-15 16:26:51 +00:00
# The Python bindings need the setuptools and numpy Python modules.
# We'll let it go through even if the AX macro wasn't found, as the
# Python modules may still be there.
m4_ifdef([AX_PYTHON_MODULE], [
AX_PYTHON_MODULE([setuptools])
AX_PYTHON_MODULE([numpy])
], [
HAVE_PYMOD_SETUPTOOLS=yes
HAVE_PYMOD_NUMPY=yes
m4_warn([unsupported],
[Missing macro AX_PYTHON_MODULE: no check for setuptools and numpy])
])
2015-08-23 21:53:01 +00:00
AS_IF([test "x$HAVE_PYMOD_SETUPTOOLS" != xyes],
[SR_APPEND([sr_python_missing], [', '], [setuptools])])
2015-09-15 16:26:51 +00:00
AS_IF([test "x$HAVE_PYMOD_NUMPY" != xyes],
[SR_APPEND([sr_python_missing], [', '], [numpy])])
2015-08-15 13:59:52 +00:00
# The Python bindings use SWIG to generate code.
2020-04-04 20:00:17 +00:00
AC_CHECK_PROGS([SWIG], [swig swig4.0 swig3.0 swig2.0])
2016-01-28 21:45:28 +00:00
AS_IF([test "x$SWIG" != x],
AC_MSG_CHECKING([for $SWIG version])
2016-05-19 20:46:24 +00:00
[SWIG_VERSION=`$SWIG -version 2>&1 | sed -n 's/SWIG Version //p'`]
2016-01-28 21:45:28 +00:00
AC_MSG_RESULT([$SWIG_VERSION]))
2015-08-23 21:53:01 +00:00
AS_IF([test "x$SWIG" = x],
[SR_APPEND([sr_python_missing], [', '], [SWIG])])
2015-08-15 13:59:52 +00:00
AS_IF([test -z "$sr_python_missing"],
[BINDINGS_PYTHON=$enable_python], [BINDINGS_PYTHON=no])
AM_CONDITIONAL([BINDINGS_PYTHON], [test "x$BINDINGS_PYTHON" = xyes])
2016-01-11 13:31:47 +00:00
#####################
## Ruby bindings ##
#####################
AS_IF([test "x$BINDINGS_CXX" = xyes],
[sr_ruby_missing=],
[sr_ruby_missing='C++ bindings'])
2016-01-28 21:48:44 +00:00
AC_PATH_PROGS(RUBY, ["${RUBY-ruby}"], [])
AS_IF([test "x$RUBY" != x],
AC_MSG_CHECKING([for Ruby version])
[RUBY_VERSION=`$RUBY -e 'puts RUBY_VERSION'`]
AC_MSG_RESULT([$RUBY_VERSION])
[RUBY_DLEXT=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG[["DLEXT"]]'`]
AC_SUBST(RUBY_DLEXT))
2016-01-11 13:31:47 +00:00
AS_IF([test "x$RUBY" = x],
2016-01-28 21:48:44 +00:00
[SR_APPEND([sr_ruby_missing], [', '], [Ruby])])
2016-01-11 13:31:47 +00:00
# Extract major and minor version number of the Ruby interpreter.
sr_rbmajor=${RUBY_VERSION%%.*}
sr_rbminor=${RUBY_VERSION#*.}
sr_rbminor=${sr_rbminor%%.*}
# The Ruby bindings need Ruby development files.
SR_PKG_CHECK([ruby_dev], [SR_PKGLIBS_RUBY],
2020-07-18 15:31:38 +00:00
[ruby >= 2.5.0],
[ruby-$sr_rbmajor.$sr_rbminor >= 2.5.0])
2016-01-11 13:31:47 +00:00
AS_IF([test "x$sr_have_ruby_dev" != xyes],
[SR_APPEND([sr_ruby_missing], [', '], [Headers])])
2016-01-28 21:45:28 +00:00
# The Ruby bindings use SWIG >= 3.0.8 to generate code.
2016-01-11 13:31:47 +00:00
AS_IF([test "x$SWIG" = x],
2016-01-28 21:45:28 +00:00
[SR_APPEND([sr_ruby_missing], [', '], [SWIG])],
[AS_VERSION_COMPARE($SWIG_VERSION, "3.0.8",
[SR_APPEND([sr_ruby_missing], [', '], ['SWIG >= 3.0.8'])])])
2016-01-11 13:31:47 +00:00
AS_IF([test -z "$sr_ruby_missing"],
[BINDINGS_RUBY=$enable_ruby], [BINDINGS_RUBY=no])
AM_CONDITIONAL([BINDINGS_RUBY], [test "x$BINDINGS_RUBY" = xyes])
2015-08-15 13:59:52 +00:00
####################
## Java bindings ##
####################
2015-08-23 21:53:01 +00:00
AS_IF([test "x$BINDINGS_CXX" = xyes],
[sr_java_missing=],
[sr_java_missing='C++ bindings'])
2015-08-15 13:59:52 +00:00
# The Java bindings use SWIG to generate code.
2015-08-23 21:53:01 +00:00
AS_IF([test "x$SWIG" = x],
[SR_APPEND([sr_java_missing], [', '], [SWIG])])
2014-04-18 18:11:47 +00:00
2014-04-27 08:48:18 +00:00
# Find Java compiler and JNI includes for Java bindings.
AC_CHECK_PROG([HAVE_JAVAC], [javac], [yes], [no])
2015-08-23 21:53:01 +00:00
AS_IF([test "x$HAVE_JAVAC" = xno],
[SR_APPEND([sr_java_missing], [', '], [JavaC])])
2015-08-15 13:59:52 +00:00
AC_ARG_WITH([jni-include-path],
[AS_HELP_STRING([[--with-jni-include-path=DIR-LIST (space-separated)]],
[specify JNI include directories [default=detect]])],
[JNI_INCLUDE_DIRS=" $withval"], [JNI_INCLUDE_DIRS=])
JNI_CPPFLAGS=
AS_IF([test "x$enable_java$HAVE_JAVAC" = xyesyes], [
2014-04-27 08:48:18 +00:00
AX_PROG_JAVAC
2015-08-15 13:59:52 +00:00
AS_IF([test -z "$JNI_INCLUDE_DIRS" && test "x$cross_compiling" != xyes], [
## Work around the totally broken logic in AX_JNI_INCLUDE_DIR:
## If we can find jni.h without any special search path, skip
## the execution of the broken macro to increase our chances of
## success.
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <jni.h>]], [])],,
[AX_JNI_INCLUDE_DIR])
])
])
for sr_dir in $JNI_INCLUDE_DIRS
do
2015-08-23 21:53:01 +00:00
SR_APPEND([JNI_CPPFLAGS], ["-I$sr_dir"])
2015-08-15 13:59:52 +00:00
done
AC_SUBST([JNI_CPPFLAGS])
sr_save_cppflags=$CPPFLAGS
2015-08-23 21:53:01 +00:00
SR_APPEND([CPPFLAGS], [$JNI_CPPFLAGS])
AC_CHECK_HEADER([jni.h],,
[SR_APPEND([sr_java_missing], [', '], ['JNI headers'])])
2015-08-15 13:59:52 +00:00
CPPFLAGS=$sr_save_cppflags
AS_IF([test -z "$sr_java_missing"],
[BINDINGS_JAVA=$enable_java], [BINDINGS_JAVA=no])
AM_CONDITIONAL([BINDINGS_JAVA], [test "x$BINDINGS_JAVA" = xyes])
##############################
## Finalize configuration ##
##############################
# Add mandatory dependencies to module list.
2015-10-30 14:07:25 +00:00
SR_APPEND([SR_PKGLIBS], ['libzip >= 0.10'])
2015-08-15 13:59:52 +00:00
AC_SUBST([SR_PKGLIBS])
# Retrieve the compile and link flags for all modules combined.
# Also, bail out at this point if any module dependency is not met.
PKG_CHECK_MODULES([LIBSIGROK], [glib-2.0 >= 2.32.0 $SR_PKGLIBS])
2015-08-26 11:13:39 +00:00
PKG_CHECK_MODULES([TESTS], [$SR_PKGLIBS_TESTS glib-2.0 $SR_PKGLIBS])
2015-08-15 13:59:52 +00:00
2015-08-18 15:46:29 +00:00
# SR_PKGLIBS_CXX may be empty, so only invoke these checks when
# the C++ bindings are enabled.
AM_COND_IF([BINDINGS_CXX], [
PKG_CHECK_MODULES([LIBSIGROKCXX], [$SR_PKGLIBS_CXX])
PKG_CHECK_MODULES([PYSIGROK], [$SR_PKGLIBS_PYTHON $SR_PKGLIBS_CXX])
2016-01-11 13:31:47 +00:00
PKG_CHECK_MODULES([RBSIGROK], [$SR_PKGLIBS_RUBY $SR_PKGLIBS_CXX], [AC_SUBST(RBSIGROK_EXTDIR, "lib/$($PKG_CONFIG --variable=sitearch $SR_PKGLIBS_RUBY)/$($PKG_CONFIG --variable=RUBY_BASE_NAME $SR_PKGLIBS_RUBY)/vendor_ruby/$($PKG_CONFIG --variable=ruby_version $SR_PKGLIBS_RUBY)")])
2015-08-18 15:46:29 +00:00
])
2015-09-07 13:01:52 +00:00
# Check for specific libusb features, now that we know the CFLAGS.
AC_LANG([C])
sr_save_cflags=$CFLAGS
2015-10-30 14:07:25 +00:00
sr_save_libs=$LIBS
2015-09-07 13:01:52 +00:00
CFLAGS="$LIBSIGROK_CFLAGS $CFLAGS"
2015-10-30 14:07:25 +00:00
LIBS="$LIBSIGROK_LIBS $LIBS"
2015-09-07 13:01:52 +00:00
AC_CHECK_TYPES([libusb_os_handle],
[sr_have_libusb_os_handle=yes], [sr_have_libusb_os_handle=no],
[[#include <libusb.h>]])
2015-10-30 14:07:25 +00:00
AC_CHECK_FUNCS([zip_discard])
LIBS=$sr_save_libs
2015-09-07 13:01:52 +00:00
CFLAGS=$sr_save_cflags
2015-10-30 14:07:25 +00:00
2015-09-07 13:01:52 +00:00
AM_COND_IF([NEED_USB], [AS_CASE([$sr_have_libusb_os_handle:$host_os], [no:mingw*],
[AC_MSG_ERROR([Windows builds require the event-abstraction branch of libusb])])])
2015-08-15 13:59:52 +00:00
sr_glib_version=`$PKG_CONFIG --modversion glib-2.0 2>&AS_MESSAGE_LOG_FD`
sr_libzip_version=`$PKG_CONFIG --modversion libzip 2>&AS_MESSAGE_LOG_FD`
2015-08-16 16:53:32 +00:00
AC_DEFINE_UNQUOTED([CONF_LIBZIP_VERSION], ["$sr_libzip_version"],
[Build-time version of libzip.])
AC_DEFINE_UNQUOTED([CONF_HOST], ["$host"],
[The canonical host libsigrok will run on.])
2015-08-15 13:59:52 +00:00
2015-08-14 15:53:06 +00:00
AC_CONFIG_FILES([Makefile libsigrok.pc bindings/cxx/libsigrokcxx.pc])
2011-12-30 09:42:39 +00:00
AC_OUTPUT
2015-08-15 13:59:52 +00:00
# Prepare bindings report messages.
2015-08-17 03:08:48 +00:00
m4_define([SR_PREPARE_BINDING_REPORT], [
sr_report_$1=
2015-08-23 21:53:01 +00:00
test -z "$sr_$1_missing" || sr_report_$1=" (missing: $sr_$1_missing)"
2015-08-17 03:08:48 +00:00
test "x$enable_$1" = xyes || sr_report_$1=' (disabled)'
2015-08-15 13:59:52 +00:00
])
2016-01-11 13:31:47 +00:00
m4_map_args([SR_PREPARE_BINDING_REPORT], [cxx], [python], [ruby], [java])
2012-01-03 23:49:21 +00:00
2015-08-15 13:59:52 +00:00
cat >&AS_MESSAGE_FD <<_EOF
libsigrok configuration summary:
- Package version................. $SR_PACKAGE_VERSION
- Library ABI version............. $SR_LIB_VERSION
- Prefix.......................... $prefix
- Building on..................... $build
- Building for.................... $host
2017-03-04 17:20:38 +00:00
- Building shared / static........ $enable_shared / $enable_static
2015-09-08 02:47:46 +00:00
Compile configuration:
2015-09-07 20:32:13 +00:00
- C compiler...................... $CC
2015-09-08 02:47:46 +00:00
- C compiler version.............. $sr_cc_version
2015-09-07 20:32:13 +00:00
- C compiler flags................ $CFLAGS
2015-08-23 19:08:54 +00:00
- Additional C compiler flags..... $SR_EXTRA_CFLAGS
2015-08-23 13:02:30 +00:00
- C compiler warnings............. $SR_WFLAGS
2015-09-07 20:32:13 +00:00
- C++ compiler.................... $CXX
2015-09-08 02:47:46 +00:00
- C++ compiler version............ $sr_cxx_version
2015-09-07 20:32:13 +00:00
- C++ compiler flags.............. $CXXFLAGS
2015-08-23 13:02:30 +00:00
- C++ compiler warnings........... $SR_WXXFLAGS
2017-03-05 15:38:48 +00:00
- Linker flags.................... $LDFLAGS
2015-08-15 13:59:52 +00:00
Detected libraries (required):
2015-08-16 21:56:43 +00:00
- glib-2.0 >= 2.32.0.............. $sr_glib_version
2015-10-30 14:07:25 +00:00
- libzip >= 0.10.................. $sr_libzip_version
2015-08-15 13:59:52 +00:00
Detected libraries (optional):
$sr_pkglibs_summary
2015-08-15 00:28:54 +00:00
Enabled hardware drivers:
2015-08-17 03:08:48 +00:00
$sr_driver_summary
2018-06-03 04:34:27 +00:00
Enabled serial communication transports:
- serial comm ................... $sr_have_serial_comm
- libserialport ................. $sr_have_libserialport
2017-03-26 14:48:36 +00:00
- hidapi ........................ $sr_have_libhidapi
2018-12-27 13:22:34 +00:00
- bluetooth ..................... $sr_have_bluetooth
- bluez ......................... $sr_have_libbluez
2018-06-03 04:34:27 +00:00
2015-08-15 13:59:52 +00:00
Enabled SCPI backends:
- TCP............................. yes
- RPC............................. $sr_cv_have_rpc
2018-06-03 04:34:27 +00:00
- serial.......................... $sr_have_serial_comm
2015-08-15 13:59:52 +00:00
- VISA............................ $sr_have_librevisa
- GPIB............................ $sr_have_libgpib
- USBTMC.......................... $sr_have_libusb
Enabled language bindings:
- C++............................. $BINDINGS_CXX$sr_report_cxx
- Python.......................... $BINDINGS_PYTHON$sr_report_python
2016-01-11 13:31:47 +00:00
- Ruby............................ $BINDINGS_RUBY$sr_report_ruby
2015-08-15 13:59:52 +00:00
- Java............................ $BINDINGS_JAVA$sr_report_java
2011-12-30 09:42:39 +00:00
2015-08-15 13:59:52 +00:00
_EOF
2018-07-17 17:43:54 +00:00
# Emit a warning if the C++ bindings are not being built.
AM_COND_IF([BINDINGS_CXX], [], [
cat >&AS_MESSAGE_FD <<_EOF
===============================================================================
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
===============================================================================
=== ===
=== The libsigrok C++ bindings are not being built since you ===
=== are missing one or more dependencies (see above)! ===
=== ===
=== This means you won't be able to compile frontends that require ===
=== the C++ bindings (such as PulseView)! You also won't be able to build ===
=== other bindings and frontends using those (such as sigrok-meter)! ===
=== ===
===============================================================================
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
===============================================================================
_EOF
])