-AM_CONDITIONAL(NEED_RPC, test "x$have_rpc" != "x0")
-
-# libglib-2.0 is always needed. Abort if it's not found.
-# Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement).
-# We require at least 2.32.0 due to e.g. g_variant_new_fixed_array().
-AM_PATH_GLIB_2_0([2.32.0],
- [LIB_CFLAGS="$LIB_CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
-
-# libzip is always needed. Abort if it's not found.
-PKG_CHECK_MODULES([libzip], [libzip >= 0.10],
- [LIB_CFLAGS="$LIB_CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
- SR_PKGLIBS="$SR_PKGLIBS libzip"])
-
-# libserialport is only needed for some hardware drivers. Disable the
-# respective drivers if it is not found.
-if test "x$enable_libserialport" != "xno"; then
- PKG_CHECK_MODULES([libserialport], [libserialport >= 0.2.0],
- [have_libserialport="yes"; LIB_CFLAGS="$LIB_CFLAGS $libserialport_CFLAGS";
- LIBS="$LIBS $libserialport_LIBS";
- SR_PKGLIBS="$SR_PKGLIBS libserialport"],
- [have_libserialport="no"])
- if test "x$enable_libserialport$have_libserialport" = "xyesno"; then
- AC_MSG_ERROR([libserialport support requested, but it was not found.])
- fi
-else
- have_libserialport="no"
-fi
-if test "x$have_libserialport" = "xno"; then
- HW_AGILENT_DMM="no"; HW_APPA_55II="no";
- HW_ATTEN_PPS3XXX="no"; HW_BRYMEN_DMM="no"; HW_CEM_DT_885X="no";
- HW_CENTER_3XX="no"; HW_COLEAD_SLM="no"; HW_CONRAD_DIGI_35_CPU="no";
- HW_DEREE_DE5000="no"; HW_FLUKE_DMM="no"; HW_GMC_MH_1X_2X="no";
- HW_HAMEG_HMO="no"; HW_MANSON_HCS_3XXX="no"; HW_MIC_985XX="no";
- HW_MOTECH_LPS_30X="no"; HW_NORMA_DMM="no";
- HW_OPENBENCH_LOGIC_SNIFFER="no"; HW_SERIAL_DMM="no";
- HW_TELEINFO="no"; HW_TONDAJ_SL_814="no";
-else
- # Define HAVE_LIBSERIALPORT in config.h if we found libserialport.
- 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)
-
-# The VISA SCPI backend is only compiled in if librevisa was found.
-PKG_CHECK_MODULES([librevisa], [librevisa >= 0.0.20130412],
- [have_librevisa="yes"; LIB_CFLAGS="$LIB_CFLAGS $librevisa_CFLAGS";
- LIBS="$LIBS $librevisa_LIBS";
- SR_PKGLIBS="$SR_PKGLIBS librevisa"],
- [have_librevisa="no"])
-AM_CONDITIONAL(NEED_VISA, test "x$have_librevisa" != xno)
-if test "x$have_librevisa" != "xno"; then
- # Define HAVE_LIBREVISA in config.h if we found librevisa.
- AC_DEFINE_UNQUOTED(HAVE_LIBREVISA, [1],
- [Specifies whether we have librevisa.])
-fi
-
-# The GPIB SCPI backend is only compiled in if libgpib is found.
-PKG_CHECK_MODULES([libgpib], [libgpib],
- [have_libgpib="yes"; LIB_CFLAGS="$LIB_CFLAGS $libgpib_CFLAGS";
- LIBS="$LIBS $libgpib_LIBS";
- SR_PKGLIBS="$SR_PKGLIBS libgpib"],
- [have_libgpib="no"])
-AM_CONDITIONAL(NEED_GPIB, test "x$have_libgpib" != xno)
-if test "x$have_libgpib" != "xno"; then
- # Define HAVE_LIBGPIB in config.h if we found libgpib.
- AC_DEFINE_UNQUOTED(HAVE_LIBGPIB, [1],
- [Specifies whether we have libgpib.])
-fi
-
-# libusb-1.0 is only needed for some hardware drivers. Disable the respective
-# drivers if it is not found.
-if test "x$enable_libusb" != "xno"; then
- case "$host" in
- *freebsd*)
- # 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,
- # and no need to (potentially) disable any drivers if it's not found.
- have_libusb1_0="yes"
- ;;
- *)
- PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.16],
- [have_libusb1_0="yes"; LIB_CFLAGS="$LIB_CFLAGS $libusb_CFLAGS";
- LIBS="$LIBS $libusb_LIBS";
- SR_PKGLIBS="$SR_PKGLIBS libusb-1.0"],
- [have_libusb1_0="no"])
- if test "x$enable_libusb$have_libusb1_0" = "xyesno"; then
- AC_MSG_ERROR([libusb support requested, but it was not found.])
- fi
- ;;
- esac
-else
- have_libusb1_0="no"
-fi
-if test "x$have_libusb1_0" = "xno"; then
- HW_BRYMEN_BM86X="no"; HW_FX2LAFW="no";
- HW_HANTEK_DSO="no"; HW_IKALOGIC_SCANALOGIC2="no";
- HW_KECHENG_KC_330B="no"; HW_LASCAR_EL_USB="no";
- HW_SYSCLK_LWLA="no"; HW_TESTO="no"; HW_UNI_T_DMM="no";
- HW_UNI_T_UT32X="no"; HW_VICTOR_DMM="no";
- HW_ZEROPLUS_LOGIC_CUBE="no"; HW_SALEAE_LOGIC16="no";
-else
- # Define HAVE_LIBUSB_1_0 in config.h if we found libusb-1.0.
- AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
- [Specifies whether we have libusb-1.0.])
-fi
-
-# USB + FX2 firmware helper code is only compiled in if libusb-1.0 was found.
-AM_CONDITIONAL(NEED_USB, test "x$have_libusb1_0" != xno)
-
-# libftdi is only needed for some hardware drivers. Disable them if not found.
-if test "x$enable_libftdi" != "xno"; then
- PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16],
- [have_libftdi="yes"; LIB_CFLAGS="$LIB_CFLAGS $libftdi_CFLAGS";
- LIBS="$LIBS $libftdi_LIBS";
- SR_PKGLIBS="$SR_PKGLIBS libftdi"],
- [PKG_CHECK_MODULES([libftdi1], [libftdi1 >= 1.0],
- [LIB_CFLAGS="$LIB_CFLAGS $libftdi1_CFLAGS";
- LIBS="$LIBS $libftdi1_LIBS";
- SR_PKGLIBS="$SR_PKGLIBS libftdi1"],
- [have_libftdi="no"])])
- if test "x$enable_libftdi$have_libftdi" = "xyesno"; then
- AC_MSG_ERROR([libftdi support requested, but it was not found.])
- fi
-else
- have_libftdi="no"
-fi
-if test "x$have_libftdi" = "xno"; then
- HW_ASIX_SIGMA="no"; HW_CHRONOVU_LA="no"; HW_IKALOGIC_SCANAPLUS="no";
- HW_PIPISTRELLO_OLS="no";
-fi
-
-# glibmm-2.4 is needed for the C++ bindings.
-PKG_CHECK_MODULES([glibmm], [glibmm-2.4 >= 2.32.0],
- [CXXFLAGS="$CXXFLAGS $glibmm_CFLAGS";
- CXXLIBS="$CXXLIBS $glibmm_LIBS"],
- [BINDINGS_CXX="no"; cxx_msg="glibmm required"])
+AM_CONDITIONAL([NEED_RPC], [test "x$sr_cv_have_rpc" = xyes])
+
+########################
+## Hardware drivers ##
+########################
+
+# Keep track of all drivers so we can list them at the end.
+SR_VAR_SUMMARY([sr_driver_summary])
+
+# 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 "*],,
+ [SR_APPEND([sr_deps_missing], [', '], [$sr_dep])])
+ done
+ test -z "$sr_deps_missing" || return 1
+}
+
+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], [
+ AC_ARG_ENABLE([$2],
+ [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], [
+ sr_check_driver_deps $4 \
+ || $3=no sr_hw_info="no (missing: $sr_deps_missing)"
+ ])], [sr_hw_info='no (disabled)'])
+ sr_driver_summary_append "$2" "$sr_hw_info"
+
+ AM_CONDITIONAL([$3], [test "x[$]$3" = xyes])
+ AM_COND_IF([$3], [AC_DEFINE([HAVE_$3], [1], [Whether to support $1 device.])])
+])