Skip to content

Commit

Permalink
Merge pull request networkupstools#2532 from jimklimov/issue-2431
Browse files Browse the repository at this point in the history
Detect `libupsclient` SO filename, revise shared object extensions
  • Loading branch information
jimklimov authored Jul 15, 2024
2 parents 400c374 + 7108b63 commit 5740508
Show file tree
Hide file tree
Showing 30 changed files with 290 additions and 178 deletions.
6 changes: 3 additions & 3 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -157,7 +157,7 @@ installed.
[issue #2244, issue #2511, PR #2509, PR #2513, PR #2517]
* implemented parallel scanning for IPMI bus, otherwise default scan for
all supported buses with `-m auto` takes unbearably long. [#2523]
* bumped version of `libnutscan` to 2.5.2, it now includes a few more
* bumped version of `libnutscan` to 2.6.0, it now includes a few more
methods and symbols from `libcommon`. [issue #2244, PR #2509]
- common code:
Expand Down
4 changes: 3 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ which the larger potential sponsors consider when choosing how to help
FOSS projects. Keeping the lights shining in such a large non-regression
build matrix is a big undertaking!
image:https://api.star-history.com/svg?repos=networkupstools/nut&type=Date[link="https://star-history.com/#networkupstools/nut&Date" alt="Star History Chart"]
ifndef::pdf_format[]
image:https://api.star-history.com/svg?repos=networkupstools/nut&type=Date[link="https://star-history.com/#networkupstools/nut&Date" alt="NUT GitHub Star History Chart"]
endif::pdf_format[]
See <<acknowledgements-ci-ops,acknowledgements of organizations which help
with NUT CI and other daily operations>> for an overview of the shared effort.
Expand Down
1 change: 1 addition & 0 deletions clients/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/libupsclient-version.h
/upsimage.cgi
/upsset.cgi
/upsstats.cgi
Expand Down
26 changes: 26 additions & 0 deletions clients/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@

EXTRA_DIST =
CLEANFILES =

# nutclient.cpp for some legacy reason (maybe initial detached development?)
# optionally includes "common.h" with the NUT build setup - and this option
Expand Down Expand Up @@ -117,6 +118,31 @@ if HAVE_WINDOWS
libupsclient_la_LDFLAGS += -no-undefined
endif

# ./clients/libupsclient.la samples (partial!) on...
# Linux:
# # The name that we can dlopen(3).
# dlname='libupsclient.so.6'
# # Names of this library.
# library_names='libupsclient.so.6.0.1 libupsclient.so.6 libupsclient.so'
# # Directory that this library needs to be installed in:
# libdir='/usr/local/ups/lib'
# WIN32:
# dlname='libupsclient-6.dll'
# library_names='libupsclient.dll.a'
# libdir='//lib'
CLEANFILES += libupsclient-version.h
libupsclient-version.h: libupsclient.la
@dlname_filter() { sed -e 's/^[^=]*=//' -e 's/^"\(.*\)"$$/\1/' -e 's/^'"'"'\(.*\)'"'"'$$/\1/' ; }; \
SOFILE_LIBUPSCLIENT="`grep -E '^dlname' '$?' | dlname_filter`" \
|| SOFILE_LIBUPSCLIENT="" ; \
if [ x"$${SOFILE_LIBUPSCLIENT-}" = x ] ; then \
printf "#ifdef SOFILE_LIBUPSCLIENT\n# undef SOFILE_LIBUPSCLIENT\n#endif\n\n" ; \
printf "#ifdef SOPATH_LIBUPSCLIENT\n# undef SOPATH_LIBUPSCLIENT\n#endif\n\n" ; \
else \
printf "#ifndef SOFILE_LIBUPSCLIENT\n# define SOFILE_LIBUPSCLIENT \"%s\"\n#endif\n\n" "$${SOFILE_LIBUPSCLIENT}" ; \
printf "#ifndef SOPATH_LIBUPSCLIENT\n# define SOPATH_LIBUPSCLIENT \"%s/%s\"\n#endif\n\n" "@LIBDIR@" "$${SOFILE_LIBUPSCLIENT}" ; \
fi > "$@"

if HAVE_CXX11
# libnutclient version information and build
libnutclient_la_SOURCES = nutclient.h nutclient.cpp
Expand Down
20 changes: 10 additions & 10 deletions clients/upsclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@

/* WA for Solaris/i386 bug: non-blocking connect sets errno to ENOENT */
#if (defined NUT_PLATFORM_SOLARIS)
#define SOLARIS_i386_NBCONNECT_ENOENT(status) ( (!strcmp("i386", CPU_TYPE)) ? (ENOENT == (status)) : 0 )
# define SOLARIS_i386_NBCONNECT_ENOENT(status) ( (!strcmp("i386", CPU_TYPE)) ? (ENOENT == (status)) : 0 )
#else
#define SOLARIS_i386_NBCONNECT_ENOENT(status) (0)
# define SOLARIS_i386_NBCONNECT_ENOENT(status) (0)
#endif /* end of Solaris/i386 WA for non-blocking connect */

/* WA for AIX bug: non-blocking connect sets errno to 0 */
#if (defined NUT_PLATFORM_AIX)
#define AIX_NBCONNECT_0(status) (0 == (status))
# define AIX_NBCONNECT_0(status) (0 == (status))
#else
#define AIX_NBCONNECT_0(status) (0)
# define AIX_NBCONNECT_0(status) (0)
#endif /* end of AIX WA for non-blocking connect */

#ifdef WITH_NSS
#include <prerror.h>
#include <prinit.h>
#include <pk11func.h>
#include <prtypes.h>
#include <ssl.h>
#include <private/pprio.h>
# include <prerror.h>
# include <prinit.h>
# include <pk11func.h>
# include <prtypes.h>
# include <ssl.h>
# include <private/pprio.h>
#endif /* WITH_NSS */

#define UPSCLIENT_MAGIC 0x19980308
Expand Down
14 changes: 7 additions & 7 deletions clients/upsclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@
#define UPSCLIENT_H_SEEN 1

#ifdef WITH_OPENSSL
#include <openssl/err.h>
#include <openssl/ssl.h>
# include <openssl/err.h>
# include <openssl/ssl.h>
#elif defined(WITH_NSS) /* WITH_OPENSSL */
#include <nss.h>
#include <ssl.h>
# include <nss.h>
# include <ssl.h>
#endif /* WITH_OPENSSL | WITH_NSS */

/* Not including nut_stdint.h because this is part of end-user API */
#if defined HAVE_INTTYPES_H
#include <inttypes.h>
# include <inttypes.h>
#endif

#if defined HAVE_STDINT_H
#include <stdint.h>
# include <stdint.h>
#endif

#if defined HAVE_LIMITS_H
#include <limits.h>
# include <limits.h>
#endif

/* Not including NUT timehead.h because this is part of end-user API */
Expand Down
2 changes: 1 addition & 1 deletion clients/upsmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static void wall(const char *text)
fprintf(wf, "%s\n", text);
pclose(wf);
#else
#define MESSAGE_CMD "message.exe"
# define MESSAGE_CMD "message.exe"
char * command;

/* first +1 is for the space between message and text
Expand Down
8 changes: 4 additions & 4 deletions common/nutwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ NutWriter::status_t UpsmonConfigWriter::writeConfig(const UpsmonConfiguration &
* \param arg Directive argument
* \param quote_arg Boolean flag; check to quote the argument
*/
#define UPSMON_DIRECTIVEX(name, arg_t, arg, quote_arg) \
# define UPSMON_DIRECTIVEX(name, arg_t, arg, quote_arg) \
CONFIG_DIRECTIVEX(name, arg_t, arg, quote_arg)

/* The "false" arg in macro below evaluates to `if (false) ...` after
Expand Down Expand Up @@ -631,7 +631,7 @@ NutWriter::status_t UpsmonConfigWriter::writeConfig(const UpsmonConfiguration &
# pragma GCC diagnostic pop
#endif

#undef UPSMON_DIRECTIVEX
# undef UPSMON_DIRECTIVEX

// Certificate identity
if (config.certIdent.set()) {
Expand Down Expand Up @@ -735,7 +735,7 @@ NutWriter::status_t UpsdConfigWriter::writeConfig(const UpsdConfiguration & conf
* \param arg_t Directive argument implementation type
* \param arg Directive argument
*/
#define UPSD_DIRECTIVEX(name, arg_t, arg) \
# define UPSD_DIRECTIVEX(name, arg_t, arg) \
CONFIG_DIRECTIVEX(name, arg_t, arg, false)

/* The "false" arg in macro below evaluates to `if (false) ...` after
Expand Down Expand Up @@ -769,7 +769,7 @@ NutWriter::status_t UpsdConfigWriter::writeConfig(const UpsdConfiguration & conf
# pragma GCC diagnostic pop
#endif

#undef UPSD_DIRECTIVEX
# undef UPSD_DIRECTIVEX

// Certificate identity
if (config.certIdent.set()) {
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ DOCBUILD_CONVERT_GITHUB_LINKS = { \

dummy:
$(top_builddir)/ChangeLog: dummy
+@echo " DOC-CHANGELOG-GENERATE $@ : call parent Makefile" \
@+echo " DOC-CHANGELOG-GENERATE-WRAPPER $@ : call parent Makefile to decide if (re-)generation is needed" \
&& cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) $(@F)

# BSD Make dislikes the path resolution here and does not always populate "$<"
Expand Down
30 changes: 25 additions & 5 deletions docs/config-prereqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ metadata about recently published package revisions:

:; apt-get install \
ccache time \
git python perl curl \
git perl curl \
make autoconf automake libltdl-dev libtool \
valgrind \
cppcheck \
Expand All @@ -152,6 +152,10 @@ metadata about recently published package revisions:
:; apt-get install \
libtool-bin

# See comments below, python version and package naming depends on distro
:; apt-get install \
python

# NOTE: For python, you may eventually have to specify a variant like this
# (numbers depending on default or additional packages of your distro):
# :; apt-get install python2 python2.7 python-is-python2
Expand Down Expand Up @@ -338,13 +342,17 @@ drivers in distro packaging of NUT. Resolution and doc PRs are welcome.
:; yum install \
ccache time \
file \
git python perl curl \
git perl curl \
make autoconf automake libtool-ltdl-devel libtool \
valgrind \
cppcheck \
pkgconfig \
gcc gcc-c++ clang

# See comments below, python version and package naming depends on distro
:; yum install \
python

# NOTE: For python, you may eventually have to specify a variant like this
# (numbers depending on default or additional packages of your distro):
# :; yum install python-2.7.5
Expand Down Expand Up @@ -688,13 +696,17 @@ below.

------
:; pkg install \
git python perl5 curl \
git perl5 curl \
gmake autoconf automake autotools libltdl libtool \
valgrind \
cppcheck \
pkgconf \
gcc clang

# See comments below, python version and package naming depends on distro
:; pkg install \
python

# NOTE: For python, you may eventually have to specify a variant like this
# (numbers depending on default or additional packages of your distro):
# :; pkg install python2 python27
Expand Down Expand Up @@ -816,13 +828,17 @@ default site.
:; pkg_add sudo bash mc wget rsync

:; pkg_add \
git python curl \
git curl \
gmake autoconf automake libltdl libtool \
valgrind \
cppcheck \
pkgconf \
gcc clang

# See comments below, python version and package naming depends on distro
:; pkg_add \
python

# NOTE: For python, you may eventually have to specify a variant like this
# (numbers depending on default or additional packages of your distro):
# :; pkg_add python-2.7.15p0 py-pip
Expand Down Expand Up @@ -956,12 +972,16 @@ you can work around by `make MKDIRPROG="mkdir -p" install -j 8` for example.

------
:; pkgin install \
git python27 python39 perl curl \
git perl curl \
make gmake autoconf automake libltdl libtool \
cppcheck \
pkgconf \
gcc7 clang

# See comments below, python version and package naming depends on distro
:; apt-get install \
python27 python39

;; ( cd /usr/pkg/bin && ( ln -fs python2.7 python2 ; ln -fs python3.9 python3 ) )
# You can find a list of what is (pre-)installed with:
# :; pkgin list | grep -Ei 'perl|python'
Expand Down
2 changes: 1 addition & 1 deletion docs/man/hwmon_ina219.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Optional parameters:
Threshold for low battery state (in percent).

*default.battery.voltage.nominal*='voltage-value'::
Nominal voltage (V) value of utilised batteries, used to derive their low
Nominal voltage (V) value of utilized batteries, used to derive their low
and high watermark settings (see below). Default: 3.6.
+
Known pre-sets include: `3.6`, `3.7`, `3.8`, `3.85`.
Expand Down
3 changes: 2 additions & 1 deletion docs/nut.dict
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
personal_ws-1.1 en 3189 utf-8
personal_ws-1.1 en 3190 utf-8
AAC
AAS
ABI
Expand Down Expand Up @@ -979,6 +979,7 @@ REPLBATT
REQSSL
RETPCT
REXX
RISC
RK
RMCARD
RMCPplus
Expand Down
6 changes: 3 additions & 3 deletions drivers/apc-mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ static info_lkp_t apcc_transfer_reasons[] = {
#define APCC_REBOOT_DO 2
#define APCC_REBOOT_GRACEFUL 3
#if 0 /* not used. */
#define APCC_OID_SLEEP ".1.3.6.1.4.1.318.1.1.1.6.2.3"
#define APCC_SLEEP_ON "2"
#define APCC_SLEEP_GRACEFUL "3"
# define APCC_OID_SLEEP ".1.3.6.1.4.1.318.1.1.1.6.2.3"
# define APCC_SLEEP_ON "2"
# define APCC_SLEEP_GRACEFUL "3"
#endif


Expand Down
4 changes: 2 additions & 2 deletions drivers/hwmon_ina219.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#include <sys/types.h>

#ifndef STRFY0
#define STRFY0(x) #x
# define STRFY0(x) #x
#endif
#ifndef STRFY
#define STRFY(x) STRFY0(x)
# define STRFY(x) STRFY0(x)
#endif

#define SYSFS_HWMON_DIR "/sys/class/hwmon"
Expand Down
6 changes: 3 additions & 3 deletions drivers/libhid.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* @file libhid.c
* @brief HID Library - User API (Generic HID Access using MGE HIDParser)
* @brief NUT HID Library - User API (Generic HID Access using MGE HIDParser)
*
* @author Copyright (C) 2003 - 2007
* Arnaud Quette <[email protected]> && <[email protected]>
Expand Down Expand Up @@ -47,10 +47,10 @@

/* Communication layers and drivers (USB and MGE SHUT) */
#if (defined SHUT_MODE) && SHUT_MODE
#include "libshut.h"
# include "libshut.h"
communication_subdriver_t *comm_driver = &shut_subdriver;
#else /* !SHUT_MODE => USB */
#include "nut_libusb.h"
# include "nut_libusb.h"
communication_subdriver_t *comm_driver = &usb_subdriver;
#endif /* SHUT_MODE / USB */

Expand Down
10 changes: 5 additions & 5 deletions drivers/libhid.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* @file libhid.h
* @brief HID Library - User API
* @brief NUT HID Library - User API
*
* @author Copyright (C) 2003 - 2007
* Arnaud Quette <[email protected]> && <[email protected]>
Expand Down Expand Up @@ -44,19 +44,19 @@
#include "timehead.h"

#if (defined SHUT_MODE) && SHUT_MODE
#include "libshut.h"
# include "libshut.h"
typedef SHUTDevice_t HIDDevice_t;
typedef char HIDDeviceMatcher_t;
typedef usb_dev_handle hid_dev_handle_t;
typedef shut_communication_subdriver_t communication_subdriver_t;
#define HID_DEV_HANDLE_CLOSED (hid_dev_handle_t)(ERROR_FD_SER)
# define HID_DEV_HANDLE_CLOSED (hid_dev_handle_t)(ERROR_FD_SER)
#else /* !SHUT_MODE => USB */
#include "nut_libusb.h" /* includes usb-common.h */
# include "nut_libusb.h" /* includes usb-common.h */
typedef USBDevice_t HIDDevice_t;
typedef USBDeviceMatcher_t HIDDeviceMatcher_t;
typedef usb_dev_handle * hid_dev_handle_t;
typedef usb_communication_subdriver_t communication_subdriver_t;
#define HID_DEV_HANDLE_CLOSED (hid_dev_handle_t)(NULL)
# define HID_DEV_HANDLE_CLOSED (hid_dev_handle_t)(NULL)
#endif /* SHUT_MODE / USB */

/* use explicit booleans */
Expand Down
Loading

0 comments on commit 5740508

Please sign in to comment.