@@ -84,6 +84,11 @@ SUBDIRS_ALL_LIBS_LOCAL = \
8484# (which used to cause us a lot of headache, building same things twice at
8585# the same time).
8686
87+ # For the intents and purposes of recursive-make calls, we have built
88+ # or updated include/nut_version.h before other targets in all-recursive
89+ # ## MAINTAINER_GENERATE_HEADER_DEBUG = yes
90+ # ## export NUT_VERSION_H_GENERATED = true
91+
8792# all all-recursive all-am-local all-local: all-fanout-maybe
8893all-recursive : all-fanout-maybe
8994
@@ -105,7 +110,10 @@ all-fanout-maybe:
105110 if [ x" $( SUBDIR_MAKE_VERBOSE) " != x0 ] ; then \
106111 echo " SUBDIR-MAKE $@ : implement optimization for parallel make as 'make all-fanout-subdirs'" ; \
107112 fi ; \
108- $(MAKE ) $(AM_MAKEFLAGS ) all-fanout-subdirs ;; \
113+ $(MAKE ) $(AM_MAKEFLAGS ) all-fanout-subdirs || exit ; \
114+ if [ x" $( SUBDIR_MAKE_VERBOSE) " != x0 ] ; then \
115+ echo " SUBDIR-MAKE $@ : optimization for parallel make as 'make all-fanout-subdirs' finished; now automake rules can follow up with default implementation of 'all-recursive' and/or 'all' (may try to regenerate some files again; should keep existing results though)" ; \
116+ fi ;; \
109117 * ) \
110118 if [ x" $( SUBDIR_MAKE_VERBOSE) " != x0 ] ; then \
111119 echo " SUBDIR-MAKE $@ : skip optimization for parallel make - we seem to run sequentially now, seen MAKEFLAGS='$( MAKEFLAGS) ' AM_MAKEFLAGS='$( AM_MAKEFLAGS) '" ; \
@@ -123,10 +131,10 @@ all-fanout-maybe:
123131# FIXME: Alas, we still tend to step on our toes when making everything at
124132# once from scratch, so still do benefit from pre-making the libraries:
125133all-fanout-staged :
126- +$(MAKE ) $(AM_MAKEFLAGS ) all/include
127- +$(MAKE ) $(AM_MAKEFLAGS ) all/common
128- +$(MAKE ) $(AM_MAKEFLAGS ) all-fanout-libs
129- +$(MAKE ) $(AM_MAKEFLAGS ) all-fanout-subdirs
134+ +$(MAKE ) $(AM_MAKEFLAGS ) NUT_VERSION_H_GENERATED=false all/include
135+ +$(MAKE ) $(AM_MAKEFLAGS ) NUT_VERSION_H_GENERATED=true all/common
136+ +$(MAKE ) $(AM_MAKEFLAGS ) NUT_VERSION_H_GENERATED=true all-fanout-libs
137+ +$(MAKE ) $(AM_MAKEFLAGS ) NUT_VERSION_H_GENERATED=true all-fanout-subdirs
130138
131139all-fanout-subdirs : $(SUBDIRS_ALL_RECURSIVE )
132140
@@ -190,12 +198,12 @@ SUBDIR_TGT_RULE = ( \
190198 [ x"$${TGT-}" != x ] || TGT="` echo ' $@' | awk -F/ ' {print $$1}' ` " ; \
191199 [ x"$${DIR-}" != x ] || DIR="` echo ' $@' | sed ' s,^[^/]*/,,' ` " ; \
192200 if [ x"$(SUBDIR_MAKE_VERBOSE ) " != x0 ] ; then \
193- echo " SUBDIR-MAKE STARTING: 'make $$TGT' in $$DIR ..." ; \
201+ echo " SUBDIR-MAKE STARTING $@ : 'make $${SUBDIR_TGT_MAKEFLAGS-} $$TGT' in $$DIR ..." ; \
194202 fi ; \
195203 cd "$(abs_builddir ) /$${DIR}" && \
196204 $(MAKE ) $(AM_MAKEFLAGS ) $${SUBDIR_TGT_MAKEFLAGS-} "$${TGT}" || { RES=$$? ; echo " SUBDIR-MAKE FAILURE: 'make $$TGT' in $$DIR" >&2 ; exit $$RES ; } ; \
197205 if [ x"$(SUBDIR_MAKE_VERBOSE ) " != x0 ] ; then \
198- echo " SUBDIR-MAKE SUCCESS: 'make $$TGT' in $$DIR" ; \
206+ echo " SUBDIR-MAKE SUCCESS $@ : 'make $${SUBDIR_TGT_MAKEFLAGS-} $$TGT' in $$DIR" ; \
199207 fi ; \
200208 )
201209
@@ -207,7 +215,8 @@ SUBDIR_TGT_RULE = ( \
207215
208216# ## Delivers: nut_version.h
209217all-libs-local/include :
210- +@$(SUBDIR_TGT_RULE )
218+ +@NUT_VERSION_H_GENERATED=false; export NUT_VERSION_H_GENERATED; \
219+ $(SUBDIR_TGT_RULE )
211220
212221# ## Delivers: libcommon.la libcommonclient.la libcommonstr.la libcommonstrjson.la
213222# ## (consume only one of these at a time!)
@@ -216,7 +225,8 @@ all-libs-local/include:
216225# ## Requires-ext: include/nut_version.h
217226# ## Requires-int: libparseconf.la libcommonclient.la
218227all-libs-local/common : all-libs-local/include
219- +@$(SUBDIR_TGT_RULE )
228+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
229+ $(SUBDIR_TGT_RULE )
220230
221231# ## Delivers: libupsclient.la libnutclient.la libnutclientstub.la
222232# ## Delivers: libupsclient-version.h
@@ -226,7 +236,8 @@ all-libs-local/common: all-libs-local/include
226236# ## Requires-ext: common/libparseconf.la
227237# ## Requires-int: libupsclient.la
228238all-libs-local/clients : all-libs-local/common
229- +@$(SUBDIR_TGT_RULE )
239+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
240+ $(SUBDIR_TGT_RULE )
230241
231242# ## Delivers: libdummy.la libdummy_serial.la libdummy_upsdrvquery.la
232243# ## Delivers: libdummy_mockdrv.la libserial-nutscan.la
@@ -236,7 +247,8 @@ all-libs-local/clients: all-libs-local/common
236247# ## Requires-int: libdummy.la libdummy_upsdrvquery.la
237248# ## Requires-int: libdummy_serial.la
238249all-libs-local/drivers : all-libs-local/common
239- +@$(SUBDIR_TGT_RULE )
250+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
251+ $(SUBDIR_TGT_RULE )
240252
241253# ## Delivers: libdriverstubusb.la
242254# ## LIB-Requires-ext: #COMMENTED-AWAY# common/libcommon.la
@@ -245,7 +257,8 @@ all-libs-local/drivers: all-libs-local/common
245257# ## Requires-ext: drivers/libdummy_mockdrv.la
246258# ## Requires-int: libdriverstubusb.la
247259all-libs-local/tests : all-libs-local/common
248- +@$(SUBDIR_TGT_RULE )
260+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
261+ $(SUBDIR_TGT_RULE )
249262
250263# ## Delivers: generated sources and/or headers for nut-scanner
251264# ## No dependencies: actually runs as part of autogen.sh but may be
@@ -265,7 +278,8 @@ all-libs-local/tools:
265278# ## however does directly use libupsclient-version.h
266279# ## for hints to find it at run-time
267280all-libs-local/tools/nut-scanner : all-libs-local/drivers all-libs-local/common all-libs-local/clients all-libs-local/tools
268- +@$(SUBDIR_TGT_RULE )
281+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
282+ $(SUBDIR_TGT_RULE )
269283
270284# Handle all SUBDIRS_ALL_RECURSIVE in a way that dependencies can be specified,
271285# and portably to different make program implementations. Note we may revisit
@@ -282,13 +296,16 @@ all-recursive/data:
282296 +@$(SUBDIR_TGT_RULE )
283297
284298all/include : all-libs-local/include
285- +@$(SUBDIR_TGT_RULE )
299+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
300+ $(SUBDIR_TGT_RULE )
286301
287302prep-src-docs/docs/man :
288- +@SUBDIR_TGT_MAKEFLAGS=' MAINTAINER_DOCS_PREP_MAN_DELAY=3' ; export SUBDIR_TGT_MAKEFLAGS; $(SUBDIR_TGT_RULE )
303+ +@SUBDIR_TGT_MAKEFLAGS=' MAINTAINER_DOCS_PREP_MAN_DELAY=3' ; export SUBDIR_TGT_MAKEFLAGS; \
304+ $(SUBDIR_TGT_RULE )
289305
290306prep-src-docs/docs :
291- +@DOCS_NO_MAN=true; export DOCS_NO_MAN; $(SUBDIR_TGT_RULE )
307+ +@DOCS_NO_MAN=true; export DOCS_NO_MAN; \
308+ $(SUBDIR_TGT_RULE )
292309
293310all/docs/man : prep-src-docs/docs/man
294311 +@$(SUBDIR_TGT_RULE )
@@ -325,15 +342,17 @@ all-recursive/docs: all/docs all/docs/man
325342
326343# ## Requires-int: libparseconf.la libcommonclient.la
327344all/common : all/include all-libs-local/common
328- +@$(SUBDIR_TGT_RULE )
345+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
346+ $(SUBDIR_TGT_RULE )
329347
330348# ## Requires-ext: common/libcommon.la common/libcommonclient.la
331349# ## Requires-ext: common/libparseconf.la
332350# ## Requires-ext: common/libcommonversion.la
333351# ## Requires-ext: common/libcommonstrjson.la
334352# ## Requires-int: libupsclient.la
335353all/clients : all/common all-libs-local/clients
336- +@$(SUBDIR_TGT_RULE )
354+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
355+ $(SUBDIR_TGT_RULE )
337356
338357# ## Summary of drivers/ subdir dependencies:
339358# ## Requires-ext: common/libcommon.la common/libparseconf.la
@@ -356,7 +375,8 @@ if SOME_DRIVERS
356375# in the default list - FIXME: configure.ac could tell us, so
357376# we could provide it for tests/NIT anyway...)
358377all/drivers : all-libs-local/clients all-libs-local/common all-libs-local/drivers
359- +@$(SUBDIR_TGT_RULE )
378+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
379+ $(SUBDIR_TGT_RULE )
360380
361381all-drivers : all/drivers
362382else !SOME_DRIVERS
@@ -368,18 +388,22 @@ else !SOME_DRIVERS
368388# should depend on both "dummy-ups" and the rest in so constrained
369389# "all/drivers". This allows to ultimately not order one after another.
370390dummy-ups$(EXEEXT ) /drivers : all-libs-local/clients all-libs-local/common all-libs-local/drivers
371- +@$(SUBDIR_TGT_RULE )
391+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
392+ $(SUBDIR_TGT_RULE )
372393
373394all/drivers : all/common all-libs-local/drivers
374- +@SUBDIR_TGT_MAKEFLAGS=' NUTSW_DRIVERLIST_DUMMY_UPS=dummy' ; export SUBDIR_TGT_MAKEFLAGS; $(SUBDIR_TGT_RULE )
395+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
396+ SUBDIR_TGT_MAKEFLAGS=' NUTSW_DRIVERLIST_DUMMY_UPS=dummy' ; export SUBDIR_TGT_MAKEFLAGS; \
397+ $(SUBDIR_TGT_RULE )
375398
376399all-drivers : dummy-ups$(EXEEXT ) /drivers all/drivers
377400endif !SOME_DRIVERS
378401
379402# ## Requires-ext: common/libcommon.la common/libparseconf.la
380403# ## Requires-ext: common/libcommonversion.la
381404all/server : all-libs-local/common
382- +@$(SUBDIR_TGT_RULE )
405+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
406+ $(SUBDIR_TGT_RULE )
383407
384408# ## LIB-Requires-ext: drivers/libserial-nutscan.la
385409# ## LIB-Requires-ext: common/libnutwincompat.la common/libcommonstr.la
@@ -389,18 +413,21 @@ all/server: all-libs-local/common
389413all/tools/nut-scanner : all-libs-local/include all-libs-local/common \
390414 all-libs-local/drivers all-libs-local/clients \
391415 all-libs-local/tools/nut-scanner
392- +@$(SUBDIR_TGT_RULE )
416+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
417+ $(SUBDIR_TGT_RULE )
393418
394419# only libnutscan is needed for nutconf,
395420# but we do wholesale subdir all-libs-local at the moment...
396421# ## Requires-ext: common/libcommon.la common/libnutconf.la
397422# ## Requires-ext: common/libcommonversion.la
398423# ## Requires-ext: tools/nut-scanner/libnutscan.la
399424all/tools/nutconf : all-libs-local/tools/nut-scanner all-libs-local/common
400- +@$(SUBDIR_TGT_RULE )
425+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
426+ $(SUBDIR_TGT_RULE )
401427
402428all-recursive/tools : all/tools/nutconf all/tools/nut-scanner
403- +@$(SUBDIR_TGT_RULE )
429+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
430+ $(SUBDIR_TGT_RULE )
404431
405432# Prereqs for NIT are runnable upsd, upsc, upsmon, dummy-ups, sample configs...
406433# For the actual "make check-NIT" runs - also python scripts and/or compiled
@@ -410,32 +437,38 @@ all-recursive/tools: all/tools/nutconf all/tools/nut-scanner
410437# But then we should also consider what is enabled by configure and what is not.
411438# Maybe we are doing a quick build not to be tested at all? :-/
412439all/tests/NIT : all/clients all/server all-drivers all-recursive/tools all-recursive/data
413- +@$(SUBDIR_TGT_RULE )
440+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
441+ $(SUBDIR_TGT_RULE )
414442
415443# ## LIB-Requires-ext: #COMMENTED-AWAY# common/libcommon.la
416444# ## Requires-ext: common/libcommon.la common/libnutconf.la
417445# ## Requires-ext: clients/libnutclient.la clients/libnutclientstub.la
418446# ## Requires-ext: drivers/libdummy_mockdrv.la
419447# ## Requires-int: libdriverstubusb.la
420448all/tests : all-libs-local/tests all-libs-local/drivers all-libs-local/common all-libs-local/clients
421- +@$(SUBDIR_TGT_RULE )
449+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
450+ $(SUBDIR_TGT_RULE )
422451
423452all-recursive/tests : all/tests/NIT all/tests
424- +@$(SUBDIR_TGT_RULE )
453+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
454+ $(SUBDIR_TGT_RULE )
425455
426456if HAVE_MINGW_RESGEN
427457if HAVE_WINDOWS
428458# ## Requires-ext: common/libcommon.la
429459# ## Requires-ext: common/libcommonversion.la
430460all/scripts/Windows : all-libs-local/common
431- +@$(SUBDIR_TGT_RULE )
461+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
462+ $(SUBDIR_TGT_RULE )
432463else !HAVE_WINDOWS
433464all/scripts/Windows :
434- +@$(SUBDIR_TGT_RULE )
465+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
466+ $(SUBDIR_TGT_RULE )
435467endif !HAVE_WINDOWS
436468else !HAVE_MINGW_RESGEN
437469all/scripts/Windows :
438- +@$(SUBDIR_TGT_RULE )
470+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
471+ $(SUBDIR_TGT_RULE )
439472endif !HAVE_MINGW_RESGEN
440473
441474# May rely on dstate.o as well as common libs
@@ -448,10 +481,12 @@ if WITH_REGENERATE_DMF_NUTSCAN
448481DMF_DEP_NUTSCAN += all-libs-local/tools/nut-scanner
449482endif WITH_REGENERATE_DMF_NUTSCAN
450483all/scripts/DMF : all-libs-local/drivers all-libs-local/common $(DMF_DEP_NUTSCAN )
451- +@$(SUBDIR_TGT_RULE )
484+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
485+ $(SUBDIR_TGT_RULE )
452486
453487all-recursive/scripts : all/scripts/Windows all/scripts/DMF
454- +@$(SUBDIR_TGT_RULE )
488+ +@NUT_VERSION_H_GENERATED=true; export NUT_VERSION_H_GENERATED; \
489+ $(SUBDIR_TGT_RULE )
455490
456491# ----------------------------------------------------------------------
457492# flags to pass to ./configure when calling "make distcheck" and "make
@@ -1588,6 +1623,7 @@ install-win-bundle-thirdparty:
15881623 if test -n " $$ ARCH" ; then export ARCH ; fi ; \
15891624 DESTDIR=' $(DESTDIR)' ; export DESTDIR ; \
15901625 ( cd ' $(DESTDIR)' || exit ; \
1626+ GREP=$(GREP ) ' EGREP=' $(EGREP ) ' \
15911627 DESTDIR=" " ' $(abs_top_srcdir)/scripts/Windows/dllldd.sh' dllldddir . \
15921628 | while read D ; do \
15931629 echo " DLL->bin $$ D" 2>&1 ; \
@@ -1596,6 +1632,7 @@ install-win-bundle-thirdparty:
15961632 ) || exit ; \
15971633 ( if test x" $( bindir) " = x" $( sbindir) " ; then exit 0 ; fi ; \
15981634 cd ' $(DESTDIR)/$(sbindir)' || exit ; \
1635+ GREP=$(GREP ) ' EGREP=' $(EGREP ) ' \
15991636 ' $(abs_top_srcdir)/scripts/Windows/dllldd.sh' dllldddir . \
16001637 | while read D ; do \
16011638 echo " DLL->sbin $$ D" 2>&1 ; \
@@ -1605,6 +1642,7 @@ install-win-bundle-thirdparty:
16051642 ( if test x" $( driverexecdir) " = x" $( bindir) " ; then exit 0 ; fi ; \
16061643 if test x" $( driverexecdir) " = x" $( sbindir) " ; then exit 0 ; fi ; \
16071644 cd ' $(DESTDIR)/$(driverexecdir)' || exit ; \
1645+ GREP=$(GREP ) ' EGREP=' $(EGREP ) ' \
16081646 ' $(abs_top_srcdir)/scripts/Windows/dllldd.sh' dllldddir . \
16091647 | while read D ; do \
16101648 echo " DLL->drv $$ D" 2>&1 ; \
@@ -1616,6 +1654,7 @@ install-win-bundle-thirdparty:
16161654 if test x" $( cgiexecdir) " = x" $( sbindir) " ; then exit 0 ; fi ; \
16171655 if test x" $( driverexecdir) " = x" $( cgiexecdir) " ; then exit 0 ; fi ; \
16181656 cd ' $(DESTDIR)/$(cgiexecdir)' || exit ; \
1657+ GREP=$(GREP ) ' EGREP=' $(EGREP ) ' \
16191658 ' $(abs_top_srcdir)/scripts/Windows/dllldd.sh' dllldddir . \
16201659 | while read D ; do \
16211660 echo " DLL->cgi $$ D" 2>&1 ; \
@@ -1627,6 +1666,7 @@ install-win-bundle-thirdparty:
16271666 if test x" $( libexecdir) " = x" $( driverexecdir) " ; then exit 0 ; fi ; \
16281667 if test x" $( libexecdir) " = x" $( cgiexecdir) " ; then exit 0 ; fi ; \
16291668 cd ' $(DESTDIR)/$(libexecdir)' || exit ; \
1669+ GREP=$(GREP ) ' EGREP=' $(EGREP ) ' \
16301670 ' $(abs_top_srcdir)/scripts/Windows/dllldd.sh' dllldddir . \
16311671 | while read D ; do \
16321672 echo " DLL->libexec $$ D" 2>&1 ; \
0 commit comments