diff --git a/m4/nut_check_libavahi.m4 b/m4/nut_check_libavahi.m4 index d49ea063ca..0e8782a366 100644 --- a/m4/nut_check_libavahi.m4 +++ b/m4/nut_check_libavahi.m4 @@ -7,7 +7,7 @@ AC_DEFUN([NUT_CHECK_LIBAVAHI], [ if test -z "${nut_have_avahi_seen}"; then nut_have_avahi_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" diff --git a/m4/nut_check_libfreeipmi.m4 b/m4/nut_check_libfreeipmi.m4 index 85b4912152..1d563013e1 100644 --- a/m4/nut_check_libfreeipmi.m4 +++ b/m4/nut_check_libfreeipmi.m4 @@ -8,7 +8,7 @@ AC_DEFUN([NUT_CHECK_LIBFREEIPMI], [ if test -z "${nut_have_libfreeipmi_seen}"; then nut_have_libfreeipmi_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" diff --git a/m4/nut_check_libgd.m4 b/m4/nut_check_libgd.m4 index b8d4329710..fbba3a8624 100644 --- a/m4/nut_check_libgd.m4 +++ b/m4/nut_check_libgd.m4 @@ -7,7 +7,7 @@ AC_DEFUN([NUT_CHECK_LIBGD], [ if test -z "${nut_have_libgd_seen}"; then nut_have_libgd_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) CFLAGS_ORIG="${CFLAGS}" LDFLAGS_ORIG="${LDFLAGS}" diff --git a/m4/nut_check_libgpiod.m4 b/m4/nut_check_libgpiod.m4 index e5f50cfecb..dd2b0b5cf9 100644 --- a/m4/nut_check_libgpiod.m4 +++ b/m4/nut_check_libgpiod.m4 @@ -7,7 +7,7 @@ AC_DEFUN([NUT_CHECK_LIBGPIO], [ if test -z "${nut_have_gpio_seen}"; then nut_have_gpio_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" diff --git a/m4/nut_check_libmodbus.m4 b/m4/nut_check_libmodbus.m4 index 359a7ea36c..cf312d4d77 100644 --- a/m4/nut_check_libmodbus.m4 +++ b/m4/nut_check_libmodbus.m4 @@ -7,7 +7,7 @@ AC_DEFUN([NUT_CHECK_LIBMODBUS], [ if test -z "${nut_have_libmodbus_seen}"; then nut_have_libmodbus_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" @@ -73,29 +73,35 @@ if test -z "${nut_have_libmodbus_seen}"; then CFLAGS="${CFLAGS_ORIG} ${depCFLAGS}" LIBS="${LIBS_ORIG} ${depLIBS}" AC_CHECK_HEADERS(modbus.h, [nut_have_libmodbus=yes], [nut_have_libmodbus=no], [AC_INCLUDES_DEFAULT]) - AC_CHECK_FUNCS(modbus_new_rtu, [], [nut_have_libmodbus=no]) - AC_CHECK_FUNCS(modbus_new_tcp, [], [nut_have_libmodbus=no]) - AC_CHECK_FUNCS(modbus_set_byte_timeout, [], [nut_have_libmodbus=no]) - AC_CHECK_FUNCS(modbus_set_response_timeout, [], [nut_have_libmodbus=no]) + AS_IF([test x"${nut_have_libmodbus}" = xyes ], [ + AC_CHECK_FUNCS(modbus_new_rtu, [], [nut_have_libmodbus=no]) + AC_CHECK_FUNCS(modbus_new_tcp, [], [nut_have_libmodbus=no]) + AC_CHECK_FUNCS(modbus_set_byte_timeout, [], [nut_have_libmodbus=no]) + AC_CHECK_FUNCS(modbus_set_response_timeout, [], [nut_have_libmodbus=no]) + ]) - AC_CHECK_FUNCS(modbus_new_rtu_usb, [nut_have_libmodbus_usb=yes], [ - nut_have_libmodbus_usb=no - AS_IF([test x"${nut_with_usb}" != xno && test x"${nut_with_modbus}" != xno && test x"${nut_have_libmodbus}" = xyes ], [ - dnl Retry with LibUSB dependency settings if we - dnl know we are not opposed to pulling it in. - dnl Static libmodbus builds do not refer to - dnl (shared) libusb for example. - NUT_CHECK_LIBUSB - AC_MSG_NOTICE([Retry detection of libmodbus USB support]) - CFLAGS="$CFLAGS $LIBUSB_CFLAGS" - LIBS="$LIBS $LIBUSB_LIBS" - unset ac_cv_func_modbus_new_rtu_usb - AC_CHECK_FUNCS(modbus_new_rtu_usb, [nut_have_libmodbus_usb=yes], [ - AS_IF([test x"${nut_with_usb}" = xyes && test x"${nut_with_modbus}" = xyes && test x"${nut_have_libmodbus}" = xyes ], [ - AC_MSG_WARN([Both --with-modbus and --with-usb were requested, and a libmodbus was found, but it seems to not support USB. You may require a custom build per https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol]) + AS_IF([test x"${nut_have_libmodbus}" = xyes ], [ + AC_CHECK_FUNCS(modbus_new_rtu_usb, [nut_have_libmodbus_usb=yes], [ + nut_have_libmodbus_usb=no + AS_IF([test x"${nut_with_usb}" != xno && test x"${nut_with_modbus}" != xno && test x"${nut_have_libmodbus}" = xyes ], [ + dnl Retry with LibUSB dependency settings if we + dnl know we are not opposed to pulling it in. + dnl Static libmodbus builds do not refer to + dnl (shared) libusb for example. + AC_REQUIRE([NUT_CHECK_LIBUSB]) + AC_MSG_NOTICE([Retry detection of libmodbus USB support]) + CFLAGS="$CFLAGS $LIBUSB_CFLAGS" + LIBS="$LIBS $LIBUSB_LIBS" + unset ac_cv_func_modbus_new_rtu_usb + AC_CHECK_FUNCS(modbus_new_rtu_usb, [nut_have_libmodbus_usb=yes], [ + AS_IF([test x"${nut_with_usb}" = xyes && test x"${nut_with_modbus}" = xyes && test x"${nut_have_libmodbus}" = xyes ], [ + AC_MSG_WARN([Both --with-modbus and --with-usb were requested, and a libmodbus was found, but it seems to not support USB. You may require a custom build per https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol]) + ]) ]) ]) ]) + ], [ + nut_have_libmodbus_usb=no ]) dnl modbus_set_byte_timeout() and modbus_set_response_timeout() diff --git a/m4/nut_check_libneon.m4 b/m4/nut_check_libneon.m4 index 864b83b8ef..a20d8328fb 100644 --- a/m4/nut_check_libneon.m4 +++ b/m4/nut_check_libneon.m4 @@ -7,7 +7,7 @@ AC_DEFUN([NUT_CHECK_LIBNEON], [ if test -z "${nut_have_neon_seen}"; then nut_have_neon_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" diff --git a/m4/nut_check_libnetsnmp.m4 b/m4/nut_check_libnetsnmp.m4 index 9e11e5b29e..78d5fa9d61 100644 --- a/m4/nut_check_libnetsnmp.m4 +++ b/m4/nut_check_libnetsnmp.m4 @@ -8,7 +8,7 @@ AC_DEFUN([NUT_CHECK_LIBNETSNMP], [ if test -z "${nut_have_libnetsnmp_seen}"; then nut_have_libnetsnmp_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) AC_LANG_PUSH([C]) dnl save CFLAGS and LIBS diff --git a/m4/nut_check_libnss.m4 b/m4/nut_check_libnss.m4 index 89ae23d81b..f3b0a60bf1 100644 --- a/m4/nut_check_libnss.m4 +++ b/m4/nut_check_libnss.m4 @@ -7,7 +7,7 @@ AC_DEFUN([NUT_CHECK_LIBNSS], [ if test -z "${nut_have_libnss_seen}"; then nut_have_libnss_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" diff --git a/m4/nut_check_libopenssl.m4 b/m4/nut_check_libopenssl.m4 index 88c5651bdd..0eeaa13260 100644 --- a/m4/nut_check_libopenssl.m4 +++ b/m4/nut_check_libopenssl.m4 @@ -8,7 +8,7 @@ AC_DEFUN([NUT_CHECK_LIBOPENSSL], [ if test -z "${nut_have_libopenssl_seen}"; then nut_have_libopenssl_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" diff --git a/m4/nut_check_libpowerman.m4 b/m4/nut_check_libpowerman.m4 index 19811632e5..f263a61a31 100644 --- a/m4/nut_check_libpowerman.m4 +++ b/m4/nut_check_libpowerman.m4 @@ -7,7 +7,7 @@ AC_DEFUN([NUT_CHECK_LIBPOWERMAN], [ if test -z "${nut_have_libpowerman_seen}"; then nut_have_libpowerman_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" diff --git a/m4/nut_check_libregex.m4 b/m4/nut_check_libregex.m4 index 204a6ef560..dd4c49b595 100644 --- a/m4/nut_check_libregex.m4 +++ b/m4/nut_check_libregex.m4 @@ -8,7 +8,7 @@ AC_DEFUN([NUT_CHECK_LIBREGEX], [ if test -z "${nut_have_libregex_seen}"; then nut_have_libregex_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" diff --git a/m4/nut_check_libsystemd.m4 b/m4/nut_check_libsystemd.m4 index 951d6b128d..671c2bb7ce 100644 --- a/m4/nut_check_libsystemd.m4 +++ b/m4/nut_check_libsystemd.m4 @@ -7,7 +7,7 @@ AC_DEFUN([NUT_CHECK_LIBSYSTEMD], [ if test -z "${nut_have_libsystemd_seen}"; then nut_have_libsystemd_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" diff --git a/m4/nut_check_libusb.m4 b/m4/nut_check_libusb.m4 index 121fd400a3..f85490f51d 100644 --- a/m4/nut_check_libusb.m4 +++ b/m4/nut_check_libusb.m4 @@ -12,10 +12,10 @@ AC_DEFUN([NUT_CHECK_LIBUSB], [ if test -z "${nut_have_libusb_seen}"; then nut_have_libusb_seen=yes - NUT_CHECK_PKGCONFIG + AC_REQUIRE([NUT_CHECK_PKGCONFIG]) dnl Our USB matching relies on regex abilities - NUT_CHECK_LIBREGEX + AC_REQUIRE([NUT_CHECK_LIBREGEX]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}"