Skip to content

Commit 1c55d0b

Browse files
authored
Merge e4b95f3 into b7f3f95
2 parents b7f3f95 + e4b95f3 commit 1c55d0b

File tree

18 files changed

+245
-92
lines changed

18 files changed

+245
-92
lines changed

Makefile.am

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ EXTRA_DIST += autogen.sh
152152

153153
if KEEP_NUT_REPORT
154154
nodist_data_DATA = config.nut_report_feature.log
155-
endif
155+
endif KEEP_NUT_REPORT
156156

157157
# Not too different from automake generated recursive rules at first sight,
158158
# but here we do not loop all subdirs sequentially - instead, a sub-make
@@ -736,9 +736,9 @@ ChangeLog: dummy-stamp
736736

737737
if WITH_PDF_NONASCII_TITLES
738738
WITH_PDF_NONASCII_TITLES_ENVVAR = WITH_PDF_NONASCII_TITLES=yes
739-
else
739+
else !WITH_PDF_NONASCII_TITLES
740740
WITH_PDF_NONASCII_TITLES_ENVVAR = WITH_PDF_NONASCII_TITLES=no
741-
endif
741+
endif !WITH_PDF_NONASCII_TITLES
742742

743743
# Be sure to not confuse with a DIST'ed file (and so try to overwrite it);
744744
# do however avoid re-generating it if already made on a previous pass and
@@ -900,39 +900,39 @@ install-data-hook:
900900

901901
if HAVE_SYSTEMD
902902
HAVE_SYSTEMD = true
903-
else
903+
else !HAVE_SYSTEMD
904904
HAVE_SYSTEMD = false
905-
endif
905+
endif !HAVE_SYSTEMD
906906

907907
if WITH_SYSTEMD_TMPFILES
908908
WITH_SYSTEMD_TMPFILES = true
909-
else
909+
else !WITH_SYSTEMD_TMPFILES
910910
WITH_SYSTEMD_TMPFILES = false
911-
endif
911+
endif !WITH_SYSTEMD_TMPFILES
912912

913913
if WITH_SYSTEMD_PRESET
914914
WITH_SYSTEMD_PRESET = true
915-
else
915+
else !WITH_SYSTEMD_PRESET
916916
WITH_SYSTEMD_PRESET = false
917-
endif
917+
endif !WITH_SYSTEMD_PRESET
918918

919919
if WITH_CGI
920920
WITH_CGI = true
921-
else
921+
else !WITH_CGI
922922
WITH_CGI = false
923-
endif
923+
endif !WITH_CGI
924924

925925
if WITH_SOLARIS_SMF
926926
WITH_SOLARIS_SMF = true
927-
else
927+
else !WITH_SOLARIS_SMF
928928
WITH_SOLARIS_SMF = false
929-
endif
929+
endif !WITH_SOLARIS_SMF
930930

931931
if WITH_SOLARIS_INIT
932932
WITH_SOLARIS_INIT = true
933-
else
933+
else !WITH_SOLARIS_INIT
934934
WITH_SOLARIS_INIT = false
935-
endif
935+
endif !WITH_SOLARIS_INIT
936936

937937
# TODO: Actually move this into scripts like Solaris/postinstall
938938
# using OS-specific `useradd`/`groupadd`, etc.
@@ -1212,13 +1212,13 @@ install-win-bundle-thirdparty:
12121212
| grep -vE "^($${relbindir}|$${relsbindir}|$${reldriverexecdir}|$${relcgiexecdir}|$${rellibexecdir})" \
12131213
| ( RES=0 ; while IFS= read LINE ; do echo "$$LINE" ; RES=1; done; exit $$RES )
12141214

1215-
else
1215+
else !HAVE_WINDOWS
12161216
install-win-bundle:
12171217
@echo "SKIP: '$@' not enabled for current build configuration"
12181218

12191219
install-win-bundle-thirdparty:
12201220
@echo "SKIP: '$@' not enabled for current build configuration"
1221-
endif
1221+
endif !HAVE_WINDOWS
12221222

12231223
print-MAINTAINERCLEANFILES print-REALCLEANFILES:
12241224
@echo $(MAINTAINERCLEANFILES)

NEWS.adoc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,33 @@ https://github.com/networkupstools/nut/milestone/11
110110
references in their command-line usage help, method `suggest_doc_links()`
111111
was introduced for this purpose. [issue #722, PR #2733]
112112
113+
- A technologically and practically interesting revamp of NUT mesh of
114+
link:https://www.gnu.org/software/automake/[automake] (`Makefile.am`)
115+
recipes was completed, allowing for a more parallelizable build routine
116+
on multi-CPU machines -- utilizing more cores and completing in less
117+
"wall-clock" time that the standard `SUBDIRS` driven approach -- when
118+
running `make -j (N)` from the project root directory to build everything
119+
enabled by the `configure` script.
120+
+
121+
This was tested with several (GNU, BSD, Sun) implementations of the
122+
"make" program on the few dozen platforms that NUT CI farm tests on.
123+
Notably, GNU make 4.x and newer seems to process parallel high-level
124+
goals and sub-`make` runs better than the competition (including GNU
125+
make 3.x).
126+
+
127+
It is not a radical rewrite like some other research suggested, and so retains
128+
the general structure and certain benefits and flexibility of that standard
129+
`automake` approach, including developer build workflows with a bespoke
130+
`Makefile` in every significant directory. This also retains (and builds
131+
upon) the benefits of older work done in NUT, for builds in one directory
132+
to depend on libraries and other artifacts built (once) in another.
133+
+
134+
Overall, NUT CI farm build times got 25%+ shorter (which is important as
135+
some scenarios had hit the 1-hour timeout imposed by providers of free
136+
CI hosting coupled with the weak machines provided in their free layer),
137+
and we suppose this is an interesting case for other projects to draw
138+
inspiration from for their recipe refactoring. [PR #2825]
139+
113140
- the `upsnotify()` common code introduced in recent NUT releases (integrating
114141
with service management frameworks, etc.) was a bit cryptic when it reported
115142
a *failure to notify* (e.g. when not running as a service currently), fixed

ci_build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,8 +1251,8 @@ consider_cleanup_shortcut() {
12511251
fi
12521252
fi
12531253

1254-
# When itertating configure.ac or m4 sources, we can end up with an
1255-
# existing but useless scropt file - nuke it and restart from scratch!
1254+
# When iterating configure.ac or m4 sources, we can end up with an
1255+
# existing but useless script file - nuke it and restart from scratch!
12561256
if [ -s "${CI_BUILDDIR}"/configure ] ; then
12571257
if ! sh -n "${CI_BUILDDIR}"/configure 2>/dev/null ; then
12581258
echo "=== Starting initial clean-up (from old build products): TAKING SHORTCUT because current configure script syntax is broken"
@@ -1351,7 +1351,7 @@ if [ -z "$BUILD_TYPE" ] ; then
13511351

13521352
win32|cross-windows-mingw32) BUILD_TYPE="cross-windows-mingw32" ; shift ;;
13531353

1354-
win|cross-windows-mingw) BUILD_TYPE="cross-windows-mingw" ; shift ;;
1354+
win|windows|cross-windows-mingw) BUILD_TYPE="cross-windows-mingw" ; shift ;;
13551355

13561356
spellcheck|spellcheck-interactive)
13571357
# Note: this is a little hack to reduce typing

clients/Makefile.am

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ $(top_builddir)/common/libparseconf.la: dummy
2626
LDADD_FULL = $(top_builddir)/common/libcommon.la libupsclient.la $(NETLIBS)
2727
if WITH_SSL
2828
LDADD_FULL += $(LIBSSL_LIBS) $(LIBSSL_LDFLAGS_RPATH)
29-
endif
29+
endif WITH_SSL
3030

3131
LDADD_CLIENT = $(top_builddir)/common/libcommonclient.la libupsclient.la $(NETLIBS)
3232
if WITH_SSL
3333
LDADD_CLIENT += $(LIBSSL_LIBS) $(LIBSSL_LDFLAGS_RPATH)
34-
endif
34+
endif WITH_SSL
3535

3636
# by default, link programs in this directory with
3737
# the more compact libcommonclient.a bundle
@@ -43,23 +43,23 @@ LDADD = $(LDADD_CLIENT)
4343
AM_CFLAGS = -I$(top_srcdir)/include
4444
if WITH_SSL
4545
AM_CFLAGS += $(LIBSSL_CFLAGS)
46-
endif
46+
endif WITH_SSL
4747
if WITH_CGI
4848
AM_CFLAGS += $(LIBGD_CFLAGS)
49-
endif
49+
endif WITH_CGI
5050

5151
bin_PROGRAMS = upsc upslog upsrw upscmd
5252
dist_bin_SCRIPTS = upssched-cmd
5353
sbin_PROGRAMS = upsmon upssched
5454
if HAVE_WINDOWS_SOCKETS
5555
sbin_PROGRAMS += message
56-
endif
56+
endif HAVE_WINDOWS_SOCKETS
5757

5858
lib_LTLIBRARIES = libupsclient.la
5959
if HAVE_CXX11
6060
lib_LTLIBRARIES += libnutclient.la
6161
lib_LTLIBRARIES += libnutclientstub.la
62-
endif
62+
endif HAVE_CXX11
6363

6464
# Optionally deliverable as part of NUT public API:
6565
if WITH_DEV
@@ -73,7 +73,7 @@ endif WITH_DEV
7373

7474
if WITH_CGI
7575
cgiexec_PROGRAMS = upsstats.cgi upsimage.cgi upsset.cgi
76-
endif
76+
endif WITH_CGI
7777

7878
upsc_SOURCES = upsc.c upsclient.h
7979
upscmd_SOURCES = upscmd.c upsclient.h
@@ -84,7 +84,7 @@ upsmon_SOURCES = upsmon.c upsmon.h upsclient.h
8484
upsmon_LDADD = $(LDADD_FULL)
8585
if HAVE_WINDOWS_SOCKETS
8686
message_SOURCES = message.c
87-
endif
87+
endif HAVE_WINDOWS_SOCKETS
8888

8989
upssched_SOURCES = upssched.c upssched.h
9090
upssched_LDADD = $(top_builddir)/common/libcommonclient.la $(top_builddir)/common/libparseconf.la $(NETLIBS)
@@ -101,10 +101,10 @@ libupsclient_la_SOURCES = upsclient.c upsclient.h
101101
libupsclient_la_LIBADD = $(top_builddir)/common/libcommonclient.la
102102
if HAVE_WINDOWS_SOCKETS
103103
libupsclient_la_LIBADD += -lws2_32
104-
endif
104+
endif HAVE_WINDOWS_SOCKETS
105105
if WITH_SSL
106106
libupsclient_la_LIBADD += $(LIBSSL_LDFLAGS_RPATH) $(LIBSSL_LIBS)
107-
endif
107+
endif WITH_SSL
108108

109109
# Below we set API versions of public libraries
110110
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
@@ -117,7 +117,7 @@ libupsclient_la_LDFLAGS += -export-symbols-regex ^upscli_
117117
if HAVE_WINDOWS
118118
# Many versions of MingW seem to fail to build non-static DLL without this
119119
libupsclient_la_LDFLAGS += -no-undefined
120-
endif
120+
endif HAVE_WINDOWS
121121

122122
# ./clients/libupsclient.la samples (partial!) on...
123123
# Linux:
@@ -154,10 +154,10 @@ libnutclient_la_LIBADD = $(top_builddir)/common/libcommonclient.la
154154
if HAVE_WINDOWS
155155
# Many versions of MingW seem to fail to build non-static DLL without this
156156
libnutclient_la_LDFLAGS += -no-undefined
157-
endif
158-
else
157+
endif HAVE_WINDOWS
158+
else !HAVE_CXX11
159159
EXTRA_DIST += nutclient.h nutclient.cpp
160-
endif
160+
endif !HAVE_CXX11
161161

162162
if HAVE_CXX11
163163
# libnutclientstub version information and build
@@ -167,10 +167,10 @@ libnutclientstub_la_LIBADD = libnutclient.la
167167
if HAVE_WINDOWS
168168
# Many versions of MingW seem to fail to build non-static DLL without this
169169
libnutclientstub_la_LDFLAGS += -no-undefined
170-
endif
171-
else
170+
endif HAVE_WINDOWS
171+
else !HAVE_CXX11
172172
EXTRA_DIST += nutclientmem.h nutclientmem.cpp
173-
endif
173+
endif !HAVE_CXX11
174174

175175
dummy:
176176

common/Makefile.am

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,23 @@ EXTRA_DIST =
1616
CLEANFILES =
1717

1818
noinst_LTLIBRARIES = libparseconf.la libcommon.la libcommonclient.la
19+
lib_LTLIBRARIES =
20+
21+
# We define the recipe below in any case, but only activate it by default
22+
# if the build configuration tells us to:
23+
if WITH_DEV_LIBNUTCONF
24+
# We want it built and delivered (standalone or with tool)
25+
lib_LTLIBRARIES += libnutconf.la
26+
else !WITH_DEV_LIBNUTCONF
1927
if WITH_NUTCONF
20-
# We define the recipe below in any case, but only activate it by default
21-
# if the build configuration tells us to:
28+
# We only want the tool, make a private build
2229
noinst_LTLIBRARIES += libnutconf.la
30+
# else do not build at all, e.g. do not have C++ support
2331
endif WITH_NUTCONF
32+
endif !WITH_DEV_LIBNUTCONF
2433

2534
libparseconf_la_SOURCES = parseconf.c
2635

27-
libnutconf_la_SOURCES = nutconf.cpp nutstream.cpp nutwriter.cpp nutipc.cpp
28-
2936
# do not hard depend on '../include/nut_version.h', since it blocks
3037
# 'dist', and is only required for actual build, in which case
3138
# BUILT_SOURCES (in ../include) will ensure nut_version.h will
@@ -136,10 +143,26 @@ libcommonclient_la_LIBADD = libparseconf.la @LTLIBOBJS@ @NETLIBS@ @BSDKVMPROCLIB
136143
libcommon_la_CFLAGS = $(AM_CFLAGS)
137144
libcommonclient_la_CFLAGS = $(AM_CFLAGS)
138145

139-
if WITH_NUTCONF
146+
if WITH_LIBNUTCONF
147+
if WITH_DEV_LIBNUTCONF
148+
# libnutconf version information and build
149+
# currently considered a highly experimental and so unstable API at least
150+
# (at least, headers contain a lot of data/code, not sure they should)
151+
libnutconf_la_LDFLAGS = -version-info 0:1:0
152+
if HAVE_WINDOWS
153+
# Many versions of MingW seem to fail to build non-static DLL without this
154+
libnutconf_la_LDFLAGS += -no-undefined
155+
endif HAVE_WINDOWS
156+
endif WITH_DEV_LIBNUTCONF
140157
libnutconf_la_CXXFLAGS = $(AM_CXXFLAGS)
141-
libnutconf_la_LIBADD = @LTLIBOBJS@ @NETLIBS@ libcommonclient.la
142-
endif WITH_NUTCONF
158+
# NOTE: No @LTLIBOBJS@ here, because libcommonclient.la includes them (if any)
159+
libnutconf_la_LIBADD = @NETLIBS@ libcommonclient.la
160+
libnutconf_la_SOURCES = nutconf.cpp nutstream.cpp nutwriter.cpp nutipc.cpp \
161+
../include/nutconf.hpp ../include/nutipc.hpp \
162+
../include/nutstream.hpp ../include/nutwriter.hpp
163+
else !WITH_LIBNUTCONF
164+
EXTRA_DIST += nutconf.cpp nutstream.cpp nutwriter.cpp nutipc.cpp
165+
endif !WITH_LIBNUTCONF
143166

144167
if HAVE_LIBREGEX
145168
libcommon_la_CFLAGS += $(LIBREGEX_CFLAGS)

common/setenv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ int nut_setenv(const char *name, const char *value, int overwrite)
2626
rv = putenv(buffer); /* man putenv, do not free(buffer) */
2727
return (rv);
2828
}
29-
#endif
29+
#endif /* !HAVE_SETENV */

configure.ac

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2098,7 +2098,7 @@ dnl check for --with-all (or --without-all, or --with-all=auto) flag
20982098

20992099
AC_MSG_CHECKING(for --with-all)
21002100
AC_ARG_WITH(all,
2101-
AS_HELP_STRING([--with-all], [enable serial, usb, snmp, neon, ipmi, powerman, modbus, gpio (currently on Linux released after ~2018), linux_i2c (on Linux), macosx-ups (on MacOS), cgi, dev, avahi, nut-scanner, nutconf, pynut]),
2101+
AS_HELP_STRING([--with-all], [enable serial, usb, snmp, neon, ipmi, powerman, modbus, gpio (currently on Linux released after ~2018), linux_i2c (on Linux), macosx-ups (on MacOS), cgi, dev, avahi, nut-scanner, nutconf, dev-libnutconf, pynut]),
21022102
[
21032103
if test -n "${withval}"; then
21042104
dnl Note: we allow "no" as a positive value, because
@@ -2143,6 +2143,7 @@ AC_ARG_WITH(all,
21432143
if test -z "${with_avahi}"; then with_avahi="${withval}"; fi
21442144
if test -z "${with_nut_scanner}"; then with_nut_scanner="${withval}"; fi
21452145
if test -z "${with_nutconf}"; then with_nutconf="${withval}"; fi
2146+
if test -z "${with_dev_libnutconf}"; then with_dev_libnutconf="${withval}"; fi
21462147
21472148
if test -n "${PYTHON}${PYTHON2}${PYTHON3}" -a x"${withval}" = xyes \
21482149
|| test x"${withval}" != xyes \
@@ -2172,10 +2173,15 @@ dnl they are listed near the top by "./configure --help"; however,
21722173
dnl note that options with further investigation methods are listed
21732174
dnl a bit below to be grouped with their additional with/enable help.
21742175

2176+
dnl Depends on C++ support being available and enabled
21752177
NUT_ARG_WITH([nutconf], [build and install the nutconf tool (experimental, has compiler/coverage warnings)], [auto])
21762178

21772179
NUT_ARG_WITH([dev], [build and install the development files], [no])
21782180

2181+
dnl Depends on C++ support being available and enabled
2182+
dnl Does not depend on nutconf or dev explicitly (but warns about inconsistencies)
2183+
NUT_ARG_WITH([dev-libnutconf], [deliver the C++ library behind the nutconf tool and its headers (experimental)], [no])
2184+
21792185
dnl Activate WITH_UNMAPPED_DATA_POINTS for troubleshooting and evolution?
21802186
dnl Note that production drivers must conform to docs/nut-names.txt
21812187
NUT_ARG_WITH([unmapped-data-points],
@@ -4495,6 +4501,39 @@ NUT_REPORT_PROGRAM([build and install the nutconf tool (experimental, may lack s
44954501

44964502
dnl ----------------------------------------------------------------------
44974503

4504+
dnl Depends on C++, potentially nutconf and dev...
4505+
dnl If not enabled for delivery, the library is built as internal detail
4506+
dnl of the tool (if that is enabled)
4507+
AC_MSG_CHECKING([whether we can and want to deliver the libnutconf library and headers])
4508+
4509+
AS_CASE(["${nut_with_dev_libnutconf}"],
4510+
["auto"], [AS_IF([test x"${have_cxx11}" = xyes], [nut_with_dev_libnutconf="yes"], [nut_with_dev_libnutconf="no"])],
4511+
["yes"], [AS_IF([test x"${have_cxx11}" = xyes], [], [AC_MSG_ERROR([explicit --with-dev-libnutconf=yes can not be satisfied: C++11 support not enabled])])],
4512+
["no"], [nut_with_dev_libnutconf=no]
4513+
)
4514+
AC_MSG_RESULT(${nut_with_dev_libnutconf})
4515+
4516+
AM_CONDITIONAL(WITH_DEV_LIBNUTCONF, test "${nut_with_dev_libnutconf}" = "yes")
4517+
NUT_REPORT_PROGRAM([build and install the deliver the libnutconf library and headers (experimental)],
4518+
[${nut_with_dev_libnutconf}], [],
4519+
[WITH_DEV_LIBNUTCONF], [Define to enable delivery of libnutconf developer files])
4520+
4521+
AS_IF([test x"$nut_with_dev_libnutconf" = x"yes" -a x"${nut_with_dev}" != x"yes"], [
4522+
AC_MSG_WARN([You are effectively building --with-dev-libnutconf --without-dev, so would only get this library and headers but maybe not others it might need])
4523+
])
4524+
AS_IF([test x"$nut_with_dev_libnutconf" = x"yes" -a x"${nut_with_nutconf}" != x"yes"], [
4525+
AC_MSG_NOTICE([You are effectively building --with-dev-libnutconf --without-nutconf, so would only get the library and headers but not the tool])
4526+
])
4527+
AS_IF([test x"$nut_with_dev_libnutconf" != x"yes" -a x"${nut_with_nutconf}" = x"yes"], [
4528+
AC_MSG_NOTICE([You are effectively building --without-dev-libnutconf --with-nutconf, so would only get the tool (library and headers are just its internal detail during build)])
4529+
])
4530+
4531+
dnl At least the lib and/or the tool delivery are enabled, generate the
4532+
dnl automake rules to build the library (privately or publicly, that depends):
4533+
AM_CONDITIONAL(WITH_LIBNUTCONF, [test x"${nut_with_dev_libnutconf}" = x"yes" -o x"${nut_with_nutconf}" = x"yes"])
4534+
4535+
dnl ----------------------------------------------------------------------
4536+
44984537
AC_MSG_CHECKING(whether to install Augeas configuration-management lenses)
44994538
AC_ARG_WITH(augeas-lenses-dir,
45004539
AS_HELP_STRING([--with-augeas-lenses-dir=PATH], [where to install Augeas configuration-management lenses (/usr/share/augeas/lenses{/dist,/})]),
@@ -5731,6 +5770,7 @@ AC_CONFIG_FILES([
57315770
include/Makefile
57325771
lib/libupsclient.pc
57335772
lib/libnutclient.pc
5773+
lib/libnutconf.pc
57345774
lib/libnutclientstub.pc
57355775
lib/libnutscan.pc
57365776
lib/Makefile

0 commit comments

Comments
 (0)