Skip to content

Commit 147cde8

Browse files
authored
Merge 9b36e2c into bf64358
2 parents bf64358 + 9b36e2c commit 147cde8

5 files changed

Lines changed: 64 additions & 10 deletions

File tree

Makefile.am

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# include directory for aclocal
1313
ACLOCAL_AMFLAGS = -I m4
1414

15+
CLEANFILES =
16+
DISTCLEANFILES =
17+
MAINTAINERCLEANFILES =
18+
1519
# Autotools' SUBDIRS (our values are listed below) allow for powerful recursive
1620
# recipe automation, with one notable weakness: the dirs are processed in a
1721
# loop sequentially, even in parallel builds (each such sub-make is parallel
@@ -91,13 +95,24 @@ SUBDIRS_ALL_LIBS_LOCAL = \
9195
#all all-recursive all-am-local all-local: all-fanout-maybe
9296
all-recursive: all-fanout-maybe
9397

98+
all: all-fanout-cleanup
99+
100+
# Run as part of "all", but after the autotools-standard "all-recursive"
101+
# where we quiesce nut_version.h regeneration attempts for each subdir
102+
all-fanout-cleanup: all-recursive
103+
@rm -f include/.all.nut_version-generated.timestamp \
104+
clients/.all.libupsclient_version-generated.timestamp
105+
94106
# Verbosity for fanout rule tracing; 0/1 (or "default" that may auto-set
95107
# to 0 or 1 in some rules below)
96108
SUBDIR_MAKE_VERBOSE = default
97109

98110
# Run the standard build if going sequential (or with unknown MAKEFLAGS),
99111
# or fanout if parallel (presuming GNU/BSD/Sun make at least):
112+
CLEANFILES += include/.all.nut_version-generated.timestamp clients/.all.libupsclient_version-generated.timestamp
100113
all-fanout-maybe: @dotMAKE@
114+
@rm -f include/.all.nut_version-generated.timestamp \
115+
clients/.all.libupsclient_version-generated.timestamp
101116
+@if [ x"$(NUT_MAKE_SKIP_FANOUT)" = xtrue ] ; then \
102117
if [ x"$(SUBDIR_MAKE_VERBOSE)" != x0 ] ; then \
103118
echo " SUBDIR-MAKE $@: skip optimization for parallel make - NUT_MAKE_SKIP_FANOUT is set" ; \
@@ -216,6 +231,10 @@ SUBDIR_TGT_RULE = ( \
216231
all-libs-local/include: @dotMAKE@
217232
+@NUT_VERSION_H_GENERATED=false; export NUT_VERSION_H_GENERATED; \
218233
$(SUBDIR_TGT_RULE)
234+
@[ -s include/nut_version.h ]
235+
@touch -r include/nut_version.h -d '-10 seconds' include/.all.nut_version-generated.timestamp && exit ; \
236+
touch -d '1970-01-01' include/.all.nut_version-generated.timestamp && exit ; \
237+
touch include/.all.nut_version-generated.timestamp
219238

220239
### Delivers: libcommon.la libcommonclient.la libcommonstr.la libcommonstrjson.la
221240
### (consume only one of these at a time!)
@@ -239,6 +258,10 @@ all-libs-local/common: all-libs-local/include @dotMAKE@
239258
all-libs-local/clients: all-libs-local/common @dotMAKE@
240259
+@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
241260
$(SUBDIR_TGT_RULE)
261+
@[ -s clients/libupsclient-version.h ]
262+
@touch -r clients/libupsclient-version.h -d '-10 seconds' clients/.all.libupsclient_version-generated.timestamp && exit ; \
263+
touch -d '1970-01-01' clients/.all.libupsclient_version-generated.timestamp && exit ; \
264+
touch clients/.all.libupsclient_version-generated.timestamp
242265

243266
### Delivers: libdummy_main.la libdummy_serial.la libdummy_upsdrvquery.la
244267
### Delivers: libdummy_mockdrv.la libserial-nutscan.la
@@ -630,8 +653,8 @@ distcleancheck:
630653
realclean: maintainer-clean
631654

632655
# Files made by our targets:
633-
CLEANFILES = *-spellchecked *.adoc-parsed cppcheck*.xml config.log.inplace-outer
634-
DISTCLEANFILES = ChangeLog
656+
CLEANFILES += *-spellchecked *.adoc-parsed cppcheck*.xml config.log.inplace-outer
657+
DISTCLEANFILES += ChangeLog
635658

636659
# Most of the files generated by custom rules in the configure script
637660
# or by autogen.sh are cleaned by the Makefile.am in their directories.
@@ -647,7 +670,7 @@ DISTCLEANFILES += include/config.h.in~
647670
# from their installation, or made by `automake` etc. on the system
648671
# which generates `configure`; rebuilding NUT after deleting these
649672
# requires `autogen.sh` script to be re-run (and tools available):
650-
MAINTAINERCLEANFILES = INSTALL
673+
MAINTAINERCLEANFILES += INSTALL
651674
MAINTAINERCLEANFILES += aclocal.m4 config.guess config.sub
652675
MAINTAINERCLEANFILES += configure
653676
MAINTAINERCLEANFILES += depcomp install-sh ltmain.sh test-driver ar-lib
@@ -1048,10 +1071,13 @@ ChangeLog.adoc: ChangeLog @dotMAKE@
10481071
+cd $(abs_top_builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) ../ChangeLog.adoc
10491072

10501073
nut_version.h include/nut_version.h: @dotMAKE@
1074+
@rm -f include/.all.nut_version-generated.timestamp
10511075
+cd $(abs_top_builddir)/include && $(MAKE) $(AM_MAKEFLAGS) nut_version.h
10521076

1077+
# May depend on nut_version.h at least when we ENABLE_SHARED_PRIVATE_LIBS
10531078
# May involve (re-)build of libupsclient.la
1054-
libupsclient-version.h clients/libupsclient-version.h: @dotMAKE@
1079+
libupsclient-version.h clients/libupsclient-version.h: include/nut_version.h @dotMAKE@
1080+
@rm -f clients/.all.libupsclient_version-generated.timestamp
10551081
+cd $(abs_top_builddir)/include && $(MAKE) $(AM_MAKEFLAGS) libupsclient-version.h
10561082

10571083
tools/gitlog2changelog.py: tools/gitlog2changelog.py.in @dotMAKE@

clients/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.all.libupsclient_version-generated.timestamp
12
/libupsclient-version.h
23
/libupsclient-version.h.tmp*
34
/upsimage.cgi

clients/Makefile.am

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,27 @@ endif HAVE_WINDOWS
201201
# dlname='libupsclient-6.dll'
202202
# library_names='libupsclient.dll.a'
203203
# libdir='//lib'
204+
# Note that volatile dependencies like nut_version.h can cause re-evaluation
205+
# of the libupsclient.la goal even if ultimately nothing has changed, and so
206+
# cause needless evaluations of libupsclient-version.h. We try a couple of
207+
# ways to skip this rebuild noise for common NUT parallel `make -j N all` runs.
204208
CLEANFILES += libupsclient-version.h libupsclient-version.h.tmp*
205209
libupsclient-version.h: libupsclient.la
206-
@echo " GENERATE-HEADER $@" ; \
210+
@if [ -s '$@' -a -s '$?' ] ; then \
211+
if test -n "`find '$@' -newer '$?' 2>/dev/null`" ; then \
212+
if [ x"$(MAINTAINER_GENERATE_HEADER_DEBUG)" = xyes ] ; then \
213+
echo "=== SKIP (include) $@ (libupsclient.la is older than the generated file - not remade when re-evaluated)" >&2; \
214+
fi ; \
215+
exit 0; \
216+
fi ; \
217+
if test -n "`find '$@' -newer '.all.libupsclient_version-generated.timestamp' 2>/dev/null`" ; then \
218+
if [ x"$(MAINTAINER_GENERATE_HEADER_DEBUG)" = xyes ] ; then \
219+
echo "=== SKIP (include) $@ (.all.libupsclient_version-generated.timestamp was made in this larger run and is older than the generated file)" >&2; \
220+
fi ; \
221+
exit 0 ; \
222+
fi ; \
223+
fi ; \
224+
echo " GENERATE-HEADER $@" ; \
207225
RES=0; \
208226
dlname_filter() { sed -e 's/^[^=]*=//' -e 's/^"\(.*\)"$$/\1/' -e 's/^'"'"'\(.*\)'"'"'$$/\1/' ; }; \
209227
SOFILE_LIBUPSCLIENT="`$(EGREP) '^dlname' '$?' | dlname_filter`" \

include/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/config.h
22
/config.h.in
3+
/.all.nut_version-generated.timestamp
34
/nut_version.h
45
/nut_version.h.tmp*
56
/stamp-h1

include/Makefile.am

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ MAINTAINERCLEANFILES = Makefile.in .dirstamp
4545
# (e.g. a commit tagged as 2.8.3-rc5 can have its own NUT_VERSION based
4646
# on 2.8.2-something, but is assumed as a pre-release for 2.8.3 SEMVER)
4747
nut_version.h: @FORCE_NUT_VERSION@
48-
@if [ -s '$@' ] && ( [ x"$(NUT_VERSION_H_GENERATED)" = xtrue ] || [ x"$${NUT_VERSION_H_GENERATED}" = xtrue ] ) ; then \
49-
if [ x"$(MAINTAINER_GENERATE_HEADER_DEBUG)" = xyes ] ; then \
50-
echo "=== SKIP (include) $@ (NUT_VERSION_H_GENERATED makevar=$(NUT_VERSION_H_GENERATED) shellvar=$${NUT_VERSION_H_GENERATED})" >&2; \
48+
@if [ -s '$@' ] ; then \
49+
if [ x"$(NUT_VERSION_H_GENERATED)" = xtrue ] || [ x"$${NUT_VERSION_H_GENERATED}" = xtrue ] ; then \
50+
if [ x"$(MAINTAINER_GENERATE_HEADER_DEBUG)" = xyes ] ; then \
51+
echo "=== SKIP (include) $@ (NUT_VERSION_H_GENERATED makevar=$(NUT_VERSION_H_GENERATED) shellvar=$${NUT_VERSION_H_GENERATED})" >&2; \
52+
fi ; \
53+
exit 0 ; \
5154
fi ; \
52-
exit 0 ; \
53-
fi ; \
55+
if test -n "`find '$@' -newer '.all.nut_version-generated.timestamp' 2>/dev/null`" ; then \
56+
if [ x"$(MAINTAINER_GENERATE_HEADER_DEBUG)" = xyes ] ; then \
57+
echo "=== SKIP (include) $@ (.all.nut_version-generated.timestamp was made in this larger run and is older than the generated file)" >&2; \
58+
fi ; \
59+
exit 0 ; \
60+
fi ; \
61+
fi; \
5462
if [ x"$(MAINTAINER_GENERATE_HEADER_DEBUG)" = xyes ] ; then \
5563
echo " GENERATE-HEADER $@ (NUT_VERSION_H_GENERATED makevar=$(NUT_VERSION_H_GENERATED) shellvar=$${NUT_VERSION_H_GENERATED})"; \
5664
else \

0 commit comments

Comments
 (0)