Skip to content

Commit

Permalink
Merge pull request networkupstools#2825 from jimklimov/fix-makefile-d…
Browse files Browse the repository at this point in the history
…ocs-check-changelog

CI: Fix Makefiles for parallel builds
  • Loading branch information
jimklimov authored Mar 1, 2025
2 parents 1d019ca + ee02c6b commit b7f3f95
Show file tree
Hide file tree
Showing 14 changed files with 577 additions and 66 deletions.
380 changes: 360 additions & 20 deletions Makefile.am

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions clients/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,7 @@ MAINTAINERCLEANFILES = Makefile.in .dirstamp
# the root Makefile.am takes care of that!
#clean-local:
# $(AM_V_at)rm -rf $(builddir)/.deps

# Helper for only the enabled libs to get built:
all-libs-local: $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
libupsclient-version.h
25 changes: 18 additions & 7 deletions common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,22 @@ libnutconf_la_SOURCES = nutconf.cpp nutstream.cpp nutwriter.cpp nutipc.cpp
# 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
# No need for symlink hack
common.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
# current directory. So for out-of-tree builds like distcheck, we have
# to symlink the "real" source to build area:
# Surprisingly, for some "make" implementations this dependency means
# that the "common.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
test -s "$@" || ln -s -f "$(top_srcdir)/common/common.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" "$@" ; \
fi
endif !BUILDING_IN_TREE

$(top_builddir)/include/nut_version.h:
Expand Down Expand Up @@ -162,5 +169,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:
clean-local:
if test -L $(builddir)/common.c || test -h $(builddir)/common.c ; then rm -f $(builddir)/common.c ; fi
# $(AM_V_at)rm -rf $(builddir)/.deps

# Helper for only the enabled libs to get built:
all-libs-local: $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) $(EXTRA_LTLIBRARIES)
3 changes: 3 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ nut.dict.sorted
docinfo.xml.in.tmp
/asciidoc-vars.conf.lastrev.tmp
.prep-src-docs*
/.check-pdf
/.check-html-single
/.check-html-chunked
142 changes: 115 additions & 27 deletions docs/Makefile.am

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/man/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
/tmp/
/linkman-driver-names.txt
/linkman-drivertool-names.txt
/.check-html-man
/.check-man-pages
/.check-man-txt
41 changes: 37 additions & 4 deletions docs/man/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ endif !WITH_HTML_SINGLE
all: $(abs_top_builddir)/docs/man/.prep-src-docs
+@case "$(ALL_TGT)" in \
*all-*) \
if [ x"$(DOCS_NO_MAN)" = xtrue ] ; then echo " DOCS_NO_MAN SKIP: $@ called in docs/man/Makefile" ; exit 0 ; fi ; \
echo " DOC-FOLLOW-UP Basic 'make $@' in `pwd` is done, following up with 'make $(ALL_TGT)' to ensure complex document types (if enabled)" ; \
$(MAKE) $(AM_MAKEFLAGS) $(ALL_TGT) ; exit ;; \
esac ; exit 0
Expand Down Expand Up @@ -154,6 +155,19 @@ endif HAVE_WINDOWS

if WITH_NUT_MONITOR
HTML_CLIENT_MANS += NUT-Monitor.html

# Can't make this work on all make implementations at once, so disabled for now
# Anyway it would be the same man-like page for several functions
HTML_CLIENT_MANS_FICTION = \
NUT-Monitor-py2gtk2.html \
NUT-Monitor-py3qt5.html

NUT-Monitor-py2gtk2.html: NUT-Monitor.html
test -n "$?" -a -s "$@" && rm -f $@ && ln -s $? $@

NUT-Monitor-py3qt5.html: NUT-Monitor.html
test -n "$?" -a -s "$@" && rm -f $@ && ln -s $? $@

endif WITH_NUT_MONITOR

SRC_TOOL_PAGES = nut-scanner.txt nut-recorder.txt nutconf.txt
Expand Down Expand Up @@ -1051,20 +1065,23 @@ check-man check-man-man: check-man-txt check-man-pages check-html-man
# the "for" loops might better use $^ but it might be not portable
check-man-html: check-html-man

check-html-man: $(HTML_MANS)
check-html-man: .check-html-man
.check-html-man: $(HTML_MANS) Makefile
@FAILED=""; CHECKED=0; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \
for F in $(HTML_MANS) ; do \
CHECKED="`expr $$CHECKED + 1`"; \
test -s "$$F" && { file "$$F" | $(EGREP) -i '(XML|HTML.*document|symbolic link)' > /dev/null ; } || FAILED="$$FAILED $$F" ; \
done; if test -n "$$FAILED" ; then \
echo "FAILED HTML-man sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \
fi; echo "PASSED HTML-man sanity check (checked $$CHECKED files)"; exit 0
@touch $@

# Note: many man-pages here have code samples and are mis-identified as C code
check-man-page: check-man-pages

# Man-pages may be pre-generated (srcdir), or re-built (builddir)
check-man-pages: $(MAN_MANS)
check-man-pages: .check-man-pages
.check-man-pages: $(MAN_MANS) Makefile
@FAILED=""; CHECKED=0; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \
for F in $(MAN_MANS) ; do \
CHECKED="`expr $$CHECKED + 1`"; \
Expand All @@ -1077,12 +1094,14 @@ check-man-pages: $(MAN_MANS)
echo "BUILDDIR:"; cd "$(abs_builddir)/" && file $$FAILED ; \
) >&2 ; exit 1; \
fi; echo "PASSED man-page sanity check (checked $$CHECKED files)"; exit 0
@touch $@

check-man-source: check-man-txt

# Note: (GNU) make can helpfully add VPATH to the short source filenames
# which we had listed above, so the "case" below handles two possibilities
check-man-txt: $(SRC_ALL_PAGES)
check-man-txt: .check-man-txt
.check-man-txt: $(SRC_ALL_PAGES) Makefile
@FAILED=""; CHECKED=0; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \
( cd $(abs_srcdir) ) || exit; \
for F in $(SRC_ALL_PAGES) ; do \
Expand All @@ -1095,8 +1114,9 @@ check-man-txt: $(SRC_ALL_PAGES)
done; if test -n "$$FAILED" ; then \
echo "FAILED man-source sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \
fi; echo "PASSED man-source sanity check (checked $$CHECKED files)"; exit 0
@touch $@

CLEANFILES = *-spellchecked .prep-src-docs *-prepped
CLEANFILES = *-spellchecked .prep-src-docs *-prepped .check-*

SUFFIXES = .txt-prepped .txt .html .$(MAN_SECTION_CMD_USR) .$(MAN_SECTION_API) .$(MAN_SECTION_CFG) .$(MAN_SECTION_CMD_SYS)

Expand Down Expand Up @@ -1314,8 +1334,21 @@ PREP_SRC = $(LINKMAN_INCLUDE_GENERATED) $(SRC_ALL_PAGES) asciidoc.conf
# NOTE: MKDIR_P may be defined via expanded $(top_builddir)/install-sh
# so should be run from $(abs_builddir) to be safe, as we jump around
# the build workspace
# NOTE: For DOCS_NO_MAN case we expect that the top-level Makefile caused
# parallel runs of several directories, so we can reasonably wait some
# time for the target file to just appear.
MAINTAINER_DOCS_PREP_MAN_DELAY = 60
prep-src-docs: $(abs_top_builddir)/docs/man/.prep-src-docs
$(abs_top_builddir)/docs/man/.prep-src-docs: $(PREP_SRC)
@cd "$(@D)" || exit ; \
if [ x"$(DOCS_NO_MAN)" = xtrue ] ; then \
if [ "$(MAINTAINER_DOCS_PREP_MAN_DELAY)" -gt 0 ] 2>/dev/null ; then \
echo " DOCS_NO_MAN BLOCK: $@ called in docs/man/Makefile : waiting for other thread to complete this target" ; \
W=0 ; while [ "$${W}" -lt "$(MAINTAINER_DOCS_PREP_MAN_DELAY)" ] && ( [ \! -e '$@' ] || [ x"`find $(PREP_SRC) \! -newer '$@' 2>/dev/null`" = x ] ) ; do sleep 1 ; W="`expr $$W + 1`"; done ; \
echo " DOCS_NO_MAN SKIP: $@ called in docs/man/Makefile : waited $$W seconds" ; \
fi ; \
exit 0 ; \
fi ; \
linkroot="$(abs_builddir)" ; \
MAN_SECTIONS_DEFAULT=false ; \
if [ x"$(MAN_SECTION_API)$(MAN_SECTION_CFG)$(MAN_SECTION_CMD_SYS)$(MAN_SECTION_CMD_USR)" = x3581 ] ; then \
Expand Down
12 changes: 11 additions & 1 deletion drivers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ if HAVE_LIBREGEX
AM_CFLAGS += $(LIBREGEX_CFLAGS)
endif

NUTSW_DRIVERLIST = dummy-ups clone clone-outlet apcupsd-ups skel
# Allow top-level Makefile override NUTSW_DRIVERLIST_DUMMY_UPS="dummy" to run
# a build scenario without this driver (it is in a different dependency)
# NOTE: Must be defaulted with EXEEXT to avoid rewrites by automake parser
# which defeat the purpose of it being optionally built via `make all/drivers`
# in top level.
NUTSW_DRIVERLIST_DUMMY_UPS = dummy-ups$(EXEEXT)
NUTSW_DRIVERLIST = $(NUTSW_DRIVERLIST_DUMMY_UPS) \
clone clone-outlet apcupsd-ups skel
SERIAL_DRIVERLIST = al175 bcmxcp belkin belkinunv bestfcom \
bestfortress bestuferrups bestups etapro everups \
gamatronic genericups isbmex liebert liebert-esp2 liebert-gxe masterguard metasys \
Expand Down Expand Up @@ -454,3 +461,6 @@ MAINTAINERCLEANFILES = Makefile.in .dirstamp
# the root Makefile.am takes care of that!
#clean-local:
# $(AM_V_at)rm -rf $(builddir)/.deps

# Helper for only the enabled libs to get built:
all-libs-local: $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) $(EXTRA_LTLIBRARIES)
2 changes: 2 additions & 0 deletions include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ FORCE:
# distribution
dist-hook:
$(AM_V_at)rm -f $(distdir)/nut_version.h

all-libs-local: nut_version.h
10 changes: 7 additions & 3 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Network UPS Tools: lib

# NOTE: Here we deliver metadata for third-party development to integrate
# their programs with NUT libraries. Actual libraries (code and recipes) are
# built in other directories, such as common, clients and tools/nut-scanner.

# Export certain values for ccache which NUT ci_build.sh can customize,
# to facilitate developer iteration re-runs of "make" later.
# At least GNU and BSD make implementations are okay with this syntax.
Expand All @@ -14,10 +18,10 @@ EXTRA_DIST = README.adoc
if WITH_DEV
if WITH_PKG_CONFIG
pkgconfig_DATA = libupsclient.pc libnutscan.pc libnutclient.pc libnutclientstub.pc
else
else !WITH_PKG_CONFIG
bin_SCRIPTS = libupsclient-config
endif
endif
endif !WITH_PKG_CONFIG
endif WITH_DEV

CLEANFILES = *-spellchecked README
MAINTAINERCLEANFILES = Makefile.in .dirstamp
6 changes: 3 additions & 3 deletions scripts/Windows/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

AM_CFLAGS = -I$(top_srcdir)/include

../include/nut_version.h: FORCE
+cd ../include/ && $(MAKE) $(AM_MAKEFLAGS) nut_version.h
$(top_builddir)/common/libcommon.la: FORCE
+@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)

EXTRA_DIST = \
winevent.mc \
Expand Down Expand Up @@ -63,7 +63,7 @@ if HAVE_WINDOWS
bin_PROGRAMS += nut halt

nut_SOURCES = wininit.c
nut_LDADD = ../../common/libcommon.la winevent.o
nut_LDADD = $(top_builddir)/common/libcommon.la winevent.o

halt_SOURCES = halt.c
endif HAVE_WINDOWS
Expand Down
5 changes: 4 additions & 1 deletion scripts/external_apis/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ endif ENABLE_EXTAPI_ENPHASE
spellcheck spellcheck-interactive spellcheck-sortdict:
+$(MAKE) -f $(top_builddir)/docs/Makefile $(AM_MAKEFLAGS) MKDIR_P="$(MKDIR_P)" builddir="$(builddir)" srcdir="$(srcdir)" top_builddir="$(top_builddir)" top_srcdir="$(top_srcdir)" SPELLCHECK_SRC="$(SPELLCHECK_SRC)" SPELLCHECK_SRCDIR="$(srcdir)" SPELLCHECK_BUILDDIR="$(builddir)" $@

CLEANFILES = *-spellchecked enphase/*-spellchecked \
CLEANFILES = *-spellchecked enphase/*-spellchecked

# Do not remove files generated from .in templates during mere "make check":
DISTCLEANFILES = \
enphase/enphase-monitor \
enphase/[email protected]

Expand Down
3 changes: 3 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,6 @@ MAINTAINERCLEANFILES = Makefile.in .dirstamp
# the root Makefile.am takes care of that!
#clean-local:
# $(AM_V_at)rm -rf $(builddir)/.deps

# Helper for only the enabled libs to get built:
all-libs-local: $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) $(EXTRA_LTLIBRARIES)
7 changes: 7 additions & 0 deletions tools/nut-scanner/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ libnutscan_la_SOURCES = scan_nut.c scan_nut_simulation.c scan_ipmi.c \
libnutscan_la_LIBADD = $(NETLIBS)
libnutscan_la_LIBADD += $(top_builddir)/drivers/libserial-nutscan.la

# Make sure generated sources are there when needed
scan_snmp.c: nutscan-snmp.h
scan_usb.c: nutscan-usb.h

if WITH_LIBLTDL
libnutscan_la_LIBADD += $(LIBLTDL_LIBS)
endif WITH_LIBLTDL
Expand Down Expand Up @@ -182,3 +186,6 @@ MAINTAINERCLEANFILES = Makefile.in .dirstamp
# the root Makefile.am takes care of that!
#clean-local:
# $(AM_V_at)rm -rf $(builddir)/.deps

# Helper for only the enabled libs to get built:
all-libs-local: $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) $(EXTRA_LTLIBRARIES)

0 comments on commit b7f3f95

Please sign in to comment.