Skip to content

Commit

Permalink
Merge pull request #2481 from jimklimov/issue-1316
Browse files Browse the repository at this point in the history
Combine several small PRs for issue #1316 and their NEWS entries
  • Loading branch information
jimklimov authored Jun 24, 2024
2 parents 17ae811 + 84f5863 commit 1d79d6e
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ endif

DISTCHECK_FLAGS = --with-all --with-ssl --with-doc=auto --with-pynut=app --with-nut_monitor=force
DISTCHECK_LIGHT_FLAGS = --with-all=auto --with-ssl=auto --with-doc=auto --with-pynut=app --with-nut_monitor=force
DISTCHECK_LIGHT_MAN_FLAGS = --with-all=auto --with-ssl=auto --with-doc=man --with-pynut=app --with-nut_monitor=force
DISTCHECK_VALGRIND_FLAGS = --with-all=auto --with-ssl=auto --with-doc=skip --with-valgrind CXXFLAGS='$(CXXFLAGS) -g' CFLAGS='$(CFLAGS) -g' --with-pynut=app --with-nut_monitor=force

# Note: this rule uses envvar DISTCHECK_FLAGS expanded at run-time
Expand All @@ -90,6 +91,9 @@ distcheck-light:
memcheck distcheck-valgrind:
+$(MAKE) $(AM_MAKEFLAGS) DISTCHECK_FLAGS="$(DISTCHECK_VALGRIND_FLAGS)" distcheck

distcheck-light-man:
+$(MAKE) $(AM_MAKEFLAGS) DISTCHECK_FLAGS="$(DISTCHECK_LIGHT_MAN_FLAGS)" distcheck

# workaround the dist generated files that are also part of the distribution
# Note that distcleancheck is disabled for now, while waiting for a proper
# solution, that do not break older unix systems
Expand Down
14 changes: 14 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,20 @@ https://github.com/networkupstools/nut/milestone/11
+
NOTE: The `html-chunked` documents are currently still not installed.
- added support to `./configure --with-doc=man=dist-auto` to use distributed
manual page files if present; only fall back to build them if we can. [#2473]
- added a `make distcheck-light-man` recipe to require verification that the
manual page files can be built using the prepared "tarball" archive. [#2473]
- added a `common/Makefile.am` build product for a new internal library
`libcommonstr.la` which allows a smaller selection of helper methods
for tools like `nut-scanner` which do not need the full `libcommon.la`
nor `libcommonclient.la`. [#2478]
- build of `snmp-ups` and `netxml-ups` drivers now explicitly brings linker
dependency on chosen SSL libraries. [#2479]
- brought keyword dictionaries of `nutconf` and `augeas` NUT configuration
file parsers up to date; restored automated checks for `augeas` lenses.
[issue #657, issue #2294]
Expand Down
18 changes: 18 additions & 0 deletions common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,22 @@ $(top_builddir)/include/nut_version.h:

libcommon_la_SOURCES = state.c str.c upsconf.c
libcommonclient_la_SOURCES = state.c str.c

# several other Makefiles include the two helpers common.c str.c (and
# perhaps some other string-related code), so make them a library too;
# note that LTLIBOBJS pulls in snprintf.c contents too.
noinst_LTLIBRARIES += libcommonstr.la
libcommonstr_la_SOURCES = str.c
libcommonstr_la_CFLAGS = $(AM_CFLAGS) -DWITHOUT_LIBSYSTEMD=1
libcommonstr_la_LIBADD = @LTLIBOBJS@ @BSDKVMPROCLIBS@

if BUILDING_IN_TREE
libcommon_la_SOURCES += common.c
libcommonstr_la_SOURCES += common.c
libcommonclient_la_SOURCES += common.c
else !BUILDING_IN_TREE
nodist_libcommon_la_SOURCES = common.c
nodist_libcommonstr_la_SOURCES = common.c
nodist_libcommonclient_la_SOURCES = common.c
CLEANFILES += $(top_builddir)/common/common.c
BUILT_SOURCES = common.c
Expand All @@ -62,6 +73,7 @@ if HAVE_STRPTIME
else !HAVE_STRPTIME
# fall back to NetBSD implem
libcommon_la_SOURCES += strptime.c
libcommonstr_la_SOURCES += strptime.c
libcommonclient_la_SOURCES += strptime.c
endif !HAVE_STRPTIME

Expand All @@ -70,6 +82,7 @@ if HAVE_STRNLEN
else !HAVE_STRNLEN
# fall back to FreeBSD implem
libcommon_la_SOURCES += strnlen.c
libcommonstr_la_SOURCES += strnlen.c
libcommonclient_la_SOURCES += strnlen.c
endif !HAVE_STRNLEN

Expand All @@ -78,6 +91,7 @@ if HAVE_STRSEP
else !HAVE_STRSEP
# fall back to simple implem
libcommon_la_SOURCES += strsep.c
libcommonstr_la_SOURCES += strsep.c
libcommonclient_la_SOURCES += strsep.c
endif !HAVE_STRSEP

Expand All @@ -92,6 +106,7 @@ if HAVE_WINDOWS
noinst_LTLIBRARIES += libnutwincompat.la

libcommon_la_SOURCES += wincompat.c $(top_srcdir)/include/wincompat.h
libcommonstr_la_SOURCES += wincompat.c $(top_srcdir)/include/wincompat.h
libcommonclient_la_SOURCES += wincompat.c $(top_srcdir)/include/wincompat.h
endif HAVE_WINDOWS

Expand All @@ -112,6 +127,9 @@ if HAVE_LIBREGEX
libcommon_la_CFLAGS += $(LIBREGEX_CFLAGS)
libcommon_la_LIBADD += $(LIBREGEX_LIBS)

libcommonstr_la_CFLAGS += $(LIBREGEX_CFLAGS)
libcommonstr_la_LIBADD += $(LIBREGEX_LIBS)

libcommonclient_la_CFLAGS += $(LIBREGEX_CFLAGS)
libcommonclient_la_LIBADD += $(LIBREGEX_LIBS)
endif HAVE_LIBREGEX
Expand Down
34 changes: 28 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2291,6 +2291,8 @@ fi
NUT_REPORT_FEATURE([enable libltdl (Libtool dlopen abstraction) support], [${nut_with_libltdl}], [],
[WITH_LIBLTDL], [Define to enable libltdl (Libtool dlopen abstraction) support])

dnl Explicitly report if we are building nut-scanner or not
dnl since it requires libltdl
if test x"${nut_with_libltdl}" = x"no" && test x"${nut_with_nut_scanner}" = x"yes"; then
AC_MSG_ERROR([libltdl support was disabled or not found, but --with-nut-scanner was requested and requires it])
fi
Expand Down Expand Up @@ -2686,6 +2688,9 @@ case "${nut_with_doc}" in
skip|all=skip)
nut_doc_build_list="man=skip html-single=skip html-chunked=skip pdf=skip"
;;
dist-auto) # Experimental, currently only for MANs: prefer disted files if present, auto otherwise
nut_doc_build_list="man=dist-auto html-single=dist-auto html-chunked=dist-auto pdf=dist-auto"
;;
no|all=no)
nut_doc_build_list=""
;;
Expand Down Expand Up @@ -2726,7 +2731,7 @@ for nut_doc_build_target in $nut_doc_build_list; do
;;
esac
case "${nut_doc_build_target_flag}" in
yes|no|auto|skip) ;;
yes|no|auto|skip|dist-auto) ;;
"") nut_doc_build_target_flag="yes" ;;
*) rm -rf "${DOCTESTDIR}"
AC_MSG_ERROR([Invalid documentation format option: ${nut_doc_build_target}]) ;;
Expand Down Expand Up @@ -2817,32 +2822,49 @@ dnl not fail if we have no tools to generate it (so add to SKIP list).
;;

man*)
dnl Experimental support for --with-doc=man=dist-auto to prefer pre-disted docs if available, below
AC_MSG_CHECKING([if we can build ${nut_doc_build_target_base}])
can_build_doc_man=no
have_disted_doc_man=no
want_disted_doc_man=no
if test -s "${abs_srcdir}"/docs/man/snmp-ups.8 ; then
dnl Test that groff files exist (building from distributed tarball, not git repo)
have_disted_doc_man=yes
fi
if test x"${nut_doc_build_target}" = x"man=dist-auto" || test "${nut_doc_build_target_flag}" = "dist-auto"; then
want_disted_doc_man=yes
fi
if test "${nut_have_asciidoc}" = yes ; then
( cd "$DOCTESTDIR" && ${A2X} --format manpage --destination-dir=. --xsltproc-opts="--nonet" "${abs_srcdir}"/docs/man/snmp-ups.txt && test -s snmp-ups.8 ) && can_build_doc_man=yes
rm -f "${DOCTESTDIR}"/snmp-ups.8
fi
if test "${can_build_doc_man}" = yes ; then
if test "${want_disted_doc_man}" = yes && test "${have_disted_doc_man}" = yes ; then
AC_MSG_NOTICE([Requested, and can, install pre-built distributed copies of ${nut_doc_build_target_base} documentation])
DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}"
DOC_INSTALL_DISTED_MANS="yes"
dnl Avoid rebuilding existing build products due to their timestamp dependencies:
touch -r "${abs_srcdir}"/docs/man/Makefile.am "${abs_srcdir}"/docs/man/*.{1,2,3,4,5,6,7,8,9}* "${abs_srcdir}"/docs/man/*.{txt,xml,html,pdf} || true
else
if test "${can_build_doc_man}" = yes ; then
AC_MSG_RESULT(yes)
DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}"
else
else
AC_MSG_RESULT(no)
if test "${nut_doc_build_target_flag}" = "yes" ; then
DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}"
AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested])
else
DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}"
if test "${nut_doc_build_target_flag}" = "auto" ; then
dnl Test that groff files exist (building from distributed tarball, not git repo)
if test -s "${abs_srcdir}"/docs/man/snmp-ups.8 ; then
if test "${nut_doc_build_target_flag}" = "auto" || test "${nut_doc_build_target_flag}" = "dist-auto" ; then
if test "${have_disted_doc_man}" = yes ; then
AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation, but can install pre-built distributed copies])
DOC_INSTALL_DISTED_MANS="yes"
else
AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation, and unable to install pre-built distributed copies because they are absent])
fi
fi # Other variants include "no", "skip"...
fi
fi
fi
;;

Expand Down
9 changes: 8 additions & 1 deletion docs/configure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,17 @@ Other values understood for this option are listed below:
* A `--with-doc=no` quietly skips generation of all types of documentation,
including manpages.

* `--with-doc=skip` is used to configure some of the `make distcheck*`
* A `--with-doc=skip` is used to configure some of the `make distcheck*`
scenarios to re-use man page files built and distributed by the main
build and not waste time on re-generation of those.

* A `--with-doc=dist-auto` allows to use pre-distributed MAN pages if present
(should be in "tarball" release archives; should not be among Git-tracked
sources; may be left over from earlier builds in same workspace), or build
those if we can (the `auto` part). Practically this is implemented in detail
only for `--with-doc=man=dist-auto`, as we do not dist HTML and PDF products;
it is a placeholder for those to simplify the generic configuration calls.

Multiple documentation format values can be specified, separated with comma.
Each such value can be suffixed with `=yes` to require building of this one
documentation format (abort configuration if tools are missing), `=auto` to
Expand Down
4 changes: 3 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 3169 utf-8
personal_ws-1.1 en 3171 utf-8
AAC
AAS
ABI
Expand Down Expand Up @@ -2137,6 +2137,8 @@ libaugeas
libavahi
libc
libcommon
libcommonclient
libcommonstr
libcppunit
libcrypto
libcurl
Expand Down
11 changes: 11 additions & 0 deletions drivers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,20 @@ snmp_ups_CFLAGS = $(AM_CFLAGS)
snmp_ups_CFLAGS += $(LIBNETSNMP_CFLAGS)
snmp_ups_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LIBS) -lm

if WITH_SSL
snmp_ups_CFLAGS += $(LIBSSL_CFLAGS)
snmp_ups_LDADD += $(LIBSSL_LIBS)
endif

# NEON XML/HTTP
netxml_ups_SOURCES = netxml-ups.c mge-xml.c
netxml_ups_LDADD = $(LDADD_DRIVERS) $(LIBNEON_LIBS)
netxml_ups_CFLAGS = $(AM_CFLAGS)

if WITH_SSL
netxml_ups_CFLAGS += $(LIBSSL_CFLAGS)
netxml_ups_LDADD += $(LIBSSL_LIBS)
endif

# Powerman
powerman_pdu_SOURCES = powerman-pdu.c
Expand Down
54 changes: 54 additions & 0 deletions m4/ax_c_pragmas.m4
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,33 @@ dnl ### [CFLAGS="${CFLAGS_SAVED} -Werror=pragmas -Werror=unknown-warning"
]) dnl Special pragma support testing for clang
dnl Test common pragmas for GCC (and compatible) compilers
AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wpedantic"],
[ax_cv__pragma__gcc__diags_ignored_pedantic],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[void func(void) {
#pragma GCC diagnostic ignored "-Wpedantic"
}
]], [])],
[ax_cv__pragma__gcc__diags_ignored_pedantic=yes],
[ax_cv__pragma__gcc__diags_ignored_pedantic=no]
)]
)
AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_pedantic" = "yes"],[
AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_PEDANTIC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wpedantic"])
])
AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wpedantic" (outside functions)],
[ax_cv__pragma__gcc__diags_ignored_pedantic_besidefunc],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wpedantic"]], [])],
[ax_cv__pragma__gcc__diags_ignored_pedantic_besidefunc=yes],
[ax_cv__pragma__gcc__diags_ignored_pedantic_besidefunc=no]
)]
)
AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_pedantic_besidefunc" = "yes"],[
AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_PEDANTIC_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wpedantic" (outside functions)])
])
AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wunused-function"],
[ax_cv__pragma__gcc__diags_ignored_unused_function],
[AC_COMPILE_IFELSE(
Expand Down Expand Up @@ -662,6 +689,33 @@ dnl ### [CFLAGS="${CFLAGS_SAVED} -Werror=pragmas -Werror=unknown-warning"
AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXTRA_SEMI_STMT_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wextra-semi-stmt" (outside functions)])
])
AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Waddress"],
[ax_cv__pragma__gcc__diags_ignored_address],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[void func(void) {
#pragma GCC diagnostic ignored "-Waddress"
}
]], [])],
[ax_cv__pragma__gcc__diags_ignored_address=yes],
[ax_cv__pragma__gcc__diags_ignored_address=no]
)]
)
AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_address" = "yes"],[
AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ADDRESS], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Waddress"])
])
AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Waddress" (outside functions)],
[ax_cv__pragma__gcc__diags_ignored_address_besidefunc],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Waddress"]], [])],
[ax_cv__pragma__gcc__diags_ignored_address_besidefunc=yes],
[ax_cv__pragma__gcc__diags_ignored_address_besidefunc=no]
)]
)
AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_address_besidefunc" = "yes"],[
AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ADDRESS_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Waddress" (outside functions)])
])
AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wcast-align"],
[ax_cv__pragma__gcc__diags_ignored_cast_align],
[AC_COMPILE_IFELSE(
Expand Down
6 changes: 4 additions & 2 deletions tools/nut-scanner/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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)/common/libcommonclient.la \
$(top_builddir)/common/libcommonstr.la \
$(top_builddir)/common/libcommon.la: dummy
+@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)

Expand Down Expand Up @@ -68,7 +68,7 @@ libnutscan_la_LIBADD = $(NETLIBS)
if WITH_LIBLTDL
libnutscan_la_LIBADD += $(LIBLTDL_LIBS)
endif WITH_LIBLTDL
libnutscan_la_LIBADD += $(top_builddir)/common/libcommonclient.la

if HAVE_SEMAPHORE_LIBS
# Are additional libraries needed for semaphore support?
libnutscan_la_LIBADD += $(SEMLIBS)
Expand Down Expand Up @@ -104,6 +104,8 @@ libnutscan_la_LDFLAGS += -export-symbols-regex '^(nutscan_|nut_debug_level|s_ups
libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -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_LDADD = libnutscan.la
Expand Down

0 comments on commit 1d79d6e

Please sign in to comment.