Skip to content

Commit

Permalink
configure.ac: introduce --with-modbus+usb option to require USB-capab…
Browse files Browse the repository at this point in the history
…le libmodbus [networkupstools#2666]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Nov 12, 2024
1 parent 8858e7f commit d3b6502
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
53 changes: 53 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,55 @@ dnl Check for Python binary program names per language version
dnl to embed into scripts and Make rules
NUT_CHECK_PYTHON_DEFAULT

dnl ----------------------------------------------------------------------
dnl Check for "require Modbus with USB support" situation before we mangle
dnl caller-provided with_* values below (by --with-drivers and --with-all)

nut_with_modbus_and_usb=auto
AC_ARG_WITH(modbus+usb,
AS_HELP_STRING([--with-modbus+usb],
[Require Modbus with USB support (auto)]),
[
case "${withval}" in
no)
dnl # AC_MSG_ERROR(invalid option --without-modbus+usb - see docs/configure.txt)
AC_MSG_NOTICE([Treating --without-modbus+usb as not-requiring that used libmodbus supports RTU USB])
nut_with_modbus_and_usb="no"
;;
auto)
nut_with_modbus_and_usb="auto"
;;
yes|'')
if test -z "${with_usb}"; then with_usb="${withval}"; fi
if test -z "${with_modbus}"; then with_modbus="${withval}"; fi
nut_with_modbus_and_usb="yes"
;;
*)
AC_MSG_ERROR(invalid option --with-modbus+usb='${withval}' - see docs/configure.txt)
;;
esac
], [
dnl Explicit request to build apc_modbus with both modbus and usb
dnl support specified on command line implies we want them present
dnl together too by default
dnl FIXME: Extend to checking --with-drivers including apc_modbus?
if test x"${with_usb}" = xyes -a x"${with_modbus}" = xyes; then
case x"${with_driver}" in
*apc_modbus*)
nut_with_modbus_and_usb="yes"
AC_MSG_WARN([Treating explicit requests to build apc_modbus with both modbus and usb as building --with-modbus+usb=yes])
;;
*)
if test x"${with_modbus_includes}" != x -a x"${with_modbus_libs}" != x ; then
nut_with_modbus_and_usb="yes"
AC_MSG_WARN([Treating explicit requests to build NUT with both modbus (with custom includes and libs) and usb as building --with-modbus+usb=yes])
fi
;;
esac
fi
])


dnl ----------------------------------------------------------------------
dnl check for --with-drivers=all (or --with-drivers=name[,name...]) flag
dnl Note: a few drivers are NUT software constructs (NUTSW_DRIVERLIST)
Expand Down Expand Up @@ -2337,6 +2386,10 @@ if test "${nut_with_modbus}" = "yes" -a "${nut_have_libmodbus}" != "yes"; then
AC_MSG_ERROR([modbus library not found, required for Modbus drivers])
fi

if test "${nut_with_modbus_and_usb}" = "yes" -a "${nut_have_libmodbus_usb}" != "yes"; then
AC_MSG_ERROR([modbus library variant with RTU USB support not found, required for USB-capable Modbus drivers])
fi

if test "${nut_with_modbus}" != "no"; then
nut_with_modbus="${nut_have_libmodbus}"
fi
Expand Down
15 changes: 15 additions & 0 deletions docs/configure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,21 @@ Build and install modbus (Serial, TCP) drivers (default: auto-detect)

Note that you need to install libmodbus development package or files.

--with-modbus+usb

Require a variant of libmodbus with RTU USB support. This feature is
currently not available in upstream project or OS distribution packages,
so your NUT build environment should provide a prerequisite build of
https://github.com/networkupstools/libmodbus/tree/rtu_usb (may be a
static library build, used from a temporary installation prefix location,
to avoid potential conflicts with the OS packaged shared library).

At the time of this writing, such constraint can be desirable for the
linkman:apc_modbus[8] driver which supports different communication media.

For more details please see
https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol

Manual selection of drivers
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit d3b6502

Please sign in to comment.