Skip to content
Merged
24 changes: 23 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ all-libs-local/include:
+@$(SUBDIR_TGT_RULE)

### Delivers: libcommon.la libcommonclient.la libcommonstr.la
### (consume only one of these at a time!)
### Delivers: libcommonversion.la (only version methods)
### Delivers: libparseconf.la libnutconf.la libnutwincompat.la
### Requires-ext: include/nut_version.h
### Requires-int: libparseconf.la libcommonclient.la
Expand All @@ -206,6 +208,7 @@ all-libs-local/common: all-libs-local/include
### Delivers: libupsclient-version.h
### LIB-Requires-ext: common/libcommonclient.la
### Requires-ext: common/libcommon.la common/libcommonclient.la
### Requires-ext: common/libcommonversion.la
### Requires-ext: common/libparseconf.la
### Requires-int: libupsclient.la
all-libs-local/clients: all-libs-local/common
Expand Down Expand Up @@ -239,6 +242,7 @@ all-libs-local/tools:
### Delivers: libnutscan.la
### LIB-Requires-ext: drivers/libserial-nutscan.la
### LIB-Requires-ext: common/libnutwincompat.la common/libcommonstr.la
### LIB-Requires-ext: common/libcommonversion.la
### HDR-Requires-ext: clients/libupsclient-version.h
### HDR-Requires-ext: nut-scanner/nutscan-snmp.h nut-scanner/nutscan-usb.h
### (generated by nut-scanner-deps/tools aliased as all-libs-local/tools)
Expand Down Expand Up @@ -311,12 +315,14 @@ all/common: all/include all-libs-local/common

### Requires-ext: common/libcommon.la common/libcommonclient.la
### Requires-ext: common/libparseconf.la
### Requires-ext: common/libcommonversion.la
### Requires-int: libupsclient.la
all/clients: all/common all-libs-local/clients
+@$(SUBDIR_TGT_RULE)

### Summary of drivers/ subdir dependencies:
### Requires-ext: common/libcommon.la common/libparseconf.la
### Requires-ext: common/libcommonversion.la
### Requires-ext: clients/libupsclient.la (dummy-ups only)
### Requires-int: libdummy.la libdummy_upsdrvquery.la
### Requires-int: libdummy_serial.la
Expand Down Expand Up @@ -356,12 +362,13 @@ all-drivers: dummy-ups$(EXEEXT)/drivers all/drivers
endif !SOME_DRIVERS

### Requires-ext: common/libcommon.la common/libparseconf.la
### Requires-ext: common/libcommonversion.la
all/server: all-libs-local/common
+@$(SUBDIR_TGT_RULE)

### LIB-Requires-ext: drivers/libserial-nutscan.la
### LIB-Requires-ext: common/libnutwincompat.la common/libcommonstr.la
### Requires-ext: include/nut_version.h
### LIB-Requires-ext: common/libcommonversion.la
### Requires-ext: clients/libupsclient-version.h
### Requires-int: libnutscan.la
all/tools/nut-scanner: all-libs-local/include all-libs-local/common \
Expand All @@ -372,6 +379,7 @@ all/tools/nut-scanner: all-libs-local/include all-libs-local/common \
# only libnutscan is needed for nutconf,
# but we do wholesale subdir all-libs-local at the moment...
### Requires-ext: common/libcommon.la common/libnutconf.la
### Requires-ext: common/libcommonversion.la
### Requires-ext: tools/nut-scanner/libnutscan.la
all/tools/nutconf: all-libs-local/tools/nut-scanner all-libs-local/common
+@$(SUBDIR_TGT_RULE)
Expand Down Expand Up @@ -403,6 +411,7 @@ all-recursive/tests: all/tests/NIT all/tests
if HAVE_MINGW_RESGEN
if HAVE_WINDOWS
### Requires-ext: common/libcommon.la
### Requires-ext: common/libcommonversion.la
all/scripts/Windows: all-libs-local/common
+@$(SUBDIR_TGT_RULE)
else !HAVE_WINDOWS
Expand Down Expand Up @@ -967,6 +976,10 @@ ChangeLog.adoc: ChangeLog
nut_version.h include/nut_version.h:
+cd $(abs_top_builddir)/include && $(MAKE) $(AM_MAKEFLAGS) nut_version.h

# May involve (re-)build of libupsclient.la
libupsclient-version.h clients/libupsclient-version.h:
+cd $(abs_top_builddir)/include && $(MAKE) $(AM_MAKEFLAGS) libupsclient-version.h

tools/gitlog2changelog.py: tools/gitlog2changelog.py.in
+cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) -s $(@F)

Expand Down Expand Up @@ -1402,3 +1415,12 @@ git-realclean-check:
done; \
done ; \
fi

# Simply group recipes which depend on a ton of source files but are generally
# quickly handled by external tools, to group (in life and log) various checks
# separately from the probably slower/louder stages for test programs like
# check-NIT:
check-files-quick: spellcheck-quick check-man

# Autotools hook: run the quick checks before recursing for defaults:
check-recursive: check-files-quick
4 changes: 4 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ https://github.com/networkupstools/nut/milestone/9

- (expected) Bug fixes for fallout possible due to "fightwarn" effort in 2.8.0+

- Refactored NUT "common" sources to reference `nut_version.h` macros from
a smaller C source file, to minimize the compilation unit size impacted by
development iterations. [issue #2097]

Release notes for NUT 2.8.3 - what's new since 2.8.2
----------------------------------------------------

Expand Down
26 changes: 21 additions & 5 deletions clients/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,24 @@ AM_CXXFLAGS = -DHAVE_NUTCOMMON=1 -I$(top_srcdir)/include
# Make sure out-of-dir dependencies exist (especially when dev-building parts):
$(top_builddir)/common/libcommon.la \
$(top_builddir)/common/libcommonclient.la \
$(top_builddir)/common/libcommonversion.la \
$(top_builddir)/common/libparseconf.la: dummy
+@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)

LDADD_FULL = $(top_builddir)/common/libcommon.la libupsclient.la $(NETLIBS)
LDADD_FULL = \
$(top_builddir)/common/libcommon.la \
$(top_builddir)/common/libcommonversion.la \
libupsclient.la \
$(NETLIBS)
if WITH_SSL
LDADD_FULL += $(LIBSSL_LIBS) $(LIBSSL_LDFLAGS_RPATH)
endif WITH_SSL

LDADD_CLIENT = $(top_builddir)/common/libcommonclient.la libupsclient.la $(NETLIBS)
LDADD_CLIENT = \
$(top_builddir)/common/libcommonclient.la \
$(top_builddir)/common/libcommonversion.la \
libupsclient.la \
$(NETLIBS)
if WITH_SSL
LDADD_CLIENT += $(LIBSSL_LIBS) $(LIBSSL_LDFLAGS_RPATH)
endif WITH_SSL
Expand Down Expand Up @@ -87,7 +96,11 @@ message_SOURCES = message.c
endif HAVE_WINDOWS_SOCKETS

upssched_SOURCES = upssched.c upssched.h
upssched_LDADD = $(top_builddir)/common/libcommonclient.la $(top_builddir)/common/libparseconf.la $(NETLIBS)
upssched_LDADD = \
$(top_builddir)/common/libcommonclient.la \
$(top_builddir)/common/libcommonversion.la \
$(top_builddir)/common/libparseconf.la \
$(NETLIBS)

upsimage_cgi_SOURCES = upsimage.c upsclient.h upsimagearg.h cgilib.c cgilib.h
upsimage_cgi_LDADD = $(LDADD) $(LIBGD_LDFLAGS)
Expand All @@ -98,7 +111,9 @@ upsstats_cgi_SOURCES = upsstats.c upsclient.h status.h upsstats.h \

# not LDADD... why?
libupsclient_la_SOURCES = upsclient.c upsclient.h
libupsclient_la_LIBADD = $(top_builddir)/common/libcommonclient.la
# NOTE: The library does not require libcommonversion.la
libupsclient_la_LIBADD = \
$(top_builddir)/common/libcommonclient.la
if HAVE_WINDOWS_SOCKETS
libupsclient_la_LIBADD += -lws2_32
endif HAVE_WINDOWS_SOCKETS
Expand Down Expand Up @@ -167,7 +182,8 @@ libnutclient_la_SOURCES = nutclient.h nutclient.cpp
libnutclient_la_LDFLAGS = -version-info 2:2:0
# Needed in not-standalone builds with -DHAVE_NUTCOMMON=1
# which is defined for in-tree CXX builds above:
libnutclient_la_LIBADD = $(top_builddir)/common/libcommonclient.la
libnutclient_la_LIBADD = \
$(top_builddir)/common/libcommonclient.la
if HAVE_WINDOWS
# Many versions of MingW seem to fail to build non-static DLL without this
libnutclient_la_LDFLAGS += -no-undefined
Expand Down
51 changes: 33 additions & 18 deletions common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,25 @@ libparseconf_la_SOURCES = parseconf.c
# BUILT_SOURCES (in ../include) will ensure nut_version.h will
# be built before anything else... but do depend on its build area:
if BUILDING_IN_TREE
# No need for symlink hack
common.c: $(top_builddir)/include/nut_version.h
# No need for symlink hack, just rebuild if header gets updated:
common-nut_version.c: $(top_builddir)/include/nut_version.h
else !BUILDING_IN_TREE
# Surprisingly, for some "make" implementations this dependency means
# that the "common.c" required for builds below will be seeked in the
# Surprisingly, for some "make" implementations this dependency means that
# the "common-nut_version.c" required for builds below will be seeked in the
# current directory. So for out-of-tree builds like distcheck, we have
# to symlink the "real" source to build area. And then when we handle
# subsequent dependencies, we already have a filename that "make" now
# discovers and is confused about:
common.c: $(top_builddir)/include/nut_version.h $(srcdir)/common.c
common-nut_version.c: $(top_builddir)/include/nut_version.h $(srcdir)/common-nut_version.c
@if [ x"$(abs_top_srcdir)" = x"$(abs_top_builddir)" ] || test -s "$@" ; then \
exit 0 ; \
else \
echo " LN $(top_srcdir)/common/common.c => $@ (relative to `pwd`)" ; \
ln -s -f "$(top_srcdir)/common/common.c" "$@" ; \
echo " LN $(top_srcdir)/common/common-nut_version.c => $@ (relative to `pwd`)" ; \
ln -s -f "$(top_srcdir)/common/common-nut_version.c" "$@" ; \
fi

CLEANFILES += $(top_builddir)/common/nut_version.c
BUILT_SOURCES = common-nut_version.c
endif !BUILDING_IN_TREE

$(top_builddir)/include/nut_version.h:
Expand All @@ -65,24 +68,34 @@ $(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;
# several other Makefiles include the three helpers common.c common-nut_version.c str.c
# (and perhaps some other string-related code), so we 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@

# This one includes only version-related data and methods and should be
# linked along with one of the other libcommon*.la for logging methods:
noinst_LTLIBRARIES += libcommonversion.la
libcommonversion_la_SOURCES = common-nut_version.c
#libcommonversion_la_CFLAGS = $(AM_CFLAGS) -DWITHOUT_LIBSYSTEMD=1
#libcommonversion_la_LIBADD = @LTLIBOBJS@ @BSDKVMPROCLIBS@

# Eventually we expect more sources as the big common.c source gets split
# into smaller better-focused files.
COMMON_SRC = \
common.c

if BUILDING_IN_TREE
libcommon_la_SOURCES += common.c
libcommonstr_la_SOURCES += common.c
libcommonclient_la_SOURCES += common.c
libcommon_la_SOURCES += $(COMMON_SRC)
libcommonstr_la_SOURCES += $(COMMON_SRC)
libcommonclient_la_SOURCES += $(COMMON_SRC)
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
nodist_libcommon_la_SOURCES = $(COMMON_SRC)
nodist_libcommonstr_la_SOURCES = $(COMMON_SRC)
nodist_libcommonclient_la_SOURCES = $(COMMON_SRC)
endif !BUILDING_IN_TREE

if HAVE_STRPTIME
Expand Down Expand Up @@ -193,7 +206,9 @@ MAINTAINERCLEANFILES = Makefile.in .dirstamp
# NOTE: Do not clean ".deps" in SUBDIRS of the main project,
# the root Makefile.am takes care of that!
clean-local:
if test -L $(builddir)/common.c || test -h $(builddir)/common.c ; then rm -f $(builddir)/common.c ; fi
if test -L $(builddir)/common-nut_version.c \
|| test -h $(builddir)/common-nut_version.c \
; then rm -f $(builddir)/common-nut_version.c ; fi
# $(AM_V_at)rm -rf $(builddir)/.deps

# Helper for only the enabled libs to get built:
Expand Down
Loading