diff --git a/NEWS.adoc b/NEWS.adoc index 25aa295e61..0ee525b938 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -142,8 +142,8 @@ https://github.com/networkupstools/nut/milestone/11 we can store and try to use the file name which was present on the build system, while we search for a suitable library. [#2431] + -NOTE: Currently both the long and short names for `libupsclient` should be -installed. +NOTE: A different but functionally equivalent trick is done for `libupsclient` +during a NUT build. * fixed support for IPv6 addresses (passed in square brackets) for both `-s` start/`-e` end command-line options, and for `-m cidr/mask` option. [issue #2512, PR #2518] diff --git a/tools/nut-scanner/Makefile.am b/tools/nut-scanner/Makefile.am index a5bdd84372..78bab5633d 100644 --- a/tools/nut-scanner/Makefile.am +++ b/tools/nut-scanner/Makefile.am @@ -11,6 +11,8 @@ # Generally, list headers and/or sources which are re-generated # for nut-scanner in the parent dir +# Note there is also a libupsclient-version.h which we ensure and +# manage via usual `make` dependencies below. NUT_SCANNER_DEPS_H = nutscan-usb.h nutscan-snmp.h NUT_SCANNER_DEPS_C = @@ -28,6 +30,7 @@ $(NUT_SCANNER_DEPS): dummy # Make sure out-of-dir dependencies exist (especially when dev-building parts): $(top_builddir)/include/nut_version.h \ +$(top_builddir)/clients/libupsclient-version.h \ $(top_builddir)/common/libnutwincompat.la \ $(top_builddir)/drivers/libserial-nutscan.la \ $(top_builddir)/common/libcommonstr.la \ @@ -39,6 +42,7 @@ $(top_builddir)/common/libcommon.la: dummy # BUILT_SOURCES (in ../include) will ensure nut_version.h will # be built before anything else nut-scanner.c: $(top_builddir)/include/nut_version.h +nutscan-init.c: $(top_builddir)/clients/libupsclient-version.h # We optionally append values to this below bin_PROGRAMS = @@ -97,13 +101,17 @@ libnutscan_la_LDFLAGS += -version-info 2:6:0 # One solution to tackle if needed for those cases would be to make some # dynamic/shared libnutcommon (etc.) libnutscan_la_LDFLAGS += -export-symbols-regex '^(nutscan_|nut_debug_level|s_upsdebug|fatalx|fatal_with_errno|xcalloc|snprintfcat|max_threads|curr_threads|nut_report_config_flags|upsdebugx_report_search_paths|nut_prepare_search_paths)' -libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include \ +libnutscan_la_CFLAGS = \ + -I$(top_builddir)/clients -I$(top_srcdir)/clients \ + -I$(top_builddir)/include -I$(top_srcdir)/include \ $(LIBLTDL_CFLAGS) -I$(top_srcdir)/drivers libnutscan_la_LIBADD += $(top_builddir)/common/libcommonstr.la nut_scanner_SOURCES = nut-scanner.c -nut_scanner_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include +nut_scanner_CFLAGS = \ + -I$(top_builddir)/clients -I$(top_srcdir)/clients \ + -I$(top_builddir)/include -I$(top_srcdir)/include nut_scanner_LDADD = libnutscan.la if WITH_SSL diff --git a/tools/nut-scanner/nutscan-init.c b/tools/nut-scanner/nutscan-init.c index aad15c69d6..609c9a04d2 100644 --- a/tools/nut-scanner/nutscan-init.c +++ b/tools/nut-scanner/nutscan-init.c @@ -37,6 +37,11 @@ #include "nut_platform.h" #include "nut_stdint.h" +/* Note: generated during build in $(top_builddir)/clients/ + * and should be ensured to be here at the right moment by + * the nut-scanner Makefile. */ +#include "libupsclient-version.h" + #ifdef WIN32 # if defined HAVE_WINSOCK2_H && HAVE_WINSOCK2_H # include @@ -542,12 +547,22 @@ void nutscan_init(void) #endif /* WITH_FREEIPMI */ /* start of libupsclient for "old NUT" (vs. Avahi) protocol - unconditional */ +#ifdef SOFILE_LIBUPSCLIENT + if (!libname) { + libname = get_libname(SOFILE_LIBUPSCLIENT); + } +#endif /* SOFILE_LIBUPSCLIENT */ if (!libname) { libname = get_libname("libupsclient" SOEXT); } +#ifdef SOPATH_LIBUPSCLIENT + if (!libname) { + libname = get_libname(SOPATH_LIBUPSCLIENT); + } +#endif /* SOPATH_LIBUPSCLIENT */ #ifdef WIN32 - /* TODO: Detect DLL name at build time, or rename it at install time? */ - /* e.g. see clients/Makefile.am for version-info value */ + /* NOTE: Normally we should detect DLL name at build time, + * see clients/Makefile.am for libupsclient-version.h */ if (!libname) { libname = get_libname("libupsclient-6" SOEXT); } @@ -566,6 +581,11 @@ void nutscan_init(void) upsdebugx(1, "%s: get_libname() did not resolve libname for %s, " "trying to load it with libtool default resolver", __func__, "NUT Client library"); +#ifdef SOFILE_LIBUPSCLIENT + if (!nutscan_avail_nut) { + nutscan_avail_xml_http = nutscan_load_upsclient_library(SOFILE_LIBUPSCLIENT); + } +#endif /* SOFILE_LIBUPSCLIENT */ nutscan_avail_nut = nutscan_load_upsclient_library("libupsclient" SOEXT); #ifdef WIN32 if (!nutscan_avail_nut) { @@ -575,6 +595,11 @@ void nutscan_init(void) nutscan_avail_nut = nutscan_load_upsclient_library("libupsclient-3" SOEXT); } #endif /* WIN32 */ +#ifdef SOPATH_LIBUPSCLIENT + if (!nutscan_avail_nut) { + nutscan_avail_xml_http = nutscan_load_upsclient_library(SOPATH_LIBUPSCLIENT); + } +#endif /* SOFILE_LIBUPSCLIENT */ } upsdebugx(1, "%s: %s to load the library for %s", __func__, nutscan_avail_nut ? "succeeded" : "failed", "NUT Client library");