Followup diff to mk that builds subdirs in parallel instead of a serial
shell loop. Like the parent diff, this is just a lightly tested proof of
concept. In particular the '===> subdir' printouts are not quite so
useful if commands are output out of order.
---
share/mk/bsd.subdir.mk | 92 +++++++++++++++++++-----------------------
1 file changed, 41 insertions(+), 51 deletions(-)
diff --git a/share/mk/bsd.subdir.mk b/share/mk/bsd.subdir.mk
index 062defef7e1..8a4106e5b3e 100644
--- a/share/mk/bsd.subdir.mk
+++ b/share/mk/bsd.subdir.mk
@@ -10,56 +10,53 @@
SKIPDIR?=
_SUBDIRUSE: .USE
-.if defined(SUBDIR)
- @for entry in ${SUBDIR}; do \
- set -e; if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
- _newdir_="$${entry}.${MACHINE}"; \
- else \
- _newdir_="$${entry}"; \
- fi; \
- if test X"${_THISDIR_}" = X""; then \
- _nextdir_="$${_newdir_}"; \
- else \
- _nextdir_="$${_THISDIR_}/$${_newdir_}"; \
- fi; \
- _makefile_spec_=""; \
- if [ -e ${.CURDIR}/$${_newdir_}/Makefile.bsd-wrapper ]; then \
- _makefile_spec_="-f Makefile.bsd-wrapper"; \
- fi; \
- subskipdir=''; \
- for skipdir in ${SKIPDIR}; do \
- subentry=$${skipdir#$${entry}}; \
- if [ X$${subentry} != X$${skipdir} ]; then \
- if [ X$${subentry} = X ]; then \
- echo "($${_nextdir_} skipped)"; \
- break; \
- fi; \
- subskipdir="$${subskipdir} $${subentry#/}"; \
- fi; \
- done; \
- if [ X$${skipdir} = X -o X$${subentry} != X ]; then \
- echo "===> $${_nextdir_}"; \
- ${MAKE} -C ${.CURDIR}/$${_newdir_} \
- SKIPDIR="$${subskipdir}" \
- $${_makefile_spec_} _THISDIR_="$${_nextdir_}" \
- ${MAKE_FLAGS} \
- ${.TARGET:S/^real//}; \
- fi; \
- done
-${SUBDIR}::
- @set -e; if test -d ${.CURDIR}/${.TARGET}.${MACHINE}; then \
- _newdir_=${.TARGET}.${MACHINE}; \
+.if defined(SUBDIR)
+_SUBDIRUSE: ${SUBDIR}
+. for t in all cleandir includes depend obj tags manlint
+. if make($t)
+. for dir in ${SUBDIR}
+${dir}::
+ @entry=${dir}; \
+ set -e; if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
+ _newdir_="$${entry}.${MACHINE}"; \
+ else \
+ _newdir_="$${entry}"; \
+ fi; \
+ if test X"${_THISDIR_}" = X""; then \
+ _nextdir_="$${_newdir_}"; \
else \
- _newdir_=${.TARGET}; \
+ _nextdir_="$${_THISDIR_}/$${_newdir_}"; \
fi; \
_makefile_spec_=""; \
- if [ -f ${.CURDIR}/$${_newdir_}/Makefile.bsd-wrapper ]; then \
+ if [ -e ${.CURDIR}/$${_newdir_}/Makefile.bsd-wrapper ]; then \
_makefile_spec_="-f Makefile.bsd-wrapper"; \
fi; \
- echo "===> $${_newdir_}"; \
- exec ${MAKE} -C ${.CURDIR}/$${_newdir_} ${MAKE_FLAGS} \
- $${_makefile_spec_} _THISDIR_="$${_newdir_}" all
+ subskipdir=''; \
+ for skipdir in ${SKIPDIR}; do \
+ subentry=$${skipdir#$${entry}}; \
+ if [ X$${subentry} != X$${skipdir} ]; then \
+ if [ X$${subentry} = X ]; then \
+ echo "($${_nextdir_} skipped)"; \
+ break; \
+ fi; \
+ subskipdir="$${subskipdir} $${subentry#/}"; \
+ fi; \
+ done; \
+ if [ X$${skipdir} = X -o X$${subentry} != X ]; then \
+ echo "===> $${_nextdir_}"; \
+ ${MAKE} -C ${.CURDIR}/$${_newdir_} \
+ SKIPDIR="$${subskipdir}" \
+ $${_makefile_spec_} _THISDIR_="$${_nextdir_}" \
+ ${MAKE_FLAGS} \
+ ${t:S/^real//}; \
+ fi
+. if !target($t)
+$t: _SUBDIRUSE
+. endif
+. endfor
+. endif
+. endfor
.endif
.if !target(install)
@@ -74,13 +71,6 @@ maninstall: afterinstall
afterinstall: realinstall
realinstall: beforeinstall _SUBDIRUSE
.endif
-
-
-.for t in all cleandir includes depend obj tags manlint
-. if !target($t)
-$t: _SUBDIRUSE
-. endif
-.endfor
.if !target(regress) && empty(.TARGETS:Mall)
regress: _SUBDIRUSE
.endif
--
2.23.0
--
Lauri Tirkkonen | lotheac @ IRCnet